vue-devui 1.0.0-rc.2 → 1.0.0-rc.5

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 (174) hide show
  1. package/README.md +9 -0
  2. package/auto-complete/index.es.js +132 -58
  3. package/auto-complete/index.umd.js +5 -3
  4. package/auto-complete/style.css +1 -1
  5. package/avatar/index.es.js +77 -81
  6. package/avatar/index.umd.js +1 -1
  7. package/button/index.es.js +23 -15
  8. package/button/index.umd.js +1 -1
  9. package/button/style.css +1 -1
  10. package/card/index.es.js +3 -6
  11. package/card/index.umd.js +1 -1
  12. package/checkbox/index.es.js +5 -11
  13. package/checkbox/index.umd.js +1 -1
  14. package/comment/index.es.js +4 -6
  15. package/comment/index.umd.js +1 -1
  16. package/countdown/index.es.js +3 -6
  17. package/countdown/index.umd.js +1 -1
  18. package/{tag-input → date-picker}/index.d.ts +0 -0
  19. package/date-picker/index.es.js +1151 -0
  20. package/date-picker/index.umd.js +1 -0
  21. package/date-picker/package.json +7 -0
  22. package/date-picker/style.css +1 -0
  23. package/drawer/index.d.ts +7 -0
  24. package/drawer/index.es.js +236 -0
  25. package/drawer/index.umd.js +1 -0
  26. package/{tag-input → drawer}/package.json +1 -1
  27. package/drawer/style.css +1 -0
  28. package/dropdown/index.d.ts +7 -0
  29. package/dropdown/index.es.js +716 -0
  30. package/dropdown/index.umd.js +1 -0
  31. package/dropdown/package.json +7 -0
  32. package/dropdown/style.css +1 -0
  33. package/editable-select/index.es.js +2 -5
  34. package/editable-select/index.umd.js +1 -1
  35. package/form/index.d.ts +7 -0
  36. package/form/index.es.js +7888 -0
  37. package/form/index.umd.js +27 -0
  38. package/form/package.json +7 -0
  39. package/form/style.css +1 -0
  40. package/grid/index.es.js +30 -36
  41. package/grid/index.umd.js +1 -1
  42. package/image-preview/index.es.js +19 -19
  43. package/image-preview/index.umd.js +1 -1
  44. package/input/index.es.js +2 -5
  45. package/input/index.umd.js +1 -1
  46. package/input-number/index.d.ts +7 -0
  47. package/input-number/index.es.js +229 -0
  48. package/input-number/index.umd.js +1 -0
  49. package/input-number/package.json +7 -0
  50. package/input-number/style.css +1 -0
  51. package/layout/index.es.js +9 -22
  52. package/layout/index.umd.js +1 -1
  53. package/loading/index.es.js +40 -25
  54. package/loading/index.umd.js +1 -1
  55. package/modal/index.es.js +70 -50
  56. package/modal/index.umd.js +1 -1
  57. package/notification/index.es.js +100 -10
  58. package/notification/index.umd.js +1 -1
  59. package/notification/style.css +1 -1
  60. package/nuxt/components/Column.js +3 -0
  61. package/nuxt/components/DatePicker.js +3 -0
  62. package/nuxt/components/Drawer.js +3 -0
  63. package/nuxt/components/DrawerService.js +3 -0
  64. package/nuxt/components/Dropdown.js +3 -0
  65. package/nuxt/components/DropdownMenu.js +3 -0
  66. package/nuxt/components/DropdownPropsKey.js +3 -0
  67. package/nuxt/components/Form.js +3 -0
  68. package/nuxt/components/FormControl.js +3 -0
  69. package/nuxt/components/FormItem.js +3 -0
  70. package/nuxt/components/FormLabel.js +3 -0
  71. package/nuxt/components/FormOperation.js +3 -0
  72. package/nuxt/components/InputNumber.js +3 -0
  73. package/nuxt/components/LoadingOptions.js +3 -0
  74. package/nuxt/components/Select.js +3 -0
  75. package/nuxt/components/StickSlider.js +3 -0
  76. package/nuxt/components/Tab.js +3 -0
  77. package/nuxt/components/Table.js +3 -0
  78. package/nuxt/components/Tabs.js +3 -0
  79. package/nuxt/components/Tooltip.js +3 -0
  80. package/nuxt/components/autoCompleteProps.js +3 -0
  81. package/nuxt/components/avatarProps.js +3 -0
  82. package/nuxt/components/cardProps.js +3 -0
  83. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  84. package/nuxt/components/checkboxGroupProps.js +3 -0
  85. package/nuxt/components/checkboxProps.js +3 -0
  86. package/nuxt/components/colProps.js +3 -0
  87. package/nuxt/components/colPropsBaseClass.js +3 -0
  88. package/nuxt/components/colPropsBaseStyle.js +3 -0
  89. package/nuxt/components/commentProps.js +3 -0
  90. package/nuxt/components/countdownProps.js +3 -0
  91. package/nuxt/components/dropdownMenuProps.js +3 -0
  92. package/nuxt/components/editableSelectProps.js +3 -0
  93. package/nuxt/components/imagePreviewProps.js +3 -0
  94. package/nuxt/components/inputProps.js +3 -0
  95. package/nuxt/components/loadingProps.js +3 -0
  96. package/nuxt/components/modalProps.js +3 -0
  97. package/nuxt/components/progressProps.js +3 -0
  98. package/nuxt/components/rateProps.js +3 -0
  99. package/nuxt/components/readTipProps.js +3 -0
  100. package/nuxt/components/resultProps.js +3 -0
  101. package/nuxt/components/rowProps.js +3 -0
  102. package/nuxt/components/screenSizes.js +3 -0
  103. package/nuxt/components/skeletonProps.js +3 -0
  104. package/nuxt/components/sliderProps.js +3 -0
  105. package/nuxt/components/splitterProps.js +3 -0
  106. package/nuxt/components/statisticProps.js +3 -0
  107. package/nuxt/components/switchProps.js +3 -0
  108. package/nuxt/components/tabsProps.js +3 -0
  109. package/nuxt/components/textareaProps.js +3 -0
  110. package/nuxt/components/timeAxisProps.js +3 -0
  111. package/nuxt/components/tooltipProps.js +3 -0
  112. package/overlay/index.es.js +20 -8
  113. package/overlay/index.umd.js +1 -1
  114. package/package.json +2 -2
  115. package/pagination/index.es.js +14 -13
  116. package/pagination/index.umd.js +1 -1
  117. package/popover/index.es.js +20 -8
  118. package/popover/index.umd.js +12 -12
  119. package/progress/index.es.js +33 -35
  120. package/progress/index.umd.js +3 -3
  121. package/rate/index.es.js +31 -41
  122. package/rate/index.umd.js +1 -1
  123. package/read-tip/index.es.js +34 -34
  124. package/read-tip/index.umd.js +1 -1
  125. package/read-tip/style.css +1 -1
  126. package/result/index.es.js +2 -5
  127. package/result/index.umd.js +1 -1
  128. package/search/index.es.js +11 -11
  129. package/search/index.umd.js +8 -8
  130. package/select/index.d.ts +7 -0
  131. package/select/index.es.js +696 -0
  132. package/select/index.umd.js +1 -0
  133. package/select/package.json +7 -0
  134. package/select/style.css +1 -0
  135. package/skeleton/index.es.js +9 -12
  136. package/skeleton/index.umd.js +1 -1
  137. package/slider/index.es.js +1 -4
  138. package/slider/index.umd.js +1 -1
  139. package/splitter/index.es.js +23 -14
  140. package/splitter/index.umd.js +15 -15
  141. package/statistic/index.es.js +7 -18
  142. package/statistic/index.umd.js +1 -1
  143. package/style.css +1 -1
  144. package/switch/index.es.js +4 -7
  145. package/switch/index.umd.js +1 -1
  146. package/switch/style.css +1 -1
  147. package/table/index.d.ts +7 -0
  148. package/table/index.es.js +2376 -0
  149. package/table/index.umd.js +1 -0
  150. package/table/package.json +7 -0
  151. package/table/style.css +1 -0
  152. package/tabs/index.d.ts +7 -0
  153. package/tabs/index.es.js +194 -0
  154. package/tabs/index.umd.js +1 -0
  155. package/tabs/package.json +7 -0
  156. package/tabs/style.css +1 -0
  157. package/textarea/index.es.js +2 -5
  158. package/textarea/index.umd.js +1 -1
  159. package/timeline/index.es.js +10 -16
  160. package/timeline/index.umd.js +1 -1
  161. package/tooltip/index.d.ts +7 -0
  162. package/tooltip/index.es.js +5847 -0
  163. package/tooltip/index.umd.js +27 -0
  164. package/tooltip/package.json +7 -0
  165. package/tooltip/style.css +1 -0
  166. package/upload/index.es.js +160 -67
  167. package/upload/index.umd.js +1 -1
  168. package/upload/style.css +1 -1
  169. package/vue-devui.es.js +16936 -24821
  170. package/vue-devui.umd.js +24 -22
  171. package/nuxt/components/TagInput.js +0 -3
  172. package/tag-input/index.es.js +0 -331
  173. package/tag-input/index.umd.js +0 -1
  174. package/tag-input/style.css +0 -1
