@xn-lib/component 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.iife.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/cascader/index.vue.d.ts +2 -2
- package/dist/types/editable-textarea/index.vue.d.ts +1 -1
- package/dist/types/form-list/index.d.ts +12 -0
- package/dist/types/form-list/index.vue.d.ts +263 -0
- package/dist/types/form-list/props.d.ts +139 -0
- package/dist/types/form-list/use-form-list-actions.d.ts +21 -0
- package/dist/types/form-list/use-form-list-layout.d.ts +8 -0
- package/dist/types/form-list/use-form-list-row-forms.d.ts +9 -0
- package/dist/types/form-list/use-form-list-uid-sync.d.ts +14 -0
- package/dist/types/form-list/use-form-list.d.ts +49 -0
- package/dist/types/form-list/utils.d.ts +14 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/time-range-picker/props.d.ts +0 -1
- package/dist/types/time-range-picker/utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -287,11 +287,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
287
287
|
}>, {
|
|
288
288
|
readonly disabled: boolean;
|
|
289
289
|
readonly filter: import("../types/cascader").Filter;
|
|
290
|
+
readonly showCheckbox: boolean;
|
|
290
291
|
readonly modelValue: CascaderValue | null;
|
|
291
292
|
readonly size: "small" | "default" | "large";
|
|
292
|
-
readonly showCheckbox: boolean;
|
|
293
293
|
readonly onLoad: import("../types/cascader").OnLoad;
|
|
294
|
-
readonly placeholder: string;
|
|
295
294
|
readonly getColumnStyle: (detail: {
|
|
296
295
|
level: number;
|
|
297
296
|
}) => string | Record<string, any>;
|
|
@@ -301,6 +300,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
301
300
|
readonly labelField: string;
|
|
302
301
|
readonly separator: string;
|
|
303
302
|
readonly options: CascaderOption[];
|
|
303
|
+
readonly placeholder: string;
|
|
304
304
|
readonly clearable: boolean;
|
|
305
305
|
readonly filterable: boolean;
|
|
306
306
|
readonly expandTrigger: import("../types/cascader").ExpandTrigger;
|
|
@@ -177,9 +177,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
177
177
|
}>, {
|
|
178
178
|
readonly disabled: boolean;
|
|
179
179
|
readonly modelValue: import("../types").EditableTextareaModelValue;
|
|
180
|
-
readonly placeholder: string;
|
|
181
180
|
readonly maxHeight: number;
|
|
182
181
|
readonly onEnter: import("../types").KeyboardEventHandler;
|
|
182
|
+
readonly placeholder: string;
|
|
183
183
|
readonly maxlength: number;
|
|
184
184
|
readonly readonly: boolean;
|
|
185
185
|
readonly autoHeight: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
import FormListComponent from './index.vue';
|
|
3
|
+
declare const FormList: typeof FormListComponent & Plugin;
|
|
4
|
+
export default FormList;
|
|
5
|
+
export type { FormListProps, FormListRow, FormListDefaultRow } from './props';
|
|
6
|
+
export { useFormListActions } from './use-form-list-actions';
|
|
7
|
+
export { useFormListLayout } from './use-form-list-layout';
|
|
8
|
+
export { useFormListRowForms } from './use-form-list-row-forms';
|
|
9
|
+
export { useFormListUidSync } from './use-form-list-uid-sync';
|
|
10
|
+
export { useFormList, type FormListExpose, type FormListSubmitRow, type UseFormListOptions, type UseFormListReturn } from './use-form-list';
|
|
11
|
+
export { generateUid, cssLength, getFormListRowKey, ensureRowUids, stripUidRow } from './utils';
|
|
12
|
+
export type { RowKeyOptions } from './utils';
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { FormListRow } from './props';
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
readonly modelValue: {
|
|
6
|
+
readonly type: import("vue").PropType<FormListRow[]>;
|
|
7
|
+
readonly default: () => never[];
|
|
8
|
+
};
|
|
9
|
+
readonly defaultRow: {
|
|
10
|
+
readonly type: import("vue").PropType<import("./props").FormListDefaultRow>;
|
|
11
|
+
readonly default: () => {};
|
|
12
|
+
};
|
|
13
|
+
readonly min: {
|
|
14
|
+
readonly type: NumberConstructor;
|
|
15
|
+
readonly default: 0;
|
|
16
|
+
};
|
|
17
|
+
readonly max: {
|
|
18
|
+
readonly type: NumberConstructor;
|
|
19
|
+
readonly default: number;
|
|
20
|
+
};
|
|
21
|
+
readonly modelProp: {
|
|
22
|
+
readonly type: StringConstructor;
|
|
23
|
+
readonly default: "rows";
|
|
24
|
+
};
|
|
25
|
+
readonly keyType: {
|
|
26
|
+
readonly type: import("vue").PropType<"uid" | "index">;
|
|
27
|
+
readonly default: "uid";
|
|
28
|
+
};
|
|
29
|
+
readonly uidKey: {
|
|
30
|
+
readonly type: StringConstructor;
|
|
31
|
+
readonly default: "uid";
|
|
32
|
+
};
|
|
33
|
+
readonly rowKey: {
|
|
34
|
+
readonly type: import("vue").PropType<string | ((row: FormListRow, index: number) => string | number)>;
|
|
35
|
+
readonly default: undefined;
|
|
36
|
+
};
|
|
37
|
+
readonly labelWidth: {
|
|
38
|
+
readonly type: import("vue").PropType<string | number>;
|
|
39
|
+
readonly default: "";
|
|
40
|
+
};
|
|
41
|
+
readonly labelPosition: {
|
|
42
|
+
readonly type: import("vue").PropType<"left" | "right" | "top">;
|
|
43
|
+
readonly default: "right";
|
|
44
|
+
};
|
|
45
|
+
readonly inline: {
|
|
46
|
+
readonly type: BooleanConstructor;
|
|
47
|
+
readonly default: false;
|
|
48
|
+
};
|
|
49
|
+
readonly rules: {
|
|
50
|
+
readonly type: import("vue").PropType<Record<string, import("element-plus").FormItemRule | import("element-plus").FormItemRule[]>>;
|
|
51
|
+
readonly default: undefined;
|
|
52
|
+
};
|
|
53
|
+
readonly size: {
|
|
54
|
+
readonly type: import("vue").PropType<"large" | "default" | "small">;
|
|
55
|
+
readonly default: "default";
|
|
56
|
+
};
|
|
57
|
+
readonly disabled: {
|
|
58
|
+
readonly type: BooleanConstructor;
|
|
59
|
+
readonly default: false;
|
|
60
|
+
};
|
|
61
|
+
readonly validateOnRuleChange: {
|
|
62
|
+
readonly type: BooleanConstructor;
|
|
63
|
+
readonly default: true;
|
|
64
|
+
};
|
|
65
|
+
readonly hideRequiredAsterisk: {
|
|
66
|
+
readonly type: BooleanConstructor;
|
|
67
|
+
readonly default: false;
|
|
68
|
+
};
|
|
69
|
+
readonly showMessage: {
|
|
70
|
+
readonly type: BooleanConstructor;
|
|
71
|
+
readonly default: true;
|
|
72
|
+
};
|
|
73
|
+
readonly inlineMessage: {
|
|
74
|
+
readonly type: BooleanConstructor;
|
|
75
|
+
readonly default: false;
|
|
76
|
+
};
|
|
77
|
+
readonly statusIcon: {
|
|
78
|
+
readonly type: BooleanConstructor;
|
|
79
|
+
readonly default: false;
|
|
80
|
+
};
|
|
81
|
+
readonly scrollToError: {
|
|
82
|
+
readonly type: BooleanConstructor;
|
|
83
|
+
readonly default: false;
|
|
84
|
+
};
|
|
85
|
+
readonly height: {
|
|
86
|
+
readonly type: import("vue").PropType<string | number>;
|
|
87
|
+
readonly default: undefined;
|
|
88
|
+
};
|
|
89
|
+
readonly maxHeight: {
|
|
90
|
+
readonly type: import("vue").PropType<string | number>;
|
|
91
|
+
readonly default: undefined;
|
|
92
|
+
};
|
|
93
|
+
readonly showFooter: {
|
|
94
|
+
readonly type: BooleanConstructor;
|
|
95
|
+
readonly default: true;
|
|
96
|
+
};
|
|
97
|
+
readonly gap: {
|
|
98
|
+
readonly type: StringConstructor;
|
|
99
|
+
readonly default: "18px";
|
|
100
|
+
};
|
|
101
|
+
}>, {
|
|
102
|
+
validate: (callback?: (valid: boolean) => void) => Promise<boolean>;
|
|
103
|
+
validateField: (propsArg: string | string[], callback?: (isValid: boolean) => void, rowIndex?: number) => import("element-plus").FormValidationResult | undefined;
|
|
104
|
+
resetFields: (rowIndex?: number) => void;
|
|
105
|
+
clearValidate: (propsArg?: string | string[], rowIndex?: number) => void;
|
|
106
|
+
scrollToField: (prop: string, rowIndex?: number) => void;
|
|
107
|
+
add: () => void;
|
|
108
|
+
remove: (index: number) => void;
|
|
109
|
+
getFormValues: () => FormListRow[];
|
|
110
|
+
getFormValue: (index: number) => FormListRow | undefined;
|
|
111
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
112
|
+
"update:modelValue": (value: FormListRow[]) => any;
|
|
113
|
+
change: (value: FormListRow[]) => any;
|
|
114
|
+
remove: (row: FormListRow, index: number) => any;
|
|
115
|
+
add: (row: FormListRow, index: number) => any;
|
|
116
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
117
|
+
readonly modelValue: {
|
|
118
|
+
readonly type: import("vue").PropType<FormListRow[]>;
|
|
119
|
+
readonly default: () => never[];
|
|
120
|
+
};
|
|
121
|
+
readonly defaultRow: {
|
|
122
|
+
readonly type: import("vue").PropType<import("./props").FormListDefaultRow>;
|
|
123
|
+
readonly default: () => {};
|
|
124
|
+
};
|
|
125
|
+
readonly min: {
|
|
126
|
+
readonly type: NumberConstructor;
|
|
127
|
+
readonly default: 0;
|
|
128
|
+
};
|
|
129
|
+
readonly max: {
|
|
130
|
+
readonly type: NumberConstructor;
|
|
131
|
+
readonly default: number;
|
|
132
|
+
};
|
|
133
|
+
readonly modelProp: {
|
|
134
|
+
readonly type: StringConstructor;
|
|
135
|
+
readonly default: "rows";
|
|
136
|
+
};
|
|
137
|
+
readonly keyType: {
|
|
138
|
+
readonly type: import("vue").PropType<"uid" | "index">;
|
|
139
|
+
readonly default: "uid";
|
|
140
|
+
};
|
|
141
|
+
readonly uidKey: {
|
|
142
|
+
readonly type: StringConstructor;
|
|
143
|
+
readonly default: "uid";
|
|
144
|
+
};
|
|
145
|
+
readonly rowKey: {
|
|
146
|
+
readonly type: import("vue").PropType<string | ((row: FormListRow, index: number) => string | number)>;
|
|
147
|
+
readonly default: undefined;
|
|
148
|
+
};
|
|
149
|
+
readonly labelWidth: {
|
|
150
|
+
readonly type: import("vue").PropType<string | number>;
|
|
151
|
+
readonly default: "";
|
|
152
|
+
};
|
|
153
|
+
readonly labelPosition: {
|
|
154
|
+
readonly type: import("vue").PropType<"left" | "right" | "top">;
|
|
155
|
+
readonly default: "right";
|
|
156
|
+
};
|
|
157
|
+
readonly inline: {
|
|
158
|
+
readonly type: BooleanConstructor;
|
|
159
|
+
readonly default: false;
|
|
160
|
+
};
|
|
161
|
+
readonly rules: {
|
|
162
|
+
readonly type: import("vue").PropType<Record<string, import("element-plus").FormItemRule | import("element-plus").FormItemRule[]>>;
|
|
163
|
+
readonly default: undefined;
|
|
164
|
+
};
|
|
165
|
+
readonly size: {
|
|
166
|
+
readonly type: import("vue").PropType<"large" | "default" | "small">;
|
|
167
|
+
readonly default: "default";
|
|
168
|
+
};
|
|
169
|
+
readonly disabled: {
|
|
170
|
+
readonly type: BooleanConstructor;
|
|
171
|
+
readonly default: false;
|
|
172
|
+
};
|
|
173
|
+
readonly validateOnRuleChange: {
|
|
174
|
+
readonly type: BooleanConstructor;
|
|
175
|
+
readonly default: true;
|
|
176
|
+
};
|
|
177
|
+
readonly hideRequiredAsterisk: {
|
|
178
|
+
readonly type: BooleanConstructor;
|
|
179
|
+
readonly default: false;
|
|
180
|
+
};
|
|
181
|
+
readonly showMessage: {
|
|
182
|
+
readonly type: BooleanConstructor;
|
|
183
|
+
readonly default: true;
|
|
184
|
+
};
|
|
185
|
+
readonly inlineMessage: {
|
|
186
|
+
readonly type: BooleanConstructor;
|
|
187
|
+
readonly default: false;
|
|
188
|
+
};
|
|
189
|
+
readonly statusIcon: {
|
|
190
|
+
readonly type: BooleanConstructor;
|
|
191
|
+
readonly default: false;
|
|
192
|
+
};
|
|
193
|
+
readonly scrollToError: {
|
|
194
|
+
readonly type: BooleanConstructor;
|
|
195
|
+
readonly default: false;
|
|
196
|
+
};
|
|
197
|
+
readonly height: {
|
|
198
|
+
readonly type: import("vue").PropType<string | number>;
|
|
199
|
+
readonly default: undefined;
|
|
200
|
+
};
|
|
201
|
+
readonly maxHeight: {
|
|
202
|
+
readonly type: import("vue").PropType<string | number>;
|
|
203
|
+
readonly default: undefined;
|
|
204
|
+
};
|
|
205
|
+
readonly showFooter: {
|
|
206
|
+
readonly type: BooleanConstructor;
|
|
207
|
+
readonly default: true;
|
|
208
|
+
};
|
|
209
|
+
readonly gap: {
|
|
210
|
+
readonly type: StringConstructor;
|
|
211
|
+
readonly default: "18px";
|
|
212
|
+
};
|
|
213
|
+
}>> & Readonly<{
|
|
214
|
+
"onUpdate:modelValue"?: ((value: FormListRow[]) => any) | undefined;
|
|
215
|
+
onChange?: ((value: FormListRow[]) => any) | undefined;
|
|
216
|
+
onRemove?: ((row: FormListRow, index: number) => any) | undefined;
|
|
217
|
+
onAdd?: ((row: FormListRow, index: number) => any) | undefined;
|
|
218
|
+
}>, {
|
|
219
|
+
readonly disabled: boolean;
|
|
220
|
+
readonly modelValue: FormListRow[];
|
|
221
|
+
readonly size: "small" | "default" | "large";
|
|
222
|
+
readonly height: string | number;
|
|
223
|
+
readonly maxHeight: string | number;
|
|
224
|
+
readonly gap: string;
|
|
225
|
+
readonly rules: Record<string, import("element-plus").FormItemRule | import("element-plus").FormItemRule[]>;
|
|
226
|
+
readonly defaultRow: import("./props").FormListDefaultRow;
|
|
227
|
+
readonly min: number;
|
|
228
|
+
readonly max: number;
|
|
229
|
+
readonly modelProp: string;
|
|
230
|
+
readonly keyType: "index" | "uid";
|
|
231
|
+
readonly uidKey: string;
|
|
232
|
+
readonly rowKey: string | ((row: FormListRow, index: number) => string | number);
|
|
233
|
+
readonly labelWidth: string | number;
|
|
234
|
+
readonly labelPosition: "top" | "right" | "left";
|
|
235
|
+
readonly inline: boolean;
|
|
236
|
+
readonly validateOnRuleChange: boolean;
|
|
237
|
+
readonly hideRequiredAsterisk: boolean;
|
|
238
|
+
readonly showMessage: boolean;
|
|
239
|
+
readonly inlineMessage: boolean;
|
|
240
|
+
readonly statusIcon: boolean;
|
|
241
|
+
readonly scrollToError: boolean;
|
|
242
|
+
readonly showFooter: boolean;
|
|
243
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
|
|
244
|
+
item?: (props: {
|
|
245
|
+
item: FormListRow;
|
|
246
|
+
index: number;
|
|
247
|
+
list: FormListRow[];
|
|
248
|
+
remove: () => void;
|
|
249
|
+
add: () => void;
|
|
250
|
+
canRemove: boolean;
|
|
251
|
+
canAdd: boolean;
|
|
252
|
+
}) => any;
|
|
253
|
+
} & {
|
|
254
|
+
add?: (props: {
|
|
255
|
+
add: () => void;
|
|
256
|
+
disabled: boolean;
|
|
257
|
+
}) => any;
|
|
258
|
+
}>;
|
|
259
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
260
|
+
new (): {
|
|
261
|
+
$slots: S;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { FormItemRule } from 'element-plus';
|
|
3
|
+
export type FormListRow = Record<string, any>;
|
|
4
|
+
export type FormListDefaultRow = FormListRow | (() => FormListRow);
|
|
5
|
+
export declare const formListProps: {
|
|
6
|
+
/**
|
|
7
|
+
* 列表数据(v-model)
|
|
8
|
+
*/
|
|
9
|
+
readonly modelValue: {
|
|
10
|
+
readonly type: PropType<FormListRow[]>;
|
|
11
|
+
readonly default: () => never[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 新增行时的默认值;对象会浅拷贝,函数每次返回新行初始数据
|
|
15
|
+
*/
|
|
16
|
+
readonly defaultRow: {
|
|
17
|
+
readonly type: PropType<FormListDefaultRow>;
|
|
18
|
+
readonly default: () => {};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 最少行数,达到后不可再删
|
|
22
|
+
*/
|
|
23
|
+
readonly min: {
|
|
24
|
+
readonly type: NumberConstructor;
|
|
25
|
+
readonly default: 0;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 最多行数,达到后不可再增
|
|
29
|
+
*/
|
|
30
|
+
readonly max: {
|
|
31
|
+
readonly type: NumberConstructor;
|
|
32
|
+
readonly default: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 保留字段,组件内不再参与表单绑定(每行独立 el-form,model 即为该行对象)
|
|
36
|
+
*/
|
|
37
|
+
readonly modelProp: {
|
|
38
|
+
readonly type: StringConstructor;
|
|
39
|
+
readonly default: "rows";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 列表项 key 策略:`uid` 使用行内 uid 字段(见 uidKey),`index` 使用行下标
|
|
43
|
+
*/
|
|
44
|
+
readonly keyType: {
|
|
45
|
+
readonly type: PropType<"uid" | "index">;
|
|
46
|
+
readonly default: "uid";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* keyType 为 uid 时,行内唯一标识字段名;缺失时会自动补全,提交前可用 getFormValues 去除
|
|
50
|
+
*/
|
|
51
|
+
readonly uidKey: {
|
|
52
|
+
readonly type: StringConstructor;
|
|
53
|
+
readonly default: "uid";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* 自定义列表项 key(优先级高于 keyType):字符串为行对象字段名(空则回退 index),函数则自定义返回值
|
|
57
|
+
*/
|
|
58
|
+
readonly rowKey: {
|
|
59
|
+
readonly type: PropType<string | ((row: FormListRow, index: number) => string | number)>;
|
|
60
|
+
readonly default: undefined;
|
|
61
|
+
};
|
|
62
|
+
readonly labelWidth: {
|
|
63
|
+
readonly type: PropType<string | number>;
|
|
64
|
+
readonly default: "";
|
|
65
|
+
};
|
|
66
|
+
readonly labelPosition: {
|
|
67
|
+
readonly type: PropType<"left" | "right" | "top">;
|
|
68
|
+
readonly default: "right";
|
|
69
|
+
};
|
|
70
|
+
readonly inline: {
|
|
71
|
+
readonly type: BooleanConstructor;
|
|
72
|
+
readonly default: false;
|
|
73
|
+
};
|
|
74
|
+
readonly rules: {
|
|
75
|
+
readonly type: PropType<Record<string, FormItemRule | FormItemRule[]>>;
|
|
76
|
+
readonly default: undefined;
|
|
77
|
+
};
|
|
78
|
+
readonly size: {
|
|
79
|
+
readonly type: PropType<"large" | "default" | "small">;
|
|
80
|
+
readonly default: "default";
|
|
81
|
+
};
|
|
82
|
+
readonly disabled: {
|
|
83
|
+
readonly type: BooleanConstructor;
|
|
84
|
+
readonly default: false;
|
|
85
|
+
};
|
|
86
|
+
readonly validateOnRuleChange: {
|
|
87
|
+
readonly type: BooleanConstructor;
|
|
88
|
+
readonly default: true;
|
|
89
|
+
};
|
|
90
|
+
readonly hideRequiredAsterisk: {
|
|
91
|
+
readonly type: BooleanConstructor;
|
|
92
|
+
readonly default: false;
|
|
93
|
+
};
|
|
94
|
+
readonly showMessage: {
|
|
95
|
+
readonly type: BooleanConstructor;
|
|
96
|
+
readonly default: true;
|
|
97
|
+
};
|
|
98
|
+
readonly inlineMessage: {
|
|
99
|
+
readonly type: BooleanConstructor;
|
|
100
|
+
readonly default: false;
|
|
101
|
+
};
|
|
102
|
+
readonly statusIcon: {
|
|
103
|
+
readonly type: BooleanConstructor;
|
|
104
|
+
readonly default: false;
|
|
105
|
+
};
|
|
106
|
+
readonly scrollToError: {
|
|
107
|
+
readonly type: BooleanConstructor;
|
|
108
|
+
readonly default: false;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* 根容器固定高度,表单项区域超出时滚动,底部操作区(footer)固定在底部
|
|
112
|
+
*/
|
|
113
|
+
readonly height: {
|
|
114
|
+
readonly type: PropType<string | number>;
|
|
115
|
+
readonly default: undefined;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* 根容器最大高度,超出时表单项区域滚动,footer 固定在底部
|
|
119
|
+
*/
|
|
120
|
+
readonly maxHeight: {
|
|
121
|
+
readonly type: PropType<string | number>;
|
|
122
|
+
readonly default: undefined;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* 是否展示底部区域(含默认「新增」或 add 插槽)
|
|
126
|
+
*/
|
|
127
|
+
readonly showFooter: {
|
|
128
|
+
readonly type: BooleanConstructor;
|
|
129
|
+
readonly default: true;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 表单项间距
|
|
133
|
+
*/
|
|
134
|
+
readonly gap: {
|
|
135
|
+
readonly type: StringConstructor;
|
|
136
|
+
readonly default: "18px";
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export type FormListProps = ExtractPropTypes<typeof formListProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ExtractPropTypes } from 'vue';
|
|
2
|
+
import { formListProps } from './props';
|
|
3
|
+
import type { FormListRow } from './props';
|
|
4
|
+
type Props = ExtractPropTypes<typeof formListProps>;
|
|
5
|
+
type Emit = {
|
|
6
|
+
(e: 'update:modelValue', value: FormListRow[]): void;
|
|
7
|
+
(e: 'add', row: FormListRow, index: number): void;
|
|
8
|
+
(e: 'remove', row: FormListRow, index: number): void;
|
|
9
|
+
(e: 'change', value: FormListRow[]): void;
|
|
10
|
+
};
|
|
11
|
+
export declare function useFormListActions(props: Props, emit: Emit): {
|
|
12
|
+
getRowKey: (row: FormListRow, index: number) => string | number;
|
|
13
|
+
canAdd: import("vue").ComputedRef<boolean>;
|
|
14
|
+
canRemove: import("vue").ComputedRef<boolean>;
|
|
15
|
+
addDisabled: import("vue").ComputedRef<boolean>;
|
|
16
|
+
add: () => void;
|
|
17
|
+
remove: (index: number) => void;
|
|
18
|
+
getFormValues: () => FormListRow[];
|
|
19
|
+
getFormValue: (index: number) => FormListRow | undefined;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ExtractPropTypes } from 'vue';
|
|
2
|
+
import { formListProps } from './props';
|
|
3
|
+
type Props = ExtractPropTypes<typeof formListProps>;
|
|
4
|
+
export declare function useFormListLayout(props: Pick<Props, 'height' | 'maxHeight'>): {
|
|
5
|
+
scrollLayout: import("vue").ComputedRef<boolean>;
|
|
6
|
+
rootStyle: import("vue").ComputedRef<Record<string, string>>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormInstance } from 'element-plus';
|
|
2
|
+
export declare function useFormListRowForms(getLength: () => number): {
|
|
3
|
+
setRowFormRef: (index: number, el: FormInstance | null) => void;
|
|
4
|
+
validate: (callback?: (valid: boolean) => void) => Promise<boolean>;
|
|
5
|
+
validateField: (propsArg: string | string[], callback?: (isValid: boolean) => void, rowIndex?: number) => import("element-plus").FormValidationResult | undefined;
|
|
6
|
+
resetFields: (rowIndex?: number) => void;
|
|
7
|
+
clearValidate: (propsArg?: string | string[], rowIndex?: number) => void;
|
|
8
|
+
scrollToField: (prop: string, rowIndex?: number) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExtractPropTypes } from 'vue';
|
|
2
|
+
import { formListProps } from './props';
|
|
3
|
+
import type { FormListRow } from './props';
|
|
4
|
+
type Props = ExtractPropTypes<typeof formListProps>;
|
|
5
|
+
type Emit = {
|
|
6
|
+
(e: 'update:modelValue', value: FormListRow[]): void;
|
|
7
|
+
(e: 'change', value: FormListRow[]): void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 勿对 modelValue 使用 deep:行内字段变更会反复触发,易与 v-model 形成递归。
|
|
11
|
+
* 仅在数组引用替换、length 变化或 keyType 切换时补全 uid。
|
|
12
|
+
*/
|
|
13
|
+
export declare function useFormListUidSync(props: Props, emit: Emit): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { FormListRow } from './props';
|
|
3
|
+
/** 与 `XnFormList` 中 `defineExpose` 一致,用于 `ref` 与 `useFormList` */
|
|
4
|
+
export interface FormListExpose {
|
|
5
|
+
validate: (callback?: (valid: boolean) => void) => Promise<boolean | void>;
|
|
6
|
+
validateField: (propsArg: string | string[], callback?: (isValid: boolean) => void, rowIndex?: number) => void | Promise<unknown>;
|
|
7
|
+
resetFields: (rowIndex?: number) => void;
|
|
8
|
+
clearValidate: (propsArg?: string | string[], rowIndex?: number) => void;
|
|
9
|
+
scrollToField: (prop: string, rowIndex?: number) => void;
|
|
10
|
+
add: () => void;
|
|
11
|
+
remove: (index: number) => void;
|
|
12
|
+
getFormValues: () => FormListRow[];
|
|
13
|
+
getFormValue: (index: number) => FormListRow | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** 提交用行类型:默认按 `uidKey` 为 `uid` 从 `T` 上剔除(与 `getFormValues` 行为一致) */
|
|
16
|
+
export type FormListSubmitRow<T extends FormListRow> = Omit<T, 'uid'>;
|
|
17
|
+
export interface UseFormListOptions<T extends FormListRow> {
|
|
18
|
+
/**
|
|
19
|
+
* 用于推断行类型 `T`;运行时不参与逻辑,可传 `defaultRow` 工厂或对象
|
|
20
|
+
* @example useFormList({ defaultRow: () => ({ name: '', age: 0 }) })
|
|
21
|
+
*/
|
|
22
|
+
defaultRow?: T | (() => T);
|
|
23
|
+
}
|
|
24
|
+
export interface UseFormListReturn<T extends FormListRow> {
|
|
25
|
+
/** 绑定到 `<xn-form-list ref="formListRef" />` 或模板 `ref="formListRef"` */
|
|
26
|
+
formListRef: Ref<FormListExpose | null>;
|
|
27
|
+
validate: FormListExpose['validate'];
|
|
28
|
+
validateField: FormListExpose['validateField'];
|
|
29
|
+
resetFields: FormListExpose['resetFields'];
|
|
30
|
+
clearValidate: FormListExpose['clearValidate'];
|
|
31
|
+
scrollToField: FormListExpose['scrollToField'];
|
|
32
|
+
add: FormListExpose['add'];
|
|
33
|
+
remove: FormListExpose['remove'];
|
|
34
|
+
/** 去掉 `uid` 后的行数据(默认 `uidKey` 为 `uid` 时与组件一致) */
|
|
35
|
+
getFormValues: () => FormListSubmitRow<T>[];
|
|
36
|
+
getFormValue: (index: number) => FormListSubmitRow<T> | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 配合 `XnFormList` 使用:通过 `defaultRow` 泛型推断行类型,并暴露与组件实例相同的方法。
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const { formListRef, validate, getFormValues } = useFormList({
|
|
44
|
+
* defaultRow: () => ({ name: '', age: 0 as number })
|
|
45
|
+
* })
|
|
46
|
+
* // getFormValues(): { name: string; age: number }[]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function useFormList<T extends FormListRow = FormListRow>(_options?: UseFormListOptions<T>): UseFormListReturn<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FormListRow } from './props';
|
|
2
|
+
export declare function generateUid(): string;
|
|
3
|
+
export declare function cssLength(v: string | number | undefined): string | undefined;
|
|
4
|
+
export type RowKeyOptions = {
|
|
5
|
+
rowKey?: string | ((row: FormListRow, index: number) => string | number);
|
|
6
|
+
keyType: 'uid' | 'index';
|
|
7
|
+
uidKey: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getFormListRowKey(row: FormListRow, index: number, options: RowKeyOptions): string | number;
|
|
10
|
+
export declare function ensureRowUids(list: FormListRow[], uidKey: string): {
|
|
11
|
+
list: FormListRow[];
|
|
12
|
+
changed: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function stripUidRow(row: FormListRow, uidKey: string): FormListRow;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import XnEditableText from './editable-text/index';
|
|
|
9
9
|
import XnEditableTextarea from './editable-textarea/index';
|
|
10
10
|
import XnTimeRangePicker from './time-range-picker/index';
|
|
11
11
|
import XnTextRuleConfig from './text-rule-config';
|
|
12
|
-
|
|
12
|
+
import XnFormList from './form-list/index';
|
|
13
|
+
export { XnCascader, XnTag, XnTransfer, XnVirtualList, XnEllipsis, XnEditableText, XnEditableTextarea, XnTimeRangePicker, XnTextRuleConfig, XnFormList };
|
|
13
14
|
export declare const components: Record<string, Component>;
|
|
14
15
|
export type { CascaderProps } from './cascader/props';
|
|
15
16
|
export type { TagProps } from './tag/props';
|
|
@@ -18,7 +19,9 @@ export type { EditableTextProps } from './editable-text/props';
|
|
|
18
19
|
export type { EditableTextareaProps } from './editable-textarea/props';
|
|
19
20
|
export type { TimeRangePickerProps, TimeRangeValue, TimeRange } from './time-range-picker/props';
|
|
20
21
|
export type { TextRuleConfigProps } from './text-rule-config/props';
|
|
22
|
+
export type { FormListProps, FormListRow, FormListDefaultRow } from './form-list/props';
|
|
23
|
+
export { useFormList, useFormListActions, useFormListLayout, useFormListRowForms, useFormListUidSync, generateUid, cssLength, getFormListRowKey, ensureRowUids, stripUidRow } from './form-list/index';
|
|
24
|
+
export type { FormListExpose, FormListSubmitRow, RowKeyOptions, UseFormListOptions, UseFormListReturn } from './form-list/index';
|
|
21
25
|
export * from './types';
|
|
22
|
-
export * from './time-range-picker/utils';
|
|
23
26
|
declare const plugin: Plugin;
|
|
24
27
|
export default plugin;
|
|
@@ -3,6 +3,6 @@ export interface TimeSlotRange {
|
|
|
3
3
|
startSlot: number;
|
|
4
4
|
endSlot: number;
|
|
5
5
|
}
|
|
6
|
-
export declare function formatTimeRanges(value: Record<number, number[]> | string,
|
|
6
|
+
export declare function formatTimeRanges(value: Record<number, number[]> | string, timeGranularity: number, weekLabels: string[], count: number): string[];
|
|
7
7
|
export declare function stringToObject(value: string, count: number): Record<number, number[]>;
|
|
8
8
|
export declare function objectToString(value: Record<number, number[]>, count: number): string;
|