@tmagic/form 1.0.0-beta.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/dist/style.css +161 -0
- package/dist/tmagic-form.es.js +3749 -0
- package/dist/tmagic-form.es.js.map +1 -0
- package/dist/tmagic-form.umd.js +3790 -0
- package/dist/tmagic-form.umd.js.map +1 -0
- package/dist/types/src/Form.vue.d.ts +304 -0
- package/dist/types/src/FormDialog.vue.d.ts +641 -0
- package/dist/types/src/containers/Container.vue.d.ts +69 -0
- package/dist/types/src/containers/Fieldset.vue.d.ts +56 -0
- package/dist/types/src/containers/GroupList.vue.d.ts +56 -0
- package/dist/types/src/containers/GroupListItem.vue.d.ts +72 -0
- package/dist/types/src/containers/Panel.vue.d.ts +41 -0
- package/dist/types/src/containers/Row.vue.d.ts +42 -0
- package/dist/types/src/containers/Step.vue.d.ts +45 -0
- package/dist/types/src/containers/Table.vue.d.ts +1401 -0
- package/dist/types/src/containers/Tabs.vue.d.ts +45 -0
- package/dist/types/src/fields/Cascader.vue.d.ts +1748 -0
- package/dist/types/src/fields/Checkbox.vue.d.ts +59 -0
- package/dist/types/src/fields/CheckboxGroup.vue.d.ts +56 -0
- package/dist/types/src/fields/Date.vue.d.ts +58 -0
- package/dist/types/src/fields/DateTime.vue.d.ts +57 -0
- package/dist/types/src/fields/Daterange.vue.d.ts +57 -0
- package/dist/types/src/fields/Display.vue.d.ts +3 -0
- package/dist/types/src/fields/DynamicField.vue.d.ts +76 -0
- package/dist/types/src/fields/Hidden.vue.d.ts +3 -0
- package/dist/types/src/fields/Link.vue.d.ts +1365 -0
- package/dist/types/src/fields/Number.vue.d.ts +59 -0
- package/dist/types/src/fields/RadioGroup.vue.d.ts +55 -0
- package/dist/types/src/fields/Select.vue.d.ts +975 -0
- package/dist/types/src/fields/Switch.vue.d.ts +59 -0
- package/dist/types/src/fields/Text.vue.d.ts +61 -0
- package/dist/types/src/fields/Textarea.vue.d.ts +56 -0
- package/dist/types/src/fields/Time.vue.d.ts +54 -0
- package/dist/types/src/index.d.ts +36 -0
- package/dist/types/src/schema.d.ts +495 -0
- package/dist/types/src/shims-vue.d.ts +6 -0
- package/dist/types/src/utils/config.d.ts +3 -0
- package/dist/types/src/utils/fieldProps.d.ts +21 -0
- package/dist/types/src/utils/form.d.ts +8 -0
- package/dist/types/src/utils/useAddField.d.ts +1 -0
- package/dist/types/src/vite-env.d.ts +1 -0
- package/package.json +51 -0
- package/src/Form.vue +188 -0
- package/src/FormDialog.vue +163 -0
- package/src/containers/Container.vue +263 -0
- package/src/containers/Fieldset.vue +138 -0
- package/src/containers/GroupList.vue +152 -0
- package/src/containers/GroupListItem.vue +159 -0
- package/src/containers/Panel.vue +106 -0
- package/src/containers/Row.vue +68 -0
- package/src/containers/Step.vue +82 -0
- package/src/containers/Table.vue +624 -0
- package/src/containers/Tabs.vue +176 -0
- package/src/fields/Cascader.vue +147 -0
- package/src/fields/Checkbox.vue +67 -0
- package/src/fields/CheckboxGroup.vue +44 -0
- package/src/fields/ColorPicker.vue +38 -0
- package/src/fields/Date.vue +51 -0
- package/src/fields/DateTime.vue +59 -0
- package/src/fields/Daterange.vue +75 -0
- package/src/fields/Display.vue +34 -0
- package/src/fields/DynamicField.vue +109 -0
- package/src/fields/Hidden.vue +29 -0
- package/src/fields/Link.vue +112 -0
- package/src/fields/Number.vue +53 -0
- package/src/fields/RadioGroup.vue +33 -0
- package/src/fields/Select.vue +393 -0
- package/src/fields/Switch.vue +65 -0
- package/src/fields/Text.vue +134 -0
- package/src/fields/Textarea.vue +62 -0
- package/src/fields/Time.vue +48 -0
- package/src/index.ts +127 -0
- package/src/schema.ts +638 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/theme/date-time.scss +7 -0
- package/src/theme/fieldset.scss +24 -0
- package/src/theme/form-dialog.scss +13 -0
- package/src/theme/form.scss +30 -0
- package/src/theme/group-list.scss +23 -0
- package/src/theme/index.scss +9 -0
- package/src/theme/link.scss +3 -0
- package/src/theme/panel.scss +18 -0
- package/src/theme/select.scss +3 -0
- package/src/theme/table.scss +69 -0
- package/src/theme/tabs.scss +25 -0
- package/src/utils/config.ts +27 -0
- package/src/utils/containerProps.ts +50 -0
- package/src/utils/createForm.ts +25 -0
- package/src/utils/fieldProps.ts +39 -0
- package/src/utils/form.ts +266 -0
- package/src/utils/useAddField.ts +40 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +9 -0
- package/vite.config.ts +27 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type { ValidateFieldCallback } from 'element-plus';
|
|
2
|
+
import type { Callback } from 'element-plus/es/components/form/src/form.vue';
|
|
3
|
+
import type { FormItemRule } from 'element-plus/es/components/form/src/form.type';
|
|
4
|
+
import type { DefineComponent, Ref, ComponentInternalInstance, ExtractPropTypes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComputedRef, ComponentOptionsMixin, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, PropType } from 'vue';
|
|
5
|
+
import { FormConfig, FormState } from './schema';
|
|
6
|
+
export interface ValidateError {
|
|
7
|
+
message: string;
|
|
8
|
+
field: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FieldErrorList {
|
|
11
|
+
[field: string]: ValidateError[];
|
|
12
|
+
}
|
|
13
|
+
declare const _default: DefineComponent<{
|
|
14
|
+
initValues: {
|
|
15
|
+
type: ObjectConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
default: () => {};
|
|
18
|
+
};
|
|
19
|
+
parentValues: {
|
|
20
|
+
type: ObjectConstructor;
|
|
21
|
+
default: () => {};
|
|
22
|
+
};
|
|
23
|
+
config: {
|
|
24
|
+
type: PropType<FormConfig>;
|
|
25
|
+
required: true;
|
|
26
|
+
default: () => never[];
|
|
27
|
+
};
|
|
28
|
+
labelWidth: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: () => string;
|
|
31
|
+
};
|
|
32
|
+
disabled: {
|
|
33
|
+
type: BooleanConstructor;
|
|
34
|
+
default: () => boolean;
|
|
35
|
+
};
|
|
36
|
+
height: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: () => string;
|
|
39
|
+
};
|
|
40
|
+
stepActive: {
|
|
41
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
42
|
+
default: () => number;
|
|
43
|
+
};
|
|
44
|
+
size: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: string;
|
|
47
|
+
};
|
|
48
|
+
inline: {
|
|
49
|
+
type: BooleanConstructor;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
52
|
+
labelPosition: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
keyProp: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
}, {
|
|
61
|
+
initialized: Ref<boolean>;
|
|
62
|
+
values: Ref<{
|
|
63
|
+
[x: string]: any;
|
|
64
|
+
[x: number]: any;
|
|
65
|
+
}>;
|
|
66
|
+
elForm: Ref<({
|
|
67
|
+
$: ComponentInternalInstance;
|
|
68
|
+
$data: {};
|
|
69
|
+
$props: Partial<{
|
|
70
|
+
disabled: boolean;
|
|
71
|
+
inline: boolean;
|
|
72
|
+
labelWidth: string | number;
|
|
73
|
+
labelSuffix: string;
|
|
74
|
+
inlineMessage: boolean;
|
|
75
|
+
statusIcon: boolean;
|
|
76
|
+
showMessage: boolean;
|
|
77
|
+
validateOnRuleChange: boolean;
|
|
78
|
+
hideRequiredAsterisk: boolean;
|
|
79
|
+
scrollToError: boolean;
|
|
80
|
+
}> & Omit<Readonly<ExtractPropTypes<{
|
|
81
|
+
model: ObjectConstructor;
|
|
82
|
+
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
83
|
+
labelPosition: StringConstructor;
|
|
84
|
+
labelWidth: {
|
|
85
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
86
|
+
default: string;
|
|
87
|
+
};
|
|
88
|
+
labelSuffix: {
|
|
89
|
+
type: StringConstructor;
|
|
90
|
+
default: string;
|
|
91
|
+
};
|
|
92
|
+
inline: BooleanConstructor;
|
|
93
|
+
inlineMessage: BooleanConstructor;
|
|
94
|
+
statusIcon: BooleanConstructor;
|
|
95
|
+
showMessage: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
size: PropType<"default" | "small" | "large">;
|
|
100
|
+
disabled: BooleanConstructor;
|
|
101
|
+
validateOnRuleChange: {
|
|
102
|
+
type: BooleanConstructor;
|
|
103
|
+
default: boolean;
|
|
104
|
+
};
|
|
105
|
+
hideRequiredAsterisk: {
|
|
106
|
+
type: BooleanConstructor;
|
|
107
|
+
default: boolean;
|
|
108
|
+
};
|
|
109
|
+
scrollToError: BooleanConstructor;
|
|
110
|
+
}>> & {
|
|
111
|
+
onValidate?: ((...args: any[]) => any) | undefined;
|
|
112
|
+
} & VNodeProps & AllowedComponentProps & ComponentCustomProps, "labelWidth" | "labelSuffix" | "inline" | "inlineMessage" | "statusIcon" | "showMessage" | "disabled" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError">;
|
|
113
|
+
$attrs: {
|
|
114
|
+
[x: string]: unknown;
|
|
115
|
+
};
|
|
116
|
+
$refs: {
|
|
117
|
+
[x: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
$slots: Readonly<{
|
|
120
|
+
[name: string]: Slot | undefined;
|
|
121
|
+
}>;
|
|
122
|
+
$root: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
123
|
+
$parent: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
124
|
+
$emit: (event: "validate", ...args: any[]) => void;
|
|
125
|
+
$el: any;
|
|
126
|
+
$options: ComponentOptionsBase<Readonly<ExtractPropTypes<{
|
|
127
|
+
model: ObjectConstructor;
|
|
128
|
+
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
129
|
+
labelPosition: StringConstructor;
|
|
130
|
+
labelWidth: {
|
|
131
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
132
|
+
default: string;
|
|
133
|
+
};
|
|
134
|
+
labelSuffix: {
|
|
135
|
+
type: StringConstructor;
|
|
136
|
+
default: string;
|
|
137
|
+
};
|
|
138
|
+
inline: BooleanConstructor;
|
|
139
|
+
inlineMessage: BooleanConstructor;
|
|
140
|
+
statusIcon: BooleanConstructor;
|
|
141
|
+
showMessage: {
|
|
142
|
+
type: BooleanConstructor;
|
|
143
|
+
default: boolean;
|
|
144
|
+
};
|
|
145
|
+
size: PropType<"default" | "small" | "large">;
|
|
146
|
+
disabled: BooleanConstructor;
|
|
147
|
+
validateOnRuleChange: {
|
|
148
|
+
type: BooleanConstructor;
|
|
149
|
+
default: boolean;
|
|
150
|
+
};
|
|
151
|
+
hideRequiredAsterisk: {
|
|
152
|
+
type: BooleanConstructor;
|
|
153
|
+
default: boolean;
|
|
154
|
+
};
|
|
155
|
+
scrollToError: BooleanConstructor;
|
|
156
|
+
}>> & {
|
|
157
|
+
onValidate?: ((...args: any[]) => any) | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
formKls: ComputedRef<string[]>;
|
|
160
|
+
validate: (callback?: Callback | undefined) => Promise<boolean> | undefined;
|
|
161
|
+
resetFields: () => void;
|
|
162
|
+
clearValidate: (props?: string | string[] | undefined) => void;
|
|
163
|
+
validateField: (props: string | string[], cb: ValidateFieldCallback) => void;
|
|
164
|
+
scrollToField: (prop: string) => void;
|
|
165
|
+
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "validate"[], string, {
|
|
166
|
+
disabled: boolean;
|
|
167
|
+
inline: boolean;
|
|
168
|
+
labelWidth: string | number;
|
|
169
|
+
labelSuffix: string;
|
|
170
|
+
inlineMessage: boolean;
|
|
171
|
+
statusIcon: boolean;
|
|
172
|
+
showMessage: boolean;
|
|
173
|
+
validateOnRuleChange: boolean;
|
|
174
|
+
hideRequiredAsterisk: boolean;
|
|
175
|
+
scrollToError: boolean;
|
|
176
|
+
}> & {
|
|
177
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
178
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
179
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
180
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
181
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
182
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
183
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
184
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
185
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
186
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
187
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
188
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
189
|
+
renderTracked?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
|
|
190
|
+
renderTriggered?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
|
|
191
|
+
errorCaptured?: (((err: unknown, instance: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
192
|
+
};
|
|
193
|
+
$forceUpdate: () => void;
|
|
194
|
+
$nextTick: typeof nextTick;
|
|
195
|
+
$watch(source: string | Function, cb: Function, options?: WatchOptions<boolean> | undefined): WatchStopHandle;
|
|
196
|
+
} & Readonly<ExtractPropTypes<{
|
|
197
|
+
model: ObjectConstructor;
|
|
198
|
+
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
199
|
+
labelPosition: StringConstructor;
|
|
200
|
+
labelWidth: {
|
|
201
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
202
|
+
default: string;
|
|
203
|
+
};
|
|
204
|
+
labelSuffix: {
|
|
205
|
+
type: StringConstructor;
|
|
206
|
+
default: string;
|
|
207
|
+
};
|
|
208
|
+
inline: BooleanConstructor;
|
|
209
|
+
inlineMessage: BooleanConstructor;
|
|
210
|
+
statusIcon: BooleanConstructor;
|
|
211
|
+
showMessage: {
|
|
212
|
+
type: BooleanConstructor;
|
|
213
|
+
default: boolean;
|
|
214
|
+
};
|
|
215
|
+
size: PropType<"default" | "small" | "large">;
|
|
216
|
+
disabled: BooleanConstructor;
|
|
217
|
+
validateOnRuleChange: {
|
|
218
|
+
type: BooleanConstructor;
|
|
219
|
+
default: boolean;
|
|
220
|
+
};
|
|
221
|
+
hideRequiredAsterisk: {
|
|
222
|
+
type: BooleanConstructor;
|
|
223
|
+
default: boolean;
|
|
224
|
+
};
|
|
225
|
+
scrollToError: BooleanConstructor;
|
|
226
|
+
}>> & {
|
|
227
|
+
onValidate?: ((...args: any[]) => any) | undefined;
|
|
228
|
+
} & ShallowUnwrapRef<{
|
|
229
|
+
formKls: ComputedRef<string[]>;
|
|
230
|
+
validate: (callback?: Callback | undefined) => Promise<boolean> | undefined;
|
|
231
|
+
resetFields: () => void;
|
|
232
|
+
clearValidate: (props?: string | string[] | undefined) => void;
|
|
233
|
+
validateField: (props: string | string[], cb: ValidateFieldCallback) => void;
|
|
234
|
+
scrollToField: (prop: string) => void;
|
|
235
|
+
}> & {} & {} & ComponentCustomProperties) | undefined>;
|
|
236
|
+
formState: FormState;
|
|
237
|
+
changeHandler: () => void;
|
|
238
|
+
resetForm: () => void | undefined;
|
|
239
|
+
submitForm: (native?: boolean | undefined) => Promise<any>;
|
|
240
|
+
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "field-input" | "field-change")[], "change" | "field-input" | "field-change", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
241
|
+
initValues: {
|
|
242
|
+
type: ObjectConstructor;
|
|
243
|
+
required: true;
|
|
244
|
+
default: () => {};
|
|
245
|
+
};
|
|
246
|
+
parentValues: {
|
|
247
|
+
type: ObjectConstructor;
|
|
248
|
+
default: () => {};
|
|
249
|
+
};
|
|
250
|
+
config: {
|
|
251
|
+
type: PropType<FormConfig>;
|
|
252
|
+
required: true;
|
|
253
|
+
default: () => never[];
|
|
254
|
+
};
|
|
255
|
+
labelWidth: {
|
|
256
|
+
type: StringConstructor;
|
|
257
|
+
default: () => string;
|
|
258
|
+
};
|
|
259
|
+
disabled: {
|
|
260
|
+
type: BooleanConstructor;
|
|
261
|
+
default: () => boolean;
|
|
262
|
+
};
|
|
263
|
+
height: {
|
|
264
|
+
type: StringConstructor;
|
|
265
|
+
default: () => string;
|
|
266
|
+
};
|
|
267
|
+
stepActive: {
|
|
268
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
269
|
+
default: () => number;
|
|
270
|
+
};
|
|
271
|
+
size: {
|
|
272
|
+
type: StringConstructor;
|
|
273
|
+
default: string;
|
|
274
|
+
};
|
|
275
|
+
inline: {
|
|
276
|
+
type: BooleanConstructor;
|
|
277
|
+
default: boolean;
|
|
278
|
+
};
|
|
279
|
+
labelPosition: {
|
|
280
|
+
type: StringConstructor;
|
|
281
|
+
default: string;
|
|
282
|
+
};
|
|
283
|
+
keyProp: {
|
|
284
|
+
type: StringConstructor;
|
|
285
|
+
default: string;
|
|
286
|
+
};
|
|
287
|
+
}>> & {
|
|
288
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
289
|
+
"onField-input"?: ((...args: any[]) => any) | undefined;
|
|
290
|
+
"onField-change"?: ((...args: any[]) => any) | undefined;
|
|
291
|
+
}, {
|
|
292
|
+
labelPosition: string;
|
|
293
|
+
labelWidth: string;
|
|
294
|
+
inline: boolean;
|
|
295
|
+
size: string;
|
|
296
|
+
disabled: boolean;
|
|
297
|
+
config: FormConfig;
|
|
298
|
+
stepActive: string | number;
|
|
299
|
+
initValues: Record<string, any>;
|
|
300
|
+
parentValues: Record<string, any>;
|
|
301
|
+
height: string;
|
|
302
|
+
keyProp: string;
|
|
303
|
+
}>;
|
|
304
|
+
export default _default;
|