@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.
@@ -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, TMagicTabs, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicOptionGroup, TMagicOption, TMagicSelect, TMagicSwitch, TMagicTimePicker } from '@tmagic/design';
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": _cache[0] || (_cache[0] = ($event) => __props.model[unref(name)].value = $event),
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 || !file.raw) {
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 uiComponent = getConfig$1("components").tabPane;
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
- const _component_el_badge = resolveComponent("el-badge");
2068
- return openBlock(), createBlock(unref(TMagicTabs), {
2069
- modelValue: activeTabName.value,
2070
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
2071
- class: normalizeClass(__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"),
2072
- type: __props.config.tabType,
2073
- editable: __props.config.editable || false,
2074
- "tab-position": __props.config.tabPosition || "top",
2075
- onTabClick: tabClickHandler,
2076
- onTabAdd,
2077
- onTabRemove
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(), createElementBlock(Fragment, null, [
2082
- display$1(tab.display) && tabItems(tab).length ? (openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
2083
- key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex,
2084
- name: filter(tab.status) || tabIndex.toString(),
2085
- lazy: tab.lazy || false
2086
- }, {
2087
- label: withCtx(() => [
2088
- createElementVNode("span", null, [
2089
- createTextVNode(toDisplayString(filter(tab.title)), 1),
2090
- createVNode(_component_el_badge, {
2091
- hidden: !diffCount.value[tabIndex],
2092
- value: diffCount.value[tabIndex],
2093
- class: "diff-count-badge"
2094
- }, null, 8, ["hidden", "value"])
2095
- ])
2096
- ]),
2097
- default: withCtx(() => [
2098
- (openBlock(true), createElementBlock(Fragment, null, renderList(tabItems(tab), (item) => {
2099
- return openBlock(), createBlock(_sfc_main$v, {
2100
- key: item[unref(mForm)?.keyProp || "__key"],
2101
- config: item,
2102
- disabled: __props.disabled,
2103
- 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,
2104
- "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,
2105
- "is-compare": __props.isCompare,
2106
- prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
2107
- size: __props.size,
2108
- "label-width": tab.labelWidth || __props.labelWidth,
2109
- "expand-more": __props.expandMore,
2110
- onChange: changeHandler,
2111
- onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
2112
- }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
2113
- }), 128))
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
- }, 8, ["modelValue", "class", "type", "editable", "tab-position"]);
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(_component_el_button, {
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,