@veltra/desktop 1.1.35 → 1.2.0
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/dist/components/action/action-group.vue.d.ts +2 -2
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/auto-complete/auto-complete.js +1 -0
- package/dist/components/auto-complete/auto-complete.js.map +1 -1
- package/dist/components/batch-edit/batch-edit-form.js +12 -5
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +8 -3
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.vue.d.ts +40 -35
- package/dist/components/batch-edit/di.js.map +1 -1
- package/dist/components/batch-edit/use-edit.js +41 -23
- package/dist/components/batch-edit/use-edit.js.map +1 -1
- package/dist/components/cascade/cascade.js +1 -0
- package/dist/components/cascade/cascade.js.map +1 -1
- package/dist/components/cascade/cascade.vue.d.ts +5 -5
- package/dist/components/checkbox/checkbox-button.js +1 -0
- package/dist/components/checkbox/checkbox-button.js.map +1 -1
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +1 -0
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +1 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/code-editor/code-editor.js +1 -0
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/condition-editor/core/evaluator.js +3 -3
- package/dist/components/condition-editor/core/evaluator.js.map +1 -1
- package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +1 -0
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +2 -0
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +1 -1
- package/dist/components/dialog/use-maximum.js +7 -1
- package/dist/components/dialog/use-maximum.js.map +1 -1
- package/dist/components/empty/empty.vue.d.ts +1 -1
- package/dist/components/expression-editor/expression-editor.js +1 -0
- package/dist/components/expression-editor/expression-editor.js.map +1 -1
- package/dist/components/file-picker/file-picker.js +1 -0
- package/dist/components/file-picker/file-picker.js.map +1 -1
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/form/form.vue.d.ts +11 -19
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js +24 -26
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form/index.d.ts +0 -3
- package/dist/components/form/use-form-fields.js +88 -0
- package/dist/components/form/use-form-fields.js.map +1 -0
- package/dist/components/form/use-node-interceptor.js +19 -30
- package/dist/components/form/use-node-interceptor.js.map +1 -1
- package/dist/components/form-item/form-item.js.map +1 -1
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +44 -18
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form-item/helper.js +4 -1
- package/dist/components/form-item/helper.js.map +1 -1
- package/dist/components/form-item/validate.d.ts +26 -0
- package/dist/components/form-item/validate.js +97 -0
- package/dist/components/form-item/validate.js.map +1 -0
- package/dist/components/group-input/group-input.js +1 -0
- package/dist/components/group-input/group-input.js.map +1 -1
- package/dist/components/index.d.ts +0 -3
- package/dist/components/index.js +0 -7
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/loading/style2.css +90 -159
- package/dist/components/multi-select/multi-select.js +1 -0
- package/dist/components/multi-select/multi-select.js.map +1 -1
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.js +1 -0
- package/dist/components/multi-tree-select/multi-tree-select.js.map +1 -1
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +4 -4
- package/dist/components/number-input/number-input.js +1 -0
- package/dist/components/number-input/number-input.js.map +1 -1
- package/dist/components/number-range-input/number-range-input.js +1 -0
- package/dist/components/number-range-input/number-range-input.js.map +1 -1
- package/dist/components/palette/palette.js +1 -0
- package/dist/components/palette/palette.js.map +1 -1
- package/dist/components/password-input/password-input.js +1 -0
- package/dist/components/password-input/password-input.js.map +1 -1
- package/dist/components/pop-confirm/pop-confirm.vue.d.ts +1 -1
- package/dist/components/radio/radio.js +1 -0
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio-group/radio-group.js +1 -0
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/rich-text-editor/rich-text-editor.js +3 -2
- package/dist/components/rich-text-editor/rich-text-editor.js.map +1 -1
- package/dist/components/rich-text-editor/toolbar.js +10 -7
- package/dist/components/rich-text-editor/toolbar.js.map +1 -1
- package/dist/components/select/select.js +6 -3
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/slider/slider.js +15 -2
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/steps/steps.vue.d.ts +1 -1
- package/dist/components/switch/switch.js +1 -0
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/style2.css +4 -7
- package/dist/components/textarea/textarea.js +1 -0
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tip/tip.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.js +1 -0
- package/dist/components/tree-select/tree-select.js.map +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +4 -4
- package/dist/components/watermark/watermark.vue.d.ts +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +1 -4
- package/dist/types/auto-complete.d.ts +3 -2
- package/dist/types/batch-edit.d.ts +4 -5
- package/dist/types/cascade.d.ts +3 -2
- package/dist/types/checkbox-group.d.ts +2 -2
- package/dist/types/checkbox.d.ts +4 -3
- package/dist/types/code-editor.d.ts +3 -2
- package/dist/types/date-picker.d.ts +3 -2
- package/dist/types/date-range-picker.d.ts +3 -2
- package/dist/types/expression-editor.d.ts +3 -2
- package/dist/types/file-picker.d.ts +3 -2
- package/dist/types/form-field.d.ts +12 -0
- package/dist/types/form-item.d.ts +2 -2
- package/dist/types/form.d.ts +9 -48
- package/dist/types/group-input.d.ts +3 -2
- package/dist/types/index.d.ts +4 -2
- package/dist/types/input.d.ts +3 -2
- package/dist/types/loading.d.ts +1 -1
- package/dist/types/multi-select.d.ts +3 -2
- package/dist/types/multi-tree-select.d.ts +3 -2
- package/dist/types/palette.d.ts +3 -2
- package/dist/types/radio-group.d.ts +3 -2
- package/dist/types/radio.d.ts +3 -2
- package/dist/types/rich-text-editor.d.ts +3 -2
- package/dist/types/select.d.ts +3 -2
- package/dist/types/slider.d.ts +3 -2
- package/dist/types/switch.d.ts +3 -2
- package/dist/types/text-editor.d.ts +3 -2
- package/dist/types/textarea.d.ts +3 -2
- package/dist/types/tree-select.d.ts +3 -2
- package/package.json +6 -6
- package/src/components/batch-edit/batch-edit-form.vue +20 -13
- package/src/components/batch-edit/batch-edit.vue +7 -8
- package/src/components/batch-edit/di.ts +1 -2
- package/src/components/batch-edit/use-edit.ts +58 -36
- package/src/components/date-range-picker/date-range-picker.vue +2 -0
- package/src/components/dialog/use-maximum.ts +8 -1
- package/src/components/form/form.vue +22 -38
- package/src/components/form/index.ts +0 -6
- package/src/components/form/use-form-fields.ts +126 -0
- package/src/components/form/use-node-interceptor.ts +27 -56
- package/src/components/form-item/form-item.vue +69 -18
- package/src/components/form-item/helper.ts +10 -4
- package/src/components/form-item/validate.ts +155 -0
- package/src/components/loading/style.scss +126 -355
- package/src/components/rich-text-editor/rich-text-editor.vue +28 -25
- package/src/components/rich-text-editor/toolbar.vue +23 -19
- package/src/components/select/select.vue +6 -4
- package/src/components/slider/slider.vue +12 -2
- package/src/components/table/style.scss +4 -14
- package/src/types/auto-complete.ts +4 -2
- package/src/types/batch-edit.ts +4 -5
- package/src/types/cascade.ts +4 -2
- package/src/types/checkbox-group.ts +2 -2
- package/src/types/checkbox.ts +5 -3
- package/src/types/code-editor.ts +4 -2
- package/src/types/date-picker.ts +4 -2
- package/src/types/date-range-picker.ts +4 -2
- package/src/types/expression-editor.ts +4 -2
- package/src/types/file-picker.ts +4 -2
- package/src/types/form-field.ts +11 -0
- package/src/types/form-item.ts +2 -2
- package/src/types/form.ts +9 -82
- package/src/types/group-input.ts +4 -2
- package/src/types/index.ts +1 -0
- package/src/types/input.ts +4 -2
- package/src/types/loading.ts +1 -1
- package/src/types/multi-select.ts +4 -2
- package/src/types/multi-tree-select.ts +5 -2
- package/src/types/palette.ts +4 -2
- package/src/types/radio-group.ts +4 -2
- package/src/types/radio.ts +4 -2
- package/src/types/rich-text-editor.ts +4 -2
- package/src/types/select.ts +4 -2
- package/src/types/slider.ts +4 -2
- package/src/types/switch.ts +4 -2
- package/src/types/text-editor.ts +4 -2
- package/src/types/textarea.ts +4 -2
- package/src/types/tree-select.ts +5 -2
- package/dist/components/form/dynamic-form-model.d.ts +0 -73
- package/dist/components/form/dynamic-form-model.js +0 -184
- package/dist/components/form/dynamic-form-model.js.map +0 -1
- package/dist/components/form/form-model.d.ts +0 -73
- package/dist/components/form/form-model.js +0 -179
- package/dist/components/form/form-model.js.map +0 -1
- package/dist/components/form/helper.d.ts +0 -16
- package/dist/components/form/helper.js +0 -20
- package/dist/components/form/helper.js.map +0 -1
- package/src/components/form/__test__/form-model.test.ts +0 -190
- package/src/components/form/dynamic-form-model.ts +0 -258
- package/src/components/form/form-model.ts +0 -255
- package/src/components/form/helper.ts +0 -23
|
@@ -209,14 +209,16 @@ watch(
|
|
|
209
209
|
|
|
210
210
|
if (!options?.length) return
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
const { valueKey } = props
|
|
214
|
-
currentIndex.value = options.findIndex((option) => o(option).get(valueKey) === modelValue)
|
|
212
|
+
const { valueKey, labelKey } = props
|
|
215
213
|
|
|
216
|
-
|
|
214
|
+
if (modelValue !== undefined && modelValue !== null && modelValue !== '') {
|
|
215
|
+
currentIndex.value = options.findIndex((option) => o(option).get(valueKey) === modelValue)
|
|
216
|
+
selected.value = currentIndex.value >= 0 ? options[currentIndex.value] : undefined
|
|
217
|
+
label.value = selected.value ? o(selected.value).get(labelKey) : undefined
|
|
217
218
|
} else {
|
|
218
219
|
currentIndex.value = -1
|
|
219
220
|
selected.value = undefined
|
|
221
|
+
label.value = undefined
|
|
220
222
|
}
|
|
221
223
|
},
|
|
222
224
|
{ immediate: true }
|
|
@@ -113,10 +113,20 @@ const ticks = computed(() => {
|
|
|
113
113
|
watch(
|
|
114
114
|
[offset1, offset2],
|
|
115
115
|
userAction((v) => {
|
|
116
|
+
if (sliderSize.value === 0) return
|
|
117
|
+
|
|
116
118
|
if (props.range) {
|
|
117
|
-
|
|
119
|
+
const next = v.map(sliderOffset2Value).toSorted((a, b) => a - b) as [number, number]
|
|
120
|
+
const current = props.modelValue as [number, number] | undefined
|
|
121
|
+
if (current) {
|
|
122
|
+
const [a, b] = [...current].sort((x, y) => x - y)
|
|
123
|
+
if (next[0] === a && next[1] === b) return
|
|
124
|
+
}
|
|
125
|
+
emit('update:modelValue', next as T)
|
|
118
126
|
} else {
|
|
119
|
-
|
|
127
|
+
const next = sliderOffset2Value(v[0])
|
|
128
|
+
if (next === props.modelValue) return
|
|
129
|
+
emit('update:modelValue', next as T)
|
|
120
130
|
}
|
|
121
131
|
})
|
|
122
132
|
)
|
|
@@ -124,12 +124,10 @@ $root-name: table;
|
|
|
124
124
|
z-index: 1;
|
|
125
125
|
user-select: none;
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
0px -1px var(--u-table-border-color) inset;
|
|
132
|
-
}
|
|
127
|
+
@include m.bem($root-name, cell) {
|
|
128
|
+
background-color: var(--u-table-header-bg);
|
|
129
|
+
font-weight: 500;
|
|
130
|
+
color: var(--u-table-header-color);
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
@include m.is(multistage) {
|
|
@@ -142,14 +140,6 @@ $root-name: table;
|
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
@include m.e(head) {
|
|
146
|
-
@include m.bem($root-name, cell) {
|
|
147
|
-
background-color: var(--u-table-header-bg);
|
|
148
|
-
font-weight: normal;
|
|
149
|
-
color: var(--u-table-header-color);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
143
|
@include m.e(resize-handle) {
|
|
154
144
|
position: absolute;
|
|
155
145
|
width: 4px;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 自动补全组件组件属性 */
|
|
4
|
-
export interface AutoCompleteProps extends
|
|
6
|
+
export interface AutoCompleteProps extends FormFieldComponentProps {
|
|
5
7
|
modelValue?: string
|
|
6
8
|
/** 占位符 */
|
|
7
9
|
placeholder?: string
|
package/src/types/batch-edit.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
|
|
3
3
|
import type { ActionProps } from './action'
|
|
4
|
-
import type { IFormModel } from './form'
|
|
5
4
|
import type { TableColumn, TableEmits, TableProps, TableRow } from './table'
|
|
6
5
|
|
|
7
6
|
/** 批量编辑列 */
|
|
@@ -20,12 +19,12 @@ export interface BatchEditColumn extends TableColumn {
|
|
|
20
19
|
export type BatchEditFeature = 'create' | 'update' | 'copy' | 'delete' | 'view' | 'createChild'
|
|
21
20
|
|
|
22
21
|
/** 批量编辑组件属性 */
|
|
23
|
-
export interface BatchEditProps
|
|
22
|
+
export interface BatchEditProps extends TableProps {
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @description
|
|
24
|
+
* 表单数据
|
|
25
|
+
* @description 与右侧 UForm 绑定的 reactive 对象
|
|
27
26
|
*/
|
|
28
|
-
model?:
|
|
27
|
+
model?: Record<string, any>
|
|
29
28
|
/** 表格标题 */
|
|
30
29
|
title?: string
|
|
31
30
|
/**
|
package/src/types/cascade.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TreeNode } from '@cat-kit/core'
|
|
2
|
-
import type { DeconstructValue
|
|
2
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
3
|
+
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
3
5
|
|
|
4
6
|
export interface CascadeNode<
|
|
5
7
|
Data extends Record<string, any> = Record<string, any>
|
|
@@ -10,7 +12,7 @@ export interface CascadeNode<
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/** 级联选择器组件属性 */
|
|
13
|
-
export interface CascadeProps extends
|
|
15
|
+
export interface CascadeProps extends FormFieldComponentProps {
|
|
14
16
|
/**
|
|
15
17
|
* 分隔符
|
|
16
18
|
* @default '/'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
2
|
|
|
3
3
|
/** 复选框组, 用来选择一组数据组件属性 */
|
|
4
|
-
export interface CheckboxGroupProps extends
|
|
4
|
+
export interface CheckboxGroupProps extends FormFieldComponentProps {
|
|
5
5
|
/** 值 */
|
|
6
6
|
modelValue?: Array<any>
|
|
7
7
|
/** 复选框项 */
|
package/src/types/checkbox.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { ColorType
|
|
1
|
+
import type { ColorType } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 复选框组件属性 */
|
|
4
|
-
export interface CheckboxProps extends
|
|
6
|
+
export interface CheckboxProps extends FormFieldComponentProps {
|
|
5
7
|
/** 部分选中 */
|
|
6
8
|
indeterminate?: boolean
|
|
7
9
|
/** 是否选中 */
|
|
8
10
|
modelValue?: boolean
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export interface CheckboxButtonProps extends
|
|
13
|
+
export interface CheckboxButtonProps extends FormFieldComponentProps {
|
|
12
14
|
/** 是否选中 */
|
|
13
15
|
modelValue?: boolean
|
|
14
16
|
/** 是否圆角 */
|
package/src/types/code-editor.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
export type CodeEditorLang = 'js' | 'sql' | 'java' | 'json'
|
|
4
6
|
|
|
5
7
|
/** 代码编辑器组件属性(不支持 `size`) */
|
|
6
|
-
export interface CodeEditorProps extends Omit<
|
|
8
|
+
export interface CodeEditorProps extends Omit<FormFieldComponentProps, 'size'> {
|
|
7
9
|
modelValue?: string
|
|
8
10
|
/** 定义语言 */
|
|
9
11
|
language?: CodeEditorLang
|
package/src/types/date-picker.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Dater } from '@cat-kit/core'
|
|
2
|
-
import type { DeconstructValue
|
|
2
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
3
|
+
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
3
5
|
|
|
4
6
|
/** date-picker组件属性 */
|
|
5
|
-
export interface DatePickerProps extends
|
|
7
|
+
export interface DatePickerProps extends FormFieldComponentProps {
|
|
6
8
|
modelValue?: string | number | Date
|
|
7
9
|
/** 占位 */
|
|
8
10
|
placeholder?: string
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Dater } from '@cat-kit/core'
|
|
2
|
-
import type { DeconstructValue
|
|
2
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
3
|
+
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
3
5
|
|
|
4
6
|
/** date-range-picker组件属性 */
|
|
5
|
-
export interface DateRangePickerProps extends
|
|
7
|
+
export interface DateRangePickerProps extends FormFieldComponentProps {
|
|
6
8
|
modelValue?: [string, string]
|
|
7
9
|
/** 占位 */
|
|
8
10
|
placeholder?: [string, string]
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
export interface VariableItem {
|
|
4
6
|
label: string
|
|
@@ -13,7 +15,7 @@ export interface VariableItem {
|
|
|
13
15
|
export type ExpressionSelectableLevels = 'leaf' | 'any'
|
|
14
16
|
|
|
15
17
|
/** 表达式编辑器组件属性 */
|
|
16
|
-
export interface ExpressionEditorProps extends
|
|
18
|
+
export interface ExpressionEditorProps extends FormFieldComponentProps {
|
|
17
19
|
modelValue?: string
|
|
18
20
|
placeholder?: string
|
|
19
21
|
/** 变量列表 */
|
package/src/types/file-picker.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 文件上传器组件属性 */
|
|
4
|
-
export interface UploaderProps extends
|
|
6
|
+
export interface UploaderProps extends FormFieldComponentProps {
|
|
5
7
|
/** 渲染标签 */
|
|
6
8
|
tag?: string
|
|
7
9
|
/** 允许上传的文件类型 */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormComponentProps } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { ValidateRule } from '../components/form-item/validate'
|
|
4
|
+
|
|
5
|
+
export type { PresetRule, ValidateRule } from '../components/form-item/validate'
|
|
6
|
+
|
|
7
|
+
/** 带校验规则的表单控件通用属性 */
|
|
8
|
+
export interface FormFieldComponentProps extends FormComponentProps {
|
|
9
|
+
/** 校验规则 */
|
|
10
|
+
rules?: ValidateRule
|
|
11
|
+
}
|
package/src/types/form-item.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
2
|
|
|
3
3
|
/** 组件项组件属性 */
|
|
4
|
-
export interface FormItemProps extends
|
|
4
|
+
export interface FormItemProps extends FormFieldComponentProps {
|
|
5
5
|
/** 标签宽度 */
|
|
6
6
|
labelWidth?: string | number
|
|
7
7
|
}
|
package/src/types/form.ts
CHANGED
|
@@ -1,93 +1,16 @@
|
|
|
1
|
-
import type { ComponentProps, DeconstructValue
|
|
1
|
+
import type { ComponentProps, DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { ShallowRef } from 'vue'
|
|
3
3
|
|
|
4
|
-
import type { NestedFieldMarker } from '../components/form/helper'
|
|
5
|
-
|
|
6
|
-
export interface FormModelItem<Val = any> extends ValidateRule {
|
|
7
|
-
/** 模型值 */
|
|
8
|
-
value?: Val
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type FormModelField = FormModelItem | NestedFieldMarker
|
|
12
|
-
|
|
13
|
-
// 最终暴露的 ModelData 类型
|
|
14
|
-
export type ModelData<Fields extends Record<string, any>> = {
|
|
15
|
-
[key in keyof Fields]: Fields[key] extends NestedFieldMarker<infer SubFields>
|
|
16
|
-
? ModelData<SubFields>
|
|
17
|
-
: Fields[key] extends FormModelItem
|
|
18
|
-
? Fields[key]['value'] extends () => infer T
|
|
19
|
-
? T
|
|
20
|
-
: Fields[key]['value']
|
|
21
|
-
: never
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 获取所有的扁平路径 Union(如 'name' | 'contact.email')
|
|
25
|
-
export type AllKeys<Fields extends Record<string, any>> = {
|
|
26
|
-
[K in keyof Fields]: K extends string
|
|
27
|
-
? Fields[K] extends NestedFieldMarker<infer SubFields>
|
|
28
|
-
? `${K}.${AllKeys<SubFields>}`
|
|
29
|
-
: K
|
|
30
|
-
: never
|
|
31
|
-
}[keyof Fields]
|
|
32
|
-
|
|
33
|
-
export type ModelRules<Fields extends Record<string, FormModelItem>> = {
|
|
34
|
-
[key in keyof Fields]: Omit<Fields[key], 'value'>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface DataSettingConfig {
|
|
38
|
-
/**
|
|
39
|
-
* 是否校验
|
|
40
|
-
* @default true
|
|
41
|
-
*/
|
|
42
|
-
validate?: boolean
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type IFormModel<Fields extends Record<string, any> = Record<string, any>> = {
|
|
46
|
-
/** 表单数据 */
|
|
47
|
-
readonly data: ModelData<Fields>
|
|
48
|
-
/** 字段校验规则 */
|
|
49
|
-
readonly fields: Fields
|
|
50
|
-
/**
|
|
51
|
-
* 字段键
|
|
52
|
-
*/
|
|
53
|
-
readonly allKeys: string[]
|
|
54
|
-
/** 需要校验的key */
|
|
55
|
-
formKeys: Map<number, string[]>
|
|
56
|
-
/** 错误 */
|
|
57
|
-
readonly errors: Map<string, string[] | undefined>
|
|
58
|
-
/**
|
|
59
|
-
* 字段校验
|
|
60
|
-
* @param fields 字段, 如果不传入时将会使用keyFields来进行校验
|
|
61
|
-
*/
|
|
62
|
-
validate: (fields?: string | string[]) => Promise<boolean>
|
|
63
|
-
/** 重置数据 */
|
|
64
|
-
resetData(fields?: string | string[]): void
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 设置数据
|
|
68
|
-
* @param formData 表单值
|
|
69
|
-
* @param options 配置
|
|
70
|
-
*/
|
|
71
|
-
setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): void
|
|
72
|
-
/** 清除校验 */
|
|
73
|
-
clearValidate(): void
|
|
74
|
-
/** 监听值变更 */
|
|
75
|
-
onChange(cb: (field: string, val: any) => void): void
|
|
76
|
-
/** 关闭监听值变更 */
|
|
77
|
-
offChange(cb: (field: string, val: any) => void): void
|
|
78
|
-
}
|
|
79
|
-
|
|
80
4
|
/** 表单组件属性 */
|
|
81
|
-
export interface FormProps
|
|
5
|
+
export interface FormProps extends ComponentProps {
|
|
82
6
|
/**
|
|
83
7
|
* 自定义表单列数
|
|
84
8
|
* - 默认根据尺寸断点自动排列
|
|
85
9
|
*/
|
|
86
10
|
cols?: number
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
model: Model
|
|
11
|
+
/** 表单数据 */
|
|
12
|
+
model?: Record<string, any>
|
|
13
|
+
// showModified?: boolean
|
|
91
14
|
/** 表单项label宽度 */
|
|
92
15
|
labelWidth?: string | number
|
|
93
16
|
/** 是否不显示tips */
|
|
@@ -100,6 +23,10 @@ export interface FormProps<Model extends IFormModel = IFormModel> extends Compon
|
|
|
100
23
|
|
|
101
24
|
export interface _FormExposed {
|
|
102
25
|
el: ShallowRef<HTMLElement | null | undefined>
|
|
26
|
+
validate: (keys?: string[]) => Promise<boolean>
|
|
27
|
+
clearValidate: () => void
|
|
28
|
+
/** 将 model 恢复为最近一次 props.model 引用变更时的快照,并清除校验 */
|
|
29
|
+
reset: () => void
|
|
103
30
|
}
|
|
104
31
|
|
|
105
32
|
export type FormExposed = DeconstructValue<_FormExposed>
|
package/src/types/group-input.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { StyleValue } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
5
|
+
|
|
4
6
|
/** 分组输入组件属性 */
|
|
5
7
|
export interface GroupInputProps<
|
|
6
8
|
GroupItem extends Record<string, any> = Record<string, any>
|
|
7
|
-
> extends
|
|
9
|
+
> extends FormFieldComponentProps {
|
|
8
10
|
modelValue?: GroupItem[]
|
|
9
11
|
/** 最大数量 */
|
|
10
12
|
max?: number
|
package/src/types/index.ts
CHANGED
package/src/types/input.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { ShallowRef } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
5
|
+
|
|
4
6
|
/** 输入框组件属性 */
|
|
5
|
-
export interface InputProps extends
|
|
7
|
+
export interface InputProps extends FormFieldComponentProps {
|
|
6
8
|
/** modelValue */
|
|
7
9
|
modelValue?: string
|
|
8
10
|
/** 占位符 */
|
package/src/types/loading.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { CSSProperties } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
5
|
+
|
|
4
6
|
/** multi-select组件属性 */
|
|
5
|
-
export interface MultiSelectProps extends
|
|
7
|
+
export interface MultiSelectProps extends FormFieldComponentProps {
|
|
6
8
|
/** 绑定值 */
|
|
7
9
|
modelValue?: Array<any>
|
|
8
10
|
/** 列表选项 */
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { CSSProperties } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
4
5
|
import type { TreeProps } from './tree'
|
|
5
6
|
/** 树形多选组件组件属性 */
|
|
6
7
|
export interface MultiTreeSelectProps
|
|
7
|
-
extends
|
|
8
|
+
extends
|
|
9
|
+
FormFieldComponentProps,
|
|
10
|
+
Omit<TreeProps, 'selected' | 'checked' | 'selectable' | 'checkable'> {
|
|
8
11
|
modelValue?: (string | number)[]
|
|
9
12
|
|
|
10
13
|
/**自定义占位文字 */
|
package/src/types/palette.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 色调 */
|
|
4
6
|
export interface PaletteRGB {
|
|
@@ -18,7 +20,7 @@ export interface PaletteHSV {
|
|
|
18
20
|
export type PaletteColorType = 'HEX' | 'RGB'
|
|
19
21
|
|
|
20
22
|
/** 调色盘组件属性 */
|
|
21
|
-
export interface PaletteProps extends
|
|
23
|
+
export interface PaletteProps extends FormFieldComponentProps {
|
|
22
24
|
modelValue?: string
|
|
23
25
|
disabled?: boolean
|
|
24
26
|
readonly?: boolean
|
package/src/types/radio-group.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
/** 单选框默认父组件组件属性 */
|
|
3
|
-
export interface RadioGroupProps extends
|
|
5
|
+
export interface RadioGroupProps extends FormFieldComponentProps {
|
|
4
6
|
/** 值 */
|
|
5
7
|
modelValue?: any
|
|
6
8
|
/** 单选框项 */
|
package/src/types/radio.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
/** 单选框组件属性 */
|
|
3
|
-
export interface RadioProps extends
|
|
5
|
+
export interface RadioProps extends FormFieldComponentProps {
|
|
4
6
|
/** 单选框值 */
|
|
5
7
|
value?: any
|
|
6
8
|
/** 文本 */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 富文本数据格式 */
|
|
4
6
|
export type RichTextFormat = 'html' | 'json'
|
|
@@ -21,7 +23,7 @@ export type ToolbarItem =
|
|
|
21
23
|
| '|'
|
|
22
24
|
|
|
23
25
|
/** 富文本编辑器组件属性 */
|
|
24
|
-
export interface RichTextEditorProps extends
|
|
26
|
+
export interface RichTextEditorProps extends FormFieldComponentProps {
|
|
25
27
|
modelValue?: string
|
|
26
28
|
/** 数据格式:html 或 json */
|
|
27
29
|
format?: RichTextFormat
|
package/src/types/select.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { CSSProperties, ShallowRef } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
5
|
+
|
|
4
6
|
/** 选择器组件属性 */
|
|
5
|
-
export interface SelectProps extends
|
|
7
|
+
export interface SelectProps extends FormFieldComponentProps {
|
|
6
8
|
/** 绑定值 */
|
|
7
9
|
modelValue?: any
|
|
8
10
|
/** 文本内容 */
|
package/src/types/slider.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 滑块组件属性 */
|
|
4
|
-
export interface SliderProps<T extends number | [number, number]> extends
|
|
6
|
+
export interface SliderProps<T extends number | [number, number]> extends FormFieldComponentProps {
|
|
5
7
|
modelValue?: T
|
|
6
8
|
/**
|
|
7
9
|
* 最小值
|
package/src/types/switch.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** 开关组件属性 */
|
|
4
|
-
export interface SwitchProps extends
|
|
6
|
+
export interface SwitchProps extends FormFieldComponentProps {
|
|
5
7
|
/** 开关状态 */
|
|
6
8
|
modelValue?: boolean
|
|
7
9
|
/** 打开时显示的文字 */
|
package/src/types/text-editor.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** text-editor组件属性 */
|
|
4
6
|
export interface BarType {
|
|
@@ -6,7 +8,7 @@ export interface BarType {
|
|
|
6
8
|
bar: string
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export interface TextEditorProps extends
|
|
11
|
+
export interface TextEditorProps extends FormFieldComponentProps {
|
|
10
12
|
modelValue?: string
|
|
11
13
|
placeholder?: string
|
|
12
14
|
toolbar?: BarType[]
|
package/src/types/textarea.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { DeconstructValue
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
|
+
|
|
3
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
2
4
|
|
|
3
5
|
/** textarea组件属性 */
|
|
4
|
-
export interface TextareaProps extends
|
|
6
|
+
export interface TextareaProps extends FormFieldComponentProps {
|
|
5
7
|
/**
|
|
6
8
|
* 文本域的值
|
|
7
9
|
*/
|
package/src/types/tree-select.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeconstructValue } from '@veltra/utils'
|
|
2
2
|
import type { CSSProperties } from 'vue'
|
|
3
3
|
|
|
4
|
+
import type { FormFieldComponentProps } from './form-field'
|
|
4
5
|
import type { TreeProps } from './tree'
|
|
5
6
|
|
|
6
7
|
/** 树形选择器组件属性 */
|
|
7
8
|
export interface TreeSelectProps
|
|
8
|
-
extends
|
|
9
|
+
extends
|
|
10
|
+
FormFieldComponentProps,
|
|
11
|
+
Omit<TreeProps, 'selected' | 'checked' | 'selectable' | 'checkable'> {
|
|
9
12
|
modelValue?: string | number
|
|
10
13
|
|
|
11
14
|
/** 自定义占位文字 */
|