vue-devui 1.0.0-rc.3 → 1.0.0-rc.6

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 (134) hide show
  1. package/README.md +144 -129
  2. package/auto-complete/index.es.js +45 -16
  3. package/auto-complete/index.umd.js +3 -3
  4. package/auto-complete/style.css +1 -1
  5. package/button/index.es.js +20 -13
  6. package/button/index.umd.js +1 -1
  7. package/button/style.css +1 -1
  8. package/comment/index.es.js +2 -1
  9. package/comment/index.umd.js +1 -1
  10. package/{tag-input → date-picker}/index.d.ts +0 -0
  11. package/date-picker/index.es.js +1145 -0
  12. package/date-picker/index.umd.js +1 -0
  13. package/date-picker/package.json +7 -0
  14. package/date-picker/style.css +1 -0
  15. package/drawer/index.d.ts +7 -0
  16. package/drawer/index.es.js +236 -0
  17. package/drawer/index.umd.js +1 -0
  18. package/{tag-input → drawer}/package.json +1 -1
  19. package/drawer/style.css +1 -0
  20. package/dropdown/index.d.ts +7 -0
  21. package/dropdown/index.es.js +718 -0
  22. package/dropdown/index.umd.js +1 -0
  23. package/dropdown/package.json +7 -0
  24. package/dropdown/style.css +1 -0
  25. package/form/index.d.ts +7 -0
  26. package/form/index.es.js +7881 -0
  27. package/form/index.umd.js +27 -0
  28. package/form/package.json +7 -0
  29. package/form/style.css +1 -0
  30. package/input/index.es.js +13 -19
  31. package/input/index.umd.js +1 -1
  32. package/input/style.css +1 -1
  33. package/input-number/index.d.ts +7 -0
  34. package/input-number/index.es.js +251 -0
  35. package/input-number/index.umd.js +1 -0
  36. package/input-number/package.json +7 -0
  37. package/input-number/style.css +1 -0
  38. package/layout/index.es.js +3 -1
  39. package/layout/index.umd.js +1 -1
  40. package/loading/index.es.js +20 -13
  41. package/loading/index.umd.js +1 -1
  42. package/modal/index.es.js +16 -4
  43. package/modal/index.umd.js +1 -1
  44. package/notification/index.es.js +100 -10
  45. package/notification/index.umd.js +1 -1
  46. package/notification/style.css +1 -1
  47. package/nuxt/components/Column.js +3 -0
  48. package/nuxt/components/DatePicker.js +3 -0
  49. package/nuxt/components/Drawer.js +3 -0
  50. package/nuxt/components/DrawerService.js +3 -0
  51. package/nuxt/components/Dropdown.js +3 -0
  52. package/nuxt/components/DropdownMenu.js +3 -0
  53. package/nuxt/components/Form.js +3 -0
  54. package/nuxt/components/FormControl.js +3 -0
  55. package/nuxt/components/FormItem.js +3 -0
  56. package/nuxt/components/FormLabel.js +3 -0
  57. package/nuxt/components/FormOperation.js +3 -0
  58. package/nuxt/components/InputNumber.js +3 -0
  59. package/nuxt/components/LoadingOptions.js +3 -0
  60. package/nuxt/components/Select.js +3 -0
  61. package/nuxt/components/StickSlider.js +3 -0
  62. package/nuxt/components/Tab.js +3 -0
  63. package/nuxt/components/Table.js +3 -0
  64. package/nuxt/components/Tabs.js +3 -0
  65. package/nuxt/components/Tooltip.js +3 -0
  66. package/nuxt/components/Tree.js +3 -0
  67. package/nuxt/components/dropdownMenuProps.js +3 -0
  68. package/nuxt/components/loadingProps.js +3 -0
  69. package/nuxt/components/modalProps.js +3 -0
  70. package/nuxt/components/sliderProps.js +3 -0
  71. package/nuxt/components/tabsProps.js +3 -0
  72. package/nuxt/components/tooltipProps.js +3 -0
  73. package/nuxt/components/treeProps.js +3 -0
  74. package/overlay/index.es.js +15 -3
  75. package/overlay/index.umd.js +1 -1
  76. package/package.json +2 -2
  77. package/popover/index.es.js +15 -3
  78. package/popover/index.umd.js +9 -9
  79. package/popover/style.css +1 -1
  80. package/rate/index.es.js +27 -34
  81. package/rate/index.umd.js +1 -1
  82. package/read-tip/index.es.js +32 -29
  83. package/read-tip/index.umd.js +1 -1
  84. package/read-tip/style.css +1 -1
  85. package/search/index.es.js +13 -19
  86. package/search/index.umd.js +12 -12
  87. package/search/style.css +1 -1
  88. package/select/index.d.ts +7 -0
  89. package/select/index.es.js +696 -0
  90. package/select/index.umd.js +1 -0
  91. package/select/package.json +7 -0
  92. package/select/style.css +1 -0
  93. package/skeleton/index.es.js +6 -6
  94. package/skeleton/index.umd.js +1 -1
  95. package/slider/index.es.js +19 -10
  96. package/slider/index.umd.js +1 -1
  97. package/splitter/index.es.js +15 -3
  98. package/splitter/index.umd.js +11 -11
  99. package/style.css +1 -1
  100. package/switch/index.es.js +1 -1
  101. package/switch/index.umd.js +1 -1
  102. package/switch/style.css +1 -1
  103. package/table/index.d.ts +7 -0
  104. package/table/index.es.js +2661 -0
  105. package/table/index.umd.js +1 -0
  106. package/table/package.json +7 -0
  107. package/table/style.css +1 -0
  108. package/tabs/index.d.ts +7 -0
  109. package/tabs/index.es.js +194 -0
  110. package/tabs/index.umd.js +1 -0
  111. package/tabs/package.json +7 -0
  112. package/tabs/style.css +1 -0
  113. package/timeline/index.es.js +2 -2
  114. package/timeline/index.umd.js +1 -1
  115. package/tooltip/index.d.ts +7 -0
  116. package/tooltip/index.es.js +5847 -0
  117. package/tooltip/index.umd.js +27 -0
  118. package/tooltip/package.json +7 -0
  119. package/tooltip/style.css +1 -0
  120. package/tree/index.d.ts +7 -0
  121. package/tree/index.es.js +1021 -0
  122. package/tree/index.umd.js +1 -0
  123. package/tree/package.json +7 -0
  124. package/tree/style.css +1 -0
  125. package/upload/index.es.js +100 -10
  126. package/upload/index.umd.js +1 -1
  127. package/upload/style.css +1 -1
  128. package/vue-devui.es.js +13211 -7394
  129. package/vue-devui.umd.js +24 -24
  130. package/nuxt/components/TagInput.js +0 -3
  131. package/nuxt/components/tagInputProps.js +0 -3
  132. package/tag-input/index.es.js +0 -328
  133. package/tag-input/index.umd.js +0 -1
  134. package/tag-input/style.css +0 -1
