@tmagic/form 1.5.0-beta.1 → 1.5.0-beta.10

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,9 +1,11 @@
1
1
  import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, 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
3
  import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
4
- import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch, TMagicPopover, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
4
+ import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch, TMagicPopover, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
5
+ import dayjs from 'dayjs';
6
+ import utc from 'dayjs/plugin/utc';
5
7
  import Sortable from 'sortablejs';
6
- import { sleep, asyncLoadJs, datetimeFormatter, getValueByKeyPath, isNumber } from '@tmagic/utils';
8
+ import { sleep, asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
7
9
 
8
10
  const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
9
11
  const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
@@ -164,12 +166,30 @@ const initValue = async (mForm, { initValues, config }) => {
164
166
  }
165
167
  return valuesTmp || {};
166
168
  };
169
+ const datetimeFormatter = (v, defaultValue = "-", format = "YYYY-MM-DD HH:mm:ss") => {
170
+ if (v) {
171
+ let time;
172
+ if (["x", "timestamp"].includes(format)) {
173
+ time = dayjs(v).valueOf();
174
+ } else if (typeof v === "string" && v.includes("Z") || v.constructor === Date) {
175
+ dayjs.extend(utc);
176
+ time = dayjs(v).utcOffset(8).format(format);
177
+ } else {
178
+ time = dayjs(v).format(format);
179
+ }
180
+ if (time !== "Invalid Date") {
181
+ return time;
182
+ }
183
+ return defaultValue;
184
+ }
185
+ return defaultValue;
186
+ };
167
187
 
168
- const _hoisted_1$d = ["id", "data-magic-id"];
169
- const _hoisted_2$8 = ["innerHTML", "title"];
170
- const _hoisted_3$5 = ["innerHTML"];
171
- const _hoisted_4$4 = ["innerHTML"];
172
- const _hoisted_5$4 = ["innerHTML"];
188
+ const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
189
+ const _hoisted_2$7 = ["innerHTML", "title"];
190
+ const _hoisted_3$4 = ["innerHTML"];
191
+ const _hoisted_4$3 = ["innerHTML"];
192
+ const _hoisted_5$3 = ["innerHTML"];
173
193
  const _hoisted_6$2 = ["innerHTML", "title"];
174
194
  const _hoisted_7$1 = ["innerHTML"];
175
195
  const _hoisted_8$1 = ["innerHTML"];
@@ -319,8 +339,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
319
339
  const _component_Container = resolveComponent("Container", true);
320
340
  return _ctx.config ? (openBlock(), createElementBlock("div", {
321
341
  key: 0,
322
- id: _ctx.config.id,
323
- "data-magic-id": _ctx.config.id,
342
+ "data-tmagic-id": _ctx.config.id,
343
+ "data-tmagic-form-item-prop": itemProp.value,
324
344
  style: normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
325
345
  class: normalizeClass(`m-form-container m-container-${type.value || ""} ${_ctx.config.className || ""}`)
326
346
  }, [
@@ -349,7 +369,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
349
369
  }, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
350
370
  createVNode(unref(TMagicFormItem), {
351
371
  style: normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
352
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
372
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
353
373
  prop: itemProp.value,
354
374
  "label-width": itemLabelWidth.value,
355
375
  rules: rule.value
@@ -358,12 +378,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
358
378
  createElementVNode("span", {
359
379
  innerHTML: type.value === "checkbox" ? "" : text.value,
360
380
  title: _ctx.config.labelTitle
361
- }, null, 8, _hoisted_2$8)
381
+ }, null, 8, _hoisted_2$7)
362
382
  ]),
363
383
  default: withCtx(() => [
364
384
  tooltip.value ? (openBlock(), createBlock(unref(TMagicTooltip), { key: 0 }, {
365
385
  content: withCtx(() => [
366
- createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$5)
386
+ createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$4)
367
387
  ]),
368
388
  default: withCtx(() => [
369
389
  (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
@@ -396,7 +416,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
396
416
  key: 2,
397
417
  innerHTML: extra.value,
398
418
  class: "m-form-tip"
399
- }, null, 8, _hoisted_4$4)) : createCommentVNode("", true)
419
+ }, null, 8, _hoisted_4$3)) : createCommentVNode("", true)
400
420
  ]),
