@tmagic/form 1.7.8-beta.1 → 1.7.8-beta.2

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.
@@ -140,12 +140,12 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
140
140
  for (const item of configs) {
141
141
  if (item.name === currentPart) {
142
142
  if (remainingParts.length === 0) return typeof item.text === "string" ? item.text : void 0;
143
- if (item.items && Array.isArray(item.items)) {
143
+ if ("items" in item && Array.isArray(item.items)) {
144
144
  const result = findInConfig(item.items, remainingParts);
145
145
  if (result !== void 0) return result;
146
146
  }
147
147
  }
148
- if (item.items && Array.isArray(item.items)) {
148
+ if ("items" in item && Array.isArray(item.items)) {
149
149
  const result = findInConfig(item.items, parts);
150
150
  if (result !== void 0) return result;
151
151
  }
@@ -68,7 +68,6 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
68
68
  });
69
69
  const tagName = computed(() => {
70
70
  if (type.value === "component" && props.config.component) return props.config.component;
71
- if (!getField(type.value || "container")) console.log(type.value, "type.value");
72
71
  return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
73
72
  });
74
73
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
@@ -2,6 +2,7 @@ import { useAddField } from "../utils/useAddField.js";
2
2
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
3
3
  import { TMagicIcon, TMagicRadio, TMagicRadioButton, TMagicRadioGroup, TMagicTooltip } from "@tmagic/design";
4
4
  //#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
5
+ var _hoisted_1 = { key: 1 };
5
6
  var RadioGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
6
7
  name: "MFormRadioGroup",
7
8
  __name: "RadioGroup",
@@ -55,7 +56,7 @@ var RadioGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
55
56
  }, {
56
57
  default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(option.icon)))]),
57
58
  _: 2
58
- }, 1032, ["size"])) : createCommentVNode("v-if", true), createElementVNode("span", null, toDisplayString(option.text), 1)])]),
59
+ }, 1032, ["size"])) : createCommentVNode("v-if", true), option.text ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(option.text), 1)) : createCommentVNode("v-if", true)])]),
59
60
  _: 2
60
61
  }, 1032, ["disabled", "content"])]),
61
62
  _: 2
@@ -56,9 +56,10 @@ var initValueItem = function(mForm, item, initValue, value) {
56
56
  if (!name) return createValues(mForm, items, initValue, value);
57
57
  setValue(mForm, value, initValue, item);
58
58
  if (type === "table") {
59
- if (item.defautSort) sortChange(value[name], item.defautSort);
60
- else if (item.defaultSort) sortChange(value[name], item.defaultSort);
61
- if (item.sort && item.sortKey) value[name].sort((a, b) => b[item.sortKey] - a[item.sortKey]);
59
+ const tableConfig = item;
60
+ if (tableConfig.defautSort) sortChange(value[name], tableConfig.defautSort);
61
+ else if (tableConfig.defaultSort) sortChange(value[name], tableConfig.defaultSort);
62
+ if (tableConfig.sort && tableConfig.sortKey) value[name].sort((a, b) => b[tableConfig.sortKey] - a[tableConfig.sortKey]);
62
63
  }
63
64
  return value;
64
65
  };
@@ -2669,9 +2669,10 @@
2669
2669
  if (!name) return createValues(mForm, items, initValue, value);
2670
2670
  setValue(mForm, value, initValue, item);
2671
2671
  if (type === "table") {
2672
- if (item.defautSort) sortChange(value[name], item.defautSort);
2673
- else if (item.defaultSort) sortChange(value[name], item.defaultSort);
2674
- if (item.sort && item.sortKey) value[name].sort((a, b) => b[item.sortKey] - a[item.sortKey]);
2672
+ const tableConfig = item;
2673
+ if (tableConfig.defautSort) sortChange(value[name], tableConfig.defautSort);
2674
+ else if (tableConfig.defaultSort) sortChange(value[name], tableConfig.defaultSort);
2675
+ if (tableConfig.sort && tableConfig.sortKey) value[name].sort((a, b) => b[tableConfig.sortKey] - a[tableConfig.sortKey]);
2675
2676
  }
2676
2677
  return value;
2677
2678
  };
@@ -2830,7 +2831,7 @@
2830
2831
  var deleteField = (tagName) => fieldRegistry.delete(tagName);
