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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xkit-editor",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "lib/xkit-editor.umd.cjs",
@@ -15,14 +15,13 @@
15
15
  },
16
16
  "files": [
17
17
  "lib",
18
- "types",
19
- "src"
18
+ "types"
20
19
  ],
21
20
  "dependencies": {
22
21
  "element-plus": "^2.9.3",
23
22
  "sortablejs": "^1.15.6",
24
23
  "vue": "^3.5.12",
25
- "xkit-ui": "2.0.0-alpha.0"
24
+ "xkit-ui": "2.0.0-alpha.1"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@tsconfig/node22": "^22.0.0",
@@ -1,288 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { componentList, componentPaletteGroups } from '../../config'
3
-
4
- describe('componentList', () => {
5
- const expectNoSchemaId = (value: unknown) => {
6
- if (!value || typeof value !== 'object') return
7
- if (Array.isArray(value)) {
8
- value.forEach(expectNoSchemaId)
9
- return
10
- }
11
-
12
- expect(value).not.toHaveProperty('id')
13
- Object.values(value).forEach(expectNoSchemaId)
14
- }
15
-
16
- it('groups palette materials into layout containers and form controls', () => {
17
- expect(componentPaletteGroups.map((group) => group.label)).toEqual(['组合容器', '基础控件'])
18
- expect(componentPaletteGroups[0].items.map((item) => item.value)).toEqual(['group', 'x-input-table', 'x-input-array'])
19
- expect(componentPaletteGroups[0].items.every((item) => item.editorKind === 'container')).toBe(true)
20
- expect(componentPaletteGroups[1].items.every((item) => item.editorKind !== 'container')).toBe(true)
21
- expect(componentList).toEqual(componentPaletteGroups.flatMap((group) => group.items))
22
- })
23
-
24
- it('registers input upload material without schema id', () => {
25
- const upload = componentList.find((item) => item.value === 'x-input-upload')
26
-
27
- expect(upload?.scaffold).toMatchObject({
28
- type: 'x-input-upload',
29
- label: '文件上传',
30
- multiple: true
31
- })
32
- expect(upload?.scaffold).not.toHaveProperty('id')
33
- })
34
-
35
- it('registers icon select material with serializable icon source selection', () => {
36
- const iconSelect = componentList.find((item) => item.value === 'x-icon-select')
37
-
38
- expect(iconSelect?.scaffold).toMatchObject({
39
- type: 'x-icon-select',
40
- label: '图标选择器',
41
- clearable: true,
42
- iconSources: []
43
- })
44
- expect(iconSelect?.scaffold).not.toHaveProperty('iconLibs')
45
- expect(iconSelect?.scaffold).not.toHaveProperty('id')
46
- })
47
-
48
- it('registers input table material with idField and schema items without id', () => {
49
- const inputTable = componentList.find((item) => item.value === 'x-input-table')
50
-
51
- expect(inputTable?.scaffold).toMatchObject({
52
- type: 'x-input-table',
53
- label: '表格输入器',
54
- name: 'tableData',
55
- border: true,
56
- idField: 'id',
57
- items: [
58
- {
59
- label: '字段名称',
60
- name: 'name',
61
- type: 'input',
62
- width: 160
63
- },
64
- {
65
- label: '操作',
66
- type: 'operation',
67
- width: 100
68
- }
69
- ]
70
- })
71
- expectNoSchemaId(inputTable?.scaffold)
72
- })
73
-
74
- it('registers input array material with idField and schema items without id', () => {
75
- const inputArray = componentList.find((item) => item.value === 'x-input-array')
76
- const dataTab = inputArray?.configTabs?.find((item) => item.key === 'data')
77
- const layoutTab = inputArray?.configTabs?.find((item) => item.key === 'layout')
78
- const fieldNames = dataTab?.body.map((item: any) => item.name).filter(Boolean)
79
- const layoutTitles = layoutTab?.body.map((item: any) => item.title).filter(Boolean)
80
- const layoutField = layoutTab?.body.find((item: any) => item.name === 'layout') as any
81
- const spanField = layoutField?.sections?.find((section: any) => section.key === 'col')?.body?.find((item: any) => item.name === 'span')
82
- const gutterField = layoutField?.sections?.find((section: any) => section.key === 'row')?.body?.find((item: any) => item.name === 'gutter')
83
-
84
- expect(inputArray?.scaffold).toMatchObject({
85
- type: 'x-input-array',
86
- label: '数组输入器',
87
- name: 'arrayData',
88
- idField: 'id',
89
- addable: true,
90
- deletable: true,
91
- useScaffoldValue: true,
92
- showInlineAddButton: true,
93
- items: [
94
- {
95
- label: '字段名称',
96
- name: 'name',
97
- type: 'input'
98
- }
99
- ]
100
- })
101
- expect(inputArray?.replace?.groups).toEqual(['collection'])
102
- expect(fieldNames).toContain('defaultValue')
103
- expect(layoutTitles).toEqual(['作为表单项的配置', '作为容器的配置'])
104
- expect(layoutField.visible({ useLayout: false })).toBe(false)
105
- expect(layoutField.visible({ useLayout: true })).toBe(true)
106
- expect(spanField).toMatchObject({
107
- label: '默认每列占位',
108
- type: 'select',
109
- options: [
110
- { label: '整行', value: 24 },
111
- { label: '1/2行', value: 12 },
112
- { label: '1/3行', value: 8 },
113
- { label: '1/4行', value: 6 }
114
- ]
115
- })
116
- expect(gutterField).toMatchObject({
117
- label: '栅格间隔',
118
- type: 'select',
119
- options: [
120
- { label: '小 8px', value: 8 },
121
- { label: '中 12px', value: 12 },
122
- { label: '大 16px', value: 16 },
123
- { label: '特大 20px', value: 20 }
124
- ]
125
- })
126
- expectNoSchemaId(inputArray?.scaffold)
127
- })
128
-
129
- it('registers input number range material with numeric configuration', () => {
130
- const inputNumberRange = componentList.find((item) => item.value === 'x-input-number-range')
131
- const dataTab = inputNumberRange?.configTabs?.find((item) => item.key === 'data')
132
- const basicTab = inputNumberRange?.configTabs?.find((item) => item.key === 'basic')
133
- const dataFieldNames = dataTab?.body.map((item: any) => item.name).filter(Boolean)
134
- const basicFieldNames = basicTab?.body.map((item: any) => item.name).filter(Boolean)
135
-
136
- expect(inputNumberRange?.scaffold).toMatchObject({
137
- type: 'x-input-number-range',
138
- label: '数值范围',
139
- name: 'numberRange',
140
- startPlaceholder: '最小值',
141
- endPlaceholder: '最大值',
142
- rangeSeperator: '至',
143
- controls: true
144
- })
145
- expect(inputNumberRange?.replace?.groups).toEqual(['placeholder', 'numeric'])
146
- expect(dataFieldNames).toEqual(['min', 'max', 'step', 'precision', 'stepStrictly', 'joinValues'])
147
- expect(basicFieldNames).toEqual(['label', 'sync', 'labelPosition', 'startPlaceholder', 'endPlaceholder', 'rangeSeperator', 'controls', 'controlsPosition'])
148
- expectNoSchemaId(inputNumberRange?.scaffold)
149
- })
150
-
151
- it('configures input number range field mapping through sync', () => {
152
- const inputNumberRange = componentList.find((item) => item.value === 'x-input-number-range')
153
- const basicTab = inputNumberRange?.configTabs?.find((item) => item.key === 'basic')
154
- const syncField = basicTab?.body.find((item: any) => item.name === 'sync') as any
155
-
156
- expect(syncField?.type).toBe('custom')
157
- expect(syncField?.label).toBe(false)
158
- expect(syncField?.sync).toEqual([{ name: 'name', syncName: 'name' }])
159
- expect(syncField?.component).toBeTruthy()
160
- })
161
-
162
- it('registers date range materials with separate start and end field mapping', () => {
163
- const legacyDateRange = componentList.find((item) => item.value === 'x-date-range-picker')
164
- const dateRangeV2 = componentList.find((item) => item.value === 'x-date-range-picker-v2')
165
- const legacyBasicTab = legacyDateRange?.configTabs?.find((item) => item.key === 'basic')
166
- const v2BasicTab = dateRangeV2?.configTabs?.find((item) => item.key === 'basic')
167
- const legacySyncField = legacyBasicTab?.body.find((item: any) => item.name === 'sync') as any
168
- const v2SyncField = v2BasicTab?.body.find((item: any) => item.name === 'sync') as any
169
-
170
- expect(legacyDateRange?.scaffold).toMatchObject({
171
- type: 'x-date-range-picker',
172
- label: '日期范围',
173
- rangeSeperator: '至',
174
- _type: 'daterange',
175
- valueFormat: 'YYYY-MM-DD',
176
- sync: [
177
- { name: 'startDate', syncName: 'startDate' },
178
- { name: 'endDate', syncName: 'endDate' }
179
- ]
180
- })
181
- expect(dateRangeV2?.scaffold).toMatchObject({
182
- type: 'x-date-range-picker-v2',
183
- label: '日期范围',
184
- rangeSeperator: '至',
185
- valueFormat: 'YYYY-MM-DD',
186
- format: 'YYYY-MM-DD',
187
- sync: [
188
- { name: 'startDate', syncName: 'startDate' },
189
- { name: 'endDate', syncName: 'endDate' }
190
- ]
191
- })
192
- expect(legacySyncField).toMatchObject({
193
- type: 'custom',
194
- label: false,
195
- allowTuple: false,
196
- startSyncName: 'startDate',
197
- endSyncName: 'endDate'
198
- })
199
- expect(v2SyncField).toMatchObject({
200
- type: 'custom',
201
- label: false,
202
- allowTuple: false,
203
- startSyncName: 'startDate',
204
- endSyncName: 'endDate'
205
- })
206
- expectNoSchemaId(legacyDateRange?.scaffold)
207
- expectNoSchemaId(dateRangeV2?.scaffold)
208
- })
209
-
210
- it('configures input table data tab for preset rows instead of columns', () => {
211
- const inputTable = componentList.find((item) => item.value === 'x-input-table')
212
- const dataTab = inputTable?.configTabs?.find((item) => item.key === 'data')
213
- const operationTab = inputTable?.configTabs?.find((item) => item.key === 'operation')
214
- const fieldNames = dataTab?.body.map((item: any) => item.name).filter(Boolean)
215
- const operationFieldNames = operationTab?.body.map((item: any) => item.name).filter(Boolean)
216
-
217
- expect(fieldNames).toContain('defaultValue')
218
- expect(fieldNames).not.toContain('items')
219
- expect(fieldNames).not.toContain('footerToolbar')
220
- expect(operationFieldNames).toContain('items')
221
- expect(operationFieldNames).toContain('footerToolbar')
222
- })
223
-
224
- it('registers radios material with runtime schema type', () => {
225
- const radios = componentList.find((item) => item.value === 'x-radios')
226
-
227
- expect(radios?.scaffold).toMatchObject({
228
- type: 'x-radios',
229
- label: '单选框',
230
- options: [
231
- { label: '选项一', value: '1' },
232
- { label: '选项二', value: '2' }
233
- ]
234
- })
235
- expectNoSchemaId(radios?.scaffold)
236
- })
237
-
238
- it('registers checkboxes material with runtime schema type and options', () => {
239
- const checkboxes = componentList.find((item) => item.value === 'x-checkboxes')
240
- const dataTab = checkboxes?.configTabs?.find((item) => item.key === 'data')
241
- const fieldNames = dataTab?.body.map((item: any) => item.name).filter(Boolean)
242
-
243
- expect(checkboxes?.scaffold).toMatchObject({
244
- type: 'x-checkboxes',
245
- label: '多选框',
246
- options: [
247
- { label: '选项一', value: '1' },
248
- { label: '选项二', value: '2' }
249
- ]
250
- })
251
- expect(fieldNames).toContain('options')
252
- expectNoSchemaId(checkboxes?.scaffold)
253
- })
254
-
255
- it('registers checkbox material as a single boolean-style control', () => {
256
- const checkbox = componentList.find((item) => item.value === 'checkbox')
257
- const dataTab = checkbox?.configTabs?.find((item) => item.key === 'data')
258
-
259
- expect(checkbox?.scaffold).toMatchObject({
260
- type: 'checkbox',
261
- label: '勾选框'
262
- })
263
- expect(checkbox?.scaffold).not.toHaveProperty('options')
264
- expect(dataTab?.body.map((item: any) => item.name).filter(Boolean)).toEqual([])
265
- expectNoSchemaId(checkbox?.scaffold)
266
- })
267
-
268
- it('configures common validation tab with rules editor', () => {
269
- const input = componentList.find((item) => item.value === 'input')
270
- const validationTab = input?.configTabs?.find((item) => item.key === 'validation')
271
- const fieldNames = validationTab?.body.map((item: any) => item.name).filter(Boolean)
272
-
273
- expect(fieldNames).toContain('rules')
274
- })
275
-
276
- it('shows missing dynamic state fields as their runtime defaults', () => {
277
- const input = componentList.find((item) => item.value === 'input')
278
- const advancedTab = input?.configTabs?.find((item) => item.key === 'advanced')
279
- const visible = advancedTab?.body.find((item: any) => item.name === 'visible') as any
280
- const disabled = advancedTab?.body.find((item: any) => item.name === 'disabled') as any
281
- const staticItem = advancedTab?.body.find((item: any) => item.name === 'static') as any
282
-
283
- expect(visible.pipeIn(undefined)).toBe(true)
284
- expect(visible.pipeIn(false)).toBe(false)
285
- expect(disabled.pipeIn(undefined)).toBe(false)
286
- expect(staticItem.pipeIn(undefined)).toBe(false)
287
- })
288
- })
@@ -1,104 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { groupComponentConfig } from '../group'
3
- import { getEditorGroupTitleStyles, registerEditorGroupTitleStyle } from '../../group-title-styles'
4
-
5
- describe('groupComponentConfig', () => {
6
- it('adds a schema-safe group scaffold for the editor palette', () => {
7
- expect(groupComponentConfig.scaffold).toMatchObject({
8
- type: 'group',
9
- title: '分组',
10
- label: false,
11
- span: 24,
12
- body: []
13
- })
14
- expect(groupComponentConfig.scaffold).not.toHaveProperty('id')
15
- })
16
-
17
- it('edits group label with a switch instead of a text input', () => {
18
- const basicTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'basic')
19
- const labelField = basicTab?.body.find((item) => item.name === 'label') as any
20
-
21
- expect(labelField?.type).toBe('switch')
22
- expect(labelField.pipeIn(false)).toBe(false)
23
- expect(labelField.pipeIn('基础信息')).toBe(true)
24
- expect(labelField.pipeOut(false, { title: '基础信息' })).toBe(false)
25
- expect(labelField.pipeOut(true, { title: '基础信息' })).toBe('基础信息')
26
- })
27
-
28
- it('separates parent item layout from child container layout', () => {
29
- const layoutTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'layout')
30
- const titles = layoutTab?.body.map((item: any) => item.title).filter(Boolean)
31
- const fieldNames = layoutTab?.body.map((item: any) => item.name).filter(Boolean)
32
-
33
- expect(titles).toEqual(['作为表单项的布局', '容器本身布局配置'])
34
- expect(fieldNames).toEqual(['span', 'layout'])
35
- })
36
-
37
- it('edits group title class through the registered style picker', () => {
38
- const advancedTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'advanced')
39
- const titleClassField = advancedTab?.body.find((item) => item.name === 'titleClass') as any
40
-
41
- expect(titleClassField?.type).toBe('custom')
42
- expect(getEditorGroupTitleStyles().map((style) => style.className)).toContain('x-group-title--bar')
43
- expect(getEditorGroupTitleStyles().map((style) => style.className)).toContain('x-group-title--gradient-bar')
44
- })
45
-
46
- it('edits group title alignment independently from title style', () => {
47
- const advancedTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'advanced')
48
- const titleAlignField = advancedTab?.body.find((item) => item.name === 'titleAlign') as any
49
-
50
- expect(titleAlignField?.type).toBe('x-radios')
51
- expect(titleAlignField.pipeIn(undefined)).toBe('left')
52
- expect(titleAlignField.pipeOut('left')).toBeUndefined()
53
- expect(titleAlignField.pipeOut('center')).toBe('center')
54
- expect(titleAlignField.pipeOut('right')).toBe('right')
55
- })
56
-
57
- it('exposes constrained title size and color instead of developer class fields', () => {
58
- const advancedTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'advanced')
59
- const fieldNames = advancedTab?.body.map((item: any) => item.name).filter(Boolean)
60
- const titleSizeField = advancedTab?.body.find((item) => item.name === 'titleSize') as any
61
- const titleColorField = advancedTab?.body.find((item) => item.name === 'titleColor') as any
62
-
63
- expect(fieldNames).toContain('titleSize')
64
- expect(fieldNames).toContain('titleColor')
65
- expect(fieldNames).not.toContain('bodyClass')
66
- expect(fieldNames).not.toContain('class')
67
- expect(titleSizeField.pipeIn(undefined)).toBe('medium')
68
- expect(titleSizeField.pipeOut('medium')).toBeUndefined()
69
- expect(titleSizeField.pipeOut('large')).toBe('large')
70
- expect(titleColorField.type).toBe('custom')
71
- expect(titleColorField.component).toBeTruthy()
72
- })
73
-
74
- it('configures group title icon with the icon selector', () => {
75
- const advancedTab = groupComponentConfig.configTabs?.find((tab) => tab.key === 'advanced')
76
- const titleIconField = advancedTab?.body.find((item) => item.name === 'titleIcon') as any
77
-
78
- expect(titleIconField?.type).toBe('x-icon-select')
79
- expect(titleIconField.clearable).toBe(true)
80
- expect(titleIconField).not.toHaveProperty('iconSources')
81
- })
82
- })
83
-
84
- describe('group title style registry', () => {
85
- it('registers and unregisters developer provided title styles', () => {
86
- const unregister = registerEditorGroupTitleStyle({
87
- key: 'test-style',
88
- label: '测试样式',
89
- className: 'test-group-title',
90
- description: '仅用于测试'
91
- })
92
-
93
- expect(getEditorGroupTitleStyles()).toContainEqual({
94
- key: 'test-style',
95
- label: '测试样式',
96
- className: 'test-group-title',
97
- description: '仅用于测试'
98
- })
99
-
100
- unregister()
101
-
102
- expect(getEditorGroupTitleStyles().some((style) => style.key === 'test-style')).toBe(false)
103
- })
104
- })
@@ -1,20 +0,0 @@
1
- import type { ComponentConfig } from './types'
2
- import { commonProps, createComponentConfigTabs } from './common-props'
3
-
4
- export const cascaderComponentConfig: ComponentConfig = {
5
- label: '级联选择器',
6
- value: 'cascader',
7
- icon: 'ri-node-tree',
8
- scaffold: {
9
- type: 'cascader',
10
- label: '级联选择器',
11
- options: []
12
- },
13
- replace: {
14
- groups: ['options']
15
- },
16
- configTabs: createComponentConfigTabs({}),
17
- configSchema: {
18
- body: [...commonProps]
19
- }
20
- }
@@ -1,43 +0,0 @@
1
- import type { ComponentConfig } from './types'
2
- import { commonProps, createComponentConfigTabs } from './common-props'
3
- import { optionsConfigItem } from './options-config'
4
-
5
- export const checkboxComponentConfig: ComponentConfig = {
6
- label: '单勾选框',
7
- value: 'checkbox',
8
- icon: 'ri-checkbox-line',
9
- scaffold: {
10
- type: 'checkbox',
11
- label: '勾选框'
12
- },
13
- replace: {
14
- groups: []
15
- },
16
- configTabs: createComponentConfigTabs({}),
17
- configSchema: {
18
- body: [...commonProps]
19
- }
20
- }
21
-
22
- export const checkboxesComponentConfig: ComponentConfig = {
23
- label: '多选框',
24
- value: 'x-checkboxes',
25
- icon: 'ri-checkbox-multiple-line',
26
- scaffold: {
27
- type: 'x-checkboxes',
28
- label: '多选框',
29
- options: [
30
- { label: '选项一', value: '1' },
31
- { label: '选项二', value: '2' }
32
- ]
33
- },
34
- replace: {
35
- groups: ['options']
36
- },
37
- configTabs: createComponentConfigTabs({
38
- data: [optionsConfigItem]
39
- }),
40
- configSchema: {
41
- body: [...commonProps, optionsConfigItem]
42
- }
43
- }
@@ -1,130 +0,0 @@
1
- import { markRaw } from 'vue'
2
- import ConditionEditor from '../components/condition-editor.vue'
3
- import FormItemLayoutEditor from '../components/form-item-layout-editor.vue'
4
- import ValidationRulesEditor from '../components/validation-rules-editor.vue'
5
- import type { XFormItem } from 'xkit-ui'
6
- import type { EditorConfigTab } from './types'
7
-
8
- export const commonBasicProps: XFormItem[] = [
9
- {
10
- title: '基本信息',
11
- label: false,
12
- type: 'group',
13
- titleClass: 'config-group-title',
14
- body: []
15
- },
16
- {
17
- label: '字段中文名',
18
- name: 'label',
19
- type: 'input',
20
- placeholder: '请输入字段中文名'
21
- },
22
- {
23
- label: '字段名',
24
- name: 'name',
25
- type: 'input',
26
- placeholder: '请输入字段名'
27
- },
28
- {
29
- label: '标签位置',
30
- name: 'labelPosition',
31
- type: 'select',
32
- // mode: 'button',
33
- // size: 'small',
34
- options: [
35
- { label: '继承', value: '' },
36
- { label: '左', value: 'left' },
37
- { label: '上', value: 'top' },
38
- { label: '右', value: 'right' }
39
- ],
40
- pipeIn(value: string | undefined) {
41
- return value ?? ''
42
- },
43
- pipeOut(value: string) {
44
- return value || undefined
45
- }
46
- }
47
- ]
48
-
49
- export const commonLayoutProps: XFormItem[] = [
50
- {
51
- title: '布局配置',
52
- name: 'span',
53
- type: 'custom',
54
- component: markRaw(FormItemLayoutEditor),
55
- titleClass: 'config-group-title',
56
- label: false,
57
- sync: [{ name: 'offsetRight', syncName: 'offsetRight' }]
58
- }
59
- ]
60
-
61
- export const commonAdvancedProps: XFormItem[] = [
62
- {
63
- title: '状态控制',
64
- type: 'group',
65
- titleClass: 'config-group-title',
66
- label: false
67
- },
68
- {
69
- label: '是否可见',
70
- name: 'visible',
71
- type: 'custom',
72
- component: markRaw(ConditionEditor),
73
- stateKind: 'visible',
74
- _defaultValue: true,
75
- pipeIn(value: any) {
76
- return value === undefined ? true : value
77
- }
78
- },
79
- {
80
- label: '是否禁用',
81
- name: 'disabled',
82
- type: 'custom',
83
- component: markRaw(ConditionEditor),
84
- stateKind: 'disabled',
85
- _defaultValue: false,
86
- pipeIn(value: any) {
87
- return value === undefined ? false : value
88
- }
89
- },
90
- {
91
- label: '是否静态',
92
- name: 'static',
93
- type: 'custom',
94
- component: markRaw(ConditionEditor),
95
- stateKind: 'static',
96
- _defaultValue: false,
97
- pipeIn(value: any) {
98
- return value === undefined ? false : value
99
- }
100
- }
101
- ]
102
-
103
- export const commonValidationProps: XFormItem[] = [
104
- {
105
- title: '校验规则',
106
- name: 'rules',
107
- type: 'custom',
108
- component: markRaw(ValidationRulesEditor),
109
- titleClass: 'config-group-title',
110
- label: false
111
- }
112
- ]
113
-
114
- export const commonProps: XFormItem[] = [...commonBasicProps, ...commonLayoutProps, ...commonValidationProps, ...commonAdvancedProps]
115
-
116
- export const createComponentConfigTabs = (tabs: {
117
- basic?: XFormItem[]
118
- layout?: XFormItem[]
119
- data?: XFormItem[]
120
- operation?: XFormItem[]
121
- validation?: XFormItem[]
122
- advanced?: XFormItem[]
123
- }): EditorConfigTab[] => [
124
- { key: 'basic', body: [...commonBasicProps, ...(tabs.basic || [])] },
125
- { key: 'layout', body: [...commonLayoutProps, ...(tabs.layout || [])] },
126
- { key: 'data', body: tabs.data || [] },
127
- { key: 'operation', body: tabs.operation || [] },
128
- { key: 'validation', body: [...commonValidationProps, ...(tabs.validation || [])] },
129
- { key: 'advanced', body: [...commonAdvancedProps, ...(tabs.advanced || [])] }
130
- ]