@tmagic/form 1.4.6 → 1.4.8

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 (61) hide show
  1. package/dist/tmagic-form.js +64 -125
  2. package/dist/tmagic-form.umd.cjs +63 -124
  3. package/package.json +9 -5
  4. package/types/schema.d.ts +2 -2
  5. package/src/Form.vue +0 -201
  6. package/src/FormBox.vue +0 -120
  7. package/src/FormDialog.vue +0 -173
  8. package/src/FormDrawer.vue +0 -159
  9. package/src/containers/Col.vue +0 -52
  10. package/src/containers/Container.vue +0 -416
  11. package/src/containers/Fieldset.vue +0 -124
  12. package/src/containers/GroupList.vue +0 -139
  13. package/src/containers/GroupListItem.vue +0 -135
  14. package/src/containers/Panel.vue +0 -99
  15. package/src/containers/Row.vue +0 -54
  16. package/src/containers/Step.vue +0 -82
  17. package/src/containers/Table.vue +0 -648
  18. package/src/containers/Tabs.vue +0 -226
  19. package/src/fields/Cascader.vue +0 -127
  20. package/src/fields/Checkbox.vue +0 -58
  21. package/src/fields/CheckboxGroup.vue +0 -43
  22. package/src/fields/ColorPicker.vue +0 -30
  23. package/src/fields/Date.vue +0 -38
  24. package/src/fields/DateTime.vue +0 -47
  25. package/src/fields/Daterange.vue +0 -99
  26. package/src/fields/Display.vue +0 -21
  27. package/src/fields/DynamicField.vue +0 -90
  28. package/src/fields/Hidden.vue +0 -16
  29. package/src/fields/Link.vue +0 -86
  30. package/src/fields/Number.vue +0 -49
  31. package/src/fields/NumberRange.vue +0 -50
  32. package/src/fields/RadioGroup.vue +0 -28
  33. package/src/fields/Select.vue +0 -449
  34. package/src/fields/Switch.vue +0 -59
  35. package/src/fields/Text.vue +0 -170
  36. package/src/fields/Textarea.vue +0 -46
  37. package/src/fields/Time.vue +0 -34
  38. package/src/fields/Timerange.vue +0 -76
  39. package/src/index.ts +0 -139
  40. package/src/schema.ts +0 -757
  41. package/src/shims-vue.d.ts +0 -6
  42. package/src/theme/date-time.scss +0 -7
  43. package/src/theme/fieldset.scss +0 -28
  44. package/src/theme/form-box.scss +0 -13
  45. package/src/theme/form-dialog.scss +0 -13
  46. package/src/theme/form-drawer.scss +0 -11
  47. package/src/theme/form.scss +0 -43
  48. package/src/theme/group-list.scss +0 -23
  49. package/src/theme/index.scss +0 -14
  50. package/src/theme/link.scss +0 -3
  51. package/src/theme/number-range.scss +0 -8
  52. package/src/theme/panel.scss +0 -24
  53. package/src/theme/select.scss +0 -3
  54. package/src/theme/table.scss +0 -70
  55. package/src/theme/tabs.scss +0 -27
  56. package/src/theme/text.scss +0 -6
  57. package/src/utils/config.ts +0 -27
  58. package/src/utils/containerProps.ts +0 -50
  59. package/src/utils/form.ts +0 -268
  60. package/src/utils/useAddField.ts +0 -40
  61. package/tsconfig.build.json +0 -13
@@ -1,4 +1,4 @@
1
- import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, watch, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
1
+ import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
2
2
  import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
3
3
  import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
4
4
  import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch, TMagicPopover, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
@@ -153,8 +153,7 @@ const getRules = function(mForm, rules = [], props) {
153
153
  });
154
154
  };
155
155
  const initValue = async (mForm, { initValues, config }) => {
156
- if (!Array.isArray(config))
157
- throw new Error("config应该为数组");
156
+ if (!Array.isArray(config)) throw new Error("config应该为数组");
158
157
  let valuesTmp = createValues(mForm, config, toRaw(initValues), {});
159
158
  const [firstForm] = config;
160
159
  if (firstForm && typeof firstForm.onInitValue === "function") {
@@ -208,8 +207,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
208
207
  const expand = ref(false);
209
208
  const name = computed(() => props.config.name || "");
210
209
  const showDiff = computed(() => {
211
- if (!props.isCompare)
212
- return false;
210
+ if (!props.isCompare) return false;
213
211
  const curValue = name.value ? props.model[name.value] : props.model;
214
212
  const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
215
213
  return !isEqual(curValue, lastValue);
@@ -227,12 +225,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
227
225
  }
228
226
  return `${props.prop}${props.prop ? "." : ""}${n}`;
229
227
  });
230
- const tagName = computed(() => {
231
- const component = resolveComponent(`m-${items.value ? "form" : "fields"}-${type.value}`);
232
- if (typeof component !== "string")
233
- return component;
234
- return "m-fields-text";
235
- });
228
+ const tagName = computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
236
229
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
237
230
  const text = computed(() => filterFunction(mForm, props.config.text, props));
238
231
  const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
@@ -240,15 +233,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
240
233
  const rule = computed(() => getRules(mForm, props.config.rules, props));
241
234
  const type = computed(() => {
242
235
  let { type: type2 } = props.config;
243
- if (typeof type2 === "function") {
244
- type2 = type2(mForm, {
245
- model: props.model
246
- });
247
- }
248
- if (type2 === "form")
249
- return "";
250
- if (type2 === "container")
251
- return "";
236
+ type2 = type2 && filterFunction(mForm, type2, props);
237
+ if (type2 === "form") return "";
238
+ if (type2 === "container") return "";
252
239
  return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (items.value ? "" : "text");
253
240
  });
254
241
  const display$1 = computed(() => {
@@ -265,10 +252,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
265
252
  watch(
266
253
  showDiff,
267
254
  (showDiff2) => {
268
- if (type.value === "hidden")
269
- return;
270
- if (items.value && !text.value && type.value && display$1.value)
271
- return;
255
+ if (type.value === "hidden") return;
256
+ if (items.value && !text.value && type.value && display$1.value) return;
272
257
  if (display$1.value && showDiff2 && type.value) {
273
258
  emit("addDiffCount");
274
259
  }
@@ -804,8 +789,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
804
789
  const changeOrder = (offset = 0) => emit("swap-item", props.index, props.index + offset);
805
790
  const movable = () => {
806
791
  const { movable: movable2 } = props.config;
807
- if (movable2 === void 0)
808
- return true;
792
+ if (movable2 === void 0) return true;
809
793
  if (typeof movable2 === "function") {
810
794
  return movable2(mForm, props.index || 0, props.model, props.groupModel);
811
795
  }
@@ -936,8 +920,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
936
920
  const emit = __emit;
937
921
  const mForm = inject("mForm");
938
922
  const addable = computed(() => {
939
- if (!props.name)
940
- return false;
923
+ if (!props.name) return false;
941
924
  if (typeof props.config.addable === "function") {
942
925
  return props.config.addable(mForm, {
943
926
  model: props.model[props.name],
@@ -949,13 +932,11 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
949
932
  return typeof props.config.addable === "undefined" ? true : props.config.addable;
950
933
  });
951
934
  const changeHandler = () => {
952
- if (!props.name)
953
- return false;
935
+ if (!props.name) return false;
954
936
  emit("change", props.model[props.name]);
955
937
  };
956
938
  const addHandler = async () => {
957
- if (!props.name)
958
- return false;
939
+ if (!props.name) return false;
959
940
  let initValues = {};
960
941
  if (typeof props.config.defaultAdd === "function") {
961
942
  initValues = await props.config.defaultAdd(mForm, {
@@ -974,14 +955,12 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
974
955
  props.model[props.name].push(groupValue);
975
956
  };
976
957
  const removeHandler = (index) => {
977
- if (!props.name)
978
- return false;
958
+ if (!props.name) return false;
979
959
  props.model[props.name].splice(index, 1);
980
960
  changeHandler();
981
961
  };
982
962
  const swapHandler = (idx1, idx2) => {
983
- if (!props.name)
984
- return false;
963
+ if (!props.name) return false;
985
964
  const [currRow] = props.model[props.name].splice(idx1, 1);
986
965
  props.model[props.name].splice(idx2, 0, currRow);
987
966
  changeHandler();
@@ -1418,10 +1397,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1418
1397
  if (tBodyEl) {
1419
1398
  const sortable = Sortable.create(tBodyEl, {
1420
1399
  onEnd: ({ newIndex, oldIndex }) => {
1421
- if (typeof newIndex === "undefined")
1422
- return;
1423
- if (typeof oldIndex === "undefined")
1424
- return;
1400
+ if (typeof newIndex === "undefined") return;
1401
+ if (typeof oldIndex === "undefined") return;
1425
1402
  swapArray(newIndex, oldIndex);
1426
1403
  emit("change", props.model[modelName.value]);
1427
1404
  foreUpdate();
@@ -1451,8 +1428,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1451
1428
  formValue: mForm?.values,
1452
1429
  prop: props.prop
1453
1430
  });
1454
- if (!beforeCheckRes)
1455
- return;
1431
+ if (!beforeCheckRes) return;
1456
1432
  }
1457
1433
  const columns = props.config.items;
1458
1434
  const enumValues = props.config.enum || [];
@@ -1557,8 +1533,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1557
1533
  return fuc;
1558
1534
  };
1559
1535
  const removeHandler = (index) => {
1560
- if (props.disabled)
1561
- return;
1536
+ if (props.disabled) return;
1562
1537
  props.model[modelName.value].splice(index, 1);
1563
1538
  emit("change", props.model[modelName.value]);
1564
1539
  };
@@ -1665,8 +1640,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1665
1640
  };
1666
1641
  const toggleMode = () => {
1667
1642
  const calcLabelWidth = (label) => {
1668
- if (!label)
1669
- return "0px";
1643
+ if (!label) return "0px";
1670
1644
  const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
1671
1645
  const chLength = label.length - zhLength;
1672
1646
  return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
@@ -1686,8 +1660,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
1686
1660
  });
1687
1661
  };
1688
1662
  const toggleFullscreen = () => {
1689
- if (!mTable.value)
1690
- return;
1663
+ if (!mTable.value) return;
1691
1664
  if (isFullscreen.value) {
1692
1665
  mTable.value.classList.remove("fixed");
1693
1666
  isFullscreen.value = false;
@@ -2002,12 +1975,9 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2002
1975
  const getActive = (mForm2, props2, activeTabName2) => {
2003
1976
  const { config, model, prop } = props2;
2004
1977
  const { active } = config;
2005
- if (typeof active === "function")
2006
- return active(mForm2, { model, formValue: mForm2?.values, prop });
2007
- if (+activeTabName2 >= props2.config.items.length)
2008
- return "0";
2009
- if (typeof active !== "undefined")
2010
- return active;
1978
+ if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
1979
+ if (+activeTabName2 >= props2.config.items.length) return "0";
1980
+ if (typeof active !== "undefined") return active;
2011
1981
  return "0";
2012
1982
  };
2013
1983
  const tabClick = (mForm2, tab, props2) => {
@@ -2028,8 +1998,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2028
1998
  const diffCount = ref({});
2029
1999
  const tabs = computed(() => {
2030
2000
  if (props.config.dynamic) {
2031
- if (!props.config.name)
2032
- throw new Error("dynamic tab 必须配置name");
2001
+ if (!props.config.name) throw new Error("dynamic tab 必须配置name");
2033
2002
  return props.model[props.config.name] || [];
2034
2003
  }
2035
2004
  return props.config.items.filter((item) => display(mForm, item.display, props));
@@ -2046,8 +2015,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2046
2015
  const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
2047
2016
  const tabClickHandler = (tab) => tabClick(mForm, tab, props);
2048
2017
  const onTabAdd = () => {
2049
- if (!props.config.name)
2050
- throw new Error("dynamic tab 必须配置name");
2018
+ if (!props.config.name) throw new Error("dynamic tab 必须配置name");
2051
2019
  if (typeof props.config.onTabAdd === "function") {
2052
2020
  props.config.onTabAdd(mForm, {
2053
2021
  model: props.model,
@@ -2063,8 +2031,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2063
2031
  mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
2064
2032
  };
2065
2033
  const onTabRemove = (tabName) => {
2066
- if (!props.config.name)
2067
- throw new Error("dynamic tab 必须配置name");
2034
+ if (!props.config.name) throw new Error("dynamic tab 必须配置name");
2068
2035
  if (typeof props.config.onTabRemove === "function") {
2069
2036
  props.config.onTabRemove(mForm, tabName, {
2070
2037
  model: props.model,
@@ -2167,8 +2134,7 @@ const setConfig = (option) => {
2167
2134
  const getConfig = (key) => $MAGIC_FORM[key];
2168
2135
 
2169
2136
  const useAddField = (prop) => {
2170
- if (!prop)
2171
- return;
2137
+ if (!prop) return;
2172
2138
  const mForm = inject("mForm");
2173
2139
  const instance = getCurrentInstance();
2174
2140
  watch(
@@ -2212,17 +2178,19 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2212
2178
  const tMagicCascader = ref();
2213
2179
  const options = ref([]);
2214
2180
  const remoteData = ref(null);
2181
+ const checkStrictly = computed(() => filterFunction(mForm, props.config.checkStrictly, props));
2182
+ const valueSeparator = computed(() => filterFunction(mForm, props.config.valueSeparator, props));
2215
2183
  const value = computed({
2216
2184
  get() {
2217
- if (typeof props.model[props.name] === "string" && props.config.valueSeparator) {
2218
- return props.model[props.name].split(props.config.valueSeparator);
2185
+ if (typeof props.model[props.name] === "string" && valueSeparator.value) {
2186
+ return props.model[props.name].split(valueSeparator.value);
2219
2187
  }
2220
2188
  return props.model[props.name];
2221
2189
  },
2222
2190
  set(value2) {
2223
2191
  let result = value2;
2224
- if (props.config.valueSeparator) {
2225
- result = value2.join(props.config.valueSeparator);
2192
+ if (valueSeparator.value) {
2193
+ result = value2.join(valueSeparator.value);
2226
2194
  }
2227
2195
  props.model[props.name] = result;
2228
2196
  }
@@ -2230,8 +2198,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2230
2198
  const setRemoteOptions = async function() {
2231
2199
  const { config } = props;
2232
2200
  const { option } = config;
2233
- if (!option)
2234
- return;
2201
+ if (!option) return;
2235
2202
  let { body } = option;
2236
2203
  const postOptions = {
2237
2204
  url: option.url,
@@ -2276,8 +2243,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2276
2243
  });
2277
2244
  }
2278
2245
  const changeHandler = () => {
2279
- if (!tMagicCascader.value)
2280
- return;
2246
+ if (!tMagicCascader.value) return;
2281
2247
  tMagicCascader.value.setQuery("");
2282
2248
  tMagicCascader.value.setPreviousQuery(null);
2283
2249
  emit("change", props.model[props.name]);
@@ -2299,7 +2265,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2299
2265
  props: {
2300
2266
  multiple: _ctx.config.multiple ?? false,
2301
2267
  emitPath: _ctx.config.emitPath ?? true,
2302
- checkStrictly: _ctx.config.checkStrictly ?? false
2268
+ checkStrictly: checkStrictly.value ?? false
2303
2269
  },
2304
2270
  onChange: changeHandler
2305
2271
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
@@ -2399,10 +2365,8 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2399
2365
  };
2400
2366
  const mForm = inject("mForm");
2401
2367
  const options = computed(() => {
2402
- if (Array.isArray(props.config.options))
2403
- return props.config.options;
2404
- if (typeof props.config.options === "function")
2405
- return filterFunction(mForm, props.config.options, props);
2368
+ if (Array.isArray(props.config.options)) return props.config.options;
2369
+ if (typeof props.config.options === "function") return filterFunction(mForm, props.config.options, props);
2406
2370
  return [];
2407
2371
  });
2408
2372
  return (_ctx, _cache) => {
@@ -2540,12 +2504,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2540
2504
  if (!value.value) {
2541
2505
  value.value = [];
2542
2506
  }
2543
- if (!start || !end)
2544
- value.value = [];
2545
- if (start !== preStart)
2546
- value.value[0] = new Date(start);
2547
- if (end !== preEnd)
2548
- value.value[1] = new Date(end);
2507
+ if (!start || !end) value.value = [];
2508
+ if (start !== preStart) value.value[0] = new Date(start);
2509
+ if (end !== preEnd) value.value[1] = new Date(end);
2549
2510
  },
2550
2511
  {
2551
2512
  immediate: true
@@ -2555,8 +2516,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2555
2516
  watch(
2556
2517
  () => props.model[props.name],
2557
2518
  (start, preStart) => {
2558
- if (start !== preStart)
2559
- value.value = start.map((item) => item ? new Date(item) : void 0);
2519
+ if (start !== preStart) value.value = start.map((item) => item ? new Date(item) : void 0);
2560
2520
  },
2561
2521
  {
2562
2522
  immediate: true
@@ -2582,8 +2542,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2582
2542
  emit(
2583
2543
  "change",
2584
2544
  value2.map((item) => {
2585
- if (item)
2586
- return datetimeFormatter(item, "");
2545
+ if (item) return datetimeFormatter(item, "");
2587
2546
  return void 0;
2588
2547
  })
2589
2548
  );
@@ -2721,14 +2680,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2721
2680
  value: {}
2722
2681
  });
2723
2682
  const changeFieldMap = async () => {
2724
- if (typeof props.config.returnFields !== "function" || !props.model)
2725
- return;
2683
+ if (typeof props.config.returnFields !== "function" || !props.model) return;
2726
2684
  const fields = await props.config.returnFields(props.config, props.model, request);
2727
2685
  fieldMap.value = {};
2728
2686
  fieldLabelMap.value = {};
2729
2687
  fields.forEach((v) => {
2730
- if (typeof v !== "object" || v.name === void 0)
2731
- return;
2688
+ if (typeof v !== "object" || v.name === void 0) return;
2732
2689
  let oldVal = props.model?.[v.name] || "";
2733
2690
  if (!oldVal && v.defaultValue !== void 0) {
2734
2691
  oldVal = v.defaultValue;
@@ -2932,12 +2889,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2932
2889
  const error = [];
2933
2890
  Object.entries(invalidFields).forEach(([, ValidateError]) => {
2934
2891
  ValidateError.forEach(({ field, message }) => {
2935
- if (field && message)
2936
- error.push(`${field} -> ${message}`);
2937
- if (field && !message)
2938
- error.push(`${field} -> 出现错误`);
2939
- if (!field && message)
2940
- error.push(`${message}`);
2892
+ if (field && message) error.push(`${field} -> ${message}`);
2893
+ if (field && !message) error.push(`${field} -> 出现错误`);
2894
+ if (!field && message) error.push(`${message}`);
2941
2895
  });
2942
2896
  });
2943
2897
  throw new Error(error.join("<br>"));
@@ -3460,8 +3414,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3460
3414
  const emit = __emit;
3461
3415
  const optionComponent = getConfig$1("components")?.option;
3462
3416
  const optionGroupComponent = getConfig$1("components")?.optionGroup;
3463
- if (!props.model)
3464
- throw new Error("不能没有model");
3417
+ if (!props.model) throw new Error("不能没有model");
3465
3418
  useAddField(props.prop);
3466
3419
  const tMagicSelect = ref();
3467
3420
  const mForm = inject("mForm");
@@ -3496,16 +3449,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3496
3449
  }));
3497
3450
  };
3498
3451
  const getOptions = async () => {
3499
- if (!props.model)
3500
- return [];
3452
+ if (!props.model) return [];
3501
3453
  if (localOptions.value.length) {
3502
3454
  return localOptions.value;
3503
3455
  }
3504
3456
  loading.value = true;
3505
3457
  let items = [];
3506
3458
  const { option } = props.config;
3507
- if (!option)
3508
- return [];
3459
+ if (!option) return [];
3509
3460
  const { root = "", totalKey = "total" } = option;
3510
3461
  let { body = {}, url } = option;
3511
3462
  if (typeof url === "function") {
@@ -3578,8 +3529,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3578
3529
  return pgIndex.value === 0 ? selectedOptions.concat(items) : options.value.concat(items);
3579
3530
  };
3580
3531
  const getInitLocalOption = async () => {
3581
- if (!props.model)
3582
- return [];
3532
+ if (!props.model) return [];
3583
3533
  const value = props.model[props.name];
3584
3534
  const { config } = props;
3585
3535
  localOptions.value = await getOptions();
@@ -3600,11 +3550,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3600
3550
  return localOptions.value.filter((item) => equalValue(item.value, value));
3601
3551
  };
3602
3552
  const getInitOption = async () => {
3603
- if (!props.model)
3604
- return [];
3553
+ if (!props.model) return [];
3605
3554
  const { option } = props.config;
3606
- if (!option)
3607
- return [];
3555
+ if (!option) return [];
3608
3556
  const { root = "", initRoot = "" } = option;
3609
3557
  let { initBody = {} } = option;
3610
3558
  let options2 = [];
@@ -3687,8 +3635,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3687
3635
  });
3688
3636
  } else if (props.config.option) {
3689
3637
  onBeforeMount(() => {
3690
- if (!props.model)
3691
- return;
3638
+ if (!props.model) return;
3692
3639
  const v = props.model[props.name];
3693
3640
  if (Array.isArray(v) ? v.length : typeof v !== "undefined") {
3694
3641
  getInitOption().then((data) => {
@@ -3732,10 +3679,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3732
3679
  emit("change", value);
3733
3680
  };
3734
3681
  const visibleHandler = async (visible) => {
3735
- if (!visible)
3736
- return;
3737
- if (!props.config.remote)
3738
- return;
3682
+ if (!visible) return;
3683
+ if (!props.config.remote) return;
3739
3684
  if (query.value && tMagicSelect.value) {
3740
3685
  tMagicSelect.value.setQuery(query.value);
3741
3686
  tMagicSelect.value.setPreviousQuery(query.value);
@@ -3962,8 +3907,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3962
3907
  mForm?.$emit("field-input", props.prop, v);
3963
3908
  };
3964
3909
  const buttonClickHandler = () => {
3965
- if (!appendConfig.value)
3966
- return;
3910
+ if (!appendConfig.value) return;
3967
3911
  if (typeof appendConfig.value.handler === "function") {
3968
3912
  appendConfig.value.handler(mForm, {
3969
3913
  model: props.model,
@@ -3972,10 +3916,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3972
3916
  }
3973
3917
  };
3974
3918
  const keyUpHandler = ($event) => {
3975
- if (!props.model)
3976
- return;
3977
- if (!props.name)
3978
- return;
3919
+ if (!props.model) return;
3920
+ if (!props.name) return;
3979
3921
  const arrowUp = $event.key === "ArrowUp";
3980
3922
  const arrowDown = $event.key === "ArrowDown";
3981
3923
  if (!arrowUp && !arrowDown) {
@@ -4205,12 +4147,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4205
4147
  if (!value.value) {
4206
4148
  value.value = [];
4207
4149
  }
4208
- if (!start || !end)
4209
- value.value = [];
4210
- if (start !== preStart)
4211
- value.value[0] = start;
4212
- if (end !== preEnd)
4213
- value.value[1] = end;
4150
+ if (!start || !end) value.value = [];
4151
+ if (start !== preStart) value.value[0] = start;
4152
+ if (end !== preEnd) value.value[1] = end;
4214
4153
  },
4215
4154
  {
4216
4155
  immediate: true