2831
2832
  //#endregion
2832
2833
  //#region packages/form/src/containers/FormLabel.vue?vue&type=script&setup=true&lang.ts
2833
- var _hoisted_1$14 = {
2834
+ var _hoisted_1$15 = {
2834
2835
  key: 0,
2835
2836
  style: {
2836
2837
  "display": "inline-flex",
@@ -2853,7 +2854,7 @@
2853
2854
  },
2854
2855
  setup(__props) {
2855
2856
  return (_ctx, _cache) => {
2856
- return __props.tip ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$14, [(0, vue.createElementVNode)("span", {
2857
+ return __props.tip ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$15, [(0, vue.createElementVNode)("span", {
2857
2858
  innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
2858
2859
  title: __props.labelTitle
2859
2860
  }, null, 8, _hoisted_2$8), __props.tip && (__props.type !== "checkbox" || __props.useLabel) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
@@ -2879,7 +2880,7 @@
2879
2880
  });
2880
2881
  //#endregion
2881
2882
  //#region packages/form/src/containers/Container.vue?vue&type=script&setup=true&lang.ts
2882
- var _hoisted_1$13 = ["data-tmagic-id", "data-tmagic-form-item-prop"];
2883
+ var _hoisted_1$14 = ["data-tmagic-id", "data-tmagic-form-item-prop"];
2883
2884
  var _hoisted_2$7 = ["innerHTML"];
2884
2885
  var _hoisted_3$6 = ["innerHTML"];
2885
2886
  var _hoisted_4$4 = ["innerHTML"];
@@ -2941,7 +2942,6 @@
2941
2942
  });
2942
2943
  const tagName = (0, vue.computed)(() => {
2943
2944
  if (type.value === "component" && props.config.component) return props.config.component;
2944
- if (!getField(type.value || "container")) console.log(type.value, "type.value");
2945
2945
  return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
2946
2946
  });
2947
2947
  const disabled = (0, vue.computed)(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
@@ -3304,7 +3304,7 @@
3304
3304
  }, {
3305
3305
  default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(expand.value ? "收起配置" : "展开更多配置"), 1)]),
3306
3306
  _: 1
3307
- })])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$13);
3307
+ })])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$14);
3308
3308
  };
3309
3309
  }
3310
3310
  });
@@ -3444,12 +3444,12 @@
3444
3444
  for (const item of configs) {
3445
3445
  if (item.name === currentPart) {
3446
3446
  if (remainingParts.length === 0) return typeof item.text === "string" ? item.text : void 0;
3447
- if (item.items && Array.isArray(item.items)) {
3447
+ if ("items" in item && Array.isArray(item.items)) {
3448
3448
  const result = findInConfig(item.items, remainingParts);
3449
3449
  if (result !== void 0) return result;
3450
3450
  }
3451
3451
  }
3452
- if (item.items && Array.isArray(item.items)) {
3452
+ if ("items" in item && Array.isArray(item.items)) {
3453
3453
  const result = findInConfig(item.items, parts);
3454
3454
  if (result !== void 0) return result;
3455
3455
  }
@@ -3536,7 +3536,7 @@
3536
3536
  });
3537
3537
  //#endregion
3538
3538
  //#region packages/form/src/FormDialog.vue?vue&type=script&setup=true&lang.ts
3539
- var _hoisted_1$12 = { style: { "min-height": "1px" } };
3539
+ var _hoisted_1$13 = { style: { "min-height": "1px" } };
3540
3540
  //#endregion
3541
3541
  //#region packages/form/src/FormDialog.vue
3542
3542
  var FormDialog_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -3663,7 +3663,7 @@
3663
3663
  span: 12,
3664
3664
  style: { "text-align": "left" }
3665
3665
  }, {
3666
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$12, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
3666
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$13, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
3667
3667
  _: 3
3668
3668
  }), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicCol), { span: 12 }, {
3669
3669
  default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "footer", {}, () => [
@@ -3756,7 +3756,7 @@
3756
3756
  });
3757
3757
  //#endregion
3758
3758
  //#region packages/form/src/FormDrawer.vue?vue&type=script&setup=true&lang.ts
