@tmagic/form 1.2.14 → 1.2.15
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/tmagic-form.js +66 -71
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +64 -69
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/containers/Fieldset.vue +2 -9
- package/src/containers/Table.vue +1 -1
- package/src/containers/Tabs.vue +65 -60
- package/src/fields/Select.vue +2 -2
- package/src/fields/Text.vue +3 -3
- package/src/schema.ts +1 -0
- package/types/schema.d.ts +1 -0
package/dist/tmagic-form.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, watch, openBlock, createElementBlock, normalizeStyle, normalizeClass, unref, createBlock, resolveDynamicComponent, Fragment, createVNode, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, toRefs, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, resolveDirective, createSlots, withModifiers } from 'vue';
|
|
1
|
+
import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, watch, openBlock, createElementBlock, normalizeStyle, normalizeClass, unref, createBlock, resolveDynamicComponent, Fragment, createVNode, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, resolveDirective, createSlots, withModifiers } from 'vue';
|
|
2
2
|
import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
|
|
3
3
|
import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
|
|
4
|
-
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1,
|
|
4
|
+
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicOptionGroup, TMagicOption, TMagicSelect, TMagicSwitch, TMagicTimePicker } from '@tmagic/design';
|
|
5
5
|
import Sortable from 'sortablejs';
|
|
6
6
|
import { asyncLoadJs, sleep, datetimeFormatter, isNumber } from '@tmagic/utils';
|
|
7
7
|
import cloneDeep$1 from 'lodash-es/cloneDeep';
|
|
@@ -647,14 +647,6 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
647
647
|
emit("change", props.model);
|
|
648
648
|
};
|
|
649
649
|
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
650
|
-
if (props.config.checkbox && name.value) {
|
|
651
|
-
watch(
|
|
652
|
-
() => props.model[name.value]?.value,
|
|
653
|
-
() => {
|
|
654
|
-
emit("change", props.model);
|
|
655
|
-
}
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
650
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
659
651
|
return (_ctx, _cache) => {
|
|
660
652
|
return (unref(name) ? __props.model[unref(name)] : __props.model) ? (openBlock(), createElementBlock("fieldset", {
|
|
@@ -666,7 +658,10 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
666
658
|
default: withCtx(() => [
|
|
667
659
|
createVNode(unref(TMagicCheckbox), {
|
|
668
660
|
modelValue: __props.model[unref(name)].value,
|
|
669
|
-
"onUpdate:modelValue":
|
|
661
|
+
"onUpdate:modelValue": [
|
|
662
|
+
_cache[0] || (_cache[0] = ($event) => __props.model[unref(name)].value = $event),
|
|
663
|
+
change
|
|
664
|
+
],
|
|
670
665
|
prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.value`,
|
|
671
666
|
"true-label": 1,
|
|
672
667
|
"false-label": 0
|
|
@@ -1614,7 +1609,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
1614
1609
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1615
1610
|
};
|
|
1616
1611
|
const excelHandler = (file) => {
|
|
1617
|
-
if (!file
|
|
1612
|
+
if (!file?.raw) {
|
|
1618
1613
|
return false;
|
|
1619
1614
|
}
|
|
1620
1615
|
const reader = new FileReader();
|
|
@@ -1967,7 +1962,8 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
1967
1962
|
emits: ["change", "addDiffCount"],
|
|
1968
1963
|
setup(__props, { emit }) {
|
|
1969
1964
|
const props = __props;
|
|
1970
|
-
const
|
|
1965
|
+
const tabPaneComponent = getConfig$1("components").tabPane;
|
|
1966
|
+
const tabsComponent = getConfig$1("components").tabs;
|
|
1971
1967
|
const getActive = (mForm2, props2, activeTabName2) => {
|
|
1972
1968
|
const { config, model, prop } = props2;
|
|
1973
1969
|
const { active } = config;
|
|
@@ -1999,7 +1995,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
1999
1995
|
throw new Error("dynamic tab 必须配置name");
|
|
2000
1996
|
return props.model[props.config.name] || [];
|
|
2001
1997
|
}
|
|
2002
|
-
return props.config.items;
|
|
1998
|
+
return props.config.items.filter((item) => display(mForm, item.display, props));
|
|
2003
1999
|
});
|
|
2004
2000
|
const filter = (config) => filterFunction(mForm, config, props);
|
|
2005
2001
|
watchEffect(() => {
|
|
@@ -2048,7 +2044,6 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
2048
2044
|
emit("change", props.model);
|
|
2049
2045
|
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2050
2046
|
};
|
|
2051
|
-
const display$1 = (displayConfig) => display(mForm, displayConfig, props);
|
|
2052
2047
|
const changeHandler = () => {
|
|
2053
2048
|
emit("change", props.model);
|
|
2054
2049
|
if (typeof props.config.onChange === "function") {
|
|
@@ -2064,61 +2059,62 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
2064
2059
|
emit("addDiffCount");
|
|
2065
2060
|
};
|
|
2066
2061
|
return (_ctx, _cache) => {
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2062
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(tabsComponent).component), mergeProps(
|
|
2063
|
+
{
|
|
2064
|
+
modelValue: activeTabName.value,
|
|
2065
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
|
|
2066
|
+
},
|
|
2067
|
+
unref(tabsComponent).props({
|
|
2068
|
+
type: __props.config.tabType,
|
|
2069
|
+
editable: __props.config.editable || false,
|
|
2070
|
+
tabPosition: __props.config.tabPosition || "top"
|
|
2071
|
+
}),
|
|
2072
|
+
{
|
|
2073
|
+
class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
|
|
2074
|
+
onTabClick: tabClickHandler,
|
|
2075
|
+
onTabAdd,
|
|
2076
|
+
onTabRemove
|
|
2077
|
+
}
|
|
2078
|
+
), {
|
|
2079
2079
|
default: withCtx(() => [
|
|
2080
2080
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(tabs), (tab, tabIndex) => {
|
|
2081
|
-
return openBlock(),
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
_: 2
|
|
2116
|
-
}, 1032, ["name", "lazy"])) : createCommentVNode("", true)
|
|
2117
|
-
], 64);
|
|
2118
|
-
}), 256))
|
|
2081
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent).component), mergeProps({
|
|
2082
|
+
key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex
|
|
2083
|
+
}, unref(tabPaneComponent).props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false })), {
|
|
2084
|
+
label: withCtx(() => [
|
|
2085
|
+
createElementVNode("span", null, [
|
|
2086
|
+
createTextVNode(toDisplayString(filter(tab.title)), 1),
|
|
2087
|
+
createVNode(unref(TMagicBadge), {
|
|
2088
|
+
hidden: !diffCount.value[tabIndex],
|
|
2089
|
+
value: diffCount.value[tabIndex],
|
|
2090
|
+
class: "diff-count-badge"
|
|
2091
|
+
}, null, 8, ["hidden", "value"])
|
|
2092
|
+
])
|
|
2093
|
+
]),
|
|
2094
|
+
default: withCtx(() => [
|
|
2095
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(tabItems(tab), (item) => {
|
|
2096
|
+
return openBlock(), createBlock(_sfc_main$v, {
|
|
2097
|
+
key: item[unref(mForm)?.keyProp || "__key"],
|
|
2098
|
+
config: item,
|
|
2099
|
+
disabled: __props.disabled,
|
|
2100
|
+
model: __props.config.dynamic ? (__props.name ? __props.model[__props.name] : __props.model)[tabIndex] : tab.name ? (__props.name ? __props.model[__props.name] : __props.model)[tab.name] : __props.name ? __props.model[__props.name] : __props.model,
|
|
2101
|
+
"last-values": unref(isEmpty)(__props.lastValues) ? {} : __props.config.dynamic ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tabIndex] : tab.name ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tab.name] : __props.name ? __props.lastValues[__props.name] : __props.lastValues,
|
|
2102
|
+
"is-compare": __props.isCompare,
|
|
2103
|
+
prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
|
|
2104
|
+
size: __props.size,
|
|
2105
|
+
"label-width": tab.labelWidth || __props.labelWidth,
|
|
2106
|
+
"expand-more": __props.expandMore,
|
|
2107
|
+
onChange: changeHandler,
|
|
2108
|
+
onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
|
|
2109
|
+
}, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
|
|
2110
|
+
}), 128))
|
|
2111
|
+
]),
|
|
2112
|
+
_: 2
|
|
2113
|
+
}, 1040);
|
|
2114
|
+
}), 128))
|
|
2119
2115
|
]),
|
|
2120
2116
|
_: 1
|
|
2121
|
-
},
|
|
2117
|
+
}, 16, ["modelValue", "class"]);
|
|
2122
2118
|
};
|
|
2123
2119
|
}
|
|
2124
2120
|
});
|
|
@@ -3646,8 +3642,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3646
3642
|
class: "m-select",
|
|
3647
3643
|
ref_key: "tMagicSelect",
|
|
3648
3644
|
ref: tMagicSelect,
|
|
3649
|
-
clearable: "",
|
|
3650
|
-
filterable: "",
|
|
3645
|
+
clearable: typeof __props.config.clearable !== "undefined" ? __props.config.clearable : true,
|
|
3646
|
+
filterable: typeof __props.config.filterable !== "undefined" ? __props.config.filterable : true,
|
|
3651
3647
|
"popper-class": `m-select-popper ${unref(popperClass)}`,
|
|
3652
3648
|
size: __props.size,
|
|
3653
3649
|
remote: remote.value,
|
|
@@ -3673,7 +3669,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3673
3669
|
]) : createCommentVNode("", true)
|
|
3674
3670
|
]),
|
|
3675
3671
|
_: 1
|
|
3676
|
-
}, 8, ["modelValue", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
|
|
3672
|
+
}, 8, ["modelValue", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
|
|
3677
3673
|
[_directive_loading, loading.value]
|
|
3678
3674
|
]) : createCommentVNode("", true);
|
|
3679
3675
|
};
|
|
@@ -3826,7 +3822,6 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3826
3822
|
emit("change", props.model[props.name]);
|
|
3827
3823
|
};
|
|
3828
3824
|
return (_ctx, _cache) => {
|
|
3829
|
-
const _component_el_button = resolveComponent("el-button");
|
|
3830
3825
|
return openBlock(), createBlock(unref(TMagicInput), {
|
|
3831
3826
|
modelValue: __props.model[__props.name],
|
|
3832
3827
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
@@ -3842,7 +3837,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3842
3837
|
name: "append",
|
|
3843
3838
|
fn: withCtx(() => [
|
|
3844
3839
|
typeof __props.config.append === "string" ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(__props.config.append), 1)) : createCommentVNode("", true),
|
|
3845
|
-
typeof __props.config.append === "object" && __props.config.append.type === "button" ? (openBlock(), createBlock(
|
|
3840
|
+
typeof __props.config.append === "object" && __props.config.append.type === "button" ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
3846
3841
|
key: 1,
|
|
3847
3842
|
style: { "color": "#409eff" },
|
|
3848
3843
|
size: __props.size,
|