@tmagic/form 1.0.0-beta.4 → 1.0.0-beta.8
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/LICENSE +5432 -0
- package/dist/tmagic-form.es.js +15 -4
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +15 -4
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/schema.d.ts +1 -0
- package/package.json +5 -4
- package/src/Form.vue +5 -0
- package/src/containers/Container.vue +9 -4
- package/src/fields/Select.vue +2 -0
- package/src/schema.ts +1 -0
- package/dist/types/src/Form.vue.d.ts +0 -301
- package/dist/types/src/FormDialog.vue.d.ts +0 -638
- package/dist/types/src/containers/Table.vue.d.ts +0 -1403
- package/dist/types/src/fields/Cascader.vue.d.ts +0 -1748
- package/dist/types/src/fields/Link.vue.d.ts +0 -1358
- package/dist/types/src/fields/Select.vue.d.ts +0 -975
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-beta.
|
|
2
|
+
"version": "1.0.0-beta.8",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "dist/tmagic-form.umd.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@element-plus/icons": "0.0.11",
|
|
31
|
-
"@tmagic/utils": "^1.0.0-beta.
|
|
32
|
-
"element-plus": "^2.
|
|
31
|
+
"@tmagic/utils": "^1.0.0-beta.8",
|
|
32
|
+
"element-plus": "^2.1.7",
|
|
33
33
|
"lodash-es": "^4.17.21",
|
|
34
34
|
"moment": "^2.29.1",
|
|
35
35
|
"sortablejs": "^1.14.0",
|
|
@@ -48,5 +48,6 @@
|
|
|
48
48
|
"vite": "^2.3.7",
|
|
49
49
|
"vite-plugin-dts": "^0.9.6",
|
|
50
50
|
"vue-tsc": "^0.0.24"
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "ff8e32901775ecc145a82f906d6af6119652d61e"
|
|
52
53
|
}
|
package/src/Form.vue
CHANGED
|
@@ -103,6 +103,10 @@ export default defineComponent({
|
|
|
103
103
|
type: String,
|
|
104
104
|
default: '__key',
|
|
105
105
|
},
|
|
106
|
+
|
|
107
|
+
popperClass: {
|
|
108
|
+
type: String,
|
|
109
|
+
},
|
|
106
110
|
},
|
|
107
111
|
|
|
108
112
|
emits: ['change', 'field-input', 'field-change'],
|
|
@@ -117,6 +121,7 @@ export default defineComponent({
|
|
|
117
121
|
|
|
118
122
|
const formState: FormState = reactive<FormState>({
|
|
119
123
|
keyProp: props.keyProp,
|
|
124
|
+
popperClass: props.popperClass,
|
|
120
125
|
config: props.config,
|
|
121
126
|
initValues: props.initValues,
|
|
122
127
|
parentValues: props.parentValues,
|
|
@@ -224,10 +224,15 @@ export default defineComponent({
|
|
|
224
224
|
|
|
225
225
|
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
226
226
|
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
227
|
-
let value: FormValue | number | string =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
let value: FormValue | number | string = v;
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
value = filterHandler(filter, v);
|
|
231
|
+
value = (await changeHandler(onChange, value)) ?? value;
|
|
232
|
+
value = trimHandler(trim, value) ?? value;
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.error(e);
|
|
235
|
+
}
|
|
231
236
|
|
|
232
237
|
// field内容下包含field-link时,model===value, 这里避免循环引用
|
|
233
238
|
if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
|
package/src/fields/Select.vue
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
ref="select"
|
|
8
8
|
clearable
|
|
9
9
|
filterable
|
|
10
|
+
:popper-class="`m-select-popper ${popperClass}`"
|
|
10
11
|
:size="size"
|
|
11
12
|
:remote="remote"
|
|
12
13
|
:placeholder="config.placeholder"
|
|
@@ -346,6 +347,7 @@ export default defineComponent({
|
|
|
346
347
|
remote,
|
|
347
348
|
options,
|
|
348
349
|
moreLoadingVisible,
|
|
350
|
+
popperClass: mForm?.popperClass,
|
|
349
351
|
|
|
350
352
|
getRequestFuc() {
|
|
351
353
|
return getConfig('request');
|
package/src/schema.ts
CHANGED
|
@@ -1,301 +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
|
-
};
|
|
47
|
-
inline: {
|
|
48
|
-
type: BooleanConstructor;
|
|
49
|
-
default: boolean;
|
|
50
|
-
};
|
|
51
|
-
labelPosition: {
|
|
52
|
-
type: StringConstructor;
|
|
53
|
-
default: string;
|
|
54
|
-
};
|
|
55
|
-
keyProp: {
|
|
56
|
-
type: StringConstructor;
|
|
57
|
-
default: string;
|
|
58
|
-
};
|
|
59
|
-
}, {
|
|
60
|
-
initialized: Ref<boolean>;
|
|
61
|
-
values: Ref<{
|
|
62
|
-
[x: string]: any;
|
|
63
|
-
[x: number]: any;
|
|
64
|
-
}>;
|
|
65
|
-
elForm: Ref<({
|
|
66
|
-
$: ComponentInternalInstance;
|
|
67
|
-
$data: {};
|
|
68
|
-
$props: Partial<{
|
|
69
|
-
disabled: boolean;
|
|
70
|
-
inline: boolean;
|
|
71
|
-
labelWidth: string | number;
|
|
72
|
-
labelSuffix: string;
|
|
73
|
-
inlineMessage: boolean;
|
|
74
|
-
statusIcon: boolean;
|
|
75
|
-
showMessage: boolean;
|
|
76
|
-
validateOnRuleChange: boolean;
|
|
77
|
-
hideRequiredAsterisk: boolean;
|
|
78
|
-
scrollToError: boolean;
|
|
79
|
-
}> & Omit<Readonly<ExtractPropTypes<{
|
|
80
|
-
model: ObjectConstructor;
|
|
81
|
-
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
82
|
-
labelPosition: StringConstructor;
|
|
83
|
-
labelWidth: {
|
|
84
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
85
|
-
default: string;
|
|
86
|
-
};
|
|
87
|
-
labelSuffix: {
|
|
88
|
-
type: StringConstructor;
|
|
89
|
-
default: string;
|
|
90
|
-
};
|
|
91
|
-
inline: BooleanConstructor;
|
|
92
|
-
inlineMessage: BooleanConstructor;
|
|
93
|
-
statusIcon: BooleanConstructor;
|
|
94
|
-
showMessage: {
|
|
95
|
-
type: BooleanConstructor;
|
|
96
|
-
default: boolean;
|
|
97
|
-
};
|
|
98
|
-
size: PropType<"small" | "default" | "large">;
|
|
99
|
-
disabled: BooleanConstructor;
|
|
100
|
-
validateOnRuleChange: {
|
|
101
|
-
type: BooleanConstructor;
|
|
102
|
-
default: boolean;
|
|
103
|
-
};
|
|
104
|
-
hideRequiredAsterisk: {
|
|
105
|
-
type: BooleanConstructor;
|
|
106
|
-
default: boolean;
|
|
107
|
-
};
|
|
108
|
-
scrollToError: BooleanConstructor;
|
|
109
|
-
}>> & {
|
|
110
|
-
onValidate?: ((...args: any[]) => any) | undefined;
|
|
111
|
-
} & VNodeProps & AllowedComponentProps & ComponentCustomProps, "labelWidth" | "disabled" | "inline" | "labelSuffix" | "inlineMessage" | "statusIcon" | "showMessage" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError">;
|
|
112
|
-
$attrs: {
|
|
113
|
-
[x: string]: unknown;
|
|
114
|
-
};
|
|
115
|
-
$refs: {
|
|
116
|
-
[x: string]: unknown;
|
|
117
|
-
};
|
|
118
|
-
$slots: Readonly<{
|
|
119
|
-
[name: string]: Slot | undefined;
|
|
120
|
-
}>;
|
|
121
|
-
$root: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
122
|
-
$parent: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
123
|
-
$emit: (event: "validate", ...args: any[]) => void;
|
|
124
|
-
$el: any;
|
|
125
|
-
$options: ComponentOptionsBase<Readonly<ExtractPropTypes<{
|
|
126
|
-
model: ObjectConstructor;
|
|
127
|
-
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
128
|
-
labelPosition: StringConstructor;
|
|
129
|
-
labelWidth: {
|
|
130
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
131
|
-
default: string;
|
|
132
|
-
};
|
|
133
|
-
labelSuffix: {
|
|
134
|
-
type: StringConstructor;
|
|
135
|
-
default: string;
|
|
136
|
-
};
|
|
137
|
-
inline: BooleanConstructor;
|
|
138
|
-
inlineMessage: BooleanConstructor;
|
|
139
|
-
statusIcon: BooleanConstructor;
|
|
140
|
-
showMessage: {
|
|
141
|
-
type: BooleanConstructor;
|
|
142
|
-
default: boolean;
|
|
143
|
-
};
|
|
144
|
-
size: PropType<"small" | "default" | "large">;
|
|
145
|
-
disabled: BooleanConstructor;
|
|
146
|
-
validateOnRuleChange: {
|
|
147
|
-
type: BooleanConstructor;
|
|
148
|
-
default: boolean;
|
|
149
|
-
};
|
|
150
|
-
hideRequiredAsterisk: {
|
|
151
|
-
type: BooleanConstructor;
|
|
152
|
-
default: boolean;
|
|
153
|
-
};
|
|
154
|
-
scrollToError: BooleanConstructor;
|
|
155
|
-
}>> & {
|
|
156
|
-
onValidate?: ((...args: any[]) => any) | undefined;
|
|
157
|
-
}, {
|
|
158
|
-
formKls: ComputedRef<string[]>;
|
|
159
|
-
validate: (callback?: Callback | undefined) => Promise<boolean> | undefined;
|
|
160
|
-
resetFields: () => void;
|
|
161
|
-
clearValidate: (props?: string | string[] | undefined) => void;
|
|
162
|
-
validateField: (props: string | string[], cb: ValidateFieldCallback) => void;
|
|
163
|
-
scrollToField: (prop: string) => void;
|
|
164
|
-
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "validate"[], string, {
|
|
165
|
-
disabled: boolean;
|
|
166
|
-
inline: boolean;
|
|
167
|
-
labelWidth: string | number;
|
|
168
|
-
labelSuffix: string;
|
|
169
|
-
inlineMessage: boolean;
|
|
170
|
-
statusIcon: boolean;
|
|
171
|
-
showMessage: boolean;
|
|
172
|
-
validateOnRuleChange: boolean;
|
|
173
|
-
hideRequiredAsterisk: boolean;
|
|
174
|
-
scrollToError: boolean;
|
|
175
|
-
}> & {
|
|
176
|
-
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
177
|
-
created?: ((() => void) | (() => void)[]) | undefined;
|
|
178
|
-
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
179
|
-
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
180
|
-
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
181
|
-
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
182
|
-
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
183
|
-
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
184
|
-
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
185
|
-
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
186
|
-
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
187
|
-
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
188
|
-
renderTracked?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
|
|
189
|
-
renderTriggered?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
|
|
190
|
-
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;
|
|
191
|
-
};
|
|
192
|
-
$forceUpdate: () => void;
|
|
193
|
-
$nextTick: typeof nextTick;
|
|
194
|
-
$watch(source: string | Function, cb: Function, options?: WatchOptions<boolean> | undefined): WatchStopHandle;
|
|
195
|
-
} & Readonly<ExtractPropTypes<{
|
|
196
|
-
model: ObjectConstructor;
|
|
197
|
-
rules: PropType<Partial<Record<string, FormItemRule | FormItemRule[]>>>;
|
|
198
|
-
labelPosition: StringConstructor;
|
|
199
|
-
labelWidth: {
|
|
200
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
201
|
-
default: string;
|
|
202
|
-
};
|
|
203
|
-
labelSuffix: {
|
|
204
|
-
type: StringConstructor;
|
|
205
|
-
default: string;
|
|
206
|
-
};
|
|
207
|
-
inline: BooleanConstructor;
|
|
208
|
-
inlineMessage: BooleanConstructor;
|
|
209
|
-
statusIcon: BooleanConstructor;
|
|
210
|
-
showMessage: {
|
|
211
|
-
type: BooleanConstructor;
|
|
212
|
-
default: boolean;
|
|
213
|
-
};
|
|
214
|
-
size: PropType<"small" | "default" | "large">;
|
|
215
|
-
disabled: BooleanConstructor;
|
|
216
|
-
validateOnRuleChange: {
|
|
217
|
-
type: BooleanConstructor;
|
|
218
|
-
default: boolean;
|
|
219
|
-
};
|
|
220
|
-
hideRequiredAsterisk: {
|
|
221
|
-
type: BooleanConstructor;
|
|
222
|
-
default: boolean;
|
|
223
|
-
};
|
|
224
|
-
scrollToError: BooleanConstructor;
|
|
225
|
-
}>> & {
|
|
226
|
-
onValidate?: ((...args: any[]) => any) | undefined;
|
|
227
|
-
} & ShallowUnwrapRef<{
|
|
228
|
-
formKls: ComputedRef<string[]>;
|
|
229
|
-
validate: (callback?: Callback | undefined) => Promise<boolean> | undefined;
|
|
230
|
-
resetFields: () => void;
|
|
231
|
-
clearValidate: (props?: string | string[] | undefined) => void;
|
|
232
|
-
validateField: (props: string | string[], cb: ValidateFieldCallback) => void;
|
|
233
|
-
scrollToField: (prop: string) => void;
|
|
234
|
-
}> & {} & {} & ComponentCustomProperties) | undefined>;
|
|
235
|
-
formState: FormState;
|
|
236
|
-
changeHandler: () => void;
|
|
237
|
-
resetForm: () => void | undefined;
|
|
238
|
-
submitForm: (native?: boolean | undefined) => Promise<any>;
|
|
239
|
-
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "field-input" | "field-change")[], "change" | "field-input" | "field-change", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
240
|
-
initValues: {
|
|
241
|
-
type: ObjectConstructor;
|
|
242
|
-
required: true;
|
|
243
|
-
default: () => {};
|
|
244
|
-
};
|
|
245
|
-
parentValues: {
|
|
246
|
-
type: ObjectConstructor;
|
|
247
|
-
default: () => {};
|
|
248
|
-
};
|
|
249
|
-
config: {
|
|
250
|
-
type: PropType<FormConfig>;
|
|
251
|
-
required: true;
|
|
252
|
-
default: () => never[];
|
|
253
|
-
};
|
|
254
|
-
labelWidth: {
|
|
255
|
-
type: StringConstructor;
|
|
256
|
-
default: () => string;
|
|
257
|
-
};
|
|
258
|
-
disabled: {
|
|
259
|
-
type: BooleanConstructor;
|
|
260
|
-
default: () => boolean;
|
|
261
|
-
};
|
|
262
|
-
height: {
|
|
263
|
-
type: StringConstructor;
|
|
264
|
-
default: () => string;
|
|
265
|
-
};
|
|
266
|
-
stepActive: {
|
|
267
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
268
|
-
default: () => number;
|
|
269
|
-
};
|
|
270
|
-
size: {
|
|
271
|
-
type: StringConstructor;
|
|
272
|
-
};
|
|
273
|
-
inline: {
|
|
274
|
-
type: BooleanConstructor;
|
|
275
|
-
default: boolean;
|
|
276
|
-
};
|
|
277
|
-
labelPosition: {
|
|
278
|
-
type: StringConstructor;
|
|
279
|
-
default: string;
|
|
280
|
-
};
|
|
281
|
-
keyProp: {
|
|
282
|
-
type: StringConstructor;
|
|
283
|
-
default: string;
|
|
284
|
-
};
|
|
285
|
-
}>> & {
|
|
286
|
-
onChange?: ((...args: any[]) => any) | undefined;
|
|
287
|
-
"onField-input"?: ((...args: any[]) => any) | undefined;
|
|
288
|
-
"onField-change"?: ((...args: any[]) => any) | undefined;
|
|
289
|
-
}, {
|
|
290
|
-
initValues: Record<string, any>;
|
|
291
|
-
parentValues: Record<string, any>;
|
|
292
|
-
config: FormConfig;
|
|
293
|
-
labelWidth: string;
|
|
294
|
-
disabled: boolean;
|
|
295
|
-
height: string;
|
|
296
|
-
stepActive: string | number;
|
|
297
|
-
inline: boolean;
|
|
298
|
-
labelPosition: string;
|
|
299
|
-
keyProp: string;
|
|
300
|
-
}>;
|
|
301
|
-
export default _default;
|