401
421
  _: 1
402
422
  }, 8, ["style", "class", "prop", "label-width", "rules"]),
@@ -407,7 +427,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
407
427
  content: withCtx(() => [
408
428
  createElementVNode("div", {
409
429
  innerHTML: _ctx.config.tip
410
- }, null, 8, _hoisted_5$4)
430
+ }, null, 8, _hoisted_5$3)
411
431
  ]),
412
432
  default: withCtx(() => [
413
433
  createVNode(unref(TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -422,7 +442,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
422
442
  ], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
423
443
  createVNode(unref(TMagicFormItem), {
424
444
  style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
425
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
445
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
426
446
  prop: itemProp.value,
427
447
  "label-width": itemLabelWidth.value,
428
448
  rules: rule.value
@@ -490,7 +510,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
490
510
  })) : createCommentVNode("", true),
491
511
  createVNode(unref(TMagicFormItem), {
492
512
  style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
493
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
513
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
494
514
  prop: itemProp.value,
495
515
  "label-width": itemLabelWidth.value,
496
516
  rules: rule.value
@@ -595,10 +615,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
595
615
  });
596
616
 
597
617
  const _hoisted_1$c = ["innerHTML"];
598
- const _hoisted_2$7 = ["innerHTML"];
599
- const _hoisted_3$4 = { key: 1 };
600
- const _hoisted_4$3 = ["innerHTML"];
601
- const _hoisted_5$3 = ["innerHTML"];
618
+ const _hoisted_2$6 = ["innerHTML"];
619
+ const _hoisted_3$3 = { key: 1 };
620
+ const _hoisted_4$2 = ["innerHTML"];
621
+ const _hoisted_5$2 = ["innerHTML"];
602
622
  const _hoisted_6$1 = {
603
623
  key: 2,
604
624
  style: { "display": "flex" }
@@ -670,21 +690,21 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
670
690
  key: 0,
671
691
  innerHTML: _ctx.config.extra,
672
692
  class: "m-form-tip"
673
- }, null, 8, _hoisted_2$7)) : createCommentVNode("", true)
693
+ }, null, 8, _hoisted_2$6)) : createCommentVNode("", true)
674
694
  ]),
675
695
  _: 1
676
696
  }, 8, ["modelValue", "prop"])
677
697
  ]),
678
698
  _: 1
679
- })) : (openBlock(), createElementBlock("legend", _hoisted_3$4, [
699
+ })) : (openBlock(), createElementBlock("legend", _hoisted_3$3, [
680
700
  createElementVNode("span", {
681
701
  innerHTML: _ctx.config.legend
682
- }, null, 8, _hoisted_4$3),
702
+ }, null, 8, _hoisted_4$2),
683
703
  _ctx.config.extra ? (openBlock(), createElementBlock("span", {
684
704
  key: 0,
685
705
  innerHTML: _ctx.config.extra,
686
706
  class: "m-form-tip"
687
- }, null, 8, _hoisted_5$3)) : createCommentVNode("", true)
707
+ }, null, 8, _hoisted_5$2)) : createCommentVNode("", true)
688
708
  ])),
689
709
  _ctx.config.schematic && show.value ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
690
710
  createElementVNode("div", _hoisted_7, [
@@ -731,7 +751,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
731
751
  });
732
752
 
733
753
  const _hoisted_1$b = { class: "m-fields-group-list-item" };
