xkit-editor 2.0.0-alpha.0 → 2.0.0-alpha.1

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.
Files changed (68) hide show
  1. package/README.md +26 -0
  2. package/lib/packages/editor/src/components/json-code-editor.vue.d.ts +2 -0
  3. package/lib/packages/editor/src/components/json-code-editor.vue.d.ts.map +1 -1
  4. package/lib/packages/editor/src/x-editor.vue.d.ts +8 -0
  5. package/lib/packages/editor/src/x-editor.vue.d.ts.map +1 -1
  6. package/lib/packages/ui/src/components/radios/type.d.ts +2 -2
  7. package/lib/xkit-editor.css +1 -1
  8. package/lib/xkit-editor.js +64 -52
  9. package/lib/xkit-editor.umd.cjs +2 -2
  10. package/package.json +3 -4
  11. package/src/component-configs/__tests__/config.test.ts +0 -288
  12. package/src/component-configs/__tests__/group.test.ts +0 -104
  13. package/src/component-configs/cascader.ts +0 -20
  14. package/src/component-configs/checkbox.ts +0 -43
  15. package/src/component-configs/common-props.ts +0 -130
  16. package/src/component-configs/date-picker.ts +0 -153
  17. package/src/component-configs/date-range-picker.ts +0 -185
  18. package/src/component-configs/group.ts +0 -196
  19. package/src/component-configs/icon-select.ts +0 -56
  20. package/src/component-configs/input-array.ts +0 -184
  21. package/src/component-configs/input-number-range.ts +0 -143
  22. package/src/component-configs/input-number.ts +0 -111
  23. package/src/component-configs/input-table.ts +0 -191
  24. package/src/component-configs/input-upload.ts +0 -123
  25. package/src/component-configs/input.ts +0 -48
  26. package/src/component-configs/layout-sections.ts +0 -546
  27. package/src/component-configs/options-config.ts +0 -12
  28. package/src/component-configs/radio.ts +0 -26
  29. package/src/component-configs/select.ts +0 -42
  30. package/src/component-configs/switch.ts +0 -19
  31. package/src/component-configs/textarea.ts +0 -84
  32. package/src/component-configs/types.ts +0 -37
  33. package/src/components/condition-editor.vue +0 -641
  34. package/src/components/design-renderers/input-array-design.vue +0 -283
  35. package/src/components/design-renderers/input-table-design.vue +0 -311
  36. package/src/components/form-item-layout-editor.vue +0 -291
  37. package/src/components/form-item-span-editor.vue +0 -328
  38. package/src/components/form-layout-editor.vue +0 -263
  39. package/src/components/group-title-color-select.vue +0 -75
  40. package/src/components/group-title-style-picker.vue +0 -125
  41. package/src/components/input-number-range-binding-editor.vue +0 -226
  42. package/src/components/input-table-default-rows-editor.vue +0 -147
  43. package/src/components/input-table-operation-editor.vue +0 -168
  44. package/src/components/json-code-editor.vue +0 -219
  45. package/src/components/object-section-editor.vue +0 -342
  46. package/src/components/options/default-dict-options-panel.vue +0 -197
  47. package/src/components/options/options-editor.vue +0 -161
  48. package/src/components/table-columns-editor.vue +0 -353
  49. package/src/components/validation-rules-editor.vue +0 -321
  50. package/src/config.ts +0 -51
  51. package/src/editor-item-wrapper.vue +0 -254
  52. package/src/group-title-styles.ts +0 -82
  53. package/src/index.ts +0 -6
  54. package/src/option-sources.ts +0 -45
  55. package/src/root-configs.ts +0 -278
  56. package/src/shims-vue.d.ts +0 -5
  57. package/src/utils/__tests__/component-replace.test.ts +0 -129
  58. package/src/utils/__tests__/editor-schema.test.ts +0 -429
  59. package/src/utils/__tests__/form-item-width.test.ts +0 -53
  60. package/src/utils/__tests__/group-drag-path.test.ts +0 -84
  61. package/src/utils/__tests__/record-field.test.ts +0 -34
  62. package/src/utils/component-replace.ts +0 -67
  63. package/src/utils/editor-schema.ts +0 -374
  64. package/src/utils/form-item-width.ts +0 -40
  65. package/src/utils/local-dict-center.ts +0 -81
  66. package/src/utils/record-field.ts +0 -30
  67. package/src/validation-rules.ts +0 -104
  68. package/src/x-editor.vue +0 -1300
