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

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