734
- const _hoisted_2$6 = ["innerHTML"];
754
+ const _hoisted_2$5 = ["innerHTML"];
735
755
  const _sfc_main$v = /* @__PURE__ */ defineComponent({
736
756
  ...{
737
757
  name: "MFormGroupListItem"
@@ -832,7 +852,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
832
852
  onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
833
853
  }, {
834
854
  default: withCtx(() => [
835
- createTextVNode("上移"),
855
+ _cache[3] || (_cache[3] = createTextVNode("上移")),
836
856
  createVNode(unref(TMagicIcon), null, {
837
857
  default: withCtx(() => [
838
858
  createVNode(unref(CaretTop))
@@ -851,7 +871,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
851
871
  onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
852
872
  }, {
853
873
  default: withCtx(() => [
854
- createTextVNode("下移"),
874
+ _cache[4] || (_cache[4] = createTextVNode("下移")),
855
875
  createVNode(unref(TMagicIcon), null, {
856
876
  default: withCtx(() => [
857
877
  createVNode(unref(CaretBottom))
@@ -868,7 +888,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
868
888
  key: 1,
869
889
  innerHTML: itemExtra.value,
870
890
  class: "m-form-tip"
871
- }, null, 8, _hoisted_2$6)) : createCommentVNode("", true)
891
+ }, null, 8, _hoisted_2$5)) : createCommentVNode("", true)
872
892
  ]),
873
893
  expand.value ? (openBlock(), createBlock(_sfc_main$x, {
874
894
  key: 0,
@@ -889,15 +909,11 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
889
909
  });
890
910
 
891
911
  const _hoisted_1$a = { class: "m-fields-group-list" };
892
- const _hoisted_2$5 = ["innerHTML"];
893
- const _hoisted_3$3 = {
912
+ const _hoisted_2$4 = ["innerHTML"];
913
+ const _hoisted_3$2 = {
894
914
  key: 1,
895
915
  class: "el-table__empty-block"
896
916
  };
897
- const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
898
- const _hoisted_5$2 = [
899
- _hoisted_4$2
900
- ];
901
917
  const _sfc_main$u = /* @__PURE__ */ defineComponent({
902
918
  ...{
903
919
  name: "MFormGroupList"
@@ -983,8 +999,10 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
983
999
  key: 0,
984
1000
  innerHTML: _ctx.config.extra,
985
1001
  style: { "color": "rgba(0, 0, 0, 0.45)" }
986
- }, null, 8, _hoisted_2$5)) : createCommentVNode("", true),
987
- !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$3, _hoisted_5$2)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.model[_ctx.name], (item, index) => {
1002
+ }, null, 8, _hoisted_2$4)) : createCommentVNode("", true),
1003
+ !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$2, _cache[1] || (_cache[1] = [
1004
+ createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1)
1005
+ ]))) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.model[_ctx.name], (item, index) => {
988
1006
  return openBlock(), createBlock(_sfc_main$v, {
989
1007
  key: index,
990
1008
  model: item,
@@ -1009,9 +1027,9 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1009
1027
  size: "small",
1010
1028
  disabled: _ctx.disabled
1011
1029
  }, {
1012
- default: withCtx(() => [
1030
+ default: withCtx(() => _cache[2] || (_cache[2] = [
1013
1031
  createTextVNode("新增")
1014
- ]),
1032
+ ])),
1015
1033
  _: 1
1016
1034
  }, 8, ["disabled"])) : createCommentVNode("", true),
1017
1035
  _ctx.config.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
@@ -1020,9 +1038,9 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1020
1038
  size: "small",
1021
1039
  onClick: toggleMode
1022
1040
  }, {
1023
- default: withCtx(() => [
1041
+ default: withCtx(() => _cache[3] || (_cache[3] = [
1024
1042
  createTextVNode("切换为表格")
1025
- ]),
1043
+ ])),
1026
1044
  _: 1
1027
1045
  }, 8, ["icon"])) : createCommentVNode("", true)
1028
1046
  ]);
@@ -1031,8 +1049,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1031
1049
  });
1032
1050
 
1033
1051
  const _hoisted_1$9 = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
1034
- const _hoisted_2$4 = ["innerHTML"];
1035
- const _hoisted_3$2 = {
1052
+ const _hoisted_2$3 = ["innerHTML"];
1053
+ const _hoisted_3$1 = {
1036
1054
  key: 0,
1037
1055
  style: { "display": "flex" }
1038
1056
  };
@@ -1082,7 +1100,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1082
1100
  key: 0,
1083
1101
  innerHTML: _ctx.config.extra,
1084
1102
  class: "m-form-tip"
1085
- }, null, 8, _hoisted_2$4)) : createCommentVNode("", true),
1103
+ }, null, 8, _hoisted_2$3)) : createCommentVNode("", true),
1086
1104
  renderSlot(_ctx.$slots, "header", {}, () => [
1087
1105
  createTextVNode(toDisplayString(filter(_ctx.config.title)), 1)
1088
1106
  ])
