@king-one/form-design 0.0.28 → 0.0.29

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.
@@ -4,145 +4,316 @@ import { Ref, VNode } from 'vue';
4
4
  export declare class FormSchema {
5
5
  private version;
6
6
  fields: Ref<{
7
- title: string;
8
- key: string;
7
+ title?: string | undefined;
8
+ key?: string | undefined;
9
+ id?: string | undefined;
10
+ children?: any[] | undefined;
11
+ icon?: (string | VNode) | undefined;
9
12
  type: valueType;
10
- 'x-component'?: string | undefined;
11
- enum?: any[] | undefined;
12
13
  format?: string | undefined;
14
+ name?: string | undefined;
15
+ enum?: any[] | undefined;
16
+ required?: boolean | undefined;
17
+ properties?: Record<string, BaseFieldSchema> | undefined;
13
18
  items?: {
14
19
  type: valueType;
15
20
  format?: string | undefined;
16
- title?: string | undefined;
17
21
  name?: string | undefined;
22
+ enum?: any[] | undefined;
23
+ required?: boolean | undefined;
24
+ properties?: Record<string, BaseFieldSchema> | undefined;
25
+ items?: any | any[] | undefined;
18
26
  'x-component'?: string | undefined;
19
27
  'x-component-props'?: Record<string, any> | undefined;
20
28
  'x-decorator'?: string | undefined;
21
- properties?: Record<string, BaseFieldSchema> | undefined;
22
- items?: any | any[] | undefined;
23
- 'x-validator'?: any[] | undefined;
29
+ 'x-decorator-props'?: {
30
+ [x: string]: any;
31
+ } | undefined;
24
32
  'x-reactions'?: {
25
- dependencies?: Record<string, any>[] | undefined;
33
+ dependencies?: {
34
+ property: string;
35
+ type?: string | undefined;
36
+ source: string;
37
+ name: string;
38
+ }[] | undefined;
26
39
  fulfill?: {
27
40
  state?: Record<string, any> | undefined;
28
41
  } | undefined;
29
42
  } | undefined;
43
+ 'x-design-props'?: {
44
+ [x: string]: any;
45
+ validate?: {
46
+ status: "success" | "error" | "warning" | "";
47
+ message: string;
48
+ } | undefined;
49
+ } | undefined;
30
50
  } | {
31
51
  type: valueType;
32
52
  format?: string | undefined;
33
- title?: string | undefined;
34
53
  name?: string | undefined;
54
+ enum?: any[] | undefined;
55
+ required?: boolean | undefined;
56
+ properties?: Record<string, BaseFieldSchema> | undefined;
57
+ items?: any | any[] | undefined;
35
58
  'x-component'?: string | undefined;
36
59
  'x-component-props'?: Record<string, any> | undefined;
37
60
  'x-decorator'?: string | undefined;
38
- properties?: Record<string, BaseFieldSchema> | undefined;
39
- items?: any | any[] | undefined;
40
- 'x-validator'?: any[] | undefined;
61
+ 'x-decorator-props'?: {
62
+ [x: string]: any;
63
+ } | undefined;
41
64
  'x-reactions'?: {
42
- dependencies?: Record<string, any>[] | undefined;
65
+ dependencies?: {
66
+ property: string;
67
+ type?: string | undefined;
68
+ source: string;
69
+ name: string;
70
+ }[] | undefined;
43
71
  fulfill?: {
44
72
  state?: Record<string, any> | undefined;
45
73
  } | undefined;
46
74
  } | undefined;
75
+ 'x-design-props'?: {
76
+ [x: string]: any;
77
+ validate?: {
78
+ status: "success" | "error" | "warning" | "";
79
+ message: string;
80
+ } | undefined;
81
+ } | undefined;
47
82
  }[] | undefined;
48
- properties?: Record<string, BaseFieldSchema> | undefined;
49
- children?: any[] | undefined;
50
- required?: boolean | undefined;
51
- id?: string | undefined;
52
- name?: string | undefined;
53
- icon?: (string | VNode) | undefined;
83
+ 'x-component'?: string | undefined;
84
+ 'x-component-props'?: Record<string, any> | undefined;
85
+ 'x-decorator'?: string | undefined;
86
+ 'x-decorator-props'?: {
87
+ [x: string]: any;
88
+ } | undefined;
89
+ 'x-reactions'?: {
90
+ dependencies?: {
91
+ property: string;
92
+ type?: string | undefined;
93
+ source: string;
94
+ name: string;
95
+ }[] | undefined;
96
+ fulfill?: {
97
+ state?: Record<string, any> | undefined;
98
+ } | undefined;
99
+ } | undefined;
54
100
  'x-design-props'?: {
55
101
  [x: string]: any;
56
102
  validate?: {
57
103
  status: "success" | "error" | "warning" | "";
58
104
  message: string;
59
105
  } | undefined;
60
- 'convert-key'?: ("items" | "properties") | undefined;
61
- 'convert-type'?: ("base" | "object" | "array") | undefined;
62
- } | undefined;
63
- 'x-component-props'?: Record<string, any> | undefined;
64
- 'x-decorator'?: string | undefined;
65
- 'x-decorator-props'?: {
66
- [x: string]: any;
67
106
  } | undefined;
68
107
  }[], FieldSchema[] | {
69
- title: string;
70
- key: string;
108
+ title?: string | undefined;
109
+ key?: string | undefined;
110
+ id?: string | undefined;
111
+ children?: any[] | undefined;
112
+ icon?: (string | VNode) | undefined;
71
113
  type: valueType;
72
- 'x-component'?: string | undefined;
73
- enum?: any[] | undefined;
74
114
  format?: string | undefined;
115
+ name?: string | undefined;
116
+ enum?: any[] | undefined;
117
+ required?: boolean | undefined;
118
+ properties?: Record<string, BaseFieldSchema> | undefined;
75
119
  items?: {
76
120
  type: valueType;
77
121
  format?: string | undefined;
78
- title?: string | undefined;
79
122
  name?: string | undefined;
123
+ enum?: any[] | undefined;
124
+ required?: boolean | undefined;
125
+ properties?: Record<string, BaseFieldSchema> | undefined;
126
+ items?: any | any[] | undefined;
80
127
  'x-component'?: string | undefined;
81
128
  'x-component-props'?: Record<string, any> | undefined;
82
129
  'x-decorator'?: string | undefined;
83
- properties?: Record<string, BaseFieldSchema> | undefined;
84
- items?: any | any[] | undefined;
85
- 'x-validator'?: any[] | undefined;
130
+ 'x-decorator-props'?: {
131
+ [x: string]: any;
132
+ } | undefined;
86
133
  'x-reactions'?: {
87
- dependencies?: Record<string, any>[] | undefined;
134
+ dependencies?: {
135
+ property: string;
136
+ type?: string | undefined;
137
+ source: string;
138
+ name: string;
139
+ }[] | undefined;
88
140
  fulfill?: {
89
141
  state?: Record<string, any> | undefined;
90
142
  } | undefined;
91
143
  } | undefined;
144
+ 'x-design-props'?: {
145
+ [x: string]: any;
146
+ validate?: {
147
+ status: "success" | "error" | "warning" | "";
148
+ message: string;
149
+ } | undefined;
150
+ } | undefined;
92
151
  } | {
93
152
  type: valueType;
94
153
  format?: string | undefined;
95
- title?: string | undefined;
96
154
  name?: string | undefined;
155
+ enum?: any[] | undefined;
156
+ required?: boolean | undefined;
157
+ properties?: Record<string, BaseFieldSchema> | undefined;
158
+ items?: any | any[] | undefined;
97
159
  'x-component'?: string | undefined;
98
160
  'x-component-props'?: Record<string, any> | undefined;
99
161
  'x-decorator'?: string | undefined;
100
- properties?: Record<string, BaseFieldSchema> | undefined;
101
- items?: any | any[] | undefined;
102
- 'x-validator'?: any[] | undefined;
162
+ 'x-decorator-props'?: {
163
+ [x: string]: any;
164
+ } | undefined;
103
165
  'x-reactions'?: {
104
- dependencies?: Record<string, any>[] | undefined;
166
+ dependencies?: {
167
+ property: string;
168
+ type?: string | undefined;
169
+ source: string;
170
+ name: string;
171
+ }[] | undefined;
105
172
  fulfill?: {
106
173
  state?: Record<string, any> | undefined;
107
174
  } | undefined;
108
175
  } | undefined;
176
+ 'x-design-props'?: {
177
+ [x: string]: any;
178
+ validate?: {
179
+ status: "success" | "error" | "warning" | "";
180
+ message: string;
181
+ } | undefined;
182
+ } | undefined;
109
183
  }[] | undefined;
110
- properties?: Record<string, BaseFieldSchema> | undefined;
111
- children?: any[] | undefined;
112
- required?: boolean | undefined;
113
- id?: string | undefined;
114
- name?: string | undefined;
115
- icon?: (string | VNode) | undefined;
184
+ 'x-component'?: string | undefined;
185
+ 'x-component-props'?: Record<string, any> | undefined;
186
+ 'x-decorator'?: string | undefined;
187
+ 'x-decorator-props'?: {
188
+ [x: string]: any;
189
+ } | undefined;
190
+ 'x-reactions'?: {
191
+ dependencies?: {
192
+ property: string;
193
+ type?: string | undefined;
194
+ source: string;
195
+ name: string;
196
+ }[] | undefined;
197
+ fulfill?: {
198
+ state?: Record<string, any> | undefined;
199
+ } | undefined;
200
+ } | undefined;
116
201
  'x-design-props'?: {
117
202
  [x: string]: any;
118
203
  validate?: {
119
204
  status: "success" | "error" | "warning" | "";
120
205
  message: string;
121
206
  } | undefined;
122
- 'convert-key'?: ("items" | "properties") | undefined;
123
- 'convert-type'?: ("base" | "object" | "array") | undefined;
124
- } | undefined;
125
- 'x-component-props'?: Record<string, any> | undefined;
126
- 'x-decorator'?: string | undefined;
127
- 'x-decorator-props'?: {
128
- [x: string]: any;
129
207
  } | undefined;
130
208
  }[]>;
131
209
  getSchema(): {
132
210
  version: string;
133
211
  form: {
134
- schema: {};
212
+ schema: {
213
+ title?: string | undefined;
214
+ key?: string | undefined;
215
+ id?: string | undefined;
216
+ children?: any[] | undefined;
217
+ icon?: (string | VNode) | undefined;
218
+ type: valueType;
219
+ format?: string | undefined;
220
+ name?: string | undefined;
221
+ enum?: any[] | undefined;
222
+ required?: boolean | undefined;
223
+ properties?: Record<string, BaseFieldSchema> | undefined;
224
+ items?: {
225
+ type: valueType;
226
+ format?: string | undefined;
227
+ name?: string | undefined;
228
+ enum?: any[] | undefined;
229
+ required?: boolean | undefined;
230
+ properties?: Record<string, BaseFieldSchema> | undefined;
231
+ items?: any | any[] | undefined;
232
+ 'x-component'?: string | undefined;
233
+ 'x-component-props'?: Record<string, any> | undefined;
234
+ 'x-decorator'?: string | undefined;
235
+ 'x-decorator-props'?: {
236
+ [x: string]: any;
237
+ } | undefined;
238
+ 'x-reactions'?: {
239
+ dependencies?: {
240
+ property: string;
241
+ type?: string | undefined;
242
+ source: string;
243
+ name: string;
244
+ }[] | undefined;
245
+ fulfill?: {
246
+ state?: Record<string, any> | undefined;
247
+ } | undefined;
248
+ } | undefined;
249
+ 'x-design-props'?: {
250
+ [x: string]: any;
251
+ validate?: {
252
+ status: "success" | "error" | "warning" | "";
253
+ message: string;
254
+ } | undefined;
255
+ } | undefined;
256
+ } | {
257
+ type: valueType;
258
+ format?: string | undefined;
259
+ name?: string | undefined;
260
+ enum?: any[] | undefined;
261
+ required?: boolean | undefined;
262
+ properties?: Record<string, BaseFieldSchema> | undefined;
263
+ items?: any | any[] | undefined;
264
+ 'x-component'?: string | undefined;
265
+ 'x-component-props'?: Record<string, any> | undefined;
266
+ 'x-decorator'?: string | undefined;
267
+ 'x-decorator-props'?: {
268
+ [x: string]: any;
269
+ } | undefined;
270
+ 'x-reactions'?: {
271
+ dependencies?: {
272
+ property: string;
273
+ type?: string | undefined;
274
+ source: string;
275
+ name: string;
276
+ }[] | undefined;
277
+ fulfill?: {
278
+ state?: Record<string, any> | undefined;
279
+ } | undefined;
280
+ } | undefined;
281
+ 'x-design-props'?: {
282
+ [x: string]: any;
283
+ validate?: {
284
+ status: "success" | "error" | "warning" | "";
285
+ message: string;
286
+ } | undefined;
287
+ } | undefined;
288
+ }[] | undefined;
289
+ 'x-component'?: string | undefined;
290
+ 'x-component-props'?: Record<string, any> | undefined;
291
+ 'x-decorator'?: string | undefined;
292
+ 'x-decorator-props'?: {
293
+ [x: string]: any;
294
+ } | undefined;
295
+ 'x-reactions'?: {
296
+ dependencies?: {
297
+ property: string;
298
+ type?: string | undefined;
299
+ source: string;
300
+ name: string;
301
+ }[] | undefined;
302
+ fulfill?: {
303
+ state?: Record<string, any> | undefined;
304
+ } | undefined;
305
+ } | undefined;
306
+ 'x-design-props'?: {
307
+ [x: string]: any;
308
+ validate?: {
309
+ status: "success" | "error" | "warning" | "";
310
+ message: string;
311
+ } | undefined;
312
+ } | undefined;
313
+ }[];
135
314
  };
136
315
  };
137
316
  getFieldList(): Field[];
138
317
  clearFields(): never[];
139
- private jsonToschema;
140
- /**
141
- * 将 schema 对象格式还原为数组格式
142
- * @param schema schema 对象
143
- * @returns FieldSchema[] 数组格式
144
- */
145
- private schemaToJson;
146
- setFields(schema: Record<string, any>): void;
147
- private omit;
318
+ setFields(schema: FieldSchema[]): void;
148
319
  }
