@tmagic/form 1.8.0-manmanyu.9 → 1.8.1
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 +88 -107
- package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +21 -5
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +21 -5
- package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +46 -12
- package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +6 -2
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +44 -47
- package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +7 -1
- package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +59 -22
- package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +118 -100
- package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +8 -3
- package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/es/containers/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/containers/table/SortColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/containers/table/Table.vue_vue_type_script_setup_true_lang.js +14 -10
- package/dist/es/containers/table/useTableColumns.js +10 -15
- package/dist/es/containers/table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js +72 -79
- package/dist/es/containers/table-group-list/useAdd.js +26 -16
- package/dist/es/containers/table-group-list/useScrollLastItemIntoView.js +72 -0
- package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/CheckboxGroup/Index.js +5 -0
- package/dist/es/fields/{CheckboxGroup.vue_vue_type_script_setup_true_lang.js → CheckboxGroup/Index.vue_vue_type_script_setup_true_lang.js} +6 -7
- package/dist/es/fields/CheckboxGroup/effect.js +8 -0
- package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/Date/Index.js +5 -0
- package/dist/es/fields/{Date.vue_vue_type_script_setup_true_lang.js → Date/Index.vue_vue_type_script_setup_true_lang.js} +5 -7
- package/dist/es/fields/Date/effect.js +10 -0
- package/dist/es/fields/DateTime/Index.js +5 -0
- package/dist/es/fields/{DateTime.vue_vue_type_script_setup_true_lang.js → DateTime/Index.vue_vue_type_script_setup_true_lang.js} +5 -9
- package/dist/es/fields/DateTime/effect.js +15 -0
- package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/Display/Index.js +5 -0
- package/dist/es/fields/{Display.vue_vue_type_script_setup_true_lang.js → Display/Index.vue_vue_type_script_setup_true_lang.js} +6 -7
- package/dist/es/fields/Display/effect.js +8 -0
- package/dist/es/fields/DynamicField/Index.js +5 -0
- package/dist/es/fields/{DynamicField.vue_vue_type_script_setup_true_lang.js → DynamicField/Index.vue_vue_type_script_setup_true_lang.js} +11 -15
- package/dist/es/fields/DynamicField/effect.js +40 -0
- package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/fields/NumberRange/Index.js +5 -0
- package/dist/es/fields/{NumberRange.vue_vue_type_script_setup_true_lang.js → NumberRange/Index.vue_vue_type_script_setup_true_lang.js} +5 -6
- package/dist/es/fields/NumberRange/effect.js +8 -0
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +14 -6
- package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +13 -10
- package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/es/headless.js +13 -0
- package/dist/es/index.js +19 -12
- package/dist/es/plugin.js +57 -39
- package/dist/es/schema.js +11 -2
- package/dist/es/style.css +123 -3
- package/dist/es/submitForm.js +270 -72
- package/dist/es/utils/builtInFields.js +49 -0
- package/dist/es/utils/collectFields.js +407 -0
- package/dist/es/utils/config.js +4 -8
- package/dist/es/utils/fieldInnerConfig.js +42 -0
- package/dist/es/utils/fieldValueEffects.js +80 -0
- package/dist/es/utils/form.js +154 -19
- package/dist/es/utils/formStateProxy.js +111 -0
- package/dist/es/utils/registerField.js +158 -0
- package/dist/es/utils/submitHeadless.js +54 -0
- package/dist/es/utils/tableGroupList.js +104 -0
- package/dist/es/utils/typeMatch.js +532 -0
- package/dist/es/utils/validateError.js +57 -0
- package/dist/es/utils/validateValues.js +115 -0
- package/dist/style.css +123 -3
- package/dist/themes/magic-admin.css +576 -14
- package/dist/tmagic-form-headless.umd.cjs +4515 -0
- package/dist/tmagic-form.umd.cjs +3444 -983
- package/package.json +16 -10
- package/src/Form.vue +113 -129
- package/src/FormBox.vue +16 -4
- package/src/FormDialog.vue +16 -5
- package/src/FormDrawer.vue +41 -13
- package/src/containers/Col.vue +3 -0
- package/src/containers/Container.vue +40 -45
- package/src/containers/Fieldset.vue +5 -0
- package/src/containers/FlexLayout.vue +2 -0
- package/src/containers/GroupList.vue +64 -13
- package/src/containers/GroupListItem.vue +88 -81
- package/src/containers/Panel.vue +3 -0
- package/src/containers/Row.vue +2 -0
- package/src/containers/Step.vue +2 -0
- package/src/containers/Tabs.vue +13 -0
- package/src/containers/table/ActionsColumn.vue +1 -1
- package/src/containers/table/Table.vue +5 -3
- package/src/containers/table/usePagination.ts +1 -1
- package/src/containers/table/useSortable.ts +1 -1
- package/src/containers/table/useTableColumns.ts +15 -22
- package/src/containers/table-group-list/TableGroupList.vue +46 -72
- package/src/containers/table-group-list/useAdd.ts +40 -25
- package/src/containers/table-group-list/useScrollLastItemIntoView.ts +94 -0
- package/src/fields/{CheckboxGroup.vue → CheckboxGroup/Index.vue} +3 -8
- package/src/fields/CheckboxGroup/effect.ts +27 -0
- package/src/fields/{Date.vue → Date/Index.vue} +2 -5
- package/src/fields/Date/effect.ts +29 -0
- package/src/fields/{DateTime.vue → DateTime/Index.vue} +2 -16
- package/src/fields/DateTime/effect.ts +36 -0
- package/src/fields/{Display.vue → Display/Index.vue} +3 -7
- package/src/fields/Display/effect.ts +28 -0
- package/src/fields/{DynamicField.vue → DynamicField/Index.vue} +11 -11
- package/src/fields/DynamicField/effect.ts +74 -0
- package/src/fields/Link.vue +3 -4
- package/src/fields/Number.vue +2 -1
- package/src/fields/{NumberRange.vue → NumberRange/Index.vue} +2 -6
- package/src/fields/NumberRange/effect.ts +27 -0
- package/src/fields/RadioGroup.vue +13 -1
- package/src/fields/Select.vue +13 -4
- package/src/headless.ts +78 -0
- package/src/index.ts +46 -9
- package/src/plugin.ts +68 -37
- package/src/schema.ts +13 -2
- package/src/submitForm.ts +410 -131
- package/src/theme/fieldset.scss +1 -0
- package/src/theme/form-box.scss +5 -0
- package/src/theme/form-dialog.scss +1 -1
- package/src/theme/group-list.scss +143 -2
- package/src/theme/table.scss +11 -1
- package/src/theme/themes/magic-admin/index.scss +27 -16
- package/src/utils/builtInFields.ts +69 -0
- package/src/utils/collectFields.ts +561 -0
- package/src/utils/config.ts +7 -15
- package/src/utils/fieldInnerConfig.ts +127 -0
- package/src/utils/fieldValueEffects.ts +140 -0
- package/src/utils/form.ts +230 -30
- package/src/utils/formStateProxy.ts +149 -0
- package/src/utils/registerField.ts +308 -0
- package/src/utils/submitHeadless.ts +206 -0
- package/src/utils/tableGroupList.ts +147 -0
- package/src/utils/typeMatch.ts +948 -0
- package/src/utils/validateError.ts +92 -0
- package/src/utils/validateValues.ts +177 -0
- package/types/headless.d.ts +682 -0
- package/types/index.d.ts +900 -180
- package/dist/es/_virtual/_rolldown/runtime.js +0 -27
- package/dist/es/fields/CheckboxGroup.js +0 -5
- package/dist/es/fields/Date.js +0 -5
- package/dist/es/fields/DateTime.js +0 -5
- package/dist/es/fields/Display.js +0 -5
- package/dist/es/fields/DynamicField.js +0 -5
- package/dist/es/fields/NumberRange.js +0 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { FORM_DIFF_CONFIG_KEY } from "../schema.js";
|
|
1
|
+
import { FORM_DIFF_CONFIG_KEY, FORM_TYPE_MATCH_VALID_KEY } from "../schema.js";
|
|
2
|
+
import { createObjectProp, display, filterFunction, getItemProp, getRules, isValidName, resolveItemType } from "../utils/form.js";
|
|
2
3
|
import Hidden_default from "../fields/Hidden.js";
|
|
3
|
-
import { getField } from "../utils/
|
|
4
|
-
import { createObjectProp, display, filterFunction, getRules } from "../utils/form.js";
|
|
4
|
+
import { getField } from "../utils/registerField.js";
|
|
5
5
|
import FormLabel_default from "./FormLabel.js";
|
|
6
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, readonly, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, provide, readonly, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
|
|
7
7
|
import { isEqual } from "lodash-es";
|
|
8
|
-
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from "@tmagic/design";
|
|
9
8
|
import { getValueByKeyPath } from "@tmagic/utils";
|
|
9
|
+
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from "@tmagic/design";
|
|
10
10
|
import { ArrowDown, ArrowUp, WarningFilled } from "@element-plus/icons-vue";
|
|
11
11
|
//#region packages/form/src/containers/Container.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var _hoisted_1 = ["data-tmagic-id", "data-tmagic-form-item-prop"];
|
|
@@ -25,7 +25,7 @@ var _hoisted_10 = {
|
|
|
25
25
|
key: 5,
|
|
26
26
|
class: "m-form-container-expand"
|
|
27
27
|
};
|
|
28
|
-
var Container_vue_vue_type_script_setup_true_lang_default =
|
|
28
|
+
var Container_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
29
29
|
name: "MFormContainer",
|
|
30
30
|
__name: "Container",
|
|
31
31
|
props: {
|
|
@@ -35,6 +35,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
35
35
|
prop: { default: "" },
|
|
36
36
|
disabled: { type: Boolean },
|
|
37
37
|
labelWidth: {},
|
|
38
|
+
labelPosition: {},
|
|
38
39
|
expandMore: {
|
|
39
40
|
type: Boolean,
|
|
40
41
|
default: false
|
|
@@ -44,7 +45,8 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
44
45
|
isCompare: {
|
|
45
46
|
type: Boolean,
|
|
46
47
|
default: false
|
|
47
|
-
}
|
|
48
|
+
},
|
|
49
|
+
isInRow: { type: Boolean }
|
|
48
50
|
},
|
|
49
51
|
emits: ["change", "addDiffCount"],
|
|
50
52
|
setup(__props, { emit: __emit }) {
|
|
@@ -52,6 +54,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
52
54
|
const emit = __emit;
|
|
53
55
|
const mForm = inject("mForm");
|
|
54
56
|
const diffConfig = inject(FORM_DIFF_CONFIG_KEY, {});
|
|
57
|
+
const typeMatchValid = inject(FORM_TYPE_MATCH_VALID_KEY);
|
|
55
58
|
const expand = ref(false);
|
|
56
59
|
const name = computed(() => props.config.name || "");
|
|
57
60
|
const showDiff = computed(() => {
|
|
@@ -68,20 +71,8 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
68
71
|
return !isEqual(curValue, lastValue);
|
|
69
72
|
});
|
|
70
73
|
const items = computed(() => props.config.items);
|
|
71
|
-
const itemProp = computed(() =>
|
|
72
|
-
|
|
73
|
-
if (name.value) n = name.value;
|
|
74
|
-
else return props.prop;
|
|
75
|
-
if (typeof props.prop !== "undefined" && props.prop !== "") return `${props.prop}.${n}`;
|
|
76
|
-
return `${n}`;
|
|
77
|
-
});
|
|
78
|
-
const type = computed(() => {
|
|
79
|
-
let type = "type" in props.config ? props.config.type : "";
|
|
80
|
-
type = type && filterFunction(mForm, type, props);
|
|
81
|
-
if (type === "form") return "";
|
|
82
|
-
if (type === "container") return "";
|
|
83
|
-
return type?.replace(/([A-Z])/g, "-$1").toLowerCase() || (items.value ? "" : "text");
|
|
84
|
-
});
|
|
74
|
+
const itemProp = computed(() => getItemProp(props.prop, name.value));
|
|
75
|
+
const type = computed(() => resolveItemType(mForm, props.config, props));
|
|
85
76
|
const tagName = computed(() => {
|
|
86
77
|
if (type.value === "component" && props.config.component) return props.config.component;
|
|
87
78
|
return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
|
|
@@ -111,7 +102,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
111
102
|
const effectiveSelfDiffFieldTypes = computed(() => {
|
|
112
103
|
const custom = diffConfig.selfDiffFieldTypes;
|
|
113
104
|
if (typeof custom === "function") return new Set(custom([...DEFAULT_SELF_DIFF_FIELD_TYPES]));
|
|
114
|
-
if (Array.isArray(custom)) return new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
|
|
105
|
+
if (Array.isArray(custom)) return /* @__PURE__ */ new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
|
|
115
106
|
return new Set(DEFAULT_SELF_DIFF_FIELD_TYPES);
|
|
116
107
|
});
|
|
117
108
|
const isSelfDiffField = computed(() => effectiveSelfDiffFieldTypes.value.has(type.value));
|
|
@@ -128,7 +119,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
128
119
|
placement: config?.placement || "top"
|
|
129
120
|
};
|
|
130
121
|
});
|
|
131
|
-
const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
122
|
+
const rule = computed(() => getRules(mForm, props.config.rules, props, typeMatchValid));
|
|
132
123
|
const display$1 = computed(() => {
|
|
133
124
|
const value = display(mForm, props.config.display, props);
|
|
134
125
|
if (value === "expand") return expand.value;
|
|
@@ -146,11 +137,13 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
146
137
|
const formItemProps = computed(() => ({
|
|
147
138
|
prop: itemProp.value,
|
|
148
139
|
labelWidth: itemLabelWidth.value,
|
|
149
|
-
labelPosition:
|
|
140
|
+
labelPosition: itemLabelPosition.value,
|
|
150
141
|
rules: rule.value,
|
|
151
|
-
extra: filterFunction(mForm, props.config.extra, props)
|
|
142
|
+
extra: filterFunction(mForm, props.config.extra, props),
|
|
143
|
+
extraTips: props.config.extraTips
|
|
152
144
|
}));
|
|
153
145
|
const itemLabelWidth = computed(() => props.config.labelWidth ?? props.labelWidth);
|
|
146
|
+
const itemLabelPosition = computed(() => props.config.labelPosition ?? props.labelPosition);
|
|
154
147
|
watchEffect(() => {
|
|
155
148
|
expand.value = props.expandMore;
|
|
156
149
|
});
|
|
@@ -159,6 +152,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
159
152
|
if (items.value && !text.value && type.value && display$1.value) return;
|
|
160
153
|
if (display$1.value && showDiff && type.value) emit("addDiffCount");
|
|
161
154
|
}, { immediate: true });
|
|
155
|
+
provide("isInRow", props.isInRow ?? false);
|
|
162
156
|
const expandHandler = () => expand.value = !expand.value;
|
|
163
157
|
const key = (config) => config[mForm?.keyProps];
|
|
164
158
|
const filterHandler = (filter, value) => {
|
|
@@ -178,18 +172,15 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
178
172
|
};
|
|
179
173
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
180
174
|
const hasModifyKey = (eventDataItem) => typeof eventDataItem?.modifyKey !== "undefined" && eventDataItem.modifyKey !== "";
|
|
181
|
-
const isValidName = () =>
|
|
182
|
-
const valueType = typeof name.value;
|
|
183
|
-
if (valueType !== "string" && valueType !== "symbol" && valueType !== "number") return false;
|
|
184
|
-
if (name.value === "") return false;
|
|
185
|
-
if (typeof name.value === "number") return name.value >= 0;
|
|
186
|
-
return true;
|
|
187
|
-
};
|
|
175
|
+
const isValidName$1 = () => isValidName(name.value);
|
|
188
176
|
const createModelProxy = (target, setModelFn, pathPrefix = "") => {
|
|
189
177
|
return new Proxy(target, {
|
|
190
178
|
get: (obj, key) => {
|
|
191
179
|
const value = obj[key];
|
|
192
|
-
if (value && typeof value === "object")
|
|
180
|
+
if (value && typeof value === "object") {
|
|
181
|
+
const newPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
182
|
+
return createModelProxy(value, setModelFn, newPath);
|
|
183
|
+
}
|
|
193
184
|
return value;
|
|
194
185
|
},
|
|
195
186
|
set: (obj, key, value) => {
|
|
@@ -255,22 +246,25 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
255
246
|
"data-tmagic-form-item-prop": itemProp.value,
|
|
256
247
|
class: normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}${__props.config.tip ? " has-tip" : ""}`),
|
|
257
248
|
style: normalizeStyle(__props.config.style)
|
|
258
|
-
}, [type.value === "hidden" ? (openBlock(), createBlock(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
249
|
+
}, [type.value === "hidden" ? (openBlock(), createBlock(unref(TMagicFormItem), mergeProps({ key: 0 }, formItemProps.value, { style: { "display": "none" } }), {
|
|
250
|
+
default: withCtx(() => [createVNode(Hidden_default, {
|
|
251
|
+
name: `${name.value}`,
|
|
252
|
+
prop: itemProp.value,
|
|
253
|
+
model: __props.model
|
|
254
|
+
}, null, 8, [
|
|
255
|
+
"name",
|
|
256
|
+
"prop",
|
|
257
|
+
"model"
|
|
258
|
+
])]),
|
|
259
|
+
_: 1
|
|
260
|
+
}, 16)) : items.value && !text.value && type.value && display$1.value ? (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
|
|
268
261
|
model: __props.model,
|
|
269
262
|
"last-values": __props.lastValues,
|
|
270
263
|
"is-compare": __props.isCompare,
|
|
271
264
|
"step-active": __props.stepActive,
|
|
272
265
|
"expand-more": expand.value,
|
|
273
266
|
"label-width": itemLabelWidth.value,
|
|
267
|
+
"label-position": itemLabelPosition.value,
|
|
274
268
|
style: __props.config.fieldStyle,
|
|
275
269
|
onChange: onChangeHandler,
|
|
276
270
|
onAddDiffCount
|
|
@@ -281,6 +275,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
281
275
|
"step-active",
|
|
282
276
|
"expand-more",
|
|
283
277
|
"label-width",
|
|
278
|
+
"label-position",
|
|
284
279
|
"style"
|
|
285
280
|
])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value } }), {
|
|
286
281
|
label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
|
|
@@ -301,7 +296,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
301
296
|
"use-label",
|
|
302
297
|
"label-title",
|
|
303
298
|
"text"
|
|
304
|
-
]), __props.config.titleExtra &&
|
|
299
|
+
]), __props.config.titleExtra && itemLabelPosition.value === "top" ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.config.titleExtra), 1)) : createCommentVNode("v-if", true)])]),
|
|
305
300
|
default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
306
301
|
key: 0,
|
|
307
302
|
placement: tooltip.value.placement
|
|
@@ -511,11 +506,11 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
511
506
|
_: 1
|
|
512
507
|
})) : createCommentVNode("v-if", true)
|
|
513
508
|
], 64))
|
|
514
|
-
], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [(isValidName() ? __props.model[name.value] : __props.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
|
|
509
|
+
], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [(isValidName$1() ? __props.model[name.value] : __props.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
|
|
515
510
|
return openBlock(), createBlock(_component_Container, {
|
|
516
511
|
key: key(item),
|
|
517
|
-
model: isValidName() ? __props.model[name.value] : __props.model,
|
|
518
|
-
"last-values": isValidName() ? __props.lastValues[name.value] || {} : __props.lastValues,
|
|
512
|
+
model: isValidName$1() ? __props.model[name.value] : __props.model,
|
|
513
|
+
"last-values": isValidName$1() ? __props.lastValues[name.value] || {} : __props.lastValues,
|
|
519
514
|
"is-compare": __props.isCompare,
|
|
520
515
|
config: item,
|
|
521
516
|
size: __props.size,
|
|
@@ -523,6 +518,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
523
518
|
"step-active": __props.stepActive,
|
|
524
519
|
"expand-more": expand.value,
|
|
525
520
|
"label-width": itemLabelWidth.value,
|
|
521
|
+
"label-position": itemLabelPosition.value,
|
|
526
522
|
prop: itemProp.value,
|
|
527
523
|
onChange: onChangeHandler,
|
|
528
524
|
onAddDiffCount
|
|
@@ -540,6 +536,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
540
536
|
"step-active",
|
|
541
537
|
"expand-more",
|
|
542
538
|
"label-width",
|
|
539
|
+
"label-position",
|
|
543
540
|
"prop"
|
|
544
541
|
]);
|
|
545
542
|
}), 128)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true), __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_10, [createVNode(unref(TMagicButton), {
|
|
@@ -14,11 +14,12 @@ var _hoisted_6 = {
|
|
|
14
14
|
};
|
|
15
15
|
var _hoisted_7 = { style: { "flex": "1" } };
|
|
16
16
|
var _hoisted_8 = ["src"];
|
|
17
|
-
var Fieldset_vue_vue_type_script_setup_true_lang_default =
|
|
17
|
+
var Fieldset_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
18
18
|
name: "MFormFieldset",
|
|
19
19
|
__name: "Fieldset",
|
|
20
20
|
props: {
|
|
21
21
|
labelWidth: {},
|
|
22
|
+
labelPosition: {},
|
|
22
23
|
prop: { default: "" },
|
|
23
24
|
size: {},
|
|
24
25
|
model: {},
|
|
@@ -58,6 +59,7 @@ var Fieldset_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
58
59
|
if (props.config.items) return props.config.labelWidth || props.labelWidth;
|
|
59
60
|
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
60
61
|
});
|
|
62
|
+
const lPosition = computed(() => props.config.labelPosition || props.labelPosition);
|
|
61
63
|
const valueChangeHandler = (value) => {
|
|
62
64
|
emit("change", value, { modifyKey: checkboxName.value });
|
|
63
65
|
};
|
|
@@ -105,6 +107,7 @@ var Fieldset_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
105
107
|
prop: __props.prop,
|
|
106
108
|
disabled: __props.disabled,
|
|
107
109
|
labelWidth: lWidth.value,
|
|
110
|
+
labelPosition: lPosition.value,
|
|
108
111
|
size: __props.size,
|
|
109
112
|
onChange: changeHandler,
|
|
110
113
|
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
@@ -117,6 +120,7 @@ var Fieldset_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
117
120
|
"prop",
|
|
118
121
|
"disabled",
|
|
119
122
|
"labelWidth",
|
|
123
|
+
"labelPosition",
|
|
120
124
|
"size"
|
|
121
125
|
]);
|
|
122
126
|
}), 128))]), createElementVNode("img", {
|
|
@@ -132,6 +136,7 @@ var Fieldset_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
132
136
|
config: item,
|
|
133
137
|
prop: __props.prop,
|
|
134
138
|
labelWidth: lWidth.value,
|
|
139
|
+
labelPosition: lPosition.value,
|
|
135
140
|
size: __props.size,
|
|
136
141
|
disabled: __props.disabled,
|
|
137
142
|
onChange: changeHandler,
|
|
@@ -144,6 +149,7 @@ var Fieldset_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
144
149
|
"config",
|
|
145
150
|
"prop",
|
|
146
151
|
"labelWidth",
|
|
152
|
+
"labelPosition",
|
|
147
153
|
"size",
|
|
148
154
|
"disabled"
|
|
149
155
|
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Container_default from "./Container.js";
|
|
2
2
|
import { Fragment, computed, createBlock, createElementBlock, defineComponent, inject, normalizeStyle, openBlock, renderList, unref } from "vue";
|
|
3
3
|
//#region packages/form/src/containers/FlexLayout.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var FlexLayout_vue_vue_type_script_setup_true_lang_default =
|
|
4
|
+
var FlexLayout_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
5
5
|
name: "MFormFlexLayout",
|
|
6
6
|
__name: "FlexLayout",
|
|
7
7
|
props: {
|
|
@@ -11,6 +11,7 @@ var FlexLayout_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
11
11
|
config: {},
|
|
12
12
|
name: {},
|
|
13
13
|
labelWidth: {},
|
|
14
|
+
labelPosition: {},
|
|
14
15
|
prop: {},
|
|
15
16
|
size: {},
|
|
16
17
|
disabled: { type: Boolean }
|
|
@@ -44,6 +45,7 @@ var FlexLayout_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
44
45
|
size: __props.size,
|
|
45
46
|
disabled: __props.disabled,
|
|
46
47
|
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
48
|
+
"label-position": __props.config.labelPosition || __props.labelPosition,
|
|
47
49
|
onChange: changeHandler,
|
|
48
50
|
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
49
51
|
}, null, 8, [
|
|
@@ -54,7 +56,8 @@ var FlexLayout_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
54
56
|
"prop",
|
|
55
57
|
"size",
|
|
56
58
|
"disabled",
|
|
57
|
-
"label-width"
|
|
59
|
+
"label-width",
|
|
60
|
+
"label-position"
|
|
58
61
|
]);
|
|
59
62
|
}), 128))], 4);
|
|
60
63
|
};
|
|
@@ -12,7 +12,7 @@ var _hoisted_1 = {
|
|
|
12
12
|
var _hoisted_2 = ["innerHTML", "title"];
|
|
13
13
|
var _hoisted_3 = ["innerHTML"];
|
|
14
14
|
var _hoisted_4 = ["innerHTML", "title"];
|
|
15
|
-
var FormLabel_vue_vue_type_script_setup_true_lang_default =
|
|
15
|
+
var FormLabel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
16
16
|
__name: "FormLabel",
|
|
17
17
|
props: {
|
|
18
18
|
tip: {},
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
+
import { getGroupListHeaderVars } from "../utils/tableGroupList.js";
|
|
1
2
|
import GroupListItem_default from "./GroupListItem.js";
|
|
2
|
-
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, openBlock, renderList, renderSlot } from "vue";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, withCtx } from "vue";
|
|
3
4
|
import { cloneDeep } from "lodash-es";
|
|
4
5
|
//#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var _hoisted_1 =
|
|
6
|
-
var _hoisted_2 =
|
|
7
|
-
var _hoisted_3 = {
|
|
6
|
+
var _hoisted_1 = ["innerHTML"];
|
|
7
|
+
var _hoisted_2 = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "el-table__empty-block"
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
class: "m-fields-group-list-footer"
|
|
14
|
-
};
|
|
15
|
-
var _hoisted_5 = { style: {
|
|
11
|
+
var _hoisted_3 = { class: "el-table__empty-text t-table__empty" };
|
|
12
|
+
var _hoisted_4 = { style: {
|
|
16
13
|
"display": "flex",
|
|
17
14
|
"justify-content": "flex-end",
|
|
18
15
|
"flex": "1"
|
|
19
16
|
} };
|
|
20
|
-
var GroupList_vue_vue_type_script_setup_true_lang_default =
|
|
17
|
+
var GroupList_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
21
18
|
name: "MFormGroupList",
|
|
22
19
|
__name: "GroupList",
|
|
23
20
|
props: {
|
|
@@ -27,6 +24,7 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
27
24
|
config: {},
|
|
28
25
|
name: {},
|
|
29
26
|
labelWidth: {},
|
|
27
|
+
labelPosition: {},
|
|
30
28
|
prop: {},
|
|
31
29
|
size: {},
|
|
32
30
|
disabled: { type: Boolean },
|
|
@@ -55,33 +53,68 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
55
53
|
emit("change", props.model[props.name]);
|
|
56
54
|
};
|
|
57
55
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
58
|
-
const
|
|
56
|
+
const asList = (value) => Array.isArray(value) ? value : [];
|
|
57
|
+
const headerVars = computed(() => getGroupListHeaderVars(props.config.header));
|
|
58
|
+
/**
|
|
59
|
+
* 取 `$slots` 而不是 `useSlots()`:宿主切换 `addable` 时插槽会增删,
|
|
60
|
+
* computed 缓存不随插槽变化失效,只有在渲染期读才拿得到最新的。
|
|
61
|
+
*/
|
|
62
|
+
const hasFooter = (slots) => !props.isCompare && Boolean(slots["toggle-button"] || slots["add-button"]);
|
|
63
|
+
/** 只有真的渲染出吸底 footer,内层列表才需要为它让位 */
|
|
64
|
+
const isFooterSticky = (slots) => hasFooter(slots) && Boolean(props.config.addButtonConfig?.sticky);
|
|
65
|
+
const currentList = computed(() => asList(props.model[props.name]));
|
|
66
|
+
/** 对比时按当前/历史较长一侧对齐,已删除的项也能渲染出来 */
|
|
67
|
+
const displayItems = computed(() => {
|
|
68
|
+
const current = currentList.value;
|
|
69
|
+
if (!props.isCompare) return current.map((item, index) => ({
|
|
70
|
+
item: item ?? {},
|
|
71
|
+
last: {},
|
|
72
|
+
index
|
|
73
|
+
}));
|
|
74
|
+
const last = asList(props.lastValues?.[props.name]);
|
|
75
|
+
return Array.from({ length: Math.max(current.length, last.length) }, (_, index) => ({
|
|
76
|
+
item: current[index] ?? {},
|
|
77
|
+
last: last[index] ?? {},
|
|
78
|
+
index
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
59
81
|
return (_ctx, _cache) => {
|
|
60
|
-
return openBlock(), createElementBlock("div",
|
|
82
|
+
return openBlock(), createElementBlock("div", {
|
|
83
|
+
class: normalizeClass(["m-fields-group-list", {
|
|
84
|
+
"is-header-sticky": Boolean(__props.config.header?.sticky),
|
|
85
|
+
"is-footer-sticky": isFooterSticky(_ctx.$slots)
|
|
86
|
+
}]),
|
|
87
|
+
style: normalizeStyle(headerVars.value)
|
|
88
|
+
}, [
|
|
61
89
|
__props.config.extra ? (openBlock(), createElementBlock("div", {
|
|
62
90
|
key: 0,
|
|
63
91
|
innerHTML: __props.config.extra,
|
|
64
92
|
style: { "color": "rgba(0, 0, 0, 0.45)" }
|
|
65
|
-
}, null, 8,
|
|
66
|
-
!
|
|
93
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
94
|
+
!displayItems.value.length ? (openBlock(), createElementBlock("div", _hoisted_2, [createElementVNode("span", _hoisted_3, "暂无" + toDisplayString(__props.config.titlePrefix || "") + "数据", 1)])) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(displayItems.value, (entry) => {
|
|
67
95
|
return openBlock(), createBlock(GroupListItem_default, {
|
|
68
|
-
key: index,
|
|
69
|
-
model: item,
|
|
70
|
-
lastValues:
|
|
96
|
+
key: entry.index,
|
|
97
|
+
model: entry.item,
|
|
98
|
+
lastValues: entry.last,
|
|
71
99
|
"is-compare": __props.isCompare,
|
|
72
100
|
config: __props.config,
|
|
73
101
|
prop: __props.prop,
|
|
74
|
-
index:
|
|
102
|
+
index: entry.index,
|
|
75
103
|
"label-width": __props.labelWidth,
|
|
104
|
+
"label-position": __props.labelPosition,
|
|
76
105
|
size: __props.size,
|
|
77
106
|
disabled: __props.disabled,
|
|
78
|
-
"group-model":
|
|
107
|
+
"group-model": currentList.value,
|
|
79
108
|
onRemoveItem: removeHandler,
|
|
80
109
|
onCopyItem: copyHandler,
|
|
81
110
|
onSwapItem: swapHandler,
|
|
82
111
|
onChange: changeHandler,
|
|
83
112
|
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
84
|
-
},
|
|
113
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.title ? {
|
|
114
|
+
name: "title",
|
|
115
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "title", mergeProps({ ref_for: true }, slotProps))]),
|
|
116
|
+
key: "0"
|
|
117
|
+
} : void 0]), 1032, [
|
|
85
118
|
"model",
|
|
86
119
|
"lastValues",
|
|
87
120
|
"is-compare",
|
|
@@ -89,13 +122,17 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
89
122
|
"prop",
|
|
90
123
|
"index",
|
|
91
124
|
"label-width",
|
|
125
|
+
"label-position",
|
|
92
126
|
"size",
|
|
93
127
|
"disabled",
|
|
94
128
|
"group-model"
|
|
95
129
|
]);
|
|
96
130
|
}), 128)),
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
hasFooter(_ctx.$slots) ? (openBlock(), createElementBlock("div", {
|
|
132
|
+
key: 3,
|
|
133
|
+
class: normalizeClass(["m-fields-group-list-footer", { "is-sticky-full": Boolean(__props.config.addButtonConfig?.sticky) }])
|
|
134
|
+
}, [renderSlot(_ctx.$slots, "toggle-button"), createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "add-button")])], 2)) : createCommentVNode("v-if", true)
|
|
135
|
+
], 6);
|
|
99
136
|
};
|
|
100
137
|
}
|
|
101
138
|
});
|