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
@@ -14,8 +14,8 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
- import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, computed, onMounted, provide, Teleport, createTextVNode, vShow } from "vue";
18
- import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
17
+ import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, onMounted, provide, Teleport, createTextVNode, vShow } from "vue";
18
+ import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
19
19
  import Clipboard from "clipboard";
20
20
  import * as Diff2Html from "diff2html";
21
21
  import { Diff2HtmlUI } from "diff2html/lib/ui/js/diff2html-ui";
@@ -160,18 +160,12 @@ const flexibleOverlayProps = {
160
160
  clickEventBubble: {
161
161
  type: Boolean,
162
162
  default: false
163
+ },
164
+ fitOriginWidth: {
165
+ type: Boolean,
166
+ default: false
163
167
  }
164
168
  };
165
- function getScrollParent(element) {
166
- const overflowRegex = /(auto|scroll|hidden)/;
167
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
168
- const style = window.getComputedStyle(parent);
169
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
170
- return parent;
171
- }
172
- }
173
- return window;
174
- }
175
169
  function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
176
170
  let { x, y } = point;
177
171
  if (!isArrowCenter) {
@@ -192,9 +186,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
192
186
  return { x, y };
193
187
  }
194
188
  function useOverlay(props, emit) {
189
+ const { fitOriginWidth, position, showArrow } = toRefs(props);
195
190
  const overlayRef = ref();
196
191
  const arrowRef = ref();
197
- let originParent = null;
192
+ const overlayWidth = ref(0);
193
+ let originObserver;
194
+ const styles = computed(() => {
195
+ if (fitOriginWidth.value) {
196
+ return { width: overlayWidth.value + "px" };
197
+ } else {
198
+ return {};
199
+ }
200
+ });
198
201
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
199
202
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
200
203
  const staticSide = {
@@ -215,54 +218,67 @@ function useOverlay(props, emit) {
215
218
  const hostEl = props.origin;
216
219
  const overlayEl = unref(overlayRef.value);
217
220
  const arrowEl = unref(arrowRef.value);
218
- const middleware = [
219
- offset(props.offset),
220
- autoPlacement({
221
- alignment: props.align,
222
- allowedPlacements: props.position
223
- })
224
- ];
225
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
226
- props.shiftOffset !== void 0 && middleware.push(shift());
227
- if (!overlayEl) {
228
- return;
221
+ const [mainPosition, ...fallbackPosition] = position.value;
222
+ const middleware = [offset(props.offset)];
223
+ middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
224
+ if (showArrow.value) {
225
+ middleware.push(arrow({ element: arrowRef.value }));
229
226
  }
230
227
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
231
228
  strategy: "fixed",
229
+ placement: mainPosition,
232
230
  middleware
233
231
  });
234
232
  let applyX = x;
235
233
  let applyY = y;
236
- if (props.shiftOffset !== void 0) {
237
- const { x: shiftX, y: shiftY } = middlewareData.shift;
238
- shiftX < 0 && (applyX -= props.shiftOffset);
239
- shiftX > 0 && (applyX += props.shiftOffset);
240
- shiftY < 0 && (applyY -= props.shiftOffset);
241
- shiftY > 0 && (applyY += props.shiftOffset);
242
- }
243
234
  emit("positionChange", placement);
244
235
  Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
245
236
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
246
237
  };
238
+ const scrollCallback = (e) => {
239
+ var _a, _b;
240
+ const scrollElement = e.target;
241
+ if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
242
+ updatePosition();
243
+ }
244
+ };
245
+ const updateWidth = (originEl) => {
246
+ overlayWidth.value = originEl.getBoundingClientRect().width;
247
+ updatePosition();
248
+ };
249
+ const observeOrigin = () => {
250
+ var _a, _b;
251
+ if (fitOriginWidth.value && typeof window !== "undefined") {
252
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
253
+ if (originEl) {
254
+ originObserver = new window.ResizeObserver(() => updateWidth(originEl));
255
+ originObserver.observe(originEl);
256
+ }
257
+ }
258
+ };
259
+ const unobserveOrigin = () => {
260
+ var _a, _b;
261
+ const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
262
+ originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
263
+ };
247
264
  watch(() => props.modelValue, () => {
248
265
  if (props.modelValue && props.origin) {
249
- originParent = getScrollParent(props.origin);
250
266
  nextTick(updatePosition);
251
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
252
- originParent !== window && window.addEventListener("scroll", updatePosition);
267
+ window.addEventListener("scroll", scrollCallback, true);
253
268
  window.addEventListener("resize", updatePosition);
269
+ observeOrigin();
254
270
  } else {
255
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
256
- originParent !== window && window.removeEventListener("scroll", updatePosition);
271
+ window.removeEventListener("scroll", scrollCallback, true);
257
272
  window.removeEventListener("resize", updatePosition);
273
+ unobserveOrigin();
258
274
  }
259
275
  });
260
276
  onUnmounted(() => {
261
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
262
- originParent !== window && window.removeEventListener("scroll", updatePosition);
277
+ window.removeEventListener("scroll", scrollCallback, true);
263
278
  window.removeEventListener("resize", updatePosition);
279
+ unobserveOrigin();
264
280
  });
265
- return { arrowRef, overlayRef, updatePosition };
281
+ return { arrowRef, overlayRef, styles, updatePosition };
266
282
  }
267
283
  var flexibleOverlay = "";
268
284
  const FlexibleOverlay = defineComponent({
@@ -283,6 +299,7 @@ const FlexibleOverlay = defineComponent({
283
299
  const {
284
300
  arrowRef,
285
301
  overlayRef,
302
+ styles,
286
303
  updatePosition
287
304
  } = useOverlay(props, emit);
288
305
  expose({
@@ -292,7 +309,8 @@ const FlexibleOverlay = defineComponent({
292
309
  var _a;
293
310
  return props.modelValue && createVNode("div", mergeProps({
294
311
  "ref": overlayRef,
295
- "class": ns2.b()
312
+ "class": ns2.b(),
313
+ "style": styles.value
296
314
  }, attrs, {
297
315
  "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
298
316
  "onPointerup": withModifiers(() => ({}), ["stop"])
@@ -4253,7 +4271,7 @@ var lodash = { exports: {} };
4253
4271
  var delay = baseRest(function(func, wait, args) {
4254
4272
  return baseDelay(func, toNumber(wait) || 0, args);
4255
4273
  });
4256
- function flip(func) {
4274
+ function flip2(func) {
4257
4275
  return createWrap(func, WRAP_FLIP_FLAG);
4258
4276
  }
4259
4277
  function memoize(func, resolver) {
@@ -5377,7 +5395,7 @@ var lodash = { exports: {} };
5377
5395
  lodash2.flatten = flatten;
5378
5396
  lodash2.flattenDeep = flattenDeep;
5379
5397
  lodash2.flattenDepth = flattenDepth;
5380
- lodash2.flip = flip;
5398
+ lodash2.flip = flip2;
5381
5399
  lodash2.flow = flow;
5382
5400
  lodash2.flowRight = flowRight;
5383
5401
  lodash2.fromPairs = fromPairs;