@tmagic/form 1.5.12 → 1.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, shallowRef, withModifiers, onBeforeMount, nextTick, resolveDirective, createSlots } from 'vue';
1
+ import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, createElementBlock, createCommentVNode, openBlock, normalizeClass, normalizeStyle, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, shallowRef, withModifiers, onBeforeMount, nextTick, resolveDirective, createSlots } from 'vue';
2
2
  import { WarningFilled, CaretBottom, CaretRight, Delete, DocumentCopy, CaretTop, Position, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
3
3
  import { cloneDeep, isEqual, isEmpty, debounce } from 'lodash-es';
4
4
  import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicPopover, TMagicInputNumber, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, tMagicMessageBox, TMagicDialog, TMagicRadioButton, TMagicRadio, TMagicRadioGroup, TMagicSelect, TMagicSwitch, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
5
+ import { setValueByKeyPath, asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
5
6
  import dayjs from 'dayjs';
6
7
  import utc from 'dayjs/plugin/utc';
7
8
  import Sortable from 'sortablejs';
8
- import { asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
9
9
  import { createPopper } from '@popperjs/core';
10
10
 
11
11
  const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
@@ -83,7 +83,7 @@ const getDefaultValue = function(mForm, { defaultValue, type, filter, multiple }
83
83
  return defaultValue(mForm);
84
84
  }
85
85
  if (defaultValue === "undefined") {
86
- return undefined;
86
+ return void 0;
87
87
  }
88
88
  if (typeof defaultValue !== "undefined") {
89
89
  return defaultValue;
@@ -342,7 +342,13 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
342
342
  formValue: mForm?.values,
343
343
  prop: itemProp.value,
344
344
  config: props.config,
345
- changeRecords: newChangeRecords
345
+ changeRecords: newChangeRecords,
346
+ setModel: (key2, value2) => {
347
+ setValueByKeyPath(key2, value2, props.model);
348
+ if (props.config.name) {
349
+ newChangeRecords.push({ propPath: itemProp.value.replace(`${props.config.name}`, key2), value: value2 });
350
+ }
351
+ }
346
352
  }) ?? value;
347
353
  }
348
354
  value = trimHandler(trim, value) ?? value;
@@ -742,7 +748,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
742
748
  if (props.config.items) {
743
749
  return props.config.labelWidth || props.labelWidth;
744
750
  }
745
- return props.config.labelWidth || props.labelWidth || (props.config.text ? undefined : "0");
751
+ return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
746
752
  });
