vue-devui 1.0.0-beta.3 → 1.0.0-beta.7

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 (182) 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 +128 -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/button/index.es.js +3 -3
  17. package/button/index.umd.js +1 -1
  18. package/card/index.d.ts +7 -0
  19. package/carousel/index.d.ts +7 -0
  20. package/carousel/index.es.js +3 -3
  21. package/carousel/index.umd.js +1 -1
  22. package/cascader/index.d.ts +7 -0
  23. package/cascader/index.es.js +1239 -83
  24. package/cascader/index.umd.js +1 -1
  25. package/cascader/style.css +1 -1
  26. package/checkbox/index.d.ts +7 -0
  27. package/checkbox/index.es.js +42 -7
  28. package/checkbox/index.umd.js +1 -1
  29. package/comment/index.d.ts +7 -0
  30. package/comment/index.es.js +57 -0
  31. package/comment/index.umd.js +1 -0
  32. package/comment/package.json +7 -0
  33. package/comment/style.css +1 -0
  34. package/date-picker/index.d.ts +7 -0
  35. package/date-picker/index.es.js +18 -17
  36. package/date-picker/index.umd.js +1 -1
  37. package/date-picker/style.css +1 -1
  38. package/dragdrop/index.d.ts +7 -0
  39. package/dragdrop/index.es.js +32 -0
  40. package/dragdrop/index.umd.js +1 -0
  41. package/dragdrop/package.json +7 -0
  42. package/drawer/index.d.ts +7 -0
  43. package/drawer/index.es.js +112 -45
  44. package/drawer/index.umd.js +1 -1
  45. package/drawer/style.css +1 -1
  46. package/dropdown/index.d.ts +7 -0
  47. package/dropdown/index.es.js +528 -0
  48. package/dropdown/index.umd.js +1 -0
  49. package/dropdown/package.json +7 -0
  50. package/dropdown/style.css +1 -0
  51. package/editable-select/index.d.ts +7 -0
  52. package/editable-select/index.es.js +5648 -434
  53. package/editable-select/index.umd.js +27 -1
  54. package/editable-select/style.css +1 -1
  55. package/form/index.d.ts +7 -0
  56. package/form/index.es.js +446 -5558
  57. package/form/index.umd.js +1 -27
  58. package/form/style.css +1 -1
  59. package/fullscreen/index.d.ts +7 -0
  60. package/gantt/index.d.ts +7 -0
  61. package/gantt/index.es.js +535 -0
  62. package/gantt/index.umd.js +1 -0
  63. package/gantt/package.json +7 -0
  64. package/gantt/style.css +1 -0
  65. package/grid/index.d.ts +7 -0
  66. package/grid/index.es.js +269 -0
  67. package/grid/index.umd.js +1 -0
  68. package/grid/package.json +7 -0
  69. package/grid/style.css +1 -0
  70. package/icon/index.d.ts +7 -0
  71. package/icon/index.es.js +3 -3
  72. package/icon/index.umd.js +1 -1
  73. package/image-preview/index.d.ts +7 -0
  74. package/image-preview/index.es.js +22 -1
  75. package/image-preview/index.umd.js +1 -1
  76. package/index.d.ts +7 -0
  77. package/input/index.d.ts +7 -0
  78. package/input/index.es.js +15 -14
  79. package/input/index.umd.js +1 -1
  80. package/input-icon/index.d.ts +7 -0
  81. package/input-icon/index.es.js +331 -0
  82. package/input-icon/index.umd.js +1 -0
  83. package/input-icon/package.json +7 -0
  84. package/input-icon/style.css +1 -0
  85. package/input-number/index.d.ts +7 -0
  86. package/input-number/index.es.js +3 -3
  87. package/input-number/index.umd.js +1 -1
  88. package/layout/index.d.ts +7 -0
  89. package/loading/index.d.ts +7 -0
  90. package/modal/index.d.ts +7 -0
  91. package/modal/index.es.js +102 -84
  92. package/modal/index.umd.js +1 -1
  93. package/modal/style.css +1 -1
  94. package/nav-sprite/index.d.ts +7 -0
  95. package/overlay/index.d.ts +7 -0
  96. package/overlay/index.es.js +100 -82
  97. package/overlay/index.umd.js +1 -1
  98. package/overlay/style.css +1 -1
  99. package/package.json +4 -33
  100. package/pagination/index.d.ts +7 -0
  101. package/panel/index.d.ts +7 -0
  102. package/popover/index.d.ts +7 -0
  103. package/progress/index.d.ts +7 -0
  104. package/quadrant-diagram/index.d.ts +7 -0
  105. package/radio/index.d.ts +7 -0
  106. package/rate/index.d.ts +7 -0
  107. package/read-tip/index.d.ts +7 -0
  108. package/read-tip/index.es.js +244 -0
  109. package/read-tip/index.umd.js +1 -0
  110. package/read-tip/package.json +7 -0
  111. package/read-tip/style.css +1 -0
  112. package/ripple/index.d.ts +7 -0
  113. package/search/index.d.ts +7 -0
  114. package/search/index.es.js +15 -14
  115. package/search/index.umd.js +1 -1
  116. package/select/index.d.ts +7 -0
  117. package/select/index.es.js +45 -10
  118. package/select/index.umd.js +1 -1
  119. package/skeleton/index.d.ts +7 -0
  120. package/skeleton/index.es.js +147 -25
  121. package/skeleton/index.umd.js +1 -1
  122. package/skeleton/style.css +1 -1
  123. package/slider/index.d.ts +7 -0
  124. package/slider/index.es.js +8 -6
  125. package/slider/index.umd.js +1 -1
  126. package/splitter/index.d.ts +7 -0
  127. package/status/index.d.ts +7 -0
  128. package/steps-guide/index.d.ts +7 -0
  129. package/steps-guide/index.es.js +99 -73
  130. package/steps-guide/index.umd.js +1 -1
  131. package/steps-guide/style.css +1 -1
  132. package/sticky/index.d.ts +7 -0
  133. package/style.css +1 -1
  134. package/switch/index.d.ts +7 -0
  135. package/table/index.d.ts +7 -0
  136. package/table/index.es.js +1490 -157
  137. package/table/index.umd.js +1 -1
  138. package/table/style.css +1 -1
  139. package/tabs/index.d.ts +7 -0
  140. package/tabs/index.es.js +1 -0
  141. package/tabs/index.umd.js +1 -1
  142. package/tag/index.d.ts +7 -0
  143. package/tag/index.es.js +105 -0
  144. package/tag/index.umd.js +1 -0
  145. package/tag/package.json +7 -0
  146. package/tag/style.css +1 -0
  147. package/tag-input/index.d.ts +7 -0
  148. package/textarea/index.d.ts +7 -0
  149. package/textarea/index.es.js +132 -0
  150. package/textarea/index.umd.js +1 -0
  151. package/textarea/package.json +7 -0
  152. package/textarea/style.css +1 -0
  153. package/time-axis/index.d.ts +7 -0
  154. package/time-axis/index.es.js +238 -21
  155. package/time-axis/index.umd.js +1 -1
  156. package/time-axis/style.css +1 -1
  157. package/time-picker/index.d.ts +7 -0
  158. package/time-picker/index.es.js +45 -22
  159. package/time-picker/index.umd.js +1 -1
  160. package/time-picker/style.css +1 -1
  161. package/toast/index.d.ts +7 -0
  162. package/toast/index.es.js +3 -3
  163. package/toast/index.umd.js +1 -1
  164. package/toast/style.css +1 -1
  165. package/tooltip/index.d.ts +7 -0
  166. package/transfer/index.d.ts +7 -0
  167. package/transfer/index.es.js +345 -70
  168. package/transfer/index.umd.js +1 -1
  169. package/transfer/style.css +1 -1
  170. package/tree/index.d.ts +7 -0
  171. package/tree/index.es.js +11 -4
  172. package/tree/index.umd.js +1 -1
  173. package/tree-select/index.d.ts +7 -0
  174. package/tree-select/index.es.js +435 -110
  175. package/tree-select/index.umd.js +1 -1
  176. package/tree-select/style.css +1 -1
  177. package/upload/index.d.ts +7 -0
  178. package/upload/index.es.js +4 -4
  179. package/upload/index.umd.js +1 -1
  180. package/upload/style.css +1 -1
  181. package/vue-devui.es.js +17873 -14511
  182. package/vue-devui.umd.js +17 -17
@@ -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;