@tmagic/form 1.2.0-beta.2 → 1.2.0-beta.21
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 +1 -1
- package/dist/tmagic-form.js +3673 -0
- package/dist/tmagic-form.js.map +1 -0
- package/dist/tmagic-form.umd.cjs +3713 -0
- package/dist/tmagic-form.umd.cjs.map +1 -0
- package/package.json +10 -9
- package/src/Form.vue +124 -159
- package/src/FormDialog.vue +108 -126
- package/src/containers/Col.vue +24 -38
- package/src/containers/Container.vue +143 -171
- package/src/containers/Fieldset.vue +15 -8
- package/src/containers/GroupList.vue +86 -116
- package/src/containers/GroupListItem.vue +91 -125
- package/src/containers/Panel.vue +29 -49
- package/src/containers/Row.vue +20 -40
- package/src/containers/Step.vue +38 -48
- package/src/containers/Table.vue +466 -481
- package/src/containers/Tabs.vue +94 -118
- package/src/fields/Cascader.vue +88 -136
- package/src/fields/Checkbox.vue +46 -50
- package/src/fields/CheckboxGroup.vue +39 -35
- package/src/fields/ColorPicker.vue +5 -3
- package/src/fields/Date.vue +21 -27
- package/src/fields/DateTime.vue +31 -39
- package/src/fields/Daterange.vue +4 -3
- package/src/fields/Display.vue +1 -1
- package/src/fields/DynamicField.vue +63 -77
- package/src/fields/Hidden.vue +1 -1
- package/src/fields/Link.vue +65 -86
- package/src/fields/Number.vue +32 -34
- package/src/fields/RadioGroup.vue +23 -23
- package/src/fields/Select.vue +294 -310
- package/src/fields/SelectOptionGroups.vue +11 -6
- package/src/fields/SelectOptions.vue +5 -3
- package/src/fields/Switch.vue +46 -49
- package/src/fields/Text.vue +99 -107
- package/src/fields/Textarea.vue +32 -44
- package/src/fields/Time.vue +21 -30
- package/src/index.ts +22 -23
- package/src/schema.ts +50 -12
- package/src/theme/form.scss +1 -1
- package/src/utils/form.ts +9 -5
- package/types/Form.vue.d.ts +211 -111
- package/types/FormDialog.vue.d.ts +813 -154
- package/types/containers/Col.vue.d.ts +96 -40
- package/types/containers/Container.vue.d.ts +126 -65
- package/types/containers/Fieldset.vue.d.ts +5 -3
- package/types/containers/GroupList.vue.d.ts +90 -53
- package/types/containers/GroupListItem.vue.d.ts +101 -67
- package/types/containers/Panel.vue.d.ts +96 -39
- package/types/containers/Row.vue.d.ts +96 -39
- package/types/containers/Step.vue.d.ts +106 -42
- package/types/containers/Table.vue.d.ts +161 -130
- package/types/containers/Tabs.vue.d.ts +97 -50
- package/types/fields/Cascader.vue.d.ts +95 -71
- package/types/fields/Checkbox.vue.d.ts +95 -56
- package/types/fields/CheckboxGroup.vue.d.ts +95 -53
- package/types/fields/ColorPicker.vue.d.ts +1 -3
- package/types/fields/Date.vue.d.ts +95 -54
- package/types/fields/DateTime.vue.d.ts +95 -54
- package/types/fields/Daterange.vue.d.ts +1 -3
- package/types/fields/Display.vue.d.ts +1 -3
- package/types/fields/DynamicField.vue.d.ts +95 -64
- package/types/fields/Hidden.vue.d.ts +1 -3
- package/types/fields/Link.vue.d.ts +60 -657
- package/types/fields/Number.vue.d.ts +99 -56
- package/types/fields/RadioGroup.vue.d.ts +96 -52
- package/types/fields/Select.vue.d.ts +97 -65
- package/types/fields/SelectOptionGroups.vue.d.ts +1 -3
- package/types/fields/SelectOptions.vue.d.ts +1 -3
- package/types/fields/Switch.vue.d.ts +95 -56
- package/types/fields/Text.vue.d.ts +98 -57
- package/types/fields/Textarea.vue.d.ts +100 -60
- package/types/fields/Time.vue.d.ts +95 -55
- package/types/index.d.ts +0 -1
- package/types/schema.d.ts +42 -9
- package/types/utils/form.d.ts +2 -1
- package/dist/tmagic-form.mjs +0 -3925
- package/dist/tmagic-form.mjs.map +0 -1
- package/dist/tmagic-form.umd.js +0 -3965
- package/dist/tmagic-form.umd.js.map +0 -1
- package/src/utils/fieldProps.ts +0 -39
- package/types/utils/fieldProps.d.ts +0 -21
|
@@ -1,58 +1,98 @@
|
|
|
1
|
-
import { PropType } from 'vue';
|
|
2
1
|
import { TimeConfig } from '../schema';
|
|
3
|
-
declare const _default:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
2
|
+
declare const _default: {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
$: import("vue").ComponentInternalInstance;
|
|
5
|
+
$data: {};
|
|
6
|
+
$props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
config: TimeConfig;
|
|
8
|
+
model: any;
|
|
9
|
+
initValues?: any;
|
|
10
|
+
values?: any;
|
|
11
|
+
name: string;
|
|
12
|
+
prop: string;
|
|
13
|
+
disabled?: boolean | undefined;
|
|
14
|
+
size: 'mini' | 'small' | 'medium';
|
|
15
|
+
}>>> & {
|
|
16
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
17
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
|
|
18
|
+
$attrs: {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
$refs: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
$slots: Readonly<{
|
|
25
|
+
[name: string]: import("vue").Slot | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
28
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
29
|
+
$emit: (event: "change", ...args: any[]) => void;
|
|
30
|
+
$el: any;
|
|
31
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
32
|
+
config: TimeConfig;
|
|
33
|
+
model: any;
|
|
34
|
+
initValues?: any;
|
|
35
|
+
values?: any;
|
|
36
|
+
name: string;
|
|
37
|
+
prop: string;
|
|
38
|
+
disabled?: boolean | undefined;
|
|
39
|
+
size: 'mini' | 'small' | 'medium';
|
|
40
|
+
}>>> & {
|
|
41
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
42
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], string, {}> & {
|
|
43
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
44
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
45
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
46
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
47
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
48
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
49
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
50
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
51
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
52
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
53
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
54
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
55
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
56
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
57
|
+
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;
|
|
58
|
+
};
|
|
59
|
+
$forceUpdate: () => void;
|
|
60
|
+
$nextTick: typeof import("vue").nextTick;
|
|
61
|
+
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
62
|
+
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
63
|
+
config: TimeConfig;
|
|
64
|
+
model: any;
|
|
65
|
+
initValues?: any;
|
|
66
|
+
values?: any;
|
|
67
|
+
name: string;
|
|
68
|
+
prop: string;
|
|
69
|
+
disabled?: boolean | undefined;
|
|
70
|
+
size: 'mini' | 'small' | 'medium';
|
|
71
|
+
}>>> & {
|
|
72
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
} & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
|
|
74
|
+
__isFragment?: undefined;
|
|
75
|
+
__isTeleport?: undefined;
|
|
76
|
+
__isSuspense?: undefined;
|
|
77
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
78
|
+
config: TimeConfig;
|
|
79
|
+
model: any;
|
|
80
|
+
initValues?: any;
|
|
81
|
+
values?: any;
|
|
54
82
|
name: string;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
83
|
+
prop: string;
|
|
84
|
+
disabled?: boolean | undefined;
|
|
85
|
+
size: 'mini' | 'small' | 'medium';
|
|
86
|
+
}>>> & {
|
|
87
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
88
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
58
89
|
export default _default;
|
|
90
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
91
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
92
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
93
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
94
|
+
} : {
|
|
95
|
+
type: import('vue').PropType<T[K]>;
|
|
96
|
+
required: true;
|
|
97
|
+
};
|
|
98
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import './theme/index.scss';
|
|
|
3
3
|
export * from './schema';
|
|
4
4
|
export * from './utils/form';
|
|
5
5
|
export * from './utils/useAddField';
|
|
6
|
-
export { default as fieldProps } from './utils/fieldProps';
|
|
7
6
|
export { default as MForm } from './Form.vue';
|
|
8
7
|
export { default as MFormDialog } from './FormDialog.vue';
|
|
9
8
|
export { default as MContainer } from './containers/Container.vue';
|
package/types/schema.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface ValidateError {
|
|
2
|
+
message: string;
|
|
3
|
+
field: string;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* 整个表单的数据,会注入到各个组件中去
|
|
3
7
|
*/
|
|
@@ -121,7 +125,7 @@ declare type DefaultValueFunction = (mForm: FormState | undefined) => any;
|
|
|
121
125
|
/**
|
|
122
126
|
* 下拉选择器选项配置
|
|
123
127
|
*/
|
|
124
|
-
export interface
|
|
128
|
+
export interface SelectConfigOption {
|
|
125
129
|
/** 选项的标签 */
|
|
126
130
|
text: string | SelectOptionTextFunction;
|
|
127
131
|
/** 选项的值 */
|
|
@@ -129,10 +133,18 @@ export interface SelectOption {
|
|
|
129
133
|
/** 是否禁用该选项 */
|
|
130
134
|
disabled?: boolean;
|
|
131
135
|
}
|
|
136
|
+
export interface SelectOption {
|
|
137
|
+
/** 选项的标签 */
|
|
138
|
+
text: string;
|
|
139
|
+
/** 选项的值 */
|
|
140
|
+
value: any;
|
|
141
|
+
/** 是否禁用该选项 */
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
}
|
|
132
144
|
/**
|
|
133
145
|
* 下拉选择器分组选项配置
|
|
134
146
|
*/
|
|
135
|
-
export interface
|
|
147
|
+
export interface SelectConfigGroupOption {
|
|
136
148
|
/** 分组的组名 */
|
|
137
149
|
label: string;
|
|
138
150
|
/** 是否禁用该选项组 */
|
|
@@ -146,6 +158,21 @@ export interface SelectGroupOption {
|
|
|
146
158
|
disabled?: boolean;
|
|
147
159
|
}[];
|
|
148
160
|
}
|
|
161
|
+
export interface SelectGroupOption {
|
|
162
|
+
/** 分组的组名 */
|
|
163
|
+
label: string;
|
|
164
|
+
/** 是否禁用该选项组 */
|
|
165
|
+
disabled: boolean;
|
|
166
|
+
options: {
|
|
167
|
+
/** 选项的标签 */
|
|
168
|
+
label?: string;
|
|
169
|
+
text?: string;
|
|
170
|
+
/** 选项的值 */
|
|
171
|
+
value: any;
|
|
172
|
+
/** 是否禁用该选项 */
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
}[];
|
|
175
|
+
}
|
|
149
176
|
declare type SelectOptionFunction = (mForm: FormState | undefined, data: {
|
|
150
177
|
model: any;
|
|
151
178
|
prop?: string;
|
|
@@ -165,10 +192,10 @@ declare type RemoteSelectOptionRequestFunction = (mForm: FormState | undefined,
|
|
|
165
192
|
formValues: any;
|
|
166
193
|
config: any;
|
|
167
194
|
}) => any;
|
|
168
|
-
declare type RemoteSelectOptionItemFunction = (optionsData: Record<string, any>) => SelectOption[];
|
|
195
|
+
declare type RemoteSelectOptionItemFunction = (optionsData: Record<string, any>) => SelectOption[] | SelectGroupOption[];
|
|
169
196
|
declare type SelectOptionValueFunction = (item: Record<string, any>) => any;
|
|
170
197
|
declare type SelectOptionTextFunction = (item: Record<string, any>) => string;
|
|
171
|
-
interface CascaderOption {
|
|
198
|
+
export interface CascaderOption {
|
|
172
199
|
/** 指定选项的值为选项对象的某个属性值 */
|
|
173
200
|
value: any;
|
|
174
201
|
/** 指定选项标签为选项对象的某个属性值 */
|
|
@@ -229,7 +256,7 @@ export interface NumberConfig extends FormItem {
|
|
|
229
256
|
min?: number;
|
|
230
257
|
max?: number;
|
|
231
258
|
step?: number;
|
|
232
|
-
placeholder?:
|
|
259
|
+
placeholder?: string;
|
|
233
260
|
}
|
|
234
261
|
/**
|
|
235
262
|
* 隐藏域
|
|
@@ -243,6 +270,7 @@ export interface HiddenConfig extends FormItem {
|
|
|
243
270
|
export interface DateConfig extends FormItem, Input {
|
|
244
271
|
type: 'date';
|
|
245
272
|
format?: 'YYYY-MM-dd HH:mm:ss' | string;
|
|
273
|
+
valueFormat?: 'YYYY-MM-dd HH:mm:ss' | string;
|
|
246
274
|
}
|
|
247
275
|
/**
|
|
248
276
|
* 日期时间选择器
|
|
@@ -258,6 +286,8 @@ export interface DateTimeConfig extends FormItem, Input {
|
|
|
258
286
|
*/
|
|
259
287
|
export interface TimeConfig extends FormItem, Input {
|
|
260
288
|
type: 'time';
|
|
289
|
+
format?: 'HH:mm:ss' | string;
|
|
290
|
+
valueFormat?: 'HH:mm:ss' | string;
|
|
261
291
|
}
|
|
262
292
|
/**
|
|
263
293
|
* 单个多选框
|
|
@@ -281,7 +311,7 @@ export interface SwitchConfig extends FormItem {
|
|
|
281
311
|
export interface RadioGroupConfig extends FormItem {
|
|
282
312
|
type: 'radio-group';
|
|
283
313
|
options: {
|
|
284
|
-
|
|
314
|
+
value: string | number | boolean;
|
|
285
315
|
text: string;
|
|
286
316
|
}[];
|
|
287
317
|
}
|
|
@@ -299,7 +329,8 @@ export interface CheckboxGroupConfig extends FormItem {
|
|
|
299
329
|
options: {
|
|
300
330
|
value: any;
|
|
301
331
|
text: string;
|
|
302
|
-
|
|
332
|
+
disabled?: boolean;
|
|
333
|
+
}[] | Function;
|
|
303
334
|
}
|
|
304
335
|
/**
|
|
305
336
|
* 下拉选择器
|
|
@@ -311,7 +342,7 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
311
342
|
valueKey?: string;
|
|
312
343
|
allowCreate?: boolean;
|
|
313
344
|
group?: boolean;
|
|
314
|
-
options:
|
|
345
|
+
options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
315
346
|
remote: true;
|
|
316
347
|
option: {
|
|
317
348
|
url: string;
|
|
@@ -416,7 +447,7 @@ export interface TabPaneConfig {
|
|
|
416
447
|
}
|
|
417
448
|
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
|
418
449
|
type: 'tab' | 'dynamic-tab';
|
|
419
|
-
tabType?:
|
|
450
|
+
tabType?: string;
|
|
420
451
|
editable?: boolean;
|
|
421
452
|
dynamic?: boolean;
|
|
422
453
|
tabPosition?: 'top' | 'right' | 'bottom' | 'left';
|
|
@@ -469,6 +500,7 @@ export interface TableConfig extends FormItem {
|
|
|
469
500
|
border?: boolean;
|
|
470
501
|
/** 显示行号 */
|
|
471
502
|
showIndex?: boolean;
|
|
503
|
+
pagination?: boolean;
|
|
472
504
|
enum?: any[];
|
|
473
505
|
/** 是否显示添加按钮 */
|
|
474
506
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
@@ -488,6 +520,7 @@ export interface TableConfig extends FormItem {
|
|
|
488
520
|
enableFullscreen?: boolean;
|
|
489
521
|
fixed?: boolean;
|
|
490
522
|
itemExtra?: string | FilterFunction;
|
|
523
|
+
rowKey: string;
|
|
491
524
|
}
|
|
492
525
|
export interface GroupListConfig extends FormItem {
|
|
493
526
|
type: 'table' | 'groupList' | 'group-list';
|
package/types/utils/form.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormConfig, FormState, FormValue, Rule } from '../schema';
|
|
1
|
+
import { FormConfig, FormState, FormValue, Rule, TabPaneConfig } from '../schema';
|
|
2
|
+
export declare const createValues: (mForm: FormState | undefined, config?: FormConfig | TabPaneConfig[], initValue?: FormValue, value?: FormValue) => FormValue;
|
|
2
3
|
export declare const filterFunction: (mForm: FormState | undefined, config: any, props: any) => any;
|
|
3
4
|
export declare const display: (mForm: FormState | undefined, config: any, props: any) => any;
|
|
4
5
|
export declare const getRules: (mForm: FormState | undefined, rules: Rule | Rule[] | undefined, props: any) => Rule[];
|