vue-devui 1.0.0-beta.2 → 1.0.0-beta.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 (157) hide show
  1. package/accordion/index.d.ts +7 -0
  2. package/accordion/index.es.js +186 -139
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.d.ts +7 -0
  6. package/anchor/index.d.ts +7 -0
  7. package/avatar/index.d.ts +7 -0
  8. package/back-top/index.d.ts +7 -0
  9. package/back-top/index.es.js +72 -0
  10. package/back-top/index.umd.js +1 -0
  11. package/back-top/package.json +7 -0
  12. package/back-top/style.css +1 -0
  13. package/badge/index.d.ts +7 -0
  14. package/breadcrumb/index.d.ts +7 -0
  15. package/button/index.d.ts +7 -0
  16. package/card/index.d.ts +7 -0
  17. package/carousel/index.d.ts +7 -0
  18. package/cascader/index.d.ts +7 -0
  19. package/cascader/index.es.js +1239 -83
  20. package/cascader/index.umd.js +1 -1
  21. package/cascader/style.css +1 -1
  22. package/checkbox/index.d.ts +7 -0
  23. package/checkbox/index.es.js +42 -7
  24. package/checkbox/index.umd.js +1 -1
  25. package/date-picker/index.d.ts +7 -0
  26. package/date-picker/index.es.js +4 -3
  27. package/date-picker/index.umd.js +1 -1
  28. package/date-picker/style.css +1 -1
  29. package/dragdrop/index.d.ts +7 -0
  30. package/dragdrop/index.es.js +32 -0
  31. package/dragdrop/index.umd.js +1 -0
  32. package/dragdrop/package.json +7 -0
  33. package/drawer/index.d.ts +7 -0
  34. package/drawer/index.es.js +112 -45
  35. package/drawer/index.umd.js +1 -1
  36. package/drawer/style.css +1 -1
  37. package/dropdown/index.d.ts +7 -0
  38. package/dropdown/index.es.js +528 -0
  39. package/dropdown/index.umd.js +1 -0
  40. package/dropdown/package.json +7 -0
  41. package/dropdown/style.css +1 -0
  42. package/editable-select/index.d.ts +7 -0
  43. package/editable-select/index.es.js +5646 -432
  44. package/editable-select/index.umd.js +27 -1
  45. package/editable-select/style.css +1 -1
  46. package/form/index.d.ts +7 -0
  47. package/form/index.es.js +427 -5554
  48. package/form/index.umd.js +1 -27
  49. package/form/style.css +1 -1
  50. package/fullscreen/index.d.ts +7 -0
  51. package/gantt/index.d.ts +7 -0
  52. package/gantt/index.es.js +535 -0
  53. package/gantt/index.umd.js +1 -0
  54. package/gantt/package.json +7 -0
  55. package/gantt/style.css +1 -0
  56. package/grid/index.d.ts +7 -0
  57. package/grid/index.es.js +269 -0
  58. package/grid/index.umd.js +1 -0
  59. package/grid/package.json +7 -0
  60. package/grid/style.css +1 -0
  61. package/icon/index.d.ts +7 -0
  62. package/image-preview/index.d.ts +7 -0
  63. package/image-preview/index.es.js +22 -1
  64. package/image-preview/index.umd.js +1 -1
  65. package/index.d.ts +7 -0
  66. package/input/index.d.ts +7 -0
  67. package/input/index.es.js +4 -3
  68. package/input/index.umd.js +1 -1
  69. package/input-number/index.d.ts +7 -0
  70. package/layout/index.d.ts +7 -0
  71. package/loading/index.d.ts +7 -0
  72. package/modal/index.d.ts +7 -0
  73. package/modal/index.es.js +100 -82
  74. package/modal/index.umd.js +1 -1
  75. package/modal/style.css +1 -1
  76. package/nav-sprite/index.d.ts +7 -0
  77. package/overlay/index.d.ts +7 -0
  78. package/overlay/index.es.js +100 -82
  79. package/overlay/index.umd.js +1 -1
  80. package/overlay/style.css +1 -1
  81. package/package.json +5 -4
  82. package/pagination/index.d.ts +7 -0
  83. package/panel/index.d.ts +7 -0
  84. package/popover/index.d.ts +7 -0
  85. package/progress/index.d.ts +7 -0
  86. package/quadrant-diagram/index.d.ts +7 -0
  87. package/radio/index.d.ts +7 -0
  88. package/rate/index.d.ts +7 -0
  89. package/read-tip/index.d.ts +7 -0
  90. package/read-tip/index.es.js +244 -0
  91. package/read-tip/index.umd.js +1 -0
  92. package/read-tip/package.json +7 -0
  93. package/read-tip/style.css +1 -0
  94. package/ripple/index.d.ts +7 -0
  95. package/search/index.d.ts +7 -0
  96. package/search/index.es.js +4 -3
  97. package/search/index.umd.js +1 -1
  98. package/select/index.d.ts +7 -0
  99. package/select/index.es.js +42 -7
  100. package/select/index.umd.js +1 -1
  101. package/skeleton/index.d.ts +7 -0
  102. package/skeleton/index.es.js +147 -25
  103. package/skeleton/index.umd.js +1 -1
  104. package/skeleton/style.css +1 -1
  105. package/slider/index.d.ts +7 -0
  106. package/slider/index.es.js +8 -6
  107. package/slider/index.umd.js +1 -1
  108. package/splitter/index.d.ts +7 -0
  109. package/status/index.d.ts +7 -0
  110. package/steps-guide/index.d.ts +7 -0
  111. package/steps-guide/index.es.js +5 -2
  112. package/steps-guide/index.umd.js +1 -1
  113. package/steps-guide/style.css +1 -1
  114. package/sticky/index.d.ts +7 -0
  115. package/style.css +1 -1
  116. package/switch/index.d.ts +7 -0
  117. package/table/index.d.ts +7 -0
  118. package/tabs/index.d.ts +7 -0
  119. package/tabs/index.es.js +1 -0
  120. package/tabs/index.umd.js +1 -1
  121. package/tag/index.d.ts +7 -0
  122. package/tag/index.es.js +49 -0
  123. package/tag/index.umd.js +1 -0
  124. package/tag/package.json +7 -0
  125. package/tag/style.css +1 -0
  126. package/tag-input/index.d.ts +7 -0
  127. package/textarea/index.d.ts +7 -0
  128. package/textarea/index.es.js +132 -0
  129. package/textarea/index.umd.js +1 -0
  130. package/textarea/package.json +7 -0
  131. package/textarea/style.css +1 -0
  132. package/time-axis/index.d.ts +7 -0
  133. package/time-axis/index.es.js +238 -21
  134. package/time-axis/index.umd.js +1 -1
  135. package/time-axis/style.css +1 -1
  136. package/time-picker/index.d.ts +7 -0
  137. package/time-picker/index.es.js +42 -19
  138. package/time-picker/index.umd.js +1 -1
  139. package/time-picker/style.css +1 -1
  140. package/toast/index.d.ts +7 -0
  141. package/toast/style.css +1 -1
  142. package/tooltip/index.d.ts +7 -0
  143. package/transfer/index.d.ts +7 -0
  144. package/transfer/index.es.js +46 -10
  145. package/transfer/index.umd.js +1 -1
  146. package/transfer/style.css +1 -1
  147. package/tree/index.d.ts +7 -0
  148. package/tree/index.es.js +11 -4
  149. package/tree/index.umd.js +1 -1
  150. package/tree-select/index.d.ts +7 -0
  151. package/tree-select/index.es.js +435 -110
  152. package/tree-select/index.umd.js +1 -1
  153. package/tree-select/style.css +1 -1
  154. package/upload/index.d.ts +7 -0
  155. package/upload/style.css +1 -1
  156. package/vue-devui.es.js +16759 -14226
  157. package/vue-devui.umd.js +16 -16
