一种描述前端组件的协议,基于 Formily Schema 2.0,类 JSON Schema 风格。
1interface ISchema {
2 type: 'void' | 'string' | 'number' | 'object' | 'array';
3 name?: string;
4 title?: any;
5 // 包装器组件
6 ['x-decorator']?: string;
7 // 包装器组件属性
8 ['x-decorator-props']?: any;
9 // 动态包装器组件属性
10 ['x-use-decorator-props']?: any;
11 // 组件
12 ['x-component']?: string;
13 // 组件属性
14 ['x-component-props']?: any;
15 // 动态组件属性
16 ['x-use-component-props']?: any;
17 // 展示状态,默认为 'visible'
18 ['x-display']?: 'none' | 'hidden' | 'visible';
19 // 组件的子节点,简单使用
20 ['x-content']?: any;
21 // children 节点 schema
22 properties?: Record<string, ISchema>;
23
24 // 以下仅字段组件时使用
25
26 // 字段联动
27 ['x-reactions']?: SchemaReactions;
28 // 字段 UI 交互模式,默认为 'editable'
29 ['x-pattern']?: 'editable' | 'disabled' | 'readPretty';
30 // 字段校验
31 ['x-validator']?: Validator;
32 // 默认数据
33 default: ?:any;
34
35 // 设计器相关
36
37 // 初始化器,决定当前 schema 相邻位置可以插入什么
38 ['x-initializer']?: string;
39 ['x-initializer-props']?: any;
40
41 // 卡片设置,决定当前 schema 可以配置哪些参数
42 ['x-settings']?: string;
43 ['x-settings-props']?: any;
44
45 // 工具栏组件
46 ['x-toolbar']?: string;
47 ['x-toolbar-props']?: any;
48}