@@ -7,3 +7,4 @@ export { FormConfig } from './components';
7
7
  export * from './config';
8
8
  export * from './effects/onEffects';
9
9
  export type { DesignSchema } from './types';
10
+ export { jsonToSchema } from './utils';
@@ -4,7 +4,14 @@ import { LifeCycleInstance } from './effects/types';
4
4
  import { Plugin } from './plugins';
5
5
  export type { ExpandPropsType } from './components/types';
6
6
  export type PluginInterface = InstanceType<typeof Plugin>;
7
- export declare const valueTypeMap: Record<string, string>;
7
+ export declare const valueTypeMap: {
8
+ readonly string: "string";
9
+ readonly number: "number";
10
+ readonly boolean: "boolean";
11
+ readonly object: "object";
12
+ readonly array: "array";
13
+ readonly void: "void";
14
+ };
8
15
  export type valueType = keyof typeof valueTypeMap;
9
16
  export interface FormProps {
10
17
  layout: 'horizontal' | 'vertical';
@@ -13,51 +20,44 @@ export interface FormProps {
13
20
  }
14
21
  export interface BaseFieldSchema {
15
22
  'type': valueType;
16
- 'format'?: string;
17
- 'title'?: string;
23
+ 'format'?: JSONSchemaFormat;
18
24
  'name'?: string;
25
+ 'enum'?: any[];
26
+ 'required'?: boolean;
27
+ 'properties'?: Record<string, BaseFieldSchema>;
28
+ 'items'?: BaseFieldSchema | BaseFieldSchema[];
19
29
  'x-component'?: string;
20
30
  'x-component-props'?: Record<string, any>;
21
31
  'x-decorator'?: string;
22
- 'properties'?: Record<string, BaseFieldSchema>;
23
- 'items'?: BaseFieldSchema | BaseFieldSchema[];
24
- 'x-validator'?: any[];
32
+ 'x-decorator-props'?: {
33
+ [x: string]: any;
34
+ };
25
35
  'x-reactions'?: {
26
- dependencies?: Record<string, any>[];
36
+ dependencies?: Array<{
37
+ property: string;
38
+ type?: string;
39
+ source: string;
40
+ name: string;
41
+ }>;
27
42
  fulfill?: {
28
43
  state?: Record<string, any>;
29
44
  };
30
45
  };
31
- }
32
- export interface FieldSchema {
33
- 'title': string;
34
- 'key': string;
35
- 'type': valueType;
36
- 'x-component'?: string;
37
- 'enum'?: any[];
38
- 'format'?: string;
39
- 'items'?: BaseFieldSchema | BaseFieldSchema[];
40
- 'properties'?: Record<string, BaseFieldSchema>;
41
- 'children'?: FieldSchema[];
42
- 'required'?: boolean;
43
- 'id'?: string;
44
- 'name'?: string;
45
- 'icon'?: string | VNode;
46
46
  'x-design-props'?: {
47
- 'validate'?: {
47
+ validate?: {
48
48
  status: 'success' | 'error' | 'warning' | '';
49
49
  message: string;
50
50
  };
51
- 'convert-key'?: 'items' | 'properties';
52
- 'convert-type'?: 'base' | 'object' | 'array';
53
- [x: string]: any;
54
- };
55
- 'x-component-props'?: Record<string, any>;
56
- 'x-decorator'?: string;
57
- 'x-decorator-props'?: {
58
51
  [x: string]: any;
59
52
  };
60
53
  }
54
+ export interface FieldSchema extends BaseFieldSchema {
55
+ title?: string;
56
+ key?: string;
57
+ id?: string;
58
+ children?: FieldSchema[];
59
+ icon?: string | VNode;
60
+ }
61
61
  export interface TemplateSchema {
62
62
  name: string;
63
63
  key: string;
@@ -110,3 +110,7 @@ export interface DragPutType {
110
110
  traget: FieldSchema[];
111
111
  region: 'form-panel' | 'k-array-card' | 'k-object' | 'k-table' | 'k-grid';
112
112
  }
113
+ /**
114
+ * JSON Schema 预定义的格式
115
+ */
116
+ type JSONSchemaFormat = 'date-time' | 'date' | 'time' | 'duration' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'iri-reference' | 'uri-template' | 'uuid' | 'json-pointer' | 'relative-json-pointer' | 'regex' | string;
@@ -1,2 +1,3 @@
1
1
  export * from './checkers';
2
2
  export * from './debounce';
3
+ export * from './schema';
@@ -0,0 +1,2 @@
1
+ import { FieldSchema } from '../types';
2
+ export declare function jsonToSchema(formList: FieldSchema[], schema?: {}): {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@king-one/form-design",
3
3
  "type": "module",
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "description": "@king-one 表单设计器",
6
6
  "author": "",
7
7
  "license": "ISC",