vue-devui 1.6.14 → 1.6.16

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 (75) hide show
  1. package/auto-complete/index.es.js +60 -42
  2. package/auto-complete/index.umd.js +13 -13
  3. package/breadcrumb/index.es.js +57 -39
  4. package/breadcrumb/index.umd.js +1 -1
  5. package/category-search/index.es.js +93 -44
  6. package/category-search/index.umd.js +21 -21
  7. package/checkbox/index.es.js +60 -42
  8. package/checkbox/index.umd.js +18 -18
  9. package/code-review/index.es.js +60 -42
  10. package/code-review/index.umd.js +20 -20
  11. package/data-grid/index.es.js +60 -42
  12. package/data-grid/index.umd.js +15 -15
  13. package/date-picker-pro/index.es.js +60 -42
  14. package/date-picker-pro/index.umd.js +13 -13
  15. package/dropdown/index.es.js +57 -39
  16. package/dropdown/index.umd.js +1 -1
  17. package/editable-select/index.es.js +66 -43
  18. package/editable-select/index.umd.js +10 -10
  19. package/editor-md/index.es.js +69 -44
  20. package/editor-md/index.umd.js +28 -28
  21. package/form/index.es.js +60 -42
  22. package/form/index.umd.js +17 -17
  23. package/input/index.es.js +59 -41
  24. package/input/index.umd.js +20 -20
  25. package/input-number/index.es.js +60 -42
  26. package/input-number/index.umd.js +19 -19
  27. package/mention/index.es.js +60 -42
  28. package/mention/index.umd.js +17 -17
  29. package/message/index.es.js +13 -13
  30. package/message/index.umd.js +1 -1
  31. package/modal/index.es.js +57 -39
  32. package/modal/index.umd.js +2 -2
  33. package/overlay/index.es.js +58 -40
  34. package/overlay/index.umd.js +1 -1
  35. package/package.json +3 -2
  36. package/pagination/index.es.js +77 -59
  37. package/pagination/index.umd.js +18 -18
  38. package/pagination/style.css +1 -1
  39. package/popover/index.es.js +60 -42
  40. package/popover/index.umd.js +15 -15
  41. package/radio/index.es.js +60 -42
  42. package/radio/index.umd.js +16 -16
  43. package/search/index.es.js +60 -42
  44. package/search/index.umd.js +16 -16
  45. package/select/index.es.js +77 -59
  46. package/select/index.umd.js +20 -20
  47. package/select/style.css +1 -1
  48. package/splitter/index.es.js +60 -42
  49. package/splitter/index.umd.js +14 -14
  50. package/style.css +1 -1
  51. package/switch/index.es.js +60 -42
  52. package/switch/index.umd.js +17 -17
  53. package/table/index.es.js +59 -41
  54. package/table/index.umd.js +16 -16
  55. package/textarea/index.es.js +60 -42
  56. package/textarea/index.umd.js +19 -19
  57. package/time-picker/index.es.js +59 -41
  58. package/time-picker/index.umd.js +14 -14
  59. package/time-select/index.es.js +77 -59
  60. package/time-select/index.umd.js +18 -18
  61. package/time-select/style.css +1 -1
  62. package/tooltip/index.es.js +60 -42
  63. package/tooltip/index.umd.js +15 -15
  64. package/tree/index.es.js +59 -41
  65. package/tree/index.umd.js +14 -14
  66. package/types/category-search/src/category-search-types.d.ts +5 -0
  67. package/types/editable-select/src/editable-select-types.d.ts +3 -0
  68. package/types/overlay/src/flexible-overlay/flexible-overlay-types.d.ts +5 -6
  69. package/types/overlay/src/flexible-overlay/index.d.ts +9 -0
  70. package/types/overlay/src/flexible-overlay/use-flexible-overlay.d.ts +11 -2
  71. package/types/select/src/composables/use-select-content.d.ts +21 -2
  72. package/types/select/src/select-types.d.ts +7 -44
  73. package/types/select/src/use-select.d.ts +26 -2
  74. package/vue-devui.es.js +138 -77
  75. package/vue-devui.umd.js +74 -74
@@ -33,10 +33,10 @@ var __publicField = (obj, key, value) => {
33
33
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
34
  return value;
35
35
  };
36
- import { defineComponent, watch, provide, reactive, toRefs, createVNode, onUnmounted, Transition, mergeProps, ref, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, computed, onMounted, Teleport, createTextVNode, onBeforeUnmount, toRef, onBeforeMount, vShow, resolveComponent, getCurrentInstance, render, resolveDirective } from "vue";
36
+ import { defineComponent, watch, provide, reactive, toRefs, createVNode, onUnmounted, Transition, mergeProps, ref, computed, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, onMounted, Teleport, createTextVNode, onBeforeUnmount, toRef, onBeforeMount, vShow, resolveComponent, getCurrentInstance, render, resolveDirective } from "vue";
37
37
  import { onClickOutside } from "@vueuse/core";
38
38
  import "clipboard";
39
- import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
39
+ import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
40
40
  function className(classStr, classOpt) {
41
41
  let classname = classStr;
42
42
  if (typeof classOpt === "object") {
@@ -3916,7 +3916,7 @@ var lodash = { exports: {} };
3916
3916
  var delay = baseRest(function(func, wait, args) {
3917
3917
  return baseDelay(func, toNumber(wait) || 0, args);
3918
3918
  });
3919
- function flip(func) {
3919
+ function flip2(func) {
3920
3920
  return createWrap(func, WRAP_FLIP_FLAG);
3921
3921
  }
3922
3922
  function memoize(func, resolver) {
@@ -5040,7 +5040,7 @@ var lodash = { exports: {} };
5040
5040
  lodash2.flatten = flatten;
5041
5041
  lodash2.flattenDeep = flattenDeep;
5042
5042
  lodash2.flattenDepth = flattenDepth;
5043
- lodash2.flip = flip;
5043
+ lodash2.flip = flip2;
5044
5044
  lodash2.flow = flow;
5045
5045
  lodash2.flowRight = flowRight;
5046
5046
  lodash2.fromPairs = fromPairs;
@@ -5843,18 +5843,12 @@ const flexibleOverlayProps = {
5843
5843
  clickEventBubble: {
5844
5844
  type: Boolean,
5845
5845
  default: false
5846
+ },
5847
+ fitOriginWidth: {
5848
+ type: Boolean,
5849
+ default: false
5846
5850
  }
5847
5851
  };
5848
- function getScrollParent(element) {
5849
- const overflowRegex = /(auto|scroll|hidden)/;
5850
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
5851
- const style = window.getComputedStyle(parent);
5852
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
5853
- return parent;
5854
- }
5855
- }
5856
- return window;
5857
- }
5858
5852
  function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
5859
5853
  let { x, y } = point;
5860
5854
  if (!isArrowCenter) {
@@ -5875,9 +5869,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
5875
5869
  return { x, y };
5876
5870
  }
5877
5871
  function useOverlay(props, emit) {
5872
+ const { fitOriginWidth, position, showArrow } = toRefs(props);
5878
5873
  const overlayRef = ref();
5879
5874
  const arrowRef = ref();
5880
- let originParent = null;
5875
+ const overlayWidth = ref(0);
5876
+ let originObserver;
5877
+ const styles = computed(() => {
5878
+ if (fitOriginWidth.value) {
5879
+ return { width: overlayWidth.value + "px" };
5880
+ } else {
5881
+ return {};
5882
+ }
5883
+ });
5881
5884
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
5882
5885
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
5883
5886
  const staticSide = {
@@ -5898,54 +5901,67 @@ function useOverlay(props, emit) {
5898
5901
  const hostEl = props.origin;
5899
5902
  const overlayEl = unref(overlayRef.value);
5900
5903
  const arrowEl = unref(arrowRef.value);
5901
- const middleware = [
5902
- offset(props.offset),
5903
- autoPlacement({
5904
- alignment: props.align,
5905
- allowedPlacements: props.position
5906
- })
5907
- ];
5908
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
5909
- props.shiftOffset !== void 0 && middleware.push(shift());
5910
- if (!overlayEl) {
5911
- return;
5904
+ const [mainPosition, ...fallbackPosition] = position.value;
5905
+ const middleware = [offset(props.offset)];
5906
+ middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
5907
+ if (showArrow.value) {
5908
+ middleware.push(arrow({ element: arrowRef.value }));
5912
5909
  }
5913
5910
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
5914
5911
  strategy: "fixed",
5912
+ placement: mainPosition,
5915
5913
  middleware
5916
5914
  });
5917
5915
  let applyX = x;
5918
5916
  let applyY = y;
5919
- if (props.shiftOffset !== void 0) {
5920
- const { x: shiftX, y: shiftY } = middlewareData.shift;
5921
- shiftX < 0 && (applyX -= props.shiftOffset);
5922
- shiftX > 0 && (applyX += props.shiftOffset);
5923
- shiftY < 0 && (applyY -= props.shiftOffset);
5924
- shiftY > 0 && (applyY += props.shiftOffset);
5925
- }
5926
5917
  emit("positionChange", placement);
5927
5918
  Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
5928
5919
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
5929
5920
  };
5921
+ const scrollCallback = (e) => {
5922
+ var _a, _b;
5923
+ const scrollElement = e.target;
5924
+ if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
5925
+ updatePosition();
5926
+ }
5927
+ };
5928
+ const updateWidth = (originEl) => {
5929
+ overlayWidth.value = originEl.getBoundingClientRect().width;
5930
+ updatePosition();
5931
+ };
5932
+ const observeOrigin = () => {
5933
+ var _a, _b;
5934
+ if (fitOriginWidth.value && typeof window !== "undefined") {
5935
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
5936
+ if (originEl) {
5937
+ originObserver = new window.ResizeObserver(() => updateWidth(originEl));
5938
+ originObserver.observe(originEl);
5939
+ }
5940
+ }
5941
+ };
5942
+ const unobserveOrigin = () => {
5943
+ var _a, _b;
5944
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
5945
+ originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
5946
+ };
5930
5947
  watch(() => props.modelValue, () => {
5931
5948
  if (props.modelValue && props.origin) {
5932
- originParent = getScrollParent(props.origin);
5933
5949
  nextTick(updatePosition);
5934
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
5935
- originParent !== window && window.addEventListener("scroll", updatePosition);
5950
+ window.addEventListener("scroll", scrollCallback, true);
5936
5951
  window.addEventListener("resize", updatePosition);
5952
+ observeOrigin();
5937
5953
  } else {
5938
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
5939
- originParent !== window && window.removeEventListener("scroll", updatePosition);
5954
+ window.removeEventListener("scroll", scrollCallback, true);
5940
5955
  window.removeEventListener("resize", updatePosition);
5956
+ unobserveOrigin();
5941
5957
  }
5942
5958
  });
5943
5959
  onUnmounted(() => {
5944
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
5945
- originParent !== window && window.removeEventListener("scroll", updatePosition);
5960
+ window.removeEventListener("scroll", scrollCallback, true);
5946
5961
  window.removeEventListener("resize", updatePosition);
5962
+ unobserveOrigin();
5947
5963
  });
5948
- return { arrowRef, overlayRef, updatePosition };
5964
+ return { arrowRef, overlayRef, styles, updatePosition };
5949
5965
  }
5950
5966
  var flexibleOverlay = "";
5951
5967
  const FlexibleOverlay = defineComponent({
@@ -5966,6 +5982,7 @@ const FlexibleOverlay = defineComponent({
5966
5982
  const {
5967
5983
  arrowRef,
5968
5984
  overlayRef,
5985
+ styles,
5969
5986
  updatePosition
5970
5987
  } = useOverlay(props, emit);
5971
5988
  expose({
@@ -5975,7 +5992,8 @@ const FlexibleOverlay = defineComponent({
5975
5992
  var _a;
5976
5993
  return props.modelValue && createVNode("div", mergeProps({
5977
5994
  "ref": overlayRef,
5978
- "class": ns2.b()
5995
+ "class": ns2.b(),
5996
+ "style": styles.value
5979
5997
  }, attrs, {
5980
5998
  "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
5981
5999
  "onPointerup": withModifiers(() => ({}), ["stop"])
@@ -8252,6 +8270,13 @@ const selectProps = {
8252
8270
  showGlowStyle: {
8253
8271
  type: Boolean,
8254
8272
  default: true
8273
+ },
8274
+ menuClass: {
8275
+ type: String,
8276
+ default: ""
8277
+ },
8278
+ maxLength: {
8279
+ type: Number
8255
8280
  }
8256
8281
  };
8257
8282
  const optionProps = {
@@ -9242,6 +9267,7 @@ function useSelectContent() {
9242
9267
  }
9243
9268
  };
9244
9269
  return {
9270
+ select: select2,
9245
9271
  searchQuery,
9246
9272
  selectedData,
9247
9273
  isSelectDisable,
@@ -9277,6 +9303,7 @@ var SelectContent = defineComponent({
9277
9303
  const multipleCls = ns2.e("multiple");
9278
9304
  const multipleInputCls = ns2.em("multiple", "input");
9279
9305
  const {
9306
+ select: select2,
9280
9307
  searchQuery,
9281
9308
  selectedData,
9282
9309
  isSelectDisable,
@@ -9340,6 +9367,7 @@ var SelectContent = defineComponent({
9340
9367
  "placeholder": placeholder.value,
9341
9368
  "readonly": isReadOnly.value,
9342
9369
  "disabled": isSelectDisable.value,
9370
+ "maxlength": select2 == null ? void 0 : select2.maxLength,
9343
9371
  "onInput": queryFilter,
9344
9372
  "onFocus": onFocus,
9345
9373
  "onBlur": onBlur
@@ -9351,6 +9379,7 @@ var SelectContent = defineComponent({
9351
9379
  "placeholder": placeholder.value,
9352
9380
  "readonly": isReadOnly.value,
9353
9381
  "disabled": isSelectDisable.value,
9382
+ "maxlength": select2 == null ? void 0 : select2.maxLength,
9354
9383
  "onFocus": onFocus,
9355
9384
  "onBlur": onBlur,
9356
9385
  "onInput": queryFilter
@@ -9649,7 +9678,6 @@ var Select = defineComponent({
9649
9678
  const isRender = ref(false);
9650
9679
  const currentPosition = ref("bottom");
9651
9680
  const position = ref(["bottom-start", "top-start"]);
9652
- const dropdownWidth = ref("0");
9653
9681
  const handlePositionChange = (pos) => {
9654
9682
  currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
9655
9683
  };
@@ -9657,14 +9685,9 @@ var Select = defineComponent({
9657
9685
  transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
9658
9686
  "z-index": "var(--devui-z-index-dropdown, 1052)"
9659
9687
  }));
9660
- const updateDropdownWidth = () => {
9661
- var _a;
9662
- dropdownWidth.value = ((_a = originRef == null ? void 0 : originRef.value) == null ? void 0 : _a.clientWidth) ? originRef.value.clientWidth + "px" : "100%";
9663
- };
9664
9688
  watch(selectRef, (val) => {
9665
9689
  if (val) {
9666
9690
  originRef.value = val.$el;
9667
- updateDropdownWidth();
9668
9691
  }
9669
9692
  });
9670
9693
  const scrollToBottom = () => {
@@ -9676,15 +9699,11 @@ var Select = defineComponent({
9676
9699
  };
9677
9700
  onMounted(() => {
9678
9701
  isRender.value = true;
9679
- updateDropdownWidth();
9680
- window.addEventListener("resize", updateDropdownWidth);
9681
9702
  nextTick(() => {
9682
- dropdownContainer.value.addEventListener("scroll", scrollToBottom);
9703
+ var _a;
9704
+ (_a = dropdownContainer.value) == null ? void 0 : _a.addEventListener("scroll", scrollToBottom);
9683
9705
  });
9684
9706
  });
9685
- onUnmounted(() => {
9686
- window.removeEventListener("resize", updateDropdownWidth);
9687
- });
9688
9707
  provide(SELECT_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
9689
9708
  selectDisabled,
9690
9709
  selectSize,
@@ -9720,17 +9739,16 @@ var Select = defineComponent({
9720
9739
  "origin": originRef.value,
9721
9740
  "align": "start",
9722
9741
  "offset": 4,
9742
+ "fit-origin-width": true,
9723
9743
  "position": position.value,
9724
9744
  "onPositionChange": handlePositionChange,
9725
- "style": styles.value
9745
+ "style": styles.value,
9746
+ "class": props.menuClass
9726
9747
  }, {
9727
9748
  default: () => {
9728
9749
  var _a, _b, _c, _d;
9729
9750
  return [withDirectives(createVNode("div", {
9730
- "class": dropdownCls,
9731
- "style": {
9732
- width: `${dropdownWidth.value}`
9733
- }
9751
+ "class": dropdownCls
9734
9752
  }, [withDirectives(createVNode("ul", {
9735
9753
  "class": listCls,
9736
9754
  "ref": dropdownContainer