@@ -0,0 +1,528 @@
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 { ref, watch, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, withDirectives, vShow, reactive, toRef, isRef, toRefs, Fragment } from "vue";
21
+ const dropdownProps = {
22
+ origin: {
23
+ type: Object
24
+ },
25
+ isOpen: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ disabled: {
30
+ type: Boolean,
31
+ default: false
32
+ },
33
+ trigger: {
34
+ type: String,
35
+ default: "click"
36
+ },
37
+ closeScope: {
38
+ type: String,
39
+ default: "all"
40
+ },
41
+ closeOnMouseLeaveMenu: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ showAnimation: {
46
+ type: Boolean,
47
+ default: true
48
+ }
49
+ };
50
+ function isComponent(target) {
51
+ return !!(target == null ? void 0 : target.$el);
52
+ }
53
+ function getElement(element) {
54
+ if (element instanceof Element) {
55
+ return element;
56
+ }
57
+ if (element && typeof element === "object" && element.$el instanceof Element) {
58
+ return element.$el;
59
+ }
60
+ return null;
61
+ }
62
+ function subscribeEvent(dom, type, callback) {
63
+ dom == null ? void 0 : dom.addEventListener(type, callback);
64
+ return () => {
65
+ dom == null ? void 0 : dom.removeEventListener(type, callback);
66
+ };
67
+ }
68
+ const useDropdown = ({
69
+ visible,
70
+ trigger,
71
+ origin,
72
+ closeScope,
73
+ closeOnMouseLeaveMenu
74
+ }) => {
75
+ const dropdownElRef = ref();
76
+ const closeByScope = () => {
77
+ if (closeScope.value === "none") {
78
+ return;
79
+ }
80
+ visible.value = false;
81
+ };
82
+ watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
83
+ const originEl = getElement(origin2);
84
+ if (!originEl || !dropdownEl) {
85
+ return;
86
+ }
87
+ const subscriptions = [
88
+ subscribeEvent(dropdownEl, "click", () => {
89
+ if (closeScope.value === "all") {
90
+ visible.value = false;
91
+ }
92
+ })
93
+ ];
94
+ if (trigger2 === "click") {
95
+ subscriptions.push(subscribeEvent(originEl, "click", () => visible.value = !visible.value), subscribeEvent(document, "click", (e) => {
96
+ if (!visible.value) {
97
+ return;
98
+ }
99
+ const target = e.target;
100
+ const isContain = originEl.contains(target) || dropdownEl.contains(target);
101
+ if (isContain) {
102
+ return;
103
+ }
104
+ closeByScope();
105
+ }), subscribeEvent(dropdownEl, "mouseleave", () => {
106
+ if (closeOnMouseLeaveMenu.value) {
107
+ visible.value = false;
108
+ }
109
+ }));
110
+ } else if (trigger2 === "hover") {
111
+ let overlayEnter = false;
112
+ let originEnter = false;
113
+ const handleLeave = async (elementType) => {
114
+ await new Promise((resolve) => setTimeout(resolve, 50));
115
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
116
+ return;
117
+ }
118
+ closeByScope();
119
+ };
120
+ subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
121
+ originEnter = true;
122
+ visible.value = true;
123
+ }), subscribeEvent(originEl, "mouseleave", () => {
124
+ originEnter = false;
125
+ if (!closeOnMouseLeaveMenu.value) {
126
+ handleLeave("origin");
127
+ }
128
+ }), subscribeEvent(dropdownEl, "mouseenter", () => {
129
+ overlayEnter = true;
130
+ visible.value = true;
131
+ }), subscribeEvent(dropdownEl, "mouseleave", () => {
132
+ overlayEnter = false;
133
+ handleLeave("dropdown");
134
+ }));
135
+ }
136
+ onInvalidate(() => subscriptions.forEach((v) => v()));
137
+ });
138
+ return { dropdownEl: dropdownElRef };
139
+ };
140
+ var overlay = "";
141
+ function _isSlot(s) {
142
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
143
+ }
144
+ const CommonOverlay = defineComponent({
145
+ setup(props, ctx) {
146
+ return () => {
147
+ let _slot;
148
+ return createVNode(Teleport, {
149
+ "to": "#d-overlay-anchor"
150
+ }, {
151
+ default: () => [createVNode(Transition, {
152
+ "name": "devui-overlay-fade"
153
+ }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
154
+ default: () => [_slot]
155
+ })]
156
+ });
157
+ };
158
+ }
159
+ });
160
+ const overlayProps = {
161
+ visible: {
162
+ type: Boolean
163
+ },
164
+ "onUpdate:visible": {
165
+ type: Function
166
+ },
167
+ backgroundBlock: {
168
+ type: Boolean,
169
+ default: false
170
+ },
171
+ backgroundClass: {
172
+ type: String,
173
+ default: ""
174
+ },
175
+ backgroundStyle: {
176
+ type: [String, Object]
177
+ },
178
+ backdropClick: {
179
+ type: Function
180
+ },
181
+ backdropClose: {
182
+ type: Boolean,
183
+ default: true
184
+ },
185
+ hasBackdrop: {
186
+ type: Boolean,
187
+ default: true
188
+ }
189
+ };
190
+ const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
191
+ overlayStyle: {
192
+ type: [String, Object],
193
+ default: void 0
194
+ }
195
+ });
196
+ const flexibleOverlayProps = __spreadValues({
197
+ origin: {
198
+ type: Object,
199
+ require: true
200
+ },
201
+ position: {
202
+ type: Object,
203
+ default: () => ({
204
+ originX: "left",
205
+ originY: "top",
206
+ overlayX: "left",
207
+ overlayY: "top"
208
+ })
209
+ }
210
+ }, overlayProps);
211
+ function useOverlayLogic(props) {
212
+ const backgroundClass = computed(() => {
213
+ return [
214
+ "devui-overlay-background",
215
+ props.backgroundClass,
216
+ !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
217
+ ];
218
+ });
219
+ const overlayClass = computed(() => {
220
+ return "devui-overlay";
221
+ });
222
+ const handleBackdropClick = (event) => {
223
+ var _a, _b;
224
+ event.preventDefault();
225
+ (_a = props.backdropClick) == null ? void 0 : _a.call(props);
226
+ if (props.backdropClose) {
227
+ (_b = props["onUpdate:visible"]) == null ? void 0 : _b.call(props, false);
228
+ }
229
+ };
230
+ const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
231
+ onMounted(() => {
232
+ const body = document.body;
233
+ const originOverflow = body.style.overflow;
234
+ const originPosition = body.style.position;
235
+ watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
236
+ if (backgroundBlock) {
237
+ const top = body.getBoundingClientRect().y;
238
+ if (visible) {
239
+ body.style.overflowY = "scroll";
240
+ body.style.position = visible ? "fixed" : "";
241
+ body.style.top = `${top}px`;
242
+ } else {
243
+ body.style.overflowY = originOverflow;
244
+ body.style.position = originPosition;
245
+ body.style.top = "";
246
+ window.scrollTo(0, -top);
247
+ }
248
+ }
249
+ });
250
+ onUnmounted(() => {
251
+ document.body.style.overflow = originOverflow;
252
+ });
253
+ });
254
+ return {
255
+ backgroundClass,
256
+ overlayClass,
257
+ handleBackdropClick,
258
+ handleOverlayBubbleCancel
259
+ };
260
+ }
261
+ const FixedOverlay = defineComponent({
262
+ name: "DFixedOverlay",
263
+ props: fixedOverlayProps,
264
+ setup(props, ctx) {
265
+ const {
266
+ backgroundClass,
267
+ overlayClass,
268
+ handleBackdropClick,
269
+ handleOverlayBubbleCancel
270
+ } = useOverlayLogic(props);
271
+ return () => createVNode(CommonOverlay, null, {
272
+ default: () => [withDirectives(createVNode("div", {
273
+ "class": backgroundClass.value,
274
+ "style": props.backgroundStyle,
275
+ "onClick": handleBackdropClick
276
+ }, [createVNode("div", {
277
+ "class": overlayClass.value,
278
+ "style": props.overlayStyle,
279
+ "onClick": handleOverlayBubbleCancel
280
+ }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
281
+ });
282
+ }
283
+ });
284
+ const FlexibleOverlay = defineComponent({
285
+ name: "DFlexibleOverlay",
286
+ props: flexibleOverlayProps,
287
+ emits: ["onUpdate:visible"],
288
+ setup(props, ctx) {
289
+ const overlayRef = ref(null);
290
+ const positionedStyle = reactive({
291
+ position: "absolute"
292
+ });
293
+ onMounted(async () => {
294
+ const handleRectChange = (position, rect, origin) => {
295
+ const point = calculatePosition(position, rect, origin);
296
+ positionedStyle.left = `${point.x}px`;
297
+ positionedStyle.top = `${point.y}px`;
298
+ };
299
+ const locationElements = computed(() => {
300
+ const overlay2 = overlayRef.value;
301
+ const origin = getOrigin(props.origin);
302
+ if (!overlay2 || !origin) {
303
+ return;
304
+ }
305
+ return {
306
+ origin,
307
+ overlay: overlay2
308
+ };
309
+ });
310
+ const visibleRef = toRef(props, "visible");
311
+ const positionRef = toRef(props, "position");
312
+ watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
313
+ if (!visible || !locationElements2) {
314
+ return;
315
+ }
316
+ const {
317
+ origin,
318
+ overlay: overlay2
319
+ } = locationElements2;
320
+ handleRectChange(position, overlay2.getBoundingClientRect(), origin);
321
+ const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
322
+ onInvalidate(() => {
323
+ unsubscriptions.forEach((fn) => fn());
324
+ });
325
+ });
326
+ });
327
+ const {
328
+ backgroundClass,
329
+ overlayClass,
330
+ handleBackdropClick,
331
+ handleOverlayBubbleCancel
332
+ } = useOverlayLogic(props);
333
+ return () => createVNode(CommonOverlay, null, {
334
+ default: () => [withDirectives(createVNode("div", {
335
+ "style": props.backgroundStyle,
336
+ "class": backgroundClass.value,
337
+ "onClick": handleBackdropClick
338
+ }, [createVNode("div", {
339
+ "ref": overlayRef,
340
+ "class": overlayClass.value,
341
+ "style": positionedStyle,
342
+ "onClick": handleOverlayBubbleCancel
343
+ }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
344
+ });
345
+ }
346
+ });
347
+ function getOrigin(origin) {
348
+ if (origin instanceof Element) {
349
+ return origin;
350
+ }
351
+ if (isRef(origin)) {
352
+ return getElement(origin.value);
353
+ }
354
+ if (isComponent(origin)) {
355
+ return getElement(origin);
356
+ }
357
+ return origin;
358
+ }
359
+ function calculatePosition(position, rect, origin) {
360
+ const originRect = getOriginRect(origin);
361
+ const originPoint = getOriginRelativePoint(originRect, position);
362
+ return getOverlayPoint(originPoint, rect, position);
363
+ }
364
+ function getOriginRect(origin) {
365
+ if (origin instanceof Element) {
366
+ return origin.getBoundingClientRect();
367
+ }
368
+ const width = origin.width || 0;
369
+ const height = origin.height || 0;
370
+ return {
371
+ top: origin.y,
372
+ bottom: origin.y + height,
373
+ left: origin.x,
374
+ right: origin.x + width,
375
+ height,
376
+ width
377
+ };
378
+ }
379
+ function getOverlayPoint(originPoint, rect, position) {
380
+ let x;
381
+ const {
382
+ width,
383
+ height
384
+ } = rect;
385
+ if (position.overlayX == "center") {
386
+ x = originPoint.x - width / 2;
387
+ } else {
388
+ x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
389
+ }
390
+ let y;
391
+ if (position.overlayY == "center") {
392
+ y = originPoint.y - height / 2;
393
+ } else {
394
+ y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
395
+ }
396
+ return {
397
+ x,
398
+ y
399
+ };
400
+ }
401
+ function getOriginRelativePoint(originRect, position) {
402
+ let x;
403
+ if (position.originX == "center") {
404
+ x = originRect.left + originRect.width / 2;
405
+ } else {
406
+ const startX = originRect.left;
407
+ const endX = originRect.right;
408
+ x = position.originX == "left" ? startX : endX;
409
+ }
410
+ let y;
411
+ if (position.originY == "center") {
412
+ y = originRect.top + originRect.height / 2;
413
+ } else {
414
+ y = position.originY == "top" ? originRect.top : originRect.bottom;
415
+ }
416
+ return {
417
+ x,
418
+ y
419
+ };
420
+ }
421
+ function subscribeLayoutEvent(event) {
422
+ window.addEventListener("scroll", event, true);
423
+ window.addEventListener("resize", event);
424
+ window.addEventListener("orientationchange", event);
425
+ return () => {
426
+ window.removeEventListener("scroll", event, true);
427
+ window.removeEventListener("resize", event);
428
+ window.removeEventListener("orientationchange", event);
429
+ };
430
+ }
431
+ function subscribeOverlayResize(overlay2, callback) {
432
+ if (overlay2 instanceof Element) {
433
+ const resizeObserver = new ResizeObserver(callback);
434
+ resizeObserver.observe(overlay2);
435
+ return () => resizeObserver.disconnect();
436
+ }
437
+ return () => {
438
+ };
439
+ }
440
+ function subscribeOriginResize(origin, callback) {
441
+ if (origin instanceof Element) {
442
+ const observer = new MutationObserver(callback);
443
+ observer.observe(origin, {
444
+ attributeFilter: ["style"]
445
+ });
446
+ return () => observer.disconnect();
447
+ }
448
+ return () => {
449
+ };
450
+ }
451
+ FlexibleOverlay.install = function(app) {
452
+ app.component(FlexibleOverlay.name, FlexibleOverlay);
453
+ };
454
+ FixedOverlay.install = function(app) {
455
+ app.component(FixedOverlay.name, FixedOverlay);
456
+ };
457
+ var dropdown = "";
458
+ var Dropdown = defineComponent({
459
+ name: "DDropdown",
460
+ props: dropdownProps,
461
+ emits: [],
462
+ setup(props, ctx) {
463
+ const {
464
+ isOpen,
465
+ origin,
466
+ trigger,
467
+ closeScope,
468
+ closeOnMouseLeaveMenu
469
+ } = toRefs(props);
470
+ const visible = ref(false);
471
+ watch(isOpen, (value) => {
472
+ visible.value = value;
473
+ }, {
474
+ immediate: true
475
+ });
476
+ const position = {
477
+ originX: "center",
478
+ originY: "bottom",
479
+ overlayX: "center",
480
+ overlayY: "top"
481
+ };
482
+ const {
483
+ dropdownEl
484
+ } = useDropdown({
485
+ visible,
486
+ origin,
487
+ trigger,
488
+ closeScope,
489
+ closeOnMouseLeaveMenu
490
+ });
491
+ const animatedVisible = computed(() => {
492
+ return props.showAnimation ? visible.value : true;
493
+ });
494
+ return () => {
495
+ return createVNode(Fragment, null, [createVNode(FlexibleOverlay, {
496
+ "origin": props.origin,
497
+ "visible": visible.value,
498
+ "onUpdate:visible": ($event) => visible.value = $event,
499
+ "position": position,
500
+ "hasBackdrop": false
501
+ }, {
502
+ default: () => [createVNode(Transition, {
503
+ "name": "devui-dropdown-fade"
504
+ }, {
505
+ default: () => {
506
+ var _a, _b;
507
+ return [withDirectives(createVNode("div", {
508
+ "ref": dropdownEl,
509
+ "style": "min-width:102px"
510
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
511
+ }
512
+ })]
513
+ })]);
514
+ };
515
+ }
516
+ });
517
+ Dropdown.install = function(app) {
518
+ app.component(Dropdown.name, Dropdown);
519
+ };
520
+ var index = {
521
+ title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
522
+ category: "\u5BFC\u822A",
523
+ status: void 0,
524
+ install(app) {
525
+ app.use(Dropdown);
526
+ }
527
+ };
528
+ export { Dropdown, index as default };
@@ -0,0 +1 @@
1
+ var K=Object.defineProperty,Q=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var j=(a,t,f)=>t in a?K(a,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[t]=f,V=(a,t)=>{for(var f in t||(t={}))Z.call(t,f)&&j(a,f,t[f]);if(L)for(var f of L(t))ee.call(t,f)&&j(a,f,t[f]);return a},X=(a,t)=>Q(a,W(t));(function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.index={},a.Vue))})(this,function(a,t){"use strict";const f={origin:{type:Object},isOpen:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},closeOnMouseLeaveMenu:{type:Boolean,default:!1},showAnimation:{type:Boolean,default:!0}};function Y(e){return!!(e==null?void 0:e.$el)}function S(e){return e instanceof Element?e:e&&typeof e=="object"&&e.$el instanceof Element?e.$el:null}function g(e,o,n){return e==null||e.addEventListener(o,n),()=>{e==null||e.removeEventListener(o,n)}}const F=({visible:e,trigger:o,origin:n,closeScope:r,closeOnMouseLeaveMenu:i})=>{const l=t.ref(),s=()=>{r.value!=="none"&&(e.value=!1)};return t.watch([o,n,l],([u,v,y],m,b)=>{const c=S(v);if(!c||!y)return;const p=[g(y,"click",()=>{r.value==="all"&&(e.value=!1)})];if(u==="click")p.push(g(c,"click",()=>e.value=!e.value),g(document,"click",d=>{if(!e.value)return;const h=d.target;c.contains(h)||y.contains(h)||s()}),g(y,"mouseleave",()=>{i.value&&(e.value=!1)}));else if(u==="hover"){let d=!1,h=!1;const O=async w=>{await new Promise(C=>setTimeout(C,50)),!(w==="origin"&&d||w==="dropdown"&&h)&&s()};p.push(g(c,"mouseenter",()=>{h=!0,e.value=!0}),g(c,"mouseleave",()=>{h=!1,i.value||O("origin")}),g(y,"mouseenter",()=>{d=!0,e.value=!0}),g(y,"mouseleave",()=>{d=!1,O("dropdown")}))}b(()=>p.forEach(d=>d()))}),{dropdownEl:l}};var te="";function _(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const R=t.defineComponent({setup(e,o){return()=>{let n;return t.createVNode(t.Teleport,{to:"#d-overlay-anchor"},{default:()=>[t.createVNode(t.Transition,{name:"devui-overlay-fade"},_(n=t.renderSlot(o.slots,"default"))?n:{default:()=>[n]})]})}}}),D={visible:{type:Boolean},"onUpdate:visible":{type:Function},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},backdropClick:{type:Function},backdropClose:{type:Boolean,default:!0},hasBackdrop:{type:Boolean,default:!0}},M=X(V({},D),{overlayStyle:{type:[String,Object],default:void 0}}),T=V({origin:{type:Object,require:!0},position:{type:Object,default:()=>({originX:"left",originY:"top",overlayX:"left",overlayY:"top"})}},D);function N(e){const o=t.computed(()=>["devui-overlay-background",e.backgroundClass,e.hasBackdrop?"devui-overlay-background__color":"devui-overlay-background__disabled"]),n=t.computed(()=>"devui-overlay"),r=l=>{var s,u;l.preventDefault(),(s=e.backdropClick)==null||s.call(e),e.backdropClose&&((u=e["onUpdate:visible"])==null||u.call(e,!1))},i=l=>l.cancelBubble=!0;return t.onMounted(()=>{const l=document.body,s=l.style.overflow,u=l.style.position;t.watch([()=>e.visible,()=>e.backgroundBlock],([v,y])=>{if(y){const m=l.getBoundingClientRect().y;v?(l.style.overflowY="scroll",l.style.position=v?"fixed":"",l.style.top=`${m}px`):(l.style.overflowY=s,l.style.position=u,l.style.top="",window.scrollTo(0,-m))}}),t.onUnmounted(()=>{document.body.style.overflow=s})}),{backgroundClass:o,overlayClass:n,handleBackdropClick:r,handleOverlayBubbleCancel:i}}const x=t.defineComponent({name:"DFixedOverlay",props:M,setup(e,o){const{backgroundClass:n,overlayClass:r,handleBackdropClick:i,handleOverlayBubbleCancel:l}=N(e);return()=>t.createVNode(R,null,{default:()=>[t.withDirectives(t.createVNode("div",{class:n.value,style:e.backgroundStyle,onClick:i},[t.createVNode("div",{class:r.value,style:e.overlayStyle,onClick:l},[t.renderSlot(o.slots,"default")])]),[[t.vShow,e.visible]])]})}}),B=t.defineComponent({name:"DFlexibleOverlay",props:T,emits:["onUpdate:visible"],setup(e,o){const n=t.ref(null),r=t.reactive({position:"absolute"});t.onMounted(async()=>{const v=(c,p,d)=>{const h=P(c,p,d);r.left=`${h.x}px`,r.top=`${h.y}px`},y=t.computed(()=>{const c=n.value,p=z(e.origin);if(!(!c||!p))return{origin:p,overlay:c}}),m=t.toRef(e,"visible"),b=t.toRef(e,"position");t.watch([y,m,b],async([c,p,d],h,O)=>{if(!p||!c)return;const{origin:w,overlay:C}=c;v(d,C.getBoundingClientRect(),w);const J=[q(()=>v(d,C.getBoundingClientRect(),w)),G(C,E=>v(d,E[0].contentRect,w)),H(w,()=>v(d,C.getBoundingClientRect(),w))];O(()=>{J.forEach(E=>E())})})});const{backgroundClass:i,overlayClass:l,handleBackdropClick:s,handleOverlayBubbleCancel:u}=N(e);return()=>t.createVNode(R,null,{default:()=>[t.withDirectives(t.createVNode("div",{style:e.backgroundStyle,class:i.value,onClick:s},[t.createVNode("div",{ref:n,class:l.value,style:r,onClick:u},[t.renderSlot(o.slots,"default")])]),[[t.vShow,e.visible]])]})}});function z(e){return e instanceof Element?e:t.isRef(e)?S(e.value):Y(e)?S(e):e}function P(e,o,n){const r=$(n),i=A(r,e);return U(i,o,e)}function $(e){if(e instanceof Element)return e.getBoundingClientRect();const o=e.width||0,n=e.height||0;return{top:e.y,bottom:e.y+n,left:e.x,right:e.x+o,height:n,width:o}}function U(e,o,n){let r;const{width:i,height:l}=o;n.overlayX=="center"?r=e.x-i/2:r=n.overlayX=="left"?e.x:e.x-i;let s;return n.overlayY=="center"?s=e.y-l/2:s=n.overlayY=="top"?e.y:e.y-l,{x:r,y:s}}function A(e,o){let n;if(o.originX=="center")n=e.left+e.width/2;else{const i=e.left,l=e.right;n=o.originX=="left"?i:l}let r;return o.originY=="center"?r=e.top+e.height/2:r=o.originY=="top"?e.top:e.bottom,{x:n,y:r}}function q(e){return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}}function G(e,o){if(e instanceof Element){const n=new ResizeObserver(o);return n.observe(e),()=>n.disconnect()}return()=>{}}function H(e,o){if(e instanceof Element){const n=new MutationObserver(o);return n.observe(e,{attributeFilter:["style"]}),()=>n.disconnect()}return()=>{}}B.install=function(e){e.component(B.name,B)},x.install=function(e){e.component(x.name,x)};var ne="",k=t.defineComponent({name:"DDropdown",props:f,emits:[],setup(e,o){const{isOpen:n,origin:r,trigger:i,closeScope:l,closeOnMouseLeaveMenu:s}=t.toRefs(e),u=t.ref(!1);t.watch(n,b=>{u.value=b},{immediate:!0});const v={originX:"center",originY:"bottom",overlayX:"center",overlayY:"top"},{dropdownEl:y}=F({visible:u,origin:r,trigger:i,closeScope:l,closeOnMouseLeaveMenu:s}),m=t.computed(()=>e.showAnimation?u.value:!0);return()=>t.createVNode(t.Fragment,null,[t.createVNode(B,{origin:e.origin,visible:u.value,"onUpdate:visible":b=>u.value=b,position:v,hasBackdrop:!1},{default:()=>[t.createVNode(t.Transition,{name:"devui-dropdown-fade"},{default:()=>{var b,c;return[t.withDirectives(t.createVNode("div",{ref:y,style:"min-width:102px"},[(c=(b=o.slots).default)==null?void 0:c.call(b)]),[[t.vShow,m.value]])]}})]})])}});k.install=function(e){e.component(k.name,k)};var I={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:void 0,install(e){e.use(k)}};a.Dropdown=k,a.default=I,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "dropdown",
3
+ "version": "0.0.0",
4
+ "main": "index.umd.js",
5
+ "module": "index.es.js",
6
+ "style": "style.css"
7
+ }
@@ -0,0 +1 @@
1
+ .devui-overlay-background{position:fixed;top:0;left:0;height:100vh;width:100vw;display:flex}.devui-overlay-background__color{background:rgba(0,0,0,.4)}.devui-overlay-background .devui-overlay{position:relative;z-index:1000;pointer-events:auto}.devui-overlay-background__disabled{pointer-events:none}@keyframes d-overlay-fade{0%{opacity:0}to{opacity:1}}.devui-overlay-fade-enter{opacity:0}.devui-overlay-fade-enter-active{animation-name:d-overlay-fade;animation-duration:.3s}.devui-overlay-fade-leave{opacity:1}.devui-overlay-fade-leave-active{animation-name:d-overlay-fade;animation-duration:.3s;animation-direction:reverse}.devui-dropdown span.icon-chevron-down,.devui-dropdown span.icon-select-arrow{display:inline-block;vertical-align:text-top}.devui-dropdown-animation span.icon-chevron-down,.devui-dropdown-animation span.icon-select-arrow{transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-dropdown.open span.icon-chevron-down,.devui-dropdown.open span.icon-select-arrow{transform:rotate(180deg)}@keyframes d-dropdown-fade{0%{opacity:0;transform:scaleY(.9999) scaleY(0)}to{opacity:1;transform:scaleY(.8) scaleY(4px)}}.devui-dropdown-fade-enter{opacity:0}.devui-dropdown-fade-enter-active{animation-name:d-dropdown-fade;animation-duration:.3s}.devui-dropdown-fade-leave{opacity:1}.devui-dropdown-fade-leave-active{animation-name:d-dropdown-fade;animation-duration:.3s;animation-direction:reverse}
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;