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.
- package/README.md +26 -0
- package/lib/packages/editor/src/components/json-code-editor.vue.d.ts +2 -0
- package/lib/packages/editor/src/components/json-code-editor.vue.d.ts.map +1 -1
- package/lib/packages/editor/src/x-editor.vue.d.ts +8 -0
- package/lib/packages/editor/src/x-editor.vue.d.ts.map +1 -1
- package/lib/packages/ui/src/components/radios/type.d.ts +2 -2
- package/lib/xkit-editor.css +1 -1
- package/lib/xkit-editor.js +64 -52
- package/lib/xkit-editor.umd.cjs +2 -2
- package/package.json +3 -4
- package/src/component-configs/__tests__/config.test.ts +0 -288
- package/src/component-configs/__tests__/group.test.ts +0 -104
- package/src/component-configs/cascader.ts +0 -20
- package/src/component-configs/checkbox.ts +0 -43
- package/src/component-configs/common-props.ts +0 -130
- package/src/component-configs/date-picker.ts +0 -153
- package/src/component-configs/date-range-picker.ts +0 -185
- package/src/component-configs/group.ts +0 -196
- package/src/component-configs/icon-select.ts +0 -56
- package/src/component-configs/input-array.ts +0 -184
- package/src/component-configs/input-number-range.ts +0 -143
- package/src/component-configs/input-number.ts +0 -111
- package/src/component-configs/input-table.ts +0 -191
- package/src/component-configs/input-upload.ts +0 -123
- package/src/component-configs/input.ts +0 -48
- package/src/component-configs/layout-sections.ts +0 -546
- package/src/component-configs/options-config.ts +0 -12
- package/src/component-configs/radio.ts +0 -26
- package/src/component-configs/select.ts +0 -42
- package/src/component-configs/switch.ts +0 -19
- package/src/component-configs/textarea.ts +0 -84
- package/src/component-configs/types.ts +0 -37
- package/src/components/condition-editor.vue +0 -641
- package/src/components/design-renderers/input-array-design.vue +0 -283
- package/src/components/design-renderers/input-table-design.vue +0 -311
- package/src/components/form-item-layout-editor.vue +0 -291
- package/src/components/form-item-span-editor.vue +0 -328
- package/src/components/form-layout-editor.vue +0 -263
- package/src/components/group-title-color-select.vue +0 -75
- package/src/components/group-title-style-picker.vue +0 -125
- package/src/components/input-number-range-binding-editor.vue +0 -226
- package/src/components/input-table-default-rows-editor.vue +0 -147
- package/src/components/input-table-operation-editor.vue +0 -168
- package/src/components/json-code-editor.vue +0 -219
- package/src/components/object-section-editor.vue +0 -342
- package/src/components/options/default-dict-options-panel.vue +0 -197
- package/src/components/options/options-editor.vue +0 -161
- package/src/components/table-columns-editor.vue +0 -353
- package/src/components/validation-rules-editor.vue +0 -321
- package/src/config.ts +0 -51
- package/src/editor-item-wrapper.vue +0 -254
- package/src/group-title-styles.ts +0 -82
- package/src/index.ts +0 -6
- package/src/option-sources.ts +0 -45
- package/src/root-configs.ts +0 -278
- package/src/shims-vue.d.ts +0 -5
- package/src/utils/__tests__/component-replace.test.ts +0 -129
- package/src/utils/__tests__/editor-schema.test.ts +0 -429
- package/src/utils/__tests__/form-item-width.test.ts +0 -53
- package/src/utils/__tests__/group-drag-path.test.ts +0 -84
- package/src/utils/__tests__/record-field.test.ts +0 -34
- package/src/utils/component-replace.ts +0 -67
- package/src/utils/editor-schema.ts +0 -374
- package/src/utils/form-item-width.ts +0 -40
- package/src/utils/local-dict-center.ts +0 -81
- package/src/utils/record-field.ts +0 -30
- package/src/validation-rules.ts +0 -104
- package/src/x-editor.vue +0 -1300
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { markRaw } from 'vue'
|
|
2
|
-
import type { ComponentConfig } from './types'
|
|
3
|
-
import { commonAdvancedProps, commonBasicProps, commonValidationProps } from './common-props'
|
|
4
|
-
import ObjectSectionEditor from '../components/object-section-editor.vue'
|
|
5
|
-
import InputTableDefaultRowsEditor from '../components/input-table-default-rows-editor.vue'
|
|
6
|
-
import FormItemLayoutEditor from '../components/form-item-layout-editor.vue'
|
|
7
|
-
import { inputArrayContainerLayoutSections } from './layout-sections'
|
|
8
|
-
import type { XFormItem } from 'xkit-ui'
|
|
9
|
-
|
|
10
|
-
const inputArrayBasicProps: XFormItem[] = [
|
|
11
|
-
{
|
|
12
|
-
title: '组件属性',
|
|
13
|
-
type: 'group',
|
|
14
|
-
titleClass: 'config-group-title',
|
|
15
|
-
label: false
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
label: '行ID字段',
|
|
19
|
-
name: 'idField',
|
|
20
|
-
type: 'input',
|
|
21
|
-
placeholder: '默认 id'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
label: '拖拽排序',
|
|
25
|
-
name: 'draggable',
|
|
26
|
-
type: 'switch'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: '允许新增',
|
|
30
|
-
name: 'addable',
|
|
31
|
-
type: 'switch',
|
|
32
|
-
defaultValue: true
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: '允许删除',
|
|
36
|
-
name: 'deletable',
|
|
37
|
-
type: 'switch',
|
|
38
|
-
defaultValue: true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: '最少行数',
|
|
42
|
-
name: 'minLength',
|
|
43
|
-
type: 'input-number',
|
|
44
|
-
min: 0,
|
|
45
|
-
step: 1,
|
|
46
|
-
controlsPosition: 'right'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: '最多行数',
|
|
50
|
-
name: 'maxLength',
|
|
51
|
-
type: 'input-number',
|
|
52
|
-
min: 1,
|
|
53
|
-
step: 1,
|
|
54
|
-
controlsPosition: 'right'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: '空值脚手架',
|
|
58
|
-
name: 'useScaffoldValue',
|
|
59
|
-
type: 'switch',
|
|
60
|
-
defaultValue: true
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: '行内新增按钮',
|
|
64
|
-
name: 'showInlineAddButton',
|
|
65
|
-
type: 'switch',
|
|
66
|
-
defaultValue: true
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: '底部新增按钮',
|
|
70
|
-
name: 'showFooterAddButton',
|
|
71
|
-
type: 'switch'
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
|
|
75
|
-
const inputArrayLayoutProps: XFormItem[] = [
|
|
76
|
-
{
|
|
77
|
-
title: '作为表单项的配置',
|
|
78
|
-
type: 'group',
|
|
79
|
-
titleClass: 'config-group-title',
|
|
80
|
-
label: false
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: 'span',
|
|
84
|
-
type: 'custom',
|
|
85
|
-
component: markRaw(FormItemLayoutEditor),
|
|
86
|
-
label: false,
|
|
87
|
-
sync: [{ name: 'offsetRight', syncName: 'offsetRight' }]
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
title: '作为容器的配置',
|
|
91
|
-
type: 'group',
|
|
92
|
-
titleClass: 'config-group-title',
|
|
93
|
-
label: false
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
label: '启用栅格布局',
|
|
97
|
-
name: 'useLayout',
|
|
98
|
-
type: 'switch'
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'layout',
|
|
102
|
-
type: 'custom',
|
|
103
|
-
component: markRaw(ObjectSectionEditor),
|
|
104
|
-
label: false,
|
|
105
|
-
rootKey: 'layout',
|
|
106
|
-
sectionMode: 'plain',
|
|
107
|
-
sections: inputArrayContainerLayoutSections,
|
|
108
|
-
visible(row: any) {
|
|
109
|
-
return Boolean(row.useLayout)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
const inputArrayDataProps: XFormItem[] = [
|
|
115
|
-
{
|
|
116
|
-
title: '预设数据',
|
|
117
|
-
name: 'defaultValue',
|
|
118
|
-
type: 'custom',
|
|
119
|
-
component: markRaw(InputTableDefaultRowsEditor),
|
|
120
|
-
titleClass: 'config-group-title',
|
|
121
|
-
label: false
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
const stripOperationColumns = (items: unknown) => {
|
|
126
|
-
return Array.isArray(items) ? items.filter((item: any) => item?.type !== 'operation') : undefined
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const createDefaultOperationColumn = () => ({
|
|
130
|
-
label: '操作',
|
|
131
|
-
type: 'operation',
|
|
132
|
-
width: 100,
|
|
133
|
-
actions: [
|
|
134
|
-
{ type: 'link', action: 'add', label: '新增' },
|
|
135
|
-
{ type: 'link', action: 'delete', label: '删除' }
|
|
136
|
-
]
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
export const inputArrayComponentConfig: ComponentConfig = {
|
|
140
|
-
label: '数组输入器',
|
|
141
|
-
value: 'x-input-array',
|
|
142
|
-
icon: 'ri-list-check-2',
|
|
143
|
-
editorKind: 'container',
|
|
144
|
-
scaffold: {
|
|
145
|
-
type: 'x-input-array',
|
|
146
|
-
label: '数组输入器',
|
|
147
|
-
name: 'arrayData',
|
|
148
|
-
idField: 'id',
|
|
149
|
-
addable: true,
|
|
150
|
-
deletable: true,
|
|
151
|
-
useScaffoldValue: true,
|
|
152
|
-
showInlineAddButton: true,
|
|
153
|
-
items: [
|
|
154
|
-
{
|
|
155
|
-
label: '字段名称',
|
|
156
|
-
name: 'name',
|
|
157
|
-
type: 'input'
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
replace: {
|
|
162
|
-
groups: ['collection'],
|
|
163
|
-
migrate({ source, targetScaffold }) {
|
|
164
|
-
return {
|
|
165
|
-
items: stripOperationColumns(source.items) || targetScaffold.items
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
configTabs: [
|
|
170
|
-
{ key: 'basic', body: [...commonBasicProps, ...inputArrayBasicProps] },
|
|
171
|
-
{ key: 'layout', body: inputArrayLayoutProps },
|
|
172
|
-
{ key: 'data', body: inputArrayDataProps },
|
|
173
|
-
{ key: 'validation', body: commonValidationProps },
|
|
174
|
-
{ key: 'advanced', body: commonAdvancedProps }
|
|
175
|
-
],
|
|
176
|
-
configSchema: {
|
|
177
|
-
body: [...commonBasicProps, ...inputArrayBasicProps, ...inputArrayLayoutProps, ...inputArrayDataProps, ...commonValidationProps, ...commonAdvancedProps]
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export const migrateInputArrayItemsToInputTable = (items: unknown) => {
|
|
182
|
-
const normalItems = stripOperationColumns(items)
|
|
183
|
-
return [...(normalItems?.length ? normalItems : []), createDefaultOperationColumn()]
|
|
184
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { ComponentConfig } from './types'
|
|
2
|
-
import { commonAdvancedProps, commonBasicProps, commonLayoutProps, commonProps, commonValidationProps } from './common-props'
|
|
3
|
-
import type { XFormItem } from 'xkit-ui'
|
|
4
|
-
import { markRaw } from 'vue'
|
|
5
|
-
import InputNumberRangeBindingEditor from '../components/input-number-range-binding-editor.vue'
|
|
6
|
-
|
|
7
|
-
const [basicInfoGroupProp, labelProp, , labelPositionProp] = commonBasicProps
|
|
8
|
-
|
|
9
|
-
const inputNumberRangeBindingProp: XFormItem = {
|
|
10
|
-
label: false,
|
|
11
|
-
name: 'sync',
|
|
12
|
-
type: 'custom',
|
|
13
|
-
component: markRaw(InputNumberRangeBindingEditor),
|
|
14
|
-
sync: [{ name: 'name', syncName: 'name' }]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const inputNumberRangeBasicProps: XFormItem[] = [
|
|
18
|
-
{
|
|
19
|
-
title: '组件属性',
|
|
20
|
-
type: 'group',
|
|
21
|
-
titleClass: 'config-group-title',
|
|
22
|
-
label: false
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: '开始占位',
|
|
26
|
-
name: 'startPlaceholder',
|
|
27
|
-
type: 'input'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: '结束占位',
|
|
31
|
-
name: 'endPlaceholder',
|
|
32
|
-
type: 'input'
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: '范围分隔符',
|
|
36
|
-
name: 'rangeSeperator',
|
|
37
|
-
type: 'input'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
label: '显示控制按钮',
|
|
41
|
-
name: 'controls',
|
|
42
|
-
type: 'switch',
|
|
43
|
-
defaultValue: true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
label: '按钮位置',
|
|
47
|
-
name: 'controlsPosition',
|
|
48
|
-
type: 'x-radios',
|
|
49
|
-
mode: 'button',
|
|
50
|
-
size: 'small',
|
|
51
|
-
options: [
|
|
52
|
-
{ label: '默认', value: '' },
|
|
53
|
-
{ label: '右侧', value: 'right' }
|
|
54
|
-
],
|
|
55
|
-
visible(row: any) {
|
|
56
|
-
return row.controls !== false
|
|
57
|
-
},
|
|
58
|
-
pipeIn(value: string | undefined) {
|
|
59
|
-
return value ?? ''
|
|
60
|
-
},
|
|
61
|
-
pipeOut(value: string) {
|
|
62
|
-
return value || undefined
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
const inputNumberRangeDataProps: XFormItem[] = [
|
|
68
|
-
{
|
|
69
|
-
title: '数值规则',
|
|
70
|
-
type: 'group',
|
|
71
|
-
titleClass: 'config-group-title',
|
|
72
|
-
label: false
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
label: '最小值',
|
|
76
|
-
name: 'min',
|
|
77
|
-
type: 'input-number',
|
|
78
|
-
controlsPosition: 'right'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: '最大值',
|
|
82
|
-
name: 'max',
|
|
83
|
-
type: 'input-number',
|
|
84
|
-
controlsPosition: 'right'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: '步长',
|
|
88
|
-
name: 'step',
|
|
89
|
-
type: 'input-number',
|
|
90
|
-
min: 0,
|
|
91
|
-
controlsPosition: 'right'
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
label: '精度',
|
|
95
|
-
name: 'precision',
|
|
96
|
-
type: 'input-number',
|
|
97
|
-
min: 0,
|
|
98
|
-
step: 1,
|
|
99
|
-
controlsPosition: 'right'
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: '严格步长',
|
|
103
|
-
name: 'stepStrictly',
|
|
104
|
-
type: 'switch'
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: '拼接为字符串',
|
|
108
|
-
name: 'joinValues',
|
|
109
|
-
type: 'switch'
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
export const inputNumberRangeComponentConfig: ComponentConfig = {
|
|
114
|
-
label: '数值范围选择器',
|
|
115
|
-
value: 'x-input-number-range',
|
|
116
|
-
icon: 'ri-expand-left-right-line',
|
|
117
|
-
scaffold: {
|
|
118
|
-
type: 'x-input-number-range',
|
|
119
|
-
label: '数值范围',
|
|
120
|
-
name: 'numberRange',
|
|
121
|
-
startPlaceholder: '最小值',
|
|
122
|
-
endPlaceholder: '最大值',
|
|
123
|
-
rangeSeperator: '至',
|
|
124
|
-
controls: true
|
|
125
|
-
},
|
|
126
|
-
replace: {
|
|
127
|
-
groups: ['placeholder', 'numeric'],
|
|
128
|
-
keep: ['controls', 'controlsPosition', 'rangeSeperator', 'joinValues']
|
|
129
|
-
},
|
|
130
|
-
configTabs: [
|
|
131
|
-
{
|
|
132
|
-
key: 'basic',
|
|
133
|
-
body: [basicInfoGroupProp, labelProp, inputNumberRangeBindingProp, labelPositionProp, ...inputNumberRangeBasicProps]
|
|
134
|
-
},
|
|
135
|
-
{ key: 'layout', body: commonLayoutProps },
|
|
136
|
-
{ key: 'data', body: inputNumberRangeDataProps },
|
|
137
|
-
{ key: 'validation', body: commonValidationProps },
|
|
138
|
-
{ key: 'advanced', body: commonAdvancedProps }
|
|
139
|
-
],
|
|
140
|
-
configSchema: {
|
|
141
|
-
body: [...commonProps, inputNumberRangeBindingProp, ...inputNumberRangeBasicProps, ...inputNumberRangeDataProps]
|
|
142
|
-
}
|
|
143
|
-
}
|
|
@@ -1,111 +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 inputNumberBasicProps: 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: 'controls',
|
|
20
|
-
type: 'switch',
|
|
21
|
-
defaultValue: true
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
label: '按钮位置',
|
|
25
|
-
name: 'controlsPosition',
|
|
26
|
-
type: 'x-radios',
|
|
27
|
-
mode: 'button',
|
|
28
|
-
size: 'small',
|
|
29
|
-
options: [
|
|
30
|
-
{ label: '默认', value: '' },
|
|
31
|
-
{ label: '右侧', value: 'right' }
|
|
32
|
-
],
|
|
33
|
-
visible(row: any) {
|
|
34
|
-
return row.controls !== false
|
|
35
|
-
},
|
|
36
|
-
pipeIn(value: string | undefined) {
|
|
37
|
-
return value ?? ''
|
|
38
|
-
},
|
|
39
|
-
pipeOut(value: string) {
|
|
40
|
-
return value || undefined
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: '单位',
|
|
45
|
-
name: 'unit',
|
|
46
|
-
type: 'input'
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
const inputNumberDataProps: XFormItem[] = [
|
|
51
|
-
{
|
|
52
|
-
title: '数值规则',
|
|
53
|
-
type: 'group',
|
|
54
|
-
titleClass: 'config-group-title',
|
|
55
|
-
label: false
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: '最小值',
|
|
59
|
-
name: 'min',
|
|
60
|
-
type: 'input-number',
|
|
61
|
-
controlsPosition: 'right'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
label: '最大值',
|
|
65
|
-
name: 'max',
|
|
66
|
-
type: 'input-number',
|
|
67
|
-
controlsPosition: 'right'
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: '步长',
|
|
71
|
-
name: 'step',
|
|
72
|
-
type: 'input-number',
|
|
73
|
-
min: 0,
|
|
74
|
-
controlsPosition: 'right'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: '精度',
|
|
78
|
-
name: 'precision',
|
|
79
|
-
type: 'input-number',
|
|
80
|
-
min: 0,
|
|
81
|
-
step: 1,
|
|
82
|
-
controlsPosition: 'right'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: '严格步长',
|
|
86
|
-
name: 'stepStrictly',
|
|
87
|
-
type: 'switch'
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
|
|
91
|
-
export const inputNumberComponentConfig: ComponentConfig = {
|
|
92
|
-
label: '数字输入框',
|
|
93
|
-
value: 'input-number',
|
|
94
|
-
icon: 'ri-input-cursor-move',
|
|
95
|
-
scaffold: {
|
|
96
|
-
type: 'input-number',
|
|
97
|
-
label: '数字输入',
|
|
98
|
-
placeholder: '请输入数字',
|
|
99
|
-
controls: true
|
|
100
|
-
},
|
|
101
|
-
replace: {
|
|
102
|
-
groups: ['placeholder', 'numeric']
|
|
103
|
-
},
|
|
104
|
-
configTabs: createComponentConfigTabs({
|
|
105
|
-
basic: inputNumberBasicProps,
|
|
106
|
-
data: inputNumberDataProps
|
|
107
|
-
}),
|
|
108
|
-
configSchema: {
|
|
109
|
-
body: [...commonProps, ...inputNumberBasicProps, ...inputNumberDataProps]
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { markRaw } from 'vue'
|
|
2
|
-
import type { ComponentConfig } from './types'
|
|
3
|
-
import { commonProps, createComponentConfigTabs } from './common-props'
|
|
4
|
-
import InputTableDefaultRowsEditor from '../components/input-table-default-rows-editor.vue'
|
|
5
|
-
import InputTableOperationEditor from '../components/input-table-operation-editor.vue'
|
|
6
|
-
import { migrateInputArrayItemsToInputTable } from './input-array'
|
|
7
|
-
import type { XFormItem } from 'xkit-ui'
|
|
8
|
-
|
|
9
|
-
const inputTableBasicProps: XFormItem[] = [
|
|
10
|
-
{
|
|
11
|
-
title: '组件属性',
|
|
12
|
-
type: 'group',
|
|
13
|
-
titleClass: 'config-group-title',
|
|
14
|
-
label: false
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: '行ID字段',
|
|
18
|
-
name: 'idField',
|
|
19
|
-
type: 'input',
|
|
20
|
-
placeholder: '默认 id'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
label: '显示边框',
|
|
24
|
-
name: 'border',
|
|
25
|
-
type: 'switch',
|
|
26
|
-
defaultValue: true
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: '显示表头',
|
|
30
|
-
name: 'showHeader',
|
|
31
|
-
type: 'switch',
|
|
32
|
-
defaultValue: true,
|
|
33
|
-
labelRemark: '默认显示。合并模式下也会显示子表列头。'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: '拖拽排序',
|
|
37
|
-
name: 'draggable',
|
|
38
|
-
type: 'switch'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: '允许新增',
|
|
42
|
-
name: 'addable',
|
|
43
|
-
type: 'switch',
|
|
44
|
-
defaultValue: true
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
label: '允许删除',
|
|
48
|
-
name: 'deletable',
|
|
49
|
-
type: 'switch',
|
|
50
|
-
defaultValue: true
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
label: '最少行数',
|
|
54
|
-
name: 'minLength',
|
|
55
|
-
type: 'input-number',
|
|
56
|
-
min: 0,
|
|
57
|
-
step: 1,
|
|
58
|
-
controlsPosition: 'right'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: '最多行数',
|
|
62
|
-
name: 'maxLength',
|
|
63
|
-
type: 'input-number',
|
|
64
|
-
min: 1,
|
|
65
|
-
step: 1,
|
|
66
|
-
controlsPosition: 'right'
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
const inputTableLayoutProps: XFormItem[] = [
|
|
71
|
-
{
|
|
72
|
-
title: '表格组合',
|
|
73
|
-
type: 'group',
|
|
74
|
-
titleClass: 'config-group-title',
|
|
75
|
-
label: false
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
label: '表格组合',
|
|
79
|
-
name: 'tableComposition',
|
|
80
|
-
type: 'x-radios',
|
|
81
|
-
mode: 'button',
|
|
82
|
-
size: 'small',
|
|
83
|
-
options: [
|
|
84
|
-
{ label: '嵌套', value: 'nested' },
|
|
85
|
-
{ label: '合并', value: 'merged' }
|
|
86
|
-
],
|
|
87
|
-
defaultValue: 'nested',
|
|
88
|
-
pipeIn(value: string | undefined) {
|
|
89
|
-
return value ?? 'nested'
|
|
90
|
-
},
|
|
91
|
-
pipeOut(value: string) {
|
|
92
|
-
return value === 'merged' ? 'merged' : undefined
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
|
|
97
|
-
const inputTableDataProps: XFormItem[] = [
|
|
98
|
-
{
|
|
99
|
-
title: '预设数据',
|
|
100
|
-
name: 'defaultValue',
|
|
101
|
-
type: 'custom',
|
|
102
|
-
component: markRaw(InputTableDefaultRowsEditor),
|
|
103
|
-
titleClass: 'config-group-title',
|
|
104
|
-
label: false
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
const inputTableOperationProps: XFormItem[] = [
|
|
109
|
-
{
|
|
110
|
-
title: '行操作列',
|
|
111
|
-
name: 'items',
|
|
112
|
-
type: 'custom',
|
|
113
|
-
component: markRaw(InputTableOperationEditor),
|
|
114
|
-
titleClass: 'config-group-title',
|
|
115
|
-
label: false
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
title: '底部工具栏',
|
|
119
|
-
type: 'group',
|
|
120
|
-
titleClass: 'config-group-title',
|
|
121
|
-
label: false
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
label: '显示底部新增',
|
|
125
|
-
name: 'footerToolbar',
|
|
126
|
-
type: 'switch',
|
|
127
|
-
pipeIn(value: unknown) {
|
|
128
|
-
return Boolean(value)
|
|
129
|
-
},
|
|
130
|
-
pipeOut(value: boolean) {
|
|
131
|
-
return value
|
|
132
|
-
? {
|
|
133
|
-
left: [{ type: 'button', action: 'add', label: '新增', attrs: { type: 'primary' } }]
|
|
134
|
-
}
|
|
135
|
-
: undefined
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
]
|
|
139
|
-
|
|
140
|
-
export const inputTableComponentConfig: ComponentConfig = {
|
|
141
|
-
label: '表格输入器',
|
|
142
|
-
value: 'x-input-table',
|
|
143
|
-
icon: 'ri-table-line',
|
|
144
|
-
editorKind: 'container',
|
|
145
|
-
scaffold: {
|
|
146
|
-
type: 'x-input-table',
|
|
147
|
-
label: '表格输入器',
|
|
148
|
-
name: 'tableData',
|
|
149
|
-
// defaultValue: [],
|
|
150
|
-
border: true,
|
|
151
|
-
idField: 'id',
|
|
152
|
-
items: [
|
|
153
|
-
{
|
|
154
|
-
label: '字段名称',
|
|
155
|
-
name: 'name',
|
|
156
|
-
type: 'input',
|
|
157
|
-
width: 160
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
label: '操作',
|
|
161
|
-
type: 'operation',
|
|
162
|
-
width: 100,
|
|
163
|
-
actions: [
|
|
164
|
-
{ type: 'link', action: 'add', label: '新增' },
|
|
165
|
-
{ type: 'link', action: 'delete', label: '删除' }
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
footerToolbar: {
|
|
170
|
-
left: [{ type: 'button', action: 'add', label: '新增', attrs: { type: 'primary' } }]
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
replace: {
|
|
174
|
-
groups: ['collection'],
|
|
175
|
-
migrate({ source }) {
|
|
176
|
-
if (source.type !== 'x-input-array') return {}
|
|
177
|
-
return {
|
|
178
|
-
items: migrateInputArrayItemsToInputTable(source.items)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
configTabs: createComponentConfigTabs({
|
|
183
|
-
basic: inputTableBasicProps,
|
|
184
|
-
layout: inputTableLayoutProps,
|
|
185
|
-
data: inputTableDataProps,
|
|
186
|
-
operation: inputTableOperationProps
|
|
187
|
-
}),
|
|
188
|
-
configSchema: {
|
|
189
|
-
body: [...commonProps, ...inputTableBasicProps, ...inputTableLayoutProps, ...inputTableDataProps, ...inputTableOperationProps]
|
|
190
|
-
}
|
|
191
|
-
}
|