bkui-vue 0.0.1-beta.83 → 0.0.1-beta.86

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 (90) hide show
  1. package/dist/index.cjs.js +28 -28
  2. package/dist/index.esm.js +379 -456
  3. package/dist/index.umd.js +29 -29
  4. package/dist/style.css +1 -1
  5. package/lib/alert/alert.css +3 -3
  6. package/lib/alert/alert.less +5 -3
  7. package/lib/alert/alert.variable.css +3 -3
  8. package/lib/alert/index.js +1 -1
  9. package/lib/badge/badge.d.ts +1 -1
  10. package/lib/badge/index.d.ts +4 -4
  11. package/lib/button/button.d.ts +1 -1
  12. package/lib/button/index.d.ts +4 -4
  13. package/lib/cascader/cascader.d.ts +2 -2
  14. package/lib/cascader/index.d.ts +7 -7
  15. package/lib/checkbox/index.js +1 -1
  16. package/lib/date-picker/date-picker.d.ts +1 -1
  17. package/lib/date-picker/index.d.ts +4 -4
  18. package/lib/date-picker/index.js +1 -1
  19. package/lib/dialog/dialog.d.ts +1 -1
  20. package/lib/dialog/index.d.ts +4 -4
  21. package/lib/dropdown/dropdown.d.ts +2 -2
  22. package/lib/dropdown/index.d.ts +7 -7
  23. package/lib/form/form-item.d.ts +3 -3
  24. package/lib/form/form.d.ts +23 -9
  25. package/lib/form/index.d.ts +44 -21
  26. package/lib/form/index.js +1 -1
  27. package/lib/form/type.d.ts +5 -4
  28. package/lib/form/validator.d.ts +1 -0
  29. package/lib/input/index.d.ts +20 -20
  30. package/lib/input/index.js +1 -1
  31. package/lib/input/input.d.ts +6 -6
  32. package/lib/link/index.d.ts +7 -7
  33. package/lib/link/link.d.ts +2 -2
  34. package/lib/message/messageConstructor.d.ts +1 -1
  35. package/lib/notify/notifyConstructor.d.ts +2 -2
  36. package/lib/pagination/index.d.ts +4 -4
  37. package/lib/pagination/index.js +1 -1
  38. package/lib/pagination/pagination.d.ts +1 -1
  39. package/lib/popover/index.d.ts +13 -13
  40. package/lib/popover/popover.d.ts +4 -4
  41. package/lib/progress/index.d.ts +4 -4
  42. package/lib/progress/progress.d.ts +1 -1
  43. package/lib/radio/index.js +1 -1
  44. package/lib/rate/index.js +1 -1
  45. package/lib/resize-layout/index.d.ts +7 -7
  46. package/lib/resize-layout/resize-layout.d.ts +2 -2
  47. package/lib/select/index.d.ts +34 -87
  48. package/lib/select/index.js +1 -1
  49. package/lib/select/option.d.ts +2 -7
  50. package/lib/select/optionGroup.d.ts +1 -1
  51. package/lib/select/select.d.ts +6 -14
  52. package/lib/shared/index.d.ts +2 -0
  53. package/lib/shared/index.js +1 -1
  54. package/lib/shared/token.d.ts +4 -2
  55. package/lib/switcher/index.d.ts +4 -4
  56. package/lib/switcher/index.js +1 -1
  57. package/lib/switcher/switcher.d.ts +1 -1
  58. package/lib/tab/index.d.ts +5 -5
  59. package/lib/tab/tab-panel.d.ts +1 -1
  60. package/lib/tab/tab.d.ts +1 -1
  61. package/lib/table/const.d.ts +3 -1
  62. package/lib/table/index.d.ts +83 -6
  63. package/lib/table/index.js +1 -1
  64. package/lib/table/props.d.ts +27 -1
  65. package/lib/table/render.d.ts +1 -1
  66. package/lib/table/table.css +27 -7
  67. package/lib/table/table.d.ts +37 -2
  68. package/lib/table/table.less +30 -6
  69. package/lib/table/table.variable.css +27 -7
  70. package/lib/table/use-common.d.ts +4 -2
  71. package/lib/table/utils.d.ts +7 -0
  72. package/lib/tag-input/index.d.ts +11 -11
  73. package/lib/tag-input/index.js +1 -1
  74. package/lib/tag-input/tag-input.d.ts +3 -3
  75. package/lib/transfer/const.d.ts +5 -0
  76. package/lib/transfer/index.d.ts +164 -150
  77. package/lib/transfer/index.js +1 -1
  78. package/lib/transfer/props.d.ts +54 -0
  79. package/lib/transfer/transfer.css +6 -6
  80. package/lib/transfer/transfer.d.ts +70 -95
  81. package/lib/transfer/transfer.less +4 -4
  82. package/lib/transfer/transfer.variable.css +6 -6
  83. package/lib/tree/index.js +1 -1
  84. package/lib/upload/upload-list.d.ts +1 -1
  85. package/lib/upload/upload-trigger.d.ts +1 -1
  86. package/lib/upload/upload.d.ts +1 -1
  87. package/lib/virtual-render/index.js +1 -1
  88. package/package.json +2 -1
  89. package/lib/form/common.d.ts +0 -3
  90. package/lib/use-form.d.ts +0 -3
package/dist/index.esm.js CHANGED
@@ -33,7 +33,7 @@ var __publicField = (obj, key, value) => {
33
33
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
34
  return value;
35
35
  };
36
- import { createVNode, h as h$1, mergeProps, defineComponent, reactive, ref, computed, watch, onMounted, onBeforeUnmount, getCurrentInstance, nextTick, Transition, provide, inject, createTextVNode, withDirectives, vShow, isVNode, Fragment, toRefs, customRef, onBeforeMount, toRef, vModelText, resolveDirective, watchEffect, onUpdated, render, onUnmounted, Teleport, withModifiers } from "vue";
36
+ import { inject, createVNode, h as h$1, mergeProps, defineComponent, reactive, ref, computed, watch, onMounted, onBeforeUnmount, getCurrentInstance, nextTick, Transition, provide, createTextVNode, withDirectives, vShow, isVNode, Fragment, toRefs, customRef, onBeforeMount, toRef, vModelText, resolveDirective, watchEffect, onUpdated, render, onUnmounted, Teleport, toRaw, withModifiers } from "vue";
37
37
  var reset = "";
38
38
  var alert = "";
39
39
  var affix = "";
@@ -1292,7 +1292,7 @@ function orderModifiers(modifiers) {
1292
1292
  }));
1293
1293
  }, []);
1294
1294
  }
