vue-devui 1.6.14 → 1.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/auto-complete/index.es.js +20 -39
  2. package/auto-complete/index.umd.js +10 -10
  3. package/breadcrumb/index.es.js +18 -37
  4. package/breadcrumb/index.umd.js +1 -1
  5. package/category-search/index.es.js +20 -39
  6. package/category-search/index.umd.js +12 -12
  7. package/checkbox/index.es.js +20 -39
  8. package/checkbox/index.umd.js +11 -11
  9. package/code-review/index.es.js +20 -39
  10. package/code-review/index.umd.js +17 -17
  11. package/data-grid/index.es.js +20 -39
  12. package/data-grid/index.umd.js +9 -9
  13. package/date-picker-pro/index.es.js +20 -39
  14. package/date-picker-pro/index.umd.js +13 -13
  15. package/dropdown/index.es.js +18 -37
  16. package/dropdown/index.umd.js +1 -1
  17. package/editable-select/index.es.js +20 -39
  18. package/editable-select/index.umd.js +14 -14
  19. package/editor-md/index.es.js +20 -39
  20. package/editor-md/index.umd.js +22 -22
  21. package/form/index.es.js +20 -39
  22. package/form/index.umd.js +12 -12
  23. package/input/index.es.js +20 -39
  24. package/input/index.umd.js +10 -10
  25. package/input-number/index.es.js +20 -39
  26. package/input-number/index.umd.js +18 -18
  27. package/mention/index.es.js +20 -39
  28. package/mention/index.umd.js +18 -18
  29. package/modal/index.es.js +18 -37
  30. package/modal/index.umd.js +2 -2
  31. package/overlay/index.es.js +18 -37
  32. package/overlay/index.umd.js +1 -1
  33. package/package.json +2 -2
  34. package/pagination/index.es.js +20 -39
  35. package/pagination/index.umd.js +10 -10
  36. package/popover/index.es.js +20 -39
  37. package/popover/index.umd.js +14 -14
  38. package/radio/index.es.js +20 -39
  39. package/radio/index.umd.js +17 -17
  40. package/search/index.es.js +20 -39
  41. package/search/index.umd.js +12 -12
  42. package/select/index.es.js +20 -39
  43. package/select/index.umd.js +16 -16
  44. package/splitter/index.es.js +20 -39
  45. package/splitter/index.umd.js +16 -16
  46. package/switch/index.es.js +20 -39
  47. package/switch/index.umd.js +12 -12
  48. package/table/index.es.js +20 -39
  49. package/table/index.umd.js +10 -10
  50. package/textarea/index.es.js +20 -39
  51. package/textarea/index.umd.js +15 -15
  52. package/time-picker/index.es.js +20 -39
  53. package/time-picker/index.umd.js +16 -16
  54. package/time-select/index.es.js +20 -39
  55. package/time-select/index.umd.js +10 -10
  56. package/tooltip/index.es.js +20 -39
  57. package/tooltip/index.umd.js +17 -17
  58. package/tree/index.es.js +20 -39
  59. package/tree/index.umd.js +12 -12
  60. package/vue-devui.es.js +19 -38
  61. package/vue-devui.umd.js +63 -63
@@ -1,5 +1,5 @@
1
1
  import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, computed, onMounted, provide, Teleport } from "vue";
2
- import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
2
+ import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
3
3
  const fixedOverlayProps = {
4
4
  modelValue: {
5
5
  type: Boolean,
@@ -143,16 +143,6 @@ const flexibleOverlayProps = {
143
143
  default: false
144
144
  }
145
145
  };
146
- function getScrollParent(element) {
147
- const overflowRegex = /(auto|scroll|hidden)/;
148
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
149
- const style = window.getComputedStyle(parent);
150
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
151
- return parent;
152
- }
153
- }
154
- return window;
155
- }
156
146
  function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
157
147
  let { x, y } = point;
158
148
  if (!isArrowCenter) {
@@ -173,9 +163,9 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
173
163
  return { x, y };
174
164
  }
