@tmagic/form 1.2.14 → 1.3.0-alpha.0

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.
Files changed (50) hide show
  1. package/dist/style.css +3 -0
  2. package/dist/tmagic-form.js +104 -91
  3. package/dist/tmagic-form.js.map +1 -1
  4. package/dist/tmagic-form.umd.cjs +102 -89
  5. package/dist/tmagic-form.umd.cjs.map +1 -1
  6. package/package.json +3 -3
  7. package/src/containers/Container.vue +1 -1
  8. package/src/containers/Fieldset.vue +2 -9
  9. package/src/containers/Table.vue +1 -1
  10. package/src/containers/Tabs.vue +65 -60
  11. package/src/fields/Cascader.vue +2 -1
  12. package/src/fields/Checkbox.vue +1 -0
  13. package/src/fields/CheckboxGroup.vue +1 -0
  14. package/src/fields/ColorPicker.vue +1 -0
  15. package/src/fields/Date.vue +1 -0
  16. package/src/fields/DateTime.vue +1 -0
  17. package/src/fields/Daterange.vue +1 -0
  18. package/src/fields/Display.vue +1 -0
  19. package/src/fields/DynamicField.vue +1 -0
  20. package/src/fields/Hidden.vue +1 -0
  21. package/src/fields/Link.vue +1 -0
  22. package/src/fields/Number.vue +1 -0
  23. package/src/fields/RadioGroup.vue +1 -0
  24. package/src/fields/Select.vue +3 -2
  25. package/src/fields/Switch.vue +1 -0
  26. package/src/fields/Text.vue +4 -3
  27. package/src/fields/Textarea.vue +1 -0
  28. package/src/fields/Time.vue +1 -0
  29. package/src/schema.ts +4 -1
  30. package/src/theme/form.scss +6 -0
  31. package/types/containers/Table.vue.d.ts +2 -2
  32. package/types/fields/Cascader.vue.d.ts +2 -0
  33. package/types/fields/Checkbox.vue.d.ts +2 -0
  34. package/types/fields/CheckboxGroup.vue.d.ts +2 -0
  35. package/types/fields/ColorPicker.vue.d.ts +2 -0
  36. package/types/fields/Date.vue.d.ts +2 -0
  37. package/types/fields/DateTime.vue.d.ts +2 -0
  38. package/types/fields/Daterange.vue.d.ts +2 -0
  39. package/types/fields/Display.vue.d.ts +2 -0
  40. package/types/fields/DynamicField.vue.d.ts +2 -0
  41. package/types/fields/Hidden.vue.d.ts +2 -0
  42. package/types/fields/Link.vue.d.ts +2 -0
  43. package/types/fields/Number.vue.d.ts +2 -0
  44. package/types/fields/RadioGroup.vue.d.ts +2 -0
  45. package/types/fields/Select.vue.d.ts +2 -0
  46. package/types/fields/Switch.vue.d.ts +2 -0
  47. package/types/fields/Text.vue.d.ts +2 -0
  48. package/types/fields/Textarea.vue.d.ts +2 -0
  49. package/types/fields/Time.vue.d.ts +2 -0
  50. package/types/schema.d.ts +3 -3
@@ -251,7 +251,7 @@
251
251
  }
252
252
  return value;
253
253
  });
254
- const itemLabelWidth = vue.computed(() => props.config.labelWidth || props.labelWidth);
254
+ const itemLabelWidth = vue.computed(() => props.config.labelWidth ?? props.labelWidth);
255
255
  vue.watchEffect(() => {
256
256
  expand.value = props.expandMore;
257
257
  });
@@ -645,14 +645,6 @@
645
645
  emit("change", props.model);
646
646
  };
647
647
  const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
648
- if (props.config.checkbox && name.value) {
649
- vue.watch(
650
- () => props.model[name.value]?.value,
651
- () => {
652
- emit("change", props.model);
653
- }
654
- );
655
- }
656
648
  const onAddDiffCount = () => emit("addDiffCount");
