MCPcopy Index your code
hub / github.com/duan602728596/antd-schema-form

github.com/duan602728596/antd-schema-form @v5.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.1.0 ↗ · + Follow
172 symbols 392 edges 64 files 13 documented · 8% updated 17mo agov5.1.0 · 2025-01-22★ 1739 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

antd-schema-form

NPM version NPM version NPM version NPM version

antd-schema-form基于Ant Design,可以通过JSON Schema配置快速生成可交互的表单。

这个Demo简单的展示了通过配置schema.json构建一个表单。

开始使用

  1. React的版本>=16.7.0
  2. 组件的使用:

```javascript import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import SchemaForm, { getKeysFromObject, // 获取schema.json下所有的key getObjectFromValue, // object对象,格式化成表单需要的值 getValueFromObject // 从form获取到的表单的值,格式化成object对象 } from 'antd-schema-form'; import 'antd-schema-form/style/antd-schema-form.css'; // 引入样式

// json schema const json = { id: '$root', type: 'object', title: '$root', properties: {} };

ReactDOM.render( , document.getElementById('app') ); ```

API

参数 说明 类型
json json schema,必需 object
value 表单的值 object
onOk 表单的确认事件 (form: object, value: object, keys: Array<string>) => void
onCancel 表单的取消事件 (form: object, keys: Array<string>) => void
okText 确认按钮文字 string
cancelText 取消按钮文字 string
footer 自定义底部内容,onOk事件参考 (form: object) => React.Node
customComponent 自定义渲染组件,参考 object
customTableRender 自定义表格列渲染组件,参考 object
languagePack 语言配置,参考 object
formOptions Form的参数,参考 object

json schema配置

自定义渲染组件

按需加载组件

开发和测试

  • 运行命令npm run dev,在浏览器中输入http://127.0.0.1:5050查看demo并开发。
  • 运行命令npm run buildnpm run test,在浏览器中输入http://127.0.0.1:6060运行测试用例。

Extension points exported contracts — how you extend this code

FormObjectProps (Interface)
* 当类型为object时的组件渲染 * json schema的属性包括:id, type, title, description, properties, required
src/components/FormObject/FormObject.tsx
SchemaFormProps (Interface)
(no doc)
src/SchemaForm.tsx
CustomComponentFuncArgs (Interface)
(no doc)
src/types.d.ts
ObjectEntriesFunc (Interface)
(no doc)
src/utils/lodash.ts
FormBooleanProps (Interface)
* 当类型为boolean时的组件渲染 * json schema的属性包括:id, type, title, description * * 扩展属性前必须加上"$" * 扩展属性包括:componentType
src/components/FormBoolean/FormBoolean.tsx
CustomTableRenderFuncArgs (Interface)
(no doc)
src/types.d.ts
ObjectFromEntriesFunc (Interface)
(no doc)
src/utils/lodash.ts
FormStringProps (Interface)
* 当类型为string时的组件渲染 * json schema的属性包括:id, type, title, description, pattern, minLength, maxLength, enum * * 扩展属性前必须加上
src/components/FormString/FormString.tsx

Core symbols most depended-on inside this repo

sleep
called by 20
test/tests/utils.js
isNil
called by 15
src/utils/lodash.ts
styleName
called by 15
src/utils/styleName.ts
template
called by 12
src/utils/template.ts
isNumber
called by 8
src/utils/lodash.ts
createReactElement
called by 6
src/utils/createReactElement.ts
getKeysFromObject
called by 5
src/utils/getKeysFromObject.ts
triggerChange
called by 4
src/components/FormArray/TableComponent.tsx

Shape

Function 154
Interface 18

Languages

TypeScript100%

Modules by API surface

src/components/FormArray/TableComponent.tsx22 symbols
src/components/custom/custom.tsx14 symbols
src/utils/lodash.ts11 symbols
test/tests/string/hasValue.js9 symbols
src/types.d.ts8 symbols
src/components/FormObject/FormObject.tsx8 symbols
test/tests/string/verification.js7 symbols
test/tests/number/verification.js7 symbols
test/tests/string/componentRendering.js5 symbols
test/tests/number/hasValue.js5 symbols
test/tests/array/hasValue.js5 symbols
src/components/FormObject/OneOf.tsx5 symbols

For agents

$ claude mcp add antd-schema-form \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page