@@ -1091,7 +1109,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1091
1109
  default: withCtx(() => [
1092
1110
  createElementVNode("div", null, [
1093
1111
  renderSlot(_ctx.$slots, "default"),
1094
- _ctx.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
1112
+ _ctx.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
1095
1113
  createElementVNode("div", _hoisted_4$1, [
1096
1114
  (openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
1097
1115
  return openBlock(), createBlock(_sfc_main$x, {
@@ -1317,8 +1335,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
1317
1335
  });
1318
1336
 
1319
1337
  const _hoisted_1$8 = { class: "m-fields-table-wrap" };
1320
- const _hoisted_2$3 = ["innerHTML"];
1321
- const _hoisted_3$1 = ["innerHTML"];
1338
+ const _hoisted_2$2 = ["innerHTML"];
1339
+ const _hoisted_3 = ["innerHTML"];
1322
1340
  const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
1323
1341
  const _hoisted_5 = { style: { "display": "flex" } };
1324
1342
  const _hoisted_6 = {
@@ -1565,6 +1583,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1565
1583
  }
1566
1584
  timer = setTimeout(() => {
1567
1585
  swapArray(index, index - 1);
1586
+ timer = void 0;
1568
1587
  }, 300);
1569
1588
  };
1570
1589
  const topHandler = (index) => {
@@ -1583,6 +1602,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1583
1602
  }
1584
1603
  timer = setTimeout(() => {
1585
1604
  swapArray(index, index + 1);
1605
+ timer = void 0;
1586
1606
  }, 300);
1587
1607
  };
1588
1608
  const bottomHandler = (index) => {
@@ -1694,7 +1714,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1694
1714
  key: 0,
1695
1715
  style: { "color": "rgba(0, 0, 0, 0.45)" },
1696
1716
  innerHTML: _ctx.config.extra
1697
- }, null, 8, _hoisted_2$3)) : createCommentVNode("", true),
1717
+ }, null, 8, _hoisted_2$2)) : createCommentVNode("", true),
1698
1718
  createVNode(unref(TMagicTooltip), {
1699
1719
  content: "拖拽可排序",
1700
1720
  placement: "left-start",
@@ -1726,7 +1746,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1726
1746
  createElementVNode("span", {
1727
1747
  innerHTML: itemExtra(_ctx.config.itemExtra, scope.$index),
1728
1748
  class: "m-form-tip"
1729
- }, null, 8, _hoisted_3$1)
1749
+ }, null, 8, _hoisted_3)
1730
1750
  ]),
1731
1751
  _: 1
1732
1752
  })) : createCommentVNode("", true),
@@ -1863,9 +1883,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1863
1883
  plain: "",
1864
1884
  onClick: _cache[2] || (_cache[2] = ($event) => newHandler())
1865
1885
  }, {
1866
- default: withCtx(() => [
1886
+ default: withCtx(() => _cache[4] || (_cache[4] = [
1867
1887
  createTextVNode("新增一行")
1868
- ]),
1888
+ ])),
1869
1889
  _: 1
1870
1890
  }, 8, ["disabled"])) : createCommentVNode("", true),
1871
1891
  createElementVNode("div", _hoisted_5, [
@@ -1876,9 +1896,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1876
1896
  type: "primary",
1877
1897
  onClick: toggleMode
1878
1898
  }, {
1879
- default: withCtx(() => [
1899
+ default: withCtx(() => _cache[5] || (_cache[5] = [
1880
1900
  createTextVNode("展开配置")
1881
- ]),
1901
+ ])),
1882
1902
  _: 1
1883
1903
  }, 8, ["icon"])) : createCommentVNode("", true),
1884
1904
  _ctx.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
@@ -1910,9 +1930,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1910
1930
  disabled: _ctx.disabled,
1911
1931
  plain: ""
1912
1932
  }, {
1913
- default: withCtx(() => [
1933
+ default: withCtx(() => _cache[6] || (_cache[6] = [
1914
1934
  createTextVNode("导入EXCEL")
1915
- ]),
1935
+ ])),
1916
1936
  _: 1
1917
1937
  }, 8, ["disabled"])
1918
1938
  ]),
@@ -1926,9 +1946,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1926
1946
  plain: "",
1927
1947
  onClick: _cache[3] || (_cache[3] = ($event) => clearHandler())
1928
1948
  }, {
1929
- default: withCtx(() => [
1949
+ default: withCtx(() => _cache[7] || (_cache[7] = [
1930
1950
  createTextVNode("清空")
1931
- ]),
1951
+ ])),
1932
1952
  _: 1
1933
1953
  }, 8, ["disabled"])) : createCommentVNode("", true)
1934
1954
  ])
@@ -1971,8 +1991,8 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
1971
1991
  },
1972
1992
  emits: ["change", "addDiffCount"],
1973
1993
  setup(__props, { emit: __emit }) {
1974
- const tabPaneComponent = getConfig$1("components")?.tabPane;
1975
- const tabsComponent = getConfig$1("components")?.tabs;
1994
+ const tabPaneComponent = getDesignConfig("components")?.tabPane;
1995
+ const tabsComponent = getDesignConfig("components")?.tabs;
1976
1996
  const getActive = (mForm2, props2, activeTabName2) => {
1977
1997
  const { config, model, prop } = props2;
1978
1998
  const { active } = config;
@@ -2455,7 +2475,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2455
2475
  const props = __props;
2456
2476
  const emit = __emit;
2457
2477
  useAddField(props.prop);
2458
- props.model[props.name] = datetimeFormatter(props.model[props.name], "");
2478
+ props.model[props.name] = datetimeFormatter(props.model[props.name], "", props.config.valueFormat || "YYYY/MM/DD");
2459
2479
  const changeHandler = (v) => {
2460
2480
  emit("change", v);
2461
2481
  };
@@ -2467,8 +2487,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2467
2487
  size: _ctx.size,
2468
2488
  placeholder: _ctx.config.placeholder,
2469
2489
  disabled: _ctx.disabled,
2470
- format: _ctx.config.format,
2471
- "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2490
+ format: _ctx.config.format || "YYYY/MM/DD",
2491
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD",
2472
2492
  onChange: changeHandler
2473
2493
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
2474
2494
  };
@@ -2506,9 +2526,10 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2506
2526
  if (!value.value) {
2507
2527
  value.value = [];
2508
2528
  }
2529
+ const format = `${props.config.dateFormat || "YYYY/MM/DD"} ${props.config.timeFormat || "HH:mm:ss"}`;
2509
2530
  if (!start || !end) value.value = [];
2510
- if (start !== preStart) value.value[0] = new Date(start);
2511
- if (end !== preEnd) value.value[1] = new Date(end);
2531
+ if (start !== preStart) value.value[0] = datetimeFormatter(start, "", format);
2532
+ if (end !== preEnd) value.value[1] = datetimeFormatter(end, "", format);
2512
2533
  },
2513
2534
  {
2514
2535
  immediate: true
@@ -2518,7 +2539,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2518
2539
  watch(
2519
2540
  () => props.model[props.name],
2520
2541
  (start, preStart) => {
2521
- if (start !== preStart) value.value = start.map((item) => item ? new Date(item) : void 0);
2542
+ const format = `${props.config.dateFormat || "YYYY/MM/DD"} ${props.config.timeFormat || "HH:mm:ss"}`;
2543
+ if (start !== preStart)
2544
+ value.value = start.map(
2545
+ (item) => item ? datetimeFormatter(item, "", format) : void 0
2546
+ );
2522
2547
  },
2523
2548
  {
2524
2549
  immediate: true
@@ -2532,7 +2557,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2532
2557
  return;
2533
2558
  }
2534
2559
  if (Array.isArray(v)) {
2535
- props.model[item] = datetimeFormatter(v[index]?.toString(), "");
2560
+ props.model[item] = v[index];
2536
2561
  } else {
2537
2562
  props.model[item] = void 0;
2538
2563
  }
@@ -2541,18 +2566,12 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2541
2566
  const changeHandler = (v) => {
2542
2567
  const value2 = v || [];
2543
2568
  if (props.name) {
2544
- emit(
2545
- "change",
2546
- value2.map((item) => {
2547
- if (item) return datetimeFormatter(item, "");
2548
- return void 0;
2549
- })
2550
- );
2569
+ emit("change", value2);
2551
2570
  } else {
2552
2571
  if (names?.length) {
2553
2572
  setValue(value2);
2554
2573
  }
2555
- emit("change", value2);
2574
+ emit("change", props.model);
2556
2575
  }
2557
2576
  };
2558
2577
  return (_ctx, _cache) => {
@@ -2567,8 +2586,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2567
2586
  "unlink-panels": true,
2568
2587
  disabled: _ctx.disabled,
2569
2588
  "default-time": _ctx.config.defaultTime,
2589
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2590
+ "date-format": _ctx.config.dateFormat || "YYYY/MM/DD",
2591
+ "time-format": _ctx.config.timeFormat || "HH:mm:ss",
2570
2592
  onChange: changeHandler
2571
- }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
2593
+ }, null, 8, ["modelValue", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
2572
2594
  };
2573
2595
  }
2574
2596
  });
@@ -2599,7 +2621,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2599
2621
  if (value === "Invalid Date") {
2600
2622
  props.model[props.name] = "";
2601
2623
  } else {
2602
- props.model[props.name] = datetimeFormatter(props.model[props.name], "", props.config.valueFormat);
2624
+ props.model[props.name] = datetimeFormatter(
2625
+ props.model[props.name],
2626
+ "",
2627
+ props.config.valueFormat || "YYYY/MM/DD HH:mm:ss"
2628
+ );
2603
2629
  }
2604
2630
  }
2605
2631
  const changeHandler = (v) => {
@@ -3055,9 +3081,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3055
3081
  onClick: cancel,
3056
3082
  size: "small"
3057
3083
  }, {
3058
- default: withCtx(() => [
3084
+ default: withCtx(() => _cache[2] || (_cache[2] = [
3059
3085
  createTextVNode("取 消")
3060
- ]),
3086
+ ])),
3061
3087
  _: 1
3062
3088
  }),
3063
3089
  hasStep.value && stepActive.value > 1 ? (openBlock(), createBlock(unref(TMagicButton), {
@@ -3066,9 +3092,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3066
3092
  size: "small",
3067
3093
  onClick: preStep
3068
3094
  }, {
3069
- default: withCtx(() => [
3095
+ default: withCtx(() => _cache[3] || (_cache[3] = [
3070
3096
  createTextVNode("上一步")
3071
- ]),
3097
+ ])),
3072
3098
  _: 1
3073
3099
  })) : createCommentVNode("", true),