@@ -0,0 +1,718 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, unref, nextTick, mergeProps, Fragment, withDirectives, vShow } from "vue";
21
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
22
+ import { onClickOutside } from "@vueuse/core";
23
+ const dropdownProps = {
24
+ visible: {
25
+ type: Boolean,
26
+ default: false
27
+ },
28
+ trigger: {
29
+ type: String,
30
+ default: "click"
31
+ },
32
+ closeScope: {
33
+ type: String,
34
+ default: "all"
35
+ },
36
+ position: {
37
+ type: Array,
38
+ default: ["bottom"]
39
+ },
40
+ align: {
41
+ type: String,
42
+ default: null
43
+ },
44
+ offset: {
45
+ type: [Number, Object],
46
+ default: 4
47
+ },
48
+ shiftOffset: {
49
+ type: Number
50
+ },
51
+ closeOnMouseLeaveMenu: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ showAnimation: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ overlayClass: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ destroyOnHide: {
64
+ type: Boolean,
65
+ default: true
66
+ }
67
+ };
68
+ function getElement(element) {
69
+ if (element instanceof Element) {
70
+ return element;
71
+ }
72
+ if (element && typeof element === "object" && element.$el instanceof Element) {
73
+ return element.$el;
74
+ }
75
+ return null;
76
+ }
77
+ const dropdownMap = /* @__PURE__ */ new Map();
78
+ function subscribeEvent(dom, type, callback) {
79
+ dom == null ? void 0 : dom.addEventListener(type, callback);
80
+ return () => {
81
+ dom == null ? void 0 : dom.removeEventListener(type, callback);
82
+ };
83
+ }
84
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
85
+ let overlayEnter = false;
86
+ let originEnter = false;
87
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
88
+ const toggle = (status) => {
89
+ isOpen.value = status;
90
+ emit("toggle", isOpen.value);
91
+ };
92
+ const handleLeave = async (elementType, closeAll) => {
93
+ await new Promise((resolve) => setTimeout(resolve, 50));
94
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
95
+ return;
96
+ }
97
+ if (closeAll) {
98
+ [...dropdownMap.values()].reverse().forEach((item) => {
99
+ setTimeout(() => {
100
+ var _a;
101
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
102
+ }, 0);
103
+ });
104
+ }
105
+ toggle(false);
106
+ };
107
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
108
+ const originEl = getElement(originVal);
109
+ const subscriptions = [];
110
+ setTimeout(() => {
111
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
112
+ const dropdownValues = [...dropdownMap.values()];
113
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
114
+ var _a;
115
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
116
+ }) && dropdownValues.some((item) => {
117
+ var _a;
118
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
119
+ })) {
120
+ return;
121
+ }
122
+ [...dropdownMap.values()].reverse().forEach((item) => {
123
+ setTimeout(() => {
124
+ var _a, _b;
125
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
126
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
127
+ }
128
+ }, 0);
129
+ });
130
+ overlayEnter = false;
131
+ }));
132
+ }, 0);
133
+ if (triggerVal === "click") {
134
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
135
+ var _a;
136
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
137
+ handleLeave("dropdown", true);
138
+ }
139
+ }));
140
+ } else if (triggerVal === "hover") {
141
+ subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
142
+ originEnter = true;
143
+ toggle(true);
144
+ }), subscribeEvent(originEl, "mouseleave", () => {
145
+ originEnter = false;
146
+ handleLeave("origin");
147
+ }), subscribeEvent(dropdownEl, "mouseenter", () => {
148
+ overlayEnter = true;
149
+ isOpen.value = true;
150
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
151
+ var _a;
152
+ overlayEnter = false;
153
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
154
+ return;
155
+ }
156
+ handleLeave("dropdown", true);
157
+ }));
158
+ }
159
+ onInvalidate(() => subscriptions.forEach((v) => v()));
160
+ });
161
+ };
162
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
163
+ const calcPopDirection = (dropdownEl) => {
164
+ const elementHeight = dropdownEl.offsetHeight;
165
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
166
+ const isBottomEnough = bottomDistance >= elementHeight;
167
+ if (!isBottomEnough) {
168
+ popDirection.value = "top";
169
+ } else {
170
+ popDirection.value = "bottom";
171
+ }
172
+ };
173
+ watch(visible, (newVal, oldVal) => {
174
+ if (oldVal === void 0) {
175
+ return;
176
+ }
177
+ isOpen.value = newVal;
178
+ emit("toggle", isOpen.value);
179
+ }, { immediate: true });
180
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
181
+ var _a;
182
+ if (isOpenVal) {
183
+ dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
184
+ menuEl: dropdownEl,
185
+ toggle: () => {
186
+ isOpen.value = false;
187
+ emit("toggle", isOpen.value);
188
+ }
189
+ }));
190
+ for (const value of dropdownMap.values()) {
191
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
192
+ value.child = dropdownEl;
193
+ }
194
+ }
195
+ }
196
+ if (dropdownEl) {
197
+ calcPopDirection(dropdownEl);
198
+ }
199
+ });
200
+ onMounted(() => {
201
+ dropdownMap.set(id, { toggleEl: origin.value });
202
+ });
203
+ onUnmounted(() => {
204
+ dropdownMap.delete(id);
205
+ });
206
+ }
207
+ function useOverlayProps(props, currentPosition, isOpen) {
208
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
209
+ const overlayModelValue = ref(false);
210
+ const overlayShowValue = ref(false);
211
+ const styles = computed(() => ({
212
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
213
+ }));
214
+ const classes = computed(() => ({
215
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
216
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
217
+ [`${overlayClass.value}`]: true
218
+ }));
219
+ const handlePositionChange = (pos) => {
220
+ currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
221
+ };
222
+ watch(isOpen, (isOpenVal) => {
223
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
224
+ overlayShowValue.value = isOpenVal;
225
+ });
226
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
227
+ }
228
+ var baseOverlay = "";
229
+ function _isSlot(s) {
230
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
231
+ }
232
+ const CommonOverlay = defineComponent({
233
+ setup(props, ctx) {
234
+ return () => {
235
+ let _slot;
236
+ return createVNode(Teleport, {
237
+ "to": "#d-overlay-anchor"
238
+ }, {
239
+ default: () => [createVNode(Transition, {
240
+ "name": "devui-overlay-fade"
241
+ }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
242
+ default: () => [_slot]
243
+ })]
244
+ });
245
+ };
246
+ }
247
+ });
248
+ const overlayProps = {
249
+ visible: {
250
+ type: Boolean
251
+ },
252
+ backgroundBlock: {
253
+ type: Boolean,
254
+ default: false
255
+ },
256
+ backgroundClass: {
257
+ type: String,
258
+ default: ""
259
+ },
260
+ backgroundStyle: {
261
+ type: [String, Object]
262
+ },
263
+ onBackdropClick: {
264
+ type: Function
265
+ },
266
+ backdropClose: {
267
+ type: Boolean,
268
+ default: true
269
+ },
270
+ hasBackdrop: {
271
+ type: Boolean,
272
+ default: true
273
+ }
274
+ };
275
+ const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
276
+ overlayStyle: {
277
+ type: [String, Object],
278
+ default: void 0
279
+ }
280
+ });
281
+ const overlayEmits = ["update:visible", "backdropClick"];
282
+ function useOverlayLogic(props, ctx) {
283
+ const backgroundClass = computed(() => {
284
+ return [
285
+ "devui-overlay-background",
286
+ props.backgroundClass,
287
+ !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
288
+ ];
289
+ });
290
+ const overlayClass = computed(() => {
291
+ return "devui-overlay";
292
+ });
293
+ const handleBackdropClick = (event) => {
294
+ var _a;
295
+ event.preventDefault();
296
+ (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
297
+ if (props.backdropClose) {
298
+ ctx.emit("update:visible", false);
299
+ }
300
+ };
301
+ const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
302
+ onMounted(() => {
303
+ const body = document.body;
304
+ const originOverflow = body.style.overflow;
305
+ const originPosition = body.style.position;
306
+ watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
307
+ if (backgroundBlock) {
308
+ const top = body.getBoundingClientRect().y;
309
+ if (visible) {
310
+ body.style.overflowY = "scroll";
311
+ body.style.position = visible ? "fixed" : "";
312
+ body.style.top = `${top}px`;
313
+ } else {
314
+ body.style.overflowY = originOverflow;
315
+ body.style.position = originPosition;
316
+ body.style.top = "";
317
+ window.scrollTo(0, -top);
318
+ }
319
+ }
320
+ });
321
+ onUnmounted(() => {
322
+ document.body.style.overflow = originOverflow;
323
+ });
324
+ });
325
+ return {
326
+ backgroundClass,
327
+ overlayClass,
328
+ handleBackdropClick,
329
+ handleOverlayBubbleCancel
330
+ };
331
+ }
332
+ var fixedOverlay = "";
333
+ defineComponent({
334
+ name: "DFixedOverlay",
335
+ props: fixedOverlayProps,
336
+ emits: overlayEmits,
337
+ setup(props, ctx) {
338
+ const {
339
+ backgroundClass,
340
+ overlayClass,
341
+ handleBackdropClick,
342
+ handleOverlayBubbleCancel
343
+ } = useOverlayLogic(props, ctx);
344
+ return () => createVNode(CommonOverlay, null, {
345
+ default: () => [props.visible && createVNode("div", {
346
+ "class": backgroundClass.value,
347
+ "style": props.backgroundStyle,
348
+ "onClick": handleBackdropClick
349
+ }, [createVNode("div", {
350
+ "class": overlayClass.value,
351
+ "style": props.overlayStyle,
352
+ "onClick": handleOverlayBubbleCancel
353
+ }, [renderSlot(ctx.slots, "default")])])]
354
+ });
355
+ }
356
+ });
357
+ const flexibleOverlayProps = {
358
+ modelValue: {
359
+ type: Boolean,
360
+ default: false
361
+ },
362
+ origin: {
363
+ type: Object,
364
+ require: true
365
+ },
366
+ position: {
367
+ type: Array,
368
+ default: ["bottom"]
369
+ },
370
+ offset: {
371
+ type: [Number, Object],
372
+ default: 8
373
+ },
374
+ shiftOffset: {
375
+ type: Number
376
+ },
377
+ align: {
378
+ type: String,
379
+ default: null
380
+ },
381
+ showArrow: {
382
+ type: Boolean,
383
+ default: false
384
+ },
385
+ isArrowCenter: {
386
+ type: Boolean,
387
+ default: true
388
+ }
389
+ };
390
+ function getScrollParent(element) {
391
+ const overflowRegex = /(auto|scroll|hidden)/;
392
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
393
+ const style = window.getComputedStyle(parent);
394
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
395
+ return parent;
396
+ }
397
+ }
398
+ return window;
399
+ }
400
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
401
+ let { x, y } = point;
402
+ if (!isArrowCenter) {
403
+ const { width, height } = originRect;
404
+ if (x && placement.includes("start")) {
405
+ x = 12;
406
+ }
407
+ if (x && placement.includes("end")) {
408
+ x = Math.round(width - 24);
409
+ }
410
+ if (y && placement.includes("start")) {
411
+ y = 10;
412
+ }
413
+ if (y && placement.includes("end")) {
414
+ y = height - 14;
415
+ }
416
+ }
417
+ return { x, y };
418
+ }
419
+ function useOverlay(props, emit) {
420
+ const overlayRef = ref();
421
+ const arrowRef = ref();
422
+ let originParent = null;
423
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
424
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
425
+ const staticSide = {
426
+ top: "bottom",
427
+ right: "left",
428
+ bottom: "top",
429
+ left: "right"
430
+ }[placement.split("-")[0]];
431
+ Object.assign(arrowEl.style, {
432
+ left: x ? `${x}px` : "",
433
+ top: y ? `${y}px` : "",
434
+ right: "",
435
+ bottom: "",
436
+ [staticSide]: "-4px"
437
+ });
438
+ };
439
+ const updatePosition = async () => {
440
+ const hostEl = props.origin;
441
+ const overlayEl = unref(overlayRef.value);
442
+ const arrowEl = unref(arrowRef.value);
443
+ const middleware = [
444
+ offset(props.offset),
445
+ autoPlacement({
446
+ alignment: props.align,
447
+ allowedPlacements: props.position
448
+ })
449
+ ];
450
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
451
+ props.shiftOffset !== void 0 && middleware.push(shift());
452
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
453
+ strategy: "fixed",
454
+ middleware
455
+ });
456
+ let applyX = x;
457
+ let applyY = y;
458
+ if (props.shiftOffset !== void 0) {
459
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
460
+ shiftX < 0 && (applyX -= props.shiftOffset);
461
+ shiftX > 0 && (applyX += props.shiftOffset);
462
+ shiftY < 0 && (applyY -= props.shiftOffset);
463
+ shiftY > 0 && (applyY += props.shiftOffset);
464
+ }
465
+ emit("positionChange", placement);
466
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
467
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
468
+ };
469
+ watch(() => props.modelValue, () => {
470
+ if (props.modelValue && props.origin) {
471
+ originParent = getScrollParent(props.origin);
472
+ nextTick(updatePosition);
473
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
474
+ originParent !== window && window.addEventListener("scroll", updatePosition);
475
+ window.addEventListener("resize", updatePosition);
476
+ } else {
477
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
478
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
479
+ window.removeEventListener("resize", updatePosition);
480
+ }
481
+ });
482
+ onUnmounted(() => {
483
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
484
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
485
+ window.removeEventListener("resize", updatePosition);
486
+ });
487
+ return { arrowRef, overlayRef, updatePosition };
488
+ }
489
+ var flexibleOverlay = "";
490
+ const FlexibleOverlay = defineComponent({
491
+ name: "DFlexibleOverlay",
492
+ inheritAttrs: false,
493
+ props: flexibleOverlayProps,
494
+ emits: ["update:modelValue", "positionChange"],
495
+ setup(props, {
496
+ slots,
497
+ attrs,
498
+ emit,
499
+ expose
500
+ }) {
501
+ const {
502
+ arrowRef,
503
+ overlayRef,
504
+ updatePosition
505
+ } = useOverlay(props, emit);
506
+ expose({
507
+ updatePosition
508
+ });
509
+ return () => {
510
+ var _a;
511
+ return props.modelValue && createVNode("div", mergeProps({
512
+ "ref": overlayRef,
513
+ "class": "devui-flexible-overlay"
514
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
515
+ "ref": arrowRef,
516
+ "class": "devui-flexible-overlay-arrow"
517
+ }, null)]);
518
+ };
519
+ }
520
+ });
521
+ var dropdown = "";
522
+ let dropdownId = 1;
523
+ var Dropdown = defineComponent({
524
+ name: "DDropdown",
525
+ inheritAttrs: false,
526
+ props: dropdownProps,
527
+ emits: ["toggle"],
528
+ setup(props, {
529
+ slots,
530
+ attrs,
531
+ emit,
532
+ expose
533
+ }) {
534
+ const {
535
+ visible,
536
+ position,
537
+ align,
538
+ offset: offset2,
539
+ destroyOnHide,
540
+ shiftOffset,
541
+ showAnimation
542
+ } = toRefs(props);
543
+ const origin = ref();
544
+ const dropdownRef = ref();
545
+ const overlayRef = ref();
546
+ const id = `dropdown_${dropdownId++}`;
547
+ const isOpen = ref(false);
548
+ const currentPosition = ref("bottom");
549
+ useDropdownEvent({
550
+ id,
551
+ isOpen,
552
+ origin,
553
+ dropdownRef,
554
+ props,
555
+ emit
556
+ });
557
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
558
+ const {
559
+ overlayModelValue,
560
+ overlayShowValue,
561
+ styles,
562
+ classes,
563
+ handlePositionChange
564
+ } = useOverlayProps(props, currentPosition, isOpen);
565
+ watch(overlayShowValue, (overlayShowValueVal) => {
566
+ nextTick(() => {
567
+ if (!destroyOnHide.value && overlayShowValueVal) {
568
+ overlayRef.value.updatePosition();
569
+ }
570
+ });
571
+ });
572
+ expose({
573
+ updatePosition: () => overlayRef.value.updatePosition()
574
+ });
575
+ return () => {
576
+ var _a;
577
+ return createVNode(Fragment, null, [createVNode("div", {
578
+ "ref": origin,
579
+ "class": "devui-dropdown-toggle"
580
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
581
+ "to": "body"
582
+ }, {
583
+ default: () => [createVNode(Transition, {
584
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
585
+ }, {
586
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
587
+ "modelValue": overlayModelValue.value,
588
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
589
+ "ref": overlayRef,
590
+ "origin": origin.value,
591
+ "position": position.value,
592
+ "align": align.value,
593
+ "offset": offset2.value,
594
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
595
+ "onPositionChange": handlePositionChange,
596
+ "class": classes.value,
597
+ "style": styles.value
598
+ }, {
599
+ default: () => {
600
+ var _a2;
601
+ return [createVNode("div", mergeProps({
602
+ "ref": dropdownRef,
603
+ "class": "devui-dropdown-menu-wrap"
604
+ }, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
605
+ }
606
+ }), [[vShow, overlayShowValue.value]])]
607
+ })]
608
+ })]);
609
+ };
610
+ }
611
+ });
612
+ const dropdownMenuProps = {
613
+ modelValue: {
614
+ type: Boolean,
615
+ default: false
616
+ },
617
+ origin: {
618
+ type: Object,
619
+ require: true
620
+ },
621
+ position: {
622
+ type: Array,
623
+ default: ["bottom"]
624
+ },
625
+ align: {
626
+ type: String,
627
+ default: null
628
+ },
629
+ offset: {
630
+ type: [Number, Object],
631
+ default: 4
632
+ },
633
+ clickOutside: {
634
+ type: Function,
635
+ default: () => true
636
+ },
637
+ showAnimation: {
638
+ type: Boolean,
639
+ default: true
640
+ },
641
+ overlayClass: {
642
+ type: String,
643
+ default: ""
644
+ }
645
+ };
646
+ var DropdownMenu = defineComponent({
647
+ name: "DDropdownMenu",
648
+ inheritAttrs: false,
649
+ props: dropdownMenuProps,
650
+ emits: ["update:modelValue"],
651
+ setup(props, {
652
+ slots,
653
+ attrs,
654
+ emit
655
+ }) {
656
+ const {
657
+ modelValue,
658
+ origin,
659
+ position,
660
+ align,
661
+ offset: offset2,
662
+ clickOutside,
663
+ showAnimation,
664
+ overlayClass
665
+ } = toRefs(props);
666
+ const dropdownMenuRef = ref(null);
667
+ onClickOutside(dropdownMenuRef, (value) => {
668
+ var _a, _b;
669
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
670
+ emit("update:modelValue", false);
671
+ }
672
+ });
673
+ const currentPosition = ref("bottom");
674
+ const handlePositionChange = (pos) => {
675
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
676
+ };
677
+ const styles = computed(() => ({
678
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
679
+ }));
680
+ return () => createVNode(Teleport, {
681
+ "to": "body"
682
+ }, {
683
+ default: () => [createVNode(Transition, {
684
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
685
+ }, {
686
+ default: () => [createVNode(FlexibleOverlay, {
687
+ "modelValue": modelValue.value,
688
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
689
+ "origin": origin == null ? void 0 : origin.value,
690
+ "position": position.value,
691
+ "align": align.value,
692
+ "offset": offset2.value,
693
+ "onPositionChange": handlePositionChange,
694
+ "class": overlayClass.value,
695
+ "style": styles.value
696
+ }, {
697
+ default: () => {
698
+ var _a;
699
+ return [createVNode("div", mergeProps({
700
+ "ref": dropdownMenuRef,
701
+ "class": "devui-dropdown-menu-wrap"
702
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
703
+ }
704
+ })]
705
+ })]
706
+ });
707
+ }
708
+ });
709
+ var index = {
710
+ title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
711
+ category: "\u5BFC\u822A",
712
+ status: "10%",
713
+ install(app) {
714
+ app.component(Dropdown.name, Dropdown);
715
+ app.component(DropdownMenu.name, DropdownMenu);
716
+ }
717
+ };
718
+ export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };