@tmagic/form 1.2.0-beta.2 → 1.2.0-beta.4

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 (66) hide show
  1. package/dist/tmagic-form.mjs +2081 -2500
  2. package/dist/tmagic-form.mjs.map +1 -1
  3. package/dist/tmagic-form.umd.js +2104 -2524
  4. package/dist/tmagic-form.umd.js.map +1 -1
  5. package/package.json +3 -4
  6. package/src/Form.vue +116 -159
  7. package/src/FormDialog.vue +104 -126
  8. package/src/containers/Col.vue +22 -38
  9. package/src/containers/Container.vue +135 -171
  10. package/src/containers/Fieldset.vue +11 -7
  11. package/src/containers/GroupList.vue +80 -112
  12. package/src/containers/GroupListItem.vue +87 -124
  13. package/src/containers/Panel.vue +26 -49
  14. package/src/containers/Row.vue +18 -40
  15. package/src/containers/Step.vue +36 -48
  16. package/src/containers/Table.vue +437 -478
  17. package/src/containers/Tabs.vue +89 -118
  18. package/src/fields/Cascader.vue +88 -136
  19. package/src/fields/Checkbox.vue +46 -50
  20. package/src/fields/CheckboxGroup.vue +39 -35
  21. package/src/fields/ColorPicker.vue +4 -2
  22. package/src/fields/Date.vue +20 -26
  23. package/src/fields/DateTime.vue +31 -39
  24. package/src/fields/Daterange.vue +3 -2
  25. package/src/fields/DynamicField.vue +63 -77
  26. package/src/fields/Link.vue +65 -86
  27. package/src/fields/Number.vue +32 -34
  28. package/src/fields/RadioGroup.vue +23 -23
  29. package/src/fields/Select.vue +294 -310
  30. package/src/fields/SelectOptionGroups.vue +10 -5
  31. package/src/fields/SelectOptions.vue +4 -2
  32. package/src/fields/Switch.vue +46 -49
  33. package/src/fields/Text.vue +99 -107
  34. package/src/fields/Textarea.vue +32 -44
  35. package/src/fields/Time.vue +19 -30
  36. package/src/index.ts +22 -23
  37. package/src/schema.ts +45 -12
  38. package/types/Form.vue.d.ts +213 -111
  39. package/types/FormDialog.vue.d.ts +812 -155
  40. package/types/containers/Col.vue.d.ts +94 -40
  41. package/types/containers/Container.vue.d.ts +124 -65
  42. package/types/containers/GroupList.vue.d.ts +88 -53
  43. package/types/containers/GroupListItem.vue.d.ts +99 -67
  44. package/types/containers/Panel.vue.d.ts +92 -39
  45. package/types/containers/Row.vue.d.ts +94 -39
  46. package/types/containers/Step.vue.d.ts +104 -42
  47. package/types/containers/Table.vue.d.ts +157 -130
  48. package/types/containers/Tabs.vue.d.ts +95 -50
  49. package/types/fields/Cascader.vue.d.ts +97 -71
  50. package/types/fields/Checkbox.vue.d.ts +97 -56
  51. package/types/fields/CheckboxGroup.vue.d.ts +97 -53
  52. package/types/fields/Date.vue.d.ts +97 -54
  53. package/types/fields/DateTime.vue.d.ts +97 -54
  54. package/types/fields/DynamicField.vue.d.ts +97 -64
  55. package/types/fields/Link.vue.d.ts +62 -657
  56. package/types/fields/Number.vue.d.ts +101 -56
  57. package/types/fields/RadioGroup.vue.d.ts +98 -52
  58. package/types/fields/Select.vue.d.ts +99 -65
  59. package/types/fields/Switch.vue.d.ts +97 -56
  60. package/types/fields/Text.vue.d.ts +100 -57
  61. package/types/fields/Textarea.vue.d.ts +102 -60
  62. package/types/fields/Time.vue.d.ts +97 -55
  63. package/types/index.d.ts +0 -1
  64. package/types/schema.d.ts +37 -9
  65. package/src/utils/fieldProps.ts +0 -39
  66. package/types/utils/fieldProps.d.ts +0 -21
