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 { ref, reactive, defineComponent, watch, provide, toRefs, createVNode, onUnmounted, Transition, mergeProps, 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 { ref, reactive, defineComponent, watch, provide, toRefs, createVNode, onUnmounted, Transition, mergeProps, 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 deepAssign(...objects) {
41
41
  const isObject2 = (obj) => obj && typeof obj === "object";
42
42
  return objects.reduce((prev, from) => {
@@ -4089,7 +4089,7 @@ var lodash = { exports: {} };
4089
4089
  var delay = baseRest(function(func, wait, args) {
4090
4090
  return baseDelay(func, toNumber(wait) || 0, args);
4091
4091
  });
4092
- function flip(func) {
4092
+ function flip2(func) {
4093
4093
  return createWrap(func, WRAP_FLIP_FLAG);
4094
4094
  }
4095
4095
  function memoize(func, resolver) {
@@ -5213,7 +5213,7 @@ var lodash = { exports: {} };
5213
5213
  lodash2.flatten = flatten;
5214
5214
  lodash2.flattenDeep = flattenDeep;
5215
5215
  lodash2.flattenDepth = flattenDepth;
5216
- lodash2.flip = flip;
5216
+ lodash2.flip = flip2;
5217
5217
  lodash2.flow = flow;
5218
5218
  lodash2.flowRight = flowRight;
5219
5219
  lodash2.fromPairs = fromPairs;
@@ -6006,18 +6006,12 @@ const flexibleOverlayProps = {
6006
6006
  clickEventBubble: {
6007
6007
  type: Boolean,
6008
6008
  default: false
6009
+ },
6010
+ fitOriginWidth: {
6011
+ type: Boolean,
6012
+ default: false
6009
6013
  }
6010
6014
  };
6011
- function getScrollParent(element) {
6012
- const overflowRegex = /(auto|scroll|hidden)/;
6013
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
6014
- const style = window.getComputedStyle(parent);
6015
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
6016
- return parent;
6017
- }
6018
- }
6019
- return window;
6020
- }
6021
6015
  function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
6022
6016
  let { x, y } = point;
6023
6017
  if (!isArrowCenter) {
@@ -6038,9 +6032,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
6038
6032
  return { x, y };
6039
6033
  }
6040
6034
  function useOverlay(props, emit) {
6035
+ const { fitOriginWidth, position, showArrow } = toRefs(props);
6041
6036
  const overlayRef = ref();
6042
6037
  const arrowRef = ref();
6043
- let originParent = null;
6038
+ const overlayWidth = ref(0);
6039
+ let originObserver;
6040
+ const styles = computed(() => {
6041
+ if (fitOriginWidth.value) {
6042
+ return { width: overlayWidth.value + "px" };
6043
+ } else {
6044
+ return {};
6045
+ }
6046
+ });
6044
6047
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
6045
6048
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
6046
6049
  const staticSide = {
@@ -6061,54 +6064,67 @@ function useOverlay(props, emit) {
6061
6064
  const hostEl = props.origin;
6062
6065
  const overlayEl = unref(overlayRef.value);
6063
6066
  const arrowEl = unref(arrowRef.value);
6064
- const middleware = [
6065
- offset(props.offset),
6066
- autoPlacement({
6067
- alignment: props.align,
6068
- allowedPlacements: props.position
6069
- })
6070
- ];
6071
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
6072
- props.shiftOffset !== void 0 && middleware.push(shift());
6073
- if (!overlayEl) {
6074
- return;
6067
+ const [mainPosition, ...fallbackPosition] = position.value;
6068
+ const middleware = [offset(props.offset)];
6069
+ middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
6070
+ if (showArrow.value) {
6071
+ middleware.push(arrow({ element: arrowRef.value }));
6075
6072
  }
6076
6073
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
6077
6074
  strategy: "fixed",
6075
+ placement: mainPosition,
6078
6076
  middleware
6079
6077
  });
6080
6078
  let applyX = x;
6081
6079
  let applyY = y;
6082
- if (props.shiftOffset !== void 0) {
6083
- const { x: shiftX, y: shiftY } = middlewareData.shift;
6084
- shiftX < 0 && (applyX -= props.shiftOffset);
6085
- shiftX > 0 && (applyX += props.shiftOffset);
6086
- shiftY < 0 && (applyY -= props.shiftOffset);
6087
- shiftY > 0 && (applyY += props.shiftOffset);
6088
- }
6089
6080
  emit("positionChange", placement);
6090
6081
  Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
6091
6082
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
6092
6083
  };
6084
+ const scrollCallback = (e) => {
6085
+ var _a, _b;
6086
+ const scrollElement = e.target;
6087
+ if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
6088
+ updatePosition();
6089
+ }
6090
+ };
6091
+ const updateWidth = (originEl) => {
6092
+ overlayWidth.value = originEl.getBoundingClientRect().width;
6093
+ updatePosition();
6094
+ };
6095
+ const observeOrigin = () => {
6096
+ var _a, _b;
6097
+ if (fitOriginWidth.value && typeof window !== "undefined") {
6098
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
6099
+ if (originEl) {
6100
+ originObserver = new window.ResizeObserver(() => updateWidth(originEl));
6101
+ originObserver.observe(originEl);
6102
+ }
6103
+ }
6104
+ };
6105
+ const unobserveOrigin = () => {
6106
+ var _a, _b;
6107
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
6108
+ originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
6109
+ };
6093
6110
  watch(() => props.modelValue, () => {
6094
6111
  if (props.modelValue && props.origin) {
6095
- originParent = getScrollParent(props.origin);
6096
6112
  nextTick(updatePosition);
6097
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
6098
- originParent !== window && window.addEventListener("scroll", updatePosition);
6113
+ window.addEventListener("scroll", scrollCallback, true);
6099
6114
  window.addEventListener("resize", updatePosition);
6115
+ observeOrigin();
6100
6116
  } else {
6101
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
6102
- originParent !== window && window.removeEventListener("scroll", updatePosition);
6117
+ window.removeEventListener("scroll", scrollCallback, true);
6103
6118
  window.removeEventListener("resize", updatePosition);
6119
+ unobserveOrigin();
6104
6120
  }
6105
6121
  });
6106
6122
  onUnmounted(() => {
6107
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
6108
- originParent !== window && window.removeEventListener("scroll", updatePosition);
6123
+ window.removeEventListener("scroll", scrollCallback, true);
6109
6124
  window.removeEventListener("resize", updatePosition);
6125
+ unobserveOrigin();
6110
6126
  });
6111
- return { arrowRef, overlayRef, updatePosition };
6127
+ return { arrowRef, overlayRef, styles, updatePosition };
6112
6128
  }
6113
6129
  var flexibleOverlay = "";
6114
6130
  const FlexibleOverlay = defineComponent({
@@ -6129,6 +6145,7 @@ const FlexibleOverlay = defineComponent({
6129
6145
  const {
6130
6146
  arrowRef,
6131
6147
  overlayRef,
6148
+ styles,
6132
6149
  updatePosition
6133
6150
  } = useOverlay(props, emit);
6134
6151
  expose({
@@ -6138,7 +6155,8 @@ const FlexibleOverlay = defineComponent({
6138
6155
  var _a;
6139
6156
  return props.modelValue && createVNode("div", mergeProps({
6140
6157
  "ref": overlayRef,
6141
- "class": ns2.b()
6158
+ "class": ns2.b(),
6159
+ "style": styles.value
6142
6160
  }, attrs, {
6143
6161
  "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
6144
6162
  "onPointerup": withModifiers(() => ({}), ["stop"])
@@ -8415,6 +8433,13 @@ const selectProps = {
8415
8433
  showGlowStyle: {
8416
8434
  type: Boolean,
8417
8435
  default: true
8436
+ },
8437
+ menuClass: {
8438
+ type: String,
8439
+ default: ""
8440
+ },
8441
+ maxLength: {
8442
+ type: Number
8418
8443
  }
8419
8444
  };
8420
8445
  const optionProps = {
@@ -9232,6 +9257,7 @@ function useSelectContent() {
9232
9257
  }
9233
9258
  };
9234
9259
  return {
9260
+ select: select2,
9235
9261
  searchQuery,
9236
9262
  selectedData,
9237
9263
  isSelectDisable,
@@ -9267,6 +9293,7 @@ var SelectContent = defineComponent({
9267
9293
  const multipleCls = ns2.e("multiple");
9268
9294
  const multipleInputCls = ns2.em("multiple", "input");
9269
9295
  const {
9296
+ select: select2,
9270
9297
  searchQuery,
9271
9298
  selectedData,
9272
9299
  isSelectDisable,
@@ -9330,6 +9357,7 @@ var SelectContent = defineComponent({
9330
9357
  "placeholder": placeholder.value,
9331
9358
  "readonly": isReadOnly.value,
9332
9359
  "disabled": isSelectDisable.value,
9360
+ "maxlength": select2 == null ? void 0 : select2.maxLength,
9333
9361
  "onInput": queryFilter,
9334
9362
  "onFocus": onFocus,
9335
9363
  "onBlur": onBlur
@@ -9341,6 +9369,7 @@ var SelectContent = defineComponent({
9341
9369
  "placeholder": placeholder.value,
9342
9370
  "readonly": isReadOnly.value,
9343
9371
  "disabled": isSelectDisable.value,
9372
+ "maxlength": select2 == null ? void 0 : select2.maxLength,
9344
9373
  "onFocus": onFocus,
9345
9374
  "onBlur": onBlur,
9346
9375
  "onInput": queryFilter
@@ -9639,7 +9668,6 @@ var Select = defineComponent({
9639
9668
  const isRender = ref(false);
9640
9669
  const currentPosition = ref("bottom");
9641
9670
  const position = ref(["bottom-start", "top-start"]);
9642
- const dropdownWidth = ref("0");
9643
9671
  const handlePositionChange = (pos) => {
9644
9672
  currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
9645
9673
  };
@@ -9647,14 +9675,9 @@ var Select = defineComponent({
9647
9675
  transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
9648
9676
  "z-index": "var(--devui-z-index-dropdown, 1052)"
9649
9677
  }));
9650
- const updateDropdownWidth = () => {
9651
- var _a;
9652
- dropdownWidth.value = ((_a = originRef == null ? void 0 : originRef.value) == null ? void 0 : _a.clientWidth) ? originRef.value.clientWidth + "px" : "100%";
9653
- };
9654
9678
  watch(selectRef, (val) => {
9655
9679
  if (val) {
9656
9680
  originRef.value = val.$el;
9657
- updateDropdownWidth();
9658
9681
  }
9659
9682
  });
9660
9683
  const scrollToBottom = () => {
@@ -9666,15 +9689,11 @@ var Select = defineComponent({
9666
9689
  };
9667
9690
  onMounted(() => {
9668
9691
  isRender.value = true;
9669
- updateDropdownWidth();
9670
- window.addEventListener("resize", updateDropdownWidth);
9671
9692
  nextTick(() => {
9672
- dropdownContainer.value.addEventListener("scroll", scrollToBottom);
9693
+ var _a;
9694
+ (_a = dropdownContainer.value) == null ? void 0 : _a.addEventListener("scroll", scrollToBottom);
9673
9695
  });
9674
9696
  });
9675
- onUnmounted(() => {
9676
- window.removeEventListener("resize", updateDropdownWidth);
9677
- });
9678
9697
  provide(SELECT_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
9679
9698
  selectDisabled,
9680
9699
  selectSize,
@@ -9710,17 +9729,16 @@ var Select = defineComponent({
9710
9729
  "origin": originRef.value,
9711
9730
  "align": "start",
9712
9731
  "offset": 4,
9732
+ "fit-origin-width": true,
9713
9733
  "position": position.value,
9714
9734
  "onPositionChange": handlePositionChange,
9715
- "style": styles.value
9735
+ "style": styles.value,
9736
+ "class": props.menuClass
9716
9737
  }, {
9717
9738
  default: () => {
9718
9739
  var _a, _b, _c, _d;
9719
9740
  return [withDirectives(createVNode("div", {
9720
- "class": dropdownCls,
9721
- "style": {
9722
- width: `${dropdownWidth.value}`
9723
- }
9741
+ "class": dropdownCls
9724
9742
  }, [withDirectives(createVNode("ul", {
9725
9743
  "class": listCls,
9726
9744
  "ref": dropdownContainer