3759
- var _hoisted_1$11 = { style: { "min-height": "1px" } };
3759
+ var _hoisted_1$12 = { style: { "min-height": "1px" } };
3760
3760
  //#endregion
3761
3761
  //#region packages/form/src/FormDrawer.vue
3762
3762
  var FormDrawer_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -3868,7 +3868,7 @@
3868
3868
  span: 12,
3869
3869
  style: { "text-align": "left" }
3870
3870
  }, {
3871
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$11, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
3871
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$12, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
3872
3872
  _: 3
3873
3873
  }), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicCol), { span: 12 }, {
3874
3874
  default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "footer", {}, () => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), { onClick: handleClose }, {
@@ -4045,7 +4045,7 @@
4045
4045
  });
4046
4046
  //#endregion
4047
4047
  //#region packages/form/src/containers/Fieldset.vue?vue&type=script&setup=true&lang.ts
4048
- var _hoisted_1$10 = ["innerHTML"];
4048
+ var _hoisted_1$11 = ["innerHTML"];
4049
4049
  var _hoisted_2$6 = ["innerHTML"];
4050
4050
  var _hoisted_3$5 = { key: 1 };
4051
4051
  var _hoisted_4$3 = ["innerHTML"];
@@ -4120,7 +4120,7 @@
4120
4120
  "false-value": checkboxFalseValue.value,
4121
4121
  "onUpdate:modelValue": valueChangeHandler
4122
4122
  }, {
4123
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: __props.config.legend }, null, 8, _hoisted_1$10), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
4123
+ 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", {
4124
4124
  key: 0,
4125
4125
  innerHTML: __props.config.extra,
4126
4126
  class: "m-form-tip"
@@ -4257,7 +4257,7 @@
4257
4257
  });
4258
4258
  //#endregion
4259
4259
  //#region packages/form/src/containers/Panel.vue?vue&type=script&setup=true&lang.ts
4260
- var _hoisted_1$9 = { style: {
4260
+ var _hoisted_1$10 = { style: {
4261
4261
  "width": "100%",
4262
4262
  "display": "flex",
4263
4263
  "align-items": "center"
@@ -4309,7 +4309,7 @@
4309
4309
  class: "box-card m-form-panel",
4310
4310
  "body-style": { display: expand.value ? "block" : "none" }
4311
4311
  }, {
4312
- header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$9, [
4312
+ header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$10, [
4313
4313
  (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
4314
4314
  style: { "padding": "0" },
4315
4315
  link: "",
@@ -5230,7 +5230,7 @@
5230
5230
  };
5231
5231
  //#endregion
5232
5232
  //#region packages/form/src/table/Table.vue?vue&type=script&setup=true&lang.ts
5233
- var _hoisted_1$8 = ["innerHTML"];
5233
+ var _hoisted_1$9 = ["innerHTML"];
5234
5234
  var _hoisted_2$4 = { style: {
5235
5235
  "display": "flex",
5236
5236
  "justify-content": "space-between",
@@ -5330,7 +5330,7 @@
5330
5330
  key: 0,
5331
5331
  style: { "color": "rgba(0, 0, 0, 0.45)" },
5332
5332
  innerHTML: __props.config.extra
5333
- }, null, 8, _hoisted_1$8)) : (0, vue.createCommentVNode)("v-if", true),
5333
+ }, null, 8, _hoisted_1$9)) : (0, vue.createCommentVNode)("v-if", true),
5334
5334
  (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
5335
5335
  content: "拖拽可排序",
5336
5336
  placement: "left-start",
@@ -5452,7 +5452,7 @@
5452
5452
  });
5453
5453
  //#endregion
5454
5454
  //#region packages/form/src/containers/GroupListItem.vue?vue&type=script&setup=true&lang.ts
5455
- var _hoisted_1$7 = ["innerHTML"];
5455
+ var _hoisted_1$8 = ["innerHTML"];
5456
5456
  var _hoisted_2$3 = { style: {
5457
5457
  "text-align": "right",
5458
5458
  "margin-top": "20px"
@@ -5546,7 +5546,7 @@
5546
5546
  default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), null, {
5547
5547
  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 }))]),
5548
5548
  _: 1
5549
- }), (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_1$7)]),
5549
+ }), (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_1$8)]),
5550
5550
  _: 1
5551
5551
  }, 8, ["disabled"]),
5552
5552
  (0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
@@ -5669,7 +5669,7 @@
5669
5669
  });
5670
5670
  //#endregion
5671
5671
  //#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
5672
- var _hoisted_1$6 = { class: "m-fields-group-list" };
5672
+ var _hoisted_1$7 = { class: "m-fields-group-list" };
5673
5673
  var _hoisted_2$2 = ["innerHTML"];
5674
5674
  var _hoisted_3$1 = {
5675
5675
  key: 1,
@@ -5762,7 +5762,7 @@
5762
5762
  const onAddDiffCount = () => emit("addDiffCount");
5763
5763
  const getLastValues = (item, index) => item?.[index] || {};
5764
5764
  return (_ctx, _cache) => {
5765
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6, [
5765
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$7, [
5766
5766
  __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
5767
5767
  key: 0,
5768
5768
  innerHTML: __props.config.extra,
@@ -5828,7 +5828,7 @@
5828
5828
  });
5829
5829
  //#endregion
5830
5830
  //#region packages/form/src/fields/Text.vue?vue&type=script&setup=true&lang.ts
5831
- var _hoisted_1$5 = { class: "m-fields-text" };
5831
+ var _hoisted_1$6 = { class: "m-fields-text" };
5832
5832
  var _hoisted_2$1 = { key: 1 };
5833
5833
  var _hoisted_3 = { style: {
5834
5834
  "display": "flex",
@@ -5972,7 +5972,7 @@
5972
5972
  instanceRef.value = void 0;
5973
5973
  };
5974
5974
  return (_ctx, _cache) => {
5975
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$5, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
5975
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
5976
5976
  modelValue: value.value,
5977
5977
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
5978
5978
  ref_key: "input",
@@ -6099,7 +6099,7 @@
6099
6099
  });
6100
6100
  //#endregion
6101
6101
  //#region packages/form/src/fields/NumberRange.vue?vue&type=script&setup=true&lang.ts
6102
- var _hoisted_1$4 = { class: "m-fields-number-range" };
6102
+ var _hoisted_1$5 = { class: "m-fields-number-range" };
6103
6103
  //#endregion
6104
6104
  //#region packages/form/src/fields/NumberRange.vue
6105
6105
  var NumberRange_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -6139,7 +6139,7 @@
6139
6139
  emit("change", [props.model[props.name][0], Number(v)]);
6140
6140
  };
6141
6141
  return (_ctx, _cache) => {
6142
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$4, [
6142
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$5, [
6143
6143
  (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
6144
6144
  modelValue: firstValue.value,
6145
6145
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => firstValue.value = $event),
@@ -6768,6 +6768,9 @@
6768
6768
  }
6769
6769
  });
6770
6770
  //#endregion
6771
+ //#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
6772
+ var _hoisted_1$4 = { key: 1 };
6773
+ //#endregion
6771
6774
  //#region packages/form/src/fields/RadioGroup.vue
6772
6775
  var RadioGroup_default = /* @__PURE__ */ (0, vue.defineComponent)({
6773
6776
  name: "MFormRadioGroup",
@@ -6822,7 +6825,7 @@
6822
6825
  }, {
6823
6826
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(option.icon)))]),
6824
6827
  _: 2
6825
- }, 1032, ["size"])) : (0, vue.createCommentVNode)("v-if", true), (0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(option.text), 1)])]),
6828
+ }, 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)])]),
6826
6829
  _: 2
6827
6830
  }, 1032, ["disabled", "content"])]),
