@tmagic/form 1.2.0-beta.9 → 1.2.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.
Files changed (82) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/{tmagic-form.mjs → tmagic-form.js} +313 -129
  3. package/dist/tmagic-form.js.map +1 -0
  4. package/dist/{tmagic-form.umd.js → tmagic-form.umd.cjs} +312 -127
  5. package/dist/tmagic-form.umd.cjs.map +1 -0
  6. package/package.json +10 -8
  7. package/src/Form.vue +2 -2
  8. package/src/FormDialog.vue +3 -1
  9. package/src/containers/Col.vue +3 -1
  10. package/src/containers/Container.vue +6 -3
  11. package/src/containers/Fieldset.vue +4 -1
  12. package/src/containers/GroupList.vue +4 -2
  13. package/src/containers/GroupListItem.vue +8 -5
  14. package/src/containers/Panel.vue +4 -1
  15. package/src/containers/Row.vue +3 -1
  16. package/src/containers/Step.vue +3 -1
  17. package/src/containers/Table.vue +46 -19
  18. package/src/containers/Tabs.vue +9 -4
  19. package/src/fields/Cascader.vue +2 -2
  20. package/src/fields/Checkbox.vue +2 -2
  21. package/src/fields/CheckboxGroup.vue +8 -3
  22. package/src/fields/ColorPicker.vue +2 -2
  23. package/src/fields/Date.vue +3 -3
  24. package/src/fields/DateTime.vue +2 -2
  25. package/src/fields/Daterange.vue +2 -2
  26. package/src/fields/Display.vue +1 -1
  27. package/src/fields/DynamicField.vue +2 -2
  28. package/src/fields/Hidden.vue +1 -1
  29. package/src/fields/Link.vue +2 -2
  30. package/src/fields/Number.vue +2 -2
  31. package/src/fields/RadioGroup.vue +9 -5
  32. package/src/fields/Select.vue +63 -24
  33. package/src/fields/SelectOptionGroups.vue +1 -1
  34. package/src/fields/SelectOptions.vue +1 -1
  35. package/src/fields/Switch.vue +2 -2
  36. package/src/fields/Text.vue +2 -2
  37. package/src/fields/Textarea.vue +2 -2
  38. package/src/fields/Time.vue +4 -2
  39. package/src/index.ts +1 -1
  40. package/src/schema.ts +25 -9
  41. package/src/theme/form.scss +1 -1
  42. package/src/utils/config.ts +1 -1
  43. package/src/utils/containerProps.ts +1 -1
  44. package/src/utils/createForm.ts +1 -1
  45. package/src/utils/form.ts +6 -6
  46. package/src/utils/useAddField.ts +1 -1
  47. package/types/Form.vue.d.ts +32 -170
  48. package/types/FormDialog.vue.d.ts +4 -0
  49. package/types/containers/Col.vue.d.ts +12 -74
  50. package/types/containers/Container.vue.d.ts +17 -95
  51. package/types/containers/Fieldset.vue.d.ts +15 -87
  52. package/types/containers/GroupList.vue.d.ts +11 -71
  53. package/types/containers/GroupListItem.vue.d.ts +12 -80
  54. package/types/containers/Panel.vue.d.ts +4 -0
  55. package/types/containers/Row.vue.d.ts +12 -74
  56. package/types/containers/Step.vue.d.ts +13 -79
  57. package/types/containers/Table.vue.d.ts +10 -0
  58. package/types/containers/Tabs.vue.d.ts +12 -74
  59. package/types/fields/Cascader.vue.d.ts +12 -78
  60. package/types/fields/Checkbox.vue.d.ts +12 -78
  61. package/types/fields/CheckboxGroup.vue.d.ts +12 -78
  62. package/types/fields/ColorPicker.vue.d.ts +12 -78
  63. package/types/fields/Date.vue.d.ts +12 -78
  64. package/types/fields/DateTime.vue.d.ts +12 -78
  65. package/types/fields/Daterange.vue.d.ts +12 -78
  66. package/types/fields/Display.vue.d.ts +9 -65
  67. package/types/fields/DynamicField.vue.d.ts +12 -78
  68. package/types/fields/Hidden.vue.d.ts +9 -65
  69. package/types/fields/Link.vue.d.ts +12 -78
  70. package/types/fields/Number.vue.d.ts +12 -81
  71. package/types/fields/RadioGroup.vue.d.ts +12 -78
  72. package/types/fields/Select.vue.d.ts +12 -79
  73. package/types/fields/SelectOptionGroups.vue.d.ts +4 -50
  74. package/types/fields/SelectOptions.vue.d.ts +5 -53
  75. package/types/fields/Switch.vue.d.ts +12 -78
  76. package/types/fields/Text.vue.d.ts +12 -81
  77. package/types/fields/Textarea.vue.d.ts +12 -81
  78. package/types/fields/Time.vue.d.ts +12 -78
  79. package/types/schema.d.ts +23 -8
  80. package/types/utils/form.d.ts +2 -1
  81. package/dist/tmagic-form.mjs.map +0 -1
  82. package/dist/tmagic-form.umd.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, openBlock, createElementBlock, normalizeStyle, normalizeClass, unref, createBlock, resolveDynamicComponent, Fragment, createVNode, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, watch, withDirectives, vShow, renderSlot, onMounted, toRefs, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
2
2
  import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
3
- import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, TMagicTabs, TMagicTabPane, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, getConfig as getConfig$1, TMagicOptionGroup, TMagicOption, TMagicSelect, TMagicSwitch, TMagicTimePicker } from '@tmagic/design';
3
+ 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
4
  import { cloneDeep } from 'lodash-es';
5
5
  import Sortable from 'sortablejs';
6
6
  import { asyncLoadJs, sleep, datetimeFormatter, isNumber } from '@tmagic/utils';
@@ -17,9 +17,9 @@ const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
17
17
  const isMultipleValue = (type) => typeof type === "string" && ["checkbox-group", "checkboxGroup", "table", "cascader", "group-list", "groupList"].includes(type);
18
18
  const initItemsValue = (mForm, value, initValue2, { items, name, extensible }) => {
19
19
  if (Array.isArray(initValue2[name])) {
20
- value[name] = initValue2[name].map((v, index) => init(mForm, items, v, value[name]?.[index]));
20
+ value[name] = initValue2[name].map((v, index) => createValues(mForm, items, v, value[name]?.[index]));
21
21
  } else {
22
- value[name] = init(mForm, items, initValue2[name], value[name]);
22
+ value[name] = createValues(mForm, items, initValue2[name], value[name]);
23
23
  if (extensible) {
24
24
  value[name] = Object.assign({}, initValue2[name], value[name]);
25
25
  }
@@ -64,12 +64,12 @@ const initValueItem = function(mForm, item, initValue2, value) {
64
64
  return names.forEach((n) => value[n] = initValue2[n] || "");
65
65
  }
66
66
  if (!name) {
67
- return init(mForm, items, initValue2, value);
67
+ return createValues(mForm, items, initValue2, value);
68
68
  }
69
69
  setValue(mForm, value, initValue2, item);
70
70
  return value;
71
71
  };
72
- const init = function(mForm, config = [], initValue2 = {}, value = {}) {
72
+ const createValues = function(mForm, config = [], initValue2 = {}, value = {}) {
73
73
  if (Array.isArray(config)) {
74
74
  config.forEach((item) => {
75
75
  initValueItem(mForm, item, initValue2, value);
@@ -156,7 +156,7 @@ const getRules = function(mForm, rules = [], props) {
156
156
  const initValue = async (mForm, { initValues, config }) => {
157
157
  if (!Array.isArray(config))
158
158
  throw new Error("config\u5E94\u8BE5\u4E3A\u6570\u7EC4");
159
- let valuesTmp = init(mForm, config, toRaw(initValues), {});
159
+ let valuesTmp = createValues(mForm, config, toRaw(initValues), {});
160
160
  const [firstForm] = config;
161
161
  if (firstForm && typeof firstForm.onInitValue === "function") {
162
162
  valuesTmp = await firstForm.onInitValue(mForm, {
@@ -175,12 +175,16 @@ const _hoisted_5$4 = {
175
175
  key: 4,
176
176
  style: { "text-align": "center" }
177
177
  };
178
+ const __default__$v = defineComponent({
179
+ name: "MFormContainer"
180
+ });
178
181
  const _sfc_main$v = /* @__PURE__ */ defineComponent({
179
- __name: "Container",
182
+ ...__default__$v,
180
183
  props: {
181
184
  model: null,
182
185
  config: null,
183
186
  prop: { default: "" },
187
+ disabled: { type: Boolean },
184
188
  labelWidth: null,
185
189
  expandMore: { type: Boolean, default: false },
186
190
  stepActive: null,
@@ -211,7 +215,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
211
215
  return component;
212
216
  return "m-fields-text";
213
217
  });
214
- const disabled = computed(() => filterFunction(mForm, props.config.disabled, props));
218
+ const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
215
219
  const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
216
220
  const extra = computed(() => filterFunction(mForm, props.config.extra, props));
217
221
  const rule = computed(() => getRules(mForm, props.config.rules, props));
@@ -308,13 +312,14 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
308
312
  size: __props.size,
309
313
  model: __props.model,
310
314
  config: __props.config,
315
+ disabled: unref(disabled),
311
316
  name: unref(name),
312
317
  prop: unref(itemProp),
313
318
  "step-active": __props.stepActive,
314
319
  "expand-more": expand.value,
315
320
  "label-width": unref(itemLabelWidth),
316
321
  onChange: onChangeHandler
317
- }, null, 40, ["size", "model", "config", "name", "prop", "step-active", "expand-more", "label-width"])) : unref(type) && unref(display$1) ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
322
+ }, null, 40, ["size", "model", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : unref(type) && unref(display$1) ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
318
323
  createVNode(unref(TMagicFormItem), {
319
324
  style: normalizeStyle(__props.config.tip ? "flex: 1" : ""),
320
325
  class: normalizeClass({ hidden: `${unref(itemLabelWidth)}` === "0" || !__props.config.text }),
@@ -389,18 +394,20 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
389
394
  model: unref(name) || unref(name) === 0 ? __props.model[unref(name)] : __props.model,
390
395
  config: item,
391
396
  size: __props.size,
397
+ disabled: unref(disabled),
392
398
  "step-active": __props.stepActive,
393
399
  "expand-more": expand.value,
394
400
  "label-width": unref(itemLabelWidth),
395
401
  prop: unref(itemProp),
396
402
  onChange: onChangeHandler
397
- }, null, 8, ["model", "config", "size", "step-active", "expand-more", "label-width", "prop"]);
403
+ }, null, 8, ["model", "config", "size", "disabled", "step-active", "expand-more", "label-width", "prop"]);
398
404
  }), 128)) : createCommentVNode("", true)
399
405
  ], 64)) : createCommentVNode("", true),
400
406
  __props.config.expand && unref(type) !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_5$4, [
401
407
  createVNode(unref(TMagicButton), {
402
408
  type: "primary",
403
409
  size: "small",
410
+ disabled: false,
404
411
  text: "",
405
412
  onClick: expandHandler
406
413
  }, {
@@ -426,15 +433,19 @@ const _hoisted_6$2 = {
426
433
  };
427
434
  const _hoisted_7$2 = { style: { "flex": "1" } };
428
435
  const _hoisted_8$1 = ["src"];
436
+ const __default__$u = defineComponent({
437
+ name: "MFormFieldset"
438
+ });
429
439
  const _sfc_main$u = /* @__PURE__ */ defineComponent({
430
- __name: "Fieldset",
440
+ ...__default__$u,
431
441
  props: {
432
442
  labelWidth: null,
433
443
  prop: { default: "" },
434
444
  size: null,
435
445
  model: null,
436
446
  config: null,
437
- rules: { default: {} }
447
+ rules: { default: {} },
448
+ disabled: { type: Boolean }
438
449
  },
439
450
  emits: ["change"],
440
451
  setup(__props, { emit }) {
@@ -513,10 +524,11 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
513
524
  rules: unref(name) ? __props.rules[unref(name)] : [],
514
525
  config: item,
515
526
  prop: __props.prop,
527
+ disabled: __props.disabled,
516
528
  labelWidth: unref(lWidth),
517
529
  size: __props.size,
518
530
  onChange: change
519
- }, null, 8, ["model", "rules", "config", "prop", "labelWidth", "size"]);
531
+ }, null, 8, ["model", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
520
532
  }), 128))
521
533
  ]),
522
534
  createElementVNode("img", {
@@ -532,8 +544,9 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
532
544
  prop: __props.prop,
533
545
  labelWidth: unref(lWidth),
534
546
  size: __props.size,
547
+ disabled: __props.disabled,
535
548
  onChange: change
536
- }, null, 8, ["model", "rules", "config", "prop", "labelWidth", "size"]);
549
+ }, null, 8, ["model", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
537
550
  }), 128)) : createCommentVNode("", true)
538
551
  ], 4)) : createCommentVNode("", true);
539
552
  };
@@ -544,8 +557,11 @@ const _hoisted_1$9 = { class: "m-fields-group-list-item" };
544
557
  const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4E0A\u79FB");
545
558
  const _hoisted_3$5 = /* @__PURE__ */ createTextVNode("\u4E0B\u79FB");
546
559
  const _hoisted_4$4 = ["innerHTML"];
560
+ const __default__$t = defineComponent({
561
+ name: "MFormGroupListItem"
562
+ });
547
563
  const _sfc_main$t = /* @__PURE__ */ defineComponent({
548
- __name: "GroupListItem",
564
+ ...__default__$t,
549
565
  props: {
550
566
  model: null,
551
567
  groupModel: null,
@@ -553,7 +569,8 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
553
569
  labelWidth: null,
554
570
  prop: null,
555
571
  size: null,
556
- index: null
572
+ index: null,
573
+ disabled: { type: Boolean }
557
574
  },
558
575
  emits: ["swap-item", "remove-item", "change"],
559
576
  setup(__props, { emit }) {
@@ -614,24 +631,27 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
614
631
  }),
615
632
  createVNode(unref(TMagicButton), {
616
633
  text: "",
634
+ disabled: __props.disabled,
617
635
  onClick: expandHandler
618
636
  }, {
619
637
  default: withCtx(() => [
620
638
  createTextVNode(toDisplayString(unref(title)), 1)
621
639
  ]),
622
640
  _: 1
623
- }),
641
+ }, 8, ["disabled"]),
624
642
  withDirectives(createVNode(unref(TMagicButton), {
643
+ style: { "color": "#f56c6c" },
625
644
  text: "",
626
645
  icon: unref(Delete),
627
- style: { "color": "#f56c6c" },
646
+ disabled: __props.disabled,
628
647
  onClick: removeHandler
629
- }, null, 8, ["icon"]), [
648
+ }, null, 8, ["icon", "disabled"]), [
630
649
  [vShow, showDelete(parseInt(String(__props.index)))]
631
650
  ]),
632
651
  movable() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
633
652
  withDirectives(createVNode(unref(TMagicButton), {
634
653
  text: "",
654
+ disabled: __props.disabled,
635
655
  size: "small",
636
656
  onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
637
657
  }, {
@@ -645,10 +665,11 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
645
665
  })
646
666
  ]),
647
667
  _: 1
648
- }, 512), [
668
+ }, 8, ["disabled"]), [
649
669
  [vShow, __props.index !== 0]
650
670
  ]),
651
671
  withDirectives(createVNode(unref(TMagicButton), {
672
+ disabled: __props.disabled,
652
673
  text: "",
653
674
  size: "small",
654
675
  onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
@@ -663,7 +684,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
663
684
  })
664
685
  ]),
665
686
  _: 1
666
- }, 512), [
687
+ }, 8, ["disabled"]), [
667
688
  [vShow, __props.index !== unref(length) - 1]
668
689
  ])
669
690
  ], 64)) : createCommentVNode("", true),
@@ -680,8 +701,9 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
680
701
  labelWidth: __props.labelWidth,
681
702
  prop: `${__props.prop}${__props.prop ? "." : ""}${String(__props.index)}`,
682
703
  size: __props.size,
704
+ disabled: __props.disabled,
683
705
  onChange: changeHandler
684
- }, null, 8, ["config", "model", "labelWidth", "prop", "size"])) : createCommentVNode("", true)
706
+ }, null, 8, ["config", "model", "labelWidth", "prop", "size", "disabled"])) : createCommentVNode("", true)
685
707
  ]);
686
708
  };
687
709
  }
@@ -699,15 +721,19 @@ const _hoisted_5$2 = [
699
721
  ];
700
722
  const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0\u7EC4");
701
723
  const _hoisted_7$1 = /* @__PURE__ */ createTextVNode("\u5207\u6362\u4E3A\u8868\u683C");
724
+ const __default__$s = defineComponent({
725
+ name: "MFormGroupList"
726
+ });
702
727
  const _sfc_main$s = /* @__PURE__ */ defineComponent({
703
- __name: "GroupList",
728
+ ...__default__$s,
704
729
  props: {
705
730
  model: null,
706
731
  config: null,
707
732
  name: null,
708
733
  labelWidth: null,
709
734
  prop: null,
710
- size: null
735
+ size: null,
736
+ disabled: { type: Boolean }
711
737
  },
712
738
  emits: ["change"],
713
739
  setup(__props, { emit }) {
@@ -789,22 +815,24 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
789
815
  index,
790
816
  "label-width": __props.labelWidth,
791
817
  size: __props.size,
818
+ disabled: __props.disabled,
792
819
  "group-model": __props.model[__props.name],
793
820
  onRemoveItem: removeHandler,
794
821
  onSwapItem: swapHandler,
795
822
  onChange: changeHandler
796
- }, null, 8, ["model", "config", "prop", "index", "label-width", "size", "group-model"]);
823
+ }, null, 8, ["model", "config", "prop", "index", "label-width", "size", "disabled", "group-model"]);
797
824
  }), 128)),
798
825
  unref(addable) ? (openBlock(), createBlock(unref(TMagicButton), {
799
826
  key: 3,
800
827
  onClick: addHandler,
801
- size: "small"
828
+ size: "small",
829
+ disabled: __props.disabled
802
830
  }, {
803
831
  default: withCtx(() => [
804
832
  _hoisted_6$1
805
833
  ]),
806
834
  _: 1
807
- })) : createCommentVNode("", true),
835
+ }, 8, ["disabled"])) : createCommentVNode("", true),
808
836
  __props.config.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
809
837
  key: 4,
810
838
  icon: unref(Grid),
@@ -829,15 +857,19 @@ const _hoisted_3$3 = {
829
857
  };
830
858
  const _hoisted_4$2 = { style: { "flex": "1" } };
831
859
  const _hoisted_5$1 = ["src"];
860
+ const __default__$r = defineComponent({
861
+ name: "MFormPanel"
862
+ });
832
863
  const _sfc_main$r = /* @__PURE__ */ defineComponent({
833
- __name: "Panel",
864
+ ...__default__$r,
834
865
  props: {
835
866
  model: null,
836
867
  config: null,
837
868
  name: null,
838
869
  labelWidth: null,
839
870
  prop: null,
840
- size: null
871
+ size: null,
872
+ disabled: { type: Boolean }
841
873
  },
842
874
  emits: ["change"],
843
875
  setup(__props, { emit }) {
@@ -887,9 +919,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
887
919
  model: __props.name ? __props.model[__props.name] : __props.model,
888
920
  prop: __props.prop,
889
921
  size: __props.size,
922
+ disabled: __props.disabled,
890
923
  "label-width": __props.config.labelWidth || __props.labelWidth,
891
924
  onChange: changeHandler
892
- }, null, 8, ["config", "model", "prop", "size", "label-width"]);
925
+ }, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"]);
893
926
  }), 128))
894
927
  ]),
895
928
  createElementVNode("img", {
@@ -903,9 +936,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
903
936
  model: __props.name ? __props.model[__props.name] : __props.model,
904
937
  prop: __props.prop,
905
938
  size: __props.size,
939
+ disabled: __props.disabled,
906
940
  "label-width": __props.config.labelWidth || __props.labelWidth,
907
941
  onChange: changeHandler
908
- }, null, 8, ["config", "model", "prop", "size", "label-width"]);
942
+ }, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"]);
909
943
  }), 128))
910
944
  ])
911
945
  ]),
@@ -915,8 +949,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
915
949
  }
916
950
  });
917
951
 
952
+ const __default__$q = defineComponent({
953
+ name: "MFormCol"
954
+ });
918
955
  const _sfc_main$q = /* @__PURE__ */ defineComponent({
919
- __name: "Col",
956
+ ...__default__$q,
920
957
  props: {
921
958
  model: null,
922
959
  config: null,
@@ -924,7 +961,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
924
961
  expandMore: { type: Boolean },
925
962
  span: null,
926
963
  size: null,
927
- prop: null
964
+ prop: null,
965
+ disabled: { type: Boolean }
928
966
  },
929
967
  emits: ["change"],
930
968
  setup(__props, { emit }) {
@@ -942,8 +980,9 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
942
980
  "label-width": __props.config.labelWidth || __props.labelWidth,
943
981
  "expand-more": __props.expandMore,
944
982
  size: __props.size,
983
+ disabled: __props.disabled,
945
984
  onChange: changeHandler
946
- }, null, 8, ["model", "config", "prop", "label-width", "expand-more", "size"])
985
+ }, null, 8, ["model", "config", "prop", "label-width", "expand-more", "size", "disabled"])
947
986
  ]),
948
987
  _: 1
949
988
  }, 8, ["span"])), [
@@ -953,8 +992,11 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
953
992
  }
954
993
  });
955
994
 
995
+ const __default__$p = defineComponent({
996
+ name: "MFormRow"
997
+ });
956
998
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
957
- __name: "Row",
999
+ ...__default__$p,
958
1000
  props: {
959
1001
  model: null,
960
1002
  config: null,
@@ -962,7 +1004,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
962
1004
  labelWidth: null,
963
1005
  prop: null,
964
1006
  size: null,
965
- expandMore: { type: Boolean }
1007
+ expandMore: { type: Boolean },
1008
+ disabled: { type: Boolean }
966
1009
  },
967
1010
  emits: ["change"],
968
1011
  setup(__props, { emit }) {
@@ -982,8 +1025,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
982
1025
  model: __props.name ? __props.model[__props.name] : __props.model,
983
1026
  prop: __props.prop,
984
1027
  size: __props.size,
1028
+ disabled: __props.disabled,
985
1029
  onChange: changeHandler
986
- }, null, 8, ["span", "config", "labelWidth", "expandMore", "model", "prop", "size"]);
1030
+ }, null, 8, ["span", "config", "labelWidth", "expandMore", "model", "prop", "size", "disabled"]);
987
1031
  }), 128))
988
1032
  ]),
989
1033
  _: 1
@@ -992,14 +1036,18 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
992
1036
  }
993
1037
  });