package/src/schema.ts CHANGED
@@ -16,6 +16,11 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ export interface ValidateError {
20
+ message: string;
21
+ field: string;
22
+ }
23
+
19
24
  /**
20
25
  * 整个表单的数据,会注入到各个组件中去
21
26
  */
@@ -167,7 +172,7 @@ type DefaultValueFunction = (mForm: FormState | undefined) => any;
167
172
  /**
168
173
  * 下拉选择器选项配置
169
174
  */
170
- export interface SelectOption {
175
+ export interface SelectConfigOption {
171
176
  /** 选项的标签 */
172
177
  text: string | SelectOptionTextFunction;
173
178
  /** 选项的值 */
@@ -176,10 +181,19 @@ export interface SelectOption {
176
181
  disabled?: boolean;
177
182
  }
178
183
 
184
+ export interface SelectOption {
185
+ /** 选项的标签 */
186
+ text: string;
187
+ /** 选项的值 */
188
+ value: any;
189
+ /** 是否禁用该选项 */
190
+ disabled?: boolean;
191
+ }
192
+
179
193
  /**
180
194
  * 下拉选择器分组选项配置
181
195
  */
182
- export interface SelectGroupOption {
196
+ export interface SelectConfigGroupOption {
183
197
  /** 分组的组名 */
184
198
  label: string;
185
199
  /** 是否禁用该选项组 */
@@ -194,6 +208,22 @@ export interface SelectGroupOption {
194
208
  }[];
195
209
  }
196
210
 
211
+ export interface SelectGroupOption {
212
+ /** 分组的组名 */
213
+ label: string;
214
+ /** 是否禁用该选项组 */
215
+ disabled: boolean;
216
+ options: {
217
+ /** 选项的标签 */
218
+ label?: string;
219
+ text?: string;
220
+ /** 选项的值 */
221
+ value: any;
222
+ /** 是否禁用该选项 */
223
+ disabled?: boolean;
224
+ }[];
225
+ }
226
+
197
227
  type SelectOptionFunction = (
198
228
  mForm: FormState | undefined,
199
229
  data: {
@@ -226,11 +256,11 @@ type RemoteSelectOptionRequestFunction = (
226
256
  },
227
257
  ) => any;
228
258
 
229
- type RemoteSelectOptionItemFunction = (optionsData: Record<string, any>) => SelectOption[];
259
+ type RemoteSelectOptionItemFunction = (optionsData: Record<string, any>) => SelectOption[] | SelectGroupOption[];
230
260
  type SelectOptionValueFunction = (item: Record<string, any>) => any;
231
261
  type SelectOptionTextFunction = (item: Record<string, any>) => string;
232
262
 
233
- interface CascaderOption {
263
+ export interface CascaderOption {
234
264
  /** 指定选项的值为选项对象的某个属性值 */
235
265
  value: any;
236
266
  /** 指定选项标签为选项对象的某个属性值 */
@@ -302,7 +332,7 @@ export interface NumberConfig extends FormItem {
302
332
  min?: number;
303
333
  max?: number;
304
334
  step?: number;
305
- placeholder?: number;
335
+ placeholder?: string;
306
336
  }
307
337
 
308
338
  /**
@@ -361,7 +391,7 @@ export interface SwitchConfig extends FormItem {
361
391
  export interface RadioGroupConfig extends FormItem {
362
392
  type: 'radio-group';
363
393
  options: {
364
- values: string | number | boolean;
394
+ value: string | number | boolean;
365
395
  text: string;
366
396
  }[];
367
397
  }
@@ -378,10 +408,13 @@ export interface ColorPickConfig extends FormItem {
378
408
  */
379
409
  export interface CheckboxGroupConfig extends FormItem {
380
410
  type: 'checkbox-group';
381
- options: {
382
- value: any;
383
- text: string;
384
- }[];
411
+ options:
412
+ | {
413
+ value: any;
414
+ text: string;
415
+ disabled?: boolean;
416
+ }[]
417
+ | Function;
385
418
  }
386
419
 
387
420
  /**
@@ -394,7 +427,7 @@ export interface SelectConfig extends FormItem, Input {
394
427
  valueKey?: string;
395
428
  allowCreate?: boolean;
396
429
  group?: boolean;
397
- options: SelectOption[] | SelectGroupOption[] | SelectOptionFunction;
430
+ options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
398
431
  remote: true;
399
432
  option: {
400
433
  url: string;
@@ -520,7 +553,7 @@ export interface TabPaneConfig {
520
553
  }
521
554
  export interface TabConfig extends FormItem, ContainerCommonConfig {
522
555
  type: 'tab' | 'dynamic-tab';
523
- tabType?: 'tab';
556
+ tabType?: string;
524
557
  editable?: boolean;
525
558
  dynamic?: boolean;
526
559
  tabPosition?: 'top' | 'right' | 'bottom' | 'left';
@@ -1,125 +1,227 @@
1
- import { PropType } from 'vue';
2
- import { FormConfig, FormState, FormValue } from './schema';
3
- declare const _default: import("vue").DefineComponent<{
4
- initValues: {
5
- type: ObjectConstructor;
6
- required: true;
7
- default: () => {};
8
- };
9
- parentValues: {
10
- type: ObjectConstructor;
11
- default: () => {};
12
- };
13
- config: {
14
- type: PropType<FormConfig>;
15
- required: true;
16
- default: () => never[];
17
- };
18
- labelWidth: {
19
- type: StringConstructor;
20
- default: () => string;
21
- };
22
- disabled: {
23
- type: BooleanConstructor;
24
- default: () => boolean;
25
- };
26
- height: {
27
- type: StringConstructor;
28
- default: () => string;
29
- };
30
- stepActive: {
31
- type: (NumberConstructor | StringConstructor)[];
32
- default: () => number;
33
- };
34
- size: {
35
- type: PropType<"small" | "default" | "large">;
36
- };
37
- inline: {
38
- type: BooleanConstructor;
39
- default: boolean;
40
- };
41
- labelPosition: {
42
- type: StringConstructor;
43
- default: string;
44
- };
45
- keyProp: {
46
- type: StringConstructor;
47
- default: string;
48
- };
49
- popperClass: {
50
- type: StringConstructor;
51
- };
1
+ import type { FormConfig, FormState, FormValue } from './schema';
2
+ declare const _default: {
3
+ new (...args: any[]): {
4
+ $: import("vue").ComponentInternalInstance;
5
+ $data: {};
6
+ $props: Partial<{
7
+ config: FormConfig;
8
+ initValues: Object;
9
+ keyProp: string;
10
+ parentValues: Object;
11
+ labelWidth: string;
12
+ disabled: boolean;
13
+ stepActive: string | number;
14
+ height: string;
15
+ inline: boolean;
16
+ labelPosition: string;
17
+ }> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
18
+ config: FormConfig;
19
+ initValues: Object;
20
+ parentValues?: Object | undefined;
21
+ labelWidth?: string | undefined;
22
+ disabled?: boolean | undefined;
23
+ height?: string | undefined;
24
+ stepActive?: string | number | undefined;
25
+ size?: "small" | "default" | "large" | undefined;
26
+ inline?: boolean | undefined;
27
+ labelPosition?: string | undefined;
28
+ keyProp?: string | undefined;
29
+ popperClass?: string | undefined;
30
+ }>, {
31
+ config: () => never[];
32
+ initValues: () => {};
33
+ parentValues: () => {};
34
+ labelWidth: string;
35
+ disabled: boolean;
36
+ height: string;
37
+ stepActive: number;
38
+ inline: boolean;
39
+ labelPosition: string;
40
+ keyProp: string;
41
+ }>>> & {
42
+ onChange?: ((...args: any[]) => any) | undefined;
43
+ "onField-input"?: ((...args: any[]) => any) | undefined;
44
+ "onField-change"?: ((...args: any[]) => any) | undefined;
45
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "config" | "initValues" | "keyProp" | "parentValues" | "labelWidth" | "disabled" | "stepActive" | "height" | "inline" | "labelPosition">;
46
+ $attrs: {
47
+ [x: string]: unknown;
48
+ };
49
+ $refs: {
50
+ [x: string]: unknown;
51
+ };
52
+ $slots: Readonly<{
53
+ [name: string]: import("vue").Slot | undefined;
54
+ }>;
55
+ $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
56
+ $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
57
+ $emit: (event: "change" | "field-input" | "field-change", ...args: any[]) => void;
58
+ $el: any;
59
+ $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
60
+ config: FormConfig;
61
+ initValues: Object;
62
+ parentValues?: Object | undefined;
63
+ labelWidth?: string | undefined;
64
+ disabled?: boolean | undefined;
65
+ height?: string | undefined;
66
+ stepActive?: string | number | undefined;
67
+ size?: "small" | "default" | "large" | undefined;
68
+ inline?: boolean | undefined;
69
+ labelPosition?: string | undefined;
70
+ keyProp?: string | undefined;
71
+ popperClass?: string | undefined;
72
+ }>, {
73
+ config: () => never[];
74
+ initValues: () => {};
75
+ parentValues: () => {};
76
+ labelWidth: string;
77
+ disabled: boolean;
78
+ height: string;
79
+ stepActive: number;
80
+ inline: boolean;
81
+ labelPosition: string;
82
+ keyProp: string;
83
+ }>>> & {
84
+ onChange?: ((...args: any[]) => any) | undefined;
85
+ "onField-input"?: ((...args: any[]) => any) | undefined;
86
+ "onField-change"?: ((...args: any[]) => any) | undefined;
87
+ }, {
88
+ values: import("vue").Ref<FormValue>;
89
+ formState: FormState;
90
+ initialized: import("vue").Ref<boolean>;
91
+ changeHandler: () => void;
92
+ resetForm: () => any;
93
+ submitForm: (native?: boolean) => Promise<any>;
94
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "field-input" | "field-change")[], string, {
95
+ config: FormConfig;
96
+ initValues: Object;
97
+ keyProp: string;
98
+ parentValues: Object;
99
+ labelWidth: string;
100
+ disabled: boolean;
101
+ stepActive: string | number;
102
+ height: string;
103
+ inline: boolean;
104
+ labelPosition: string;
105
+ }> & {
106
+ beforeCreate?: ((() => void) | (() => void)[]) | undefined;
107
+ created?: ((() => void) | (() => void)[]) | undefined;
108
+ beforeMount?: ((() => void) | (() => void)[]) | undefined;
109
+ mounted?: ((() => void) | (() => void)[]) | undefined;
110
+ beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
111
+ updated?: ((() => void) | (() => void)[]) | undefined;
112
+ activated?: ((() => void) | (() => void)[]) | undefined;
113
+ deactivated?: ((() => void) | (() => void)[]) | undefined;
114
+ beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
115
+ beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
116
+ destroyed?: ((() => void) | (() => void)[]) | undefined;
117
+ unmounted?: ((() => void) | (() => void)[]) | undefined;
118
+ renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
119
+ renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
120
+ errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
121
+ };
122
+ $forceUpdate: () => void;
123
+ $nextTick: typeof import("vue").nextTick;
124
+ $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
125
+ } & Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
126
+ config: FormConfig;
127
+ initValues: Object;
128
+ parentValues?: Object | undefined;
129
+ labelWidth?: string | undefined;
130
+ disabled?: boolean | undefined;
131
+ height?: string | undefined;
132
+ stepActive?: string | number | undefined;
133
+ size?: "small" | "default" | "large" | undefined;
134
+ inline?: boolean | undefined;
135
+ labelPosition?: string | undefined;
136
+ keyProp?: string | undefined;
137
+ popperClass?: string | undefined;
138
+ }>, {
139
+ config: () => never[];
140
+ initValues: () => {};
141
+ parentValues: () => {};
142
+ labelWidth: string;
143
+ disabled: boolean;
144
+ height: string;
145
+ stepActive: number;
146
+ inline: boolean;
147
+ labelPosition: string;
148
+ keyProp: string;
149
+ }>>> & {
150
+ onChange?: ((...args: any[]) => any) | undefined;
151
+ "onField-input"?: ((...args: any[]) => any) | undefined;
152
+ "onField-change"?: ((...args: any[]) => any) | undefined;
153
+ } & import("vue").ShallowUnwrapRef<{
154
+ values: import("vue").Ref<FormValue>;
155
+ formState: FormState;
156
+ initialized: import("vue").Ref<boolean>;
157
+ changeHandler: () => void;
158
+ resetForm: () => any;
159
+ submitForm: (native?: boolean) => Promise<any>;
160
+ }> & {} & import("vue").ComponentCustomProperties;
161
+ __isFragment?: undefined;
162
+ __isTeleport?: undefined;
163
+ __isSuspense?: undefined;
164
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
165
+ config: FormConfig;
166
+ initValues: Object;
167
+ parentValues?: Object | undefined;
168
+ labelWidth?: string | undefined;
169
+ disabled?: boolean | undefined;
170
+ height?: string | undefined;
171
+ stepActive?: string | number | undefined;
172
+ size?: "small" | "default" | "large" | undefined;
173
+ inline?: boolean | undefined;
174
+ labelPosition?: string | undefined;
175
+ keyProp?: string | undefined;
176
+ popperClass?: string | undefined;
177
+ }>, {
178
+ config: () => never[];
179
+ initValues: () => {};
180
+ parentValues: () => {};
181
+ labelWidth: string;
182
+ disabled: boolean;
183
+ height: string;
184
+ stepActive: number;
185
+ inline: boolean;
186
+ labelPosition: string;
187
+ keyProp: string;
188
+ }>>> & {
189
+ onChange?: ((...args: any[]) => any) | undefined;
190
+ "onField-input"?: ((...args: any[]) => any) | undefined;
191
+ "onField-change"?: ((...args: any[]) => any) | undefined;
52
192
  }, {
53
- initialized: import("vue").Ref<boolean>;
54
193
  values: import("vue").Ref<FormValue>;
55
- elForm: import("vue").Ref<any>;
56
194
  formState: FormState;
195
+ initialized: import("vue").Ref<boolean>;
57
196
  changeHandler: () => void;
58
197
  resetForm: () => any;
59
198
  submitForm: (native?: boolean) => Promise<any>;
60
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "field-input" | "field-change")[], "change" | "field-input" | "field-change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
61
- initValues: {
62
- type: ObjectConstructor;
63
- required: true;
64
- default: () => {};
65
- };
66
- parentValues: {
67
- type: ObjectConstructor;
68
- default: () => {};
69
- };
70
- config: {
71
- type: PropType<FormConfig>;
72
- required: true;
73
- default: () => never[];
74
- };
75
- labelWidth: {
76
- type: StringConstructor;
77
- default: () => string;
78
- };
79
- disabled: {
80
- type: BooleanConstructor;
81
- default: () => boolean;
82
- };
83
- height: {
84
- type: StringConstructor;
85
- default: () => string;
86
- };
87
- stepActive: {
88
- type: (NumberConstructor | StringConstructor)[];
89
- default: () => number;
90
- };
91
- size: {
92
- type: PropType<"small" | "default" | "large">;
93
- };
94
- inline: {
95
- type: BooleanConstructor;
96
- default: boolean;
97
- };
98
- labelPosition: {
99
- type: StringConstructor;
100
- default: string;
101
- };
102
- keyProp: {
103
- type: StringConstructor;
104
- default: string;
105
- };
106
- popperClass: {
107
- type: StringConstructor;
108
- };
109
- }>> & {
110
- onChange?: ((...args: any[]) => any) | undefined;
111
- "onField-input"?: ((...args: any[]) => any) | undefined;
112
- "onField-change"?: ((...args: any[]) => any) | undefined;
113
- }, {
199
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "field-input" | "field-change")[], "change" | "field-input" | "field-change", {
114
200
  config: FormConfig;
115
- initValues: Record<string, any>;
201
+ initValues: Object;
116
202
  keyProp: string;
117
- parentValues: Record<string, any>;
203
+ parentValues: Object;
118
204
  labelWidth: string;
119
205
  disabled: boolean;
120
- height: string;
121
206
  stepActive: string | number;
207
+ height: string;
122
208
  inline: boolean;
123
209
  labelPosition: string;
124
- }>;
210
+ }> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
211
+ $slots: {};
212
+ });
125
213
  export default _default;
214
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
215
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
216
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
217
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
218
+ } : {
219
+ type: import('vue').PropType<T[K]>;
220
+ required: true;
221
+ };
222
+ };
223
+ declare type __VLS_WithDefaults<P, D> = {
224
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
225
+ default: D[K];
226
+ } : P[K];
227
+ };