6828
6831
  _: 2
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.8-beta.1",
2
+ "version": "1.7.8-beta.2",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -52,9 +52,9 @@
52
52
  "peerDependencies": {
53
53
  "vue": "^3.5.24",
54
54
  "typescript": "^5.9.3",
55
- "@tmagic/utils": "1.7.8-beta.1",
56
- "@tmagic/form-schema": "1.7.8-beta.1",
57
- "@tmagic/design": "1.7.8-beta.1"
55
+ "@tmagic/design": "1.7.8-beta.2",
56
+ "@tmagic/utils": "1.7.8-beta.2",
57
+ "@tmagic/form-schema": "1.7.8-beta.2"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "typescript": {
package/src/Form.vue CHANGED
@@ -218,13 +218,13 @@ const getTextByName = (name: string, config: FormConfig = props.config): string
218
218
  return typeof item.text === 'string' ? item.text : undefined;
219
219
  }
220
220
 
221
- if (item.items && Array.isArray(item.items)) {
221
+ if ('items' in item && Array.isArray(item.items)) {
222
222
  const result = findInConfig(item.items, remainingParts);
223
223
  if (result !== undefined) return result;
224
224
  }
225
225
  }
226
226
 
227
- if (item.items && Array.isArray(item.items)) {
227
+ if ('items' in item && Array.isArray(item.items)) {
228
228
  const result = findInConfig(item.items, parts);
229
229
  if (result !== undefined) return result;
230
230
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div
3
- :data-tmagic-id="config.id"
3
+ :data-tmagic-id="(config as Record<string, any>).id"
4
4
  :data-tmagic-form-item-prop="itemProp"
5
5
  :class="`m-form-container m-container-${type || ''} ${config.className || ''}${config.tip ? ' has-tip' : ''}`"
6
6
  :style="config.style"
@@ -28,7 +28,7 @@
28
28
  <FormLabel
29
29
  :tip="config.tip"
30
30
  :type="type"
31
- :use-label="config.useLabel"
31
+ :use-label="(config as CheckboxConfig).useLabel"
32
32
  :label-title="config.labelTitle"
33
33
  :text="text"
34
34
  ></FormLabel>
@@ -61,7 +61,7 @@
61
61
  ></component>
62
62
  </TMagicFormItem>
63
63
 
64
- <TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
64
+ <TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
65
65
  <TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
66
66
  <template #content>
67
67
  <div v-html="config.tip"></div>
@@ -80,7 +80,7 @@
80
80
  <FormLabel
81
81
  :tip="config.tip"
82
82
  :type="type"
83
- :use-label="config.useLabel"
83
+ :use-label="(config as CheckboxConfig).useLabel"
84
84
  :label-title="config.labelTitle"
85
85
  :text="text"
86
86
  ></FormLabel>
@@ -95,7 +95,7 @@
95
95
  <component v-else v-bind="fieldsProps" :is="tagName" :model="lastValues" @change="onChangeHandler"></component>
96
96
  </TMagicFormItem>
97
97
 
98
- <TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
98
+ <TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
99
99
  <TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
100
100
  <template #content>
101
101
  <div v-html="config.tip"></div>
@@ -112,7 +112,7 @@
112
112
  <FormLabel
113
113
  :tip="config.tip"
114
114
  :type="type"
115
- :use-label="config.useLabel"
115
+ :use-label="(config as CheckboxConfig).useLabel"
116
116
  :label-title="config.labelTitle"
117
117
  :text="text"
118
118
  ></FormLabel>
@@ -127,7 +127,7 @@
127
127
  <component v-else v-bind="fieldsProps" :is="tagName" :model="model" @change="onChangeHandler"></component>
128
128
  </TMagicFormItem>
129
129
 
130
- <TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
130
+ <TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
131
131
  <TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
132
132
  <template #content>
133
133
  <div v-html="config.tip"></div>
@@ -174,7 +174,9 @@ import { getValueByKeyPath } from '@tmagic/utils';
174
174
 
175
175
  import MHidden from '../fields/Hidden.vue';
176
176
  import type {
177
+ CheckboxConfig,
177
178
  ChildConfig,
179
+ ComponentConfig,
178
180
  ContainerChangeEventData,
179
181
  ContainerCommonConfig,
180
182
  FormState,
@@ -259,13 +261,10 @@ const type = computed((): string => {
259
261
  });
260
262
 
261
263
  const tagName = computed(() => {
262
- if (type.value === 'component' && props.config.component) {
263
- return props.config.component;
264
+ if (type.value === 'component' && (props.config as ComponentConfig).component) {
265
+ return (props.config as ComponentConfig).component;
264
266
  }
265
267
 
266
- if (!getField(type.value || 'container')) {
267
- console.log(type.value, 'type.value');
268
- }
269
268
  return getField(type.value || 'container') || `m-${items.value ? 'form' : 'fields'}-${type.value}`;
270
269
  });
271
270
 
@@ -305,7 +304,7 @@ const fieldsProps = computed(() => ({
305
304
  name: name.value,
306
305
  disabled: disabled.value,
307
306
  prop: itemProp.value,
308
- key: props.config[mForm?.keyProps],
307
+ key: (props.config as Record<string, any>)[mForm?.keyProps],
309
308
  style: props.config.fieldStyle,
310
309
  }));
311
310
 
@@ -144,7 +144,9 @@ const rowConfig = computed(() => ({
144
144
  span: props.config.span || 24,
145
145
  items: props.config.items,
146
146
  labelWidth: props.config.labelWidth,
147
- [mForm?.keyProp || '__key']: `${props.config[mForm?.keyProp || '__key']}${String(props.index)}`,
147
+ [mForm?.keyProp || '__key']: `${(props.config as Record<string, any>)[mForm?.keyProp || '__key']}${String(
148
+ props.index,
149
+ )}`,
148
150
  }));
149
151
 
150
152
  const title = computed(() => {
@@ -10,7 +10,7 @@
10
10
  <TMagicTooltip :disabled="!Boolean(option.tooltip)" placement="top-start" :content="option.tooltip">
11
11
  <div>
12
12
  <TMagicIcon v-if="option.icon" :size="iconSize"><component :is="option.icon"></component></TMagicIcon>
13
- <span>{{ option.text }}</span>
13
+ <span v-if="option.text">{{ option.text }}</span>
14
14
  </div>
15
15
  </TMagicTooltip>
16
16
  </component>
@@ -21,7 +21,7 @@ import dayjs from 'dayjs';
21
21
 
22
22
  import { TMagicTimePicker } from '@tmagic/design';
23
23
 
24
- import type { ChangeRecord, DaterangeConfig, FieldProps } from '../schema';
24
+ import type { ChangeRecord, FieldProps, TimerangeConfig } from '../schema';
25
25
  import { datetimeFormatter } from '../utils/form';
26
26
  import { useAddField } from '../utils/useAddField';
27
27
 
@@ -29,7 +29,7 @@ defineOptions({
29
29
  name: 'MFormTimeRange',
30
30
  });
31
31
 
32
- const props = defineProps<FieldProps<DaterangeConfig>>();
32
+ const props = defineProps<FieldProps<TimerangeConfig>>();
33
33
 
34
34
  const emit = defineEmits(['change']);
35
35
 
package/src/utils/form.ts CHANGED
@@ -29,11 +29,13 @@ import {
29
29
  DaterangeConfig,
30
30
  FilterFunction,
31
31
  FormConfig,
32
+ FormItem,
32
33
  FormState,
33
34
  FormValue,
34
35
  HtmlField,
35
36
  Rule,
36
37
  SortProp,
38
+ TableConfig,
37
39
  TabPaneConfig,
38
40
  TypeFunction,
39
41
  } from '../schema';
@@ -118,7 +120,7 @@ const initValueItem = function (
118
120
  ) {
119
121
  const { items } = item as ContainerCommonConfig;
120
122
  const { names } = item as DaterangeConfig;
121
- const { type, name } = item as ChildConfig;
123
+ const { type, name } = item as FormItem;
122
124
 
123
125
  if (isTableSelect(type) && name) {
124
126
  value[name] = initValue[name] ?? '';
@@ -148,14 +150,15 @@ const initValueItem = function (
148
150
  setValue(mForm, value, initValue, item);
149
151
 
150
152
  if (type === 'table') {
151
- if (item.defautSort) {
152
- sortChange(value[name], item.defautSort);
153
- } else if (item.defaultSort) {
154
- sortChange(value[name], item.defaultSort);
153
+ const tableConfig = item as TableConfig;
154
+ if (tableConfig.defautSort) {
155
+ sortChange(value[name], tableConfig.defautSort);
156
+ } else if (tableConfig.defaultSort) {
157
+ sortChange(value[name], tableConfig.defaultSort);
155
158
  }
156
159
 
157
- if (item.sort && item.sortKey) {
158
- value[name].sort((a: any, b: any) => b[item.sortKey] - a[item.sortKey]);
160
+ if (tableConfig.sort && tableConfig.sortKey) {
161
+ value[name].sort((a: any, b: any) => b[tableConfig.sortKey!] - a[tableConfig.sortKey!]);
159
162
  }
160
163
  }
161
164
 
package/types/index.d.ts CHANGED
@@ -95,13 +95,13 @@ declare const __VLS_export$31: _vue_runtime_core0.DefineComponent<__VLS_Props$30
95
95
  inline: boolean;
96
96
  labelPosition: string;
97
97
  config: schema_d_exports.FormConfig;
98
- height: string;
99
98
  initValues: Record<string, any>;
100
99
  lastValues: Record<string, any>;
101
100
  isCompare: boolean;
102
101
  keyProp: string;
103
102
  parentValues: Record<string, any>;
104
103
  stepActive: string | number;
104
+ height: string;
105
105
  }, {}, {}, {}, string, _vue_runtime_core0.ComponentProvideOptions, false, {}, any>;
106
106
  declare const _default$12: typeof __VLS_export$31;
107
107
  //#endregion
@@ -181,13 +181,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
181
181
  inline: boolean;
182
182
  labelPosition: string;
183
183
  config: schema_d_exports.FormConfig;
184
- height: string;
185
184
  initValues: Record<string, any>;
186
185
  lastValues: Record<string, any>;
187
186
  isCompare: boolean;
188
187
  keyProp: string;
189
188
  parentValues: Record<string, any>;
190
189
  stepActive: string | number;
190
+ height: string;
191
191
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
192
192
  P: {};
193
193
  B: {};
@@ -234,13 +234,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
234
234
  inline: boolean;
235
235
  labelPosition: string;
236
236
  config: schema_d_exports.FormConfig;
237
- height: string;
238
237
  initValues: Record<string, any>;
239
238
  lastValues: Record<string, any>;
240
239
  isCompare: boolean;
241
240
  keyProp: string;
242
241
  parentValues: Record<string, any>;
243
242
  stepActive: string | number;
243
+ height: string;
244
244
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
245
245
  config: schema_d_exports.FormConfig;
246
246
  initValues: Record<string, any>;
@@ -286,13 +286,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
286
286
  inline: boolean;
287
287
  labelPosition: string;
288
288
  config: schema_d_exports.FormConfig;
289
- height: string;
290
289
  initValues: Record<string, any>;
291
290
  lastValues: Record<string, any>;
292
291
  isCompare: boolean;
293
292
  keyProp: string;
294
293
  parentValues: Record<string, any>;
295
294
  stepActive: string | number;
295
+ height: string;
296
296
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
297
297
  P: {};
298
298
  B: {};
@@ -339,13 +339,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
339
339
  inline: boolean;
340
340
  labelPosition: string;
341
341
  config: schema_d_exports.FormConfig;
342
- height: string;
343
342
  initValues: Record<string, any>;
344
343
  lastValues: Record<string, any>;
345
344
  isCompare: boolean;
346
345
  keyProp: string;
347
346
  parentValues: Record<string, any>;
348
347
  stepActive: string | number;
348
+ height: string;
349
349
  }> | undefined>;
350
350
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
351
351
  dialogVisible: _vue_reactivity0.Ref<boolean, boolean>;
@@ -453,13 +453,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
453
453
  inline: boolean;
454
454
  labelPosition: string;
455
455
  config: schema_d_exports.FormConfig;
456
- height: string;
457
456
  initValues: Record<string, any>;
458
457
  lastValues: Record<string, any>;
459
458
  isCompare: boolean;
460
459
  keyProp: string;
461
460
  parentValues: Record<string, any>;
462
461
  stepActive: string | number;
462
+ height: string;
463
463
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
464
464
  P: {};
465
465
  B: {};
@@ -506,13 +506,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
506
506
  inline: boolean;
507
507
  labelPosition: string;
508
508
  config: schema_d_exports.FormConfig;
509
- height: string;
510
509
  initValues: Record<string, any>;
511
510
  lastValues: Record<string, any>;
512
511
  isCompare: boolean;
513
512
  keyProp: string;
514
513
  parentValues: Record<string, any>;
515
514
  stepActive: string | number;
515
+ height: string;
516
516
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
517
517
  config: schema_d_exports.FormConfig;
518
518
  initValues: Record<string, any>;
@@ -558,13 +558,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
558
558
  inline: boolean;
559
559
  labelPosition: string;
560
560
  config: schema_d_exports.FormConfig;
561
- height: string;
562
561
  initValues: Record<string, any>;
563
562
  lastValues: Record<string, any>;
564
563
  isCompare: boolean;
565
564
  keyProp: string;
566
565
  parentValues: Record<string, any>;
567
566
  stepActive: string | number;
567
+ height: string;
568
568
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
569
569
  P: {};
570
570
  B: {};
@@ -611,13 +611,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
611
611
  inline: boolean;
612
612
  labelPosition: string;
613
613
  config: schema_d_exports.FormConfig;
614
- height: string;
615
614
  initValues: Record<string, any>;
616
615
  lastValues: Record<string, any>;
617
616
  isCompare: boolean;
618
617
  keyProp: string;
619
618
  parentValues: Record<string, any>;
620
619
  stepActive: string | number;
620
+ height: string;
621
621
  }> | undefined>;
622
622
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
623
623
  bodyHeight: _vue_reactivity0.Ref<number, number>;
@@ -723,13 +723,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
723
723
  inline: boolean;
724
724
  labelPosition: string;
725
725
  config: schema_d_exports.FormConfig;
726
- height: string;
727
726
  initValues: Record<string, any>;
728
727
  lastValues: Record<string, any>;
729
728
  isCompare: boolean;
730
729
  keyProp: string;
731
730
  parentValues: Record<string, any>;
732
731
  stepActive: string | number;
732
+ height: string;
733
733
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
734
734
  P: {};
735
735
  B: {};
@@ -776,13 +776,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
776
776
  inline: boolean;
777
777
  labelPosition: string;
778
778
  config: schema_d_exports.FormConfig;
779
- height: string;
780
779
  initValues: Record<string, any>;
781
780
  lastValues: Record<string, any>;
782
781
  isCompare: boolean;
783
782
  keyProp: string;
784
783
  parentValues: Record<string, any>;
785
784
  stepActive: string | number;
785
+ height: string;
786
786
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
787
787
  config: schema_d_exports.FormConfig;
788
788
  initValues: Record<string, any>;
@@ -828,13 +828,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
828
828
  inline: boolean;
829
829
  labelPosition: string;
830
830
  config: schema_d_exports.FormConfig;
831
- height: string;
832
831
  initValues: Record<string, any>;
833
832
  lastValues: Record<string, any>;
834
833
  isCompare: boolean;
835
834
  keyProp: string;
836
835
  parentValues: Record<string, any>;
837
836
  stepActive: string | number;
837
+ height: string;
838
838
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
839
839
  P: {};
840
840
  B: {};
@@ -881,13 +881,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
881
881
  inline: boolean;
882
882
  labelPosition: string;
883
883
  config: schema_d_exports.FormConfig;
884
- height: string;
885
884
  initValues: Record<string, any>;
886
885
  lastValues: Record<string, any>;
887
886
  isCompare: boolean;
888
887
  keyProp: string;
889
888
  parentValues: Record<string, any>;
890
889
  stepActive: string | number;
890
+ height: string;
891
891
  }> | undefined>;
892
892
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
893
893
  show: () => void;
@@ -1248,7 +1248,7 @@ declare const __VLS_export$9: _vue_runtime_core0.DefineComponent<__VLS_Props$9,
1248
1248
  declare const _default$7: typeof __VLS_export$9;
1249
1249
  //#endregion
1250
1250
  //#region temp/packages/form/src/fields/Timerange.vue.d.ts
1251
- type __VLS_Props$8 = schema_d_exports.FieldProps<schema_d_exports.DaterangeConfig>;
1251
+ type __VLS_Props$8 = schema_d_exports.FieldProps<schema_d_exports.TimerangeConfig>;
1252
1252
  declare const __VLS_export$8: _vue_runtime_core0.DefineComponent<__VLS_Props$8, {}, {}, {}, {}, _vue_runtime_core0.ComponentOptionsMixin, _vue_runtime_core0.ComponentOptionsMixin, {
1253
1253
  change: (...args: any[]) => void;
1254
1254
  }, string, _vue_runtime_core0.PublicProps, Readonly<__VLS_Props$8> & Readonly<{