994
1038
 
1039
+ const __default__$o = defineComponent({
1040
+ name: "MFormStep"
1041
+ });
995
1042
  const _sfc_main$o = /* @__PURE__ */ defineComponent({
996
- __name: "Step",
1043
+ ...__default__$o,
997
1044
  props: {
998
1045
  model: null,
999
1046
  config: null,
1000
1047
  stepActive: { default: 1 },
1001
1048
  labelWidth: null,
1002
- size: null
1049
+ size: null,
1050
+ disabled: { type: Boolean }
1003
1051
  },
1004
1052
  emits: ["change"],
1005
1053
  setup(__props, { emit }) {
@@ -1045,9 +1093,10 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
1045
1093
  model: step.name ? __props.model[step.name] : __props.model,
1046
1094
  prop: `${step.name}`,
1047
1095
  size: __props.size,
1096
+ disabled: __props.disabled,
1048
1097
  "label-width": __props.config.labelWidth || __props.labelWidth,
1049
1098
  onChange: changeHandler
1050
- }, null, 8, ["config", "model", "prop", "size", "label-width"])), [
1099
+ }, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"])), [
1051
1100
  [vShow, active.value - 1 === index]
1052
1101
  ]) : createCommentVNode("", true)
1053
1102
  ], 64);
@@ -1069,11 +1118,15 @@ const _hoisted_7 = /* @__PURE__ */ createTextVNode("\u5BFC\u5165EXCEL");
1069
1118
  const _hoisted_8 = /* @__PURE__ */ createTextVNode("\xA0 ");
1070
1119
  const _hoisted_9 = /* @__PURE__ */ createTextVNode("\u6E05\u7A7A");
1071
1120
  const _hoisted_10 = {
1121
+ key: 1,
1072
1122
  class: "bottom",
1073
1123
  style: { "text-align": "right" }
1074
1124
  };
1125
+ const __default__$n = defineComponent({
1126
+ name: "MFormTable"
1127
+ });
1075
1128
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
1076
- __name: "Table",
1129
+ ...__default__$n,
1077
1130
  props: {
1078
1131
  model: null,
1079
1132
  config: null,
@@ -1081,6 +1134,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1081
1134
  prop: { default: "" },
1082
1135
  labelWidth: null,
1083
1136
  sort: { type: Boolean },
1137
+ disabled: { type: Boolean },
1084
1138
  sortKey: { default: "" },
1085
1139
  text: null,
1086
1140
  size: null,
@@ -1100,6 +1154,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1100
1154
  const updateKey = ref(1);
1101
1155
  const isFullscreen = ref(false);
1102
1156
  const modelName = computed(() => props.name || props.config.name || "");
1157
+ const data = computed(
1158
+ () => props.config.pagination ? props.model[modelName.value].filter(
1159
+ (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1160
+ ) : props.model[modelName.value]
1161
+ );
1103
1162
  const sortChange = ({ prop, order }) => {
1104
1163
  if (order === "ascending") {
1105
1164
  props.model[modelName.value] = props.model[modelName.value].sort((a, b) => a[prop] - b[prop]);
@@ -1125,10 +1184,10 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1125
1184
  mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1126
1185
  };
1127
1186
  const rowDrop = () => {
1128
- const tableEl = tMagicTable.value?.$el;
1129
- if (tableEl?.querySelectorAll(".el-table__body > tbody")) {
1130
- const el = tableEl.querySelectorAll(".el-table__body > tbody")[0];
1131
- const sortable = Sortable.create(el, {
1187
+ const tableEl = tMagicTable.value?.instance.$el;
1188
+ const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
1189
+ if (tBodyEl) {
1190
+ const sortable = Sortable.create(tBodyEl, {
1132
1191
  onEnd: ({ newIndex, oldIndex }) => {
1133
1192
  if (typeof newIndex === "undefined")
1134
1193
  return;
@@ -1140,11 +1199,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1140
1199
  sortable.destroy();
1141
1200
  mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1142
1201
  sleep(1e3).then(() => {
1143
- const eltrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
1144
- if (eltrs?.[newIndex]) {
1145
- eltrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
1202
+ const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
1203
+ if (elTrs?.[newIndex]) {
1204
+ elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
1146
1205
  sleep(1e3).then(() => {
1147
- eltrs[newIndex].style.backgroundColor = "";
1206
+ elTrs[newIndex].style.backgroundColor = "";
1148
1207
  });
1149
1208
  }
1150
1209
  });
@@ -1215,6 +1274,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1215
1274
  if (props.sort && props.sortKey) {
1216
1275
  props.model[modelName.value].sort((a, b) => b[props.sortKey] - a[props.sortKey]);
1217
1276
  }
1277
+ });
1278
+ watchEffect(() => {
1218
1279
  if (props.config.dropSort) {
1219
1280
  rowDrop();
1220
1281
  }
@@ -1261,6 +1322,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1261
1322
  return fuc;
1262
1323
  };
1263
1324
  const removeHandler = (index) => {
1325
+ if (props.disabled)
1326
+ return;
1264
1327
  props.model[modelName.value].splice(index, 1);
1265
1328
  emit("change", props.model[modelName.value]);
1266
1329
  };
@@ -1277,8 +1340,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1277
1340
  const toggleRowSelection = (row, selected) => {
1278
1341
  tMagicTable.value?.toggleRowSelection.call(tMagicTable.value, row, selected);
1279
1342
  };
1280
- const makeConfig = (config) => {
1343
+ const makeConfig = (config, row) => {
1281
1344
  const newConfig = cloneDeep(config);
1345
+ if (typeof config.itemsFunction === "function") {
1346
+ newConfig.items = config.itemsFunction(row);
1347
+ }
1282
1348
  delete newConfig.display;
1283
1349
  return newConfig;
1284
1350
  };
@@ -1336,8 +1402,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1336
1402
  }
1337
1403
  const reader = new FileReader();
1338
1404
  reader.onload = () => {
1339
- const data = reader.result;
1340
- const pdata = globalThis.XLSX.read(data, { type: "array" });
1405
+ const data2 = reader.result;
1406
+ const pdata = globalThis.XLSX.read(data2, { type: "array" });
1341
1407
  pdata.SheetNames.forEach((sheetName) => {
1342
1408
  const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
1343
1409
  if (arr?.[0]) {
@@ -1419,7 +1485,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1419
1485
  ref_key: "tMagicTable",
1420
1486
  ref: tMagicTable,
1421
1487
  style: { "width": "100%" },
1422
- data: __props.model[unref(modelName)],
1488
+ "row-key": __props.config.rowKey || "id",
1489
+ data: unref(data),
1423
1490
  border: __props.config.border,
1424
1491
  "max-height": __props.config.maxHeight,
1425
1492
  "default-expand-all": true,
@@ -1444,11 +1511,12 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1444
1511
  })) : createCommentVNode("", true),
1445
1512
  createVNode(unref(TMagicTableColumn), {
1446
1513
  label: "\u64CD\u4F5C",
1447
- width: "55",
1514
+ width: __props.config.operateColWidth || 55,
1448
1515
  align: "center",
1449
1516
  fixed: __props.config.fixed === false ? void 0 : "left"
1450
1517
  }, {
1451
1518
  default: withCtx((scope) => [
1519
+ renderSlot(_ctx.$slots, "operateCol", { scope }),
1452
1520
  withDirectives(createVNode(unref(TMagicIcon), {
1453
1521
  class: "m-table-delete-icon",
1454
1522
  onClick: ($event) => removeHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
@@ -1461,8 +1529,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1461
1529
  [vShow, showDelete(scope.$index + 1 + pagecontext.value * pagesize.value - 1)]
1462
1530
  ])
1463
1531
  ]),
1464
- _: 1
1465
- }, 8, ["fixed"]),
1532
+ _: 3
1533
+ }, 8, ["width", "fixed"]),
1466
1534
  __props.sort && __props.model[unref(modelName)] && __props.model[unref(modelName)].length > 1 ? (openBlock(), createBlock(unref(TMagicTableColumn), {
1467
1535
  key: 1,
1468
1536
  label: "\u6392\u5E8F",
@@ -1480,10 +1548,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1480
1548
  size: "small",
1481
1549
  type: "primary",
1482
1550
  icon: unref(ArrowUp),
1551
+ disabled: __props.disabled,
1483
1552
  text: "",
1484
1553
  onClick: ($event) => upHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
1485
1554
  onDblclick: ($event) => topHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
1486
- }, null, 8, ["icon", "onClick", "onDblclick"])
1555
+ }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
1487
1556
  ]),
1488
1557
  _: 2
1489
1558
  }, 1024)) : createCommentVNode("", true),
@@ -1498,10 +1567,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1498
1567
  size: "small",
1499
1568
  type: "primary",
1500
1569
  icon: unref(ArrowDown),
1570
+ disabled: __props.disabled,
1501
1571
  text: "",
1502
1572
  onClick: ($event) => downHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
1503
1573
  onDblclick: ($event) => bottomHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
1504
- }, null, 8, ["icon", "onClick", "onDblclick"])
1574
+ }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
1505
1575
  ]),
1506
1576
  _: 2
1507
1577
  }, 1024)) : createCommentVNode("", true)