3074
3100
  hasStep.value && stepCount.value > stepActive.value ? (openBlock(), createBlock(unref(TMagicButton), {
@@ -3077,9 +3103,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3077
3103
  size: "small",
3078
3104
  onClick: nextStep
3079
3105
  }, {
3080
- default: withCtx(() => [
3106
+ default: withCtx(() => _cache[4] || (_cache[4] = [
3081
3107
  createTextVNode("下一步")
3082
- ]),
3108
+ ])),
3083
3109
  _: 1
3084
3110
  })) : (openBlock(), createBlock(unref(TMagicButton), {
3085
3111
  key: 2,
@@ -3133,7 +3159,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3133
3159
  });
3134
3160
 
3135
3161
  const _hoisted_1$4 = ["href"];
3136
- const _hoisted_2$2 = {
3162
+ const _hoisted_2$1 = {
3137
3163
  key: 2,
3138
3164
  class: "m-fields-link"
3139
3165
  };
@@ -3209,15 +3235,15 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3209
3235
  }, toDisplayString(displayText.value), 13, _hoisted_1$4)) : _ctx.config.href && _ctx.disabled ? (openBlock(), createElementBlock("span", {
3210
3236
  key: 1,
3211
3237
  style: normalizeStyle(_ctx.config.disabledCss || {})
3212
- }, toDisplayString(displayText.value), 5)) : (openBlock(), createElementBlock("div", _hoisted_2$2, [
3238
+ }, toDisplayString(displayText.value), 5)) : (openBlock(), createElementBlock("div", _hoisted_2$1, [
3213
3239
  createVNode(unref(TMagicButton), {
3214
3240
  link: "",
3215
3241
  type: "primary",
3216
3242
  onClick: editHandler
3217
3243
  }, {
3218
- default: withCtx(() => [
3244
+ default: withCtx(() => _cache[0] || (_cache[0] = [
3219
3245
  createTextVNode("点击编辑")
3220
- ]),
3246
+ ])),
3221
3247
  _: 1
3222
3248
  }),
3223
3249
  createVNode(_sfc_main$c, {
@@ -3286,7 +3312,6 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
3286
3312
  });
3287
3313
 
3288
3314
  const _hoisted_1$3 = { class: "m-fields-number-range" };
3289
- const _hoisted_2$1 = /* @__PURE__ */ createElementVNode("span", { class: "split-tag" }, "-", -1);
3290
3315
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3291
3316
  ...{
3292
3317
  name: "MFormNumberRange"
@@ -3327,7 +3352,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3327
3352
  disabled: _ctx.disabled,
3328
3353
  onChange: minChangeHandler
3329
3354
  }, null, 8, ["modelValue", "size", "disabled"]),
3330
- _hoisted_2$1,
3355
+ _cache[2] || (_cache[2] = createElementVNode("span", { class: "split-tag" }, "-", -1)),
3331
3356
  createVNode(unref(TMagicInput), {
3332
3357
  modelValue: _ctx.model[_ctx.name][1],
3333
3358
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.model[_ctx.name][1] = $event),
@@ -3414,8 +3439,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3414
3439
  setup(__props, { emit: __emit }) {
3415
3440
  const props = __props;
3416
3441
  const emit = __emit;
3417
- const optionComponent = getConfig$1("components")?.option;
3418
- const optionGroupComponent = getConfig$1("components")?.optionGroup;
3442
+ const optionComponent = getDesignConfig("components")?.option;
3443
+ const optionGroupComponent = getDesignConfig("components")?.optionGroup;
3419
3444
  if (!props.model) throw new Error("不能没有model");
3420
3445
  useAddField(props.prop);
3421
3446
  const tMagicSelect = ref();
@@ -3850,8 +3875,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3850
3875
  });
3851
3876
 
3852
3877
  const _hoisted_1$1 = { class: "m-form-item__content" };
3853
- const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1);
3854
- const _hoisted_3 = { style: { "display": "flex", "justify-content": "flex-end" } };
3878
+ const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
3855
3879
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3856
3880
  ...{
3857
3881
  name: "MFormText"
@@ -3968,8 +3992,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3968
3992
  };
3969
3993
  return (_ctx, _cache) => {
3970
3994
  return openBlock(), createBlock(unref(TMagicPopover), {
3995
+ width: "220px",
3971
3996
  visible: popoverVisible.value,
3972
- width: "220px"
3997
+ "destroy-on-close": true
3973
3998
  }, {
3974
3999
  reference: withCtx(() => [
3975
4000
  createVNode(unref(TMagicInput), {
@@ -4004,16 +4029,16 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4004
4029
  ]),
4005
4030
  default: withCtx(() => [
4006
4031
  createElementVNode("div", _hoisted_1$1, [
4007
- _hoisted_2,
4008
- createElementVNode("div", _hoisted_3, [
4032
+ _cache[5] || (_cache[5] = createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
4033
+ createElementVNode("div", _hoisted_2, [
4009
4034
  createVNode(unref(TMagicButton), {
4010
4035
  link: "",
4011
4036
  size: "small",
4012
4037
  onClick: _cache[2] || (_cache[2] = ($event) => popoverVisible.value = false)
4013
4038
  }, {
4014
- default: withCtx(() => [
4039
+ default: withCtx(() => _cache[3] || (_cache[3] = [
4015
4040
  createTextVNode("保持原样")
4016
- ]),
4041
+ ])),
4017
4042
  _: 1
4018
4043
  }),
4019
4044
  createVNode(unref(TMagicButton), {
@@ -4021,9 +4046,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4021
4046
  size: "small",
4022
4047
  onClick: confirmTrimHandler
4023
4048
  }, {
4024
- default: withCtx(() => [
4049
+ default: withCtx(() => _cache[4] || (_cache[4] = [
4025
4050
  createTextVNode("移除空格")
4026
- ]),
4051
+ ])),
4027
4052
  _: 1
4028
4053
  })
4029
4054
  ])
@@ -4164,7 +4189,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4164
4189
  return;
4165
4190
  }
4166
4191
  if (Array.isArray(v)) {
4167
- props.model[item] = datetimeFormatter(v[index]?.toString(), "");
4192
+ props.model[item] = v[index];
4168
4193
  } else {
4169
4194
  props.model[item] = void 0;
4170
4195
  }
@@ -4309,9 +4334,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4309
4334
  default: withCtx(() => [
4310
4335
  renderSlot(_ctx.$slots, "footer", {}, () => [
4311
4336
  createVNode(unref(TMagicButton), { onClick: handleClose }, {
4312
- default: withCtx(() => [
4337
+ default: withCtx(() => _cache[1] || (_cache[1] = [
4313
4338
  createTextVNode("关闭")
4314
- ]),
4339
+ ])),
4315
4340
  _: 1
4316
4341
  }),
4317
4342
  createVNode(unref(TMagicButton), {
@@ -4486,8 +4511,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4486
4511
  const createForm = (config) => config;
4487
4512
  const defaultInstallOpt = {};
4488
4513
  const index = {
4489
- install(app, opt = {}) {
4490
- const option = Object.assign(defaultInstallOpt, opt);
4514
+ install(app, opt) {
4515
+ const option = Object.assign(defaultInstallOpt, opt || {});
4491
4516
  app.config.globalProperties.$MAGIC_FORM = option;
4492
4517
  setConfig(option);
4493
4518
  app.component("m-form", _sfc_main$d);
@@ -4523,4 +4548,4 @@ const index = {
4523
4548
  }
4524
4549
  };
4525
4550
 
4526
- export { _sfc_main$n as MCascader, _sfc_main$m as MCheckbox, _sfc_main$l as MCheckboxGroup, _sfc_main$k as MColorPicker, _sfc_main$x as MContainer, _sfc_main$j as MDate, _sfc_main$h as MDateTime, _sfc_main$i as MDaterange, _sfc_main$g as MDisplay, _sfc_main$f as MDynamicField, _sfc_main$w as MFieldset, _sfc_main$d as MForm, _sfc_main as MFormBox, _sfc_main$c as MFormDialog, _sfc_main$1 as MFormDrawer, _sfc_main$u as MGroupList, _sfc_main$e as MHidden, _sfc_main$b as MLink, _sfc_main$a as MNumber, _sfc_main$9 as MNumberRange, _sfc_main$t as MPanel, _sfc_main$8 as MRadioGroup, _sfc_main$r as MRow, _sfc_main$7 as MSelect, _sfc_main$6 as MSwitch, _sfc_main$p as MTable, _sfc_main$o as MTabs, _sfc_main$5 as MText, _sfc_main$4 as MTextarea, _sfc_main$3 as MTime, _sfc_main$2 as MTimerange, createForm, createValues, index as default, display, filterFunction, getRules, initValue, useAddField };
4551
+ export { _sfc_main$n as MCascader, _sfc_main$m as MCheckbox, _sfc_main$l as MCheckboxGroup, _sfc_main$k as MColorPicker, _sfc_main$x as MContainer, _sfc_main$j as MDate, _sfc_main$h as MDateTime, _sfc_main$i as MDaterange, _sfc_main$g as MDisplay, _sfc_main$f as MDynamicField, _sfc_main$w as MFieldset, _sfc_main$d as MForm, _sfc_main as MFormBox, _sfc_main$c as MFormDialog, _sfc_main$1 as MFormDrawer, _sfc_main$u as MGroupList, _sfc_main$e as MHidden, _sfc_main$b as MLink, _sfc_main$a as MNumber, _sfc_main$9 as MNumberRange, _sfc_main$t as MPanel, _sfc_main$8 as MRadioGroup, _sfc_main$r as MRow, _sfc_main$7 as MSelect, _sfc_main$6 as MSwitch, _sfc_main$p as MTable, _sfc_main$o as MTabs, _sfc_main$5 as MText, _sfc_main$4 as MTextarea, _sfc_main$3 as MTime, _sfc_main$2 as MTimerange, createForm, createValues, datetimeFormatter, index as default, display, filterFunction, getRules, initValue, useAddField };