657
649
  return (_ctx, _cache) => {
658
650
  return (vue.unref(name) ? __props.model[vue.unref(name)] : __props.model) ? (vue.openBlock(), vue.createElementBlock("fieldset", {
@@ -664,7 +656,10 @@
664
656
  default: vue.withCtx(() => [
665
657
  vue.createVNode(vue.unref(design.TMagicCheckbox), {
666
658
  modelValue: __props.model[vue.unref(name)].value,
667
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[vue.unref(name)].value = $event),
659
+ "onUpdate:modelValue": [
660
+ _cache[0] || (_cache[0] = ($event) => __props.model[vue.unref(name)].value = $event),
661
+ change
662
+ ],
668
663
  prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.value`,
669
664
  "true-label": 1,
670
665
  "false-label": 0
@@ -1612,7 +1607,7 @@
1612
1607
  mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1613
1608
  };
1614
1609
  const excelHandler = (file) => {
1615
- if (!file || !file.raw) {
1610
+ if (!file?.raw) {
1616
1611
  return false;
1617
1612
  }
1618
1613
  const reader = new FileReader();
@@ -1965,7 +1960,8 @@
1965
1960
  emits: ["change", "addDiffCount"],
1966
1961
  setup(__props, { emit }) {
1967
1962
  const props = __props;
1968
- const uiComponent = design.getConfig("components").tabPane;
1963
+ const tabPaneComponent = design.getConfig("components").tabPane;
1964
+ const tabsComponent = design.getConfig("components").tabs;
1969
1965
  const getActive = (mForm2, props2, activeTabName2) => {
1970
1966
  const { config, model, prop } = props2;
1971
1967
  const { active } = config;
@@ -1997,7 +1993,7 @@
1997
1993
  throw new Error("dynamic tab 必须配置name");
1998
1994
  return props.model[props.config.name] || [];
1999
1995
  }
2000
- return props.config.items;
1996
+ return props.config.items.filter((item) => display(mForm, item.display, props));
2001
1997
  });
2002
1998
  const filter = (config) => filterFunction(mForm, config, props);
2003
1999
  vue.watchEffect(() => {
@@ -2046,7 +2042,6 @@
2046
2042
  emit("change", props.model);
2047
2043
  mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
2048
2044
  };
2049
- const display$1 = (displayConfig) => display(mForm, displayConfig, props);
2050
2045
  const changeHandler = () => {
2051
2046
  emit("change", props.model);
2052
2047
  if (typeof props.config.onChange === "function") {
@@ -2062,61 +2057,62 @@
2062
2057
  emit("addDiffCount");
2063
2058
  };
2064
2059
  return (_ctx, _cache) => {
2065
- const _component_el_badge = vue.resolveComponent("el-badge");
2066
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTabs), {
2067
- modelValue: activeTabName.value,
2068
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
2069
- class: vue.normalizeClass(__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"),
2070
- type: __props.config.tabType,
2071
- editable: __props.config.editable || false,
2072
- "tab-position": __props.config.tabPosition || "top",
2073
- onTabClick: tabClickHandler,
2074
- onTabAdd,
2075
- onTabRemove
2076
- }, {
2060
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tabsComponent).component), vue.mergeProps(
2061
+ {
2062
+ modelValue: activeTabName.value,
2063
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
2064
+ },
2065
+ vue.unref(tabsComponent).props({
2066
+ type: __props.config.tabType,
2067
+ editable: __props.config.editable || false,
2068
+ tabPosition: __props.config.tabPosition || "top"
2069
+ }),
2070
+ {
2071
+ class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
2072
+ onTabClick: tabClickHandler,
2073
+ onTabAdd,
2074
+ onTabRemove
2075
+ }
2076
+ ), {
2077
2077
  default: vue.withCtx(() => [
2078
2078
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(tabs), (tab, tabIndex) => {
2079
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
2080
- display$1(tab.display) && tabItems(tab).length ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(uiComponent).component), {
2081
- key: tab[vue.unref(mForm)?.keyProp || "__key"] ?? tabIndex,
2082
- name: filter(tab.status) || tabIndex.toString(),
2083
- lazy: tab.lazy || false
2084
- }, {
2085
- label: vue.withCtx(() => [
2086
- vue.createElementVNode("span", null, [
2087
- vue.createTextVNode(vue.toDisplayString(filter(tab.title)), 1),
2088
- vue.createVNode(_component_el_badge, {
2089
- hidden: !diffCount.value[tabIndex],
2090
- value: diffCount.value[tabIndex],
2091
- class: "diff-count-badge"
2092
- }, null, 8, ["hidden", "value"])
2093
- ])
2094
- ]),
2095
- default: vue.withCtx(() => [
2096
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(tabItems(tab), (item) => {
2097
- return vue.openBlock(), vue.createBlock(_sfc_main$v, {
2098
- key: item[vue.unref(mForm)?.keyProp || "__key"],
2099
- config: item,
2100
- disabled: __props.disabled,
2101
- 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,
2102
- "last-values": vue.unref(lodashEs.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,
2103
- "is-compare": __props.isCompare,
2104
- prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
2105
- size: __props.size,
2106
- "label-width": tab.labelWidth || __props.labelWidth,
2107
- "expand-more": __props.expandMore,
2108
- onChange: changeHandler,
2109
- onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
2110
- }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
2111
- }), 128))
2112
- ]),
2113
- _: 2
2114
- }, 1032, ["name", "lazy"])) : vue.createCommentVNode("", true)
2115
- ], 64);
2116
- }), 256))
2079
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tabPaneComponent).component), vue.mergeProps({
2080
+ key: tab[vue.unref(mForm)?.keyProp || "__key"] ?? tabIndex
2081
+ }, vue.unref(tabPaneComponent).props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false })), {
2082
+ label: vue.withCtx(() => [
2083
+ vue.createElementVNode("span", null, [
2084
+ vue.createTextVNode(vue.toDisplayString(filter(tab.title)), 1),
2085
+ vue.createVNode(vue.unref(design.TMagicBadge), {
2086
+ hidden: !diffCount.value[tabIndex],
2087
+ value: diffCount.value[tabIndex],
2088
+ class: "diff-count-badge"
2089
+ }, null, 8, ["hidden", "value"])
2090
+ ])
2091
+ ]),
2092
+ default: vue.withCtx(() => [
2093
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(tabItems(tab), (item) => {
2094
+ return vue.openBlock(), vue.createBlock(_sfc_main$v, {
2095
+ key: item[vue.unref(mForm)?.keyProp || "__key"],
2096
+ config: item,
2097
+ disabled: __props.disabled,
2098
+ 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,
2099
+ "last-values": vue.unref(lodashEs.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,
2100
+ "is-compare": __props.isCompare,
2101
+ prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
2102
+ size: __props.size,
2103
+ "label-width": tab.labelWidth || __props.labelWidth,
2104
+ "expand-more": __props.expandMore,
2105
+ onChange: changeHandler,
2106
+ onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
2107
+ }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
2108
+ }), 128))
2109
+ ]),
2110
+ _: 2
2111
+ }, 1040);
2112
+ }), 128))
2117
2113
  ]),
2118
2114
  _: 1
2119
- }, 8, ["modelValue", "class", "type", "editable", "tab-position"]);
2115
+ }, 16, ["modelValue", "class"]);
2120
2116
  };
2121
2117
  }
2122
2118
  });
@@ -2160,7 +2156,8 @@
2160
2156
  name: null,
2161
2157
  prop: null,
2162
2158
  disabled: { type: Boolean },
2163
- size: null
2159
+ size: null,
2160
+ lastValues: null
2164
2161
  },
2165
2162
  emits: ["change"],
2166
2163
  setup(__props, { emit }) {
@@ -2204,7 +2201,7 @@
2204
2201
  vue.watchEffect(
2205
2202
  () => options.value = props.config.options(mForm, { model: props.model, formValues: mForm.values })
2206
2203
  );
2207
- } else if (!props.config.options || !props.config.options.length || props.config.remote) {
2204
+ } else if (!props.config.options?.length || props.config.remote) {
2208
2205
  Promise.resolve(setRemoteOptions());
2209
2206
  }
2210
2207
  const changeHandler = (value) => {
@@ -2247,7 +2244,8 @@
2247
2244
  name: null,
2248
2245
  prop: null,
2249
2246
  disabled: { type: Boolean },
2250
- size: null
2247
+ size: null,
2248
+ lastValues: null
2251
2249
  },
2252
2250
  emits: ["change"],
2253
2251
  setup(__props, { emit }) {
@@ -2308,7 +2306,8 @@
2308
2306
  name: null,
2309
2307
  prop: null,
2310
2308
  disabled: { type: Boolean },
2311
- size: null
2309
+ size: null,
2310
+ lastValues: null
2312
2311
  },
2313
2312
  emits: ["change"],
2314
2313
  setup(__props, { emit }) {
@@ -2370,7 +2369,8 @@
2370
2369
  name: null,
2371
2370
  prop: null,
2372
2371
  disabled: { type: Boolean },
2373
- size: null
2372
+ size: null,
2373
+ lastValues: null
2374
2374
  },
2375
2375
  emits: ["change"],
2376
2376
  setup(__props, { emit }) {
@@ -2403,7 +2403,8 @@
2403
2403
  name: null,
2404
2404
  prop: null,
2405
2405
  disabled: { type: Boolean },
2406
- size: null
2406
+ size: null,
2407
+ lastValues: null
2407
2408
  },
2408
2409
  emits: ["change"],
2409
2410
  setup(__props, { emit }) {
@@ -2442,7 +2443,8 @@
2442
2443
  name: null,
2443
2444
  prop: null,
2444
2445
  disabled: { type: Boolean },
2445
- size: null
2446
+ size: null,
2447
+ lastValues: null
2446
2448
  },
2447
2449
  emits: ["change"],
2448
2450
  setup(__props, { emit }) {
@@ -2543,7 +2545,8 @@
2543
2545
  name: null,
2544
2546
  prop: null,
2545
2547
  disabled: { type: Boolean },
2546
- size: null
2548
+ size: null,
2549
+ lastValues: null
2547
2550
  },
2548
2551
  emits: ["change"],
2549
2552
  setup(__props, { emit }) {
@@ -2590,7 +2593,8 @@
2590
2593
  initValues: null,
2591
2594
  values: null,
2592
2595
  name: null,
2593
- prop: null
2596
+ prop: null,
2597
+ lastValues: null
2594
2598
  },
2595
2599
  setup(__props) {
2596
2600
  const props = __props;
@@ -2618,7 +2622,8 @@
2618
2622
  name: null,
2619
2623
  prop: null,
2620
2624
  disabled: { type: Boolean },
2621
- size: null
2625
+ size: null,
2626
+ lastValues: null
2622
2627
  },
2623
2628
  emits: ["change"],
2624
2629
  setup(__props, { emit }) {
@@ -2707,7 +2712,8 @@
2707
2712
  initValues: null,
2708
2713
  values: null,
2709
2714
  name: null,
2710
- prop: null
2715
+ prop: null,
2716
+ lastValues: null
2711
2717
  },
2712
2718
  setup(__props) {
2713
2719
  const props = __props;
@@ -3083,7 +3089,8 @@
3083
3089
  name: null,
3084
3090
  prop: null,
3085
3091
  disabled: { type: Boolean },
3086
- size: null
3092
+ size: null,
3093
+ lastValues: null
3087
3094
  },
3088
3095
  emits: ["change"],
3089
3096
  setup(__props, { emit }) {
@@ -3180,7 +3187,8 @@
3180
3187
  name: null,
3181
3188
  prop: null,
3182
3189
  disabled: { type: Boolean },
3183
- size: null
3190
+ size: null,
3191
+ lastValues: null
3184
3192
  },
3185
3193
  emits: ["change", "input"],
3186
3194
  setup(__props, { emit }) {
@@ -3227,7 +3235,8 @@
3227
3235
  name: null,
3228
3236
  prop: null,
3229
3237
  disabled: { type: Boolean },
3230
- size: null
3238
+ size: null,
3239
+ lastValues: null
3231
3240
  },
3232
3241
  emits: ["change"],
3233
3242
  setup(__props, { emit }) {
@@ -3336,7 +3345,8 @@
3336
3345
  name: null,
3337
3346
  prop: null,
3338
3347
  disabled: { type: Boolean },
3339
- size: null
3348
+ size: null,
3349
+ lastValues: null
3340
3350
  },
3341
3351
  emits: ["change"],
3342
3352
  setup(__props, { emit }) {
@@ -3644,8 +3654,8 @@
3644
3654
  class: "m-select",
3645
3655
  ref_key: "tMagicSelect",
3646
3656
  ref: tMagicSelect,
3647
- clearable: "",
3648
- filterable: "",
3657
+ clearable: typeof __props.config.clearable !== "undefined" ? __props.config.clearable : true,
3658
+ filterable: typeof __props.config.filterable !== "undefined" ? __props.config.filterable : true,
3649
3659
  "popper-class": `m-select-popper ${vue.unref(popperClass)}`,
3650
3660
  size: __props.size,
3651
3661
  remote: remote.value,
@@ -3671,7 +3681,7 @@
3671
3681
  ]) : vue.createCommentVNode("", true)
3672
3682
  ]),
3673
3683
  _: 1
3674
- }, 8, ["modelValue", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
3684
+ }, 8, ["modelValue", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
3675
3685
  [_directive_loading, loading.value]
3676
3686
  ]) : vue.createCommentVNode("", true);
3677
3687
  };
@@ -3691,7 +3701,8 @@
3691
3701
  name: null,
3692
3702
  prop: null,
3693
3703
  disabled: { type: Boolean },
3694
- size: null
3704
+ size: null,
3705
+ lastValues: null
3695
3706
  },
3696
3707
  emits: ["change"],
3697
3708
  setup(__props, { emit }) {
@@ -3748,7 +3759,8 @@
3748
3759
  name: null,
3749
3760
  prop: null,
3750
3761
  disabled: { type: Boolean },
3751
- size: null
3762
+ size: null,
3763
+ lastValues: null
3752
3764
  },
3753
3765
  emits: ["change", "input"],
3754
3766
  setup(__props, { emit }) {
@@ -3824,7 +3836,6 @@
3824
3836
  emit("change", props.model[props.name]);
3825
3837
  };
3826
3838
  return (_ctx, _cache) => {
3827
- const _component_el_button = vue.resolveComponent("el-button");
3828
3839
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
3829
3840
  modelValue: __props.model[__props.name],
3830
3841
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
@@ -3840,7 +3851,7 @@
3840
3851
  name: "append",
3841
3852
  fn: vue.withCtx(() => [
3842
3853
  typeof __props.config.append === "string" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(__props.config.append), 1)) : vue.createCommentVNode("", true),
3843
- typeof __props.config.append === "object" && __props.config.append.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_button, {
3854
+ typeof __props.config.append === "object" && __props.config.append.type === "button" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
3844
3855
  key: 1,
3845
3856
  style: { "color": "#409eff" },
3846
3857
  size: __props.size,
@@ -3871,7 +3882,8 @@
3871
3882
  name: null,
3872
3883
  prop: null,
3873
3884
  disabled: { type: Boolean },
3874
- size: null
3885
+ size: null,
3886
+ lastValues: null
3875
3887
  },
3876
3888
  emits: ["change", "input"],
3877
3889
  setup(__props, { emit }) {
@@ -3914,7 +3926,8 @@
3914
3926
  name: null,
3915
3927
  prop: null,
3916
3928
  disabled: { type: Boolean },
3917
- size: null
3929
+ size: null,
3930
+ lastValues: null
3918
3931
  },
3919
3932
  emits: ["change"],
3920
3933
  setup(__props, { emit }) {