@@ -1540,29 +1610,31 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1540
1610
  scope.$index > -1 ? (openBlock(), createBlock(_sfc_main$v, {
1541
1611
  key: 0,
1542
1612
  labelWidth: "0",
1613
+ disabled: __props.disabled,
1543
1614
  prop: getProp(scope.$index),
1544
1615
  rules: column.rules,
1545
- config: makeConfig(column),
1616
+ config: makeConfig(column, scope.row),
1546
1617
  model: scope.row,
1547
1618
  size: __props.size,
1548
1619
  onChange: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("change", __props.model[unref(modelName)]))
1549
- }, null, 8, ["prop", "rules", "config", "model", "size"])) : createCommentVNode("", true)
1620
+ }, null, 8, ["disabled", "prop", "rules", "config", "model", "size"])) : createCommentVNode("", true)
1550
1621
  ]),
1551
1622
  _: 2
1552
1623
  }, 1032, ["prop", "width", "label", "sortable", "class-name"])) : createCommentVNode("", true)
1553
1624
  ], 64);
1554
1625
  }), 256))
1555
1626
  ]),
1556
- _: 1
1557
- }, 8, ["data", "border", "max-height"])) : createCommentVNode("", true)
1627
+ _: 3
1628
+ }, 8, ["row-key", "data", "border", "max-height"])) : createCommentVNode("", true)
1558
1629
  ]),
1559
- _: 1
1630
+ _: 3
1560
1631
  }, 8, ["disabled"]),
1561
1632
  renderSlot(_ctx.$slots, "default"),
1562
1633
  unref(addable) ? (openBlock(), createBlock(unref(TMagicButton), {
1563
1634
  key: 0,
1564
1635
  size: "small",
1565
1636
  type: "primary",
1637
+ disabled: __props.disabled,
1566
1638
  plain: "",
1567
1639
  onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
1568
1640
  }, {
@@ -1570,7 +1642,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1570
1642
  _hoisted_4$1
1571
1643
  ]),
1572
1644
  _: 1
1573
- })) : createCommentVNode("", true),
1645
+ }, 8, ["disabled"])) : createCommentVNode("", true),
1574
1646
  _hoisted_5,
1575
1647
  __props.enableToggleMode && !isFullscreen.value ? (openBlock(), createBlock(unref(TMagicButton), {
1576
1648
  key: 1,
@@ -1598,32 +1670,35 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1598
1670
  }, 8, ["icon"])) : createCommentVNode("", true),
1599
1671
  unref(importable) ? (openBlock(), createBlock(unref(TMagicUpload), {
1600
1672
  key: 3,
1673
+ style: { "display": "inline-block" },
1601
1674
  ref_key: "excelBtn",
1602
1675
  ref: excelBtn,
1603
1676
  action: "/noop",
1677
+ disabled: __props.disabled,
1604
1678
  "on-change": excelHandler,
1605
- "auto-upload": false,
1606
- style: { "display": "inline-block" }
1679
+ "auto-upload": false
1607
1680
  }, {
1608
1681
  default: withCtx(() => [
1609
1682
  createVNode(unref(TMagicButton), {
1610
1683
  size: "small",
1611
1684
  type: "success",
1685
+ disabled: __props.disabled,
1612
1686
  plain: ""
1613
1687
  }, {
1614
1688
  default: withCtx(() => [
1615
1689
  _hoisted_7
1616
1690
  ]),
1617
1691
  _: 1
1618
- })
1692
+ }, 8, ["disabled"])
1619
1693
  ]),
1620
1694
  _: 1
1621
- }, 512)) : createCommentVNode("", true),
1695
+ }, 8, ["disabled"])) : createCommentVNode("", true),
1622
1696
  _hoisted_8,
1623
1697
  unref(importable) ? (openBlock(), createBlock(unref(TMagicButton), {
1624
1698
  key: 4,
1625
1699
  size: "small",
1626
1700
  type: "warning",
1701
+ disabled: __props.disabled,
1627
1702
  plain: "",
1628
1703
  onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
1629
1704
  }, {
@@ -1631,9 +1706,9 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1631
1706
  _hoisted_9
1632
1707
  ]),
1633
1708
  _: 1
1634
- })) : createCommentVNode("", true)
1709
+ }, 8, ["disabled"])) : createCommentVNode("", true)
1635
1710
  ]),
1636
- createElementVNode("div", _hoisted_10, [
1711
+ __props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_10, [
1637
1712
  createVNode(unref(TMagicPagination), {
1638
1713
  layout: "total, sizes, prev, pager, next, jumper",
1639
1714
  "hide-on-single-page": __props.model[unref(modelName)].length < pagesize.value,
@@ -1644,14 +1719,17 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
1644
1719
  onSizeChange: handleSizeChange,
1645
1720
  onCurrentChange: handleCurrentChange
1646
1721
  }, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total"])
1647
- ])
1722
+ ])) : createCommentVNode("", true)
1648
1723
  ], 2);
1649
1724
  };
1650
1725
  }
1651
1726
  });
1652
1727
 