747
753
  const valueChangeHandler = (value) => {
748
754
  emit("change", value, { modifyKey: "value" });
@@ -918,7 +924,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
918
924
  const changeOrder = (offset = 0) => emit("swap-item", props.index, props.index + offset);
919
925
  const movable = computed(() => {
920
926
  const { movable: movable2 } = props.config;
921
- if (movable2 === undefined) return true;
927
+ if (movable2 === void 0) return true;
922
928
  if (typeof movable2 === "function") {
923
929
  return movable2(mForm, props.index || 0, props.model, props.groupModel);
924
930
  }
@@ -1672,15 +1678,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1672
1678
  const updateKey = ref(1);
1673
1679
  const isFullscreen = ref(false);
1674
1680
  const modelName = computed(() => props.name || props.config.name || "");
1675
- const data = computed(
1676
- () => props.config.pagination ? (props.model[modelName.value] || []).filter(
1677
- (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1678
- ) : props.model[modelName.value]
1681
+ const getDataByPage = (data2 = []) => data2.filter(
1682
+ (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1679
1683
  );
1684
+ const pageinationData = computed(() => getDataByPage(props.model[modelName.value]));
1685
+ const data = computed(() => props.config.pagination ? pageinationData.value : props.model[modelName.value]);
1680
1686
  const lastData = computed(
1681
- () => props.config.pagination ? (props.lastValues[modelName.value] || []).filter(
1682
- (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1683
- ) : props.lastValues[modelName.value] || []
1687
+ () => props.config.pagination ? getDataByPage(props.lastValues[modelName.value]) : props.lastValues[modelName.value] || []
1684
1688
  );
1685
1689
  const sortChange = ({ prop, order }) => {
1686
1690
  if (order === "ascending") {
@@ -1708,6 +1712,10 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1708
1712
  }
1709
1713
  sortable = Sortable.create(tBodyEl, {
1710
1714
  draggable: ".tmagic-design-table-row",
1715
+ filter: "input",
1716
+ // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
1717
+ preventOnFilter: false,
1718
+ // 允许选字
1711
1719
  direction: "vertical",
1712
1720
  onEnd: ({ newIndex, oldIndex }) => {
1713
1721
  if (typeof newIndex === "undefined") return;
@@ -1872,7 +1880,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1872
1880
  }
1873
1881
  timer = setTimeout(() => {
1874
1882
  swapArray(index, index - 1);
1875
- timer = undefined;
1883
+ timer = void 0;
1876
1884
  }, 300);
1877
1885
  };
1878
1886
  const topHandler = (index) => {
@@ -1891,7 +1899,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1891
1899
  }
1892
1900
  timer = setTimeout(() => {
1893
1901
  swapArray(index, index + 1);
1894
- timer = undefined;
1902
+ timer = void 0;
1895
1903
  }, 300);
1896
1904
  };
1897
1905
  const bottomHandler = (index) => {
@@ -2068,7 +2076,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
2068
2076
  label: "操作",
2069
2077
  width: _ctx.config.operateColWidth || 100,
2070
2078
  align: "center",
2071
- fixed: _ctx.config.fixed === false ? undefined : "left"
2079
+ fixed: _ctx.config.fixed === false ? void 0 : "left"
2072
2080
  }, {
2073
2081
  default: withCtx((scope) => [
2074
2082
  renderSlot(_ctx.$slots, "operateCol", { scope }),
@@ -2727,7 +2735,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2727
2735
  } else {
2728
2736
  return props.config.activeValue;
2729
2737
  }
2730
- return undefined;
2738
+ return void 0;
2731
2739
  });
2732
2740
  const inactiveValue = computed(() => {
2733
2741
  if (typeof props.config.inactiveValue === "undefined") {
@@ -2737,7 +2745,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2737
2745
  } else {
2738
2746
  return props.config.inactiveValue;
2739
2747
  }
2740
- return undefined;
2748
+ return void 0;
2741
2749
  });
2742
2750
  const changeHandler = (value) => {
2743
2751
  emit("change", value);
@@ -2939,7 +2947,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2939
2947
  useAddField(props.prop);
2940
2948
  const { names } = props.config;
2941
2949
  const value = ref([]);
2942
- if (props.model !== undefined) {
2950
+ if (props.model !== void 0) {
2943
2951
  if (names?.length) {
2944
2952
  watch(
2945
2953
  [() => props.model[names[0]], () => props.model[names[1]]],
@@ -2963,7 +2971,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2963
2971
  const format = `${props.config.dateFormat || "YYYY/MM/DD"} ${props.config.timeFormat || "HH:mm:ss"}`;
2964
2972
  if (start !== preStart)
2965
2973
  value.value = start.map(
2966
- (item) => item ? datetimeFormatter(item, "", format) : undefined
2974
+ (item) => item ? datetimeFormatter(item, "", format) : void 0
2967
2975
  );
2968
2976
  },
2969
2977
  {
@@ -2980,7 +2988,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2980
2988
  if (Array.isArray(v)) {
2981
2989
  props.model[item] = v[index];
2982
2990
  } else {
2983
- props.model[item] = undefined;
2991
+ props.model[item] = void 0;
2984
2992
  }
2985
2993
  });
2986
2994
  };
@@ -3140,9 +3148,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3140
3148
  fieldMap.value = {};
3141
3149
  fieldLabelMap.value = {};
3142
3150
  fields.forEach((v) => {
3143
- if (typeof v !== "object" || v.name === undefined) return;
3151
+ if (typeof v !== "object" || v.name === void 0) return;
3144
3152
  let oldVal = props.model?.[v.name] || "";
3145
- if (!oldVal && v.defaultValue !== undefined) {
3153
+ if (!oldVal && v.defaultValue !== void 0) {
3146
3154
  oldVal = v.defaultValue;
3147
3155
  emit("change", oldVal, { modifyKey: v.name });
3148
3156
  }
@@ -4520,7 +4528,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4520
4528
  return {
4521
4529
  text: props.config.append,
4522
4530
  type: "button",
4523
- handler: undefined
4531
+ handler: void 0
4524
4532
  };
4525
4533
  }
4526
4534
  if (props.config.append && typeof props.config.append === "object") {
@@ -4577,7 +4585,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4577
4585
  unit = $2;
4578
4586
  });
4579
4587
  }
4580
- if (num === undefined) {
4588
+ if (num === void 0) {
4581
4589
  return;
4582
4590
  }
4583
4591
  const ctrl = navigator.platform.match("Mac") ? $event.metaKey : $event.ctrlKey;
@@ -4629,7 +4637,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4629
4637
  const destroyPopover = () => {
4630
4638
  if (!instanceRef.value) return;
4631
4639
  instanceRef.value.destroy();
4632
- instanceRef.value = undefined;
4640
+ instanceRef.value = void 0;
4633
4641
  };
4634
4642
  return (_ctx, _cache) => {
4635
4643
  return openBlock(), createElementBlock("div", _hoisted_1$1, [
@@ -4670,7 +4678,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4670
4678
  }, 8, ["size"])) : createCommentVNode("v-if", true)
4671
4679
  ]),
4672
4680
  key: "0"
4673
- } : undefined
4681
+ } : void 0
4674
4682
  ]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
4675
4683
  (openBlock(), createBlock(Teleport, { to: "body" }, [
4676
4684
  popoverVisible.value ? (openBlock(), createElementBlock(
@@ -4840,7 +4848,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4840
4848
  useAddField(props.prop);
4841
4849
  const { names } = props.config;
4842
4850
  const value = ref([]);
4843
- if (props.model !== undefined && names?.length) {
4851
+ if (props.model !== void 0 && names?.length) {
4844
4852
  watch(
4845
4853
  [() => props.model[names[0]], () => props.model[names[1]]],
4846
4854
  ([start, end], [preStart, preEnd]) => {
@@ -4864,7 +4872,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4864
4872
  if (Array.isArray(v)) {
4865
4873
  props.model[item] = v[index];
4866
4874
  } else {
4867
- props.model[item] = undefined;
4875
+ props.model[item] = void 0;
4868
4876
  }
4869
4877
  });
4870
4878
  };