@tmagic/form 1.8.0-manmanyu.27 → 1.8.0-manmanyu.28
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/es/Form.vue_vue_type_script_setup_true_lang.js +50 -11
- package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +6 -2
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +7 -2
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +19 -13
- package/dist/es/containers/table/Table.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/es/index.js +5 -4
- package/dist/es/plugin.js +2 -0
- package/dist/es/schema.js +2 -1
- package/dist/es/style.css +6 -2
- package/dist/es/submitForm.js +374 -142
- package/dist/es/utils/form.js +45 -5
- package/dist/es/utils/typeMatch.js +408 -0
- package/dist/style.css +6 -2
- package/dist/themes/magic-admin.css +6 -2
- package/dist/tmagic-form.umd.cjs +2563 -1720
- package/package.json +5 -5
- package/src/Form.vue +75 -13
- package/src/FormBox.vue +3 -0
- package/src/FormDialog.vue +3 -0
- package/src/FormDrawer.vue +3 -0
- package/src/containers/Container.vue +7 -3
- package/src/fields/RadioGroup.vue +3 -0
- package/src/index.ts +11 -0
- package/src/plugin.ts +9 -0
- package/src/schema.ts +2 -1
- package/src/submitForm.ts +574 -197
- package/src/theme/form-dialog.scss +1 -1
- package/src/theme/table.scss +11 -1
- package/src/utils/form.ts +93 -22
- package/src/utils/typeMatch.ts +757 -0
- package/types/index.d.ts +180 -17
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FORM_DIFF_CONFIG_KEY } from "./schema.js";
|
|
1
|
+
import { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY } from "./schema.js";
|
|
2
2
|
import { getConfig } from "./utils/config.js";
|
|
3
3
|
import { initValue } from "./utils/form.js";
|
|
4
4
|
import Container_default from "./containers/Container.js";
|
|
5
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createSlots, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, provide, reactive, ref, renderList, renderSlot, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
5
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createSlots, defineComponent, inject, mergeProps, nextTick, normalizeClass, normalizeStyle, openBlock, provide, reactive, ref, renderList, renderSlot, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
6
6
|
import { cloneDeep, isEqual } from "lodash-es";
|
|
7
7
|
import { M_THEME_KEY, TMagicForm, tMagicMessage, tMagicMessageBox } from "@tmagic/design";
|
|
8
8
|
import { setValueByKeyPath } from "@tmagic/utils";
|
|
@@ -20,6 +20,7 @@ var Form_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
20
20
|
},
|
|
21
21
|
parentValues: { default: () => ({}) },
|
|
22
22
|
labelWidth: { default: "200px" },
|
|
23
|
+
typeMatchValid: { type: Boolean },
|
|
23
24
|
disabled: {
|
|
24
25
|
type: Boolean,
|
|
25
26
|
default: false
|
|
@@ -54,6 +55,7 @@ var Form_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
54
55
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
55
56
|
const props = __props;
|
|
56
57
|
const emit = __emit;
|
|
58
|
+
provide(FORM_TYPE_MATCH_VALID_KEY, computed(() => props.typeMatchValid));
|
|
57
59
|
const tMagicFormRef = useTemplateRef("tMagicForm");
|
|
58
60
|
const initialized = ref(false);
|
|
59
61
|
const values = ref({});
|
|
@@ -210,6 +212,9 @@ var Form_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
210
212
|
}).then((value) => {
|
|
211
213
|
values.value = value;
|
|
212
214
|
initialized.value = !props.isCompare;
|
|
215
|
+
nextTick(() => {
|
|
216
|
+
tMagicFormRef.value?.validate();
|
|
217
|
+
});
|
|
213
218
|
});
|
|
214
219
|
if (props.isCompare) initValue(formState, {
|
|
215
220
|
initValues: props.lastValues,
|
|
@@ -261,6 +266,23 @@ var Form_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
261
266
|
};
|
|
262
267
|
return findInConfig(config, nameParts);
|
|
263
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* 将校验返回的 invalidFields 汇总为可读的错误文案(多条以 `<br>` 拼接)。
|
|
271
|
+
*
|
|
272
|
+
* 抽离为独立方法,供 `submitForm`(提交校验)与 `validate`(返回错误文案的校验)复用,
|
|
273
|
+
* 保证两种校验入口产出的错误文案格式完全一致。
|
|
274
|
+
*/
|
|
275
|
+
const formatValidateError = (invalidFields) => {
|
|
276
|
+
const error = [];
|
|
277
|
+
Object.entries(invalidFields).forEach(([prop, validateError]) => {
|
|
278
|
+
validateError.forEach(({ field, message }) => {
|
|
279
|
+
const name = field || prop;
|
|
280
|
+
const text = (props.useFieldTextInError ? getTextByName(name, props.config) : void 0) || name;
|
|
281
|
+
error.push(`${text} -> ${message}`);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
return error.join("<br>");
|
|
285
|
+
};
|
|
264
286
|
__expose({
|
|
265
287
|
values,
|
|
266
288
|
lastValuesProcessed,
|
|
@@ -280,15 +302,32 @@ var Form_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
280
302
|
return native ? values.value : cloneDeep(toRaw(values.value));
|
|
281
303
|
} catch (invalidFields) {
|
|
282
304
|
emit("error", invalidFields);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
305
|
+
throw new Error(formatValidateError(invalidFields));
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
/**
|
|
309
|
+
* 校验:对表单当前值执行校验,返回汇总后的错误文案。
|
|
310
|
+
*
|
|
311
|
+
* 与 `submitForm` 的区别:
|
|
312
|
+
* - 校验失败时不抛异常、不触发 `error` 事件,而是以返回值形式给出错误文案;
|
|
313
|
+
* - 不重置 `changeRecords`,不改变提交语义,仅用于「探测」当前配置是否合法。
|
|
314
|
+
*
|
|
315
|
+
* 注意:本方法只改变「校验结果的返回方式」,并不负责「不污染页面表单状态」——
|
|
316
|
+
* 若需对一份独立的「配置 + 值」做完全不影响页面上已渲染表单的校验,请使用 `validateForm`
|
|
317
|
+
* (内部会新建一个隐藏的 MForm 实例,通过 `initValues` 传入待校验值,用完即卸载)。
|
|
318
|
+
*
|
|
319
|
+
* 典型用途:作为 `validateForm` 内部复用的校验实现;也可在已渲染的表单实例上主动调用,
|
|
320
|
+
* 根据返回的错误文案自行决定后续处理(如记录节点错误状态)。
|
|
321
|
+
*
|
|
322
|
+
* @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
|
|
323
|
+
*/
|
|
324
|
+
validate: async () => {
|
|
325
|
+
try {
|
|
326
|
+
const result = await tMagicFormRef.value?.validate();
|
|
327
|
+
if (result !== true) throw result;
|
|
328
|
+
return "";
|
|
329
|
+
} catch (invalidFields) {
|
|
330
|
+
return formatValidateError(invalidFields);
|
|
292
331
|
}
|
|
293
332
|
},
|
|
294
333
|
getTextByName
|
|
@@ -13,6 +13,7 @@ var FormBox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCo
|
|
|
13
13
|
width: {},
|
|
14
14
|
height: {},
|
|
15
15
|
labelWidth: {},
|
|
16
|
+
typeMatchValid: { type: Boolean },
|
|
16
17
|
disabled: { type: Boolean },
|
|
17
18
|
size: {},
|
|
18
19
|
confirmText: { default: "确定" },
|
|
@@ -49,7 +50,8 @@ var FormBox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCo
|
|
|
49
50
|
const submitHandler = async () => {
|
|
50
51
|
try {
|
|
51
52
|
const changeRecords = form.value?.changeRecords;
|
|
52
|
-
|
|
53
|
+
const values = await form.value?.submitForm();
|
|
54
|
+
emit("submit", values, { changeRecords });
|
|
53
55
|
} catch (e) {
|
|
54
56
|
emit("error", e);
|
|
55
57
|
}
|
|
@@ -87,6 +89,7 @@ var FormBox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCo
|
|
|
87
89
|
"prevent-submit-default": __props.preventSubmitDefault,
|
|
88
90
|
"use-field-text-in-error": __props.useFieldTextInError,
|
|
89
91
|
"extend-state": __props.extendState,
|
|
92
|
+
"type-match-valid": __props.typeMatchValid,
|
|
90
93
|
onChange: changeHandler
|
|
91
94
|
}, null, 8, [
|
|
92
95
|
"size",
|
|
@@ -99,7 +102,8 @@ var FormBox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCo
|
|
|
99
102
|
"inline",
|
|
100
103
|
"prevent-submit-default",
|
|
101
104
|
"use-field-text-in-error",
|
|
102
|
-
"extend-state"
|
|
105
|
+
"extend-state",
|
|
106
|
+
"type-match-valid"
|
|
103
107
|
]), renderSlot(_ctx.$slots, "default")]),
|
|
104
108
|
_: 3
|
|
105
109
|
})], 4), createElementVNode("div", {
|
|
@@ -12,6 +12,7 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
12
12
|
parentValues: {},
|
|
13
13
|
width: {},
|
|
14
14
|
labelWidth: {},
|
|
15
|
+
typeMatchValid: { type: Boolean },
|
|
15
16
|
fullscreen: { type: Boolean },
|
|
16
17
|
disabled: { type: Boolean },
|
|
17
18
|
title: {},
|
|
@@ -82,7 +83,8 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
82
83
|
const save = async () => {
|
|
83
84
|
try {
|
|
84
85
|
const changeRecords = [...form.value?.changeRecords || []];
|
|
85
|
-
|
|
86
|
+
const values = await form.value?.submitForm();
|
|
87
|
+
emit("submit", values, { changeRecords });
|
|
86
88
|
} catch (e) {
|
|
87
89
|
emit("error", e);
|
|
88
90
|
}
|
|
@@ -200,6 +202,7 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
200
202
|
inline: __props.inline,
|
|
201
203
|
"prevent-submit-default": __props.preventSubmitDefault,
|
|
202
204
|
"use-field-text-in-error": __props.useFieldTextInError,
|
|
205
|
+
"type-match-valid": __props.typeMatchValid,
|
|
203
206
|
"extend-state": __props.extendState,
|
|
204
207
|
theme: effectiveTheme.value,
|
|
205
208
|
onChange: changeHandler
|
|
@@ -215,6 +218,7 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
215
218
|
"inline",
|
|
216
219
|
"prevent-submit-default",
|
|
217
220
|
"use-field-text-in-error",
|
|
221
|
+
"type-match-valid",
|
|
218
222
|
"extend-state",
|
|
219
223
|
"theme"
|
|
220
224
|
]), renderSlot(_ctx.$slots, "default")], 4)) : createCommentVNode("v-if", true)]),
|
|
@@ -12,6 +12,7 @@ var FormDrawer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
12
12
|
parentValues: {},
|
|
13
13
|
width: {},
|
|
14
14
|
labelWidth: {},
|
|
15
|
+
typeMatchValid: { type: Boolean },
|
|
15
16
|
disabled: { type: Boolean },
|
|
16
17
|
closeOnPressEscape: {
|
|
17
18
|
type: Boolean,
|
|
@@ -59,7 +60,8 @@ var FormDrawer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
59
60
|
const submitHandler = async () => {
|
|
60
61
|
try {
|
|
61
62
|
const changeRecords = form.value?.changeRecords;
|
|
62
|
-
|
|
63
|
+
const values = await form.value?.submitForm();
|
|
64
|
+
emit("submit", values, { changeRecords });
|
|
63
65
|
} catch (e) {
|
|
64
66
|
emit("error", e);
|
|
65
67
|
}
|
|
@@ -98,7 +100,8 @@ var FormDrawer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
98
100
|
const save = async () => {
|
|
99
101
|
try {
|
|
100
102
|
const changeRecords = [...form.value?.changeRecords || []];
|
|
101
|
-
|
|
103
|
+
const values = await form.value?.submitForm();
|
|
104
|
+
emit("submit", values, { changeRecords });
|
|
102
105
|
} catch (e) {
|
|
103
106
|
emit("error", e);
|
|
104
107
|
}
|
|
@@ -176,6 +179,7 @@ var FormDrawer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
176
179
|
inline: __props.inline,
|
|
177
180
|
"prevent-submit-default": __props.preventSubmitDefault,
|
|
178
181
|
"use-field-text-in-error": __props.useFieldTextInError,
|
|
182
|
+
"type-match-valid": __props.typeMatchValid,
|
|
179
183
|
"extend-state": __props.extendState,
|
|
180
184
|
theme: effectiveTheme.value,
|
|
181
185
|
onChange: changeHandler
|
|
@@ -190,6 +194,7 @@ var FormDrawer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
190
194
|
"inline",
|
|
191
195
|
"prevent-submit-default",
|
|
192
196
|
"use-field-text-in-error",
|
|
197
|
+
"type-match-valid",
|
|
193
198
|
"extend-state",
|
|
194
199
|
"theme"
|
|
195
200
|
]), renderSlot(_ctx.$slots, "default")], 512)) : createCommentVNode("v-if", true)]),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FORM_DIFF_CONFIG_KEY } from "../schema.js";
|
|
1
|
+
import { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY } from "../schema.js";
|
|
2
2
|
import Hidden_default from "../fields/Hidden.js";
|
|
3
3
|
import { getField } from "../utils/config.js";
|
|
4
4
|
import { createObjectProp, display, filterFunction, getRules } from "../utils/form.js";
|
|
@@ -52,6 +52,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
52
52
|
const emit = __emit;
|
|
53
53
|
const mForm = inject("mForm");
|
|
54
54
|
const diffConfig = inject(FORM_DIFF_CONFIG_KEY, {});
|
|
55
|
+
const typeMatchValid = inject(FORM_TYPE_MATCH_VALID_KEY);
|
|
55
56
|
const expand = ref(false);
|
|
56
57
|
const name = computed(() => props.config.name || "");
|
|
57
58
|
const showDiff = computed(() => {
|
|
@@ -128,7 +129,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
128
129
|
placement: config?.placement || "top"
|
|
129
130
|
};
|
|
130
131
|
});
|
|
131
|
-
const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
132
|
+
const rule = computed(() => getRules(mForm, props.config.rules, props, typeMatchValid));
|
|
132
133
|
const display$1 = computed(() => {
|
|
133
134
|
const value = display(mForm, props.config.display, props);
|
|
134
135
|
if (value === "expand") return expand.value;
|
|
@@ -190,7 +191,10 @@ var Container_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
190
191
|
return new Proxy(target, {
|
|
191
192
|
get: (obj, key) => {
|
|
192
193
|
const value = obj[key];
|
|
193
|
-
if (value && typeof value === "object")
|
|
194
|
+
if (value && typeof value === "object") {
|
|
195
|
+
const newPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
196
|
+
return createModelProxy(value, setModelFn, newPath);
|
|
197
|
+
}
|
|
194
198
|
return value;
|
|
195
199
|
},
|
|
196
200
|
set: (obj, key, value) => {
|
|
@@ -256,16 +260,18 @@ var Container_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
256
260
|
"data-tmagic-form-item-prop": itemProp.value,
|
|
257
261
|
class: normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}${__props.config.tip ? " has-tip" : ""}`),
|
|
258
262
|
style: normalizeStyle(__props.config.style)
|
|
259
|
-
}, [type.value === "hidden" ? (openBlock(), createBlock(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
}, [type.value === "hidden" ? (openBlock(), createBlock(unref(TMagicFormItem), mergeProps({ key: 0 }, formItemProps.value, { style: { "display": "none" } }), {
|
|
264
|
+
default: withCtx(() => [createVNode(Hidden_default, {
|
|
265
|
+
name: `${name.value}`,
|
|
266
|
+
prop: itemProp.value,
|
|
267
|
+
model: __props.model
|
|
268
|
+
}, null, 8, [
|
|
269
|
+
"name",
|
|
270
|
+
"prop",
|
|
271
|
+
"model"
|
|
272
|
+
])]),
|
|
273
|
+
_: 1
|
|
274
|
+
}, 16)) : items.value && !text.value && type.value && display$1.value ? (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
|
|
269
275
|
model: __props.model,
|
|
270
276
|
"last-values": __props.lastValues,
|
|
271
277
|
"is-compare": __props.isCompare,
|
|
@@ -114,7 +114,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
114
114
|
}, 8, ["disabled"]),
|
|
115
115
|
renderSlot(_ctx.$slots, "default"),
|
|
116
116
|
createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [
|
|
117
|
-
!unref(isFullscreen) ? renderSlot(_ctx.$slots, "toggle-button", {
|
|
117
|
+
!unref(isFullscreen) ? renderSlot(_ctx.$slots, "toggle-button", {}, void 0, void 0, 0) : createCommentVNode("v-if", true),
|
|
118
118
|
__props.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
119
119
|
key: 1,
|
|
120
120
|
icon: unref(FullScreen),
|
|
@@ -155,7 +155,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
155
155
|
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("清空", -1)])]),
|
|
156
156
|
_: 1
|
|
157
157
|
}, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true)
|
|
158
|
-
]), !__props.isCompare ? renderSlot(_ctx.$slots, "add-button", {
|
|
158
|
+
]), !__props.isCompare ? renderSlot(_ctx.$slots, "add-button", {}, void 0, void 0, 0) : createCommentVNode("v-if", true)]),
|
|
159
159
|
__props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(unref(TMagicPagination), {
|
|
160
160
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
161
161
|
"hide-on-single-page": __props.model[modelName.value].length < unref(pageSize),
|
|
@@ -31,6 +31,7 @@ var RadioGroup_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
31
31
|
const itemComponent = computed(() => props.config.childType === "button" ? TMagicRadioButton : TMagicRadio);
|
|
32
32
|
const emit = __emit;
|
|
33
33
|
const clickHandler = (item) => {
|
|
34
|
+
if (props.disabled) return;
|
|
34
35
|
emit("change", props.model[props.name] === item ? "" : item);
|
|
35
36
|
};
|
|
36
37
|
useAddField(props.prop);
|
|
@@ -230,7 +230,8 @@ var Select_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
|
|
|
230
230
|
const v = props.model[props.name];
|
|
231
231
|
if (Array.isArray(v) ? !v.length : typeof v === "undefined") return;
|
|
232
232
|
if (typeof v === "undefined" || hasOption(v)) return;
|
|
233
|
-
|
|
233
|
+
const data = await getInitOption();
|
|
234
|
+
setOptions(data);
|
|
234
235
|
};
|
|
235
236
|
watch(() => props.model?.[props.name], () => {
|
|
236
237
|
initOption();
|
package/dist/es/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { FORM_DIFF_CONFIG_KEY } from "./schema.js";
|
|
2
|
+
import { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY } from "./schema.js";
|
|
3
3
|
import { useAddField } from "./utils/useAddField.js";
|
|
4
4
|
import Hidden_default from "./fields/Hidden.js";
|
|
5
5
|
import { deleteField, getField, registerField } from "./utils/config.js";
|
|
6
|
-
import {
|
|
6
|
+
import { clearTypeMatchRules, deleteTypeMatchRule, getTypeMatchRule, registerTypeMatchRule, registerTypeMatchRules, validateTypeMatch } from "./utils/typeMatch.js";
|
|
7
|
+
import { adaptFormValidator, createObjectProp, createValues, datetimeFormatter, display, filterFunction, getDataByPage, getRules, initValue, sortArray, sortChange } from "./utils/form.js";
|
|
7
8
|
import Container_default from "./containers/Container.js";
|
|
8
9
|
import Form_default from "./Form.js";
|
|
9
|
-
import { submitForm } from "./submitForm.js";
|
|
10
|
+
import { stripTabItemsLazy, submitForm, validateForm } from "./submitForm.js";
|
|
10
11
|
import FormDialog_default from "./FormDialog.js";
|
|
11
12
|
import FormDrawer_default from "./FormDrawer.js";
|
|
12
13
|
import FormBox_default from "./FormBox.js";
|
|
@@ -39,4 +40,4 @@ import plugin_default from "./plugin.js";
|
|
|
39
40
|
export * from "@tmagic/form-schema";
|
|
40
41
|
var createForm = (config) => config;
|
|
41
42
|
//#endregion
|
|
42
|
-
export { FORM_DIFF_CONFIG_KEY, Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer, TableGroupList_default as MGroupList, Hidden_default as MHidden, Link_default as MLink, Number_default as MNumber, NumberRange_default as MNumberRange, Panel_default as MPanel, RadioGroup_default as MRadioGroup, Row_default as MRow, Select_default as MSelect, Switch_default as MSwitch, TableGroupList_default as MTable, TableGroupList_default as MTableGroupList, Tabs_default as MTabs, Text_default as MText, Textarea_default as MTextarea, Time_default as MTime, Timerange_default as MTimerange, createForm, createObjectProp, createValues, datetimeFormatter, plugin_default as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, submitForm, useAddField };
|
|
43
|
+
export { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY, Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer, TableGroupList_default as MGroupList, Hidden_default as MHidden, Link_default as MLink, Number_default as MNumber, NumberRange_default as MNumberRange, Panel_default as MPanel, RadioGroup_default as MRadioGroup, Row_default as MRow, Select_default as MSelect, Switch_default as MSwitch, TableGroupList_default as MTable, TableGroupList_default as MTableGroupList, Tabs_default as MTabs, Text_default as MText, Textarea_default as MTextarea, Time_default as MTime, Timerange_default as MTimerange, adaptFormValidator, clearTypeMatchRules, createForm, createObjectProp, createValues, datetimeFormatter, plugin_default as default, deleteField as deleteFormField, deleteTypeMatchRule, display, filterFunction, getDataByPage, getField as getFormField, getRules, getTypeMatchRule, initValue, registerField as registerFormField, registerTypeMatchRule, registerTypeMatchRules, sortArray, sortChange, stripTabItemsLazy, submitForm, useAddField, validateForm, validateTypeMatch };
|
package/dist/es/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Hidden_default from "./fields/Hidden.js";
|
|
2
2
|
import { setConfig } from "./utils/config.js";
|
|
3
|
+
import { registerTypeMatchRules } from "./utils/typeMatch.js";
|
|
3
4
|
import Container_default from "./containers/Container.js";
|
|
4
5
|
import Form_default from "./Form.js";
|
|
5
6
|
import FormDialog_default from "./FormDialog.js";
|
|
@@ -37,6 +38,7 @@ var plugin_default = { install(app, opt = {}) {
|
|
|
37
38
|
const option = Object.assign(defaultInstallOpt, opt);
|
|
38
39
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
39
40
|
setConfig(option);
|
|
41
|
+
if (option.typeMatchRules) registerTypeMatchRules(option.typeMatchRules);
|
|
40
42
|
app.component("m-form", Form_default);
|
|
41
43
|
app.component("m-form-dialog", FormDialog_default);
|
|
42
44
|
app.component("m-form-drawer", FormDrawer_default);
|
package/dist/es/schema.js
CHANGED
|
@@ -2,5 +2,6 @@ import "./_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
export * from "@tmagic/form-schema";
|
|
3
3
|
//#region packages/form/src/schema.ts
|
|
4
4
|
var FORM_DIFF_CONFIG_KEY = Symbol("mFormDiffConfig");
|
|
5
|
+
var FORM_TYPE_MATCH_VALID_KEY = Symbol("mFormTypeMatchValid");
|
|
5
6
|
//#endregion
|
|
6
|
-
export { FORM_DIFF_CONFIG_KEY };
|
|
7
|
+
export { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY };
|
package/dist/es/style.css
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
.m-form-dialog .m-dialog-body {
|
|
27
27
|
padding: 0 20px;
|
|
28
28
|
}
|
|
29
|
-
.m-form-dialog .el-table .m-form-item .el-form-item {
|
|
29
|
+
.m-form-dialog .el-table .m-form-item .el-form-item:not(.is-error) {
|
|
30
30
|
margin-bottom: 0;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -345,6 +345,10 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
345
345
|
width: 95vw !important;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
.el-form-item .m-fields-table .el-form-item.is-error {
|
|
349
|
+
margin-bottom: 18px;
|
|
350
|
+
}
|
|
351
|
+
|
|
348
352
|
.m-fields-table {
|
|
349
353
|
width: 100%;
|
|
350
354
|
}
|
|
@@ -367,7 +371,7 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
367
371
|
.m-fields-table .el-table__expanded-cell .m-form-tip {
|
|
368
372
|
margin-left: 80px;
|
|
369
373
|
}
|
|
370
|
-
.m-fields-table .el-form-item {
|
|
374
|
+
.m-fields-table .el-form-item:not(.is-error) {
|
|
371
375
|
margin-bottom: 0;
|
|
372
376
|
}
|
|
373
377
|
.m-fields-table .tmagic-form-table-drag-target {
|