1728
+ const __default__$m = defineComponent({
1729
+ name: "MFormTabs"
1730
+ });
1653
1731
  const _sfc_main$m = /* @__PURE__ */ defineComponent({
1654
- __name: "Tabs",
1732
+ ...__default__$m,
1655
1733
  props: {
1656
1734
  model: null,
1657
1735
  config: null,
@@ -1659,11 +1737,13 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
1659
1737
  size: null,
1660
1738
  labelWidth: null,
1661
1739
  prop: null,
1662
- expandMore: { type: Boolean }
1740
+ expandMore: { type: Boolean },
1741
+ disabled: { type: Boolean }
1663
1742
  },
1664
1743
  emits: ["change"],
1665
1744
  setup(__props, { emit }) {
1666
1745
  const props = __props;
1746
+ const uiComponent = getConfig$1("components").tabPane;
1667
1747
  const getActive = (mForm2, props2, activeTabName2) => {
1668
1748
  const { config, model, prop } = props2;
1669
1749
  const { active } = config;
@@ -1765,7 +1845,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
1765
1845
  default: withCtx(() => [
1766
1846
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(tabs), (tab, tabIndex) => {
1767
1847
  return openBlock(), createElementBlock(Fragment, null, [
1768
- display$1(tab.display) && tabItems(tab).length ? (openBlock(), createBlock(unref(TMagicTabPane), {
1848
+ display$1(tab.display) && tabItems(tab).length ? (openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
1769
1849
  key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex,
1770
1850
  name: filter(tab.status) || tabIndex.toString(),
1771
1851
  label: filter(tab.title),
@@ -1776,13 +1856,14 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
1776
1856
  return openBlock(), createBlock(_sfc_main$v, {
1777
1857
  key: item[unref(mForm)?.keyProp || "__key"],
1778
1858
  config: item,
1859
+ disabled: __props.disabled,
1779
1860
  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,
1780
1861
  prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
1781
1862
  size: __props.size,
1782
1863
  "label-width": tab.labelWidth || __props.labelWidth,
1783
1864
  "expand-more": __props.expandMore,
1784
1865
  onChange: changeHandler
1785
- }, null, 8, ["config", "model", "prop", "size", "label-width", "expand-more"]);
1866
+ }, null, 8, ["config", "disabled", "model", "prop", "size", "label-width", "expand-more"]);
1786
1867
  }), 128))
1787
1868
  ]),
1788
1869
  _: 2
@@ -1822,8 +1903,11 @@ const useAddField = (prop) => {
1822
1903
  );
1823
1904
  };
1824
1905
 
1906
+ const __default__$l = defineComponent({
1907
+ name: "MFormCascader"
1908
+ });
1825
1909
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
1826
- __name: "Cascader",
1910
+ ...__default__$l,
1827
1911
  props: {
1828
1912
  config: null,
1829
1913
  model: null,
@@ -1906,8 +1990,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
1906
1990
  }
1907
1991
  });
1908
1992
 
1993
+ const __default__$k = defineComponent({
1994
+ name: "MFormCheckbox"
1995
+ });
1909
1996
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
1910
- __name: "Checkbox",
1997
+ ...__default__$k,
1911
1998
  props: {
1912
1999
  config: null,
1913
2000
  model: null,
@@ -1964,8 +2051,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1964
2051
  }
1965
2052
  });
1966
2053
 
2054
+ const __default__$j = defineComponent({
2055
+ name: "MFormCheckGroup"
2056
+ });
1967
2057
  const _sfc_main$j = /* @__PURE__ */ defineComponent({
1968
- __name: "CheckboxGroup",
2058
+ ...__default__$j,
1969
2059
  props: {
1970
2060
  config: null,
1971
2061
  model: null,
@@ -2006,6 +2096,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2006
2096
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(options), (option) => {
2007
2097
  return openBlock(), createBlock(unref(TMagicCheckbox), {
2008
2098
  label: option.value,
2099
+ value: option.value,
2009
2100
  key: option.value,
2010
2101
  disabled: option.disabled
2011
2102
  }, {
@@ -2013,7 +2104,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2013
2104
  createTextVNode(toDisplayString(option.text), 1)
2014
2105
  ]),
2015
2106
  _: 2
2016
- }, 1032, ["label", "disabled"]);
2107
+ }, 1032, ["label", "value", "disabled"]);
2017
2108
  }), 128))
2018
2109
  ]),
2019
2110
  _: 1
@@ -2022,8 +2113,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2022
2113
  }
2023
2114
  });
2024
2115
 
2116
+ const __default__$i = defineComponent({
2117
+ name: "MFormColorPicker"
2118
+ });
2025
2119
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
2026
- __name: "ColorPicker",
2120
+ ...__default__$i,
2027
2121
  props: {
2028
2122
  config: null,
2029
2123
  model: null,
@@ -2052,8 +2146,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2052
2146
  }
2053
2147
  });
2054
2148
 
2149
+ const __default__$h = defineComponent({
2150
+ name: "MFormDate"
2151
+ });
2055
2152
  const _sfc_main$h = /* @__PURE__ */ defineComponent({
2056
- __name: "Date",
2153
+ ...__default__$h,
2057
2154
  props: {
2058
2155
  config: null,
2059
2156
  model: null,
@@ -2081,15 +2178,18 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2081
2178
  placeholder: __props.config.placeholder,
2082
2179
  disabled: __props.disabled,
2083
2180
  format: __props.config.format,
2084
- "value-format": __props.config.format || "YYYY-MM-DD HH:mm:ss",
2181
+ "value-format": __props.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
2085
2182
  onChange: changeHandler
2086
2183
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
2087
2184
  };
2088
2185
  }
2089
2186
  });
2090
2187
 
2188
+ const __default__$g = defineComponent({
2189
+ name: "MFormDateRange"
2190
+ });
2091
2191
  const _sfc_main$g = /* @__PURE__ */ defineComponent({
2092
- __name: "Daterange",
2192
+ ...__default__$g,
2093
2193
  props: {
2094
2194
  config: null,
2095
2195
  model: null,
@@ -2186,8 +2286,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2186
2286
  }
2187
2287
  });
2188
2288
 
2289
+ const __default__$f = defineComponent({
2290
+ name: "MFormDateTime"
2291
+ });
2189
2292
  const _sfc_main$f = /* @__PURE__ */ defineComponent({
2190
- __name: "DateTime",
2293
+ ...__default__$f,
2191
2294
  props: {
2192
2295
  config: null,
2193
2296
  model: null,
@@ -2232,8 +2335,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2232
2335
  });
2233
2336
 
2234
2337
  const _hoisted_1$5 = { key: 0 };
2338
+ const __default__$e = defineComponent({
2339
+ name: "MFormDisplay"
2340
+ });
2235
2341
  const _sfc_main$e = /* @__PURE__ */ defineComponent({
2236
- __name: "Display",
2342
+ ...__default__$e,
2237
2343
  props: {
2238
2344
  config: null,
2239
2345
  model: null,
@@ -2255,8 +2361,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2255
2361
  });
2256
2362
 
2257
2363
  const _hoisted_1$4 = { class: "m-fields-dynamic-field" };
2364
+ const __default__$d = defineComponent({
2365
+ name: "MFormDynamicField"
2366
+ });
2258
2367
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
2259
- __name: "DynamicField",
2368
+ ...__default__$d,
2260
2369
  props: {
2261
2370
  config: null,
2262
2371
  model: null,
@@ -2343,8 +2452,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2343
2452
  }
2344
2453
  });
2345
2454
 
2455
+ const __default__$c = defineComponent({
2456
+ name: "MFormHidden"
2457
+ });
2346
2458
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
2347
- __name: "Hidden",
2459
+ ...__default__$c,
2348
2460
  props: {
2349
2461
  config: null,
2350
2462
  model: null,
@@ -2368,8 +2480,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2368
2480
  }
2369
2481
  });
2370
2482
 
2483
+ const __default__$b = defineComponent({
2484
+ name: "MForm"
2485
+ });
2371
2486
  const _sfc_main$b = /* @__PURE__ */ defineComponent({
2372
- __name: "Form",
2487
+ ...__default__$b,
2373
2488
  props: {
2374
2489
  config: { default: () => [] },
2375
2490
  initValues: { default: () => ({}) },
@@ -2473,7 +2588,6 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2473
2588
  ref: tMagicForm,
2474
2589
  model: values.value,
2475
2590
  "label-width": __props.labelWidth,
2476
- disabled: __props.disabled,
2477
2591
  style: normalizeStyle(`height: ${__props.height}`),
2478
2592
  inline: __props.inline,
2479
2593
  "label-position": __props.labelPosition
@@ -2481,6 +2595,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2481
2595
  default: withCtx(() => [
2482
2596
  initialized.value && Array.isArray(__props.config) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(__props.config, (item, index) => {
2483
2597
  return openBlock(), createBlock(_sfc_main$v, {
2598
+ disabled: __props.disabled,
2484
2599
  key: item[__props.keyProp] ?? index,
2485
2600
  config: item,
2486
2601
  model: values.value,
@@ -2488,11 +2603,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2488
2603
  "step-active": __props.stepActive,
2489
2604
  size: __props.size,
2490
2605
  onChange: changeHandler
2491
- }, null, 8, ["config", "model", "label-width", "step-active", "size"]);
2606
+ }, null, 8, ["disabled", "config", "model", "label-width", "step-active", "size"]);
2492
2607
  }), 128)) : createCommentVNode("", true)
2493
2608
  ]),
2494
2609
  _: 1
2495
- }, 8, ["model", "label-width", "disabled", "style", "inline", "label-position"]);
2610
+ }, 8, ["model", "label-width", "style", "inline", "label-position"]);
2496
2611
  };
2497
2612
  }
2498
2613
  });
@@ -2501,8 +2616,11 @@ const _hoisted_1$3 = { style: { "min-height": "1px" } };
2501
2616
  const _hoisted_2$1 = /* @__PURE__ */ createTextVNode("\u53D6 \u6D88");
2502
2617
  const _hoisted_3$1 = /* @__PURE__ */ createTextVNode("\u4E0A\u4E00\u6B65");
2503
2618
  const _hoisted_4 = /* @__PURE__ */ createTextVNode("\u4E0B\u4E00\u6B65");
2619
+ const __default__$a = defineComponent({
2620
+ name: "MFormDialog"
2621
+ });
2504
2622
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
2505
- __name: "FormDialog",
2623
+ ...__default__$a,
2506
2624
  props: {
2507
2625
  config: { default: () => [] },
2508
2626
  values: { default: () => ({}) },
@@ -2510,6 +2628,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2510
2628
  width: null,
2511
2629
  labelWidth: null,
2512
2630
  fullscreen: { type: Boolean },
2631
+ disabled: { type: Boolean },
2513
2632
  title: null,
2514
2633
  zIndex: null,
2515
2634
  size: null,
@@ -2665,12 +2784,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2665
2784
  ref_key: "form",
2666
2785
  ref: form,
2667
2786
  size: __props.size,
2787
+ disabled: __props.disabled,
2668
2788
  config: __props.config,
2669
2789
  "init-values": __props.values,
2670
2790
  "parent-values": __props.parentValues,
2671
2791
  "label-width": __props.labelWidth,
2672
2792
  onChange: changeHandler
2673
- }, null, 8, ["modelValue", "size", "config", "init-values", "parent-values", "label-width"]),
2793
+ }, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width"]),
2674
2794
  renderSlot(_ctx.$slots, "default")
2675
2795
  ], 4)) : createCommentVNode("", true)
2676
2796
  ]),
@@ -2686,8 +2806,11 @@ const _hoisted_2 = {
2686
2806
  class: "m-fields-link"
2687
2807
  };
2688
2808
  const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u70B9\u51FB\u7F16\u8F91");
2809
+ const __default__$9 = defineComponent({
2810
+ name: "MFormLink"
2811
+ });
2689
2812
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2690
- __name: "Link",
2813
+ ...__default__$9,
2691
2814
  props: {
2692
2815
  config: null,
2693
2816
  model: null,
@@ -2780,8 +2903,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2780
2903
  }
2781
2904
  });
2782
2905
 
2906
+ const __default__$8 = defineComponent({
2907
+ name: "MFormNumber"
2908
+ });
2783
2909
  const _sfc_main$8 = /* @__PURE__ */ defineComponent({
2784
- __name: "Number",
2910
+ ...__default__$8,
2785
2911
  props: {
2786
2912
  config: null,
2787
2913
  model: null,
@@ -2824,8 +2950,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
2824
2950
  }
2825
2951
  });
2826
2952
 
2953
+ const __default__$7 = defineComponent({
2954
+ name: "MFormRadioGroup"
2955
+ });
2827
2956
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2828
- __name: "RadioGroup",
2957
+ ...__default__$7,
2829
2958
  props: {
2830
2959
  config: null,
2831
2960
  model: null,
@@ -2856,13 +2985,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2856
2985
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.options, (option) => {
2857
2986
  return openBlock(), createBlock(unref(TMagicRadio), {
2858
2987
  label: option.value,
2988
+ value: option.value,
2859
2989
  key: `${option.value}`
2860
2990
  }, {
2861
2991
  default: withCtx(() => [
2862
2992
  createTextVNode(toDisplayString(option.text), 1)
2863
2993
  ]),
2864
2994
  _: 2
2865
- }, 1032, ["label"]);
2995
+ }, 1032, ["label", "value"]);
2866
2996
  }), 128))
2867
2997
  ]),
2868
2998
  _: 1
@@ -2871,8 +3001,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2871
3001
  }
2872
3002
  });
2873
3003
 
3004
+ const __default__$6 = defineComponent({
3005
+ name: "MFormSelectOptionGroups"
3006
+ });
2874
3007
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
2875
- __name: "SelectOptionGroups",
3008
+ ...__default__$6,
2876
3009
  props: {
2877
3010
  options: null
2878
3011
  },
@@ -2902,8 +3035,11 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
2902
3035
  }
2903
3036
  });
2904
3037
 
3038
+ const __default__$5 = defineComponent({
3039
+ name: "MFormSelectOptions"
3040
+ });
2905
3041
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2906
- __name: "SelectOptions",
3042
+ ...__default__$5,
2907
3043
  props: {
2908
3044
  options: null,
2909
3045
  valueKey: null
@@ -2923,8 +3059,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2923
3059
  });
2924
3060
 
2925
3061
  const _hoisted_1$1 = { key: 2 };
3062
+ const __default__$4 = defineComponent({
3063
+ name: "MFormSelect"
3064
+ });
2926
3065
  const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2927
- __name: "Select",
3066
+ ...__default__$4,
2928
3067
  props: {
2929
3068
  config: null,
2930
3069
  model: null,
@@ -2979,30 +3118,32 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2979
3118
  let items = [];
2980
3119
  const { config } = props;
2981
3120
  const { option } = config;
2982
- let { body } = option;
3121
+ const { root = "", totalKey = "total" } = option;
3122
+ let { body = {}, url } = option;
3123
+ if (typeof url === "function") {
3124
+ url = await url(mForm, { model: props.model, formValue: mForm?.values });
3125
+ }
2983
3126
  let postOptions = {
2984
3127
  method: option.method || "POST",
2985
- url: option.url,
3128
+ url,
2986
3129
  cache: option.cache,
2987
3130
  timeout: option.timeout,
2988
3131
  mode: option.mode,
2989
3132
  headers: option.headers || {},
2990
3133
  json: option.json || false
2991
3134
  };
2992
- if (body) {
2993
- if (typeof body === "function") {
2994
- body = body(mForm, {
2995
- model: props.model,
2996
- formValue: mForm?.values,
2997
- formValues: mForm?.values,
2998
- config: props.config
2999
- });
3000
- }
3001
- body.query = query.value;
3002
- body.pgSize = pgSize.value;
3003
- body.pgIndex = pgIndex.value;
3004
- postOptions.data = body;
3135
+ if (typeof body === "function") {
3136
+ body = body(mForm, {
3137
+ model: props.model,
3138
+ formValue: mForm?.values,
3139
+ formValues: mForm?.values,
3140
+ config: props.config
3141
+ });
3005
3142
  }
3143
+ body.query = query.value;
3144
+ body.pgSize = pgSize.value;
3145
+ body.pgIndex = pgIndex.value;
3146
+ postOptions.data = body;
3006
3147
  const requestFuc = getConfig("request");
3007
3148
  if (typeof option.beforeRequest === "function") {
3008
3149
  postOptions = option.beforeRequest(mForm, postOptions, {
@@ -3022,9 +3163,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3022
3163
  config: props.config
3023
3164
  });
3024
3165
  }
3025
- const optionsData = res[option.root];
3026
- if (res.total > 0) {
3027
- total.value = res.total;
3166
+ const optionsData = root.split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res);
3167
+ const resTotal = globalThis.parseInt(
3168
+ totalKey.split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res),
3169
+ 10
3170
+ );
3171
+ if (resTotal > 0) {
3172
+ total.value = resTotal;
3028
3173
  }
3029
3174
  remoteData.value = remoteData.value.concat(optionsData);
3030
3175
  if (optionsData) {
@@ -3073,6 +3218,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3073
3218
  return [];
3074
3219
  const { config } = props;
3075
3220
  const { option } = config;
3221
+ const { root = "", initRoot = "" } = option;
3222
+ let { initBody = {} } = option;
3076
3223
  let options2 = [];
3077
3224
  let url = option.initUrl;
3078
3225
  if (!url) {
@@ -3081,22 +3228,45 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3081
3228
  if (typeof url === "function") {
3082
3229
  url = await url(mForm, { model: props.model, formValue: mForm?.values });
3083
3230
  }
3084
- const postOptions = {
3231
+ if (typeof initBody === "function") {
3232
+ initBody = initBody(mForm, {
3233
+ model: props.model,
3234
+ formValue: mForm?.values,
3235
+ formValues: mForm?.values,
3236
+ config: props.config
3237
+ });
3238
+ }
3239
+ let postOptions = {
3085
3240
  method: option.method || "POST",
3086
3241
  url,
3087
3242
  data: {
3088
- id: props.model[props.name]
3243
+ id: props.model[props.name],
3244
+ ...initBody
3089
3245
  },
3090
3246
  mode: option.mode,
3091
3247
  headers: option.headers || {},
3092
3248
  json: option.json || false
3093
3249
  };
3250
+ if (typeof option.beforeInitRequest === "function") {
3251
+ postOptions = option.beforeInitRequest(mForm, postOptions, {
3252
+ model: props.model,
3253
+ formValue: mForm?.values
3254
+ });
3255
+ }
3094
3256
  if (option.method?.toLocaleLowerCase() === "jsonp") {
3095
3257
  postOptions.jsonpCallback = option.jsonpCallback || "callback";
3096
3258
  }
3097
3259
  const requestFuc = getConfig("request");
3098
- const res = await requestFuc(postOptions);
3099
- let initData = res[option.root];
3260
+ let res = await requestFuc(postOptions);
3261
+ if (typeof option.afterRequest === "function") {
3262
+ res = option.afterRequest(mForm, res, {
3263
+ model: props.model,
3264
+ formValue: mForm?.values,
3265
+ formValues: mForm?.values,
3266
+ config: props.config
3267
+ });
3268
+ }
3269
+ let initData = (initRoot || root).split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res);
3100
3270
  if (initData) {
3101
3271
  if (!Array.isArray(initData)) {
3102
3272
  initData = [initData];
@@ -3231,8 +3401,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3231
3401
  }
3232
3402
  });
3233
3403
 
3404
+ const __default__$3 = defineComponent({
3405
+ name: "MFormSwitch"
3406
+ });
3234
3407
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3235
- __name: "Switch",
3408
+ ...__default__$3,
3236
3409
  props: {
3237
3410
  config: null,
3238
3411
  model: null,
@@ -3285,8 +3458,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3285
3458
  });
3286
3459
 
3287
3460
  const _hoisted_1 = { key: 0 };
3461
+ const __default__$2 = defineComponent({
3462
+ name: "MFormText"
3463
+ });
3288
3464
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3289
- __name: "Text",
3465
+ ...__default__$2,
3290
3466
  props: {
3291
3467
  config: null,
3292
3468
  model: null,
@@ -3405,8 +3581,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3405
3581
  }
3406
3582
  });
3407
3583
 
3584
+ const __default__$1 = defineComponent({
3585
+ name: "MFormTextarea"
3586
+ });
3408
3587
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3409
- __name: "Textarea",
3588
+ ...__default__$1,
3410
3589
  props: {
3411
3590
  config: null,
3412
3591
  model: null,
@@ -3445,8 +3624,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3445
3624
  }
3446
3625
  });
3447
3626
 
3627
+ const __default__ = defineComponent({
3628
+ name: "MFormTime"
3629
+ });
3448
3630
  const _sfc_main = /* @__PURE__ */ defineComponent({
3449
- __name: "Time",
3631
+ ...__default__,
3450
3632
  props: {
3451
3633
  config: null,
3452
3634
  model: null,
@@ -3468,11 +3650,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
3468
3650
  return openBlock(), createBlock(unref(TMagicTimePicker), {
3469
3651
  modelValue: __props.model[__props.name],
3470
3652
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3653
+ "value-format": __props.config.valueFormat || "HH:mm:ss",
3654
+ format: __props.config.format || "HH:mm:ss",
3471
3655
  size: __props.size,
3472
3656
  placeholder: __props.config.placeholder,
3473
3657
  disabled: __props.disabled,
3474
3658
  onChange: changeHandler
3475
- }, null, 8, ["modelValue", "size", "placeholder", "disabled"]);
3659
+ }, null, 8, ["modelValue", "value-format", "format", "size", "placeholder", "disabled"]);
3476
3660
  };
3477
3661
  }
3478
3662
  });
@@ -3517,5 +3701,5 @@ const index = {
3517
3701
  install
3518
3702
  };
3519
3703
 
3520
- export { _sfc_main$l as MCascader, _sfc_main$k as MCheckbox, _sfc_main$j as MCheckboxGroup, _sfc_main$i as MColorPicker, _sfc_main$v as MContainer, _sfc_main$h as MDate, _sfc_main$f as MDateTime, _sfc_main$g as MDaterange, _sfc_main$e as MDisplay, _sfc_main$d as MDynamicField, _sfc_main$u as MFieldset, _sfc_main$b as MForm, _sfc_main$a as MFormDialog, _sfc_main$s as MGroupList, _sfc_main$c as MHidden, _sfc_main$9 as MLink, _sfc_main$8 as MNumber, _sfc_main$r as MPanel, _sfc_main$7 as MRadioGroup, _sfc_main$p as MRow, _sfc_main$4 as MSelect, _sfc_main$3 as MSwitch, _sfc_main$n as MTable, _sfc_main$m as MTabs, _sfc_main$2 as MText, _sfc_main$1 as MTextarea, _sfc_main as MTime, index as default, display, filterFunction, getRules, initValue, useAddField };
3521
- //# sourceMappingURL=tmagic-form.mjs.map
3704
+ export { _sfc_main$l as MCascader, _sfc_main$k as MCheckbox, _sfc_main$j as MCheckboxGroup, _sfc_main$i as MColorPicker, _sfc_main$v as MContainer, _sfc_main$h as MDate, _sfc_main$f as MDateTime, _sfc_main$g as MDaterange, _sfc_main$e as MDisplay, _sfc_main$d as MDynamicField, _sfc_main$u as MFieldset, _sfc_main$b as MForm, _sfc_main$a as MFormDialog, _sfc_main$s as MGroupList, _sfc_main$c as MHidden, _sfc_main$9 as MLink, _sfc_main$8 as MNumber, _sfc_main$r as MPanel, _sfc_main$7 as MRadioGroup, _sfc_main$p as MRow, _sfc_main$4 as MSelect, _sfc_main$3 as MSwitch, _sfc_main$n as MTable, _sfc_main$m as MTabs, _sfc_main$2 as MText, _sfc_main$1 as MTextarea, _sfc_main as MTime, createValues, index as default, display, filterFunction, getRules, initValue, useAddField };
3705
+ //# sourceMappingURL=tmagic-form.js.map