@@ -1,123 +0,0 @@
1
- import type { ComponentConfig } from './types'
2
- import { commonProps, createComponentConfigTabs } from './common-props'
3
- import type { XFormItem } from 'xkit-ui'
4
-
5
- const uploadBasicProps: XFormItem[] = [
6
- {
7
- title: '组件属性',
8
- type: 'group',
9
- titleClass: 'config-group-title',
10
- label: false
11
- },
12
- {
13
- label: '上传模式',
14
- name: 'mode',
15
- type: 'x-radios',
16
- mode: 'button',
17
- size: 'small',
18
- options: [
19
- { label: '文件', value: 'file' },
20
- { label: '图片', value: 'image' }
21
- ],
22
- pipeIn(value: string | undefined) {
23
- return value ?? 'file'
24
- },
25
- pipeOut(value: string) {
26
- return value === 'file' ? undefined : value
27
- }
28
- },
29
- {
30
- label: '多文件',
31
- name: 'multiple',
32
- type: 'switch',
33
- defaultValue: true
34
- },
35
- {
36
- label: '提示文案',
37
- name: 'tips',
38
- type: 'input',
39
- placeholder: '上传提示'
40
- }
41
- ]
42
-
43
- const uploadDataProps: XFormItem[] = [
44
- {
45
- title: '上传数据',
46
- type: 'group',
47
- titleClass: 'config-group-title',
48
- label: false
49
- },
50
- {
51
- label: '数量限制',
52
- name: 'limit',
53
- type: 'input-number',
54
- min: 1,
55
- step: 1,
56
- controlsPosition: 'right',
57
- visible(row: any) {
58
- return row.multiple !== false
59
- }
60
- },
61
- {
62
- label: '大小限制(M)',
63
- name: 'limitSize',
64
- type: 'input-number',
65
- min: 0,
66
- controlsPosition: 'right'
67
- },
68
- {
69
- label: '文件类型',
70
- name: 'accept',
71
- type: 'input',
72
- placeholder: '例如 .png,.jpg'
73
- },
74
- {
75
- label: '连接值',
76
- name: 'joinValues',
77
- type: 'switch'
78
- },
79
- {
80
- label: '连接字段',
81
- name: 'joinValuesField',
82
- type: 'input',
83
- placeholder: '默认 url',
84
- visible(row: any) {
85
- return row.joinValues === true
86
- }
87
- },
88
- {
89
- label: '值字段',
90
- name: 'valueField',
91
- type: 'input',
92
- placeholder: '默认 url',
93
- visible(row: any) {
94
- return row.joinValues === true
95
- }
96
- },
97
- {
98
- label: 'ID模式',
99
- name: 'idMode',
100
- type: 'switch'
101
- }
102
- ]
103
-
104
- export const inputUploadComponentConfig: ComponentConfig = {
105
- label: '文件上传',
106
- value: 'x-input-upload',
107
- icon: 'ri-upload-cloud-2-line',
108
- scaffold: {
109
- type: 'x-input-upload',
110
- label: '文件上传',
111
- multiple: true
112
- },
113
- replace: {
114
- groups: ['upload']
115
- },
116
- configTabs: createComponentConfigTabs({
117
- basic: uploadBasicProps,
118
- data: uploadDataProps
119
- }),
120
- configSchema: {
121
- body: [...commonProps, ...uploadBasicProps, ...uploadDataProps]
122
- }
123
- }
@@ -1,48 +0,0 @@
1
- import type { ComponentConfig } from './types'
2
- import { commonProps, createComponentConfigTabs } from './common-props'
3
- import type { XFormItem } from 'xkit-ui'
4
-
5
- const inputBasicProps: XFormItem[] = [
6
- {
7
- title: '组件属性',
8
- type: 'group',
9
- titleClass: 'config-group-title',
10
- label: false
11
- },
12
- {
13
- label: '占位提示',
14
- name: 'placeholder',
15
- type: 'input'
16
- },
17
- {
18
- label: '最大长度',
19
- name: 'maxlength',
20
- type: 'input'
21
- },
22
- {
23
- label: '允许清空',
24
- name: 'clearable',
25
- type: 'switch',
26
- defaultValue: true
27
- }
28
- ]
29
-
30
- export const inputComponentConfig: ComponentConfig = {
31
- label: '输入框',
32
- value: 'input',
33
- icon: 'ri-barcode-box-line',
34
- scaffold: {
35
- type: 'input',
36
- label: '输入框',
37
- placeholder: '请输入内容'
38
- },
39
- replace: {
40
- groups: ['placeholder', 'lengthLimit']
41
- },
42
- configTabs: createComponentConfigTabs({
43
- basic: inputBasicProps
44
- }),
45
- configSchema: {
46
- body: [...commonProps, ...inputBasicProps]
47
- }
48
- }
@@ -1,546 +0,0 @@
1
- import type { ObjectSection } from '../components/object-section-editor.vue'
2
-
3
- export const containerLayoutSections: ObjectSection[] = [
4
- {
5
- label: '列数',
6
- key: 'col',
7
- body: [
8
- {
9
- label: '默认列数',
10
- name: 'span',
11
- type: 'slider',
12
- min: 2,
13
- max: 24,
14
- step: 2,
15
- marks: {
16
- 8: '1/3',
17
- 12: '1/2',
18
- 16: '2/3',
19
- 24: '100%'
20
- },
21
- pipeIn(value: number | undefined) {
22
- return value ?? 24
23
- },
24
- pipeOut(value: number) {
25
- return value === 24 ? undefined : value
26
- }
27
- }
28
- ]
29
- },
30
- {
31
- label: '间距',
32
- key: 'row',
33
- body: [
34
- {
35
- label: '栅格间隔',
36
- name: 'gutter',
37
- type: 'input-number',
38
- min: 0,
39
- step: 1,
40
- controlsPosition: 'right',
41
- placeholder: 'gutter'
42
- }
43
- ]
44
- }
45
- ]
46
-
47
- export const inputArrayContainerLayoutSections: ObjectSection[] = [
48
- {
49
- label: '列宽',
50
- key: 'col',
51
- body: [
52
- {
53
- label: '默认每列占位',
54
- name: 'span',
55
- type: 'select',
56
- clearable: false,
57
- options: [
58
- { label: '整行', value: 24 },
59
- { label: '1/2行', value: 12 },
60
- { label: '1/3行', value: 8 },
61
- { label: '1/4行', value: 6 }
62
- ],
63
- pipeIn(value: number | undefined) {
64
- return value ?? 24
65
- },
66
- pipeOut(value: number) {
67
- return value === 24 ? undefined : value
68
- }
69
- }
70
- ]
71
- },
72
- {
73
- label: '间距',
74
- key: 'row',
75
- body: [
76
- {
77
- label: '栅格间隔',
78
- name: 'gutter',
79
- type: 'select',
80
- clearable: false,
81
- options: [
82
- { label: '小 8px', value: 8 },
83
- { label: '中 12px', value: 12 },
84
- { label: '大 16px', value: 16 },
85
- { label: '特大 20px', value: 20 }
86
- ],
87
- pipeIn(value: number | undefined) {
88
- return value ?? 8
89
- },
90
- pipeOut(value: number) {
91
- return value === 8 ? undefined : value
92
- }
93
- }
94
- ]
95
- }
96
- ]
97
-
98
- export const inputArrayItemWidthLayoutSections: ObjectSection[] = [
99
- {
100
- label: '宽度',
101
- key: 'width',
102
- body: [
103
- {
104
- label: '控件宽度',
105
- name: 'width',
106
- type: 'input',
107
- placeholder: '例如 180px 或 100%'
108
- }
109
- ]
110
- }
111
- ]
112
-
113
- export const descriptionsLayoutSections: ObjectSection[] = [
114
- {
115
- label: '基础',
116
- key: 'basic',
117
- body: [
118
- {
119
- label: '每行项数',
120
- name: 'column',
121
- type: 'input-number',
122
- min: 1,
123
- max: 6,
124
- step: 1,
125
- controlsPosition: 'right',
126
- placeholder: '默认 3'
127
- },
128
- {
129
- label: '标签宽度',
130
- name: 'labelWidth',
131
- type: 'input',
132
- placeholder: '例如 120'
133
- },
134
- {
135
- label: '排列方向',
136
- name: 'direction',
137
- type: 'x-radios',
138
- mode: 'button',
139
- size: 'small',
140
- options: [
141
- { label: '水平', value: 'horizontal' },
142
- { label: '垂直', value: 'vertical' }
143
- ]
144
- }
145
- ]
146
- },
147
- {
148
- label: '样式',
149
- key: 'style',
150
- body: [
151
- {
152
- label: '尺寸',
153
- name: 'size',
154
- type: 'x-radios',
155
- mode: 'button',
156
- size: 'small',
157
- options: [
158
- { label: '默认', value: '' },
159
- { label: '小', value: 'small' },
160
- { label: '大', value: 'large' }
161
- ]
162
- },
163
- {
164
- label: '标题',
165
- name: 'title',
166
- type: 'input'
167
- }
168
- ]
169
- }
170
- ]
171
-
172
- export const tableLayoutSections: ObjectSection[] = [
173
- {
174
- label: '基础',
175
- key: 'basic',
176
- body: [
177
- {
178
- label: '每行列数',
179
- name: 'columns',
180
- type: 'input-number',
181
- min: 2,
182
- max: 24,
183
- step: 1,
184
- controlsPosition: 'right',
185
- placeholder: '默认 4',
186
- pipeIn(value: number | undefined) {
187
- return value ?? 4
188
- },
189
- pipeOut(value: number) {
190
- return value
191
- }
192
- },
193
- {
194
- label: '标签宽度',
195
- name: 'labelWidth',
196
- type: 'input',
197
- placeholder: '例如 140'
198
- },
199
- {
200
- label: '值最小宽度',
201
- name: 'valueMinWidth',
202
- type: 'input',
203
- placeholder: '例如 220'
204
- },
205
- {
206
- label: '物理列宽',
207
- name: 'columnWidths',
208
- type: 'x-input-array',
209
- labelPosition: 'top',
210
- useScaffoldValue: false,
211
- showFooterAddButton: true,
212
- addable: true,
213
- deletable: true,
214
- useLayout: true,
215
- layout: {
216
- row: { gutter: 8 },
217
- col: { span: 24 }
218
- },
219
- pipeIn(value: Array<string | number> | undefined) {
220
- return Array.isArray(value) ? value.map((width) => ({ width })) : []
221
- },
222
- pipeOut(value: Array<{ width?: string | number }> | undefined) {
223
- const result = Array.isArray(value) ? value.map((item) => item?.width).filter((width) => width !== undefined && width !== null && width !== '') : []
224
- return result.length ? result : undefined
225
- },
226
- items: [
227
- {
228
- label: false,
229
- name: 'width',
230
- type: 'input',
231
- placeholder: '例如 160 或 25%',
232
- span: 24
233
- }
234
- ]
235
- }
236
- ]
237
- },
238
- {
239
- label: '外观',
240
- key: 'appearance',
241
- body: [
242
- {
243
- label: '外观模式',
244
- name: 'variant',
245
- type: 'x-radios',
246
- mode: 'button',
247
- size: 'small',
248
- options: [
249
- { label: '默认', value: 'default' },
250
- { label: '纯表格', value: 'plain' },
251
- { label: '文档', value: 'document' }
252
- ],
253
- pipeIn(value: string | undefined) {
254
- return value ?? 'default'
255
- },
256
- pipeOut(value: string) {
257
- return value === 'default' ? undefined : value
258
- }
259
- },
260
- {
261
- label: '边框颜色',
262
- name: 'borderColor',
263
- type: 'input',
264
- placeholder: '例如 #333'
265
- },
266
- {
267
- label: '边框宽度',
268
- name: 'borderWidth',
269
- type: 'input',
270
- placeholder: '例如 1'
271
- },
272
- {
273
- label: '标签背景',
274
- name: 'labelBackground',
275
- type: 'input',
276
- placeholder: '例如 transparent'
277
- },
278
- {
279
- label: '值背景',
280
- name: 'valueBackground',
281
- type: 'input',
282
- placeholder: '例如 transparent'
283
- },
284
- {
285
- label: '标签字重',
286
- name: 'labelFontWeight',
287
- type: 'input',
288
- placeholder: '例如 400'
289
- },
290
- {
291
- label: '单元格内边距',
292
- name: 'cellPadding',
293
- type: 'input',
294
- placeholder: '例如 6px 8px'
295
- },
296
- {
297
- label: '控件边框',
298
- name: 'controlBorder',
299
- type: 'switch',
300
- labelRemark: '关闭后,输入框、选择框等控件自身边框会隐藏,更接近 Word 表格。'
301
- },
302
- {
303
- label: '占位提示',
304
- name: 'showPlaceholder',
305
- type: 'switch',
306
- labelRemark: '文档模式默认隐藏占位提示,开启后显示输入框、选择框等控件的 placeholder。',
307
- pipeIn(value: boolean | undefined, formValue: Record<string, any>) {
308
- if (typeof value === 'boolean') return value
309
- return formValue.variant !== 'document'
310
- },
311
- pipeOut(value: boolean) {
312
- return value
313
- }
314
- }
315
- ]
316
- },
317
- {
318
- label: '高级',
319
- key: 'advanced',
320
- body: [
321
- {
322
- label: '值宽度',
323
- name: 'valueWidth',
324
- type: 'input',
325
- placeholder: '例如 240'
326
- },
327
- {
328
- label: '行高',
329
- name: 'rowHeight',
330
- type: 'input',
331
- placeholder: '例如 48'
332
- }
333
- ]
334
- }
335
- ]
336
-
337
- export const descriptionsItemLayoutSections: ObjectSection[] = [
338
- {
339
- label: '基础',
340
- key: 'basic',
341
- body: [
342
- {
343
- label: '占用项数',
344
- name: 'span',
345
- type: 'input-number',
346
- min: 1,
347
- max: 8,
348
- step: 1,
349
- controlsPosition: 'right',
350
- placeholder: '默认 1'
351
- },
352
- {
353
- label: '标签宽度',
354
- name: 'labelWidth',
355
- type: 'input',
356
- placeholder: '例如 120'
357
- }
358
- ]
359
- },
360
- {
361
- label: '高级',
362
- key: 'advanced',
363
- body: [
364
- {
365
- label: '行合并',
366
- name: 'rowspan',
367
- type: 'input-number',
368
- min: 1,
369
- step: 1,
370
- controlsPosition: 'right'
371
- },
372
- {
373
- label: '内容宽度',
374
- name: 'width',
375
- type: 'input'
376
- },
377
- {
378
- label: '最小宽度',
379
- name: 'minWidth',
380
- type: 'input'
381
- }
382
- ]
383
- }
384
- ]
385
-
386
- export const tableItemLayoutSections: ObjectSection[] = [
387
- {
388
- label: '基础',
389
- key: 'basic',
390
- body: [
391
- {
392
- label: '标签占列',
393
- name: 'labelColspan',
394
- type: 'input-number',
395
- min: 1,
396
- step: 1,
397
- controlsPosition: 'right',
398
- placeholder: '默认 1'
399
- },
400
- {
401
- label: '值占列',
402
- name: 'valueColspan',
403
- type: 'input-number',
404
- min: 1,
405
- step: 1,
406
- controlsPosition: 'right',
407
- placeholder: '默认 1'
408
- },
409
- {
410
- label: '标签宽度',
411
- name: 'labelWidth',
412
- type: 'input',
413
- placeholder: '例如 140'
414
- },
415
- {
416
- label: '值最小宽度',
417
- name: 'valueMinWidth',
418
- type: 'input',
419
- placeholder: '例如 220'
420
- }
421
- ]
422
- },
423
- {
424
- label: '高级',
425
- key: 'advanced',
426
- body: [
427
- {
428
- label: '行合并',
429
- name: 'rowspan',
430
- type: 'input-number',
431
- min: 1,
432
- step: 1,
433
- controlsPosition: 'right'
434
- }
435
- ]
436
- }
437
- ]
438
-
439
- export const inputTableNestedColumnLayoutSections: ObjectSection[] = [
440
- {
441
- label: '基础',
442
- key: 'basic',
443
- body: [
444
- {
445
- label: '内容对齐',
446
- name: 'align',
447
- type: 'x-radios',
448
- mode: 'button',
449
- size: 'small',
450
- options: [
451
- { label: '继承', value: '' },
452
- { label: '左', value: 'left' },
453
- { label: '中', value: 'center' },
454
- { label: '右', value: 'right' }
455
- ],
456
- pipeIn(value: string | undefined) {
457
- return value ?? ''
458
- },
459
- pipeOut(value: string) {
460
- return value || undefined
461
- }
462
- },
463
- {
464
- label: '表头对齐',
465
- name: 'headerAlign',
466
- type: 'x-radios',
467
- mode: 'button',
468
- size: 'small',
469
- options: [
470
- { label: '继承', value: '' },
471
- { label: '左', value: 'left' },
472
- { label: '中', value: 'center' },
473
- { label: '右', value: 'right' }
474
- ],
475
- pipeIn(value: string | undefined) {
476
- return value ?? ''
477
- },
478
- pipeOut(value: string) {
479
- return value || undefined
480
- }
481
- },
482
- {
483
- label: '最小宽度',
484
- name: 'minWidth',
485
- type: 'input',
486
- placeholder: '例如 160'
487
- }
488
- ]
489
- }
490
- ]
491
-
492
- export const inputTableMergedColumnLayoutSections: ObjectSection[] = [
493
- {
494
- label: '基础',
495
- key: 'basic',
496
- body: [
497
- {
498
- label: '内容对齐',
499
- name: 'align',
500
- type: 'x-radios',
501
- mode: 'button',
502
- size: 'small',
503
- options: [
504
- { label: '继承', value: '' },
505
- { label: '左', value: 'left' },
506
- { label: '中', value: 'center' },
507
- { label: '右', value: 'right' }
508
- ],
509
- pipeIn(value: string | undefined) {
510
- return value ?? ''
511
- },
512
- pipeOut(value: string) {
513
- return value || undefined
514
- }
515
- },
516
- {
517
- label: '表头对齐',
518
- name: 'headerAlign',
519
- type: 'x-radios',
520
- mode: 'button',
521
- size: 'small',
522
- options: [
523
- { label: '继承', value: '' },
524
- { label: '左', value: 'left' },
525
- { label: '中', value: 'center' },
526
- { label: '右', value: 'right' }
527
- ],
528
- pipeIn(value: string | undefined) {
529
- return value ?? ''
530
- },
531
- pipeOut(value: string) {
532
- return value || undefined
533
- }
534
- },
535
- {
536
- label: '占列',
537
- name: 'colspan',
538
- type: 'input-number',
539
- min: 1,
540
- step: 1,
541
- controlsPosition: 'right',
542
- placeholder: '默认 1'
543
- }
544
- ]
545
- }
546
- ]