@xbeeant/form-engine-designer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -66
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,69 +1,78 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
export default tseslint.config([
|
|
16
|
-
globalIgnores(['dist']),
|
|
17
|
-
{
|
|
18
|
-
files: ['**/*.{ts,tsx}'],
|
|
19
|
-
extends: [
|
|
20
|
-
// Other configs...
|
|
21
|
-
|
|
22
|
-
// Remove tseslint.configs.recommended and replace with this
|
|
23
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
24
|
-
// Alternatively, use this for stricter rules
|
|
25
|
-
...tseslint.configs.strictTypeChecked,
|
|
26
|
-
// Optionally, add this for stylistic rules
|
|
27
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
28
|
-
|
|
29
|
-
// Other configs...
|
|
30
|
-
],
|
|
31
|
-
languageOptions: {
|
|
32
|
-
parserOptions: {
|
|
33
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
34
|
-
tsconfigRootDir: import.meta.dirname,
|
|
35
|
-
},
|
|
36
|
-
// other options...
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
])
|
|
1
|
+
# @xbeeant/form-engine-designer
|
|
2
|
+
|
|
3
|
+
`@xbeeant/form-engine` 的 Schema 可视化设计器。
|
|
4
|
+
|
|
5
|
+
提供组件面板(Palette)、画布(Canvas)与属性面板(PropertyPanel),拖拽生成符合协议规范的 Schema——布局节点(card / tabs / grid 等)的 Key 不会进入数据路径。内置 antd 控件目录与属性编辑器,开箱即用。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @xbeeant/form-engine-designer @xbeeant/form-engine @xbeeant/form-engine-ui
|
|
40
11
|
```
|
|
41
12
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
import
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
reactDom.configs.recommended,
|
|
59
|
-
],
|
|
60
|
-
languageOptions: {
|
|
61
|
-
parserOptions: {
|
|
62
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
63
|
-
tsconfigRootDir: import.meta.dirname,
|
|
64
|
-
},
|
|
65
|
-
// other options...
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
])
|
|
13
|
+
peerDependencies:`antd >= 5`、`react >= 18`、`react-dom >= 18`、`dayjs >= 1.11`。
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Designer } from '@xbeeant/form-engine-designer';
|
|
19
|
+
import { useRef } from 'react';
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<Designer
|
|
24
|
+
schema={initialSchema}
|
|
25
|
+
onSchemaChange={(schema) => console.log(schema)}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
69
29
|
```
|
|
30
|
+
|
|
31
|
+
`Designer` 默认使用 `@xbeeant/form-engine-ui` 的 `registerAntdUI` 注册控件、`widgetSchemas` 提供属性描述符;传入自定义 `registerUI` / `propertySchemaMap` 即可接入其它 UI 库。
|
|
32
|
+
|
|
33
|
+
## Designer Props
|
|
34
|
+
|
|
35
|
+
| Prop | 类型 | 说明 |
|
|
36
|
+
| :--- | :--- | :--- |
|
|
37
|
+
| `schema` | `NexusSchema` | 初始 Schema |
|
|
38
|
+
| `onSchemaChange` | `(schema: NexusSchema) => void` | Schema 变更回调 |
|
|
39
|
+
| `propertySchemaMap` | `PropertySchemaMap` | widget 名 → 属性描述符映射(默认 `widgetSchemas`,可按 widget 名覆盖) |
|
|
40
|
+
| `registerUI` | `(engine: NexusEngine) => void` | UI 注册函数(默认 `registerAntdUI`) |
|
|
41
|
+
| `fields` | `FieldDef[]` | 外部字段列表(palette 增加「字段列表」分组) |
|
|
42
|
+
| `widgetCatalog` | `CatalogItem[]` | 额外 widget 目录项(同名覆盖内置) |
|
|
43
|
+
| `layoutCatalog` | `CatalogItem[]` | 额外 layout 目录项(同名覆盖内置) |
|
|
44
|
+
|
|
45
|
+
## 导出
|
|
46
|
+
|
|
47
|
+
### 组件与上下文
|
|
48
|
+
|
|
49
|
+
- `Designer` — 设计器主组件
|
|
50
|
+
- `DesignerProvider` / `useDesigner` / `DesignerContextValue` — 设计器上下文
|
|
51
|
+
- `Palette` / `Canvas` / `PropertyPanel` — 三大面板
|
|
52
|
+
|
|
53
|
+
### Schema 工具(schemaUtils)
|
|
54
|
+
|
|
55
|
+
| 函数 | 说明 |
|
|
56
|
+
| :--- | :--- |
|
|
57
|
+
| `addChildToSchema` | 向指定节点添加子节点 |
|
|
58
|
+
| `removeNodeFromSchema` | 移除节点 |
|
|
59
|
+
| `updateNodeInSchema` / `updateNodeWithNesting` | 更新节点(支持嵌套结构) |
|
|
60
|
+
| `getNodeAtProperties` | 按路径获取节点 |
|
|
61
|
+
| `flattenNodeForPropertyEditor` | 展平节点供属性编辑器使用 |
|
|
62
|
+
| `collectDataFieldPaths` / `collectDataFieldOptions` | 收集数据字段路径 / 选项 |
|
|
63
|
+
|
|
64
|
+
### 目录
|
|
65
|
+
|
|
66
|
+
- `widgetCatalog` / `layoutCatalog` — 内置控件与布局目录项
|
|
67
|
+
|
|
68
|
+
### 类型
|
|
69
|
+
|
|
70
|
+
- `CatalogItem`、`DesignerMode`、`FieldDef`、`SchemaPath`、`DesignerProps`、`DesignerContextValue`
|
|
71
|
+
|
|
72
|
+
## 关联包
|
|
73
|
+
|
|
74
|
+
| 包 | 说明 |
|
|
75
|
+
| :--- | :--- |
|
|
76
|
+
| `@xbeeant/form-engine` | 表单引擎核心(纯 TypeScript) |
|
|
77
|
+
| `@xbeeant/form-engine-react` | React 渲染适配 |
|
|
78
|
+
| `@xbeeant/form-engine-ui` | Ant Design 控件与布局库(设计器默认 UI) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbeeant/form-engine-designer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -53,10 +53,11 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@xbeeant/form-engine": "^0.0.
|
|
57
|
-
"@xbeeant/form-engine-ui": "^0.0.
|
|
56
|
+
"@xbeeant/form-engine": "^0.0.2",
|
|
57
|
+
"@xbeeant/form-engine-ui": "^0.0.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"vitest": "^4.1.10"
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "5e640d99e81bec24182061a9f431c39647e562dd"
|
|
62
63
|
}
|