@king-one/form-design 0.0.28 → 0.0.30

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.
@@ -12,10 +12,6 @@ const o = {
12
12
  "x-component-props": {
13
13
  gutter: 20
14
14
  },
15
- "x-design-props": {
16
- "convert-key": "properties",
17
- "convert-type": "base"
18
- },
19
15
  "x-decorator": "Void"
20
16
  }
21
17
  ]
@@ -117,17 +113,27 @@ const o = {
117
113
  type: e.object,
118
114
  icon: "form-area",
119
115
  "x-component": "FormArea",
120
- properties: {
121
- province: {
122
- type: e.string
123
- },
124
- city: {
125
- type: e.string
116
+ children: [
117
+ {
118
+ type: e.string,
119
+ name: "province"
126
120
  },
127
- county: {
128
- type: e.string
121
+ {
122
+ type: e.string,
123
+ name: "city"
129
124
  }
130
- }
125
+ ]
126
+ // 'properties': {
127
+ // province: {
128
+ // type: valueTypeMap.string
129
+ // },
130
+ // city: {
131
+ // type: valueTypeMap.string
132
+ // },
133
+ // county: {
134
+ // type: valueTypeMap.string
135
+ // }
136
+ // }
131
137
  }
132
138
  ]
133
139
  }, a = {
@@ -139,11 +145,7 @@ const o = {
139
145
  key: "k-object",
140
146
  type: e.object,
141
147
  icon: "form-object",
142
- children: [],
143
- "x-design-props": {
144
- "convert-key": "properties",
145
- "convert-type": "base"
146
- }
148
+ children: []
147
149
  },
148
150
  {
149
151
  title: "列表容器",
@@ -152,11 +154,7 @@ const o = {
152
154
  icon: "form-list",
153
155
  children: [],
154
156
  "x-component": "ArrayCard",
155
- "x-decorator": "Void",
156
- "x-design-props": {
157
- "convert-key": "items",
158
- "convert-type": "object"
159
- }
157
+ "x-decorator": "Void"
160
158
  },
161
159
  {
162
160
  title: "明细表",
@@ -164,12 +162,9 @@ const o = {
164
162
  type: e.array,
165
163
  icon: "form-table",
166
164
  "x-component": "ArrayTable",
165
+ children: [],
167
166
  "x-decorator-props": {
168
167
  labelAlign: "top"
169
- },
170
- "x-design-props": {
171
- "convert-key": "items",
172
- "convert-type": "object"
173
168
  }
174
169
  }
175
170
  ]
@@ -190,67 +185,63 @@ const o = {
190
185
  message: ""
191
186
  }
192
187
  },
193
- properties: {
194
- details: {
188
+ children: [
189
+ {
195
190
  type: e.array,
191
+ name: "details",
196
192
  title: "加班明细",
197
193
  "x-component": "ArrayCard",
198
194
  "x-decorator": "Void",
199
- name: "details",
200
- items: {
201
- type: e.object,
202
- properties: {
203
- date: {
204
- type: e.array,
205
- title: "加班日期",
206
- format: "date",
207
- items: {
208
- type: e.string,
209
- format: "date"
210
- },
211
- name: "date",
212
- "x-component": "DateRange",
213
- "x-component-props": {
214
- valueFormat: "YYYY-MM-DD HH:mm:ss",
215
- showTime: !0,
216
- placeholder: [
217
- "开始日期",
218
- "结束日期"
219
- ]
220
- }
195
+ children: [
196
+ {
197
+ type: e.array,
198
+ title: "加班日期",
199
+ items: {
200
+ type: e.string,
201
+ format: "date"
221
202
  },
222
- hours: {
223
- type: e.number,
224
- title: "加班时长",
225
- name: "hours",
226
- "x-component": "InputNumber",
227
- "x-component-props": {
228
- placeholder: "请输入"
229
- },
230
- "x-validator": [
231
- {
232
- validator: `{{const sourceValue = $parent.date
233
- if (!sourceValue || !sourceValue.length) {
234
- return true
235
- }else{
236
- const [start, end] = sourceValue
237
- const s = new Date(start)
238
- const e = new Date(end)
239
- const hoursDiff = Math.abs(e - s) / (1000 * 60 * 60)
240
- const actualHours = Math.round(hoursDiff * 100) / 100
241
- if ( $value> actualHours) {
242
- return new Error(\`不得超过\${actualHours}小时\`)
243
- }
244
- return true
245
- }
246
- }}`
247
- }
203
+ name: "date",
204
+ "x-component": "DateRange",
205
+ "x-component-props": {
206
+ valueFormat: "YYYY-MM-DD HH:mm:ss",
207
+ showTime: !0,
208
+ placeholder: [
209
+ "开始日期",
210
+ "结束日期"
248
211
  ]
249
212
  }
213
+ },
214
+ {
215
+ type: e.number,
216
+ title: "加班时长",
217
+ name: "hours",
218
+ "x-component": "InputNumber",
219
+ "x-component-props": {
220
+ placeholder: "请输入"
221
+ },
222
+ "x-validator": [
223
+ {
224
+ validator: `{{const sourceValue = $parent.date
225
+ if (!sourceValue || !sourceValue.length) {
226
+ return true
227
+ }else{
228
+ const [start, end] = sourceValue
229
+ const s = new Date(start)
230
+ const e = new Date(end)
231
+ const hoursDiff = Math.abs(e - s) / (1000 * 60 * 60)
232
+ const actualHours = Math.round(hoursDiff * 100) / 100
233
+ if ( $value> actualHours) {
234
+ return new Error(\`不得超过\${actualHours}小时\`)
235
+ }
236
+ return true
237
+ }
238
+ }}`
239
+ }
240
+ ]
250
241
  }
251
- }
242
+ ]
252
243
  },
253
- total: {
244
+ {
254
245
  type: e.number,
255
246
  title: "总时长",
256
247
  name: "total",
@@ -274,78 +265,163 @@ const o = {
274
265
  }
275
266
  }
276
267
  }
277
- }
278
- }
279
- },
280
- {
281
- name: "请假模版",
282
- key: "liveTime",
283
- icon: "form-kit-liveTime",
284
- schema: {
285
- title: "请假模版",
286
- key: "k-liveTime",
287
- type: e.object,
288
- name: "liveTime",
289
- id: "liveTime",
290
- "x-design-props": {
291
- validate: {
292
- status: "",
293
- message: ""
294
- }
295
- },
296
- properties: {
297
- details: {
298
- type: e.array,
299
- title: "加班明细",
300
- "x-component": "ArrayCard",
301
- "x-decorator": "Void",
302
- name: "details",
303
- items: {
304
- type: e.object,
305
- properties: {
306
- date: {
307
- type: e.array,
308
- title: "加班日期",
309
- format: "date",
310
- items: {
311
- type: e.string,
312
- format: "date"
313
- },
314
- name: "date",
315
- "x-component": "DateRange",
316
- "x-component-props": {
317
- valueFormat: "YYYY-MM-DD HH:mm:ss",
318
- showTime: !0,
319
- placeholder: [
320
- "开始日期",
321
- "结束日期"
322
- ]
323
- }
324
- },
325
- hours: {
326
- type: e.number,
327
- title: "加班时长",
328
- name: "hours",
329
- "x-component": "InputNumber",
330
- "x-component-props": {
331
- placeholder: "请输入"
332
- }
333
- }
334
- }
335
- }
336
- },
337
- total: {
338
- type: e.number,
339
- title: "总时长",
340
- name: "total",
341
- "x-component": "InputNumber",
342
- "x-component-props": {
343
- placeholder: "请输入"
344
- }
345
- }
346
- }
268
+ ]
269
+ // 'properties': {
270
+ // details: {
271
+ // 'type': valueTypeMap.array,
272
+ // 'title': '加班明细',
273
+ // 'x-component': 'ArrayCard',
274
+ // 'x-decorator': 'Void',
275
+ // 'name': 'details',
276
+ // 'items': {
277
+ // type: valueTypeMap.object,
278
+ // properties: {
279
+ // date: {
280
+ // 'type': valueTypeMap.array,
281
+ // 'title': '加班日期',
282
+ // 'format': 'date',
283
+ // 'items': {
284
+ // type: valueTypeMap.string,
285
+ // format: 'date'
286
+ // },
287
+ // 'name': 'date',
288
+ // 'x-component': 'DateRange',
289
+ // 'x-component-props': {
290
+ // valueFormat: 'YYYY-MM-DD HH:mm:ss',
291
+ // showTime: true,
292
+ // placeholder: [
293
+ // '开始日期',
294
+ // '结束日期'
295
+ // ]
296
+ // }
297
+ // },
298
+ // hours: {
299
+ // 'type': valueTypeMap.number,
300
+ // 'title': '加班时长',
301
+ // 'name': 'hours',
302
+ // 'x-component': 'InputNumber',
303
+ // 'x-component-props': {
304
+ // placeholder: '请输入'
305
+ // },
306
+ // 'x-validator': [
307
+ // {
308
+ // validator: `{{const sourceValue = \$parent.date
309
+ // if (!sourceValue || !sourceValue.length) {
310
+ // return true
311
+ // }else{
312
+ // const [start, end] = sourceValue
313
+ // const s = new Date(start)
314
+ // const e = new Date(end)
315
+ // const hoursDiff = Math.abs(e - s) / (1000 * 60 * 60)
316
+ // const actualHours = Math.round(hoursDiff * 100) / 100
317
+ // if ( \$value> actualHours) {
318
+ // return new Error(\`不得超过\${actualHours}小时\`)
319
+ // }
320
+ // return true
321
+ // }
322
+ // }}`
323
+ // }
324
+ // ]
325
+ // }
326
+ // }
327
+ // }
328
+ // },
329
+ // total: {
330
+ // 'type': valueTypeMap.number,
331
+ // 'title': '总时长',
332
+ // 'name': 'total',
333
+ // 'x-component': 'InputNumber',
334
+ // 'x-component-props': {
335
+ // placeholder: '请输入'
336
+ // },
337
+ // 'x-reactions': {
338
+ // dependencies: [
339
+ // {
340
+ // property: 'value',
341
+ // type: 'string',
342
+ // source: '.details',
343
+ // name: 'details'
344
+ // }
345
+ // ],
346
+ // fulfill: {
347
+ // state: {
348
+ // value: '{{$deps.details.reduce((acc, cur) => acc + cur.hours, 0)}}'
349
+ // }
350
+ // }
351
+ // }
352
+ // }
353
+ // }
347
354
  }
348
355
  }
356
+ // {
357
+ // name: '请假模版',
358
+ // key: 'liveTime',
359
+ // icon: 'form-kit-liveTime',
360
+ // schema: {
361
+ // 'title': '请假模版',
362
+ // 'key': 'k-liveTime',
363
+ // 'type': valueTypeMap.object,
364
+ // 'name': 'liveTime',
365
+ // 'id': 'liveTime',
366
+ // 'x-design-props': {
367
+ // validate: {
368
+ // status: '',
369
+ // message: ''
370
+ // }
371
+ // },
372
+ // 'properties': {
373
+ // details: {
374
+ // 'type': valueTypeMap.array,
375
+ // 'title': '加班明细',
376
+ // 'x-component': 'ArrayCard',
377
+ // 'x-decorator': 'Void',
378
+ // 'name': 'details',
379
+ // 'items': {
380
+ // type: valueTypeMap.object,
381
+ // properties: {
382
+ // date: {
383
+ // 'type': valueTypeMap.array,
384
+ // 'title': '加班日期',
385
+ // 'format': 'date',
386
+ // 'items': {
387
+ // type: valueTypeMap.string,
388
+ // format: 'date'
389
+ // },
390
+ // 'name': 'date',
391
+ // 'x-component': 'DateRange',
392
+ // 'x-component-props': {
393
+ // valueFormat: 'YYYY-MM-DD HH:mm:ss',
394
+ // showTime: true,
395
+ // placeholder: [
396
+ // '开始日期',
397
+ // '结束日期'
398
+ // ]
399
+ // }
400
+ // },
401
+ // hours: {
402
+ // 'type': valueTypeMap.number,
403
+ // 'title': '加班时长',
404
+ // 'name': 'hours',
405
+ // 'x-component': 'InputNumber',
406
+ // 'x-component-props': {
407
+ // placeholder: '请输入'
408
+ // }
409
+ // }
410
+ // }
411
+ // }
412
+ // },
413
+ // total: {
414
+ // 'type': valueTypeMap.number,
415
+ // 'title': '总时长',
416
+ // 'name': 'total',
417
+ // 'x-component': 'InputNumber',
418
+ // 'x-component-props': {
419
+ // placeholder: '请输入'
420
+ // }
421
+ // }
422
+ // }
423
+ // }
424
+ // }
349
425
  ];
350
426
  export {
351
427
  r as BaseSchema,
@@ -1,79 +1,58 @@
1
- var a = Object.defineProperty;
2
- var m = (r, t, s) => t in r ? a(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s;
3
- var c = (r, t, s) => m(r, typeof t != "symbol" ? t + "" : t, s);
4
- import { ref as f, toRaw as d } from "vue";
5
- import { uid as u } from "@king-one/utils";
6
- import { Field as y } from "./Field.mjs";
7
- class F {
1
+ var l = Object.defineProperty;
2
+ var a = (s, e, t) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var n = (s, e, t) => a(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ref as h, toRaw as m } from "vue";
5
+ import { uid as c } from "@king-one/utils";
6
+ import { Field as d } from "./Field.mjs";
7
+ class g {
8
8
  constructor() {
9
- c(this, "version", "1.0.0");
10
- c(this, "fields", f([]));
9
+ n(this, "version", "1.0.0");
10
+ n(this, "fields", h([]));
11
11
  }
12
12
  getSchema() {
13
- const t = d(this.fields.value);
14
- console.log(t, "s");
15
- const s = this.jsonToschema(t);
13
+ const e = m(this.fields.value), t = this.jsonToSchema(e);
16
14
  return {
17
15
  version: this.version,
18
16
  form: {
19
- schema: s
17
+ schema: t
20
18
  }
21
19
  };
22
20
  }
23
21
  getFieldList() {
24
- return this.fields.value.map((t) => new y(t));
22
+ return this.fields.value.map((e) => new d(e));
25
23
  }
26
24
  clearFields() {
27
25
  return this.fields.value = [];
28
26
  }
29
- jsonToschema(t, s = {}) {
30
- return t.forEach((i) => {
31
- const e = this.omit(i, ["children"]), o = i.children || [];
32
- e.type === "object" && o.length ? s[e.name] = {
33
- ...e,
34
- properties: this.jsonToschema(o)
35
- } : e.type === "void" && o.length ? s[e.name] = {
36
- ...e,
37
- properties: this.jsonToschema(o)
38
- } : e.type === "array" && o.length ? s[e.name] = {
39
- ...e,
40
- items: e.items || {
27
+ setFields(e) {
28
+ this.fields.value = e;
29
+ }
30
+ jsonToSchema(e, t = {}) {
31
+ return e.forEach((o) => {
32
+ const i = this.omit(o, ["children"]), r = o.children || [];
33
+ i.type === "object" && r.length ? t[i.name] = {
34
+ ...i,
35
+ properties: this.jsonToSchema(r)
36
+ } : i.type === "void" && r.length ? t[i.name] = {
37
+ ...i,
38
+ properties: this.jsonToSchema(r)
39
+ } : i.type === "array" && r.length ? t[i.name] = {
40
+ ...i,
41
+ items: i.items || {
41
42
  type: "object",
42
- id: u(),
43
- properties: this.jsonToschema(o)
43
+ id: c(),
44
+ properties: this.jsonToSchema(r)
44
45
  }
45
- } : s[e.name] = e;
46
- }), s;
47
- }
48
- /**
49
- * 将 schema 对象格式还原为数组格式
50
- * @param schema schema 对象
51
- * @returns FieldSchema[] 数组格式
52
- */
53
- schemaToJson(t) {
54
- const s = [];
55
- return Object.keys(t).forEach((i) => {
56
- var h;
57
- const e = t[i], o = e["x-design-props"], l = o == null ? void 0 : o["convert-key"], p = o == null ? void 0 : o["convert-type"];
58
- if (!l || !p) {
59
- s.push(e);
60
- return;
61
- }
62
- const n = this.omit(e, ["properties", "items"]);
63
- e.type === "object" || e.type === "void" ? n.children = e.properties ? this.schemaToJson(e.properties) : [] : e.type === "array" && ((h = e.items) != null && h.properties) && (n.children = this.schemaToJson(e.items.properties)), s.push(n);
64
- }), s;
46
+ } : t[i.name] = i;
47
+ }), t;
65
48
  }
66
- setFields(t) {
67
- const s = this.schemaToJson(t);
68
- this.fields.value = s;
69
- }
70
- omit(t, s) {
71
- const i = { ...t };
72
- return s.forEach((e) => {
73
- delete i[e];
74
- }), i;
49
+ omit(e, t) {
50
+ const o = { ...e };
51
+ return t.forEach((i) => {
52
+ delete o[i];
53
+ }), o;
75
54
  }
76
55
  }
77
56
  export {
78
- F as FormSchema
57
+ g as FormSchema
79
58
  };
@@ -1,19 +1,20 @@
1
1
  import "./components/base/Carousel.vue2.mjs";
2
2
  import "./components/panel/panel-item.vue2.mjs";
3
- import { useInjectDesignContext as n } from "./context/design.mjs";
4
- import { default as i } from "./components/form-desgin.mjs";
5
- import { CreateFormDesign as s } from "./core/index.mjs";
3
+ import { useInjectDesignContext as i } from "./context/design.mjs";
4
+ import { default as p } from "./components/form-desgin.mjs";
5
+ import { CreateFormDesign as x } from "./core/index.mjs";
6
6
  import "./components/index.mjs";
7
- import { BaseSchema as f, ExtendSchema as g, LayoutSchema as c, tempSchema as h } from "./config/index.mjs";
8
- import { onDesignFieldChange as S, onDesignInit as d } from "./effects/onEffects.mjs";
7
+ import { BaseSchema as g, ExtendSchema as c, LayoutSchema as h, tempSchema as D } from "./config/index.mjs";
8
+ import { onDesignFieldChange as d, onDesignInit as u } from "./effects/onEffects.mjs";
9
+ import "./utils/index.mjs";
9
10
  export {
10
- f as BaseSchema,
11
- s as CreateFormDesign,
12
- g as ExtendSchema,
13
- i as FormDesign,
14
- c as LayoutSchema,
15
- S as onDesignFieldChange,
16
- d as onDesignInit,
17
- h as tempSchema,
18
- n as useInjectDesignContext
11
+ g as BaseSchema,
12
+ x as CreateFormDesign,
13
+ c as ExtendSchema,
14
+ p as FormDesign,
15
+ h as LayoutSchema,
16
+ d as onDesignFieldChange,
17
+ u as onDesignInit,
18
+ D as tempSchema,
19
+ i as useInjectDesignContext
19
20
  };
@@ -11,7 +11,7 @@ class g {
11
11
  const { region: t, source: n } = e, s = ["k-array-card", "k-object", "k-table", "k-grid"];
12
12
  if (s.includes(t)) {
13
13
  const { key: c } = n;
14
- return !s.includes(c);
14
+ return !s.includes(c || "");
15
15
  }
16
16
  return !0;
17
17
  });
@@ -1,21 +1,23 @@
1
- import { getType as s, isArr as t, isBool as r, isFn as o, isHTMLElement as a, isMap as m, isNum as p, isNumberLike as n, isObj as b, isPlainObj as l, isReactElement as k, isRegExp as u, isSet as x, isStr as E, isWeakMap as M, isWeakSet as S } from "./checkers.mjs";
2
- import { debounce as f } from "./debounce.mjs";
1
+ import { getType as s, isArr as o, isBool as r, isFn as t, isHTMLElement as m, isMap as a, isNum as p, isNumberLike as n, isObj as b, isPlainObj as l, isReactElement as x, isRegExp as S, isSet as c, isStr as f, isWeakMap as j, isWeakSet as k } from "./checkers.mjs";
2
+ import { debounce as E } from "./debounce.mjs";
3
+ import { jsonToSchema as T } from "./schema.mjs";
3
4
  export {
4
- f as debounce,
5
+ E as debounce,
5
6
  s as getType,
6
- t as isArr,
7
+ o as isArr,
7
8
  r as isBool,
8
- o as isFn,
9
- a as isHTMLElement,
10
- m as isMap,
9
+ t as isFn,
10
+ m as isHTMLElement,
11
+ a as isMap,
11
12
  p as isNum,
12
13
  n as isNumberLike,
13
14
  b as isObj,
14
15
  l as isPlainObj,
15
- k as isReactElement,
16
- u as isRegExp,
17
- x as isSet,
18
- E as isStr,
19
- M as isWeakMap,
20
- S as isWeakSet
16
+ x as isReactElement,
17
+ S as isRegExp,
18
+ c as isSet,
19
+ f as isStr,
20
+ j as isWeakMap,
21
+ k as isWeakSet,
22
+ T as jsonToSchema
21
23
  };
@@ -0,0 +1,29 @@
1
+ import { uid as p } from "@king-one/utils";
2
+ function l(o, t) {
3
+ const n = { ...o };
4
+ return t.forEach((e) => {
5
+ delete n[e];
6
+ }), n;
7
+ }
8
+ function i(o, t = {}) {
9
+ return o.forEach((n) => {
10
+ const e = l(n, ["children"]), r = n.children || [];
11
+ e.type === "object" && r.length ? t[e.name] = {
12
+ ...e,
13
+ properties: i(r)
14
+ } : e.type === "void" && r.length ? t[e.name] = {
15
+ ...e,
16
+ properties: i(r)
17
+ } : e.type === "array" && r.length ? t[e.name] = {
18
+ ...e,
19
+ items: e.items || {
20
+ type: "object",
21
+ id: p(),
22
+ properties: i(r)
23
+ }
24
+ } : t[e.name] = e;
25
+ }), t;
26
+ }
27
+ export {
28
+ i as jsonToSchema
29
+ };