@gravity-ui/dynamic-forms

中文文档
6.1.0发布于 2026/11/17MITTypeScriptESM + CJS近 30 天下载 2.4万

English · Русский

原始使用文档
文档目录7 节
  1. Install
  2. Contents
  3. What it is
  4. How it works
  5. Dependencies
  6. I18N
  7. Development

@gravity-ui/dynamic-forms · npm package CI storybook

English · Русский

A form renderer on top of JSON Schema and react-final-form. A single schema describes both the value and how it is rendered: validation rules are standard Draft-07 keywords, and what a node is drawn with is the nodeParameters extension.

  • Entry point: @gravity-ui/dynamic-forms.
  • Status: stable API.
  • Two layers: core (headless engine) and kit (ready-made entities and layouts on @gravity-ui/uikit).

The previous DynamicField / DynamicView API is available from @gravity-ui/dynamic-forms/deprecated. SchemaRenderer imports from the removed /unstable entry point move to the package root. See the migration guide for the full transition and docs/deprecated for the previous API documentation.

Install

npm install --save-dev @gravity-ui/dynamic-forms

Contents

  • How to use — quick start, the name prop, modes, what to pick.
  • API reference — components, hooks, props, constants, utilities, kit exports, types.
  • Schema — nodeParameters, flags, annotations, keywords, stringNumber, $ref.
  • Runtime — node lifecycle, value coercion, validation, errors, events, patches.
  • Kit — layouts, entity catalog, service components, styles.
  • Extension — custom entities, layouts, validators, config, standalone renderer.
  • Migration — moving from the previous main API or /unstable, converting Spec, compatibility through /deprecated.
  • Caveats and limitations — code-verified discrepancies, limitations and bugs.

What it is

src/lib is a form engine where both the form and the values overview are built from a single JSON Schema. The core layer has no controls of its own: everything rendered comes from the config. Validation runs through json-schema-library (Draft-07) plus the custom stringNumber keyword. The kit layer provides a ready registry: 30 entity keys across 6 node types, 7 layout keys, service components, the useExpanded hook, error texts and the specToJsonSchema converter from the old Spec format.

How it works

  1. Schema and config. useSchemaRenderer clones schema and stores state in a service field with a validator.
  2. Nodes. SchemaRendererNode takes the subschema by pointer, registers a final-form field, picks entity and layout.
  3. Change. A value edit, via validateFields, triggers only the service field validator.
  4. Errors. The validator spreads errors by name into srState.errors; nodes with a changed message re-render.
  5. Imperative. useSchemaRendererTools patches the schema and adds external errors, restarting validation.

Dependencies

PackageRoleWhy
react / react-dom / react-ispeer18, 19. Rendering.
final-form / react-final-formpeerForm, fields, submit, subscriptions.
@gravity-ui/uikitpeerVersion 8. Kit controls: TextInput, Select, Checkbox, etc.
json-schema-libraryruntimeDraft-07 validation and the custom stringNumber keyword.
decimal.jsruntimeNumber comparison and scale in stringNumber and *_with_scale.
@gravity-ui/date-components, date-utilsruntimeDateInput and DateValue.
@gravity-ui/iconsruntimeiconName in Alert, Label, TextContent.
@gravity-ui/i18nruntimeLocalization of error texts.
@bem-react/classname, lodash, uuidruntimeClasses, utilities, keys.
MonacoexternalNot bundled. Passed via userContext.MonacoEditor.

I18N

Certain components include text tokens (words and phrases) that are available in two languages: en (the default) and ru. To set the language, use the configure function:

// index.js

import {configure, Lang} from '@gravity-ui/dynamic-forms';

configure({lang: Lang.Ru});

Development

To start the development server with storybook execute the following command:

npm ci
npm run dev

版本与发布记录

@gravity-ui/dynamic-forms 共发布 139 个版本,首次发布于 2023/03/14;过去 12 个月发布了 45 个版本。

版本发布日期距今
6.1.0latest2026/11/17今天
5.40.0untagged2026/11/17今天
5.39.02026/11/161 天前
5.38.12026/11/107 天前
6.0.02026/11/107 天前
5.38.02026/10/2325 天前

其他发布通道:beta → 5.0.0-beta.0,untagged → 5.40.0。

关于 @gravity-ui/dynamic-forms 的常见问题

@gravity-ui/dynamic-forms 是什么?

English · Русский

如何安装 @gravity-ui/dynamic-forms?

在项目目录运行 npm install @gravity-ui/dynamic-forms,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-is(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)、final-form(^4.20.2)、react-final-form(^6.5.3)、@gravity-ui/uikit(^8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gravity-ui/dynamic-forms 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gravity-ui/dynamic-forms 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gravity-ui/dynamic-forms 可以商用吗?

@gravity-ui/dynamic-forms 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gravity-ui/dynamic-forms 的下载量有多少?

根据 npm 官方下载统计,@gravity-ui/dynamic-forms 在 2026/10/17 – 2026/11/15 这 30 天内被下载 23,717 次,日均约 791 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gravity-ui/dynamic-forms 还在维护吗?

最新版本 6.1.0 发布于 2026/11/17(今天);至今共发布 139 个版本,其中过去 12 个月发布了 45 个;首次发布于 2023/03/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。