@@ -0,0 +1,716 @@
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.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
+ showAnimation
541
+ } = toRefs(props);
542
+ const origin = ref();
543
+ const dropdownRef = ref();
544
+ const overlayRef = ref();
545
+ const id = `dropdown_${dropdownId++}`;
546
+ const isOpen = ref(false);
547
+ const currentPosition = ref("bottom");
548
+ useDropdownEvent({
549
+ id,
550
+ isOpen,
551
+ origin,
552
+ dropdownRef,
553
+ props,
554
+ emit
555
+ });
556
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
557
+ const {
558
+ overlayModelValue,
559
+ overlayShowValue,
560
+ styles,
561
+ classes,
562
+ handlePositionChange
563
+ } = useOverlayProps(props, currentPosition, isOpen);
564
+ watch(overlayShowValue, (overlayShowValueVal) => {
565
+ nextTick(() => {
566
+ if (!destroyOnHide.value && overlayShowValueVal) {
567
+ overlayRef.value.updatePosition();
568
+ }
569
+ });
570
+ });
571
+ expose({
572
+ updatePosition: () => overlayRef.value.updatePosition()
573
+ });
574
+ return () => {
575
+ var _a;
576
+ return createVNode(Fragment, null, [createVNode("div", {
577
+ "ref": origin,
578
+ "class": "devui-dropdown-toggle"
579
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
580
+ "to": "body"
581
+ }, {
582
+ default: () => [createVNode(Transition, {
583
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
584
+ }, {
585
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
586
+ "modelValue": overlayModelValue.value,
587
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
588
+ "ref": overlayRef,
589
+ "origin": origin.value,
590
+ "position": position.value,
591
+ "align": align.value,
592
+ "offset": offset2.value,
593
+ "onPositionChange": handlePositionChange,
594
+ "class": classes.value,
595
+ "style": styles.value
596
+ }, {
597
+ default: () => {
598
+ var _a2;
599
+ return [createVNode("div", mergeProps({
600
+ "ref": dropdownRef,
601
+ "class": "devui-dropdown-menu-wrap"
602
+ }, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
603
+ }
604
+ }), [[vShow, overlayShowValue.value]])]
605
+ })]
606
+ })]);
607
+ };
608
+ }
609
+ });
610
+ const dropdownMenuProps = {
611
+ modelValue: {
612
+ type: Boolean,
613
+ default: false
614
+ },
615
+ origin: {
616
+ type: Object,
617
+ require: true
618
+ },
619
+ position: {
620
+ type: Array,
621
+ default: ["bottom"]
622
+ },
623
+ align: {
624
+ type: String,
625
+ default: null
626
+ },
627
+ offset: {
628
+ type: [Number, Object],
629
+ default: 4
630
+ },
631
+ clickOutside: {
632
+ type: Function,
633
+ default: () => true
634
+ },
635
+ showAnimation: {
636
+ type: Boolean,
637
+ default: true
638
+ },
639
+ overlayClass: {
640
+ type: String,
641
+ default: ""
642
+ }
643
+ };
644
+ var DropdownMenu = defineComponent({
645
+ name: "DDropdownMenu",
646
+ inheritAttrs: false,
647
+ props: dropdownMenuProps,
648
+ emits: ["update:modelValue"],
649
+ setup(props, {
650
+ slots,
651
+ attrs,
652
+ emit
653
+ }) {
654
+ const {
655
+ modelValue,
656
+ origin,
657
+ position,
658
+ align,
659
+ offset: offset2,
660
+ clickOutside,
661
+ showAnimation,
662
+ overlayClass
663
+ } = toRefs(props);
664
+ const dropdownMenuRef = ref(null);
665
+ onClickOutside(dropdownMenuRef, (value) => {
666
+ var _a, _b;
667
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
668
+ emit("update:modelValue", false);
669
+ }
670
+ });
671
+ const currentPosition = ref("bottom");
672
+ const handlePositionChange = (pos) => {
673
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
674
+ };
675
+ const styles = computed(() => ({
676
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
677
+ }));
678
+ return () => createVNode(Teleport, {
679
+ "to": "body"
680
+ }, {
681
+ default: () => [createVNode(Transition, {
682
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
683
+ }, {
684
+ default: () => [createVNode(FlexibleOverlay, {
685
+ "modelValue": modelValue.value,
686
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
687
+ "origin": origin == null ? void 0 : origin.value,
688
+ "position": position.value,
689
+ "align": align.value,
690
+ "offset": offset2.value,
691
+ "onPositionChange": handlePositionChange,
692
+ "class": overlayClass.value,
693
+ "style": styles.value
694
+ }, {
695
+ default: () => {
696
+ var _a;
697
+ return [createVNode("div", mergeProps({
698
+ "ref": dropdownMenuRef,
699
+ "class": "devui-dropdown-menu-wrap"
700
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
701
+ }
702
+ })]
703
+ })]
704
+ });
705
+ }
706
+ });
707
+ var index = {
708
+ title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
709
+ category: "\u5BFC\u822A",
710
+ status: "10%",
711
+ install(app) {
712
+ app.component(Dropdown.name, Dropdown);
713
+ app.component(DropdownMenu.name, DropdownMenu);
714
+ }
715
+ };
716
+ export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };