@tmagic/form 1.8.0-beta.2 → 1.8.0-beta.21

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 (91) hide show
  1. package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +120 -27
  2. package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +19 -3
  3. package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +30 -7
  4. package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +56 -14
  5. package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +3 -2
  6. package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +51 -36
  7. package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +5 -3
  8. package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +1 -1
  9. package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +1 -1
  10. package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +7 -6
  11. package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +42 -32
  12. package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +17 -11
  13. package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +1 -1
  14. package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +1 -1
  15. package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +1 -1
  16. package/dist/es/containers/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +14 -7
  17. package/dist/es/containers/table/SortColumn.vue_vue_type_script_setup_true_lang.js +1 -1
  18. package/dist/es/containers/table/Table.vue_vue_type_script_setup_true_lang.js +7 -5
  19. package/dist/es/containers/table/useTableColumns.js +5 -1
  20. package/dist/es/containers/table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js +3 -2
  21. package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +6 -3
  22. package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +5 -2
  23. package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +6 -3
  24. package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +5 -2
  25. package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +6 -3
  26. package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +6 -3
  27. package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +6 -3
  28. package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +6 -3
  29. package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +5 -2
  30. package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +1 -1
  31. package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +30 -8
  32. package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +8 -3
  33. package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +5 -2
  34. package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +21 -10
  35. package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +7 -3
  36. package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +5 -2
  37. package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +113 -78
  38. package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +5 -2
  39. package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +5 -2
  40. package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +7 -4
  41. package/dist/es/index.js +5 -4
  42. package/dist/es/plugin.js +4 -0
  43. package/dist/es/schema.js +12 -1
  44. package/dist/es/style.css +133 -11
  45. package/dist/es/submitForm.js +415 -56
  46. package/dist/es/utils/config.js +4 -1
  47. package/dist/es/utils/form.js +84 -9
  48. package/dist/es/utils/typeMatch.js +487 -0
  49. package/dist/style.css +133 -11
  50. package/dist/themes/magic-admin.css +509 -0
  51. package/dist/tmagic-form.umd.cjs +1773 -399
  52. package/package.json +5 -5
  53. package/src/Form.vue +163 -30
  54. package/src/FormBox.vue +11 -0
  55. package/src/FormDialog.vue +25 -3
  56. package/src/FormDrawer.vue +51 -12
  57. package/src/containers/Col.vue +1 -0
  58. package/src/containers/Container.vue +32 -11
  59. package/src/containers/Fieldset.vue +5 -2
  60. package/src/containers/GroupList.vue +1 -1
  61. package/src/containers/GroupListItem.vue +28 -22
  62. package/src/containers/Panel.vue +10 -3
  63. package/src/containers/table/ActionsColumn.vue +10 -4
  64. package/src/containers/table/Table.vue +1 -0
  65. package/src/containers/table/useTableColumns.ts +7 -3
  66. package/src/containers/table-group-list/TableGroupList.vue +7 -1
  67. package/src/fields/Link.vue +16 -3
  68. package/src/fields/Number.vue +2 -1
  69. package/src/fields/RadioGroup.vue +24 -6
  70. package/src/fields/Text.vue +43 -19
  71. package/src/index.ts +11 -0
  72. package/src/plugin.ts +12 -0
  73. package/src/schema.ts +13 -1
  74. package/src/submitForm.ts +699 -66
  75. package/src/theme/container.scss +3 -0
  76. package/src/theme/fieldset.scss +51 -0
  77. package/src/theme/form-dialog.scss +1 -1
  78. package/src/theme/form.scss +6 -0
  79. package/src/theme/group-list.scss +19 -8
  80. package/src/theme/index.scss +1 -0
  81. package/src/theme/link.scss +17 -0
  82. package/src/theme/panel.scss +1 -1
  83. package/src/theme/radio-group.scss +23 -0
  84. package/src/theme/table.scss +11 -1
  85. package/src/theme/tabs.scss +2 -2
  86. package/src/theme/text.scss +38 -0
  87. package/src/theme/themes/magic-admin/index.scss +106 -0
  88. package/src/utils/config.ts +7 -1
  89. package/src/utils/form.ts +144 -22
  90. package/src/utils/typeMatch.ts +870 -0
  91. package/types/index.d.ts +408 -21
@@ -1,15 +1,16 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("@tmagic/design"), require("@tmagic/utils"), require("@element-plus/icons-vue"), require("dayjs"), require("dayjs/plugin/utc"), require("@popperjs/core")) : typeof define === "function" && define.amd ? define([
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("dayjs"), require("dayjs/plugin/utc"), require("@tmagic/design"), require("@tmagic/utils"), require("dayjs/plugin/customParseFormat"), require("@element-plus/icons-vue"), require("@popperjs/core")) : typeof define === "function" && define.amd ? define([
3
3
  "exports",
4
4
  "vue",
5
+ "dayjs",
6
+ "dayjs/plugin/utc",
5
7
  "@tmagic/design",
6
8
  "@tmagic/utils",
9
+ "dayjs/plugin/customParseFormat",
7
10
  "@element-plus/icons-vue",
8
- "dayjs",
9
- "dayjs/plugin/utc",
10
11
  "@popperjs/core"
11
- ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global._tmagic_design, global._tmagic_utils, global._element_plus_icons_vue, global.dayjs, global.dayjs_plugin_utc, global._popperjs_core));
12
- })(this, function(exports, vue, _tmagic_design, _tmagic_utils, _element_plus_icons_vue, dayjs, dayjs_plugin_utc, _popperjs_core) {
12
+ ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.dayjs, global.dayjs_plugin_utc, global._tmagic_design, global._tmagic_utils, global.dayjs_plugin_customParseFormat, global._element_plus_icons_vue, global._popperjs_core));
13
+ })(this, function(exports, vue, dayjs, dayjs_plugin_utc, _tmagic_design, _tmagic_utils, dayjs_plugin_customParseFormat, _element_plus_icons_vue, _popperjs_core) {
13
14
  Object.defineProperties(exports, {
14
15
  __esModule: { value: true },
15
16
  [Symbol.toStringTag]: { value: "Module" }
@@ -38,8 +39,20 @@
38
39
  //#endregion
39
40
  dayjs = __toESM(dayjs, 1);
40
41
  dayjs_plugin_utc = __toESM(dayjs_plugin_utc, 1);
42
+ dayjs_plugin_customParseFormat = __toESM(dayjs_plugin_customParseFormat, 1);
41
43
  //#region packages/form/src/schema.ts
42
44
  var FORM_DIFF_CONFIG_KEY = Symbol("mFormDiffConfig");
45
+ var FORM_TYPE_MATCH_VALID_KEY = Symbol("mFormTypeMatchValid");
46
+ /**
47
+ * 静默模式标记,由 `submitForm` / `validateForm` 以隐藏方式挂载临时表单时 provide(debug 弹层模式不提供)。
48
+ *
49
+ * 重型字段组件(如 vs-code)可 inject 该标记并跳过自身渲染:字段校验由 FormItem 基于 model 值完成,
50
+ * 与叶子 UI 组件实例无关,跳过可省去无谓的实例化开销(如 monaco worker / model 的创建)。
51
+ *
52
+ * 注意:仅「挂载无值副作用」(不在 onMounted/watch immediate 中 emit change、不依赖 DOM 计算值)的
53
+ * 字段组件可以安全跳过,接入前需逐一审计。
54
+ */
55
+ var FORM_SILENT_MODE_KEY = Symbol("mFormSilentMode");
43
56
  //#endregion
44
57
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
45
58
  /** Detect free variable `global` from Node.js. */
@@ -107,7 +120,8 @@
107
120
  //#endregion
108
121
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
109
122
  /** `Object#toString` result references. */
110
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
123
+ var nullTag = "[object Null]";
124
+ var undefinedTag = "[object Undefined]";
111
125
  /** Built-in value references. */
112
126
  var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
113
127
  /**
@@ -312,7 +326,10 @@
312
326
  //#endregion
313
327
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js
314
328
  /** `Object#toString` result references. */
315
- var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
329
+ var asyncTag = "[object AsyncFunction]";
330
+ var funcTag$2 = "[object Function]";
331
+ var genTag$1 = "[object GeneratorFunction]";
332
+ var proxyTag = "[object Proxy]";
316
333
  /**
317
334
  * Checks if `value` is classified as a `Function` object.
318
335
  *
@@ -388,7 +405,8 @@
388
405
  /** Used to detect host constructors (Safari). */
389
406
  var reIsHostCtor = /^\[object .+?Constructor\]$/;
390
407
  /** Used for built-in method references. */
391
- var funcProto = Function.prototype, objectProto$2 = Object.prototype;
408
+ var funcProto = Function.prototype;
409
+ var objectProto$2 = Object.prototype;
392
410
  /** Used to resolve the decompiled source of functions. */
393
411
  var funcToString = funcProto.toString;
394
412
  /** Used to check objects for own properties. */
@@ -806,8 +824,30 @@
806
824
  //#endregion
807
825
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsTypedArray.js
808
826
  /** `Object#toString` result references. */
809
- var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", funcTag$1 = "[object Function]", mapTag$6 = "[object Map]", numberTag$3 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$3 = "[object RegExp]", setTag$6 = "[object Set]", stringTag$3 = "[object String]", weakMapTag$2 = "[object WeakMap]";
810
- var arrayBufferTag$3 = "[object ArrayBuffer]", dataViewTag$4 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
827
+ var argsTag$2 = "[object Arguments]";
828
+ var arrayTag$2 = "[object Array]";
829
+ var boolTag$3 = "[object Boolean]";
830
+ var dateTag$3 = "[object Date]";
831
+ var errorTag$2 = "[object Error]";
832
+ var funcTag$1 = "[object Function]";
833
+ var mapTag$6 = "[object Map]";
834
+ var numberTag$3 = "[object Number]";
835
+ var objectTag$3 = "[object Object]";
836
+ var regexpTag$3 = "[object RegExp]";
837
+ var setTag$6 = "[object Set]";
838
+ var stringTag$3 = "[object String]";
839
+ var weakMapTag$2 = "[object WeakMap]";
840
+ var arrayBufferTag$3 = "[object ArrayBuffer]";
841
+ var dataViewTag$4 = "[object DataView]";
842
+ var float32Tag$2 = "[object Float32Array]";
843
+ var float64Tag$2 = "[object Float64Array]";
844
+ var int8Tag$2 = "[object Int8Array]";
845
+ var int16Tag$2 = "[object Int16Array]";
846
+ var int32Tag$2 = "[object Int32Array]";
847
+ var uint8Tag$2 = "[object Uint8Array]";
848
+ var uint8ClampedTag$2 = "[object Uint8ClampedArray]";
849
+ var uint16Tag$2 = "[object Uint16Array]";
850
+ var uint32Tag$2 = "[object Uint32Array]";
811
851
  /** Used to identify `toStringTag` values of typed arrays. */
812
852
  var typedArrayTags = {};
813
853
  typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
@@ -1543,7 +1583,8 @@
1543
1583
  /** Detect free variable `module`. */
1544
1584
  var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1545
1585
  /** Built-in value references. */
1546
- var Buffer$1 = freeModule && freeModule.exports === freeExports ? root.Buffer : void 0, allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : void 0;
1586
+ var Buffer$1 = freeModule && freeModule.exports === freeExports ? root.Buffer : void 0;
1587
+ var allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : void 0;
1547
1588
  /**
1548
1589
  * Creates a clone of `buffer`.
1549
1590
  *
@@ -1716,10 +1757,18 @@
1716
1757
  //#endregion
1717
1758
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getTag.js
1718
1759
  /** `Object#toString` result references. */
1719
- var mapTag$5 = "[object Map]", objectTag$2 = "[object Object]", promiseTag = "[object Promise]", setTag$5 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
1760
+ var mapTag$5 = "[object Map]";
1761
+ var objectTag$2 = "[object Object]";
1762
+ var promiseTag = "[object Promise]";
1763
+ var setTag$5 = "[object Set]";
1764
+ var weakMapTag$1 = "[object WeakMap]";
1720
1765
  var dataViewTag$3 = "[object DataView]";
1721
1766
  /** Used to detect maps, sets, and weakmaps. */
1722
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap);
1767
+ var dataViewCtorString = toSource(DataView);
1768
+ var mapCtorString = toSource(Map$1);
1769
+ var promiseCtorString = toSource(Promise$1);
1770
+ var setCtorString = toSource(Set$1);
1771
+ var weakMapCtorString = toSource(WeakMap);
1723
1772
  /**
1724
1773
  * Gets the `toStringTag` of `value`.
1725
1774
  *
@@ -1810,7 +1859,8 @@
1810
1859
  //#endregion
1811
1860
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneSymbol.js
1812
1861
  /** Used to convert symbols to primitives and strings. */
1813
- var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : void 0;
1862
+ var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0;
1863
+ var symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : void 0;
1814
1864
  /**
1815
1865
  * Creates a clone of the `symbol` object.
1816
1866
  *
@@ -1838,8 +1888,25 @@
1838
1888
  //#endregion
1839
1889
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneByTag.js
1840
1890
  /** `Object#toString` result references. */
1841
- var boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", symbolTag$2 = "[object Symbol]";
1842
- var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
1891
+ var boolTag$2 = "[object Boolean]";
1892
+ var dateTag$2 = "[object Date]";
1893
+ var mapTag$4 = "[object Map]";
1894
+ var numberTag$2 = "[object Number]";
1895
+ var regexpTag$2 = "[object RegExp]";
1896
+ var setTag$4 = "[object Set]";
1897
+ var stringTag$2 = "[object String]";
1898
+ var symbolTag$2 = "[object Symbol]";
1899
+ var arrayBufferTag$2 = "[object ArrayBuffer]";
1900
+ var dataViewTag$2 = "[object DataView]";
1901
+ var float32Tag$1 = "[object Float32Array]";
1902
+ var float64Tag$1 = "[object Float64Array]";
1903
+ var int8Tag$1 = "[object Int8Array]";
1904
+ var int16Tag$1 = "[object Int16Array]";
1905
+ var int32Tag$1 = "[object Int32Array]";
1906
+ var uint8Tag$1 = "[object Uint8Array]";
1907
+ var uint8ClampedTag$1 = "[object Uint8ClampedArray]";
1908
+ var uint16Tag$1 = "[object Uint16Array]";
1909
+ var uint32Tag$1 = "[object Uint32Array]";
1843
1910
  /**
1844
1911
  * Initializes an object clone based on its `toStringTag`.
1845
1912
  *
@@ -1961,10 +2028,36 @@
1961
2028
  //#endregion
1962
2029
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseClone.js
1963
2030
  /** Used to compose bitmasks for cloning. */
1964
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
2031
+ var CLONE_DEEP_FLAG$1 = 1;
2032
+ var CLONE_FLAT_FLAG = 2;
2033
+ var CLONE_SYMBOLS_FLAG$1 = 4;
1965
2034
  /** `Object#toString` result references. */
1966
- var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$1 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]", weakMapTag = "[object WeakMap]";
1967
- var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
2035
+ var argsTag$1 = "[object Arguments]";
2036
+ var arrayTag$1 = "[object Array]";
2037
+ var boolTag$1 = "[object Boolean]";
2038
+ var dateTag$1 = "[object Date]";
2039
+ var errorTag$1 = "[object Error]";
2040
+ var funcTag = "[object Function]";
2041
+ var genTag = "[object GeneratorFunction]";
2042
+ var mapTag$2 = "[object Map]";
2043
+ var numberTag$1 = "[object Number]";
2044
+ var objectTag$1 = "[object Object]";
2045
+ var regexpTag$1 = "[object RegExp]";
2046
+ var setTag$2 = "[object Set]";
2047
+ var stringTag$1 = "[object String]";
2048
+ var symbolTag$1 = "[object Symbol]";
2049
+ var weakMapTag = "[object WeakMap]";
2050
+ var arrayBufferTag$1 = "[object ArrayBuffer]";
2051
+ var dataViewTag$1 = "[object DataView]";
2052
+ var float32Tag = "[object Float32Array]";
2053
+ var float64Tag = "[object Float64Array]";
2054
+ var int8Tag = "[object Int8Array]";
2055
+ var int16Tag = "[object Int16Array]";
2056
+ var int32Tag = "[object Int32Array]";
2057
+ var uint8Tag = "[object Uint8Array]";
2058
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
2059
+ var uint16Tag = "[object Uint16Array]";
2060
+ var uint32Tag = "[object Uint32Array]";
1968
2061
  /** Used to identify `toStringTag` values supported by `_.clone`. */
1969
2062
  var cloneableTags = {};
1970
2063
  cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$2] = cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = cloneableTags[regexpTag$1] = cloneableTags[setTag$2] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
@@ -2028,7 +2121,8 @@
2028
2121
  //#endregion
2029
2122
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/cloneDeep.js
2030
2123
  /** Used to compose bitmasks for cloning. */
2031
- var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
2124
+ var CLONE_DEEP_FLAG = 1;
2125
+ var CLONE_SYMBOLS_FLAG = 4;
2032
2126
  /**
2033
2127
  * This method is like `_.clone` except that it recursively clones `value`.
2034
2128
  *
@@ -2132,7 +2226,8 @@
2132
2226
  //#endregion
2133
2227
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalArrays.js
2134
2228
  /** Used to compose bitmasks for value comparisons. */
2135
- var COMPARE_PARTIAL_FLAG$3 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
2229
+ var COMPARE_PARTIAL_FLAG$3 = 1;
2230
+ var COMPARE_UNORDERED_FLAG$1 = 2;
2136
2231
  /**
2137
2232
  * A specialized version of `baseIsEqualDeep` for arrays with support for
2138
2233
  * partial deep comparisons.
@@ -2214,12 +2309,23 @@
2214
2309
  //#endregion
2215
2310
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalByTag.js
2216
2311
  /** Used to compose bitmasks for value comparisons. */
2217
- var COMPARE_PARTIAL_FLAG$2 = 1, COMPARE_UNORDERED_FLAG = 2;
2312
+ var COMPARE_PARTIAL_FLAG$2 = 1;
2313
+ var COMPARE_UNORDERED_FLAG = 2;
2218
2314
  /** `Object#toString` result references. */
2219
- var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag$1 = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
2220
- var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
2315
+ var boolTag = "[object Boolean]";
2316
+ var dateTag = "[object Date]";
2317
+ var errorTag = "[object Error]";
2318
+ var mapTag$1 = "[object Map]";
2319
+ var numberTag = "[object Number]";
2320
+ var regexpTag = "[object RegExp]";
2321
+ var setTag$1 = "[object Set]";
2322
+ var stringTag = "[object String]";
2323
+ var symbolTag = "[object Symbol]";
2324
+ var arrayBufferTag = "[object ArrayBuffer]";
2325
+ var dataViewTag = "[object DataView]";
2221
2326
  /** Used to convert symbols to primitives and strings. */
2222
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2327
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0;
2328
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2223
2329
  /**
2224
2330
  * A specialized version of `baseIsEqualDeep` for comparing objects of
2225
2331
  * the same `toStringTag`.
@@ -2325,7 +2431,9 @@
2325
2431
  /** Used to compose bitmasks for value comparisons. */
2326
2432
  var COMPARE_PARTIAL_FLAG = 1;
2327
2433
  /** `Object#toString` result references. */
2328
- var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
2434
+ var argsTag = "[object Arguments]";
2435
+ var arrayTag = "[object Array]";
2436
+ var objectTag = "[object Object]";
2329
2437
  /** Used to check objects for own properties. */
2330
2438
  var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
2331
2439
  /**
@@ -2414,7 +2522,8 @@
2414
2522
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js
2415
2523
  /** Error message constants. */
2416
2524
  var FUNC_ERROR_TEXT = "Expected a function";
2417
- var nativeMax = Math.max, nativeMin = Math.min;
2525
+ var nativeMax = Math.max;
2526
+ var nativeMin = Math.min;
2418
2527
  /**
2419
2528
  * Creates a debounced function that delays invoking `func` until after `wait`
2420
2529
  * milliseconds have elapsed since the last time the debounced function was
@@ -2541,7 +2650,8 @@
2541
2650
  //#endregion
2542
2651
  //#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
2543
2652
  /** `Object#toString` result references. */
2544
- var mapTag = "[object Map]", setTag = "[object Set]";
2653
+ var mapTag = "[object Map]";
2654
+ var setTag = "[object Set]";
2545
2655
  /** Used to check objects for own properties. */
2546
2656
  var hasOwnProperty = Object.prototype.hasOwnProperty;
2547
2657
  /**
@@ -2620,54 +2730,523 @@
2620
2730
  return baseIsEqual(value, other);
2621
2731
  }
2622
2732
  //#endregion
2623
- //#region packages/form/src/utils/useAddField.ts
2624
- var useAddField = (prop) => {
2625
- if (!prop) return;
2626
- const mForm = (0, vue.inject)("mForm");
2627
- const instance = (0, vue.getCurrentInstance)();
2628
- (0, vue.watch)(() => instance?.proxy, (vm) => {
2629
- if (vm) mForm?.setField(prop, vm);
2630
- else mForm?.deleteField(prop);
2631
- }, { immediate: true });
2733
+ //#region packages/form/src/utils/typeMatch.ts
2734
+ dayjs.default.extend(dayjs_plugin_customParseFormat.default);
2735
+ var typeMatchRuleRegistry = /* @__PURE__ */ new Map();
2736
+ var isPromise = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
2737
+ /** 注册或覆盖某个字段 type typeMatch 校验规则 */
2738
+ var registerTypeMatchRule = (type, validator) => {
2739
+ typeMatchRuleRegistry.set((0, _tmagic_utils.toLine)(type), validator);
2632
2740
  };
2633
- //#endregion
2634
- //#region packages/form/src/fields/Hidden.vue
2635
- var Hidden_default = /* @__PURE__ */ (0, vue.defineComponent)({
2636
- name: "MFormHidden",
2637
- __name: "Hidden",
2638
- props: {
2639
- model: {},
2640
- name: {},
2641
- prop: {}
2642
- },
2643
- setup(__props) {
2644
- useAddField(__props.prop);
2645
- return (_ctx, _cache) => {
2646
- return __props.model ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createElementBlock)("input", {
2647
- key: 0,
2648
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2649
- type: "hidden"
2650
- }, null, 512)), [[vue.vModelText, __props.model[__props.name]]]) : (0, vue.createCommentVNode)("v-if", true);
2651
- };
2741
+ /** 批量注册 typeMatch 校验规则 */
2742
+ var registerTypeMatchRules = (rules) => {
2743
+ Object.entries(rules).forEach(([type, validator]) => {
2744
+ registerTypeMatchRule(type, validator);
2745
+ });
2746
+ };
2747
+ /** 获取某个字段 type 的自定义 typeMatch 校验规则 */
2748
+ var getTypeMatchRule = (type) => typeMatchRuleRegistry.get((0, _tmagic_utils.toLine)(type));
2749
+ /** 删除某个字段 type 的自定义 typeMatch 校验规则 */
2750
+ var deleteTypeMatchRule = (type) => typeMatchRuleRegistry.delete((0, _tmagic_utils.toLine)(type));
2751
+ /** 清空所有自定义 typeMatch 校验规则 */
2752
+ var clearTypeMatchRules = () => {
2753
+ typeMatchRuleRegistry.clear();
2754
+ };
2755
+ /** 本地解析配置函数,避免与 form.ts 循环依赖 */
2756
+ var resolveConfig = (mForm, config, props) => {
2757
+ if (typeof config === "function") return config(mForm, {
2758
+ values: (0, vue.readonly)(mForm?.initValues || {}),
2759
+ model: (0, vue.readonly)(props.model),
2760
+ parent: (0, vue.readonly)(mForm?.parentValues || {}),
2761
+ formValue: (0, vue.readonly)(mForm?.values || props.model),
2762
+ prop: props.prop,
2763
+ config: props.config,
2764
+ index: props.index,
2765
+ getFormValue: (prop) => (0, _tmagic_utils.getValueByKeyPath)(prop, mForm?.values || props.model)
2766
+ });
2767
+ return config;
2768
+ };
2769
+ var SKIP_TYPES = /* @__PURE__ */ new Set([
2770
+ "display",
2771
+ "hidden",
2772
+ "row",
2773
+ "tab",
2774
+ "dynamic-tab",
2775
+ "fieldset",
2776
+ "panel",
2777
+ "step",
2778
+ "flex-layout",
2779
+ "link",
2780
+ "component",
2781
+ "dynamic-field",
2782
+ "dynamicfield",
2783
+ "form",
2784
+ "container"
2785
+ ]);
2786
+ var STRING_TYPES = /* @__PURE__ */ new Set([
2787
+ "text",
2788
+ "textarea",
2789
+ "color-picker",
2790
+ "html",
2791
+ ""
2792
+ ]);
2793
+ var DATE_LIKE_TYPES = /* @__PURE__ */ new Set([
2794
+ "date",
2795
+ "datetime",
2796
+ "time"
2797
+ ]);
2798
+ var DATE_LIKE_DEFAULT_VALUE_FORMAT = {
2799
+ date: "YYYY/MM/DD",
2800
+ datetime: "YYYY/MM/DD HH:mm:ss",
2801
+ time: "HH:mm:ss",
2802
+ daterange: "YYYY/MM/DD HH:mm:ss",
2803
+ timerange: "HH:mm:ss"
2804
+ };
2805
+ var TIMESTAMP_VALUE_FORMATS = /* @__PURE__ */ new Set(["x", "timestamp"]);
2806
+ /**
2807
+ * 将值格式化为可读的参考示例字符串。
2808
+ */
2809
+ var stringifyExampleValue = (value) => {
2810
+ if (typeof value === "string") return `"${value}"`;
2811
+ if (value === null || value === void 0) return String(value);
2812
+ if (typeof value === "object") try {
2813
+ return JSON.stringify(value);
2814
+ } catch {
2815
+ return String(value);
2652
2816
  }
2653
- });
2654
- //#endregion
2655
- //#region packages/form/src/utils/config.ts
2656
- var $MAGIC_FORM = {};
2657
- var setConfig = (option) => {
2658
- $MAGIC_FORM = option;
2817
+ return String(value);
2659
2818
  };
2660
- var getConfig = (key) => $MAGIC_FORM[key];
2661
- var fieldRegistry = /* @__PURE__ */ new Map();
2662
- var registerField = (tagName, component) => {
2663
- if (fieldRegistry.has(tagName)) return;
2664
- fieldRegistry.set(tagName, component);
2819
+ var MAX_SUGGESTION_OPTIONS = 20;
2820
+ /**
2821
+ * 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
2822
+ * 可选值超过 MAX_SUGGESTION_OPTIONS 个时仅展示前若干个并以「等」省略。
2823
+ */
2824
+ var optionSuggestion = (optionValues) => {
2825
+ const values = optionValues.filter((item) => typeof item !== "undefined");
2826
+ if (!values.length) return "";
2827
+ const shown = values.slice(0, MAX_SUGGESTION_OPTIONS).map(stringifyExampleValue);
2828
+ const suffix = values.length > MAX_SUGGESTION_OPTIONS ? " 等" : "";
2829
+ return `请使用以下某一个值:${shown.join(";")}${suffix}`;
2830
+ };
2831
+ /**
2832
+ * 基于真实 options 生成类型不匹配场景的「参考示例值」。
2833
+ *
2834
+ * - expectArray 为 true 时,取前若干个真实可选值组成数组示例;
2835
+ * - 否则取第一个真实可选值作为标量示例。
2836
+ * 无可用 options 时回退到通用示例。
2837
+ */
2838
+ var optionExampleSuggestion = (optionValues, fallbackExample, expectArray) => {
2839
+ const values = optionValues.filter((item) => typeof item !== "undefined");
2840
+ if (!values.length) return `请参考以下示例值:${fallbackExample}`;
2841
+ return `请参考以下示例值:${expectArray ? stringifyExampleValue(values.slice(0, 2)) : stringifyExampleValue(values[0])}`;
2842
+ };
2843
+ /**
2844
+ * 生成开关类字段的参考建议,列出合法的开关值。
2845
+ */
2846
+ var toggleSuggestion = (activeValue, inactiveValue) => `请使用以下某一个值:${stringifyExampleValue(activeValue)};${stringifyExampleValue(inactiveValue)}`;
2847
+ /**
2848
+ * 解析字段配置中的真实默认值(defaultValue),用于生成「真实」的参考示例值。
2849
+ * defaultValue 可能是函数,交由 resolveConfig 处理;未配置时返回 undefined。
2850
+ */
2851
+ var resolveFieldDefaultValue = (mForm, props) => {
2852
+ const { defaultValue } = props.config || {};
2853
+ if (typeof defaultValue === "undefined" || defaultValue === "undefined") return void 0;
2854
+ const resolvedDefaultValue = resolveConfig(mForm, defaultValue, props);
2855
+ if (isPromise(resolvedDefaultValue)) return;
2856
+ return resolvedDefaultValue;
2857
+ };
2858
+ var isNumberValue = (value) => typeof value === "number" && !Number.isNaN(value);
2859
+ var isStringValue = (value) => typeof value === "string";
2860
+ var isObjectValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2861
+ var isObjectArrayValue = (value) => Array.isArray(value) && value.every((item) => isObjectValue(item));
2862
+ var isNumberRangeValue = (value) => Array.isArray(value) && value.length === 2 && value.every((item) => isNumberValue(item));
2863
+ /**
2864
+ * 生成类型不匹配场景的「参考示例值」。
2865
+ *
2866
+ * 优先使用字段配置的真实默认值(defaultValue,需符合期望类型);无可用默认值时回退到通用示例。
2867
+ */
2868
+ var typeExampleSuggestion = (mForm, props, fallbackExample, isValid) => {
2869
+ const defaultValue = resolveFieldDefaultValue(mForm, props);
2870
+ return `请参考以下示例值:${typeof defaultValue !== "undefined" && isValid(defaultValue) ? stringifyExampleValue(defaultValue) : fallbackExample}`;
2871
+ };
2872
+ /**
2873
+ * 返回最终错误文案。
2874
+ *
2875
+ * - 传入了自定义 `message` 时,直接使用自定义文案(不追加建议);
2876
+ * - 否则使用默认文案 `fallback`,并在其后拼接「参考建议」。
2877
+ * 参考建议给出一个可参考的示例值(如可选项列表、示例数据),仅用于错误汇总展示;
2878
+ * form-item 行内错误不展示建议(由 @tmagic/design FormItem 在渲染时截断建议)。
2879
+ * 主文案与建议的拼接/截断统一复用 @tmagic/design 的 `appendValidateSuggestion`。
2880
+ */
2881
+ var defaultMessage = (message, fallback, suggestion) => {
2882
+ if (message) return message;
2883
+ return (0, _tmagic_design.appendValidateSuggestion)(fallback, suggestion);
2884
+ };
2885
+ var isEmptyValue = (value) => value === void 0 || value === null || value === "";
2886
+ var isEmptyArray = (value) => Array.isArray(value) && value.length === 0;
2887
+ var resolveDateValueFormat = (fieldType, config) => config.valueFormat || DATE_LIKE_DEFAULT_VALUE_FORMAT[fieldType] || "YYYY/MM/DD HH:mm:ss";
2888
+ var isTimestampValueFormat = (valueFormat) => TIMESTAMP_VALUE_FORMATS.has(valueFormat);
2889
+ var isValidDateValueByFormat = (value, valueFormat) => {
2890
+ if (isTimestampValueFormat(valueFormat)) return typeof value === "number" && !Number.isNaN(value);
2891
+ if (typeof value !== "string") return false;
2892
+ return (0, dayjs.default)(value, valueFormat, true).isValid();
2893
+ };
2894
+ /**
2895
+ * 生成单个日期类字段的参考示例值:时间戳格式给出当前时间戳,其余按 valueFormat 格式化当前时间。
2896
+ */
2897
+ var dateSuggestion = (valueFormat) => isTimestampValueFormat(valueFormat) ? `请参考以下示例值:${Date.now()}` : `请参考以下示例值:"${(0, dayjs.default)().format(valueFormat)}"`;
2898
+ /**
2899
+ * 生成日期范围类字段的参考示例值(长度为 2 的数组)。
2900
+ */
2901
+ var dateRangeSuggestion = (valueFormat) => {
2902
+ if (isTimestampValueFormat(valueFormat)) return `请参考以下示例值:[${Date.now()}, ${Date.now()}]`;
2903
+ const example = (0, dayjs.default)().format(valueFormat);
2904
+ return `请参考以下示例值:["${example}", "${example}"]`;
2905
+ };
2906
+ var dateValueFormatErrorMessage = (message, valueFormat) => defaultMessage(message, isTimestampValueFormat(valueFormat) ? "值类型应为时间戳数字" : `值格式应为 ${valueFormat}`, dateSuggestion(valueFormat));
2907
+ var resolveToggleValues = (config) => {
2908
+ const filterIsNumber = config.filter === "number";
2909
+ const { activeValue: configActiveValue, inactiveValue: configInactiveValue } = config;
2910
+ let activeValue = configActiveValue;
2911
+ let inactiveValue = configInactiveValue;
2912
+ if (typeof activeValue === "undefined") activeValue = filterIsNumber ? 1 : true;
2913
+ if (typeof inactiveValue === "undefined") inactiveValue = filterIsNumber ? 0 : false;
2914
+ return {
2915
+ activeValue,
2916
+ inactiveValue
2917
+ };
2918
+ };
2919
+ var flattenSelectOptions = (options) => {
2920
+ const values = [];
2921
+ options.forEach((option) => {
2922
+ if (Array.isArray(option?.options)) {
2923
+ option.options.forEach((child) => {
2924
+ if (typeof child?.value !== "undefined") values.push(child.value);
2925
+ });
2926
+ return;
2927
+ }
2928
+ if (typeof option?.value !== "undefined") values.push(option.value);
2929
+ });
2930
+ return values;
2931
+ };
2932
+ var resolveOptions = (props) => {
2933
+ const { options } = props.config || {};
2934
+ return Array.isArray(options) ? options : [];
2935
+ };
2936
+ var includesOptionValue = (optionValues, value) => optionValues.some((item) => Object.is(item, value));
2937
+ var collectCascaderLeafValues = (options, result = []) => {
2938
+ options.forEach((option) => {
2939
+ if (option.children?.length) collectCascaderLeafValues(option.children, result);
2940
+ else if (typeof option.value !== "undefined") result.push(option.value);
2941
+ });
2942
+ return result;
2943
+ };
2944
+ var isValidCascaderPath = (options, path) => {
2945
+ if (!path.length) return false;
2946
+ let currentOptions = options;
2947
+ for (let i = 0; i < path.length; i++) {
2948
+ const node = currentOptions.find((option) => Object.is(option.value, path[i]));
2949
+ if (!node) return false;
2950
+ if (i === path.length - 1) return true;
2951
+ currentOptions = node.children || [];
2952
+ }
2953
+ return false;
2954
+ };
2955
+ /**
2956
+ * 取 cascader options 的第一条完整路径(从顶层到叶子的 value 数组)。
2957
+ */
2958
+ var firstCascaderPath = (options) => {
2959
+ const path = [];
2960
+ let current = options;
2961
+ while (current?.length) {
2962
+ const node = current[0];
2963
+ if (typeof node.value === "undefined") break;
2964
+ path.push(node.value);
2965
+ current = node.children;
2966
+ }
2967
+ return path;
2968
+ };
2969
+ /**
2970
+ * 基于真实 cascader options 生成类型不匹配场景的「参考示例值」。
2971
+ *
2972
+ * 依据 valueSeparator / multiple / emitPath 组织真实选中值的形态;无可用 options 时回退到通用示例。
2973
+ */
2974
+ var cascaderExampleSuggestion = (options, config, valueSeparator, fallbackExample) => {
2975
+ const path = firstCascaderPath(options);
2976
+ if (!path.length) return `请参考以下示例值:${fallbackExample}`;
2977
+ const emitPath = config.emitPath !== false;
2978
+ const multiple = Boolean(config.multiple);
2979
+ const single = emitPath ? path : path[path.length - 1];
2980
+ let example;
2981
+ if (valueSeparator) example = path.join(valueSeparator);
2982
+ else if (multiple) example = [single];
2983
+ else example = single;
2984
+ return `请参考以下示例值:${stringifyExampleValue(example)}`;
2985
+ };
2986
+ var validateSelectValue = (value, config, optionValues, message) => {
2987
+ if (optionValues.length === 0) return;
2988
+ if (config.allowCreate || config.remote) {
2989
+ if (config.multiple) {
2990
+ if (!Array.isArray(value)) return defaultMessage(message, `${value} 类型应为数组`, optionExampleSuggestion(optionValues, "[\"选项1\", \"选项2\"]", true));
2991
+ return;
2992
+ }
2993
+ if (typeof value === "object") return defaultMessage(message, `${value} 类型不合法`, optionExampleSuggestion(optionValues, "\"文本内容\" 或 123", false));
2994
+ return;
2995
+ }
2996
+ const isStaticOptions = Array.isArray(config.options);
2997
+ if (config.multiple) {
2998
+ if (!Array.isArray(value)) return defaultMessage(message, `${value} 类型应为数组`, optionExampleSuggestion(optionValues, "[\"选项1\", \"选项2\"]", true));
2999
+ if (isStaticOptions && value.some((item) => !includesOptionValue(optionValues, item))) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
3000
+ return;
3001
+ }
3002
+ if (isStaticOptions && !includesOptionValue(optionValues, value)) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
3003
+ };
3004
+ var validateCascaderValue = (value, config, props, mForm, message) => {
3005
+ const options = resolveOptions(props);
3006
+ if (!options.length) return;
3007
+ const valueSeparator = resolveConfig(mForm, config.valueSeparator, props);
3008
+ if (isPromise(valueSeparator)) return;
3009
+ const emitPath = config.emitPath !== false;
3010
+ const multiple = Boolean(config.multiple);
3011
+ const cascaderExample = (fallbackExample) => cascaderExampleSuggestion(options, config, valueSeparator, fallbackExample);
3012
+ if (valueSeparator) {
3013
+ if (typeof value !== "string" && !Array.isArray(value)) return defaultMessage(message, `${value} 类型应为字符串或数组`, cascaderExample("\"选项1,选项2\" 或 [\"选项1\", \"选项2\"]"));
3014
+ } else if (multiple) {
3015
+ if (!Array.isArray(value)) return defaultMessage(message, `${value} 类型应为数组`, cascaderExample("[\"选项1\", \"选项2\"]"));
3016
+ } else if (emitPath && !Array.isArray(value)) return defaultMessage(message, `${value} 类型应为数组`, cascaderExample("[\"选项1\", \"选项2\"]"));
3017
+ if (config.remote) return;
3018
+ if (!options.length) return;
3019
+ const normalizedValue = typeof value === "string" && valueSeparator ? value.split(valueSeparator) : value;
3020
+ if (multiple) {
3021
+ if (!Array.isArray(normalizedValue)) return defaultMessage(message, `${value} 类型应为数组`, cascaderExample("[\"选项1\", \"选项2\"]"));
3022
+ if (normalizedValue.some((item) => {
3023
+ if (emitPath) return !Array.isArray(item) || !isValidCascaderPath(options, item);
3024
+ return !includesOptionValue(collectCascaderLeafValues(options), item);
3025
+ })) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(collectCascaderLeafValues(options)));
3026
+ return;
3027
+ }
3028
+ if (emitPath) {
3029
+ if (!Array.isArray(normalizedValue) || !isValidCascaderPath(options, normalizedValue)) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(collectCascaderLeafValues(options)));
3030
+ return;
3031
+ }
3032
+ if (!includesOptionValue(collectCascaderLeafValues(options), normalizedValue)) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(collectCascaderLeafValues(options)));
3033
+ };
3034
+ var validateBuiltinTypeMatch = (value, fieldType, mForm, props, message) => {
3035
+ if (SKIP_TYPES.has(fieldType)) return;
3036
+ const config = props.config || {};
3037
+ if (STRING_TYPES.has(fieldType)) {
3038
+ if (config.filter === "number") {
3039
+ if (typeof value !== "number" || Number.isNaN(value)) return defaultMessage(message, `${value} 类型应为数字`, typeExampleSuggestion(mForm, props, "123", isNumberValue));
3040
+ return;
3041
+ }
3042
+ if (typeof config.filter === "function") return;
3043
+ if (fieldType === "text" && isNumberValue(value)) return;
3044
+ if (typeof value !== "string") return defaultMessage(message, `${value} 类型应为字符串`, typeExampleSuggestion(mForm, props, "\"文本内容\"", isStringValue));
3045
+ return;
3046
+ }
3047
+ if (DATE_LIKE_TYPES.has(fieldType)) {
3048
+ const valueFormat = resolveDateValueFormat(fieldType, config);
3049
+ if (!isValidDateValueByFormat(value, valueFormat)) return dateValueFormatErrorMessage(message, valueFormat);
3050
+ return;
3051
+ }
3052
+ if (fieldType === "number") {
3053
+ if (typeof value !== "number" || Number.isNaN(value)) return defaultMessage(message, `${value} 类型应为数字`, typeExampleSuggestion(mForm, props, "123", isNumberValue));
3054
+ return;
3055
+ }
3056
+ if (fieldType === "number-range") {
3057
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== "number" || Number.isNaN(item))) return defaultMessage(message, `${value} 类型应为长度为 2 的数字数组`, typeExampleSuggestion(mForm, props, "[0, 100]", isNumberRangeValue));
3058
+ return;
3059
+ }
3060
+ if (fieldType === "switch" || fieldType === "checkbox") {
3061
+ const { activeValue, inactiveValue } = resolveToggleValues(config);
3062
+ if (!Object.is(value, activeValue) && !Object.is(value, inactiveValue)) return defaultMessage(message, `${value} 不在合法开关值中`, toggleSuggestion(activeValue, inactiveValue));
3063
+ return;
3064
+ }
3065
+ if (fieldType === "select") return validateSelectValue(value, config, flattenSelectOptions(resolveOptions(props)), message);
3066
+ if (fieldType === "radio-group") {
3067
+ const optionValues = flattenSelectOptions(resolveOptions(props));
3068
+ if (optionValues.length === 0) return;
3069
+ if (!includesOptionValue(optionValues, value)) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
3070
+ return;
3071
+ }
3072
+ if (fieldType === "checkbox-group") {
3073
+ const optionValues = flattenSelectOptions(resolveOptions(props));
3074
+ if (optionValues.length === 0) return;
3075
+ if (!Array.isArray(value)) return defaultMessage(message, `${value} 类型应为数组`, optionExampleSuggestion(optionValues, "[\"选项1\", \"选项2\"]", true));
3076
+ if (value.some((item) => !includesOptionValue(optionValues, item))) return defaultMessage(message, `${value} 不在可选项中`, optionSuggestion(optionValues));
3077
+ return;
3078
+ }
3079
+ if (fieldType === "cascader") return validateCascaderValue(value, config, props, mForm, message);
3080
+ if (fieldType === "daterange" || fieldType === "timerange") {
3081
+ if (config.names) return;
3082
+ const valueFormat = resolveDateValueFormat(fieldType, config);
3083
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => !isValidDateValueByFormat(item, valueFormat))) return defaultMessage(message, isTimestampValueFormat(valueFormat) ? `${value} 类型应为长度为 2 的时间戳数字数组` : `${value} 格式应为长度为 2 的 ${valueFormat} 数组`, dateRangeSuggestion(valueFormat));
3084
+ return;
3085
+ }
3086
+ if (fieldType === "table" || fieldType === "group-list" || fieldType === "grouplist") {
3087
+ if (!Array.isArray(value) || value.some((item) => !isObjectValue(item))) return defaultMessage(message, `${value} 类型应为对象数组`, typeExampleSuggestion(mForm, props, "[{}]", isObjectArrayValue));
3088
+ return;
3089
+ }
3090
+ };
3091
+ /**
3092
+ * 校验取值与字段 type 是否匹配;通过返回 undefined,否则返回错误文案。
3093
+ *
3094
+ * 命中的自定义规则是异步校验器时返回 Promise,内置规则始终同步返回。
3095
+ */
3096
+ var validateTypeMatch = (value, mForm, props, message) => {
3097
+ if (isEmptyValue(value) || isEmptyArray(value)) return;
3098
+ if (!props.config?.name) return;
3099
+ const rawFieldType = "type" in (props.config || {}) ? props.config.type : "";
3100
+ if (typeof rawFieldType !== "string" || !rawFieldType) return;
3101
+ const fieldType = (0, _tmagic_utils.toLine)(rawFieldType);
3102
+ const customValidator = getTypeMatchRule(fieldType);
3103
+ if (customValidator) return customValidator(value, {
3104
+ fieldType,
3105
+ mForm,
3106
+ props,
3107
+ message
3108
+ });
3109
+ return validateBuiltinTypeMatch(value, fieldType, mForm, props, message);
3110
+ };
3111
+ var toError = (error) => error instanceof Error ? error : /* @__PURE__ */ new Error(`${error}`);
3112
+ var createTypeMatchValidator = (mForm, props, rule) => {
3113
+ const originalValidator = typeof rule.validator === "function" ? rule.validator : void 0;
3114
+ /**
3115
+ * 每次校验取一个自增序号,只有最新一轮的结论会被采用。
3116
+ *
3117
+ * 旧值的在途校验不能用自己的结论结算:它可能晚于新校验结束,用过期结论覆盖新结论
3118
+ * (表单取最后结束的那次结果);也不能在新校验开始时无条件按通过结算,否则
3119
+ * `form.validate()` 会对一个还没校验过的值返回成功。因此所有尚未结算的调用都登记在
3120
+ * pendingSettlers 中,等最新一轮出结论后用同一个结论一起结算。
3121
+ *
3122
+ * 不比较取值本身:配了 names 或取值为对象/数组时拿到的是同一个引用,就地修改后比较不出变化。
3123
+ */
3124
+ let generation = 0;
3125
+ let pendingSettlers = [];
3126
+ return (asyncValidatorRule, value, callback, source, options) => {
3127
+ const actualValue = props.config?.names ? props.model : value;
3128
+ generation += 1;
3129
+ const currentGeneration = generation;
3130
+ /** 已有更新的一轮校验开始,本轮结论作废 */
3131
+ const isStale = () => currentGeneration !== generation;
3132
+ pendingSettlers.push((args) => callback(...args));
3133
+ /**
3134
+ * 结算本轮与被本轮取代的所有在途校验。
3135
+ *
3136
+ * async-validator 的 callback 不幂等:重复调用会让它的内部计数提前满足、错误信息重复;
3137
+ * 原始 validator 写成 async 时很容易既调 callback 又返回 Promise,故所有回调都收敛到这里,
3138
+ * 由「取出即出队」保证每个调用的 callback 只会被调用一次。
3139
+ */
3140
+ const conclude = (...args) => {
3141
+ if (isStale()) return;
3142
+ const settlers = pendingSettlers;
3143
+ pendingSettlers = [];
3144
+ for (const settle of settlers) settle(args);
3145
+ };
3146
+ /**
3147
+ * 执行原始 validator 并把结果统一转成 callback。
3148
+ *
3149
+ * async-validator 只解析同步返回给它的返回值(true / false / Error / 错误数组 / Promise,
3150
+ * 抛错转成错误信息),异步路径已脱离它的调用栈,这些约定会失效导致校验永不结束,故复刻一份。
3151
+ */
3152
+ const settleWithOriginalValidator = () => {
3153
+ if (isStale()) return;
3154
+ if (!originalValidator) {
3155
+ conclude();
3156
+ return;
3157
+ }
3158
+ let result;
3159
+ try {
3160
+ result = originalValidator({
3161
+ rule: asyncValidatorRule,
3162
+ value: actualValue,
3163
+ callback: conclude,
3164
+ source,
3165
+ options
3166
+ }, {
3167
+ values: mForm?.initValues || {},
3168
+ model: props.model,
3169
+ parent: mForm?.parentValues || {},
3170
+ formValue: mForm?.values || props.model,
3171
+ prop: props.prop,
3172
+ config: props.config
3173
+ }, mForm);
3174
+ } catch (err) {
3175
+ conclude(toError(err));
3176
+ return;
3177
+ }
3178
+ if (isPromise(result)) result.then(() => conclude(), (err) => conclude(toError(err)));
3179
+ else if (result === true) conclude();
3180
+ else if (result === false) {
3181
+ const field = asyncValidatorRule?.fullField || asyncValidatorRule?.field || props.prop;
3182
+ conclude(new Error(rule.message || `${field} fails`));
3183
+ } else if (result instanceof Error || Array.isArray(result)) conclude(result);
3184
+ };
3185
+ const skipFailedTypeMatch = (err) => {
3186
+ console.error(err);
3187
+ settleWithOriginalValidator();
3188
+ };
3189
+ let error;
3190
+ try {
3191
+ error = validateTypeMatch(actualValue, mForm, props, rule.message);
3192
+ } catch (err) {
3193
+ skipFailedTypeMatch(err);
3194
+ return;
3195
+ }
3196
+ if (isPromise(error)) {
3197
+ error.then((asyncMessage) => {
3198
+ if (asyncMessage) {
3199
+ conclude(new Error(asyncMessage));
3200
+ return;
3201
+ }
3202
+ settleWithOriginalValidator();
3203
+ }, skipFailedTypeMatch);
3204
+ return;
3205
+ }
3206
+ if (error) {
3207
+ conclude(new Error(error));
3208
+ return;
3209
+ }
3210
+ settleWithOriginalValidator();
3211
+ };
2665
3212
  };
2666
- var getField = (tagName) => fieldRegistry.get(tagName);
2667
- var deleteField = (tagName) => fieldRegistry.delete(tagName);
2668
3213
  //#endregion
2669
3214
  //#region packages/form/src/utils/form.ts
2670
- var TABLE_SELECT_TYPES = new Set(["table-select", "tableSelect"]);
3215
+ var isTDesignAdapter = () => (0, _tmagic_design.getDesignConfig)("adapterType") === "tdesign-vue-next";
3216
+ /**
3217
+ * 将 async-validator(Element Plus)风格的 validator 适配到当前 UI 库。
3218
+ * TDesign 调用签名为 `(val) => boolean | CustomValidateObj | Promise`,无 callback。
3219
+ */
3220
+ var adaptFormValidator = (validator) => {
3221
+ return (arg1, arg2, arg3, arg4, arg5) => {
3222
+ if (!isTDesignAdapter()) return validator(arg1, arg2, arg3, arg4, arg5);
3223
+ const value = arg1;
3224
+ return new Promise((resolve) => {
3225
+ let settled = false;
3226
+ const callback = (error) => {
3227
+ if (settled) return;
3228
+ settled = true;
3229
+ const first = Array.isArray(error) ? error[0] : error;
3230
+ if (first) resolve({
3231
+ result: false,
3232
+ message: typeof first === "string" ? first : first.message
3233
+ });
3234
+ else resolve(true);
3235
+ };
3236
+ try {
3237
+ const result = validator(void 0, value, callback);
3238
+ if (result && typeof result.then === "function") Promise.resolve(result).then(() => {
3239
+ if (!settled) callback();
3240
+ }, (err) => {
3241
+ callback(err instanceof Error ? err : new Error(String(err)));
3242
+ });
3243
+ } catch (e) {
3244
+ callback(e instanceof Error ? e : new Error(String(e)));
3245
+ }
3246
+ });
3247
+ };
3248
+ };
3249
+ var TABLE_SELECT_TYPES = /* @__PURE__ */ new Set(["table-select", "tableSelect"]);
2671
3250
  var isTableSelect = (type) => typeof type === "string" && TABLE_SELECT_TYPES.has(type);
2672
3251
  var asyncLoadConfig = (value, initValue, { asyncLoad, name, type }) => {
2673
3252
  if (type === "html" && typeof asyncLoad === "object" && typeof name !== "undefined") {
@@ -2675,7 +3254,7 @@
2675
3254
  value.asyncLoad = typeof initValue.asyncLoad === "object" ? initValue.asyncLoad : asyncLoad;
2676
3255
  }
2677
3256
  };
2678
- var MULTIPLE_VALUE_TYPES = new Set([
3257
+ var MULTIPLE_VALUE_TYPES = /* @__PURE__ */ new Set([
2679
3258
  "checkbox-group",
2680
3259
  "checkboxGroup",
2681
3260
  "table",
@@ -2762,13 +3341,18 @@
2762
3341
  if (config === false) return false;
2763
3342
  return true;
2764
3343
  };
2765
- var getRules = function(mForm, rules = [], props) {
2766
- rules = cloneDeep(rules);
3344
+ var getRules = function(mForm, r = [], props, typeMatchValid) {
3345
+ let rules = cloneDeep(r);
2767
3346
  if (typeof rules === "object" && !Array.isArray(rules)) rules = [rules];
3347
+ if (typeMatchValid?.value && !rules.some((r) => typeof r.typeMatch !== "undefined")) rules.push({ typeMatch: true });
2768
3348
  return rules.map((item) => {
3349
+ if (item.typeMatch) {
3350
+ item.validator = adaptFormValidator(createTypeMatchValidator(mForm, props, item));
3351
+ return item;
3352
+ }
2769
3353
  if (typeof item.validator === "function") {
2770
3354
  const fnc = item.validator;
2771
- item.validator = (rule, value, callback, source, options) => fnc({
3355
+ item.validator = adaptFormValidator((rule, value, callback, source, options) => fnc({
2772
3356
  rule,
2773
3357
  value: props.config.names ? props.model : value,
2774
3358
  callback,
@@ -2781,7 +3365,7 @@
2781
3365
  formValue: mForm?.values || props.model,
2782
3366
  prop: props.prop,
2783
3367
  config: props.config
2784
- }, mForm);
3368
+ }, mForm));
2785
3369
  }
2786
3370
  return item;
2787
3371
  });
@@ -2826,6 +3410,40 @@
2826
3410
  if (order === "ascending") data.sort((a, b) => a[prop] - b[prop]);
2827
3411
  else if (order === "descending") data.sort((a, b) => b[prop] - a[prop]);
2828
3412
  };
3413
+ /**
3414
+ * 将 extendState 返回的扩展字段合并进 formState。
3415
+ *
3416
+ * - data 描述符(普通字段)通过 `formState[key] = value` 写入,走 reactive proxy 的 set,
3417
+ * 触发依赖通知;
3418
+ * - accessor 描述符(`{ get stage() { return ... } }`)按原样 defineProperty,调用方
3419
+ * 可控制读时求值;强制 `configurable: true` 以便下一次合并可再 define。
3420
+ *
3421
+ * 注意:extendState 只能向 formState「新增」字段,不允许覆盖其已有 key。
3422
+ * 调用方可通过 `reservedKeys` 传入合并前已存在的内置 key 快照(keyProp / popperClass /
3423
+ * config / initValues / isCompare / lastValues / parentValues / values / $emit / fields /
3424
+ * post 等),命中这些 key 时统一跳过并告警。
3425
+ *
3426
+ * 兜底:未传 `reservedKeys` 时,仍会拦截 props 派生的只读 getter 字段(无 setter),
3427
+ * 否则以普通字段形式赋值会让 proxy 的 set trap 抛出
3428
+ * `TypeError: 'set' on proxy: trap returned falsish`。
3429
+ */
3430
+ var applyExtendState = (formState, state, reservedKeys) => {
3431
+ if (!state) return;
3432
+ for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(state))) {
3433
+ if (reservedKeys?.has(key)) continue;
3434
+ if (!("value" in descriptor)) {
3435
+ descriptor.configurable = true;
3436
+ Object.defineProperty(formState, key, descriptor);
3437
+ continue;
3438
+ }
3439
+ const targetDescriptor = Object.getOwnPropertyDescriptor(formState, key);
3440
+ if (targetDescriptor && !("value" in targetDescriptor) && typeof targetDescriptor.set !== "function") {
3441
+ console.warn(`[MForm] extendState: "${key}" is a read-only field derived from props and cannot be assigned a plain value. Return it as a getter accessor if you really need to override it.`);
3442
+ continue;
3443
+ }
3444
+ formState[key] = state[key];
3445
+ }
3446
+ };
2829
3447
  var createObjectProp = (prop, key, name) => {
2830
3448
  if (prop === "") return key;
2831
3449
  const itemPath = `${prop}`.split(".");
@@ -2835,6 +3453,54 @@
2835
3453
  return `${[...itemPath, key].join(".")}`;
2836
3454
  };
2837
3455
  //#endregion
3456
+ //#region packages/form/src/utils/useAddField.ts
3457
+ var useAddField = (prop) => {
3458
+ if (!prop) return;
3459
+ const mForm = (0, vue.inject)("mForm");
3460
+ const instance = (0, vue.getCurrentInstance)();
3461
+ (0, vue.watch)(() => instance?.proxy, (vm) => {
3462
+ if (vm) mForm?.setField(prop, vm);
3463
+ else mForm?.deleteField(prop);
3464
+ }, { immediate: true });
3465
+ };
3466
+ //#endregion
3467
+ //#region packages/form/src/fields/Hidden.vue
3468
+ var Hidden_default = /* @__PURE__ */ (0, vue.defineComponent)({
3469
+ name: "MFormHidden",
3470
+ __name: "Hidden",
3471
+ props: {
3472
+ model: {},
3473
+ name: {},
3474
+ prop: {}
3475
+ },
3476
+ setup(__props) {
3477
+ useAddField(__props.prop);
3478
+ return (_ctx, _cache) => {
3479
+ return __props.model ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createElementBlock)("input", {
3480
+ key: 0,
3481
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3482
+ type: "hidden"
3483
+ }, null, 512)), [[vue.vModelText, __props.model[__props.name]]]) : (0, vue.createCommentVNode)("v-if", true);
3484
+ };
3485
+ }
3486
+ });
3487
+ //#endregion
3488
+ //#region packages/form/src/utils/config.ts
3489
+ var $MAGIC_FORM = {};
3490
+ var isGlobalFlat = (0, vue.ref)(false);
3491
+ var setConfig = (option) => {
3492
+ $MAGIC_FORM = option;
3493
+ isGlobalFlat.value = option.flat ?? false;
3494
+ };
3495
+ var getConfig = (key) => $MAGIC_FORM[key];
3496
+ var fieldRegistry = /* @__PURE__ */ new Map();
3497
+ var registerField = (tagName, component) => {
3498
+ if (fieldRegistry.has(tagName)) return;
3499
+ fieldRegistry.set(tagName, component);
3500
+ };
3501
+ var getField = (tagName) => fieldRegistry.get(tagName);
3502
+ var deleteField = (tagName) => fieldRegistry.delete(tagName);
3503
+ //#endregion
2838
3504
  //#region packages/form/src/containers/FormLabel.vue?vue&type=script&setup=true&lang.ts
2839
3505
  var _hoisted_1$15 = {
2840
3506
  key: 0,
@@ -2843,9 +3509,9 @@
2843
3509
  "align-items": "center"
2844
3510
  }
2845
3511
  };
2846
- var _hoisted_2$8 = ["innerHTML", "title"];
2847
- var _hoisted_3$7 = ["innerHTML"];
2848
- var _hoisted_4$5 = ["innerHTML", "title"];
3512
+ var _hoisted_2$9 = ["innerHTML", "title"];
3513
+ var _hoisted_3$8 = ["innerHTML"];
3514
+ var _hoisted_4$7 = ["innerHTML", "title"];
2849
3515
  //#endregion
2850
3516
  //#region packages/form/src/containers/FormLabel.vue
2851
3517
  var FormLabel_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -2862,11 +3528,11 @@
2862
3528
  return __props.tip ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$15, [(0, vue.createElementVNode)("span", {
2863
3529
  innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
2864
3530
  title: __props.labelTitle
2865
- }, null, 8, _hoisted_2$8), __props.tip && (__props.type !== "checkbox" || __props.useLabel) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
3531
+ }, null, 8, _hoisted_2$9), __props.tip && (__props.type !== "checkbox" || __props.useLabel) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
2866
3532
  key: 0,
2867
3533
  placement: "top"
2868
3534
  }, {
2869
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.tip }, null, 8, _hoisted_3$7)]),
3535
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.tip }, null, 8, _hoisted_3$8)]),
2870
3536
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), { style: {
2871
3537
  "margin-left": "5px",
2872
3538
  "display": "flex"
@@ -2879,23 +3545,27 @@
2879
3545
  key: 1,
2880
3546
  innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
2881
3547
  title: __props.labelTitle
2882
- }, null, 8, _hoisted_4$5));
3548
+ }, null, 8, _hoisted_4$7));
2883
3549
  };
2884
3550
  }
2885
3551
  });
2886
3552
  //#endregion
2887
3553
  //#region packages/form/src/containers/Container.vue?vue&type=script&setup=true&lang.ts
2888
3554
  var _hoisted_1$14 = ["data-tmagic-id", "data-tmagic-form-item-prop"];
2889
- var _hoisted_2$7 = ["innerHTML"];
2890
- var _hoisted_3$6 = ["innerHTML"];
2891
- var _hoisted_4$4 = ["innerHTML"];
2892
- var _hoisted_5$3 = ["innerHTML"];
2893
- var _hoisted_6$1 = ["innerHTML"];
2894
- var _hoisted_7$1 = ["innerHTML"];
2895
- var _hoisted_8$1 = ["innerHTML"];
2896
- var _hoisted_9 = {
3555
+ var _hoisted_2$8 = {
3556
+ key: 0,
3557
+ class: "m-form-tip m-form-title-extra"
3558
+ };
3559
+ var _hoisted_3$7 = ["innerHTML"];
3560
+ var _hoisted_4$6 = ["innerHTML"];
3561
+ var _hoisted_5$4 = ["innerHTML"];
3562
+ var _hoisted_6$3 = ["innerHTML"];
3563
+ var _hoisted_7$2 = ["innerHTML"];
3564
+ var _hoisted_8$2 = ["innerHTML"];
3565
+ var _hoisted_9 = ["innerHTML"];
3566
+ var _hoisted_10 = {
2897
3567
  key: 5,
2898
- style: { "text-align": "center" }
3568
+ class: "m-form-container-expand"
2899
3569
  };
2900
3570
  //#endregion
2901
3571
  //#region packages/form/src/containers/Container.vue
@@ -2918,7 +3588,8 @@
2918
3588
  isCompare: {
2919
3589
  type: Boolean,
2920
3590
  default: false
2921
- }
3591
+ },
3592
+ isInRow: { type: Boolean }
2922
3593
  },
2923
3594
  emits: ["change", "addDiffCount"],
2924
3595
  setup(__props, { emit: __emit }) {
@@ -2926,12 +3597,14 @@
2926
3597
  const emit = __emit;
2927
3598
  const mForm = (0, vue.inject)("mForm");
2928
3599
  const diffConfig = (0, vue.inject)(FORM_DIFF_CONFIG_KEY, {});
3600
+ const typeMatchValid = (0, vue.inject)(FORM_TYPE_MATCH_VALID_KEY);
2929
3601
  const expand = (0, vue.ref)(false);
2930
3602
  const name = (0, vue.computed)(() => props.config.name || "");
2931
3603
  const showDiff = (0, vue.computed)(() => {
2932
3604
  if (!props.isCompare) return false;
2933
- const curValue = name.value ? props.model[name.value] : props.model;
2934
- const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
3605
+ if (!name.value) return false;
3606
+ const curValue = props.model[name.value];
3607
+ const lastValue = props.lastValues[name.value];
2935
3608
  const customShowDiff = diffConfig.showDiff;
2936
3609
  if (typeof customShowDiff === "function") return Boolean(customShowDiff({
2937
3610
  curValue,
@@ -2984,7 +3657,7 @@
2984
3657
  const effectiveSelfDiffFieldTypes = (0, vue.computed)(() => {
2985
3658
  const custom = diffConfig.selfDiffFieldTypes;
2986
3659
  if (typeof custom === "function") return new Set(custom([...DEFAULT_SELF_DIFF_FIELD_TYPES]));
2987
- if (Array.isArray(custom)) return new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
3660
+ if (Array.isArray(custom)) return /* @__PURE__ */ new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
2988
3661
  return new Set(DEFAULT_SELF_DIFF_FIELD_TYPES);
2989
3662
  });
2990
3663
  const isSelfDiffField = (0, vue.computed)(() => effectiveSelfDiffFieldTypes.value.has(type.value));
@@ -3001,7 +3674,7 @@
3001
3674
  placement: config?.placement || "top"
3002
3675
  };
3003
3676
  });
3004
- const rule = (0, vue.computed)(() => getRules(mForm, props.config.rules, props));
3677
+ const rule = (0, vue.computed)(() => getRules(mForm, props.config.rules, props, typeMatchValid));
3005
3678
  const display$3 = (0, vue.computed)(() => {
3006
3679
  const value = display(mForm, props.config.display, props);
3007
3680
  if (value === "expand") return expand.value;
@@ -3021,7 +3694,8 @@
3021
3694
  labelWidth: itemLabelWidth.value,
3022
3695
  labelPosition: props.config.labelPosition,
3023
3696
  rules: rule.value,
3024
- extra: filterFunction(mForm, props.config.extra, props)
3697
+ extra: filterFunction(mForm, props.config.extra, props),
3698
+ extraTips: props.config.extraTips
3025
3699
  }));
3026
3700
  const itemLabelWidth = (0, vue.computed)(() => props.config.labelWidth ?? props.labelWidth);
3027
3701
  (0, vue.watchEffect)(() => {
@@ -3032,6 +3706,7 @@
3032
3706
  if (items.value && !text.value && type.value && display$3.value) return;
3033
3707
  if (display$3.value && showDiff && type.value) emit("addDiffCount");
3034
3708
  }, { immediate: true });
3709
+ (0, vue.provide)("isInRow", props.isInRow ?? false);
3035
3710
  const expandHandler = () => expand.value = !expand.value;
3036
3711
  const key = (config) => config[mForm?.keyProps];
3037
3712
  const filterHandler = (filter, value) => {
@@ -3062,7 +3737,10 @@
3062
3737
  return new Proxy(target, {
3063
3738
  get: (obj, key) => {
3064
3739
  const value = obj[key];
3065
- if (value && typeof value === "object") return createModelProxy(value, setModelFn, pathPrefix ? `${pathPrefix}.${key}` : key);
3740
+ if (value && typeof value === "object") {
3741
+ const newPath = pathPrefix ? `${pathPrefix}.${key}` : key;
3742
+ return createModelProxy(value, setModelFn, newPath);
3743
+ }
3066
3744
  return value;
3067
3745
  },
3068
3746
  set: (obj, key, value) => {
@@ -3128,16 +3806,18 @@
3128
3806
  "data-tmagic-form-item-prop": itemProp.value,
3129
3807
  class: (0, vue.normalizeClass)(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}${__props.config.tip ? " has-tip" : ""}`),
3130
3808
  style: (0, vue.normalizeStyle)(__props.config.style)
3131
- }, [type.value === "hidden" ? ((0, vue.openBlock)(), (0, vue.createBlock)(Hidden_default, {
3132
- key: 0,
3133
- name: `${name.value}`,
3134
- prop: itemProp.value,
3135
- model: __props.model
3136
- }, null, 8, [
3137
- "name",
3138
- "prop",
3139
- "model"
3140
- ])) : items.value && !text.value && type.value && display$3.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)({ key: 1 }, fieldsProps.value, {
3809
+ }, [type.value === "hidden" ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicFormItem), (0, vue.mergeProps)({ key: 0 }, formItemProps.value, { style: { "display": "none" } }), {
3810
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)(Hidden_default, {
3811
+ name: `${name.value}`,
3812
+ prop: itemProp.value,
3813
+ model: __props.model
3814
+ }, null, 8, [
3815
+ "name",
3816
+ "prop",
3817
+ "model"
3818
+ ])]),
3819
+ _: 1
3820
+ }, 16)) : items.value && !text.value && type.value && display$3.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)({ key: 1 }, fieldsProps.value, {
3141
3821
  model: __props.model,
3142
3822
  "last-values": __props.lastValues,
3143
3823
  "is-compare": __props.isCompare,
@@ -3174,12 +3854,12 @@
3174
3854
  "use-label",
3175
3855
  "label-title",
3176
3856
  "text"
3177
- ])])]),
3857
+ ]), __props.config.titleExtra && __props.config.labelPosition === "top" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_2$8, (0, vue.toDisplayString)(__props.config.titleExtra), 1)) : (0, vue.createCommentVNode)("v-if", true)])]),
3178
3858
  default: (0, vue.withCtx)(() => [tooltip.value.text ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
3179
3859
  key: 0,
3180
3860
  placement: tooltip.value.placement
3181
3861
  }, {
3182
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_2$7)]),
3862
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_3$7)]),
3183
3863
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)(fieldsProps.value, {
3184
3864
  model: __props.model,
3185
3865
  "last-values": __props.lastValues,
@@ -3208,7 +3888,7 @@
3208
3888
  key: 0,
3209
3889
  placement: "top"
3210
3890
  }, {
3211
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_3$6)]),
3891
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_4$6)]),
3212
3892
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), { style: {
3213
3893
  "line-height": "40px",
3214
3894
  "margin-left": "5px"
@@ -3247,7 +3927,7 @@
3247
3927
  key: 0,
3248
3928
  placement: tooltip.value.placement
3249
3929
  }, {
3250
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_4$4)]),
3930
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_5$4)]),
3251
3931
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)(fieldsProps.value, {
3252
3932
  model: __props.model,
3253
3933
  "last-values": __props.lastValues,
@@ -3300,7 +3980,7 @@
3300
3980
  key: 0,
3301
3981
  placement: tooltip.value.placement
3302
3982
  }, {
3303
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_5$3)]),
3983
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_6$3)]),
3304
3984
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)(fieldsProps.value, {
3305
3985
  model: __props.lastValues,
3306
3986
  onChange: onChangeHandler
@@ -3316,7 +3996,7 @@
3316
3996
  key: 0,
3317
3997
  placement: "top"
3318
3998
  }, {
3319
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_6$1)]),
3999
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_7$2)]),
3320
4000
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), { style: {
3321
4001
  "line-height": "40px",
3322
4002
  "margin-left": "5px"
@@ -3357,7 +4037,7 @@
3357
4037
  key: 0,
3358
4038
  placement: tooltip.value.placement
3359
4039
  }, {
3360
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_7$1)]),
4040
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_8$2)]),
3361
4041
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(tagName.value), (0, vue.mergeProps)(fieldsProps.value, {
3362
4042
  model: __props.model,
3363
4043
  onChange: onChangeHandler
@@ -3373,7 +4053,7 @@
3373
4053
  key: 1,
3374
4054
  placement: "top"
3375
4055
  }, {
3376
- content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_8$1)]),
4056
+ content: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_9)]),
3377
4057
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), { style: {
3378
4058
  "line-height": "40px",
3379
4059
  "margin-left": "5px"
@@ -3415,16 +4095,17 @@
3415
4095
  "label-width",
3416
4096
  "prop"
3417
4097
  ]);
3418
- }), 128)) : (0, vue.createCommentVNode)("v-if", true)], 64)) : (0, vue.createCommentVNode)("v-if", true), __props.config.expand && type.value !== "fieldset" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_9, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
4098
+ }), 128)) : (0, vue.createCommentVNode)("v-if", true)], 64)) : (0, vue.createCommentVNode)("v-if", true), __props.config.expand && type.value !== "fieldset" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_10, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
3419
4099
  type: "primary",
3420
4100
  size: "small",
3421
4101
  disabled: false,
3422
4102
  link: "",
3423
- onClick: expandHandler
4103
+ onClick: expandHandler,
4104
+ icon: expand.value ? (0, vue.unref)(_element_plus_icons_vue.ArrowUp) : (0, vue.unref)(_element_plus_icons_vue.ArrowDown)
3424
4105
  }, {
3425
4106
  default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(expand.value ? "收起配置" : "展开更多配置"), 1)]),
3426
4107
  _: 1
3427
- })])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$14);
4108
+ }, 8, ["icon"])])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$14);
3428
4109
  };
3429
4110
  }
3430
4111
  });
@@ -3443,6 +4124,11 @@
3443
4124
  },
3444
4125
  parentValues: { default: () => ({}) },
3445
4126
  labelWidth: { default: "200px" },
4127
+ typeMatchValid: { type: Boolean },
4128
+ validateOnInit: {
4129
+ type: Boolean,
4130
+ default: false
4131
+ },
3446
4132
  disabled: {
3447
4133
  type: Boolean,
3448
4134
  default: false
@@ -3458,9 +4144,14 @@
3458
4144
  keyProp: { default: "__key" },
3459
4145
  popperClass: {},
3460
4146
  preventSubmitDefault: { type: Boolean },
4147
+ useFieldTextInError: {
4148
+ type: Boolean,
4149
+ default: true
4150
+ },
3461
4151
  extendState: {},
3462
4152
  showDiff: {},
3463
- selfDiffFieldTypes: {}
4153
+ selfDiffFieldTypes: {},
4154
+ theme: {}
3464
4155
  },
3465
4156
  emits: [
3466
4157
  "change",
@@ -3472,6 +4163,7 @@
3472
4163
  setup(__props, { expose: __expose, emit: __emit }) {
3473
4164
  const props = __props;
3474
4165
  const emit = __emit;
4166
+ (0, vue.provide)(FORM_TYPE_MATCH_VALID_KEY, (0, vue.computed)(() => props.typeMatchValid));
3475
4167
  const tMagicFormRef = (0, vue.useTemplateRef)("tMagicForm");
3476
4168
  const initialized = (0, vue.ref)(false);
3477
4169
  const values = (0, vue.ref)({});
@@ -3479,6 +4171,25 @@
3479
4171
  const fields = /* @__PURE__ */ new Map();
3480
4172
  const requestFuc = getConfig("request");
3481
4173
  /**
4174
+ * 当前表单生效的主题名称:
4175
+ * - 优先用本组件自己的 `props.theme`;
4176
+ * - 没设置时回退到最近祖先 `<MEditor>` / `<MForm>` provide 的主题,便于内嵌于编辑器
4177
+ * 时自动跟随外层主题,无需在每个 `MForm` 上重复传 `theme`。
4178
+ *
4179
+ * 同时把合并后的值再 provide 出去(见下方 `provide(M_THEME_KEY, ...)`),让 form 子树
4180
+ * 里再嵌套的 portal 组件(`TMagicPopover` 等)依然能拿到非空主题。
4181
+ */
4182
+ const ancestorTheme = (0, vue.inject)(_tmagic_design.M_THEME_KEY, null);
4183
+ const effectiveTheme = (0, vue.computed)(() => props.theme || ancestorTheme?.value || "");
4184
+ /**
4185
+ * 拼到 `formState.popperClass` 上的主题修饰类(仅 `m-theme--<theme>`,
4186
+ * 不带 `m-form` / `m-editor` 前缀,因为 Element Plus 弹层节点本身既不是 form 也不是 editor)。
4187
+ *
4188
+ * 这条类会随所有读 `mForm.popperClass` 的字段(Select / DateTime / Cascader 等)下发到
4189
+ * Element Plus 的 `popper-class`,让 portal 节点也命中 `m-theme--<theme>` 上的 CSS 变量。
4190
+ */
4191
+ const themeClass = (0, vue.computed)(() => effectiveTheme.value ? `m-theme--${effectiveTheme.value}` : "");
4192
+ /**
3482
4193
  * formState 实现说明:
3483
4194
  *
3484
4195
  * 1. 与 props 直接对应的字段(config / initValues / lastValues / isCompare / parentValues /
@@ -3494,13 +4205,21 @@
3494
4205
  * 把最新值刷进 formState。
3495
4206
  * - accessor 描述符(`{ get stage() { return ... } }`)按原样写入,调用方可以控制
3496
4207
  * 读时求值,每次读取都会重新执行 getter。
4208
+ *
4209
+ * 4. `popperClass` 会自动拼接 `themeClass`:调用方传入的 `popperClass` + 当前主题
4210
+ * 修饰类(含祖先 `<MEditor>` provide 的主题)。这样所有透传到 Element Plus 弹层
4211
+ * `popper-class` 的字段(Select / DateTime / Cascader 等)能自带主题作用域。
3497
4212
  */
3498
4213
  const formState = (0, vue.reactive)({
3499
4214
  get keyProp() {
3500
4215
  return props.keyProp;
3501
4216
  },
3502
4217
  get popperClass() {
3503
- return props.popperClass;
4218
+ const userClass = props.popperClass ?? "";
4219
+ const tc = themeClass.value;
4220
+ if (!userClass) return tc;
4221
+ if (!tc) return userClass;
4222
+ return `${userClass} ${tc}`;
3504
4223
  },
3505
4224
  get config() {
3506
4225
  return props.config;
@@ -3534,6 +4253,17 @@
3534
4253
  }
3535
4254
  });
3536
4255
  /**
4256
+ * formState 的内置 key 快照(keyProp / values / $emit / fields / post 等)。
4257
+ *
4258
+ * 在 `extendState` 首次合并前捕获,`applyExtendState` 会据此禁止 `extendState`
4259
+ * 覆盖这些已有字段(只能新增字段),避免表单核心状态被外部意外改写。
4260
+ *
4261
+ * 之所以在此处(effect 之外)捕获而不是在 `applyExtendState` 内动态取:
4262
+ * `watchEffect` 会在依赖变化时重跑,若动态取,`extendState` 自己新增的字段在第二次
4263
+ * 合并时也会被当成「已有 key」而拒绝刷新;这里只锁定内置字段即可规避该问题。
4264
+ */
4265
+ const reservedStateKeys = new Set(Reflect.ownKeys(formState));
4266
+ /**
3537
4267
  * `extendState` 的同步段(直到第一个 `await` 之前)所访问的任何响应式数据,
3538
4268
  * 都会被 `watchEffect` 自动跟踪。这样可以兼容历史用法 ——
3539
4269
  *
@@ -3548,11 +4278,10 @@
3548
4278
  * 这里不再重复同步;因此 `props.initValues` 这类高频变化也不会再触发
3549
4279
  * `extendState` 重跑(旧版的性能问题修复点)。
3550
4280
  *
3551
- * 实现细节:
3552
- * - data 描述符:通过 `formState[key] = value` 走 reactive proxy 的 set
3553
- * 触发依赖通知;与旧版「逐项赋值」语义完全等价。
3554
- * - accessor 描述符(`{ get stage() {...} }`)按原样写入 formState,调用方
3555
- * 可以自行控制读时求值;强制 `configurable: true` 以便下一次重跑可再 define。
4281
+ * 实现细节:合并逻辑统一收口在 `applyExtendState`(utils/form)——
4282
+ * data 描述符走 reactive proxy 的 set 触发依赖通知(与旧版「逐项赋值」语义等价),
4283
+ * accessor 描述符按原样 defineProperty 支持读时求值;
4284
+ * props 派生的只读 getter 字段(keyProp 等)以普通字段形式返回时会被跳过并告警。
3556
4285
  */
3557
4286
  (0, vue.watchEffect)(async (onCleanup) => {
3558
4287
  const { extendState } = props;
@@ -3569,13 +4298,16 @@
3569
4298
  return;
3570
4299
  }
3571
4300
  if (stale) return;
3572
- for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(state))) if ("value" in descriptor) formState[key] = state[key];
3573
- else {
3574
- descriptor.configurable = true;
3575
- Object.defineProperty(formState, key, descriptor);
3576
- }
4301
+ applyExtendState(formState, state, reservedStateKeys);
3577
4302
  });
3578
4303
  (0, vue.provide)("mForm", formState);
4304
+ /**
4305
+ * 把生效主题(自身或祖先)再 provide 出去,供 form 子树内含 `Teleport` 的组件
4306
+ * (如 `TMagicPopover`)在传送目标上挂 `m-theme--<theme>` 类。
4307
+ * 详见 `@tmagic/design/theme.ts`。
4308
+ */
4309
+ (0, vue.provide)(_tmagic_design.M_THEME_KEY, effectiveTheme);
4310
+ (0, vue.provide)("formInline", props.inline);
3579
4311
  (0, vue.provide)(FORM_DIFF_CONFIG_KEY, {
3580
4312
  get showDiff() {
3581
4313
  return props.showDiff;
@@ -3594,6 +4326,9 @@
3594
4326
  }).then((value) => {
3595
4327
  values.value = value;
3596
4328
  initialized.value = !props.isCompare;
4329
+ if (props.validateOnInit) (0, vue.nextTick)(() => {
4330
+ tMagicFormRef.value?.validate();
4331
+ });
3597
4332
  });
3598
4333
  if (props.isCompare) initValue(formState, {
3599
4334
  initValues: props.lastValues,
@@ -3645,6 +4380,23 @@
3645
4380
  };
3646
4381
  return findInConfig(config, nameParts);
3647
4382
  };
4383
+ /**
4384
+ * 将校验返回的 invalidFields 汇总为可读的错误文案(多条以 `<br>` 拼接)。
4385
+ *
4386
+ * 抽离为独立方法,供 `submitForm`(提交校验)与 `validate`(返回错误文案的校验)复用,
4387
+ * 保证两种校验入口产出的错误文案格式完全一致。
4388
+ */
4389
+ const formatValidateError = (invalidFields) => {
4390
+ const error = [];
4391
+ Object.entries(invalidFields).forEach(([prop, validateError]) => {
4392
+ validateError.forEach(({ field, message }) => {
4393
+ const name = field || prop;
4394
+ const text = (props.useFieldTextInError ? getTextByName(name, props.config) : void 0) || name;
4395
+ error.push(`${text} -> ${message}`);
4396
+ });
4397
+ });
4398
+ return error.join("<br>");
4399
+ };
3648
4400
  __expose({
3649
4401
  values,
3650
4402
  lastValuesProcessed,
@@ -3664,22 +4416,43 @@
3664
4416
  return native ? values.value : cloneDeep((0, vue.toRaw)(values.value));
3665
4417
  } catch (invalidFields) {
3666
4418
  emit("error", invalidFields);
3667
- const error = [];
3668
- Object.entries(invalidFields).forEach(([prop, ValidateError]) => {
3669
- ValidateError.forEach(({ field, message }) => {
3670
- const name = field || prop;
3671
- const text = getTextByName(name, props.config) || name;
3672
- error.push(`${text} -> ${message}`);
3673
- });
3674
- });
3675
- throw new Error(error.join("<br>"));
4419
+ throw new Error(formatValidateError(invalidFields));
4420
+ }
4421
+ },
4422
+ /**
4423
+ * 校验:对表单当前值执行校验,返回汇总后的错误文案。
4424
+ *
4425
+ * 与 `submitForm` 的区别:
4426
+ * - 校验失败时不抛异常、不触发 `error` 事件,而是以返回值形式给出错误文案;
4427
+ * - 不重置 `changeRecords`,不改变提交语义,仅用于「探测」当前配置是否合法。
4428
+ *
4429
+ * 注意:本方法只改变「校验结果的返回方式」,并不负责「不污染页面表单状态」——
4430
+ * 若需对一份独立的「配置 + 值」做完全不影响页面上已渲染表单的校验,请使用 `validateForm`
4431
+ * (内部会新建一个隐藏的 MForm 实例,通过 `initValues` 传入待校验值,用完即卸载)。
4432
+ *
4433
+ * 典型用途:作为 `validateForm` 内部复用的校验实现;也可在已渲染的表单实例上主动调用,
4434
+ * 根据返回的错误文案自行决定后续处理(如记录节点错误状态)。
4435
+ *
4436
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
4437
+ */
4438
+ validate: async () => {
4439
+ try {
4440
+ const result = await tMagicFormRef.value?.validate();
4441
+ if (result !== true) throw result;
4442
+ return "";
4443
+ } catch (invalidFields) {
4444
+ return formatValidateError(invalidFields);
3676
4445
  }
3677
4446
  },
3678
4447
  getTextByName
3679
4448
  });
3680
4449
  return (_ctx, _cache) => {
3681
4450
  return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicForm), {
3682
- class: "m-form",
4451
+ class: (0, vue.normalizeClass)([
4452
+ "m-form",
4453
+ effectiveTheme.value ? `m-form--${effectiveTheme.value}` : "",
4454
+ effectiveTheme.value ? `m-theme--${effectiveTheme.value}` : ""
4455
+ ]),
3683
4456
  ref: "tMagicForm",
3684
4457
  model: values.value,
3685
4458
  "label-width": __props.labelWidth,
@@ -3717,6 +4490,7 @@
3717
4490
  }), 128)) : (0, vue.createCommentVNode)("v-if", true)]),
3718
4491
  _: 3
3719
4492
  }, 8, [
4493
+ "class",
3720
4494
  "model",
3721
4495
  "label-width",
3722
4496
  "style",
@@ -3728,6 +4502,198 @@
3728
4502
  });
3729
4503
  //#endregion
3730
4504
  //#region packages/form/src/submitForm.ts
4505
+ /** 未指定或传入非正数 timeout 时的兜底超时(毫秒),保证非 debug 挂载始终能被清理 */
4506
+ var DEFAULT_MOUNT_TIMEOUT = 1e4;
4507
+ /**
4508
+ * submitForm / validateForm 的公共脚手架:
4509
+ *
4510
+ * 创建临时容器 → 挂载一个 wrapper 组件(内含 MForm)→ 提供统一的 cleanup / timeout / appContext 继承 →
4511
+ * 由 `createWrapper` 决定「何时调用 MForm 的哪个方法、如何 resolve/reject」。
4512
+ *
4513
+ * 调用方只需关注差异逻辑(调用 `submitForm` 还是 `validate`、结果如何包装、是否需要调试弹层),
4514
+ * 容器创建、卸载、超时、上下文注入等模板代码在此统一收口。
4515
+ */
4516
+ var mountFormInstance = (options) => {
4517
+ const { formProps, appContext, timeout, timeoutMessage, hidden = true, skipTimeout = false, signal, createWrapper } = options;
4518
+ return new Promise((resolve, reject) => {
4519
+ if (signal?.aborted) {
4520
+ reject(signal.reason ?? /* @__PURE__ */ new Error("mountFormInstance aborted"));
4521
+ return;
4522
+ }
4523
+ let cleaned = false;
4524
+ let timer = null;
4525
+ let onAbort = null;
4526
+ const instance = { app: null };
4527
+ const container = document.createElement("div");
4528
+ if (hidden) container.style.display = "none";
4529
+ document.body.appendChild(container);
4530
+ const cleanup = () => {
4531
+ if (cleaned) return;
4532
+ cleaned = true;
4533
+ if (timer) {
4534
+ clearTimeout(timer);
4535
+ timer = null;
4536
+ }
4537
+ if (signal && onAbort) {
4538
+ signal.removeEventListener("abort", onAbort);
4539
+ onAbort = null;
4540
+ }
4541
+ try {
4542
+ instance.app?.unmount();
4543
+ } catch {}
4544
+ container.parentNode?.removeChild(container);
4545
+ };
4546
+ if (signal) {
4547
+ onAbort = () => {
4548
+ if (cleaned) return;
4549
+ reject(signal.reason ?? /* @__PURE__ */ new Error("mountFormInstance aborted"));
4550
+ cleanup();
4551
+ };
4552
+ signal.addEventListener("abort", onAbort);
4553
+ }
4554
+ try {
4555
+ const formRef = (0, vue.ref)(null);
4556
+ const { extendState, ...restFormProps } = formProps;
4557
+ const userWrapper = createWrapper({
4558
+ formRef,
4559
+ formProps: restFormProps,
4560
+ cleanup,
4561
+ resolve,
4562
+ reject
4563
+ });
4564
+ const wrapperComponent = typeof extendState === "function" ? (0, vue.defineComponent)({
4565
+ name: "MFormExtendStateInjector",
4566
+ setup() {
4567
+ (0, vue.watch)(() => formRef.value, (form) => {
4568
+ if (!form) return;
4569
+ let result;
4570
+ try {
4571
+ result = extendState(form.formState);
4572
+ } catch (e) {
4573
+ console.error("[MForm] extendState failed:", e);
4574
+ return;
4575
+ }
4576
+ const reservedStateKeys = new Set(Reflect.ownKeys(form.formState));
4577
+ const apply = (state) => applyExtendState(form.formState, state, reservedStateKeys);
4578
+ if (result && typeof result.then === "function") result.then(apply, (e) => console.error("[MForm] extendState failed:", e));
4579
+ else apply(result);
4580
+ }, {
4581
+ flush: "sync",
4582
+ immediate: true
4583
+ });
4584
+ return () => (0, vue.h)(userWrapper);
4585
+ }
4586
+ }) : userWrapper;
4587
+ const app = (0, vue.createApp)(hidden ? (0, vue.defineComponent)({
4588
+ name: "MFormSilentProvider",
4589
+ setup() {
4590
+ (0, vue.provide)(FORM_SILENT_MODE_KEY, true);
4591
+ return () => (0, vue.h)(wrapperComponent);
4592
+ }
4593
+ }) : wrapperComponent);
4594
+ instance.app = app;
4595
+ if (appContext) Object.assign(app._context, appContext);
4596
+ if (!skipTimeout) timer = setTimeout(() => {
4597
+ if (!cleaned) {
4598
+ reject(new Error(timeoutMessage));
4599
+ cleanup();
4600
+ }
4601
+ }, timeout > 0 ? timeout : DEFAULT_MOUNT_TIMEOUT);
4602
+ app.mount(container);
4603
+ } catch (err) {
4604
+ reject(err);
4605
+ cleanup();
4606
+ }
4607
+ });
4608
+ };
4609
+ /**
4610
+ * 构造调试模式下的可见弹层 wrapper:以 fixed 遮罩居中渲染 MForm,提供「确定 / 取消」按钮与错误展示区。
4611
+ *
4612
+ * submitForm 与 validateForm 的调试弹层 UI 完全一致,仅「确定」时调用的实例方法、错误处理与取消文案不同,
4613
+ * 这些差异通过 `onConfirm` / `onCancel` 注入,弹层结构在此统一收口。
4614
+ */
4615
+ var createDebugWrapper = (options) => {
4616
+ const { formRef, formProps, title, name, onConfirm, onCancel } = options;
4617
+ const btnBase = {
4618
+ padding: "8px 20px",
4619
+ fontSize: "14px",
4620
+ lineHeight: "1",
4621
+ border: "1px solid #dcdfe6",
4622
+ borderRadius: "4px",
4623
+ cursor: "pointer"
4624
+ };
4625
+ return (0, vue.defineComponent)({
4626
+ name,
4627
+ setup() {
4628
+ const errorMsg = (0, vue.ref)("");
4629
+ const setError = (msg) => {
4630
+ errorMsg.value = msg;
4631
+ };
4632
+ return () => (0, vue.h)("div", { style: {
4633
+ position: "fixed",
4634
+ inset: "0",
4635
+ zIndex: "10000",
4636
+ display: "flex",
4637
+ alignItems: "center",
4638
+ justifyContent: "center",
4639
+ background: "rgba(0, 0, 0, 0.5)"
4640
+ } }, [(0, vue.h)("div", { style: {
4641
+ display: "flex",
4642
+ flexDirection: "column",
4643
+ width: "600px",
4644
+ maxWidth: "90vw",
4645
+ maxHeight: "85vh",
4646
+ background: "#fff",
4647
+ borderRadius: "8px",
4648
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.2)",
4649
+ overflow: "hidden"
4650
+ } }, [
4651
+ (0, vue.h)("div", { style: {
4652
+ padding: "16px 20px",
4653
+ fontSize: "16px",
4654
+ fontWeight: "600",
4655
+ borderBottom: "1px solid #ebeef5"
4656
+ } }, title),
4657
+ (0, vue.h)("div", { style: {
4658
+ flex: "1",
4659
+ padding: "20px",
4660
+ overflow: "auto"
4661
+ } }, [(0, vue.h)(Form_default, {
4662
+ ...formProps,
4663
+ ref: formRef
4664
+ }), errorMsg.value ? (0, vue.h)("div", {
4665
+ style: {
4666
+ marginTop: "12px",
4667
+ color: "#f56c6c",
4668
+ fontSize: "13px",
4669
+ lineHeight: "1.5"
4670
+ },
4671
+ innerHTML: errorMsg.value
4672
+ }) : null]),
4673
+ (0, vue.h)("div", { style: {
4674
+ display: "flex",
4675
+ justifyContent: "flex-end",
4676
+ gap: "12px",
4677
+ padding: "12px 20px",
4678
+ borderTop: "1px solid #ebeef5"
4679
+ } }, [(0, vue.h)("button", {
4680
+ type: "button",
4681
+ onClick: onCancel,
4682
+ style: { ...btnBase }
4683
+ }, "取消"), (0, vue.h)("button", {
4684
+ type: "button",
4685
+ onClick: () => onConfirm(setError),
4686
+ style: {
4687
+ ...btnBase,
4688
+ color: "#fff",
4689
+ background: "#409eff",
4690
+ borderColor: "#409eff"
4691
+ }
4692
+ }, "确定")])
4693
+ ])]);
4694
+ }
4695
+ });
4696
+ };
3731
4697
  /**
3732
4698
  * 以命令式方式调用 Form.vue 完成一次表单校验/提交。
3733
4699
  *
@@ -3748,65 +4714,230 @@
3748
4714
  * } catch (e) {
3749
4715
  * console.error(e);
3750
4716
  * }
4717
+ *
4718
+ * // 需要同时获取变更记录时:
4719
+ * const { values, changeRecords } = await submitForm({
4720
+ * config: [...],
4721
+ * initValues: { name: 'foo' },
4722
+ * returnChangeRecords: true,
4723
+ * });
4724
+ *
4725
+ * // 调试模式:可见地渲染表单,点击「确定」才提交:
4726
+ * const values = await submitForm({
4727
+ * config: [...],
4728
+ * initValues: { name: 'foo' },
4729
+ * debug: true,
4730
+ * });
3751
4731
  * ```
3752
4732
  */
3753
4733
  var submitForm = (options) => {
3754
- const { native, appContext, timeout = 1e4, ...formProps } = options;
3755
- return new Promise((resolve, reject) => {
3756
- const container = document.createElement("div");
3757
- container.style.display = "none";
3758
- document.body.appendChild(container);
3759
- let cleaned = false;
3760
- let timer = null;
3761
- const app = (0, vue.createApp)((0, vue.defineComponent)({
3762
- name: "MFormSubmitWrapper",
3763
- setup() {
3764
- const formRef = (0, vue.ref)(null);
3765
- const stop = (0, vue.watch)(() => formRef.value?.initialized, async (initialized) => {
3766
- if (!initialized) return;
3767
- stop();
3768
- try {
3769
- await (0, vue.nextTick)();
3770
- resolve(await formRef.value.submitForm(native));
3771
- } catch (err) {
3772
- reject(err);
3773
- } finally {
4734
+ const { native, appContext, timeout = 1e4, returnChangeRecords, debug = false, signal, ...formProps } = options;
4735
+ return mountFormInstance({
4736
+ formProps,
4737
+ appContext,
4738
+ timeout,
4739
+ signal,
4740
+ hidden: !debug,
4741
+ skipTimeout: debug,
4742
+ timeoutMessage: `submitForm timeout after ${timeout}ms: form is not initialized.`,
4743
+ createWrapper: ({ formRef, formProps, cleanup, resolve, reject }) => {
4744
+ /**
4745
+ * 执行一次提交:nextTick 等待子组件渲染 快照 changeRecords 调用实例 submitForm resolve。
4746
+ * 校验失败时交给 `onValidateError` 决定「保留弹层展示错误(debug)」还是「reject 并清理(普通)」,
4747
+ * 从而让 debug 与普通模式共享同一份提交逻辑。
4748
+ */
4749
+ const doSubmit = async (onValidateError) => {
4750
+ try {
4751
+ await (0, vue.nextTick)();
4752
+ const changeRecords = [...formRef.value?.changeRecords ?? []];
4753
+ const result = await formRef.value.submitForm(native);
4754
+ resolve(returnChangeRecords ? {
4755
+ values: result,
4756
+ changeRecords
4757
+ } : result);
4758
+ cleanup();
4759
+ } catch (err) {
4760
+ onValidateError(err);
4761
+ }
4762
+ };
4763
+ if (debug) return createDebugWrapper({
4764
+ formRef,
4765
+ formProps,
4766
+ name: "MFormSubmitWrapper",
4767
+ title: "submitForm 调试",
4768
+ onConfirm: (setError) => doSubmit((err) => {
4769
+ setError(err instanceof Error ? err.message : String(err));
4770
+ }),
4771
+ onCancel: () => {
4772
+ reject(/* @__PURE__ */ new Error("submitForm canceled in debug mode."));
4773
+ cleanup();
4774
+ }
4775
+ });
4776
+ return (0, vue.defineComponent)({
4777
+ name: "MFormSubmitWrapper",
4778
+ setup() {
4779
+ const stop = (0, vue.watch)(() => formRef.value?.initialized, (initialized) => {
4780
+ if (!initialized) return;
4781
+ stop();
4782
+ doSubmit((err) => {
4783
+ reject(err);
4784
+ cleanup();
4785
+ });
4786
+ }, {
4787
+ flush: "post",
4788
+ immediate: true
4789
+ });
4790
+ return () => (0, vue.h)(Form_default, {
4791
+ ...formProps,
4792
+ ref: formRef
4793
+ });
4794
+ }
4795
+ });
4796
+ }
4797
+ });
4798
+ };
4799
+ /**
4800
+ * 深拷贝配置值,保留函数(display / onTabClick 等回调)引用,避免破坏配置中的回调。
4801
+ */
4802
+ var cloneConfigValue = (value) => {
4803
+ if (Array.isArray(value)) return value.map(cloneConfigValue);
4804
+ if (value && typeof value === "object") return Object.keys(value).reduce((acc, key) => {
4805
+ acc[key] = cloneConfigValue(value[key]);
4806
+ return acc;
4807
+ }, {});
4808
+ return value;
4809
+ };
4810
+ /**
4811
+ * 深度遍历配置,去掉所有 type 为 'tab' 的容器中各标签页(items)的 lazy 配置。
4812
+ */
4813
+ var removeTabItemsLazy = (node) => {
4814
+ if (Array.isArray(node)) {
4815
+ node.forEach(removeTabItemsLazy);
4816
+ return;
4817
+ }
4818
+ if (!node || typeof node !== "object") return;
4819
+ if (node.type === "tab" && Array.isArray(node.items)) node.items.forEach((pane) => {
4820
+ if (pane && typeof pane === "object") delete pane.lazy;
4821
+ });
4822
+ Object.keys(node).forEach((key) => {
4823
+ removeTabItemsLazy(node[key]);
4824
+ });
4825
+ };
4826
+ /**
4827
+ * 返回一份去除了 tab 标签页 lazy 的配置副本。
4828
+ *
4829
+ * tab 容器开启 lazy 时,非激活标签页的内容不会渲染,导致 validateForm 静默挂载后
4830
+ * 无法校验到这些标签页内的字段。校验场景需要一次性渲染全部字段,故在此统一去除 lazy。
4831
+ * 处理基于深拷贝,不会污染调用方传入的原始 config。
4832
+ */
4833
+ var stripTabItemsLazy = (config) => {
4834
+ const cloned = cloneConfigValue(config);
4835
+ removeTabItemsLazy(cloned);
4836
+ return cloned;
4837
+ };
4838
+ /**
4839
+ * 以命令式方式对一份「表单配置 + 值」做一次静默校验,**不依赖也不影响任何已渲染的表单**。
4840
+ *
4841
+ * 与 `submitForm` 类似,内部会临时挂载一个不可见的 MForm 实例,等待其初始化完成后调用
4842
+ * 实例的 `validate` 方法,返回汇总后的错误文案,随后自动卸载实例。
4843
+ *
4844
+ * 与 `submitForm` 的区别:
4845
+ * - 「静默」:校验失败不抛异常、不触发 `error` 事件、不返回表单值;
4846
+ * - 仅用于「探测」配置是否合法,适合源码保存后校验、批量校验组件配置等场景。
4847
+ *
4848
+ * 由于每次都新建一个独立的 MForm 实例,调用方无需持有任何表单 ref,也不会污染
4849
+ * 页面上正在展示的表单状态。
4850
+ *
4851
+ * @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
4852
+ * 仅在初始化超时或挂载失败等异常情况下才会 reject。
4853
+ *
4854
+ * @example
4855
+ * ```ts
4856
+ * import { validateForm } from '@tmagic/form';
4857
+ *
4858
+ * const error = await validateForm({
4859
+ * config: [...],
4860
+ * initValues: { name: 'foo' },
4861
+ * appContext: getCurrentInstance()?.appContext,
4862
+ * });
4863
+ * if (error) {
4864
+ * // 配置不合法,error 为错误文案
4865
+ * }
4866
+ *
4867
+ * // 调试模式:可见地渲染表单,点击「确定」才校验,校验失败保留弹层可修正重试:
4868
+ * const error = await validateForm({
4869
+ * config: [...],
4870
+ * initValues: { name: 'foo' },
4871
+ * debug: true,
4872
+ * });
4873
+ * ```
4874
+ */
4875
+ var validateForm = (options) => {
4876
+ const { appContext, timeout = 1e4, debug = false, config, signal, ...rest } = options;
4877
+ return mountFormInstance({
4878
+ formProps: {
4879
+ ...rest,
4880
+ config: stripTabItemsLazy(config)
4881
+ },
4882
+ appContext,
4883
+ timeout,
4884
+ signal,
4885
+ hidden: !debug,
4886
+ skipTimeout: debug,
4887
+ timeoutMessage: `validateForm timeout after ${timeout}ms: form is not initialized.`,
4888
+ createWrapper: ({ formRef, formProps, cleanup, resolve, reject }) => {
4889
+ /**
4890
+ * 执行一次校验:nextTick 等待子组件渲染 → 调用实例 validate → 通过则 resolve ''。
4891
+ * 校验失败(返回非空错误文案)时交给 `onInvalid` 决定「静默 resolve 错误文案(普通)」
4892
+ * 还是「在弹层展示错误并保留供重试(debug)」,从而让两种模式共享同一份校验逻辑。
4893
+ */
4894
+ const doValidate = async (onInvalid) => {
4895
+ try {
4896
+ await (0, vue.nextTick)();
4897
+ const error = await formRef.value.validate();
4898
+ if (error) onInvalid(error);
4899
+ else {
4900
+ resolve("");
3774
4901
  cleanup();
3775
4902
  }
3776
- }, {
3777
- flush: "post",
3778
- immediate: true
3779
- });
3780
- return () => (0, vue.h)(Form_default, {
3781
- ...formProps,
3782
- ref: formRef
3783
- });
3784
- }
3785
- }));
3786
- if (appContext) Object.assign(app._context, appContext);
3787
- const cleanup = () => {
3788
- if (cleaned) return;
3789
- cleaned = true;
3790
- if (timer) {
3791
- clearTimeout(timer);
3792
- timer = null;
3793
- }
3794
- try {
3795
- app.unmount();
3796
- } catch {}
3797
- container.parentNode?.removeChild(container);
3798
- };
3799
- if (timeout > 0) timer = setTimeout(() => {
3800
- if (!cleaned) {
3801
- reject(/* @__PURE__ */ new Error(`submitForm timeout after ${timeout}ms: form is not initialized.`));
3802
- cleanup();
3803
- }
3804
- }, timeout);
3805
- try {
3806
- app.mount(container);
3807
- } catch (err) {
3808
- reject(err);
3809
- cleanup();
4903
+ } catch (err) {
4904
+ reject(err);
4905
+ cleanup();
4906
+ }
4907
+ };
4908
+ if (debug) return createDebugWrapper({
4909
+ formRef,
4910
+ formProps,
4911
+ name: "MFormValidateWrapper",
4912
+ title: "validateForm 调试",
4913
+ onConfirm: (setError) => doValidate((error) => {
4914
+ setError(error);
4915
+ }),
4916
+ onCancel: () => {
4917
+ reject(/* @__PURE__ */ new Error("validateForm canceled in debug mode."));
4918
+ cleanup();
4919
+ }
4920
+ });
4921
+ return (0, vue.defineComponent)({
4922
+ name: "MFormValidateWrapper",
4923
+ setup() {
4924
+ const stop = (0, vue.watch)(() => formRef.value?.initialized, (initialized) => {
4925
+ if (!initialized) return;
4926
+ stop();
4927
+ doValidate((error) => {
4928
+ resolve(error);
4929
+ cleanup();
4930
+ });
4931
+ }, {
4932
+ flush: "post",
4933
+ immediate: true
4934
+ });
4935
+ return () => (0, vue.h)(Form_default, {
4936
+ ...formProps,
4937
+ ref: formRef
4938
+ });
4939
+ }
4940
+ });
3810
4941
  }
3811
4942
  });
3812
4943
  };
@@ -3824,6 +4955,11 @@
3824
4955
  parentValues: {},
3825
4956
  width: {},
3826
4957
  labelWidth: {},
4958
+ typeMatchValid: { type: Boolean },
4959
+ validateOnInit: {
4960
+ type: Boolean,
4961
+ default: false
4962
+ },
3827
4963
  fullscreen: { type: Boolean },
3828
4964
  disabled: { type: Boolean },
3829
4965
  title: {},
@@ -3853,7 +4989,12 @@
3853
4989
  type: Boolean,
3854
4990
  default: true
3855
4991
  },
3856
- extendState: {}
4992
+ useFieldTextInError: {
4993
+ type: Boolean,
4994
+ default: true
4995
+ },
4996
+ extendState: {},
4997
+ theme: {}
3857
4998
  },
3858
4999
  emits: [
3859
5000
  "close",
@@ -3863,6 +5004,9 @@
3863
5004
  ],
3864
5005
  setup(__props, { expose: __expose, emit: __emit }) {
3865
5006
  const props = __props;
5007
+ const ancestorTheme = (0, vue.inject)(_tmagic_design.M_THEME_KEY, null);
5008
+ const effectiveTheme = (0, vue.computed)(() => props.theme || ancestorTheme?.value || "");
5009
+ (0, vue.provide)(_tmagic_design.M_THEME_KEY, effectiveTheme);
3866
5010
  const emit = __emit;
3867
5011
  const form = (0, vue.ref)();
3868
5012
  const dialogVisible = (0, vue.ref)(false);
@@ -3886,7 +5030,8 @@
3886
5030
  const save = async () => {
3887
5031
  try {
3888
5032
  const changeRecords = [...form.value?.changeRecords || []];
3889
- emit("submit", await form.value?.submitForm(), { changeRecords });
5033
+ const values = await form.value?.submitForm();
5034
+ emit("submit", values, { changeRecords });
3890
5035
  } catch (e) {
3891
5036
  emit("error", e);
3892
5037
  }
@@ -3922,7 +5067,7 @@
3922
5067
  return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicDialog), {
3923
5068
  modelValue: dialogVisible.value,
3924
5069
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
3925
- class: "m-form-dialog",
5070
+ class: (0, vue.normalizeClass)(["m-form-dialog", effectiveTheme.value ? `m-theme--${effectiveTheme.value}` : ""]),
3926
5071
  top: "20px",
3927
5072
  "append-to-body": "",
3928
5073
  title: __props.title,
@@ -4003,7 +5148,11 @@
4003
5148
  "label-position": __props.labelPosition,
4004
5149
  inline: __props.inline,
4005
5150
  "prevent-submit-default": __props.preventSubmitDefault,
5151
+ "use-field-text-in-error": __props.useFieldTextInError,
5152
+ "type-match-valid": __props.typeMatchValid,
5153
+ "validate-on-init": __props.validateOnInit,
4006
5154
  "extend-state": __props.extendState,
5155
+ theme: effectiveTheme.value,
4007
5156
  onChange: changeHandler
4008
5157
  }, null, 8, [
4009
5158
  "modelValue",
@@ -4016,11 +5165,16 @@
4016
5165
  "label-position",
4017
5166
  "inline",
4018
5167
  "prevent-submit-default",
4019
- "extend-state"
5168
+ "use-field-text-in-error",
5169
+ "type-match-valid",
5170
+ "validate-on-init",
5171
+ "extend-state",
5172
+ "theme"
4020
5173
  ]), (0, vue.renderSlot)(_ctx.$slots, "default")], 4)) : (0, vue.createCommentVNode)("v-if", true)]),
4021
5174
  _: 3
4022
5175
  }, 8, [
4023
5176
  "modelValue",
5177
+ "class",
4024
5178
  "title",
4025
5179
  "width",
4026
5180
  "zIndex",
@@ -4039,7 +5193,7 @@
4039
5193
  //#endregion
4040
5194
  //#region packages/form/src/FormDrawer.vue
4041
5195
  var FormDrawer_default = /* @__PURE__ */ (0, vue.defineComponent)({
4042
- name: "MFormDialog",
5196
+ name: "MFormDrawer",
4043
5197
  __name: "FormDrawer",
4044
5198
  props: {
4045
5199
  config: { default: () => [] },
@@ -4047,6 +5201,11 @@
4047
5201
  parentValues: {},
4048
5202
  width: {},
4049
5203
  labelWidth: {},
5204
+ typeMatchValid: { type: Boolean },
5205
+ validateOnInit: {
5206
+ type: Boolean,
5207
+ default: false
5208
+ },
4050
5209
  disabled: { type: Boolean },
4051
5210
  closeOnPressEscape: {
4052
5211
  type: Boolean,
@@ -4059,8 +5218,13 @@
4059
5218
  inline: { type: Boolean },
4060
5219
  labelPosition: {},
4061
5220
  preventSubmitDefault: { type: Boolean },
5221
+ useFieldTextInError: {
5222
+ type: Boolean,
5223
+ default: true
5224
+ },
4062
5225
  beforeClose: {},
4063
- extendState: {}
5226
+ extendState: {},
5227
+ theme: {}
4064
5228
  },
4065
5229
  emits: [
4066
5230
  "close",
@@ -4072,11 +5236,15 @@
4072
5236
  "opened"
4073
5237
  ],
4074
5238
  setup(__props, { expose: __expose, emit: __emit }) {
5239
+ const props = __props;
5240
+ const ancestorTheme = (0, vue.inject)(_tmagic_design.M_THEME_KEY, null);
5241
+ const effectiveTheme = (0, vue.computed)(() => props.theme || ancestorTheme?.value || "");
5242
+ (0, vue.provide)(_tmagic_design.M_THEME_KEY, effectiveTheme);
4075
5243
  const emit = __emit;
4076
5244
  const drawer = (0, vue.ref)();
4077
5245
  const form = (0, vue.ref)();
4078
5246
  const drawerBody = (0, vue.ref)();
4079
- const visible = (0, vue.ref)(false);
5247
+ const dialogVisible = (0, vue.ref)(false);
4080
5248
  const saveFetch = (0, vue.ref)(false);
4081
5249
  const bodyHeight = (0, vue.ref)(0);
4082
5250
  (0, vue.watchEffect)(() => {
@@ -4085,7 +5253,8 @@
4085
5253
  const submitHandler = async () => {
4086
5254
  try {
4087
5255
  const changeRecords = form.value?.changeRecords;
4088
- emit("submit", await form.value?.submitForm(), { changeRecords });
5256
+ const values = await form.value?.submitForm();
5257
+ emit("submit", values, { changeRecords });
4089
5258
  } catch (e) {
4090
5259
  emit("error", e);
4091
5260
  }
@@ -4106,30 +5275,48 @@
4106
5275
  emit("closed");
4107
5276
  };
4108
5277
  const show = () => {
4109
- visible.value = true;
5278
+ dialogVisible.value = true;
4110
5279
  };
4111
5280
  const hide = () => {
4112
- visible.value = false;
5281
+ dialogVisible.value = false;
5282
+ };
5283
+ const close = () => {
5284
+ dialogVisible.value = false;
5285
+ };
5286
+ const cancel = () => {
5287
+ hide();
4113
5288
  };
4114
5289
  /** 用于关闭 Drawer, 该方法会调用传入的 before-close 方法 */
4115
5290
  const handleClose = () => {
4116
5291
  drawer.value?.handleClose();
4117
5292
  };
5293
+ const save = async () => {
5294
+ try {
5295
+ const changeRecords = [...form.value?.changeRecords || []];
5296
+ const values = await form.value?.submitForm();
5297
+ emit("submit", values, { changeRecords });
5298
+ } catch (e) {
5299
+ emit("error", e);
5300
+ }
5301
+ };
4118
5302
  __expose({
4119
5303
  form,
4120
5304
  saveFetch,
4121
5305
  bodyHeight,
5306
+ close,
4122
5307
  show,
4123
5308
  hide,
5309
+ save,
5310
+ cancel,
4124
5311
  handleClose
4125
5312
  });
4126
5313
  return (_ctx, _cache) => {
4127
5314
  return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicDrawer), {
4128
- class: "m-form-drawer",
5315
+ class: (0, vue.normalizeClass)(["m-form-drawer", effectiveTheme.value ? `m-theme--${effectiveTheme.value}` : ""]),
4129
5316
  ref_key: "drawer",
4130
5317
  ref: drawer,
4131
- modelValue: visible.value,
4132
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
5318
+ modelValue: dialogVisible.value,
5319
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dialogVisible.value = $event),
4133
5320
  title: __props.title,
4134
5321
  "close-on-press-escape": __props.closeOnPressEscape,
4135
5322
  "append-to-body": true,
@@ -4167,7 +5354,7 @@
4167
5354
  })]),
4168
5355
  _: 3
4169
5356
  })]),
4170
- default: (0, vue.withCtx)(() => [visible.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
5357
+ default: (0, vue.withCtx)(() => [dialogVisible.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
4171
5358
  key: 0,
4172
5359
  ref_key: "drawerBody",
4173
5360
  ref: drawerBody,
@@ -4184,7 +5371,11 @@
4184
5371
  "label-position": __props.labelPosition,
4185
5372
  inline: __props.inline,
4186
5373
  "prevent-submit-default": __props.preventSubmitDefault,
5374
+ "use-field-text-in-error": __props.useFieldTextInError,
5375
+ "type-match-valid": __props.typeMatchValid,
5376
+ "validate-on-init": __props.validateOnInit,
4187
5377
  "extend-state": __props.extendState,
5378
+ theme: effectiveTheme.value,
4188
5379
  onChange: changeHandler
4189
5380
  }, null, 8, [
4190
5381
  "size",
@@ -4196,10 +5387,15 @@
4196
5387
  "label-position",
4197
5388
  "inline",
4198
5389
  "prevent-submit-default",
4199
- "extend-state"
5390
+ "use-field-text-in-error",
5391
+ "type-match-valid",
5392
+ "validate-on-init",
5393
+ "extend-state",
5394
+ "theme"
4200
5395
  ]), (0, vue.renderSlot)(_ctx.$slots, "default")], 512)) : (0, vue.createCommentVNode)("v-if", true)]),
4201
5396
  _: 3
4202
5397
  }, 8, [
5398
+ "class",
4203
5399
  "modelValue",
4204
5400
  "title",
4205
5401
  "close-on-press-escape",
@@ -4225,12 +5421,21 @@
4225
5421
  width: {},
4226
5422
  height: {},
4227
5423
  labelWidth: {},
5424
+ typeMatchValid: { type: Boolean },
5425
+ validateOnInit: {
5426
+ type: Boolean,
5427
+ default: false
5428
+ },
4228
5429
  disabled: { type: Boolean },
4229
5430
  size: {},
4230
5431
  confirmText: { default: "确定" },
4231
5432
  inline: { type: Boolean },
4232
5433
  labelPosition: {},
4233
5434
  preventSubmitDefault: { type: Boolean },
5435
+ useFieldTextInError: {
5436
+ type: Boolean,
5437
+ default: true
5438
+ },
4234
5439
  extendState: {}
4235
5440
  },
4236
5441
  emits: [
@@ -4257,7 +5462,8 @@
4257
5462
  const submitHandler = async () => {
4258
5463
  try {
4259
5464
  const changeRecords = form.value?.changeRecords;
4260
- emit("submit", await form.value?.submitForm(), { changeRecords });
5465
+ const values = await form.value?.submitForm();
5466
+ emit("submit", values, { changeRecords });
4261
5467
  } catch (e) {
4262
5468
  emit("error", e);
4263
5469
  }
@@ -4293,7 +5499,10 @@
4293
5499
  "label-position": __props.labelPosition,
4294
5500
  inline: __props.inline,
4295
5501
  "prevent-submit-default": __props.preventSubmitDefault,
5502
+ "use-field-text-in-error": __props.useFieldTextInError,
4296
5503
  "extend-state": __props.extendState,
5504
+ "type-match-valid": __props.typeMatchValid,
5505
+ "validate-on-init": __props.validateOnInit,
4297
5506
  onChange: changeHandler
4298
5507
  }, null, 8, [
4299
5508
  "size",
@@ -4305,7 +5514,10 @@
4305
5514
  "label-position",
4306
5515
  "inline",
4307
5516
  "prevent-submit-default",
4308
- "extend-state"
5517
+ "use-field-text-in-error",
5518
+ "extend-state",
5519
+ "type-match-valid",
5520
+ "validate-on-init"
4309
5521
  ]), (0, vue.renderSlot)(_ctx.$slots, "default")]),
4310
5522
  _: 3
4311
5523
  })], 4), (0, vue.createElementVNode)("div", {
@@ -4331,16 +5543,16 @@
4331
5543
  //#endregion
4332
5544
  //#region packages/form/src/containers/Fieldset.vue?vue&type=script&setup=true&lang.ts
4333
5545
  var _hoisted_1$11 = ["innerHTML"];
4334
- var _hoisted_2$6 = ["innerHTML"];
4335
- var _hoisted_3$5 = { key: 1 };
4336
- var _hoisted_4$3 = ["innerHTML"];
4337
- var _hoisted_5$2 = ["innerHTML"];
4338
- var _hoisted_6 = {
5546
+ var _hoisted_2$7 = ["innerHTML"];
5547
+ var _hoisted_3$6 = { key: 1 };
5548
+ var _hoisted_4$5 = ["innerHTML"];
5549
+ var _hoisted_5$3 = ["innerHTML"];
5550
+ var _hoisted_6$2 = {
4339
5551
  key: 2,
4340
5552
  style: { "display": "flex" }
4341
5553
  };
4342
- var _hoisted_7 = { style: { "flex": "1" } };
4343
- var _hoisted_8 = ["src"];
5554
+ var _hoisted_7$1 = { style: { "flex": "1" } };
5555
+ var _hoisted_8$1 = ["src"];
4344
5556
  //#endregion
4345
5557
  //#region packages/form/src/containers/Fieldset.vue
4346
5558
  var Fieldset_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -4366,6 +5578,7 @@
4366
5578
  const emit = __emit;
4367
5579
  const mForm = (0, vue.inject)("mForm");
4368
5580
  const name = (0, vue.computed)(() => props.config.name || "");
5581
+ const legend = (0, vue.computed)(() => filterFunction(mForm, props.config.legend, props));
4369
5582
  const checkboxName = (0, vue.computed)(() => {
4370
5583
  if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.name === "string") return props.config.checkbox.name;
4371
5584
  return "value";
@@ -4405,11 +5618,11 @@
4405
5618
  "false-value": checkboxFalseValue.value,
4406
5619
  "onUpdate:modelValue": valueChangeHandler
4407
5620
  }, {
4408
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: __props.config.legend }, null, 8, _hoisted_1$11), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
5621
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: legend.value }, null, 8, _hoisted_1$11), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
4409
5622
  key: 0,
4410
5623
  innerHTML: __props.config.extra,
4411
5624
  class: "m-form-tip"
4412
- }, null, 8, _hoisted_2$6)) : (0, vue.createCommentVNode)("v-if", true)]),
5625
+ }, null, 8, _hoisted_2$7)) : (0, vue.createCommentVNode)("v-if", true)]),
4413
5626
  _: 1
4414
5627
  }, 8, [
4415
5628
  "model-value",
@@ -4418,11 +5631,11 @@
4418
5631
  "false-value"
4419
5632
  ])]),
4420
5633
  _: 1
4421
- })) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("legend", _hoisted_3$5, [(0, vue.createElementVNode)("span", { innerHTML: __props.config.legend }, null, 8, _hoisted_4$3), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
5634
+ })) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("legend", _hoisted_3$6, [(0, vue.createElementVNode)("span", { innerHTML: legend.value }, null, 8, _hoisted_4$5), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
4422
5635
  key: 0,
4423
5636
  innerHTML: __props.config.extra,
4424
5637
  class: "m-form-tip"
4425
- }, null, 8, _hoisted_5$2)) : (0, vue.createCommentVNode)("v-if", true)])), __props.config.schematic && show.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_6, [(0, vue.createElementVNode)("div", _hoisted_7, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(__props.config.items, (item, index) => {
5638
+ }, null, 8, _hoisted_5$3)) : (0, vue.createCommentVNode)("v-if", true)])), __props.config.schematic && show.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_6$2, [(0, vue.createElementVNode)("div", _hoisted_7$1, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(__props.config.items, (item, index) => {
4426
5639
  return (0, vue.openBlock)(), (0, vue.createBlock)(Container_default, {
4427
5640
  key: key(item, index),
4428
5641
  model: name.value ? __props.model[name.value] : __props.model,
@@ -4450,7 +5663,7 @@
4450
5663
  }), 128))]), (0, vue.createElementVNode)("img", {
4451
5664
  class: "m-form-schematic",
4452
5665
  src: __props.config.schematic
4453
- }, null, 8, _hoisted_8)])) : show.value ? ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 3 }, (0, vue.renderList)(__props.config.items, (item, index) => {
5666
+ }, null, 8, _hoisted_8$1)])) : show.value ? ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 3 }, (0, vue.renderList)(__props.config.items, (item, index) => {
4454
5667
  return (0, vue.openBlock)(), (0, vue.createBlock)(Container_default, {
4455
5668
  key: key(item, index),
4456
5669
  model: name.value ? __props.model[name.value] : __props.model,
@@ -4547,13 +5760,13 @@
4547
5760
  "display": "flex",
4548
5761
  "align-items": "center"
4549
5762
  } };
4550
- var _hoisted_2$5 = ["innerHTML"];
4551
- var _hoisted_3$4 = {
5763
+ var _hoisted_2$6 = ["innerHTML"];
5764
+ var _hoisted_3$5 = {
4552
5765
  key: 0,
4553
5766
  style: { "display": "flex" }
4554
5767
  };
4555
- var _hoisted_4$2 = { style: { "flex": "1" } };
4556
- var _hoisted_5$1 = ["src"];
5768
+ var _hoisted_4$4 = { style: { "flex": "1" } };
5769
+ var _hoisted_5$2 = ["src"];
4557
5770
  //#endregion
4558
5771
  //#region packages/form/src/containers/Panel.vue
4559
5772
  var Panel_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -4568,7 +5781,8 @@
4568
5781
  labelWidth: {},
4569
5782
  prop: {},
4570
5783
  size: {},
4571
- disabled: { type: Boolean }
5784
+ disabled: { type: Boolean },
5785
+ hideExpand: { type: Boolean }
4572
5786
  },
4573
5787
  emits: ["change", "addDiffCount"],
4574
5788
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -4592,26 +5806,31 @@
4592
5806
  return items.value && items.value.length ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicCard), {
4593
5807
  key: 0,
4594
5808
  class: "box-card m-form-panel",
4595
- "body-style": { display: expand.value ? "block" : "none" }
5809
+ "body-style": { display: expand.value ? "block" : "none" },
5810
+ flat: __props.config.flat
4596
5811
  }, {
4597
5812
  header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$10, [
4598
- (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
4599
- style: { "padding": "0" },
5813
+ !__props.hideExpand ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
5814
+ key: 0,
5815
+ style: {
5816
+ "padding": "0",
5817
+ "margin-right": "10px"
5818
+ },
4600
5819
  link: "",
4601
- icon: expand.value ? (0, vue.unref)(_element_plus_icons_vue.CaretBottom) : (0, vue.unref)(_element_plus_icons_vue.CaretRight),
5820
+ icon: expand.value ? (0, vue.unref)(_element_plus_icons_vue.ArrowDown) : (0, vue.unref)(_element_plus_icons_vue.ArrowRight),
4602
5821
  onClick: _cache[0] || (_cache[0] = ($event) => expand.value = !expand.value)
4603
- }, null, 8, ["icon"]),
5822
+ }, null, 8, ["icon"])) : (0, vue.createCommentVNode)("v-if", true),
4604
5823
  (0, vue.renderSlot)(_ctx.$slots, "header", {}, () => [(0, vue.createElementVNode)("span", {
4605
5824
  style: { "cursor": "pointer" },
4606
5825
  onClick: _cache[1] || (_cache[1] = ($event) => expand.value = !expand.value)
4607
5826
  }, (0, vue.toDisplayString)(filter(__props.config.title)), 1)]),
4608
5827
  __props.config && __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
4609
- key: 0,
5828
+ key: 1,
4610
5829
  innerHTML: __props.config.extra,
4611
5830
  class: "m-form-tip"
4612
- }, null, 8, _hoisted_2$5)) : (0, vue.createCommentVNode)("v-if", true)
5831
+ }, null, 8, _hoisted_2$6)) : (0, vue.createCommentVNode)("v-if", true)
4613
5832
  ])]),
4614
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", null, [(0, vue.renderSlot)(_ctx.$slots, "default"), __props.config.schematic ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_3$4, [(0, vue.createElementVNode)("div", _hoisted_4$2, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(items.value, (item, index) => {
5833
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", null, [(0, vue.renderSlot)(_ctx.$slots, "default"), __props.config.schematic ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_3$5, [(0, vue.createElementVNode)("div", _hoisted_4$4, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(items.value, (item, index) => {
4615
5834
  return (0, vue.openBlock)(), (0, vue.createBlock)(Container_default, {
4616
5835
  key: item[(0, vue.unref)(mForm)?.keyProp || "__key"] ?? index,
4617
5836
  config: item,
@@ -4637,7 +5856,7 @@
4637
5856
  }), 128))]), (0, vue.createElementVNode)("img", {
4638
5857
  class: "m-form-schematic",
4639
5858
  src: __props.config.schematic
4640
- }, null, 8, _hoisted_5$1)])) : ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, (0, vue.renderList)(items.value, (item, index) => {
5859
+ }, null, 8, _hoisted_5$2)])) : ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, (0, vue.renderList)(items.value, (item, index) => {
4641
5860
  return (0, vue.openBlock)(), (0, vue.createBlock)(Container_default, {
4642
5861
  key: item[(0, vue.unref)(mForm)?.keyProp || "__key"] ?? index,
4643
5862
  config: item,
@@ -4662,7 +5881,7 @@
4662
5881
  ]);
4663
5882
  }), 128))])]),
4664
5883
  _: 3
4665
- }, 8, ["body-style"])) : (0, vue.createCommentVNode)("v-if", true);
5884
+ }, 8, ["body-style", "flat"])) : (0, vue.createCommentVNode)("v-if", true);
4666
5885
  };
4667
5886
  }
4668
5887
  });
@@ -4705,7 +5924,8 @@
4705
5924
  size: __props.size,
4706
5925
  disabled: __props.disabled,
4707
5926
  onChange: changeHandler,
4708
- onAddDiffCount
5927
+ onAddDiffCount,
5928
+ "is-in-row": true
4709
5929
  }, null, 8, [
4710
5930
  "model",
4711
5931
  "lastValues",
@@ -4976,12 +6196,13 @@
4976
6196
  });
4977
6197
  //#endregion
4978
6198
  //#region packages/form/src/containers/GroupListItem.vue?vue&type=script&setup=true&lang.ts
4979
- var _hoisted_1$9 = ["innerHTML"];
4980
- var _hoisted_2$4 = { style: {
6199
+ var _hoisted_1$9 = { class: "m-fields-group-list-item-header" };
6200
+ var _hoisted_2$5 = ["innerHTML"];
6201
+ var _hoisted_3$4 = { style: {
4981
6202
  "text-align": "right",
4982
6203
  "margin-top": "20px"
4983
6204
  } };
4984
- var _hoisted_3$3 = ["innerHTML"];
6205
+ var _hoisted_4$3 = ["innerHTML"];
4985
6206
  //#endregion
4986
6207
  //#region packages/form/src/containers/GroupListItem.vue
4987
6208
  var GroupListItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -5020,7 +6241,10 @@
5020
6241
  [mForm?.keyProp || "__key"]: `${props.config[mForm?.keyProp || "__key"]}${String(props.index)}`
5021
6242
  }));
5022
6243
  const title = (0, vue.computed)(() => {
5023
- if (props.config.titleKey && props.model[props.config.titleKey]) return props.model[props.config.titleKey];
6244
+ if (props.config.titleKey && props.model[props.config.titleKey]) {
6245
+ const { titlePrefix } = props.config;
6246
+ return titlePrefix ? `${titlePrefix} ${String(props.index + 1)}: ${props.model[props.config.titleKey]}` : `${props.model[props.config.titleKey]}`;
6247
+ }
5024
6248
  if (props.config.title) return filterFunction(mForm, props.config.title, props);
5025
6249
  return `${props.config.titlePrefix || "组"} ${String(props.index + 1)}`;
5026
6250
  });
@@ -5059,33 +6283,39 @@
5059
6283
  return (_ctx, _cache) => {
5060
6284
  return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicCard), {
5061
6285
  class: "m-fields-group-list-item",
6286
+ flat: __props.config.flat,
5062
6287
  "body-style": { display: expand.value ? "block" : "none" }
5063
6288
  }, {
5064
- header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", null, [
6289
+ header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$9, [
5065
6290
  (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
5066
6291
  link: "",
5067
6292
  disabled: __props.disabled,
5068
- onClick: expandHandler
6293
+ onClick: expandHandler,
6294
+ class: "expand-button"
5069
6295
  }, {
5070
6296
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), null, {
5071
- default: (0, vue.withCtx)(() => [expand.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.CaretBottom), { key: 0 })) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.CaretRight), { key: 1 }))]),
6297
+ default: (0, vue.withCtx)(() => [expand.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.ArrowDown), { key: 0 })) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.ArrowRight), { key: 1 }))]),
5072
6298
  _: 1
5073
- }), (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_1$9)]),
6299
+ })]),
5074
6300
  _: 1
5075
6301
  }, 8, ["disabled"]),
5076
- !__props.isCompare ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
5077
- key: 0,
5078
- type: "danger",
5079
- size: "small",
5080
- link: "",
5081
- icon: (0, vue.unref)(_element_plus_icons_vue.Delete),
5082
- disabled: __props.disabled,
5083
- onClick: removeHandler
5084
- }, null, 8, ["icon", "disabled"])), [[vue.vShow, showDelete.value]]) : (0, vue.createCommentVNode)("v-if", true),
6302
+ (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_2$5),
6303
+ (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicTooltip), { content: `删除 ${title.value}` }, {
6304
+ default: (0, vue.withCtx)(() => [!__props.isCompare ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
6305
+ key: 0,
6306
+ size: "default",
6307
+ link: "",
6308
+ class: "delete-button",
6309
+ icon: (0, vue.unref)(_element_plus_icons_vue.Delete),
6310
+ disabled: __props.disabled,
6311
+ onClick: removeHandler
6312
+ }, null, 8, ["icon", "disabled"])), [[vue.vShow, showDelete.value]]) : (0, vue.createCommentVNode)("v-if", true)]),
6313
+ _: 1
6314
+ }, 8, ["content"]),
5085
6315
  copyable.value && !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
5086
- key: 1,
6316
+ key: 0,
5087
6317
  link: "",
5088
- size: "small",
6318
+ size: "default",
5089
6319
  type: "primary",
5090
6320
  icon: (0, vue.unref)(_element_plus_icons_vue.DocumentCopy),
5091
6321
  disabled: __props.disabled,
@@ -5094,27 +6324,27 @@
5094
6324
  default: (0, vue.withCtx)(() => [..._cache[6] || (_cache[6] = [(0, vue.createTextVNode)("复制", -1)])]),
5095
6325
  _: 1
5096
6326
  }, 8, ["icon", "disabled"])) : (0, vue.createCommentVNode)("v-if", true),
5097
- movable.value && !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
6327
+ movable.value && !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
5098
6328
  link: "",
5099
- size: "small",
6329
+ size: "default",
5100
6330
  disabled: __props.disabled,
5101
- icon: (0, vue.unref)(_element_plus_icons_vue.CaretTop),
6331
+ icon: (0, vue.unref)(_element_plus_icons_vue.Top),
5102
6332
  onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
5103
6333
  }, {
5104
6334
  default: (0, vue.withCtx)(() => [..._cache[7] || (_cache[7] = [(0, vue.createTextVNode)("上移", -1)])]),
5105
6335
  _: 1
5106
6336
  }, 8, ["disabled", "icon"]), [[vue.vShow, __props.index !== 0]]), (0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
5107
6337
  link: "",
5108
- size: "small",
6338
+ size: "default",
5109
6339
  disabled: __props.disabled,
5110
- icon: (0, vue.unref)(_element_plus_icons_vue.CaretBottom),
6340
+ icon: (0, vue.unref)(_element_plus_icons_vue.Bottom),
5111
6341
  onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
5112
6342
  }, {
5113
6343
  default: (0, vue.withCtx)(() => [..._cache[8] || (_cache[8] = [(0, vue.createTextVNode)("下移", -1)])]),
5114
6344
  _: 1
5115
6345
  }, 8, ["disabled", "icon"]), [[vue.vShow, __props.index !== length.value - 1]])], 64)) : (0, vue.createCommentVNode)("v-if", true),
5116
6346
  __props.config.moveSpecifyLocation && !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicPopover), {
5117
- key: 3,
6347
+ key: 2,
5118
6348
  trigger: "click",
5119
6349
  placement: "top",
5120
6350
  width: "200",
@@ -5142,7 +6372,7 @@
5142
6372
  disabled: __props.disabled
5143
6373
  }, null, 8, ["modelValue", "disabled"]),
5144
6374
  _cache[11] || (_cache[11] = (0, vue.createTextVNode)("行 ", -1))
5145
- ]), (0, vue.createElementVNode)("div", _hoisted_2$4, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
6375
+ ]), (0, vue.createElementVNode)("div", _hoisted_3$4, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
5146
6376
  size: "small",
5147
6377
  text: "",
5148
6378
  onClick: _cache[4] || (_cache[4] = ($event) => moveSpecifyLocationVisible.value = false)
@@ -5160,10 +6390,10 @@
5160
6390
  _: 1
5161
6391
  }, 8, ["visible"])) : (0, vue.createCommentVNode)("v-if", true),
5162
6392
  itemExtra.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
5163
- key: 4,
6393
+ key: 3,
5164
6394
  innerHTML: itemExtra.value,
5165
6395
  class: "m-form-tip"
5166
- }, null, 8, _hoisted_3$3)) : (0, vue.createCommentVNode)("v-if", true)
6396
+ }, null, 8, _hoisted_4$3)) : (0, vue.createCommentVNode)("v-if", true)
5167
6397
  ])]),
5168
6398
  default: (0, vue.withCtx)(() => [expand.value ? ((0, vue.openBlock)(), (0, vue.createBlock)(Container_default, {
5169
6399
  key: 0,
@@ -5188,23 +6418,24 @@
5188
6418
  "disabled"
5189
6419
  ])) : (0, vue.createCommentVNode)("v-if", true)]),
5190
6420
  _: 1
5191
- }, 8, ["body-style"]);
6421
+ }, 8, ["flat", "body-style"]);
5192
6422
  };
5193
6423
  }
5194
6424
  });
5195
6425
  //#endregion
5196
6426
  //#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
5197
6427
  var _hoisted_1$8 = { class: "m-fields-group-list" };
5198
- var _hoisted_2$3 = ["innerHTML"];
5199
- var _hoisted_3$2 = {
6428
+ var _hoisted_2$4 = ["innerHTML"];
6429
+ var _hoisted_3$3 = {
5200
6430
  key: 1,
5201
6431
  class: "el-table__empty-block"
5202
6432
  };
5203
- var _hoisted_4$1 = {
6433
+ var _hoisted_4$2 = { class: "el-table__empty-text t-table__empty" };
6434
+ var _hoisted_5$1 = {
5204
6435
  key: 3,
5205
6436
  class: "m-fields-group-list-footer"
5206
6437
  };
5207
- var _hoisted_5 = { style: {
6438
+ var _hoisted_6$1 = { style: {
5208
6439
  "display": "flex",
5209
6440
  "justify-content": "flex-end",
5210
6441
  "flex": "1"
@@ -5256,8 +6487,8 @@
5256
6487
  key: 0,
5257
6488
  innerHTML: __props.config.extra,
5258
6489
  style: { "color": "rgba(0, 0, 0, 0.45)" }
5259
- }, null, 8, _hoisted_2$3)) : (0, vue.createCommentVNode)("v-if", true),
5260
- !__props.model[__props.name] || !__props.model[__props.name].length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_3$2, [..._cache[1] || (_cache[1] = [(0, vue.createElementVNode)("span", { class: "el-table__empty-text t-table__empty" }, "暂无数据", -1)])])) : ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, (0, vue.renderList)(__props.model[__props.name], (item, index) => {
6490
+ }, null, 8, _hoisted_2$4)) : (0, vue.createCommentVNode)("v-if", true),
6491
+ !__props.model[__props.name] || !__props.model[__props.name].length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_3$3, [(0, vue.createElementVNode)("span", _hoisted_4$2, "暂无" + (0, vue.toDisplayString)(__props.config.titlePrefix || "") + "数据", 1)])) : ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, (0, vue.renderList)(__props.model[__props.name], (item, index) => {
5261
6492
  return (0, vue.openBlock)(), (0, vue.createBlock)(GroupListItem_default, {
5262
6493
  key: index,
5263
6494
  model: item,
@@ -5288,7 +6519,7 @@
5288
6519
  "group-model"
5289
6520
  ]);
5290
6521
  }), 128)),
5291
- !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_4$1, [(0, vue.renderSlot)(_ctx.$slots, "toggle-button"), (0, vue.createElementVNode)("div", _hoisted_5, [(0, vue.renderSlot)(_ctx.$slots, "add-button")])])) : (0, vue.createCommentVNode)("v-if", true)
6522
+ !__props.isCompare ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5$1, [(0, vue.renderSlot)(_ctx.$slots, "toggle-button"), (0, vue.createElementVNode)("div", _hoisted_6$1, [(0, vue.renderSlot)(_ctx.$slots, "add-button")])])) : (0, vue.createCommentVNode)("v-if", true)
5292
6523
  ]);
5293
6524
  };
5294
6525
  }
@@ -5450,7 +6681,8 @@
5450
6681
  index: {},
5451
6682
  row: {},
5452
6683
  prop: {},
5453
- sortKey: {}
6684
+ sortKey: {},
6685
+ flat: { type: Boolean }
5454
6686
  },
5455
6687
  emits: ["change"],
5456
6688
  setup(__props, { emit: __emit }) {
@@ -5521,19 +6753,25 @@
5521
6753
  type: "danger",
5522
6754
  link: "",
5523
6755
  title: "删除",
5524
- icon: __props.config.deleteActionButtonIcon || (0, vue.unref)(_element_plus_icons_vue.Delete),
6756
+ icon: __props.flat ? void 0 : __props.config.deleteActionButtonIcon || (0, vue.unref)(_element_plus_icons_vue.Delete),
5525
6757
  onClick: _cache[0] || (_cache[0] = ($event) => removeHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
5526
- }, null, 8, ["icon"]), [[vue.vShow, showDelete(__props.index + 1 + __props.currentPage * __props.pageSize - 1)]]),
6758
+ }, {
6759
+ default: (0, vue.withCtx)(() => [__props.flat ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.createTextVNode)("删除")], 64)) : (0, vue.createCommentVNode)("v-if", true)]),
6760
+ _: 1
6761
+ }, 8, ["icon"]), [[vue.vShow, showDelete(__props.index + 1 + __props.currentPage * __props.pageSize - 1)]]),
5527
6762
  copyable(__props.index + 1 + __props.currentPage * __props.pageSize - 1) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
5528
6763
  key: 1,
5529
6764
  link: "",
5530
6765
  size: "small",
5531
6766
  type: "primary",
5532
6767
  title: "复制",
5533
- icon: __props.config.copyActionButtonIcon || (0, vue.unref)(_element_plus_icons_vue.DocumentCopy),
6768
+ icon: __props.flat ? void 0 : __props.config.copyActionButtonIcon || (0, vue.unref)(_element_plus_icons_vue.DocumentCopy),
5534
6769
  disabled: __props.disabled,
5535
6770
  onClick: _cache[1] || (_cache[1] = ($event) => copyHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
5536
- }, null, 8, ["icon", "disabled"])) : (0, vue.createCommentVNode)("v-if", true)
6771
+ }, {
6772
+ default: (0, vue.withCtx)(() => [__props.flat ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.createTextVNode)("复制")], 64)) : (0, vue.createCommentVNode)("v-if", true)]),
6773
+ _: 1
6774
+ }, 8, ["icon", "disabled"])) : (0, vue.createCommentVNode)("v-if", true)
5537
6775
  ], 64);
5538
6776
  };
5539
6777
  }
@@ -5683,8 +6921,10 @@
5683
6921
  type: "selection",
5684
6922
  width: 45
5685
6923
  } });
5686
- let actionFixed = props.config.fixed === false ? void 0 : "left";
6924
+ const defaultFixed = isGlobalFlat.value ? "right" : "left";
6925
+ let actionFixed = props.config.fixed === false ? void 0 : defaultFixed;
5687
6926
  if (typeof props.config.fixed === "string" && ["left", "right"].includes(props.config.fixed)) actionFixed = props.config.fixed;
6927
+ const actionFlat = props.config.flat === void 0 && isGlobalFlat.value ? true : props.config.flat;
5688
6928
  const actionColumn = {
5689
6929
  props: {
5690
6930
  label: "操作",
@@ -5694,6 +6934,7 @@
5694
6934
  },
5695
6935
  cell: ({ row, $index }) => (0, vue.h)(ActionsColumn_default, {
5696
6936
  row,
6937
+ flat: actionFlat,
5697
6938
  index: $index,
5698
6939
  model: props.model,
5699
6940
  config: props.config,
@@ -5776,13 +7017,13 @@
5776
7017
  //#endregion
5777
7018
  //#region packages/form/src/containers/table/Table.vue?vue&type=script&setup=true&lang.ts
5778
7019
  var _hoisted_1$7 = ["innerHTML"];
5779
- var _hoisted_2$2 = { style: {
7020
+ var _hoisted_2$3 = { style: {
5780
7021
  "display": "flex",
5781
7022
  "justify-content": "space-between",
5782
7023
  "margin": "10px 0"
5783
7024
  } };
5784
- var _hoisted_3$1 = { style: { "display": "flex" } };
5785
- var _hoisted_4 = {
7025
+ var _hoisted_3$2 = { style: { "display": "flex" } };
7026
+ var _hoisted_4$1 = {
5786
7027
  key: 1,
5787
7028
  class: "bottom",
5788
7029
  style: { "text-align": "right" }
@@ -5867,20 +7108,22 @@
5867
7108
  "default-expand-all": true,
5868
7109
  key: updateKey.value,
5869
7110
  onSelect: (0, vue.unref)(selectHandle),
5870
- onSortChange: sortChangeHandler
7111
+ onSortChange: sortChangeHandler,
7112
+ "empty-text": `暂无${__props.config.titlePrefix || ""}数据`
5871
7113
  }, null, 8, [
5872
7114
  "row-key",
5873
7115
  "columns",
5874
7116
  "data",
5875
7117
  "border",
5876
7118
  "max-height",
5877
- "onSelect"
7119
+ "onSelect",
7120
+ "empty-text"
5878
7121
  ])) : (0, vue.createCommentVNode)("v-if", true)]),
5879
7122
  _: 1
5880
7123
  }, 8, ["disabled"]),
5881
7124
  (0, vue.renderSlot)(_ctx.$slots, "default"),
5882
- (0, vue.createElementVNode)("div", _hoisted_2$2, [(0, vue.createElementVNode)("div", _hoisted_3$1, [
5883
- !(0, vue.unref)(isFullscreen) ? (0, vue.renderSlot)(_ctx.$slots, "toggle-button", { key: 0 }) : (0, vue.createCommentVNode)("v-if", true),
7125
+ (0, vue.createElementVNode)("div", _hoisted_2$3, [(0, vue.createElementVNode)("div", _hoisted_3$2, [
7126
+ !(0, vue.unref)(isFullscreen) ? (0, vue.renderSlot)(_ctx.$slots, "toggle-button", {}, void 0, void 0, 0) : (0, vue.createCommentVNode)("v-if", true),
5884
7127
  __props.config.enableFullscreen !== false ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
5885
7128
  key: 1,
5886
7129
  icon: (0, vue.unref)(_element_plus_icons_vue.FullScreen),
@@ -5921,8 +7164,8 @@
5921
7164
  default: (0, vue.withCtx)(() => [..._cache[1] || (_cache[1] = [(0, vue.createTextVNode)("清空", -1)])]),
5922
7165
  _: 1
5923
7166
  }, 8, ["disabled", "onClick"])) : (0, vue.createCommentVNode)("v-if", true)
5924
- ]), !__props.isCompare ? (0, vue.renderSlot)(_ctx.$slots, "add-button", { key: 0 }) : (0, vue.createCommentVNode)("v-if", true)]),
5925
- __props.config.pagination ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_4, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicPagination), {
7167
+ ]), !__props.isCompare ? (0, vue.renderSlot)(_ctx.$slots, "add-button", {}, void 0, void 0, 0) : (0, vue.createCommentVNode)("v-if", true)]),
7168
+ __props.config.pagination ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_4$1, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicPagination), {
5926
7169
  layout: "total, sizes, prev, pager, next, jumper",
5927
7170
  "hide-on-single-page": __props.model[modelName.value].length < (0, vue.unref)(pageSize),
5928
7171
  "current-page": (0, vue.unref)(currentPage) + 1,
@@ -6142,9 +7385,10 @@
6142
7385
  size: addButtonSize.value,
6143
7386
  plain: displayMode.value === "table",
6144
7387
  icon: (0, vue.unref)(_element_plus_icons_vue.Plus),
7388
+ text: "",
6145
7389
  disabled: __props.disabled
6146
7390
  }, currentConfig.value.addButtonConfig?.props || { type: "primary" }, { onClick: (0, vue.unref)(newHandler) }), {
6147
- default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(currentConfig.value.addButtonConfig?.text || (displayMode.value === "table" ? "新增一行" : "新增")), 1)]),
7391
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(currentConfig.value.addButtonConfig?.text || (displayMode.value === "table" ? `新增一行${groupListConfig.value.titlePrefix || ""}` : `新增${groupListConfig.value.titlePrefix || ""}`)), 1)]),
6148
7392
  _: 1
6149
7393
  }, 16, [
6150
7394
  "class",
@@ -6174,9 +7418,17 @@
6174
7418
  });
6175
7419
  //#endregion
6176
7420
  //#region packages/form/src/fields/Text.vue?vue&type=script&setup=true&lang.ts
6177
- var _hoisted_1$6 = { class: "m-fields-text" };
6178
- var _hoisted_2$1 = { key: 1 };
6179
- var _hoisted_3 = { style: {
7421
+ var _hoisted_1$6 = { key: 0 };
7422
+ var _hoisted_2$2 = {
7423
+ key: 0,
7424
+ class: "m-fields-text__prepend"
7425
+ };
7426
+ var _hoisted_3$1 = { class: "m-fields-text__value" };
7427
+ var _hoisted_4 = ["src"];
7428
+ var _hoisted_5 = { key: 2 };
7429
+ var _hoisted_6 = ["src"];
7430
+ var _hoisted_7 = { key: 2 };
7431
+ var _hoisted_8 = { style: {
6180
7432
  "display": "flex",
6181
7433
  "justify-content": "flex-end"
6182
7434
  } };
@@ -6195,7 +7447,10 @@
6195
7447
  disabled: { type: Boolean },
6196
7448
  size: {},
6197
7449
  lastValues: {},
6198
- isCompare: { type: Boolean }
7450
+ isCompare: { type: Boolean },
7451
+ text: {},
7452
+ labelWidth: {},
7453
+ labelPosition: {}
6199
7454
  },
6200
7455
  emits: ["change", "input"],
6201
7456
  setup(__props, { emit: __emit }) {
@@ -6208,21 +7463,15 @@
6208
7463
  value.value = v;
6209
7464
  }, { immediate: true });
6210
7465
  const appendConfig = (0, vue.computed)(() => {
6211
- if (typeof props.config.append === "string") return {
7466
+ const { append } = props.config;
7467
+ if (typeof append === "string") return {
6212
7468
  type: "text",
6213
- text: props.config.append,
7469
+ text: append,
6214
7470
  handler: void 0
6215
7471
  };
6216
- if (typeof props.config.append === "object") {
6217
- if (typeof props.config.append?.handler === "function") return {
6218
- type: "button",
6219
- text: props.config.append.text,
6220
- handler: props.config.append.handler
6221
- };
6222
- if (props.config.append) {
6223
- if (props.config.append.value === 0) return false;
6224
- return props.config.append;
6225
- }
7472
+ if (typeof append === "object" && append) {
7473
+ if (append.value === 0) return false;
7474
+ return append;
6226
7475
  }
6227
7476
  return false;
6228
7477
  });
@@ -6318,67 +7567,97 @@
6318
7567
  instanceRef.value = void 0;
6319
7568
  };
6320
7569
  return (_ctx, _cache) => {
6321
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
6322
- modelValue: value.value,
6323
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
6324
- ref_key: "input",
6325
- ref: input,
6326
- clearable: __props.config.clearable ?? true,
6327
- size: __props.size,
6328
- placeholder: __props.config.placeholder,
6329
- disabled: __props.disabled,
6330
- onChange: changeHandler,
6331
- onInput: inputHandler,
6332
- onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
6333
- }, (0, vue.createSlots)({ _: 2 }, [__props.config.prepend ? {
6334
- name: "prepend",
6335
- fn: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(__props.config.prepend), 1)]),
6336
- key: "0"
6337
- } : void 0, appendConfig.value ? {
6338
- name: "append",
6339
- fn: (0, vue.withCtx)(() => [appendConfig.value.type === "button" ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
6340
- key: 0,
6341
- style: { "color": "#409eff" },
7570
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)(["m-fields-text", { "m-fields-text--static": __props.config.static }]) }, [
7571
+ __props.config.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6)) : (0, vue.createCommentVNode)("v-if", true),
7572
+ (0, vue.createCommentVNode)(" 新增静态展示文本样式 "),
7573
+ __props.config.static ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [
7574
+ __props.config.prepend ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_2$2, (0, vue.toDisplayString)(__props.config.prepend), 1)) : (0, vue.createCommentVNode)("v-if", true),
7575
+ (0, vue.createElementVNode)("span", _hoisted_3$1, (0, vue.toDisplayString)(value.value), 1),
7576
+ appendConfig.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [appendConfig.value.type === "button" ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
7577
+ key: 0,
7578
+ style: { "color": "#0056ea" },
7579
+ size: __props.size,
7580
+ onClick: (0, vue.withModifiers)(buttonClickHandler, ["prevent"])
7581
+ }, {
7582
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(appendConfig.value.text), 1)]),
7583
+ _: 1
7584
+ }, 8, ["size"])) : appendConfig.value.type === "icon" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("img", {
7585
+ key: 1,
7586
+ class: "m-fields-text__icon",
7587
+ src: appendConfig.value.text,
7588
+ onClick: buttonClickHandler
7589
+ }, null, 8, _hoisted_4)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_5, (0, vue.toDisplayString)(appendConfig.value.text), 1))], 64)) : (0, vue.createCommentVNode)("v-if", true)
7590
+ ], 64)) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicInput), {
7591
+ key: 2,
7592
+ modelValue: value.value,
7593
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
7594
+ ref_key: "input",
7595
+ ref: input,
7596
+ clearable: __props.config.clearable ?? true,
6342
7597
  size: __props.size,
6343
- onClick: (0, vue.withModifiers)(buttonClickHandler, ["prevent"])
6344
- }, {
6345
- default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(appendConfig.value.text), 1)]),
6346
- _: 1
6347
- }, 8, ["size"])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_2$1, (0, vue.toDisplayString)(appendConfig.value.text), 1))]),
6348
- key: "1"
6349
- } : void 0]), 1032, [
6350
- "modelValue",
6351
- "clearable",
6352
- "size",
6353
- "placeholder",
6354
- "disabled"
6355
- ]), ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, { to: "body" }, [popoverVisible.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
6356
- key: 0,
6357
- class: "tmagic-form-text-popper m-form-item__content",
6358
- ref_key: "popoverEl",
6359
- ref: popoverEl
6360
- }, [
6361
- _cache[5] || (_cache[5] = (0, vue.createElementVNode)("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
6362
- (0, vue.createElementVNode)("div", _hoisted_3, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
6363
- link: "",
6364
- size: "small",
6365
- onClick: _cache[2] || (_cache[2] = ($event) => popoverVisible.value = false)
6366
- }, {
6367
- default: (0, vue.withCtx)(() => [..._cache[3] || (_cache[3] = [(0, vue.createTextVNode)("保持原样", -1)])]),
6368
- _: 1
6369
- }), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
6370
- type: "primary",
6371
- size: "small",
6372
- onClick: confirmTrimHandler
6373
- }, {
6374
- default: (0, vue.withCtx)(() => [..._cache[4] || (_cache[4] = [(0, vue.createTextVNode)("移除空格", -1)])]),
6375
- _: 1
6376
- })]),
6377
- _cache[6] || (_cache[6] = (0, vue.createElementVNode)("span", {
6378
- class: "tmagic-form-text-popper-arrow",
6379
- "data-popper-arrow": ""
6380
- }, null, -1))
6381
- ], 512)) : (0, vue.createCommentVNode)("v-if", true)]))]);
7598
+ placeholder: __props.config.placeholder,
7599
+ disabled: __props.disabled,
7600
+ onChange: changeHandler,
7601
+ onInput: inputHandler,
7602
+ onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
7603
+ }, (0, vue.createSlots)({ _: 2 }, [__props.config.prepend ? {
7604
+ name: "prepend",
7605
+ fn: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(__props.config.prepend), 1)]),
7606
+ key: "0"
7607
+ } : void 0, appendConfig.value ? {
7608
+ name: "append",
7609
+ fn: (0, vue.withCtx)(() => [appendConfig.value.type === "button" ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
7610
+ key: 0,
7611
+ style: { "color": "#0056ea" },
7612
+ size: __props.size,
7613
+ onClick: (0, vue.withModifiers)(buttonClickHandler, ["prevent"])
7614
+ }, {
7615
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(appendConfig.value.text), 1)]),
7616
+ _: 1
7617
+ }, 8, ["size"])) : appendConfig.value.type === "icon" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("img", {
7618
+ key: 1,
7619
+ src: appendConfig.value.text,
7620
+ onClick: buttonClickHandler
7621
+ }, null, 8, _hoisted_6)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_7, (0, vue.toDisplayString)(appendConfig.value.text), 1))]),
7622
+ key: "1"
7623
+ } : void 0]), 1032, [
7624
+ "modelValue",
7625
+ "clearable",
7626
+ "size",
7627
+ "placeholder",
7628
+ "disabled"
7629
+ ])),
7630
+ !__props.config.static ? ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, {
7631
+ key: 3,
7632
+ to: "body"
7633
+ }, [popoverVisible.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
7634
+ key: 0,
7635
+ class: "tmagic-form-text-popper m-form-item__content",
7636
+ ref_key: "popoverEl",
7637
+ ref: popoverEl
7638
+ }, [
7639
+ _cache[5] || (_cache[5] = (0, vue.createElementVNode)("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
7640
+ (0, vue.createElementVNode)("div", _hoisted_8, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
7641
+ link: "",
7642
+ size: "small",
7643
+ onClick: _cache[2] || (_cache[2] = ($event) => popoverVisible.value = false)
7644
+ }, {
7645
+ default: (0, vue.withCtx)(() => [..._cache[3] || (_cache[3] = [(0, vue.createTextVNode)("保持原样", -1)])]),
7646
+ _: 1
7647
+ }), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
7648
+ type: "primary",
7649
+ size: "small",
7650
+ onClick: confirmTrimHandler
7651
+ }, {
7652
+ default: (0, vue.withCtx)(() => [..._cache[4] || (_cache[4] = [(0, vue.createTextVNode)("移除空格", -1)])]),
7653
+ _: 1
7654
+ })]),
7655
+ _cache[6] || (_cache[6] = (0, vue.createElementVNode)("span", {
7656
+ class: "tmagic-form-text-popper-arrow",
7657
+ "data-popper-arrow": ""
7658
+ }, null, -1))
7659
+ ], 512)) : (0, vue.createCommentVNode)("v-if", true)])) : (0, vue.createCommentVNode)("v-if", true)
7660
+ ], 2);
6382
7661
  };
6383
7662
  }
6384
7663
  });
@@ -6397,7 +7676,10 @@
6397
7676
  disabled: { type: Boolean },
6398
7677
  size: {},
6399
7678
  lastValues: {},
6400
- isCompare: { type: Boolean }
7679
+ isCompare: { type: Boolean },
7680
+ text: {},
7681
+ labelWidth: {},
7682
+ labelPosition: {}
6401
7683
  },
6402
7684
  emits: ["change", "input"],
6403
7685
  setup(__props, { emit: __emit }) {
@@ -6422,7 +7704,7 @@
6422
7704
  modelValue: value.value,
6423
7705
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
6424
7706
  clearable: "",
6425
- "controls-position": "right",
7707
+ "controls-position": (0, vue.unref)(isGlobalFlat) ? "" : "right",
6426
7708
  size: __props.size,
6427
7709
  max: __props.config.max,
6428
7710
  min: __props.config.min,
@@ -6433,6 +7715,7 @@
6433
7715
  onInput: inputHandler
6434
7716
  }, null, 8, [
6435
7717
  "modelValue",
7718
+ "controls-position",
6436
7719
  "size",
6437
7720
  "max",
6438
7721
  "min",
@@ -6461,7 +7744,10 @@
6461
7744
  disabled: { type: Boolean },
6462
7745
  size: {},
6463
7746
  lastValues: {},
6464
- isCompare: { type: Boolean }
7747
+ isCompare: { type: Boolean },
7748
+ text: {},
7749
+ labelWidth: {},
7750
+ labelPosition: {}
6465
7751
  },
6466
7752
  emits: ["change"],
6467
7753
  setup(__props, { emit: __emit }) {
@@ -6532,7 +7818,10 @@
6532
7818
  disabled: { type: Boolean },
6533
7819
  size: {},
6534
7820
  lastValues: {},
6535
- isCompare: { type: Boolean }
7821
+ isCompare: { type: Boolean },
7822
+ text: {},
7823
+ labelWidth: {},
7824
+ labelPosition: {}
6536
7825
  },
6537
7826
  emits: ["change", "input"],
6538
7827
  setup(__props, { emit: __emit }) {
@@ -6588,7 +7877,10 @@
6588
7877
  disabled: { type: Boolean },
6589
7878
  size: {},
6590
7879
  lastValues: {},
6591
- isCompare: { type: Boolean }
7880
+ isCompare: { type: Boolean },
7881
+ text: {},
7882
+ labelWidth: {},
7883
+ labelPosition: {}
6592
7884
  },
6593
7885
  emits: ["change"],
6594
7886
  setup(__props, { emit: __emit }) {
@@ -6635,7 +7927,10 @@
6635
7927
  disabled: { type: Boolean },
6636
7928
  size: {},
6637
7929
  lastValues: {},
6638
- isCompare: { type: Boolean }
7930
+ isCompare: { type: Boolean },
7931
+ text: {},
7932
+ labelWidth: {},
7933
+ labelPosition: {}
6639
7934
  },
6640
7935
  emits: ["change"],
6641
7936
  setup(__props, { emit: __emit }) {
@@ -6687,7 +7982,10 @@
6687
7982
  disabled: { type: Boolean },
6688
7983
  size: {},
6689
7984
  lastValues: {},
6690
- isCompare: { type: Boolean }
7985
+ isCompare: { type: Boolean },
7986
+ text: {},
7987
+ labelWidth: {},
7988
+ labelPosition: {}
6691
7989
  },
6692
7990
  emits: ["change"],
6693
7991
  setup(__props, { emit: __emit }) {
@@ -6732,7 +8030,10 @@
6732
8030
  disabled: { type: Boolean },
6733
8031
  size: {},
6734
8032
  lastValues: {},
6735
- isCompare: { type: Boolean }
8033
+ isCompare: { type: Boolean },
8034
+ text: {},
8035
+ labelWidth: {},
8036
+ labelPosition: {}
6736
8037
  },
6737
8038
  emits: ["change"],
6738
8039
  setup(__props, { emit: __emit }) {
@@ -6789,7 +8090,10 @@
6789
8090
  disabled: { type: Boolean },
6790
8091
  size: {},
6791
8092
  lastValues: {},
6792
- isCompare: { type: Boolean }
8093
+ isCompare: { type: Boolean },
8094
+ text: {},
8095
+ labelWidth: {},
8096
+ labelPosition: {}
6793
8097
  },
6794
8098
  emits: ["change"],
6795
8099
  setup(__props, { emit: __emit }) {
@@ -6844,7 +8148,10 @@
6844
8148
  disabled: { type: Boolean },
6845
8149
  size: {},
6846
8150
  lastValues: {},
6847
- isCompare: { type: Boolean }
8151
+ isCompare: { type: Boolean },
8152
+ text: {},
8153
+ labelWidth: {},
8154
+ labelPosition: {}
6848
8155
  },
6849
8156
  emits: ["change"],
6850
8157
  setup(__props, { emit: __emit }) {
@@ -6938,7 +8245,10 @@
6938
8245
  disabled: { type: Boolean },
6939
8246
  size: {},
6940
8247
  lastValues: {},
6941
- isCompare: { type: Boolean }
8248
+ isCompare: { type: Boolean },
8249
+ text: {},
8250
+ labelWidth: {},
8251
+ labelPosition: {}
6942
8252
  },
6943
8253
  emits: ["change"],
6944
8254
  setup(__props, { emit: __emit }) {
@@ -7032,7 +8342,10 @@
7032
8342
  disabled: { type: Boolean },
7033
8343
  size: {},
7034
8344
  lastValues: {},
7035
- isCompare: { type: Boolean }
8345
+ isCompare: { type: Boolean },
8346
+ text: {},
8347
+ labelWidth: {},
8348
+ labelPosition: {}
7036
8349
  },
7037
8350
  emits: ["change"],
7038
8351
  setup(__props, { emit: __emit }) {
@@ -7070,7 +8383,10 @@
7070
8383
  disabled: { type: Boolean },
7071
8384
  size: {},
7072
8385
  lastValues: {},
7073
- isCompare: { type: Boolean }
8386
+ isCompare: { type: Boolean },
8387
+ text: {},
8388
+ labelWidth: {},
8389
+ labelPosition: {}
7074
8390
  },
7075
8391
  emits: ["change"],
7076
8392
  setup(__props, { emit: __emit }) {
@@ -7115,7 +8431,11 @@
7115
8431
  });
7116
8432
  //#endregion
7117
8433
  //#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
7118
- var _hoisted_1$4 = { key: 1 };
8434
+ var _hoisted_1$4 = { class: "m-fields-radio-group__option" };
8435
+ var _hoisted_2$1 = {
8436
+ key: 1,
8437
+ class: "m-fields-radio-group__text"
8438
+ };
7119
8439
  //#endregion
7120
8440
  //#region packages/form/src/fields/RadioGroup.vue
7121
8441
  var RadioGroup_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -7131,7 +8451,10 @@
7131
8451
  disabled: { type: Boolean },
7132
8452
  size: {},
7133
8453
  lastValues: {},
7134
- isCompare: { type: Boolean }
8454
+ isCompare: { type: Boolean },
8455
+ text: {},
8456
+ labelWidth: {},
8457
+ labelPosition: {}
7135
8458
  },
7136
8459
  emits: ["change"],
7137
8460
  setup(__props, { emit: __emit }) {
@@ -7139,20 +8462,23 @@
7139
8462
  const itemComponent = (0, vue.computed)(() => props.config.childType === "button" ? _tmagic_design.TMagicRadioButton : _tmagic_design.TMagicRadio);
7140
8463
  const emit = __emit;
7141
8464
  const clickHandler = (item) => {
8465
+ if (props.disabled) return;
7142
8466
  emit("change", props.model[props.name] === item ? "" : item);
7143
8467
  };
7144
8468
  useAddField(props.prop);
7145
8469
  const iconSize = (0, vue.computed)(() => {
7146
- if (props.size === "small") return "12";
8470
+ if (props.config.iconSize) return props.config.iconSize;
8471
+ if (props.size === "small") return "14";
7147
8472
  if (props.size === "large") return "16";
7148
- return "14";
8473
+ return "16";
7149
8474
  });
7150
8475
  return (_ctx, _cache) => {
7151
8476
  return __props.model ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicRadioGroup), {
7152
8477
  key: 0,
7153
8478
  "model-value": __props.model[__props.name],
7154
8479
  size: __props.size,
7155
- disabled: __props.disabled
8480
+ disabled: __props.disabled,
8481
+ class: "icon-{{ iconSize }}"
7156
8482
  }, {
7157
8483
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(__props.config.options, (option) => {
7158
8484
  return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(itemComponent.value), {
@@ -7165,13 +8491,14 @@
7165
8491
  placement: "top-start",
7166
8492
  content: option.tooltip
7167
8493
  }, {
7168
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", null, [option.icon ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicIcon), {
8494
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$4, [option.icon ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicIcon), {
7169
8495
  key: 0,
7170
- size: iconSize.value
8496
+ size: iconSize.value,
8497
+ class: (0, vue.normalizeClass)({ "m-fields-radio-group__icon_with_text": !!option.text })
7171
8498
  }, {
7172
8499
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(option.icon)))]),
7173
8500
  _: 2
7174
- }, 1032, ["size"])) : (0, vue.createCommentVNode)("v-if", true), option.text ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$4, (0, vue.toDisplayString)(option.text), 1)) : (0, vue.createCommentVNode)("v-if", true)])]),
8501
+ }, 1032, ["size", "class"])) : (0, vue.createCommentVNode)("v-if", true), option.text ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_2$1, (0, vue.toDisplayString)(option.text), 1)) : (0, vue.createCommentVNode)("v-if", true)])]),
7175
8502
  _: 2
7176
8503
  }, 1032, ["disabled", "content"])]),
7177
8504
  _: 2
@@ -7204,7 +8531,10 @@
7204
8531
  disabled: { type: Boolean },
7205
8532
  size: {},
7206
8533
  lastValues: {},
7207
- isCompare: { type: Boolean }
8534
+ isCompare: { type: Boolean },
8535
+ text: {},
8536
+ labelWidth: {},
8537
+ labelPosition: {}
7208
8538
  },
7209
8539
  setup(__props) {
7210
8540
  const props = __props;
@@ -7223,8 +8553,9 @@
7223
8553
  //#endregion
7224
8554
  //#region packages/form/src/fields/Link.vue?vue&type=script&setup=true&lang.ts
7225
8555
  var _hoisted_1$2 = ["href"];
7226
- var _hoisted_2 = {
7227
- key: 2,
8556
+ var _hoisted_2 = ["href"];
8557
+ var _hoisted_3 = {
8558
+ key: 3,
7228
8559
  class: "m-fields-link"
7229
8560
  };
7230
8561
  //#endregion
@@ -7242,7 +8573,11 @@
7242
8573
  disabled: { type: Boolean },
7243
8574
  size: {},
7244
8575
  lastValues: {},
7245
- isCompare: { type: Boolean }
8576
+ isCompare: { type: Boolean },
8577
+ text: {},
8578
+ labelWidth: {},
8579
+ labelPosition: {},
8580
+ theme: {}
7246
8581
  },
7247
8582
  emits: ["change"],
7248
8583
  setup(__props, { emit: __emit }) {
@@ -7285,15 +8620,30 @@
7285
8620
  editor.value && (editor.value.dialogVisible = false);
7286
8621
  };
7287
8622
  return (_ctx, _cache) => {
7288
- return __props.config.href && !__props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
8623
+ return (0, vue.unref)(isGlobalFlat) && __props.config.href && !__props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
7289
8624
  key: 0,
7290
8625
  target: "_blank",
7291
8626
  href: href.value,
8627
+ class: "magic-admin-link",
7292
8628
  style: (0, vue.normalizeStyle)(__props.config.css || {})
7293
- }, (0, vue.toDisplayString)(displayText.value), 13, _hoisted_1$2)) : __props.config.href && __props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
8629
+ }, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
8630
+ link: "",
8631
+ type: "primary"
8632
+ }, {
8633
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), null, {
8634
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.Notebook))]),
8635
+ _: 1
8636
+ }), (0, vue.createTextVNode)((0, vue.toDisplayString)(displayText.value), 1)]),
8637
+ _: 1
8638
+ })], 12, _hoisted_1$2)) : __props.config.href && !__props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
7294
8639
  key: 1,
8640
+ target: "_blank",
8641
+ href: href.value,
8642
+ style: (0, vue.normalizeStyle)(__props.config.css || {})
8643
+ }, (0, vue.toDisplayString)(displayText.value), 13, _hoisted_2)) : __props.config.href && __props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
8644
+ key: 2,
7295
8645
  style: (0, vue.normalizeStyle)(__props.config.disabledCss || {})
7296
- }, (0, vue.toDisplayString)(displayText.value), 5)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_2, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
8646
+ }, (0, vue.toDisplayString)(displayText.value), 5)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_3, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
7297
8647
  link: "",
7298
8648
  type: "primary",
7299
8649
  onClick: editHandler
@@ -7339,7 +8689,10 @@
7339
8689
  disabled: { type: Boolean },
7340
8690
  size: {},
7341
8691
  lastValues: {},
7342
- isCompare: { type: Boolean }
8692
+ isCompare: { type: Boolean },
8693
+ text: {},
8694
+ labelWidth: {},
8695
+ labelPosition: {}
7343
8696
  },
7344
8697
  emits: ["change"],
7345
8698
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -7548,7 +8901,8 @@
7548
8901
  const v = props.model[props.name];
7549
8902
  if (Array.isArray(v) ? !v.length : typeof v === "undefined") return;
7550
8903
  if (typeof v === "undefined" || hasOption(v)) return;
7551
- setOptions(await getInitOption());
8904
+ const data = await getInitOption();
8905
+ setOptions(data);
7552
8906
  };
7553
8907
  (0, vue.watch)(() => props.model?.[props.name], () => {
7554
8908
  initOption();
@@ -7687,7 +9041,10 @@
7687
9041
  disabled: { type: Boolean },
7688
9042
  size: {},
7689
9043
  lastValues: {},
7690
- isCompare: { type: Boolean }
9044
+ isCompare: { type: Boolean },
9045
+ text: {},
9046
+ labelWidth: {},
9047
+ labelPosition: {}
7691
9048
  },
7692
9049
  emits: ["change"],
7693
9050
  setup(__props, { emit: __emit }) {
@@ -7807,7 +9164,10 @@
7807
9164
  disabled: { type: Boolean },
7808
9165
  size: {},
7809
9166
  lastValues: {},
7810
- isCompare: { type: Boolean }
9167
+ isCompare: { type: Boolean },
9168
+ text: {},
9169
+ labelWidth: {},
9170
+ labelPosition: {}
7811
9171
  },
7812
9172
  emits: ["change"],
7813
9173
  setup(__props, { emit: __emit }) {
@@ -7965,8 +9325,10 @@
7965
9325
  const option = Object.assign(defaultInstallOpt, opt);
7966
9326
  app.config.globalProperties.$MAGIC_FORM = option;
7967
9327
  setConfig(option);
9328
+ if (option.typeMatchRules) registerTypeMatchRules(option.typeMatchRules);
7968
9329
  app.component("m-form", Form_default);
7969
9330
  app.component("m-form-dialog", FormDialog_default);
9331
+ app.component("m-form-drawer", FormDrawer_default);
7970
9332
  app.component("m-form-container", Container_default);
7971
9333
  app.component("m-form-fieldset", Fieldset_default);
7972
9334
  app.component("m-form-group-list", TableGroupList_default);
@@ -8001,6 +9363,8 @@
8001
9363
  var createForm = (config) => config;
8002
9364
  //#endregion
8003
9365
  exports.FORM_DIFF_CONFIG_KEY = FORM_DIFF_CONFIG_KEY;
9366
+ exports.FORM_SILENT_MODE_KEY = FORM_SILENT_MODE_KEY;
9367
+ exports.FORM_TYPE_MATCH_VALID_KEY = FORM_TYPE_MATCH_VALID_KEY;
8004
9368
  exports.MCascader = Cascader_default;
8005
9369
  exports.MCheckbox = Checkbox_default;
8006
9370
  exports.MCheckboxGroup = CheckboxGroup_default;
@@ -8034,23 +9398,33 @@
8034
9398
  exports.MTextarea = Textarea_default;
8035
9399
  exports.MTime = Time_default;
8036
9400
  exports.MTimerange = Timerange_default;
9401
+ exports.adaptFormValidator = adaptFormValidator;
9402
+ exports.applyExtendState = applyExtendState;
9403
+ exports.clearTypeMatchRules = clearTypeMatchRules;
8037
9404
  exports.createForm = createForm;
8038
9405
  exports.createObjectProp = createObjectProp;
8039
9406
  exports.createValues = createValues;
8040
9407
  exports.datetimeFormatter = datetimeFormatter;
8041
9408
  exports.default = plugin_default;
8042
9409
  exports.deleteFormField = deleteField;
9410
+ exports.deleteTypeMatchRule = deleteTypeMatchRule;
8043
9411
  exports.display = display;
8044
9412
  exports.filterFunction = filterFunction;
8045
9413
  exports.getDataByPage = getDataByPage;
8046
9414
  exports.getFormField = getField;
8047
9415
  exports.getRules = getRules;
9416
+ exports.getTypeMatchRule = getTypeMatchRule;
8048
9417
  exports.initValue = initValue;
8049
9418
  exports.registerFormField = registerField;
9419
+ exports.registerTypeMatchRule = registerTypeMatchRule;
9420
+ exports.registerTypeMatchRules = registerTypeMatchRules;
8050
9421
  exports.sortArray = sortArray;
8051
9422
  exports.sortChange = sortChange;
9423
+ exports.stripTabItemsLazy = stripTabItemsLazy;
8052
9424
  exports.submitForm = submitForm;
8053
9425
  exports.useAddField = useAddField;
9426
+ exports.validateForm = validateForm;
9427
+ exports.validateTypeMatch = validateTypeMatch;
8054
9428
  var _tmagic_form_schema = require("@tmagic/form-schema");
8055
9429
  Object.keys(_tmagic_form_schema).forEach(function(k) {
8056
9430
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {