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, shallowRef, resolveDynamicComponent, getCurrentInstance, resolveDirective, onBeforeMount, isVNode, onUpdated, toRaw, watchEffect, render, resolveComponent, vShow, toRef, renderSlot, useSlots } 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, shallowRef, resolveDynamicComponent, getCurrentInstance, resolveDirective, onBeforeMount, isVNode, onUpdated, toRaw, watchEffect, render, resolveComponent, vShow, toRef, renderSlot, useSlots } 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
  const datePickerProCommonProps = {
41
41
  format: {
42
42
  type: String
@@ -4314,7 +4314,7 @@ var lodash = { exports: {} };
4314
4314
  var delay = baseRest(function(func, wait, args) {
4315
4315
  return baseDelay(func, toNumber(wait) || 0, args);
4316
4316
  });
4317
- function flip(func) {
4317
+ function flip2(func) {
4318
4318
  return createWrap(func, WRAP_FLIP_FLAG);
4319
4319
  }
4320
4320
  function memoize(func, resolver) {
@@ -5438,7 +5438,7 @@ var lodash = { exports: {} };
5438
5438
  lodash2.flatten = flatten;
5439
5439
  lodash2.flattenDeep = flattenDeep;
5440
5440
  lodash2.flattenDepth = flattenDepth;
5441
- lodash2.flip = flip;
5441
+ lodash2.flip = flip2;
5442
5442
  lodash2.flow = flow;
5443
5443
  lodash2.flowRight = flowRight;
5444
5444
  lodash2.fromPairs = fromPairs;
@@ -6144,18 +6144,12 @@ const flexibleOverlayProps = {
6144
6144
  clickEventBubble: {
6145
6145
  type: Boolean,
6146
6146
  default: false
6147
+ },
6148
+ fitOriginWidth: {
6149
+ type: Boolean,
6150
+ default: false
6147
6151
  }
6148
6152
  };
6149
- function getScrollParent(element) {
6150
- const overflowRegex = /(auto|scroll|hidden)/;
6151
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
6152
- const style = window.getComputedStyle(parent);
6153
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
6154
- return parent;
6155
- }
6156
- }
6157
- return window;
6158
- }
6159
6153
  function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
6160
6154
  let { x, y } = point;
6161
6155
  if (!isArrowCenter) {
@@ -6176,9 +6170,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
6176
6170
  return { x, y };
6177
6171
  }
6178
6172
  function useOverlay(props, emit) {
6173
+ const { fitOriginWidth, position, showArrow } = toRefs(props);
6179
6174
  const overlayRef = ref();
6180
6175
  const arrowRef = ref();
6181
- let originParent = null;
6176
+ const overlayWidth = ref(0);
6177
+ let originObserver;
6178
+ const styles = computed(() => {
6179
+ if (fitOriginWidth.value) {
6180
+ return { width: overlayWidth.value + "px" };
6181
+ } else {
6182
+ return {};
6183
+ }
6184
+ });
6182
6185
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
6183
6186
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
6184
6187
  const staticSide = {
@@ -6199,54 +6202,67 @@ function useOverlay(props, emit) {
6199
6202
  const hostEl = props.origin;
6200
6203
  const overlayEl = unref(overlayRef.value);
6201
6204
  const arrowEl = unref(arrowRef.value);
6202
- const middleware = [
6203
- offset(props.offset),
6204
- autoPlacement({
6205
- alignment: props.align,
6206
- allowedPlacements: props.position
6207
- })
6208
- ];
6209
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
6210
- props.shiftOffset !== void 0 && middleware.push(shift());
6211
- if (!overlayEl) {
6212
- return;
6205
+ const [mainPosition, ...fallbackPosition] = position.value;
6206
+ const middleware = [offset(props.offset)];
6207
+ middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
6208
+ if (showArrow.value) {
6209
+ middleware.push(arrow({ element: arrowRef.value }));
6213
6210
  }
6214
6211
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
6215
6212
  strategy: "fixed",
6213
+ placement: mainPosition,
6216
6214
  middleware
6217
6215
  });
6218
6216
  let applyX = x;
6219
6217
  let applyY = y;
6220
- if (props.shiftOffset !== void 0) {
6221
- const { x: shiftX, y: shiftY } = middlewareData.shift;
6222
- shiftX < 0 && (applyX -= props.shiftOffset);
6223
- shiftX > 0 && (applyX += props.shiftOffset);
6224
- shiftY < 0 && (applyY -= props.shiftOffset);
6225
- shiftY > 0 && (applyY += props.shiftOffset);
6226
- }
6227
6218
  emit("positionChange", placement);
6228
6219
  Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
6229
6220
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
6230
6221
  };
6222
+ const scrollCallback = (e) => {
6223
+ var _a, _b;
6224
+ const scrollElement = e.target;
6225
+ if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
6226
+ updatePosition();
6227
+ }
6228
+ };
6229
+ const updateWidth = (originEl) => {
6230
+ overlayWidth.value = originEl.getBoundingClientRect().width;
6231
+ updatePosition();
6232
+ };
6233
+ const observeOrigin = () => {
6234
+ var _a, _b;
6235
+ if (fitOriginWidth.value && typeof window !== "undefined") {
6236
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
6237
+ if (originEl) {
6238
+ originObserver = new window.ResizeObserver(() => updateWidth(originEl));
6239
+ originObserver.observe(originEl);
6240
+ }
6241
+ }
6242
+ };
6243
+ const unobserveOrigin = () => {
6244
+ var _a, _b;
6245
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
6246
+ originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
6247
+ };
6231
6248
  watch(() => props.modelValue, () => {
6232
6249
  if (props.modelValue && props.origin) {
6233
- originParent = getScrollParent(props.origin);
6234
6250
  nextTick(updatePosition);
6235
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
6236
- originParent !== window && window.addEventListener("scroll", updatePosition);
6251
+ window.addEventListener("scroll", scrollCallback, true);
6237
6252
  window.addEventListener("resize", updatePosition);
6253
+ observeOrigin();
6238
6254
  } else {
6239
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
6240
- originParent !== window && window.removeEventListener("scroll", updatePosition);
6255
+ window.removeEventListener("scroll", scrollCallback, true);
6241
6256
  window.removeEventListener("resize", updatePosition);
6257
+ unobserveOrigin();
6242
6258
  }
6243
6259
  });
6244
6260
  onUnmounted(() => {
6245
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
6246
- originParent !== window && window.removeEventListener("scroll", updatePosition);
6261
+ window.removeEventListener("scroll", scrollCallback, true);
6247
6262
  window.removeEventListener("resize", updatePosition);
6263
+ unobserveOrigin();
6248
6264
  });
6249
- return { arrowRef, overlayRef, updatePosition };
6265
+ return { arrowRef, overlayRef, styles, updatePosition };
6250
6266
  }
6251
6267
  var flexibleOverlay = "";
6252
6268
  const FlexibleOverlay = defineComponent({
@@ -6267,6 +6283,7 @@ const FlexibleOverlay = defineComponent({
6267
6283
  const {
6268
6284
  arrowRef,
6269
6285
  overlayRef,
6286
+ styles,
6270
6287
  updatePosition
6271
6288
  } = useOverlay(props, emit);
6272
6289
  expose({
@@ -6276,7 +6293,8 @@ const FlexibleOverlay = defineComponent({
6276
6293
  var _a;
6277
6294
  return props.modelValue && createVNode("div", mergeProps({
6278
6295
  "ref": overlayRef,
6279
- "class": ns2.b()
6296
+ "class": ns2.b(),
6297
+ "style": styles.value
6280
6298
  }, attrs, {
6281
6299
  "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
6282
6300
  "onPointerup": withModifiers(() => ({}), ["stop"])