175
165
  function useOverlay(props, emit) {
166
+ const { position, showArrow } = toRefs(props);
176
167
  const overlayRef = ref();
177
168
  const arrowRef = ref();
178
- let originParent = null;
179
169
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
180
170
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
181
171
  const staticSide = {
@@ -196,51 +186,42 @@ function useOverlay(props, emit) {
196
186
  const hostEl = props.origin;
197
187
  const overlayEl = unref(overlayRef.value);
198
188
  const arrowEl = unref(arrowRef.value);
199
- const middleware = [
200
- offset(props.offset),
201
- autoPlacement({
202
- alignment: props.align,
203
- allowedPlacements: props.position
204
- })
205
- ];
206
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
207
- props.shiftOffset !== void 0 && middleware.push(shift());
208
- if (!overlayEl) {
209
- return;
189
+ const [mainPosition, ...fallbackPosition] = position.value;
190
+ const middleware = [offset(props.offset)];
191
+ middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
192
+ if (showArrow.value) {
193
+ middleware.push(arrow({ element: arrowRef.value }));
210
194
  }
211
195
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
212
196
  strategy: "fixed",
197
+ placement: mainPosition,
213
198
  middleware
214
199
  });
215
200
  let applyX = x;
216
201
  let applyY = y;
217
- if (props.shiftOffset !== void 0) {
218
- const { x: shiftX, y: shiftY } = middlewareData.shift;
219
- shiftX < 0 && (applyX -= props.shiftOffset);
220
- shiftX > 0 && (applyX += props.shiftOffset);
221
- shiftY < 0 && (applyY -= props.shiftOffset);
222
- shiftY > 0 && (applyY += props.shiftOffset);
223
- }
224
202
  emit("positionChange", placement);
225
203
  Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
226
204
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
227
205
  };
206
+ const scrollCallback = (e) => {
207
+ var _a, _b;
208
+ const scrollElement = e.target;
209
+ if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
210
+ updatePosition();
211
+ }
212
+ };
228
213
  watch(() => props.modelValue, () => {
229
214
  if (props.modelValue && props.origin) {
230
- originParent = getScrollParent(props.origin);
231
215
  nextTick(updatePosition);
232
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
233
- originParent !== window && window.addEventListener("scroll", updatePosition);
216
+ window.addEventListener("scroll", scrollCallback, true);
234
217
  window.addEventListener("resize", updatePosition);
235
218
  } else {
236
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
237
- originParent !== window && window.removeEventListener("scroll", updatePosition);
219
+ window.removeEventListener("scroll", scrollCallback, true);
238
220
  window.removeEventListener("resize", updatePosition);
239
221
  }
240
222
  });
241
223
  onUnmounted(() => {
242
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
243
- originParent !== window && window.removeEventListener("scroll", updatePosition);
224
+ window.removeEventListener("scroll", scrollCallback, true);
244
225
  window.removeEventListener("resize", updatePosition);
245
226
  });
246
227
  return { arrowRef, overlayRef, updatePosition };
@@ -4233,7 +4214,7 @@ var lodash = { exports: {} };
4233
4214
  var delay = baseRest(function(func, wait, args) {
4234
4215
  return baseDelay(func, toNumber(wait) || 0, args);
4235
4216
  });
4236
- function flip(func) {
4217
+ function flip2(func) {
4237
4218
  return createWrap(func, WRAP_FLIP_FLAG);
4238
4219
  }
4239
4220
  function memoize(func, resolver) {
@@ -5357,7 +5338,7 @@ var lodash = { exports: {} };
5357
5338
  lodash2.flatten = flatten;
5358
5339
  lodash2.flattenDeep = flattenDeep;
5359
5340
  lodash2.flattenDepth = flattenDepth;
5360
- lodash2.flip = flip;
5341
+ lodash2.flip = flip2;
5361
5342
  lodash2.flow = flow;
5362
5343
  lodash2.flowRight = flowRight;
5363
5344
  lodash2.fromPairs = fromPairs;