@tmagic/form 1.0.0-beta.1 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +5432 -0
  2. package/README.md +1 -0
  3. package/dist/style.css +0 -1
  4. package/dist/tmagic-form.es.js +71 -47
  5. package/dist/tmagic-form.es.js.map +1 -1
  6. package/dist/tmagic-form.umd.js +71 -47
  7. package/dist/tmagic-form.umd.js.map +1 -1
  8. package/dist/types/src/containers/Container.vue.d.ts +1 -1
  9. package/dist/types/src/containers/Fieldset.vue.d.ts +1 -1
  10. package/dist/types/src/containers/GroupList.vue.d.ts +1 -1
  11. package/dist/types/src/containers/GroupListItem.vue.d.ts +1 -1
  12. package/dist/types/src/containers/Panel.vue.d.ts +1 -1
  13. package/dist/types/src/containers/Row.vue.d.ts +1 -1
  14. package/dist/types/src/containers/Step.vue.d.ts +1 -1
  15. package/dist/types/src/containers/Tabs.vue.d.ts +2 -2
  16. package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
  17. package/dist/types/src/fields/CheckboxGroup.vue.d.ts +2 -2
  18. package/dist/types/src/fields/Date.vue.d.ts +2 -2
  19. package/dist/types/src/fields/DateTime.vue.d.ts +2 -2
  20. package/dist/types/src/fields/Daterange.vue.d.ts +2 -2
  21. package/dist/types/src/fields/DynamicField.vue.d.ts +2 -2
  22. package/dist/types/src/fields/Number.vue.d.ts +2 -2
  23. package/dist/types/src/fields/RadioGroup.vue.d.ts +2 -2
  24. package/dist/types/src/fields/Switch.vue.d.ts +2 -2
  25. package/dist/types/src/fields/Text.vue.d.ts +2 -2
  26. package/dist/types/src/fields/Textarea.vue.d.ts +2 -2
  27. package/dist/types/src/fields/Time.vue.d.ts +2 -2
  28. package/dist/types/src/schema.d.ts +2 -0
  29. package/package.json +10 -8
  30. package/src/Form.vue +39 -30
  31. package/src/FormDialog.vue +3 -0
  32. package/src/containers/Container.vue +20 -7
  33. package/src/containers/Table.vue +8 -6
  34. package/src/containers/Tabs.vue +4 -0
  35. package/src/fields/Select.vue +4 -3
  36. package/src/fields/Text.vue +4 -4
  37. package/src/schema.ts +2 -0
  38. package/src/theme/table.scss +0 -1
  39. package/src/utils/form.ts +5 -1
  40. package/dist/types/src/Form.vue.d.ts +0 -304
  41. package/dist/types/src/FormDialog.vue.d.ts +0 -641
  42. package/dist/types/src/containers/Table.vue.d.ts +0 -1401
  43. package/dist/types/src/fields/Cascader.vue.d.ts +0 -1748
  44. package/dist/types/src/fields/Link.vue.d.ts +0 -1365
  45. package/dist/types/src/fields/Select.vue.d.ts +0 -975
package/src/utils/form.ts CHANGED
@@ -122,7 +122,11 @@ const initValueItem = function (
122
122
  // 这种情况比较多,提前结束
123
123
  if (name && !items && typeof initValue[name] !== 'undefined') {
124
124
  if (typeof value[name] === 'undefined') {
125
- value[name] = typeof initValue[name] === 'object' ? cloneDeep(initValue[name]) : initValue[name];
125
+ if (type === 'number') {
126
+ value[name] = Number(initValue[name]);
127
+ } else {
128
+ value[name] = typeof initValue[name] === 'object' ? cloneDeep(initValue[name]) : initValue[name];
129
+ }
126
130
  }
127
131
 
128
132
  return value;
@@ -1,304 +0,0 @@
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;