1295
- function debounce(fn2) {
1295
+ function debounce$1(fn2) {
1296
1296
  var pending;
1297
1297
  return function() {
1298
1298
  if (!pending) {
@@ -1406,7 +1406,7 @@ function popperGenerator(generatorOptions) {
1406
1406
  }
1407
1407
  }
1408
1408
  },
1409
- update: debounce(function() {
1409
+ update: debounce$1(function() {
1410
1410
  return new Promise(function(resolve) {
1411
1411
  instance.forceUpdate();
1412
1412
  resolve(state);
@@ -1454,12 +1454,6 @@ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyS
1454
1454
  var createPopper = /* @__PURE__ */ popperGenerator({
1455
1455
  defaultModifiers
1456
1456
  });
1457
- function isNullOrUndef(value) {
1458
- return value === null || typeof value === "undefined";
1459
- }
1460
- function isEmpty(value, IncludeNullUndefined = true) {
1461
- return value === "" || (IncludeNullUndefined ? isNullOrUndef(value) : false);
1462
- }
1463
1457
  function isArray(value) {
1464
1458
  if (Array.isArray(value)) {
1465
1459
  return true;
@@ -2322,6 +2316,10 @@ class PropTypes extends propTypesNS {
2322
2316
  });
2323
2317
  }
2324
2318
  }
2319
+ const formKey = Symbol("form");
2320
+ const formItemKey = Symbol("formItem");
2321
+ const useForm = () => inject(formKey);
2322
+ const useFormItem = () => inject(formItemKey, EMPTY_OBJ);
2325
2323
  function classes(dynamicCls, constCls = "") {
2326
2324
  return Object.entries(dynamicCls).filter((entry) => entry[1]).map((entry) => entry[0]).join(" ").concat(constCls ? ` ${constCls}` : "");
2327
2325
  }
@@ -2350,6 +2348,34 @@ const withInstallProps = (component, childComponents, isProps = false) => {
2350
2348
  function resolveClassName(clsName, prefix = "bk") {
2351
2349
  return `${prefix}-${clsName}`;
2352
2350
  }
2351
+ function debounce(delay = 300, fn2, immediate = false) {
2352
+ let timeout;
2353
+ let result;
2354
+ const debounced = function() {
2355
+ const ctx = this;
2356
+ const args = arguments;
2357
+ if (timeout)
2358
+ clearTimeout(timeout);
2359
+ if (immediate) {
2360
+ const applyImmediate = !timeout;
2361
+ timeout = setTimeout(() => {
2362
+ timeout = null;
2363
+ }, delay);
2364
+ if (applyImmediate)
2365
+ result = fn2.apply(ctx, args);
2366
+ } else {
2367
+ timeout = setTimeout(() => {
2368
+ fn2.apply(ctx, args);
2369
+ }, delay);
2370
+ }
2371
+ return result;
2372
+ };
2373
+ debounced.cancel = function() {
2374
+ clearTimeout(timeout);
2375
+ timeout = null;
2376
+ };
2377
+ return debounced;
2378
+ }
2353
2379
  function filterProperty(data2, filter) {
2354
2380
  return JSON.parse(JSON.stringify(data2, (key, value) => {
2355
2381
  if (filter.includes(key)) {
@@ -2840,6 +2866,7 @@ var Component$C = defineComponent({
2840
2866
  };
2841
2867
  },
2842
2868
  render() {
2869
+ var _a, _b;
2843
2870
  if (!this.state.visible) {
2844
2871
  return null;
2845
2872
  }
@@ -2847,7 +2874,7 @@ var Component$C = defineComponent({
2847
2874
  const closeButtonClasses = classes({
2848
2875
  "bk-alert-close": true,
2849
2876
  "close-text": renderCloseText,
2850
- "icon-close": !renderCloseText
2877
+ "bk-alert-close-icon": !renderCloseText
2851
2878
  });
2852
2879
  const typeClass = classes({
2853
2880
  "bk-alert": true,
@@ -2863,12 +2890,12 @@ var Component$C = defineComponent({
2863
2890
  "class": "bk-alert-content"
2864
2891
  }, [createVNode("div", {
2865
2892
  "class": "bk-alert-title"
2866
- }, [this.title]), createVNode("div", {
2893
+ }, [this.$slots.title ? this.$slots.title() : this.title]), createVNode("div", {
2867
2894
  "class": "bk-alert-description"
2868
- }, null)]), this.closable && createVNode("span", {
2895
+ }, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)])]), this.closable && createVNode("span", {
2869
2896
  "class": closeButtonClasses,
2870
2897
  "onClick": this.handleClose
2871
- }, [this.closeText])])]);
2898
+ }, [this.closeText ? this.closeText : createVNode(closeLine, null, null)])])]);
2872
2899
  }
2873
2900
  });
2874
2901
  const BkAlert = withInstall(Component$C);
@@ -6925,7 +6952,7 @@ var lodash = { exports: {} };
6925
6952
  function isElement2(value) {
6926
6953
  return isObjectLike(value) && value.nodeType === 1 && !isPlainObject2(value);
6927
6954
  }
6928
- function isEmpty2(value) {
6955
+ function isEmpty(value) {
6929
6956
  if (value == null) {
6930
6957
  return true;
6931
6958
  }
@@ -8055,7 +8082,7 @@ var lodash = { exports: {} };
8055
8082
  lodash2.isBuffer = isBuffer;
8056
8083
  lodash2.isDate = isDate2;
8057
8084
  lodash2.isElement = isElement2;
8058
- lodash2.isEmpty = isEmpty2;
8085
+ lodash2.isEmpty = isEmpty;
8059
8086
  lodash2.isEqual = isEqual;
8060
8087
  lodash2.isEqualWith = isEqualWith;
8061
8088
  lodash2.isError = isError;
@@ -8983,6 +9010,7 @@ var Component$u = defineComponent({
8983
9010
  props: inputType,
8984
9011
  emits: inputEmitEventsType,
8985
9012
  setup(props, ctx) {
9013
+ const formItem = useFormItem();
8986
9014
  const isFocused = ref(false);
8987
9015
  const isCNInput = ref(false);
8988
9016
  const isTextArea = computed(() => props.type === "textarea");
@@ -9035,20 +9063,25 @@ var Component$u = defineComponent({
9035
9063
  clear
9036
9064
  });
9037
9065
  function clear() {
9066
+ var _a2;
9038
9067
  ctx.emit(EVENTS$2.UPDATE, "");
9039
9068
  ctx.emit(EVENTS$2.CHANGE, "");
9040
9069
  ctx.emit(EVENTS$2.CLEAR);
9070
+ (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "change");
9041
9071
  }
9042
9072
  function handleFocus(e) {
9043
9073
  isFocused.value = true;
9044
9074
  ctx.emit(EVENTS$2.FOCUS, e);
9045
9075
  }
9046
9076
  function handleBlur(e) {
9077
+ var _a2;
9047
9078
  isFocused.value = false;
9048
9079
  ctx.emit(EVENTS$2.BLUR, e);
9080
+ (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "blur");
9049
9081
  }
9050
9082
  function eventHandler(eventName) {
9051
9083
  return (e) => {
9084
+ var _a2;
9052
9085
  if (e.code === "Enter" || e.key === "Enter" || e.keyCode === 13) {
9053
9086
  ctx.emit(EVENTS$2.ENTER, e.target.value, e);
9054
9087
  }
@@ -9058,6 +9091,9 @@ var Component$u = defineComponent({
9058
9091
  ctx.emit(EVENTS$2.UPDATE, isNumberInput.value ? +e.target.value : e.target.value);
9059
9092
  }
9060
9093
  ctx.emit(eventName, e.target.value, e);
9094
+ if (eventName === EVENTS$2.INPUT) {
9095
+ (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "change");
9096
+ }
9061
9097
  };
9062
9098
  }
9063
9099
  const [handleKeyup, handleKeydown, handleKeyPress, handlePaste, handleChange, handleInput] = [EVENTS$2.KEYUP, EVENTS$2.KEYDOWN, EVENTS$2.KEYPRESS, EVENTS$2.PASTE, EVENTS$2.CHANGE, EVENTS$2.INPUT].map(eventHandler);
@@ -9270,6 +9306,7 @@ const useCheckbox = () => {
9270
9306
  props,
9271
9307
  emit
9272
9308
  } = currentInstance;
9309
+ const formItem = useFormItem();
9273
9310
  const checkboxGroup = inject(checkboxGroupKey, EMPTY_OBJ);
9274
9311
  const isGroup = !isEmptyObj(checkboxGroup);
9275
9312
  const isChecked = ref(props.checked);
@@ -9299,6 +9336,7 @@ const useCheckbox = () => {
9299
9336
  isChecked.value = value;
9300
9337
  };
9301
9338
  const handleChange = (event) => {
9339
+ var _a;
9302
9340
  if (isDisabled.value) {
9303
9341
  return;
9304
9342
  }
@@ -9310,6 +9348,7 @@ const useCheckbox = () => {
9310
9348
  if (isGroup) {
9311
9349
  checkboxGroup.handleChange();
9312
9350
  }
9351
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
9313
9352
  nextTick(() => {
9314
9353
  if ($targetInput.checked !== isChecked.value) {
9315
9354
  $targetInput.checked = isChecked.value;
@@ -10485,6 +10524,7 @@ const useRadio = () => {
10485
10524
  props,
10486
10525
  emit
10487
10526
  } = currentInstance;
10527
+ const formItem = useFormItem();
10488
10528
  const radioGroup = inject(radioGroupKey, EMPTY_OBJ);
10489
10529
  const isGroup = !isEmptyObj(radioGroup);
10490
10530
  const isChecked = ref(props.checked);
@@ -10512,6 +10552,7 @@ const useRadio = () => {
10512
10552
  isChecked.value = value;
10513
10553
  };
10514
10554
  const handleChange = (event) => {
10555
+ var _a;
10515
10556
  if (isDisabled.value) {
10516
10557
  return;
10517
10558
  }
@@ -10523,6 +10564,7 @@ const useRadio = () => {
10523
10564
  if (isGroup) {
10524
10565
  radioGroup.handleChange(currentInstance.proxy);
10525
10566
  }
10567
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
10526
10568
  nextTick(() => {
10527
10569
  if ($targetInput.checked !== isChecked.value) {
10528
10570
  $targetInput.checked = isChecked.value;
@@ -10791,12 +10833,15 @@ var Component$i = defineComponent({
10791
10833
  setup(props, {
10792
10834
  emit
10793
10835
  }) {
10836
+ const formItem = useFormItem();
10794
10837
  const hoverRate = ref(0);
10795
10838
  const chooseRate = (val) => {
10839
+ var _a;
10796
10840
  if (!props.editable)
10797
10841
  return;
10798
10842
  emit("update:modelValue", val);
10799
10843
  emit("change", val);
10844
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
10800
10845
  };
10801
10846
  const changeHover = (val) => {
10802
10847
  hoverRate.value = val;
@@ -11133,7 +11178,7 @@ var BkOption = defineComponent({
11133
11178
  name: "Option",
11134
11179
  props: {
11135
11180
  value: PropTypes.any,
11136
- label: PropTypes.string,
11181
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
11137
11182
  disabled: PropTypes.bool.def(false)
11138
11183
  },
11139
11184
  setup(props) {
@@ -11862,6 +11907,7 @@ var Component$f = defineComponent({
11862
11907
  multipleMode,
11863
11908
  allowCreate
11864
11909
  } = toRefs(props);
11910
+ const formItem = useFormItem();
11865
11911
  const inputRef = ref();
11866
11912
  const popoverRef = ref();
11867
11913
  const selectTagInputRef = ref();
@@ -11971,10 +12017,12 @@ var Component$f = defineComponent({
11971
12017
  searchLoading
11972
12018
  } = useRemoteSearch(isRemoteSearch.value ? remoteMethod.value : defaultSearchMethod, initActiveOptionValue);
11973
12019
  const emitChange = (val) => {
12020
+ var _a;
11974
12021
  if (val === modelValue.value)
11975
12022
  return;
11976
12023
  emit("change", val);
11977
12024
  emit("update:modelValue", val);
12025
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
11978
12026
  };
11979
12027
  const handleTogglePopover = () => {
11980
12028
  if (isDisabled.value)
@@ -11988,7 +12036,7 @@ var Component$f = defineComponent({
11988
12036
  searchKey.value = value;
11989
12037
  };
11990
12038
  const handleInputEnter = (value, e) => {
11991
- if (!allowCreate.value || !value || filterable.value && options.value.find((data3) => toLowerCase(data3.label) === toLowerCase(value)))
12039
+ if (!allowCreate.value || !value || filterable.value && options.value.find((data3) => toLowerCase(String(data3.label)) === toLowerCase(value)))
11992
12040
  return;
11993
12041
  const data2 = optionsMap.value.get(value);
11994
12042
  if (data2)
@@ -12605,6 +12653,7 @@ var Component$c = defineComponent({
12605
12653
  setup(props, {
12606
12654
  emit
12607
12655
  }) {
12656
+ const formItem = useFormItem();
12608
12657
  const isLoading = ref(false);
12609
12658
  const isChecked = computed(() => props.trueValue === localValue.value);
12610
12659
  const isModelValue = ref(props.modelValue !== false);
@@ -12646,8 +12695,10 @@ var Component$c = defineComponent({
12646
12695
  const lastValue = isChecked.value ? props.falseValue : props.trueValue;
12647
12696
  const lastChecked = !isChecked.value;
12648
12697
  const trigger = () => {
12698
+ var _a;
12649
12699
  emit("update:modelValue", lastValue);
12650
12700
  emit("change", lastChecked);
12701
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
12651
12702
  };
12652
12703
  let goodJob = true;
12653
12704
  if (typeof props.preCheck === "function") {
@@ -12777,7 +12828,7 @@ function computedVirtualIndex(lineHeight, callback, pagination2, el, event) {
12777
12828
  }
12778
12829
  if (elScrollTop !== scrollTop || targetStartIndex !== startIndex || targetEndIndex !== endIndex) {
12779
12830
  const bottom2 = el.scrollHeight - el.offsetHeight - el.scrollTop;
12780
- typeof callback === "function" && callback(event, targetStartIndex, targetEndIndex, elScrollTop, translateY, elScrollLeft, { bottom: bottom2 });
12831
+ typeof callback === "function" && callback(event, targetStartIndex, targetEndIndex, elScrollTop, translateY, elScrollLeft, { bottom: bottom2 >= 0 ? bottom2 : 0 });
12781
12832
  }
12782
12833
  }
12783
12834
  function visibleRender(e, wrapper, binding) {
@@ -12786,7 +12837,7 @@ function visibleRender(e, wrapper, binding) {
12786
12837
  const elScrollTop = wrapper.scrollTop;
12787
12838
  const elScrollLeft = wrapper.scrollLeft;
12788
12839
  const bottom2 = wrapper.scrollHeight - wrapper.offsetHeight - wrapper.scrollTop;
12789
- handleScrollCallback(e, null, null, elScrollTop, elScrollTop, elScrollLeft, { bottom: bottom2 });
12840
+ handleScrollCallback(e, null, null, elScrollTop, elScrollTop, elScrollLeft, { bottom: bottom2 >= 0 ? bottom2 : 0 });
12790
12841
  return;
12791
12842
  }
12792
12843
  const { startIndex, endIndex, groupItemCount, count, scrollTop } = pagination2;
@@ -12982,6 +13033,7 @@ var EMITEVENTS = /* @__PURE__ */ ((EMITEVENTS2) => {
12982
13033
  EMITEVENTS2["PAGE_LIMIT_CHANGE"] = "pageLimitChange";
12983
13034
  EMITEVENTS2["PAGE_VALUE_CHANGE"] = "pageValueChange";
12984
13035
  EMITEVENTS2["SETTING_CHANGE"] = "settingChange";
13036
+ EMITEVENTS2["SCROLL_BOTTOM"] = "scrollBottom";
12985
13037
  return EMITEVENTS2;
12986
13038
  })(EMITEVENTS || {});
12987
13039
  const EMPTY$1 = (..._args) => true;
@@ -12993,7 +13045,8 @@ const EMIT_EVENT_TYPES = {
12993
13045
  ["rowDblClick"]: EMPTY$1,
12994
13046
  ["pageLimitChange"]: EMPTY$1,
12995
13047
  ["pageValueChange"]: EMPTY$1,
12996
- ["settingChange"]: EMPTY$1
13048
+ ["settingChange"]: EMPTY$1,
13049
+ ["scrollBottom"]: EMPTY$1
12997
13050
  };
12998
13051
  const resolvePropVal = (prop, key, args) => {
12999
13052
  if (Object.prototype.hasOwnProperty.call(prop, key)) {
@@ -13147,6 +13200,18 @@ const getRowText = (row, key, column) => {
13147
13200
  }
13148
13201
  return row[key];
13149
13202
  };
13203
+ const formatPropAsArray = (prop, args) => {
13204
+ if (Array.isArray(prop)) {
13205
+ return prop;
13206
+ }
13207
+ if (typeof prop === "string" || typeof prop === "object") {
13208
+ return [prop];
13209
+ }
13210
+ if (typeof prop === "function") {
13211
+ return formatPropAsArray(Reflect.apply(prop, globalThis, args), args);
13212
+ }
13213
+ return [];
13214
+ };
13150
13215
  const resolveActiveColumns = (props) => {
13151
13216
  if (props.columnPick !== "disabled") {
13152
13217
  if (props.columnPick === "multi") {
@@ -13482,7 +13547,7 @@ const tableProps = {
13482
13547
  PropTypes.bool,
13483
13548
  PropTypes.string
13484
13549
  ]).def(false)
13485
- })),
13550
+ })).def([]),
13486
13551
  activeColumn: PropTypes.oneOfType([PropTypes.number.def(-1), PropTypes.arrayOf(PropTypes.number.def(-1))]),
13487
13552
  columnPick: PropTypes.commonType(["multi", "single", "disabled"], "columnPick").def("disabled"),
13488
13553
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).def("auto"),
@@ -13507,7 +13572,11 @@ const tableProps = {
13507
13572
  limit: PropTypes.number.def(void 0),
13508
13573
  size: PropTypes.size(["small", "default", "large"]).def("default"),
13509
13574
  sizeList: PropTypes.shape([]).def(void 0)
13510
- })]).def(false)
13575
+ })]).def(false),
13576
+ rowClass: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
13577
+ rowStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
13578
+ cellStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
13579
+ cellClass: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({})
13511
13580
  };
13512
13581
  function _isSlot$2(s2) {
13513
13582
  return typeof s2 === "function" || Object.prototype.toString.call(s2) === "[object Object]" && !isVNode(s2);
@@ -13748,14 +13817,6 @@ var useSmallList = () => {
13748
13817
  }
13749
13818
  localCurrent.value = localCurrent.value + 1;
13750
13819
  };
13751
- const setSelection = () => {
13752
- nextTick(() => {
13753
- inputRef.value.focus();
13754
- const range = window.getSelection();
13755
- range.selectAllChildren(inputRef.value);
13756
- range.collapseToEnd();
13757
- });
13758
- };
13759
13820
  const handlePageEditorFocus = () => {
13760
13821
  isFocused.value = true;
13761
13822
  };
@@ -13773,13 +13834,11 @@ var useSmallList = () => {
13773
13834
  return;
13774
13835
  }
13775
13836
  inputMemo = value;
13776
- setSelection();
13777
13837
  };
13778
13838
  const handlePageEditorKeydown = (event) => {
13779
13839
  if (["Enter", "NumpadEnter"].includes(event.code)) {
13780
13840
  event.preventDefault();
13781
13841
  handlePageEditorBlur();
13782
- setSelection();
13783
13842
  }
13784
13843
  };
13785
13844
  const handlePageChange = (item) => {
@@ -14381,6 +14440,14 @@ class TableRender {
14381
14440
  }, [this.renderColGroup(), this.renderHeader()])];
14382
14441
  }
14383
14442
  renderTableBodySchema(rows) {
14443
+ var _a, _b, _c;
14444
+ if (!rows.length) {
14445
+ return (_c = (_b = (_a = this.context.slots).empty) == null ? void 0 : _b.call(_a)) != null ? _c : createVNode(BodyEmpty, {
14446
+ "filterList": rows,
14447
+ "list": this.props.data,
14448
+ "emptyText": this.props.emptyText
14449
+ }, null);
14450
+ }
14384
14451
  return createVNode("table", {
14385
14452
  "cellpadding": 0,
14386
14453
  "cellspacing": 0
@@ -14526,38 +14593,36 @@ class TableRender {
14526
14593
  }, [renderHeadCell(column, index)])]))])]);
14527
14594
  }
14528
14595
  renderTBody(rows) {
14529
- var _a, _b, _c;
14530
14596
  const {
14531
14597
  getFixedColumnStyleResolve
14532
14598
  } = useFixedColumn(this.props, this.colgroups);
14533
- return createVNode("tbody", null, [rows.length ? rows.map((row, rowIndex) => {
14534
- const rowStyle = {
14599
+ return createVNode("tbody", null, [rows.map((row, rowIndex) => {
14600
+ const rowStyle = [...formatPropAsArray(this.props.rowStyle, [row, rowIndex, this]), {
14535
14601
  "--row-height": `${this.getRowHeight(row, rowIndex)}px`
14536
- };
14602
+ }];
14603
+ const rowClass = [...formatPropAsArray(this.props.rowClass, [row, rowIndex, this])];
14537
14604
  const {
14538
14605
  resolveFixedColumnStyle,
14539
14606
  fixedoffset
14540
14607
  } = getFixedColumnStyleResolve();
14541
14608
  return createVNode("tr", {
14542
14609
  "style": rowStyle,
14610
+ "class": rowClass,
14543
14611
  "onClick": (e) => this.handleRowClick(e, row, rowIndex, rows),
14544
14612
  "onDblclick": (e) => this.handleRowDblClick(e, row, rowIndex, rows)
14545
- }, [this.filterColgroups.map((column, index) => createVNode("td", {
14546
- "class": this.getColumnClass(column, index),
14547
- "style": resolveFixedColumnStyle(column, fixedoffset),
14548
- "colspan": 1,
14549
- "rowspan": 1
14550
- }, [createVNode("div", {
14551
- "class": "cell"
14552
- }, [this.renderCell(row, column, rowIndex, rows)])]))]);
14553
- }) : createVNode("tr", null, [createVNode("td", {
14554
- "colspan": this.props.columns.length,
14555
- "class": "empty-cell"
14556
- }, [(_c = (_b = (_a = this.context.slots).empty) == null ? void 0 : _b.call(_a)) != null ? _c : createVNode(BodyEmpty, {
14557
- "filterList": rows,
14558
- "list": this.props.data,
14559
- "emptyText": this.props.emptyText
14560
- }, null)])])]);
14613
+ }, [this.filterColgroups.map((column, index) => {
14614
+ const cellStyle = [resolveFixedColumnStyle(column, fixedoffset), ...formatPropAsArray(this.props.cellStyle, [column, index, row, rowIndex, this])];
14615
+ const cellClass = [this.getColumnClass(column, index), ...formatPropAsArray(this.props.cellClass, [column, index, row, rowIndex, this])];
14616
+ return createVNode("td", {
14617
+ "class": cellClass,
14618
+ "style": cellStyle,
14619
+ "colspan": 1,
14620
+ "rowspan": 1
14621
+ }, [createVNode("div", {
14622
+ "class": "cell"
14623
+ }, [this.renderCell(row, column, rowIndex, rows)])]);
14624
+ })]);
14625
+ })]);
14561
14626
  }
14562
14627
  handleRowClick(e, row, index, rows) {
14563
14628
  this.context.emit("rowClick", e, row, index, rows, this);
@@ -14594,7 +14659,7 @@ class TableRender {
14594
14659
  return this.reactiveProp.setting;
14595
14660
  }
14596
14661
  }
14597
- const useClass = (props, root, reactiveProp) => {
14662
+ const useClass = (props, root, reactiveProp, pageData) => {
14598
14663
  const autoHeight = ref(200);
14599
14664
  const hasScrollY = ref(false);
14600
14665
  const hasFooter = computed(() => props.pagination && props.data.length);
@@ -14613,9 +14678,9 @@ const useClass = (props, root, reactiveProp) => {
14613
14678
  "--scroll-head-left": `-${reactiveProp.scrollTranslateX}px`,
14614
14679
  "--scroll-left": `${reactiveProp.scrollTranslateX}px`
14615
14680
  }));
14616
- const contentClass = classes({
14681
+ const contentClass = {
14617
14682
  [resolveClassName("table-body")]: true
14618
- });
14683
+ };
14619
14684
  const footerClass = computed(() => classes({
14620
14685
  [resolveClassName("table-footer")]: true,
14621
14686
  ["is-hidden"]: !props.pagination || !props.data.length
@@ -14649,7 +14714,7 @@ const useClass = (props, root, reactiveProp) => {
14649
14714
  const maxHeight = resolveMaxHeight - resolveHeadHeight - resolveFooterHeight;
14650
14715
  const minHeight = resolveMinHeight - resolveHeadHeight - resolveFooterHeight;
14651
14716
  Object.assign(contentStyle, {
14652
- display: "block",
14717
+ display: (pageData == null ? void 0 : pageData.length) ? "block" : false,
14653
14718
  "max-height": `${maxHeight}px`,
14654
14719
  "min-height": `${minHeight}px`,
14655
14720
  height
@@ -14668,7 +14733,9 @@ const useClass = (props, root, reactiveProp) => {
14668
14733
  const updateBorderClass = (root2) => {
14669
14734
  if (root2) {
14670
14735
  const tableBody = root2.querySelector(".bk-table-body table");
14671
- hasScrollY.value = tableBody.offsetHeight > root2.offsetHeight;
14736
+ if (tableBody) {
14737
+ hasScrollY.value = tableBody.offsetHeight > root2.offsetHeight;
14738
+ }
14672
14739
  }
14673
14740
  };
14674
14741
  return {
@@ -14689,7 +14756,8 @@ var Component$9 = defineComponent({
14689
14756
  props: tableProps,
14690
14757
  emits: EMIT_EVENT_TYPES,
14691
14758
  setup(props, ctx) {
14692
- const colgroups = reactive(props.columns.map((col) => __spreadProps(__spreadValues({}, col), {
14759
+ var _a;
14760
+ const colgroups = reactive(((_a = props.columns) != null ? _a : []).map((col) => __spreadProps(__spreadValues({}, col), {
14693
14761
  calcWidth: null,
14694
14762
  resizeWidth: null,
14695
14763
  listeners: /* @__PURE__ */ new Map()
@@ -14734,7 +14802,7 @@ var Component$9 = defineComponent({
14734
14802
  updateBorderClass,
14735
14803
  resetTableHeight,
14736
14804
  hasFooter
14737
- } = useClass(props, root, reactiveProp);
14805
+ } = useClass(props, root, reactiveProp, pageData);
14738
14806
  const {
14739
14807
  renderFixedColumns,
14740
14808
  fixedWrapperClass
@@ -14783,14 +14851,14 @@ var Component$9 = defineComponent({
14783
14851
  index
14784
14852
  });
14785
14853
  }).on(EVENTS$1.ON_SETTING_CHANGE, (args) => {
14786
- var _a, _b;
14854
+ var _a2, _b;
14787
14855
  const {
14788
14856
  checked = [],
14789
14857
  size,
14790
14858
  height
14791
14859
  } = args;
14792
14860
  checked.length && resolveColumnWidth(root.value, colgroups, 20);
14793
- (_b = (_a = refVirtualRender.value) == null ? void 0 : _a.reset) == null ? void 0 : _b.call(_a);
14861
+ (_b = (_a2 = refVirtualRender.value) == null ? void 0 : _a2.reset) == null ? void 0 : _b.call(_a2);
14794
14862
  ctx.emit(EMITEVENTS.SETTING_CHANGE, {
14795
14863
  checked,
14796
14864
  size,
@@ -14798,6 +14866,8 @@ var Component$9 = defineComponent({
14798
14866
  });
14799
14867
  });
14800
14868
  const handleScrollChanged = (args) => {
14869
+ var _a2;
14870
+ const preBottom = (_a2 = reactiveProp.pos.bottom) != null ? _a2 : 0;
14801
14871
  const pagination2 = args[1];
14802
14872
  const {
14803
14873
  translateX,
@@ -14807,6 +14877,17 @@ var Component$9 = defineComponent({
14807
14877
  reactiveProp.scrollTranslateY = translateY;
14808
14878
  reactiveProp.scrollTranslateX = translateX;
14809
14879
  reactiveProp.pos = pos;
14880
+ const {
14881
+ bottom: bottom2
14882
+ } = pos;
14883
+ if (bottom2 <= 2 && preBottom !== bottom2) {
14884
+ debounce(60, () => {
14885
+ ctx.emit(EMITEVENTS.SCROLL_BOTTOM, __spreadProps(__spreadValues({}, pos), {
14886
+ translateX,
14887
+ translateY
14888
+ }));
14889
+ }, true)();
14890
+ }
14810
14891
  };
14811
14892
  onMounted(() => {
14812
14893
  observerIns = observerResize(root.value, () => {
@@ -14825,6 +14906,20 @@ var Component$9 = defineComponent({
14825
14906
  ctx.expose({
14826
14907
  plugins: tableRender.plugins
14827
14908
  });
14909
+ const tableBodyClass = __spreadProps(__spreadValues({}, contentClass), {
14910
+ "__is-empty": !pageData.length
14911
+ });
14912
+ const tableBodyContentClass = {
14913
+ [resolveClassName("table-body-content")]: true,
14914
+ "with-virtual-render": props.virtualEnabled
14915
+ };
14916
+ const resizeColumnClass = {
14917
+ [resolveClassName("drag-column")]: true,
14918
+ "offset-x": true
14919
+ };
14920
+ const loadingRowClass = {
14921
+ [resolveClassName("table-loading_bottom")]: true
14922
+ };
14828
14923
  return () => createVNode("div", {
14829
14924
  "class": tableClass.value,
14830
14925
  "style": wrapperStyle.value,
@@ -14837,9 +14932,10 @@ var Component$9 = defineComponent({
14837
14932
  createVNode(BkVirtualRender, {
14838
14933
  "ref": refVirtualRender,
14839
14934
  "lineHeight": tableRender.getRowHeight,
14840
- "class": contentClass,
14935
+ "class": tableBodyClass,
14841
14936
  "style": contentStyle,
14842
14937
  "list": pageData,
14938
+ "contentClassName": tableBodyContentClass,
14843
14939
  "onContentScroll": handleScrollChanged,
14844
14940
  "throttleDelay": 0,
14845
14941
  "scrollEvent": true,
@@ -14850,8 +14946,10 @@ var Component$9 = defineComponent({
14850
14946
  createVNode("div", {
14851
14947
  "class": fixedWrapperClass
14852
14948
  }, [renderFixedColumns(), createVNode("div", {
14853
- "class": "bk-drag-column offset-x",
14949
+ "class": resizeColumnClass,
14854
14950
  "style": dragOffsetXStyle.value
14951
+ }, null), createVNode("div", {
14952
+ "class": loadingRowClass
14855
14953
  }, null)]),
14856
14954
  createVNode("div", {
14857
14955
  "class": footerClass.value
@@ -15041,6 +15139,7 @@ var Component$8 = defineComponent({
15041
15139
  setup(props, {
15042
15140
  emit
15043
15141
  }) {
15142
+ const formItem = useFormItem();
15044
15143
  const state = reactive({
15045
15144
  isEdit: false,
15046
15145
  isHover: false,
@@ -15325,6 +15424,7 @@ var Component$8 = defineComponent({
15325
15424
  };
15326
15425
  const handleBlur = () => {
15327
15426
  timer.value = setTimeout(() => {
15427
+ var _a;
15328
15428
  const inputValue = curInputValue.value;
15329
15429
  clearInput();
15330
15430
  state.isEdit = false;
@@ -15351,6 +15451,7 @@ var Component$8 = defineComponent({
15351
15451
  }
15352
15452
  popoverProps.isShow = false;
15353
15453
  emit("blur", inputValue, tagList.value);
15454
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
15354
15455
  }, 50);
15355
15456
  };
15356
15457
  const handleTagSelected = (item, type, e) => {
@@ -15374,9 +15475,11 @@ var Component$8 = defineComponent({
15374
15475
  tagInputRef.value.style.width = `${INPUT_MIN_WIDTH}px`;
15375
15476
  };
15376
15477
  const handleChange = (type, data2) => {
15478
+ var _a;
15377
15479
  emit("change", tagList.value);
15378
15480
  emit(type, data2);
15379
15481
  emit("update:modelValue", tagList.value);
15482
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
15380
15483
  };
15381
15484
  const handleClear = (e) => {
15382
15485
  e.stopPropagation();
@@ -20465,6 +20568,7 @@ var Component$5 = defineComponent({
20465
20568
  slots,
20466
20569
  emit
20467
20570
  }) {
20571
+ const formItem = useFormItem();
20468
20572
  const isRange = props.type.includes("range");
20469
20573
  const emptyArray = isRange ? [null, null] : [null];
20470
20574
  let initialValue = isAllEmptyArr((isRange ? props.modelValue : [props.modelValue]) || []) ? emptyArray : parseDate(props.modelValue, props.type, props.multiple, props.format);
@@ -20664,11 +20768,12 @@ var Component$5 = defineComponent({
20664
20768
  };
20665
20769
  const emitChange = (type) => {
20666
20770
  nextTick(() => {
20667
- var _a;
20771
+ var _a, _b;
20668
20772
  emit("change", publicStringValue.value, type);
20669
20773
  emit("update:modelValue", publicVModelValue.value);
20774
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
20670
20775
  if (props.type.indexOf("time") < 0) {
20671
- (_a = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _a.blur();
20776
+ (_b = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _b.blur();
20672
20777
  }
20673
20778
  });
20674
20779
  };
@@ -20705,7 +20810,7 @@ var Component$5 = defineComponent({
20705
20810
  (_a = pickerPanelRef == null ? void 0 : pickerPanelRef.value) == null ? void 0 : _a.reset();
20706
20811
  };
20707
20812
  const handleBlur = (e) => {
20708
- var _a;
20813
+ var _a, _b;
20709
20814
  if (state.internalFocus) {
20710
20815
  state.internalFocus = false;
20711
20816
  return;
@@ -20719,6 +20824,7 @@ var Component$5 = defineComponent({
20719
20824
  state.internalValue = state.internalValue.slice();
20720
20825
  reset2();
20721
20826
  (_a = pickerPanelRef == null ? void 0 : pickerPanelRef.value) == null ? void 0 : _a.onToggleVisibility(false);
20827
+ (_b = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _b.call(formItem, "blur");
20722
20828
  };
20723
20829
  const handleKeydown = (e) => {
20724
20830
  const {
@@ -20986,359 +21092,169 @@ var Component$5 = defineComponent({
20986
21092
  }
20987
21093
  });
20988
21094
  const BkDatePicker = withInstall(Component$5);
20989
- ({
20990
- title: Array,
20991
- extCls: PropTypes.string,
20992
- settingKey: PropTypes.string,
20993
- displayKey: PropTypes.string,
20994
- searchPlaceholder: PropTypes.string,
20995
- showOverflowTips: PropTypes.bool,
20996
- searchable: PropTypes.bool,
20997
- sortKey: PropTypes.string,
20998
- sortable: PropTypes.bool,
20999
- sourceList: Array,
21000
- targetList: Array,
21001
- emptyContent: Array
21002
- });
21095
+ var ArrayType = /* @__PURE__ */ ((ArrayType2) => {
21096
+ ArrayType2["OBJECT_ARRAY"] = "objectArray";
21097
+ ArrayType2["BASE_ARRAY"] = "baseArray";
21098
+ ArrayType2["NOT_ARRAY"] = "notArray";
21099
+ return ArrayType2;
21100
+ })(ArrayType || {});
21101
+ const transferProps = {
21102
+ title: PropTypes.arrayOf(PropTypes.string).def([]),
21103
+ extCls: PropTypes.string.def(""),
21104
+ searchPlaceholder: PropTypes.string.def(""),
21105
+ settingKey: PropTypes.string.def("id"),
21106
+ displayKey: PropTypes.string.def("value"),
21107
+ sortKey: PropTypes.string.def("value"),
21108
+ showOverflowTips: PropTypes.bool.def(false),
21109
+ searchable: PropTypes.bool.def(false),
21110
+ sortable: PropTypes.bool.def(false),
21111
+ sourceList: PropTypes.arrayOf(PropTypes.any).def([]),
21112
+ targetList: PropTypes.arrayOf(PropTypes.any).def([]),
21113
+ emptyContent: PropTypes.arrayOf(PropTypes.string).def([])
21114
+ };
21115
+ function useTransferData(sourceData, targetList, settingCode) {
21116
+ const selectList = ref([]);
21117
+ const selectedList = ref([]);
21118
+ const transformData = () => {
21119
+ sourceData.value.forEach((s2) => {
21120
+ const keyId = s2[settingCode.value];
21121
+ if (targetList.value.includes(keyId)) {
21122
+ selectedList.value.push(s2);
21123
+ } else {
21124
+ selectList.value.push(s2);
21125
+ }
21126
+ });
21127
+ };
21128
+ transformData();
21129
+ watch(() => [sourceData, targetList, settingCode], transformData);
21130
+ return {
21131
+ selectList,
21132
+ selectedList
21133
+ };
21134
+ }
21135
+ function useSelectListSearch(selectList, displayCode) {
21136
+ const selectSearchQuery = ref("");
21137
+ const selectListSearch = computed(() => {
21138
+ return selectList.value.filter((select2) => {
21139
+ const val = select2[displayCode.value];
21140
+ if (val instanceof Object)
21141
+ return false;
21142
+ return val.toString().includes(selectSearchQuery.value);
21143
+ });
21144
+ });
21145
+ return {
21146
+ selectSearchQuery,
21147
+ selectListSearch
21148
+ };
21149
+ }
21003
21150
  var Component$4 = defineComponent({
21004
21151
  name: "Transfer",
21005
- props: {
21006
- title: {
21007
- type: Array,
21008
- default: () => []
21009
- },
21010
- extCls: {
21011
- type: String,
21012
- default: ""
21013
- },
21014
- searchPlaceholder: {
21015
- type: String,
21016
- default: ""
21017
- },
21018
- settingKey: {
21019
- type: String,
21020
- default: "id"
21021
- },
21022
- displayKey: {
21023
- type: String,
21024
- default: "value"
21025
- },
21026
- sortKey: {
21027
- type: String,
21028
- default: ""
21029
- },
21030
- showOverflowTips: {
21031
- type: Boolean,
21032
- default: false
21033
- },
21034
- searchable: {
21035
- type: Boolean,
21036
- default: false
21037
- },
21038
- sortable: {
21039
- type: Boolean,
21040
- default: false
21041
- },
21042
- sourceList: {
21043
- type: Array,
21044
- default: () => []
21045
- },
21046
- targetList: {
21047
- type: Array,
21048
- default: () => []
21049
- },
21050
- emptyContent: {
21051
- type: Array,
21052
- default: () => []
21053
- }
21054
- },
21055
- emits: ["change"],
21056
- slots: ["left-header", "right-header", "source-option", "target-option", "left-empty-content", "right-empty-content"],
21152
+ props: transferProps,
21153
+ emits: ["change", "update:targetList"],
21057
21154
  setup(props, {
21058
21155
  emit
21059
21156
  }) {
21060
- let sortList = [];
21061
- let sortCode = props.sortKey;
21062
- let isSortFlag = props.sortable;
21063
- const keyword = ref("");
21064
- const transferRef = ref(null);
21065
- const dataList = ref([]);
21066
- const hasSelectedList = ref([]);
21067
- const leftHoverIndex = ref(-1);
21068
- const rightHoverIndex = ref(-1);
21069
- const typeFlag = computed(() => {
21070
- if (!props.sourceList || !Array.isArray(props.sourceList)) {
21071
- return "empty";
21072
- }
21073
- const str = props.sourceList.toString();
21074
- if (str.indexOf("[object Object]") !== -1) {
21075
- return true;
21076
- }
21077
- return false;
21078
- });
21079
- const settingCode = computed(() => {
21080
- if (!typeFlag.value) {
21081
- return "index";
21082
- }
21083
- return props.settingKey;
21084
- });
21085
- const displayCode = computed(() => {
21086
- if (!typeFlag.value) {
21087
- return "value";
21088
- }
21089
- return props.displayKey;
21090
- });
21091
- const displayDataList = computed(() => {
21092
- if (keyword.value) {
21093
- return dataList.value.filter((item) => !isEmpty(item[displayCode.value]) && String(item[displayCode.value]).indexOf(keyword.value) > -1);
21094
- }
21095
- return dataList.value;
21096
- });
21097
- watch(() => props.sourceList, () => {
21098
- if (typeFlag.value !== "empty") {
21099
- initData();
21100
- initSort();
21157
+ const sourceListType = computed(() => {
21158
+ if (Array.isArray(props.sourceList)) {
21159
+ const isObjectArray = props.sourceList.every((s2) => s2.toString().includes("[object Object]"));
21160
+ return isObjectArray ? ArrayType.OBJECT_ARRAY : ArrayType.BASE_ARRAY;
21161
+ }
21162
+ return ArrayType.NOT_ARRAY;
21163
+ });
21164
+ const settingCode = computed(() => sourceListType.value === ArrayType.BASE_ARRAY ? "value" : props.settingKey);
21165
+ const displayCode = computed(() => sourceListType.value === ArrayType.BASE_ARRAY ? "value" : props.displayKey);
21166
+ const sortCode = computed(() => props.sortKey || displayCode.value);
21167
+ const sourceData = computed(() => {
21168
+ switch (sourceListType.value) {
21169
+ case ArrayType.BASE_ARRAY:
21170
+ return [...new Set(props.sourceList)].map((s2) => ({
21171
+ value: s2
21172
+ }));
21173
+ case ArrayType.OBJECT_ARRAY:
21174
+ return [...props.sourceList];
21175
+ default:
21176
+ return [];
21101
21177
  }
21102
- }, {
21103
- deep: true
21104
- });
21105
- watch(() => props.targetList, () => {
21106
- initData();
21107
- initSort();
21108
- }, {
21109
- deep: true
21110
21178
  });
21111
- watch(() => [displayCode.value, settingCode.value], () => {
21112
- initData();
21113
- });
21114
- watch(() => props.sortKey, (value) => {
21115
- sortCode = value;
21116
- initSort();
21117
- });
21118
- watch(() => props.sortable, (value) => {
21119
- isSortFlag = value;
21120
- initSort();
21179
+ const {
21180
+ targetList
21181
+ } = toRefs(props);
21182
+ const {
21183
+ selectList,
21184
+ selectedList
21185
+ } = useTransferData(sourceData, targetList, settingCode);
21186
+ const {
21187
+ selectSearchQuery,
21188
+ selectListSearch
21189
+ } = useSelectListSearch(selectList, displayCode);
21190
+ const selectListSort = computed(() => {
21191
+ return [...selectListSearch.value].sort((a2, b2) => {
21192
+ const va = a2[sortCode.value];
21193
+ const vb = b2[sortCode.value];
21194
+ return va > vb ? 1 : -1;
21195
+ });
21121
21196
  });
21122
- const initData = () => {
21123
- if (typeFlag.value !== "empty") {
21124
- if (!typeFlag.value) {
21125
- generalInit();
21126
- } else {
21127
- init();
21128
- }
21129
- }
21130
- };
21131
- const generalInit = () => {
21132
- if (!props.targetList.length || props.targetList.length > props.sourceList.length) {
21133
- const list = [];
21134
- for (let i = 0; i < props.sourceList.length; i++) {
21135
- list.push({
21136
- index: i,
21137
- value: props.sourceList[i]
21138
- });
21139
- }
21140
- dataList.value = [...list];
21141
- hasSelectedList.value.splice(0, hasSelectedList.value.length, ...[]);
21142
- emit("change", dataList.value, [], []);
21143
- } else {
21144
- const list = [];
21145
- const valueList = [];
21146
- for (let i = 0; i < props.sourceList.length; i++) {
21147
- list.push({
21148
- index: i,
21149
- value: props.sourceList[i]
21150
- });
21151
- }
21152
- props.targetList.forEach((target) => {
21153
- const matchItem = list.find((val) => val.value === target);
21154
- if (matchItem) {
21155
- valueList.push(matchItem);
21156
- }
21157
- });
21158
- hasSelectedList.value = [...valueList];
21159
- const result = list.filter((item1) => valueList.every((item2) => item2.index !== item1.index));
21160
- dataList.value = [...result];
21161
- emit("change", dataList.value, [...handleListFormat(hasSelectedList.value, false)], []);
21162
- }
21163
- };
21164
- const init = () => {
21165
- if (!props.targetList.length || props.targetList.length > props.sourceList.length) {
21166
- dataList.value.splice(0, dataList.value.length, ...props.sourceList);
21167
- hasSelectedList.value = [];
21168
- emit("change", dataList.value, [], []);
21169
- } else {
21170
- const result = props.sourceList.filter((item1) => props.targetList.every((item2) => item2 !== item1[settingCode.value]));
21171
- const hasTempList = [];
21172
- props.sourceList.forEach((item1) => {
21173
- props.targetList.forEach((item2) => {
21174
- if (item1[settingCode.value] === item2) {
21175
- hasTempList.push(item1);
21176
- }
21177
- });
21178
- });
21179
- hasSelectedList.value = [...hasTempList];
21180
- dataList.value = [...result];
21181
- const list = [...handleListFormat(hasSelectedList.value)];
21182
- emit("change", dataList.value, hasSelectedList.value, list);
21183
- }
21184
- };
21185
- const initSort = () => {
21186
- let templateList = [];
21187
- if (!typeFlag.value) {
21188
- sortCode = isSortFlag ? "index" : "";
21189
- for (let k2 = 0; k2 < props.sourceList.length; k2++) {
21190
- templateList.push({
21191
- index: k2,
21192
- value: props.sourceList[k2]
21193
- });
21194
- }
21195
- } else {
21196
- if (!isSortFlag) {
21197
- sortCode = "";
21198
- }
21199
- templateList = [...props.sourceList];
21200
- }
21201
- if (sortCode) {
21202
- const arr = [];
21203
- templateList.forEach((item) => {
21204
- arr.push(item[sortCode]);
21205
- });
21206
- sortList = [...arr];
21207
- if (sortList.length === props.sourceList.length) {
21208
- const list = [...dataList.value];
21209
- dataList.value = [...sortDataList(list, sortCode, sortList)];
21210
- }
21211
- }
21212
- };
21213
- const handleItemChange = () => {
21214
- const sourceList = dataList.value;
21215
- const targetList = !typeFlag.value ? [...handleListFormat(hasSelectedList.value, false)] : hasSelectedList.value;
21216
- const targetValueList = !typeFlag.value ? [] : [...handleListFormat(hasSelectedList.value)];
21217
- emit("change", sourceList, targetList, targetValueList);
21218
- };
21219
- const handleListFormat = (list, objectType = true) => {
21220
- const templateList = [];
21221
- if (!list.length) {
21222
- return [];
21223
- }
21224
- const dataList2 = [...list];
21225
- dataList2.forEach((item) => {
21226
- if (objectType) {
21227
- for (const [key, value] of Object.entries(item)) {
21228
- if (key === settingCode.value) {
21229
- templateList.push(value);
21230
- }
21231
- }
21232
- } else {
21233
- templateList.push(item.value);
21234
- }
21197
+ const selectedListSort = computed(() => {
21198
+ return [...selectedList.value].sort((a2, b2) => {
21199
+ const va = a2[sortCode.value];
21200
+ const vb = b2[sortCode.value];
21201
+ return va > vb ? 1 : -1;
21235
21202
  });
21236
- return templateList;
21237
- };
21203
+ });
21238
21204
  const allToRight = () => {
21239
- leftHoverIndex.value = -1;
21240
- const curDisplayDataList = displayDataList.value;
21241
- const selectedList = hasSelectedList.value;
21242
- curDisplayDataList.forEach((transferItem) => {
21243
- selectedList.push(transferItem);
21244
- removeFromDataList(transferItem);
21245
- });
21246
- if (sortList.length === props.sourceList.length) {
21247
- hasSelectedList.value = [...sortDataList(selectedList, sortCode, sortList)];
21248
- } else {
21249
- hasSelectedList.value = [...selectedList];
21250
- }
21251
- handleItemChange();
21205
+ selectList.value = [];
21206
+ selectedList.value = [...sourceData.value];
21207
+ handleEmitUpdateTargetList();
21252
21208
  };
21253
21209
  const allToLeft = () => {
21254
- rightHoverIndex.value = -1;
21255
- const selectedList = hasSelectedList.value;
21256
- const curDataList = dataList.value;
21257
- while (selectedList.length) {
21258
- const transferItem = selectedList.shift();
21259
- curDataList.push(transferItem);
21260
- if (sortList.length === props.sourceList.length) {
21261
- dataList.value = [...sortDataList(curDataList, sortCode, sortList)];
21262
- } else {
21263
- dataList.value = [...curDataList];
21264
- }
21265
- }
21266
- handleItemChange();
21210
+ selectList.value = [...sourceData.value];
21211
+ selectedList.value = [];
21212
+ handleEmitUpdateTargetList();
21213
+ };
21214
+ const handleItemClick = (itemKey, isLeft) => {
21215
+ const from = isLeft ? selectList : selectedList;
21216
+ const to = isLeft ? selectedList : selectList;
21217
+ const index = from.value.findIndex((item) => item[settingCode.value] === itemKey);
21218
+ to.value.push(...from.value.splice(index, 1));
21219
+ handleEmitUpdateTargetList();
21220
+ };
21221
+ const handleEmitUpdateTargetList = () => {
21222
+ const restList = selectList.value.map((item) => item[settingCode.value]);
21223
+ const targetList2 = selectedList.value.map((item) => item[settingCode.value]);
21224
+ emit("update:targetList", targetList2);
21225
+ emit("change", sourceListType.value === ArrayType.BASE_ARRAY ? restList : selectList.value.map((v2) => toRaw(v2)), sourceListType.value === ArrayType.BASE_ARRAY ? targetList2 : selectedList.value.map((v2) => toRaw(v2)), targetList2);
21267
21226
  };
21268
- const sortDataList = (list, key, sortList2) => {
21269
- const arr = sortList2;
21270
- return list.sort((a2, b2) => arr.indexOf(a2[key]) - arr.indexOf(b2[key]) >= 0);
21271
- };
21272
- const removeFromDataList = (removeItem) => {
21273
- dataList.value = dataList.value.filter((item) => item[settingCode.value] !== removeItem[settingCode.value]);
21274
- };
21275
- const handleItemMouseEvent = (type, event, isLeft, index) => {
21276
- event.preventDefault();
21277
- event.stopPropagation();
21278
- const hoverIndex = type === "over" ? index : -1;
21279
- isLeft ? leftHoverIndex.value = hoverIndex : rightHoverIndex.value = hoverIndex;
21280
- };
21281
- const handleItemClick = (event, index, isLeft) => {
21282
- event.preventDefault();
21283
- event.stopPropagation();
21284
- isLeft ? leftHoverIndex.value = -1 : rightHoverIndex.value = -1;
21285
- const transferItem = isLeft ? displayDataList.value[index] : hasSelectedList.value.splice(index, 1)[0];
21286
- const selectedList = isLeft ? hasSelectedList.value : dataList.value;
21287
- selectedList.push(transferItem);
21288
- isLeft && removeFromDataList(transferItem);
21289
- const newList = sortList.length === props.sourceList.length ? [...sortDataList(selectedList, sortCode, sortList)] : [...selectedList];
21290
- isLeft ? hasSelectedList.value = [...newList] : dataList.value = [...newList];
21291
- handleItemChange();
21292
- };
21293
- if (typeFlag.value !== "empty") {
21294
- if (!typeFlag.value) {
21295
- generalInit();
21296
- } else {
21297
- init();
21298
- }
21299
- initSort();
21300
- }
21301
21227
  return {
21302
- keyword,
21303
- transferRef,
21304
- dataList,
21228
+ selectSearchQuery,
21229
+ selectListSearch,
21230
+ selectedList,
21231
+ selectListSort,
21232
+ selectedListSort,
21233
+ settingCode,
21234
+ displayCode,
21305
21235
  allToRight,
21306
21236
  allToLeft,
21307
- displayDataList,
21308
- displayCode,
21309
- leftHoverIndex,
21310
- rightHoverIndex,
21311
- handleItemMouseEvent,
21312
- handleItemClick,
21313
- hasSelectedList
21237
+ handleItemClick
21314
21238
  };
21315
21239
  },
21316
21240
  render() {
21317
- const {
21318
- extCls,
21319
- title,
21320
- emptyContent,
21321
- searchable,
21322
- searchPlaceholder
21323
- } = this.$props;
21241
+ const leftList = this.sortable ? this.selectListSort : this.selectListSearch;
21242
+ const rightList = this.sortable ? this.selectedListSort : this.selectedList;
21324
21243
  const getHeaderHtml = (dirct) => {
21325
21244
  var _a, _b;
21326
21245
  const isLeft = dirct === "left-header";
21327
- const titleText = isLeft ? `${(_a = title[0]) != null ? _a : "\u5DE6\u4FA7\u5217\u8868"}` : `${(_b = title[1]) != null ? _b : "\u53F3\u4FA7\u5217\u8868"}`;
21328
- const isDisabled = isLeft ? !this.dataList.length : !this.hasSelectedList.length;
21246
+ const titleText = isLeft ? `${(_a = this.title[0]) != null ? _a : "\u5DE6\u4FA7\u5217\u8868"}` : `${(_b = this.title[1]) != null ? _b : "\u53F3\u4FA7\u5217\u8868"}`;
21247
+ const isDisabled = isLeft ? !leftList.length : !rightList.length;
21329
21248
  const headerClick = () => {
21330
- if (isLeft && this.dataList.length) {
21331
- this.allToRight();
21332
- }
21333
- if (!isLeft && this.hasSelectedList.length) {
21334
- this.allToLeft();
21335
- }
21249
+ if (isDisabled)
21250
+ return;
21251
+ isLeft ? this.allToRight() : this.allToLeft();
21336
21252
  };
21337
21253
  return this.$slots[dirct] ? createVNode("div", {
21338
21254
  "class": "slot-header"
21339
21255
  }, [this.$slots[dirct]()]) : createVNode("div", {
21340
21256
  "class": "header"
21341
- }, [`${titleText}\uFF08\u5171${this.dataList.length}\u6761\uFF09`, createVNode("span", {
21257
+ }, [`${titleText}\uFF08\u5171${isLeft ? leftList.length : rightList.length}\u6761\uFF09`, createVNode("span", {
21342
21258
  "class": {
21343
21259
  disabled: isDisabled
21344
21260
  },
@@ -21348,20 +21264,19 @@ var Component$4 = defineComponent({
21348
21264
  const getEmptyHtml = (dirct) => {
21349
21265
  var _a;
21350
21266
  const isLeft = dirct === "left-empty-content";
21351
- const emptyText = (_a = isLeft ? emptyContent[0] : emptyContent[1]) != null ? _a : isLeft ? "\u65E0\u6570\u636E" : "\u672A\u9009\u62E9\u4EFB\u4F55\u9879";
21267
+ const emptyText = (_a = isLeft ? this.emptyContent[0] : this.emptyContent[1]) != null ? _a : isLeft ? "\u65E0\u6570\u636E" : "\u672A\u9009\u62E9\u4EFB\u4F55\u9879";
21352
21268
  return this.$slots[dirct] ? createVNode("div", null, [this.$slots[dirct]()]) : createVNode("div", {
21353
21269
  "class": "empty"
21354
21270
  }, [emptyText]);
21355
21271
  };
21356
- const getDefaultListHtml = (item, index, isLeft = true) => {
21357
- const hoverIndex = isLeft ? this.leftHoverIndex : this.rightHoverIndex;
21272
+ const getDefaultListHtml = (item, isLeft = true) => {
21358
21273
  return createVNode("div", {
21359
21274
  "class": "item-content"
21360
21275
  }, [createVNode("span", {
21361
21276
  "class": "content-text",
21362
21277
  "title": item[this.displayCode]
21363
21278
  }, [item[this.displayCode]]), createVNode("span", {
21364
- "class": ["icon-wrapper", index === hoverIndex ? "hover" : ""]
21279
+ "class": "icon-wrapper"
21365
21280
  }, [isLeft ? createVNode(arrowsRight, {
21366
21281
  "class": "bk-icon"
21367
21282
  }, null) : createVNode(error, {
@@ -21370,33 +21285,30 @@ var Component$4 = defineComponent({
21370
21285
  };
21371
21286
  const getListContentHtml = (dirct) => {
21372
21287
  const isLeft = dirct === "left";
21373
- const list = isLeft ? this.displayDataList : this.hasSelectedList;
21288
+ const list = isLeft ? leftList : rightList;
21374
21289
  const slotName = isLeft ? "source-option" : "target-option";
21375
21290
  const emptySlotName = isLeft ? "left-empty-content" : "right-empty-content";
21376
21291
  return list.length ? createVNode("ul", {
21377
- "class": ["content", searchable && isLeft ? "is-search" : ""]
21378
- }, [list.map((item, index) => {
21292
+ "class": ["content", this.searchable && isLeft ? "is-search" : ""]
21293
+ }, [list.map((item) => {
21379
21294
  var _a, _b, _c;
21380
21295
  return createVNode("li", {
21381
- "key": index,
21382
- "class": [!!this.$slots[slotName] ? "custom-item" : ""],
21383
- "onClick": (event) => this.handleItemClick(event, index, isLeft),
21384
- "onMouseover": (event) => this.handleItemMouseEvent("over", event, isLeft, index),
21385
- "onMouseleave": (event) => this.handleItemMouseEvent("leave", event, isLeft, index)
21386
- }, [(_c = (_b = (_a = this.$slots)[slotName]) == null ? void 0 : _b.call(_a, item)) != null ? _c : getDefaultListHtml(item, index, isLeft)]);
21296
+ "key": item[this.settingCode],
21297
+ "class": [this.$slots[slotName] ? "custom-item" : ""],
21298
+ "onClick": () => this.handleItemClick(item[this.settingCode], isLeft)
21299
+ }, [(_c = (_b = (_a = this.$slots)[slotName]) == null ? void 0 : _b.call(_a, item)) != null ? _c : getDefaultListHtml(item, isLeft)]);
21387
21300
  })]) : getEmptyHtml(emptySlotName);
21388
21301
  };
21389
21302
  return createVNode("div", {
21390
- "class": ["bk-transfer", extCls],
21391
- "ref": "transferRef"
21303
+ "class": ["bk-transfer", this.extCls]
21392
21304
  }, [createVNode("div", {
21393
21305
  "class": "source-list"
21394
- }, [getHeaderHtml("left-header"), searchable && createVNode(BkInput, {
21395
- "modelValue": this.keyword,
21396
- "onUpdate:modelValue": ($event) => this.keyword = $event,
21306
+ }, [getHeaderHtml("left-header"), this.searchable && createVNode(BkInput, {
21307
+ "modelValue": this.selectSearchQuery,
21308
+ "onUpdate:modelValue": ($event) => this.selectSearchQuery = $event,
21397
21309
  "class": "transfer-search-input",
21398
21310
  "clearable": true,
21399
- "placeholder": searchPlaceholder || "\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u5B57",
21311
+ "placeholder": this.searchPlaceholder || "\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u5B57",
21400
21312
  "type": "search",
21401
21313
  "left-icon": "bk-icon icon-search"
21402
21314
  }, null), getListContentHtml("left")]), createVNode("div", {
@@ -21496,7 +21408,7 @@ const treeProps = {
21496
21408
  draggable: PropTypes.bool.def(false),
21497
21409
  dragSort: PropTypes.bool.def(false),
21498
21410
  selectable: PropTypes.bool.def(true),
21499
- selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null),
21411
+ selected: PropTypes.oneOfType([PropTypes.string, null, PropTypes.number, PropTypes.object]).def(null),
21500
21412
  autoCheckChildren: PropTypes.bool.def(true)
21501
21413
  };
21502
21414
  var useEmpty = (props, {
@@ -22349,7 +22261,19 @@ var useTreeInit = (props) => {
22349
22261
  }
22350
22262
  return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
22351
22263
  }
22264
+ const cachedDefaultVal = {
22265
+ [NODE_ATTRIBUTES.IS_OPEN]: () => false,
22266
+ [NODE_ATTRIBUTES.IS_CHECKED]: () => false,
22267
+ [NODE_ATTRIBUTES.IS_MATCH]: () => true,
22268
+ [NODE_ATTRIBUTES.IS_SELECTED]: (uuid2) => props2.selected === uuid2,
22269
+ [NODE_ATTRIBUTES.IS_CACHED]: () => false,
22270
+ [NODE_ATTRIBUTES.IS_ASYNC]: () => null
22271
+ };
22352
22272
  function getCachedTreeNodeAttr(uuid2, node, cachedAttr, defVal = void 0) {
22273
+ let defaultValue = defVal;
22274
+ if (defVal === void 0 && typeof cachedDefaultVal[cachedAttr] === "function") {
22275
+ defaultValue = cachedDefaultVal[cachedAttr](uuid2, node);
22276
+ }
22353
22277
  const sourceAttr = NODE_SOURCE_ATTRS[cachedAttr];
22354
22278
  if (Object.prototype.hasOwnProperty.call(node, sourceAttr)) {
22355
22279
  return node[sourceAttr];
@@ -22360,27 +22284,15 @@ var useTreeInit = (props) => {
22360
22284
  result = cached[cachedAttr];
22361
22285
  }
22362
22286
  if (result === void 0 || result === null) {
22363
- result = defVal;
22287
+ result = defaultValue;
22364
22288
  }
22365
22289
  return result;
22366
22290
  }
22367
- function isCachedTreeNodeOpened(uuid2, node) {
22368
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_OPEN, false);
22369
- }
22370
- function isCachedTreeNodeChecked(uuid2, node) {
22371
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CHECKED, false);
22372
- }
22373
- function isCachedTreeNodeMatch(uuid2, node) {
22374
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_MATCH, true);
22375
- }
22376
22291
  function isCachedTreeNodeSelected(uuid2, node) {
22377
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_SELECTED, false);
22378
- }
22379
- function isCachedTreeNodeHasCached(uuid2, node) {
22380
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_CACHED, false);
22381
- }
22382
- function isCachedTreeNodeAsync(uuid2, node) {
22383
- return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_ASYNC, null);
22292
+ if (!props2.selectable) {
22293
+ return false;
22294
+ }
22295
+ return getCachedTreeNodeAttr(uuid2, node, NODE_ATTRIBUTES.IS_SELECTED, props2.selected === uuid2);
22384
22296
  }
22385
22297
  function isCachedTreeNodeLoading(uuid2, node) {
22386
22298
  if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.IS_LOADING)) {
@@ -22411,12 +22323,12 @@ var useTreeInit = (props) => {
22411
22323
  [NODE_ATTRIBUTES.PATH]: currentPath,
22412
22324
  [NODE_ATTRIBUTES.IS_ROOT]: parent === null,
22413
22325
  [NODE_ATTRIBUTES.ORDER]: order2,
22414
- [NODE_ATTRIBUTES.IS_SELECTED]: props2.selectable ? isCachedTreeNodeSelected(uuid2, item) : false,
22415
- [NODE_ATTRIBUTES.IS_MATCH]: isCachedTreeNodeMatch(uuid2, item),
22416
- [NODE_ATTRIBUTES.IS_OPEN]: isCachedTreeNodeOpened(uuid2, item),
22417
- [NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
22418
- [NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
22419
- [NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
22326
+ [NODE_ATTRIBUTES.IS_SELECTED]: isCachedTreeNodeSelected(uuid2, item),
22327
+ [NODE_ATTRIBUTES.IS_MATCH]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_MATCH),
22328
+ [NODE_ATTRIBUTES.IS_OPEN]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_OPEN),
22329
+ [NODE_ATTRIBUTES.IS_CHECKED]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_CHECKED),
22330
+ [NODE_ATTRIBUTES.IS_CACHED]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_CACHED),
22331
+ [NODE_ATTRIBUTES.IS_ASYNC]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_ASYNC),
22420
22332
  [NODE_ATTRIBUTES.IS_LOADING]: isCachedTreeNodeLoading(uuid2, item),
22421
22333
  [children]: null
22422
22334
  };
@@ -22730,15 +22642,12 @@ var ComposeFormItem = defineComponent({
22730
22642
  }, childrenArr);
22731
22643
  }
22732
22644
  });
22733
- const formKey$1 = Symbol("form");
22734
- const getFormKey = () => formKey$1;
22735
- const formKey = getFormKey();
22736
22645
  const formProps = {
22737
22646
  formType: PropTypes.oneOf(["default", "vertical"]).def("default"),
22738
22647
  labelWidth: PropTypes.oneOfType([Number, String]),
22739
22648
  labelPosition: PropTypes.oneOf(["left", "center", "right"]),
22740
22649
  model: PropTypes.object,
22741
- rules: PropTypes.array
22650
+ rules: PropTypes.object
22742
22651
  };
22743
22652
  var Form = defineComponent({
22744
22653
  name: "Form",
@@ -22822,9 +22731,9 @@ var Form = defineComponent({
22822
22731
  }, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
22823
22732
  }
22824
22733
  });
22825
- var validator = {
22734
+ var defaultValidator = {
22826
22735
  required: (value) => {
22827
- console.log("required");
22736
+ console.log("required", value, value !== "" && value !== void 0 && value !== null);
22828
22737
  return value !== "" && value !== void 0 && value !== null;
22829
22738
  },
22830
22739
  min: (value, min2) => {
@@ -22842,6 +22751,10 @@ var validator = {
22842
22751
  maxlength: (value, maxlength) => {
22843
22752
  console.log("maxlength");
22844
22753
  return value.length <= maxlength;
22754
+ },
22755
+ pattern: (value, pattern) => {
22756
+ console.log("pattern");
22757
+ return pattern.test(value);
22845
22758
  }
22846
22759
  };
22847
22760
  const formItemProps = {
@@ -22864,35 +22777,35 @@ const getRulesFromProps = (props) => {
22864
22777
  const rules = [];
22865
22778
  if (props.required) {
22866
22779
  rules.push({
22867
- validator: validator.required,
22780
+ validator: defaultValidator.required,
22868
22781
  message: `${props.label}\u4E0D\u80FD\u4E3A\u7A7A`,
22869
22782
  trigger: "blur"
22870
22783
  });
22871
22784
  }
22872
22785
  if (props.email) {
22873
22786
  rules.push({
22874
- validator: validator.email,
22787
+ validator: defaultValidator.email,
22875
22788
  message: `${props.label}\u683C\u5F0F\u4E0D\u6B63\u786E`,
22876
22789
  trigger: "blur"
22877
22790
  });
22878
22791
  }
22879
22792
  if (Number(props.max) > -1) {
22880
22793
  rules.push({
22881
- validator: (value) => validator.max(value, props.max),
22794
+ validator: (value) => defaultValidator.max(value, props.max),
22882
22795
  message: `${props.label}\u6700\u5927\u503C${props.max}`,
22883
22796
  trigger: "blur"
22884
22797
  });
22885
22798
  }
22886
22799
  if (Number(props.min) > -1) {
22887
22800
  rules.push({
22888
- validator: (value) => validator.min(value, props.min),
22801
+ validator: (value) => defaultValidator.min(value, props.min),
22889
22802
  message: `${props.label}\u6700\u5C0F\u503C${props.min}`,
22890
22803
  trigger: "blur"
22891
22804
  });
22892
22805
  }
22893
22806
  if (Number(props.maxlength) > -1) {
22894
22807
  rules.push({
22895
- validator: (value) => validator.maxlength(value, props.maxlength),
22808
+ validator: (value) => defaultValidator.maxlength(value, props.maxlength),
22896
22809
  message: `${props.label}\u6700\u5927\u957F\u5EA6${props.maxlength}`,
22897
22810
  trigger: "blur"
22898
22811
  });
@@ -22900,27 +22813,32 @@ const getRulesFromProps = (props) => {
22900
22813
  return rules;
22901
22814
  };
22902
22815
  const mergeRules = (configRules, propsRules) => {
22903
- const formatConfigRules = configRules.map((rule) => {
22816
+ const formatConfigRules = configRules.reduce((result, rule) => {
22904
22817
  let rulevalidator;
22905
22818
  if (rule.required) {
22906
- rulevalidator = validator.required;
22819
+ rulevalidator = defaultValidator.required;
22907
22820
  } else if (rule.email) {
22908
- rulevalidator = validator.email;
22821
+ rulevalidator = defaultValidator.email;
22909
22822
  } else if (Number(rule.max) > -1) {
22910
- rulevalidator = (value) => validator.max(value, rule.max);
22823
+ rulevalidator = (value) => defaultValidator.max(value, rule.max);
22911
22824
  } else if (Number(rule.min) > -1) {
22912
- rulevalidator = (value) => validator.min(value, rule.max);
22825
+ rulevalidator = (value) => defaultValidator.min(value, rule.max);
22913
22826
  } else if (Number(rule.maxlength) > -1) {
22914
- rulevalidator = (value) => validator.min(value, rule.max);
22827
+ rulevalidator = (value) => defaultValidator.min(value, rule.max);
22828
+ } else if (Object.prototype.toString.call(rule.pattern) === "[object RegExp]") {
22829
+ rulevalidator = (value) => defaultValidator.pattern(value, rule.pattern);
22830
+ } else if (Object.prototype.toString.call(rule.validator) === "[object Function]") {
22831
+ rulevalidator = rule.validator;
22915
22832
  } else {
22916
- rulevalidator = () => true;
22833
+ return result;
22917
22834
  }
22918
- return {
22835
+ result.push({
22919
22836
  validator: rulevalidator,
22920
22837
  message: rule.message,
22921
22838
  trigger: rule.trigger
22922
- };
22923
- });
22839
+ });
22840
+ return result;
22841
+ }, []);
22924
22842
  return [...propsRules, ...formatConfigRules];
22925
22843
  };
22926
22844
  const getTriggerRules = (trigger, rules) => rules.reduce((result, rule) => {
@@ -22947,7 +22865,7 @@ var FormItem = defineComponent({
22947
22865
  isError: false,
22948
22866
  errorMessage: ""
22949
22867
  });
22950
- const form2 = inject(formKey);
22868
+ const form2 = useForm();
22951
22869
  const isForm = Boolean(form2);
22952
22870
  const labelStyles = computed(() => {
22953
22871
  const styles = {
@@ -22980,6 +22898,7 @@ var FormItem = defineComponent({
22980
22898
  rules = props.rules;
22981
22899
  }
22982
22900
  rules = getTriggerRules(trigger, mergeRules(rules, getRulesFromProps(props)));
22901
+ console.log(rules);
22983
22902
  const value = form2.props.model[props.property];
22984
22903
  const doValidate = (() => {
22985
22904
  let stepIndex = -1;
@@ -23013,6 +22932,10 @@ var FormItem = defineComponent({
23013
22932
  state.isError = false;
23014
22933
  state.errorMessage = "";
23015
22934
  };
22935
+ provide(formItemKey, __spreadProps(__spreadValues({}, props), {
22936
+ validate,
22937
+ clearValidate
22938
+ }));
23016
22939
  onMounted(() => {
23017
22940
  if (isForm) {
23018
22941
  form2.register(currentInstance.proxy);