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

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 (293) hide show
  1. package/README.md +132 -200
  2. package/auto-complete/index.es.js +150 -110
  3. package/auto-complete/index.umd.js +5 -1
  4. package/auto-complete/style.css +1 -1
  5. package/avatar/index.es.js +77 -81
  6. package/avatar/index.umd.js +1 -1
  7. package/button/index.es.js +23 -15
  8. package/button/index.umd.js +1 -1
  9. package/button/style.css +1 -1
  10. package/card/index.es.js +3 -6
  11. package/card/index.umd.js +1 -1
  12. package/checkbox/index.es.js +5 -11
  13. package/checkbox/index.umd.js +1 -1
  14. package/comment/index.es.js +4 -6
  15. package/comment/index.umd.js +1 -1
  16. package/countdown/index.es.js +3 -6
  17. package/countdown/index.umd.js +1 -1
  18. package/editable-select/index.es.js +120 -167
  19. package/editable-select/index.umd.js +1 -1
  20. package/grid/index.es.js +30 -36
  21. package/grid/index.umd.js +1 -1
  22. package/image-preview/index.es.js +19 -19
  23. package/image-preview/index.umd.js +1 -1
  24. package/input/index.es.js +2 -5
  25. package/input/index.umd.js +1 -1
  26. package/layout/index.es.js +9 -22
  27. package/layout/index.umd.js +1 -1
  28. package/loading/index.es.js +40 -25
  29. package/loading/index.umd.js +1 -1
  30. package/modal/index.es.js +55 -47
  31. package/modal/index.umd.js +1 -1
  32. package/notification/index.es.js +100 -10
  33. package/notification/index.umd.js +1 -1
  34. package/notification/style.css +1 -1
  35. package/nuxt/components/DropdownPropsKey.js +3 -0
  36. package/nuxt/components/LoadingOptions.js +3 -0
  37. package/nuxt/components/autoCompleteProps.js +3 -0
  38. package/nuxt/components/avatarProps.js +3 -0
  39. package/nuxt/components/cardProps.js +3 -0
  40. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  41. package/nuxt/components/checkboxGroupProps.js +3 -0
  42. package/nuxt/components/checkboxProps.js +3 -0
  43. package/nuxt/components/colProps.js +3 -0
  44. package/nuxt/components/colPropsBaseClass.js +3 -0
  45. package/nuxt/components/colPropsBaseStyle.js +3 -0
  46. package/nuxt/components/commentProps.js +3 -0
  47. package/nuxt/components/countdownProps.js +3 -0
  48. package/nuxt/components/editableSelectProps.js +3 -0
  49. package/nuxt/components/imagePreviewProps.js +3 -0
  50. package/nuxt/components/inputProps.js +3 -0
  51. package/nuxt/components/loadingProps.js +3 -0
  52. package/nuxt/components/modalProps.js +3 -0
  53. package/nuxt/components/progressProps.js +3 -0
  54. package/nuxt/components/rateProps.js +3 -0
  55. package/nuxt/components/readTipProps.js +3 -0
  56. package/nuxt/components/resultProps.js +3 -0
  57. package/nuxt/components/rowProps.js +3 -0
  58. package/nuxt/components/screenSizes.js +3 -0
  59. package/nuxt/components/skeletonProps.js +3 -0
  60. package/nuxt/components/sliderProps.js +3 -0
  61. package/nuxt/components/splitterProps.js +3 -0
  62. package/nuxt/components/statisticProps.js +3 -0
  63. package/nuxt/components/switchProps.js +3 -0
  64. package/nuxt/components/tagInputProps.js +3 -0
  65. package/nuxt/components/tagProps.js +3 -0
  66. package/nuxt/components/textareaProps.js +3 -0
  67. package/nuxt/components/timeAxisProps.js +3 -0
  68. package/overlay/index.es.js +5 -5
  69. package/overlay/index.umd.js +1 -1
  70. package/package.json +1 -1
  71. package/pagination/index.es.js +14 -13
  72. package/pagination/index.umd.js +1 -1
  73. package/popover/index.es.js +7 -7
  74. package/popover/index.umd.js +12 -12
  75. package/progress/index.es.js +34 -36
  76. package/progress/index.umd.js +3 -3
  77. package/progress/style.css +1 -1
  78. package/radio/index.es.js +8 -2
  79. package/radio/index.umd.js +1 -1
  80. package/radio/style.css +1 -1
  81. package/rate/index.es.js +4 -7
  82. package/rate/index.umd.js +1 -1
  83. package/read-tip/index.es.js +34 -34
  84. package/read-tip/index.umd.js +1 -1
  85. package/read-tip/style.css +1 -1
  86. package/result/index.es.js +2 -5
  87. package/result/index.umd.js +1 -1
  88. package/ripple/index.es.js +43 -42
  89. package/ripple/index.umd.js +1 -1
  90. package/search/index.es.js +11 -11
  91. package/search/index.umd.js +8 -8
  92. package/skeleton/index.es.js +9 -12
  93. package/skeleton/index.umd.js +1 -1
  94. package/slider/index.es.js +59 -62
  95. package/slider/index.umd.js +1 -1
  96. package/splitter/index.es.js +176 -136
  97. package/splitter/index.umd.js +13 -13
  98. package/statistic/index.es.js +7 -18
  99. package/statistic/index.umd.js +1 -1
  100. package/style.css +1 -1
  101. package/switch/index.es.js +4 -7
  102. package/switch/index.umd.js +1 -1
  103. package/switch/style.css +1 -1
  104. package/tag/index.es.js +13 -17
  105. package/tag/index.umd.js +1 -1
  106. package/tag/style.css +1 -1
  107. package/tag-input/index.es.js +3 -6
  108. package/tag-input/index.umd.js +1 -1
  109. package/textarea/index.es.js +2 -5
  110. package/textarea/index.umd.js +1 -1
  111. package/timeline/index.es.js +10 -16
  112. package/timeline/index.umd.js +1 -1
  113. package/upload/index.es.js +160 -67
  114. package/upload/index.umd.js +1 -1
  115. package/upload/style.css +1 -1
  116. package/vue-devui.es.js +12182 -24718
  117. package/vue-devui.umd.js +24 -20
  118. package/accordion/index.d.ts +0 -7
  119. package/accordion/index.es.js +0 -723
  120. package/accordion/index.umd.js +0 -1
  121. package/accordion/package.json +0 -7
  122. package/accordion/style.css +0 -1
  123. package/anchor/index.d.ts +0 -7
  124. package/anchor/index.es.js +0 -263
  125. package/anchor/index.umd.js +0 -1
  126. package/anchor/package.json +0 -7
  127. package/anchor/style.css +0 -1
  128. package/back-top/index.d.ts +0 -7
  129. package/back-top/index.es.js +0 -130
  130. package/back-top/index.umd.js +0 -1
  131. package/back-top/package.json +0 -7
  132. package/back-top/style.css +0 -1
  133. package/breadcrumb/index.d.ts +0 -7
  134. package/breadcrumb/index.es.js +0 -128
  135. package/breadcrumb/index.umd.js +0 -1
  136. package/breadcrumb/package.json +0 -7
  137. package/breadcrumb/style.css +0 -1
  138. package/carousel/index.d.ts +0 -7
  139. package/carousel/index.es.js +0 -314
  140. package/carousel/index.umd.js +0 -1
  141. package/carousel/package.json +0 -7
  142. package/carousel/style.css +0 -1
  143. package/cascader/index.d.ts +0 -7
  144. package/cascader/index.es.js +0 -5971
  145. package/cascader/index.umd.js +0 -27
  146. package/cascader/package.json +0 -7
  147. package/cascader/style.css +0 -1
  148. package/color-picker/index.d.ts +0 -7
  149. package/color-picker/index.es.js +0 -8196
  150. package/color-picker/index.umd.js +0 -27
  151. package/color-picker/package.json +0 -7
  152. package/color-picker/style.css +0 -1
  153. package/date-picker/index.d.ts +0 -7
  154. package/date-picker/index.es.js +0 -1154
  155. package/date-picker/index.umd.js +0 -1
  156. package/date-picker/package.json +0 -7
  157. package/date-picker/style.css +0 -1
  158. package/dragdrop/index.d.ts +0 -7
  159. package/dragdrop/index.es.js +0 -157
  160. package/dragdrop/index.umd.js +0 -1
  161. package/dragdrop/package.json +0 -7
  162. package/drawer/index.d.ts +0 -7
  163. package/drawer/index.es.js +0 -234
  164. package/drawer/index.umd.js +0 -1
  165. package/drawer/package.json +0 -7
  166. package/drawer/style.css +0 -1
  167. package/dropdown/index.d.ts +0 -7
  168. package/dropdown/index.es.js +0 -693
  169. package/dropdown/index.umd.js +0 -1
  170. package/dropdown/package.json +0 -7
  171. package/dropdown/style.css +0 -1
  172. package/form/index.d.ts +0 -7
  173. package/form/index.es.js +0 -7876
  174. package/form/index.umd.js +0 -27
  175. package/form/package.json +0 -7
  176. package/form/style.css +0 -1
  177. package/gantt/index.d.ts +0 -7
  178. package/gantt/index.es.js +0 -523
  179. package/gantt/index.umd.js +0 -1
  180. package/gantt/package.json +0 -7
  181. package/gantt/style.css +0 -1
  182. package/input-icon/index.d.ts +0 -7
  183. package/input-icon/index.es.js +0 -332
  184. package/input-icon/index.umd.js +0 -1
  185. package/input-icon/package.json +0 -7
  186. package/input-icon/style.css +0 -1
  187. package/input-number/index.d.ts +0 -7
  188. package/input-number/index.es.js +0 -229
  189. package/input-number/index.umd.js +0 -1
  190. package/input-number/package.json +0 -7
  191. package/input-number/style.css +0 -1
  192. package/list/index.d.ts +0 -7
  193. package/list/index.es.js +0 -39
  194. package/list/index.umd.js +0 -1
  195. package/list/package.json +0 -7
  196. package/list/style.css +0 -1
  197. package/nav-sprite/index.d.ts +0 -7
  198. package/nav-sprite/index.es.js +0 -68
  199. package/nav-sprite/index.umd.js +0 -1
  200. package/nav-sprite/package.json +0 -7
  201. package/nuxt/components/Accordion.js +0 -3
  202. package/nuxt/components/Anchor.js +0 -3
  203. package/nuxt/components/BackTop.js +0 -3
  204. package/nuxt/components/Breadcrumb.js +0 -3
  205. package/nuxt/components/Carousel.js +0 -3
  206. package/nuxt/components/CarouselItem.js +0 -3
  207. package/nuxt/components/Cascader.js +0 -3
  208. package/nuxt/components/ColorPicker.js +0 -3
  209. package/nuxt/components/Column.js +0 -3
  210. package/nuxt/components/DatePicker.js +0 -3
  211. package/nuxt/components/Drawer.js +0 -3
  212. package/nuxt/components/DrawerService.js +0 -3
  213. package/nuxt/components/Dropdown.js +0 -3
  214. package/nuxt/components/DropdownMenu.js +0 -3
  215. package/nuxt/components/Form.js +0 -3
  216. package/nuxt/components/FormControl.js +0 -3
  217. package/nuxt/components/FormItem.js +0 -3
  218. package/nuxt/components/FormLabel.js +0 -3
  219. package/nuxt/components/FormOperation.js +0 -3
  220. package/nuxt/components/Gantt.js +0 -3
  221. package/nuxt/components/InputIcon.js +0 -3
  222. package/nuxt/components/InputNumber.js +0 -3
  223. package/nuxt/components/List.js +0 -3
  224. package/nuxt/components/ListItem.js +0 -3
  225. package/nuxt/components/NavSprite.js +0 -2
  226. package/nuxt/components/QuadrantDiagram.js +0 -3
  227. package/nuxt/components/Select.js +0 -3
  228. package/nuxt/components/StepsGuide.js +0 -3
  229. package/nuxt/components/StickSlider.js +0 -3
  230. package/nuxt/components/Sticky.js +0 -2
  231. package/nuxt/components/Table.js +0 -3
  232. package/nuxt/components/Tabs.js +0 -3
  233. package/nuxt/components/TimePicker.js +0 -3
  234. package/nuxt/components/Tooltip.js +0 -3
  235. package/nuxt/components/Transfer.js +0 -3
  236. package/nuxt/components/Tree.js +0 -3
  237. package/nuxt/components/TreeSelect.js +0 -3
  238. package/nuxt/components/dropdownMenuProps.js +0 -3
  239. package/nuxt/components/tooltipProps.js +0 -3
  240. package/quadrant-diagram/index.d.ts +0 -7
  241. package/quadrant-diagram/index.es.js +0 -5728
  242. package/quadrant-diagram/index.umd.js +0 -27
  243. package/quadrant-diagram/package.json +0 -7
  244. package/quadrant-diagram/style.css +0 -1
  245. package/select/index.d.ts +0 -7
  246. package/select/index.es.js +0 -706
  247. package/select/index.umd.js +0 -1
  248. package/select/package.json +0 -7
  249. package/select/style.css +0 -1
  250. package/steps-guide/index.d.ts +0 -7
  251. package/steps-guide/index.es.js +0 -242
  252. package/steps-guide/index.umd.js +0 -1
  253. package/steps-guide/package.json +0 -7
  254. package/steps-guide/style.css +0 -1
  255. package/sticky/index.d.ts +0 -7
  256. package/sticky/index.es.js +0 -197
  257. package/sticky/index.umd.js +0 -1
  258. package/sticky/package.json +0 -7
  259. package/table/index.d.ts +0 -7
  260. package/table/index.es.js +0 -2024
  261. package/table/index.umd.js +0 -1
  262. package/table/package.json +0 -7
  263. package/table/style.css +0 -1
  264. package/tabs/index.d.ts +0 -7
  265. package/tabs/index.es.js +0 -194
  266. package/tabs/index.umd.js +0 -1
  267. package/tabs/package.json +0 -7
  268. package/tabs/style.css +0 -1
  269. package/time-picker/index.d.ts +0 -7
  270. package/time-picker/index.es.js +0 -1238
  271. package/time-picker/index.umd.js +0 -1
  272. package/time-picker/package.json +0 -7
  273. package/time-picker/style.css +0 -1
  274. package/tooltip/index.d.ts +0 -7
  275. package/tooltip/index.es.js +0 -5835
  276. package/tooltip/index.umd.js +0 -27
  277. package/tooltip/package.json +0 -7
  278. package/tooltip/style.css +0 -1
  279. package/transfer/index.d.ts +0 -7
  280. package/transfer/index.es.js +0 -7615
  281. package/transfer/index.umd.js +0 -27
  282. package/transfer/package.json +0 -7
  283. package/transfer/style.css +0 -1
  284. package/tree/index.d.ts +0 -7
  285. package/tree/index.es.js +0 -6495
  286. package/tree/index.umd.js +0 -27
  287. package/tree/package.json +0 -7
  288. package/tree/style.css +0 -1
  289. package/tree-select/index.d.ts +0 -7
  290. package/tree-select/index.es.js +0 -627
  291. package/tree-select/index.umd.js +0 -1
  292. package/tree-select/package.json +0 -7
  293. 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 };