vue-devui 1.0.0-pre.0 → 1.0.0-rc.10

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 (347) hide show
  1. package/README.md +149 -187
  2. package/alert/index.es.js +74 -45
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8182 -296
  6. package/auto-complete/index.umd.js +29 -1
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +153 -146
  9. package/avatar/index.umd.js +1 -1
  10. package/avatar/style.css +1 -1
  11. package/badge/index.es.js +30 -5
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5741 -127
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +59 -35
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +8060 -255
  21. package/checkbox/index.umd.js +27 -1
  22. package/checkbox/style.css +1 -1
  23. package/{accordion → collapse}/index.d.ts +0 -0
  24. package/collapse/index.es.js +379 -0
  25. package/collapse/index.umd.js +1 -0
  26. package/{anchor → collapse}/package.json +1 -1
  27. package/collapse/style.css +1 -0
  28. package/countdown/index.es.js +5 -7
  29. package/countdown/index.umd.js +1 -1
  30. package/date-picker/index.es.js +8159 -288
  31. package/date-picker/index.umd.js +27 -1
  32. package/date-picker/style.css +1 -1
  33. package/drawer/index.es.js +31 -4
  34. package/drawer/index.umd.js +1 -1
  35. package/drawer/style.css +1 -1
  36. package/dropdown/index.es.js +297 -181
  37. package/dropdown/index.umd.js +1 -1
  38. package/dropdown/style.css +1 -1
  39. package/editable-select/index.es.js +525 -154
  40. package/editable-select/index.umd.js +1 -1
  41. package/editable-select/style.css +1 -1
  42. package/form/index.es.js +1039 -1175
  43. package/form/index.umd.js +15 -15
  44. package/form/style.css +1 -1
  45. package/fullscreen/index.es.js +42 -21
  46. package/fullscreen/index.umd.js +1 -1
  47. package/fullscreen/style.css +1 -1
  48. package/grid/index.es.js +101 -86
  49. package/grid/index.umd.js +1 -1
  50. package/grid/style.css +1 -1
  51. package/icon/index.es.js +197 -56
  52. package/icon/index.umd.js +1 -1
  53. package/icon/style.css +1 -0
  54. package/image-preview/index.es.js +55 -31
  55. package/image-preview/index.umd.js +1 -1
  56. package/image-preview/style.css +1 -1
  57. package/input/index.es.js +8066 -144
  58. package/input/index.umd.js +27 -1
  59. package/input/style.css +1 -1
  60. package/input-number/index.es.js +269 -183
  61. package/input-number/index.umd.js +1 -1
  62. package/input-number/style.css +1 -1
  63. package/layout/index.es.js +40 -25
  64. package/layout/index.umd.js +1 -1
  65. package/layout/style.css +1 -1
  66. package/loading/index.es.js +74 -35
  67. package/loading/index.umd.js +1 -1
  68. package/loading/style.css +1 -1
  69. package/modal/index.es.js +412 -204
  70. package/modal/index.umd.js +1 -1
  71. package/modal/style.css +1 -1
  72. package/notification/index.es.js +307 -57
  73. package/notification/index.umd.js +1 -1
  74. package/notification/style.css +1 -1
  75. package/nuxt/components/ButtonGroup.js +3 -0
  76. package/nuxt/components/CheckboxButton.js +3 -0
  77. package/nuxt/components/CheckboxGroup.js +3 -0
  78. package/nuxt/components/Collapse.js +3 -0
  79. package/nuxt/components/CollapseItem.js +3 -0
  80. package/nuxt/components/DropdownPropsKey.js +3 -0
  81. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  82. package/nuxt/components/FORM_TOKEN.js +3 -0
  83. package/nuxt/components/Icon.js +1 -0
  84. package/nuxt/components/IconGroup.js +3 -0
  85. package/nuxt/components/LABEL_DATA.js +3 -0
  86. package/nuxt/components/LoadingOptions.js +3 -0
  87. package/nuxt/components/Option.js +3 -0
  88. package/nuxt/components/PanelBody.js +3 -0
  89. package/nuxt/components/PanelFooter.js +3 -0
  90. package/nuxt/components/PanelHeader.js +3 -0
  91. package/nuxt/components/RadioButton.js +3 -0
  92. package/nuxt/components/Tab.js +3 -0
  93. package/nuxt/components/Timeline.js +3 -0
  94. package/nuxt/components/TimelineItem.js +3 -0
  95. package/nuxt/components/alertProps.js +3 -0
  96. package/nuxt/components/autoCompleteProps.js +3 -0
  97. package/nuxt/components/avatarProps.js +3 -0
  98. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  99. package/nuxt/components/buttonGroupProps.js +3 -0
  100. package/nuxt/components/cardProps.js +3 -0
  101. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  102. package/nuxt/components/checkboxGroupProps.js +3 -0
  103. package/nuxt/components/checkboxProps.js +3 -0
  104. package/nuxt/components/colProps.js +3 -0
  105. package/nuxt/components/colPropsBaseClass.js +3 -0
  106. package/nuxt/components/colPropsBaseStyle.js +3 -0
  107. package/nuxt/components/collapseItemProps.js +3 -0
  108. package/nuxt/components/collapseProps.js +3 -0
  109. package/nuxt/components/countdownProps.js +3 -0
  110. package/nuxt/components/editableSelectProps.js +3 -0
  111. package/nuxt/components/formItemProps.js +3 -0
  112. package/nuxt/components/formProps.js +3 -0
  113. package/nuxt/components/fullscreenProps.js +3 -0
  114. package/nuxt/components/iconProps.js +3 -0
  115. package/nuxt/components/imagePreviewProps.js +3 -0
  116. package/nuxt/components/inputProps.js +3 -0
  117. package/nuxt/components/loadingProps.js +3 -0
  118. package/nuxt/components/modalProps.js +3 -0
  119. package/nuxt/components/paginationProps.js +3 -0
  120. package/nuxt/components/panelProps.js +3 -0
  121. package/nuxt/components/progressProps.js +3 -0
  122. package/nuxt/components/rateProps.js +3 -0
  123. package/nuxt/components/resultProps.js +3 -0
  124. package/nuxt/components/rowProps.js +3 -0
  125. package/nuxt/components/screenSizes.js +3 -0
  126. package/nuxt/components/searchProps.js +3 -0
  127. package/nuxt/components/skeletonProps.js +3 -0
  128. package/nuxt/components/sliderProps.js +3 -0
  129. package/nuxt/components/splitterProps.js +3 -0
  130. package/nuxt/components/statisticProps.js +3 -0
  131. package/nuxt/components/svgIconProps.js +3 -0
  132. package/nuxt/components/switchProps.js +3 -0
  133. package/nuxt/components/tabsProps.js +3 -0
  134. package/nuxt/components/tagProps.js +3 -0
  135. package/nuxt/components/textareaProps.js +3 -0
  136. package/nuxt/components/timeAxisProps.js +3 -0
  137. package/nuxt/components/treeProps.js +3 -0
  138. package/overlay/index.es.js +127 -149
  139. package/overlay/index.umd.js +1 -1
  140. package/overlay/style.css +1 -1
  141. package/package.json +10 -44
  142. package/pagination/index.es.js +158 -148
  143. package/pagination/index.umd.js +1 -1
  144. package/pagination/style.css +1 -1
  145. package/panel/index.es.js +45 -32
  146. package/panel/index.umd.js +1 -1
  147. package/panel/style.css +1 -1
  148. package/popover/index.es.js +317 -246
  149. package/popover/index.umd.js +15 -15
  150. package/popover/style.css +1 -1
  151. package/progress/index.es.js +110 -56
  152. package/progress/index.umd.js +3 -3
  153. package/progress/style.css +1 -1
  154. package/radio/index.es.js +7964 -157
  155. package/radio/index.umd.js +27 -1
  156. package/radio/style.css +1 -1
  157. package/rate/index.es.js +77 -55
  158. package/rate/index.umd.js +1 -1
  159. package/rate/style.css +1 -1
  160. package/result/index.es.js +184 -57
  161. package/result/index.umd.js +1 -1
  162. package/result/style.css +1 -1
  163. package/ripple/index.es.js +47 -42
  164. package/ripple/index.umd.js +1 -1
  165. package/search/index.es.js +3644 -1122
  166. package/search/index.umd.js +18 -18
  167. package/search/style.css +1 -1
  168. package/select/index.es.js +9144 -597
  169. package/select/index.umd.js +27 -1
  170. package/select/style.css +1 -1
  171. package/skeleton/index.es.js +63 -41
  172. package/skeleton/index.umd.js +1 -1
  173. package/skeleton/style.css +1 -1
  174. package/slider/index.es.js +109 -75
  175. package/slider/index.umd.js +1 -1
  176. package/slider/style.css +1 -1
  177. package/splitter/index.es.js +469 -349
  178. package/splitter/index.umd.js +15 -15
  179. package/splitter/style.css +1 -1
  180. package/statistic/index.es.js +7 -18
  181. package/statistic/index.umd.js +1 -1
  182. package/status/index.es.js +27 -6
  183. package/status/index.umd.js +1 -1
  184. package/status/style.css +1 -1
  185. package/style.css +1 -1
  186. package/switch/index.es.js +7794 -64
  187. package/switch/index.umd.js +27 -1
  188. package/switch/style.css +1 -1
  189. package/table/index.es.js +10119 -1206
  190. package/table/index.umd.js +27 -1
  191. package/table/style.css +1 -1
  192. package/tabs/index.es.js +342 -141
  193. package/tabs/index.umd.js +1 -1
  194. package/tabs/style.css +1 -1
  195. package/tag/index.es.js +49 -24
  196. package/tag/index.umd.js +1 -1
  197. package/tag/style.css +1 -1
  198. package/textarea/index.es.js +7913 -83
  199. package/textarea/index.umd.js +35 -1
  200. package/textarea/style.css +1 -1
  201. package/{anchor → timeline}/index.d.ts +0 -0
  202. package/timeline/index.es.js +425 -0
  203. package/timeline/index.umd.js +1 -0
  204. package/{back-top → timeline}/package.json +1 -1
  205. package/timeline/style.css +1 -0
  206. package/tooltip/index.es.js +308 -236
  207. package/tooltip/index.umd.js +15 -15
  208. package/tooltip/style.css +1 -1
  209. package/tree/index.es.js +4189 -1851
  210. package/tree/index.umd.js +18 -18
  211. package/tree/style.css +1 -1
  212. package/upload/index.es.js +380 -123
  213. package/upload/index.umd.js +1 -1
  214. package/upload/style.css +1 -1
  215. package/vue-devui.es.js +18121 -23161
  216. package/vue-devui.umd.js +25 -15
  217. package/accordion/index.es.js +0 -720
  218. package/accordion/index.umd.js +0 -1
  219. package/accordion/package.json +0 -7
  220. package/accordion/style.css +0 -1
  221. package/anchor/index.es.js +0 -263
  222. package/anchor/index.umd.js +0 -1
  223. package/anchor/style.css +0 -1
  224. package/back-top/index.d.ts +0 -7
  225. package/back-top/index.es.js +0 -128
  226. package/back-top/index.umd.js +0 -1
  227. package/back-top/style.css +0 -1
  228. package/breadcrumb/index.d.ts +0 -7
  229. package/breadcrumb/index.es.js +0 -127
  230. package/breadcrumb/index.umd.js +0 -1
  231. package/breadcrumb/package.json +0 -7
  232. package/breadcrumb/style.css +0 -1
  233. package/carousel/index.d.ts +0 -7
  234. package/carousel/index.es.js +0 -329
  235. package/carousel/index.umd.js +0 -1
  236. package/carousel/package.json +0 -7
  237. package/carousel/style.css +0 -1
  238. package/cascader/index.d.ts +0 -7
  239. package/cascader/index.es.js +0 -5963
  240. package/cascader/index.umd.js +0 -27
  241. package/cascader/package.json +0 -7
  242. package/cascader/style.css +0 -1
  243. package/color-picker/index.d.ts +0 -7
  244. package/color-picker/index.es.js +0 -8187
  245. package/color-picker/index.umd.js +0 -27
  246. package/color-picker/package.json +0 -7
  247. package/color-picker/style.css +0 -1
  248. package/comment/index.d.ts +0 -7
  249. package/comment/index.es.js +0 -86
  250. package/comment/index.umd.js +0 -1
  251. package/comment/package.json +0 -7
  252. package/comment/style.css +0 -1
  253. package/dragdrop/index.d.ts +0 -7
  254. package/dragdrop/index.es.js +0 -157
  255. package/dragdrop/index.umd.js +0 -1
  256. package/dragdrop/package.json +0 -7
  257. package/gantt/index.d.ts +0 -7
  258. package/gantt/index.es.js +0 -523
  259. package/gantt/index.umd.js +0 -1
  260. package/gantt/package.json +0 -7
  261. package/gantt/style.css +0 -1
  262. package/input-icon/index.d.ts +0 -7
  263. package/input-icon/index.es.js +0 -331
  264. package/input-icon/index.umd.js +0 -1
  265. package/input-icon/package.json +0 -7
  266. package/input-icon/style.css +0 -1
  267. package/list/index.d.ts +0 -7
  268. package/list/index.es.js +0 -39
  269. package/list/index.umd.js +0 -1
  270. package/list/package.json +0 -7
  271. package/list/style.css +0 -1
  272. package/nav-sprite/index.d.ts +0 -7
  273. package/nav-sprite/index.es.js +0 -68
  274. package/nav-sprite/index.umd.js +0 -1
  275. package/nav-sprite/package.json +0 -7
  276. package/nuxt/components/Accordion.js +0 -3
  277. package/nuxt/components/Anchor.js +0 -3
  278. package/nuxt/components/BackTop.js +0 -3
  279. package/nuxt/components/Breadcrumb.js +0 -3
  280. package/nuxt/components/Carousel.js +0 -3
  281. package/nuxt/components/CarouselItem.js +0 -3
  282. package/nuxt/components/Cascader.js +0 -3
  283. package/nuxt/components/ColorPicker.js +0 -3
  284. package/nuxt/components/Comment.js +0 -3
  285. package/nuxt/components/FormControl.js +0 -3
  286. package/nuxt/components/FormLabel.js +0 -3
  287. package/nuxt/components/Gantt.js +0 -3
  288. package/nuxt/components/InputIcon.js +0 -3
  289. package/nuxt/components/List.js +0 -3
  290. package/nuxt/components/ListItem.js +0 -3
  291. package/nuxt/components/NavSprite.js +0 -2
  292. package/nuxt/components/QuadrantDiagram.js +0 -3
  293. package/nuxt/components/ReadTip.js +0 -3
  294. package/nuxt/components/StepsGuide.js +0 -3
  295. package/nuxt/components/Sticky.js +0 -2
  296. package/nuxt/components/TagInput.js +0 -3
  297. package/nuxt/components/TimeAxis.js +0 -3
  298. package/nuxt/components/TimeAxisItem.js +0 -3
  299. package/nuxt/components/TimePicker.js +0 -3
  300. package/nuxt/components/Transfer.js +0 -3
  301. package/nuxt/components/TreeSelect.js +0 -3
  302. package/nuxt/components/overlayEmits.js +0 -3
  303. package/nuxt/components/overlayProps.js +0 -3
  304. package/quadrant-diagram/index.d.ts +0 -7
  305. package/quadrant-diagram/index.es.js +0 -5728
  306. package/quadrant-diagram/index.umd.js +0 -27
  307. package/quadrant-diagram/package.json +0 -7
  308. package/quadrant-diagram/style.css +0 -1
  309. package/read-tip/index.d.ts +0 -7
  310. package/read-tip/index.es.js +0 -258
  311. package/read-tip/index.umd.js +0 -1
  312. package/read-tip/package.json +0 -7
  313. package/read-tip/style.css +0 -1
  314. package/steps-guide/index.d.ts +0 -7
  315. package/steps-guide/index.es.js +0 -239
  316. package/steps-guide/index.umd.js +0 -1
  317. package/steps-guide/package.json +0 -7
  318. package/steps-guide/style.css +0 -1
  319. package/sticky/index.d.ts +0 -7
  320. package/sticky/index.es.js +0 -197
  321. package/sticky/index.umd.js +0 -1
  322. package/sticky/package.json +0 -7
  323. package/tag-input/index.d.ts +0 -7
  324. package/tag-input/index.es.js +0 -329
  325. package/tag-input/index.umd.js +0 -1
  326. package/tag-input/package.json +0 -7
  327. package/tag-input/style.css +0 -1
  328. package/time-axis/index.d.ts +0 -7
  329. package/time-axis/index.es.js +0 -299
  330. package/time-axis/index.umd.js +0 -1
  331. package/time-axis/package.json +0 -7
  332. package/time-axis/style.css +0 -1
  333. package/time-picker/index.d.ts +0 -7
  334. package/time-picker/index.es.js +0 -1237
  335. package/time-picker/index.umd.js +0 -1
  336. package/time-picker/package.json +0 -7
  337. package/time-picker/style.css +0 -1
  338. package/transfer/index.d.ts +0 -7
  339. package/transfer/index.es.js +0 -7608
  340. package/transfer/index.umd.js +0 -27
  341. package/transfer/package.json +0 -7
  342. package/transfer/style.css +0 -1
  343. package/tree-select/index.d.ts +0 -7
  344. package/tree-select/index.es.js +0 -623
  345. package/tree-select/index.umd.js +0 -1
  346. package/tree-select/package.json +0 -7
  347. package/tree-select/style.css +0 -1
@@ -17,8 +17,8 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { toRefs, watch, onMounted, onUnmounted, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, ref, nextTick, unref, mergeProps, Fragment } from "vue";
21
- import { offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
20
+ import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode, Transition, mergeProps, unref, nextTick, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, provide, Teleport, vShow } from "vue";
21
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
22
22
  import { onClickOutside } from "@vueuse/core";
23
23
  const dropdownProps = {
24
24
  visible: {
@@ -45,11 +45,27 @@ const dropdownProps = {
45
45
  type: [Number, Object],
46
46
  default: 4
47
47
  },
48
+ shiftOffset: {
49
+ type: Number
50
+ },
48
51
  closeOnMouseLeaveMenu: {
49
52
  type: Boolean,
50
53
  default: false
54
+ },
55
+ showAnimation: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ overlayClass: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ destroyOnHide: {
64
+ type: Boolean,
65
+ default: true
51
66
  }
52
67
  };
68
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
53
69
  function getElement(element) {
54
70
  if (element instanceof Element) {
55
71
  return element;
@@ -74,12 +90,12 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
74
90
  isOpen.value = status;
75
91
  emit("toggle", isOpen.value);
76
92
  };
77
- const handleLeave = async (elementType, e) => {
93
+ const handleLeave = async (elementType, closeAll) => {
78
94
  await new Promise((resolve) => setTimeout(resolve, 50));
79
95
  if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
80
96
  return;
81
97
  }
82
- if (e) {
98
+ if (closeAll) {
83
99
  [...dropdownMap.values()].reverse().forEach((item) => {
84
100
  setTimeout(() => {
85
101
  var _a;
@@ -95,7 +111,7 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
95
111
  setTimeout(() => {
96
112
  subscriptions.push(subscribeEvent(document, "click", (e) => {
97
113
  const dropdownValues = [...dropdownMap.values()];
98
- if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
114
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
99
115
  var _a;
100
116
  return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
101
117
  }) && dropdownValues.some((item) => {
@@ -119,7 +135,7 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
119
135
  subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
120
136
  var _a;
121
137
  if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
122
- handleLeave("dropdown", e);
138
+ handleLeave("dropdown", true);
123
139
  }
124
140
  }));
125
141
  } else if (triggerVal === "hover") {
@@ -138,7 +154,7 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
138
154
  if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
139
155
  return;
140
156
  }
141
- handleLeave("dropdown", e);
157
+ handleLeave("dropdown", true);
142
158
  }));
143
159
  }
144
160
  onInvalidate(() => subscriptions.forEach((v) => v()));
@@ -189,58 +205,131 @@ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emi
189
205
  dropdownMap.delete(id);
190
206
  });
191
207
  }
192
- var overlay = "";
193
- function _isSlot(s) {
194
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
208
+ function useOverlayProps(props, currentPosition, isOpen) {
209
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
210
+ const overlayModelValue = ref(false);
211
+ const overlayShowValue = ref(false);
212
+ const styles = computed(() => ({
213
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
214
+ }));
215
+ const classes = computed(() => ({
216
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
217
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
218
+ [`${overlayClass.value}`]: true
219
+ }));
220
+ const handlePositionChange = (pos) => {
221
+ currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
222
+ };
223
+ watch(isOpen, (isOpenVal) => {
224
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
225
+ overlayShowValue.value = isOpenVal;
226
+ });
227
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
195
228
  }
196
- const CommonOverlay = defineComponent({
197
- setup(props, ctx) {
198
- return () => {
199
- let _slot;
200
- return createVNode(Teleport, {
201
- "to": "#d-overlay-anchor"
202
- }, {
203
- default: () => [createVNode(Transition, {
204
- "name": "devui-overlay-fade"
205
- }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
206
- default: () => [_slot]
207
- })]
208
- });
209
- };
210
- }
211
- });
212
- const overlayProps = {
213
- visible: {
214
- type: Boolean
215
- },
216
- backgroundBlock: {
229
+ const fixedOverlayProps = {
230
+ modelValue: {
217
231
  type: Boolean,
218
232
  default: false
219
233
  },
220
- backgroundClass: {
221
- type: String,
222
- default: ""
223
- },
224
- backgroundStyle: {
225
- type: [String, Object]
226
- },
227
- onBackdropClick: {
228
- type: Function
229
- },
230
- backdropClose: {
234
+ lockScroll: {
231
235
  type: Boolean,
232
236
  default: true
233
237
  },
234
- hasBackdrop: {
238
+ closeOnClickOverlay: {
235
239
  type: Boolean,
236
240
  default: true
237
241
  }
238
242
  };
239
- const overlayEmits = ["update:visible", "backdropClick"];
240
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
241
- overlayStyle: {
242
- type: [String, Object],
243
- default: void 0
243
+ function lockScroll() {
244
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
245
+ const scrollTop = document.documentElement.scrollTop;
246
+ const style = document.documentElement.getAttribute("style");
247
+ document.documentElement.style.position = "fixed";
248
+ document.documentElement.style.top = `-${scrollTop}px`;
249
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
250
+ document.documentElement.style.overflowY = "scroll";
251
+ return () => {
252
+ if (style) {
253
+ document.documentElement.setAttribute("style", style);
254
+ } else {
255
+ document.documentElement.removeAttribute("style");
256
+ }
257
+ document.documentElement.scrollTop = scrollTop;
258
+ };
259
+ }
260
+ return;
261
+ }
262
+ function useFixedOverlay(props, ctx) {
263
+ let lockScrollCb;
264
+ const onClick = (event) => {
265
+ event.preventDefault();
266
+ ctx.emit("click", event);
267
+ if (props.closeOnClickOverlay) {
268
+ ctx.emit("update:modelValue", false);
269
+ }
270
+ };
271
+ const removeBodyAdditions = () => {
272
+ lockScrollCb == null ? void 0 : lockScrollCb();
273
+ };
274
+ watch(() => props.modelValue, (val) => {
275
+ if (val) {
276
+ props.lockScroll && (lockScrollCb = lockScroll());
277
+ } else {
278
+ removeBodyAdditions();
279
+ }
280
+ });
281
+ onUnmounted(removeBodyAdditions);
282
+ return { onClick };
283
+ }
284
+ function createBem(namespace, element, modifier) {
285
+ let cls = namespace;
286
+ if (element) {
287
+ cls += `__${element}`;
288
+ }
289
+ if (modifier) {
290
+ cls += `--${modifier}`;
291
+ }
292
+ return cls;
293
+ }
294
+ function useNamespace(block, needDot = false) {
295
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
296
+ const b = () => createBem(namespace);
297
+ const e = (element) => element ? createBem(namespace, element) : "";
298
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
299
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
300
+ return {
301
+ b,
302
+ e,
303
+ m,
304
+ em
305
+ };
306
+ }
307
+ var fixedOverlay = "";
308
+ defineComponent({
309
+ name: "DFixedOverlay",
310
+ inheritAttrs: false,
311
+ props: fixedOverlayProps,
312
+ emits: ["update:modelValue", "click"],
313
+ setup(props, ctx) {
314
+ const {
315
+ modelValue
316
+ } = toRefs(props);
317
+ const ns2 = useNamespace("fixed-overlay");
318
+ const {
319
+ onClick
320
+ } = useFixedOverlay(props, ctx);
321
+ return () => createVNode(Transition, {
322
+ "name": ns2.m("fade")
323
+ }, {
324
+ default: () => {
325
+ var _a, _b;
326
+ return [modelValue.value && createVNode("div", mergeProps({
327
+ "class": ns2.b()
328
+ }, ctx.attrs, {
329
+ "onClick": onClick
330
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
331
+ }
332
+ });
244
333
  }
245
334
  });
246
335
  const flexibleOverlayProps = {
@@ -260,6 +349,9 @@ const flexibleOverlayProps = {
260
349
  type: [Number, Object],
261
350
  default: 8
262
351
  },
352
+ shiftOffset: {
353
+ type: Number
354
+ },
263
355
  align: {
264
356
  type: String,
265
357
  default: null
@@ -273,80 +365,6 @@ const flexibleOverlayProps = {
273
365
  default: true
274
366
  }
275
367
  };
276
- function useOverlayLogic(props, ctx) {
277
- const backgroundClass = computed(() => {
278
- return [
279
- "devui-overlay-background",
280
- props.backgroundClass,
281
- !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
282
- ];
283
- });
284
- const overlayClass = computed(() => {
285
- return "devui-overlay";
286
- });
287
- const handleBackdropClick = (event) => {
288
- var _a;
289
- event.preventDefault();
290
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
291
- if (props.backdropClose) {
292
- ctx.emit("update:visible", false);
293
- }
294
- };
295
- const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
296
- onMounted(() => {
297
- const body = document.body;
298
- const originOverflow = body.style.overflow;
299
- const originPosition = body.style.position;
300
- watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
301
- if (backgroundBlock) {
302
- const top = body.getBoundingClientRect().y;
303
- if (visible) {
304
- body.style.overflowY = "scroll";
305
- body.style.position = visible ? "fixed" : "";
306
- body.style.top = `${top}px`;
307
- } else {
308
- body.style.overflowY = originOverflow;
309
- body.style.position = originPosition;
310
- body.style.top = "";
311
- window.scrollTo(0, -top);
312
- }
313
- }
314
- });
315
- onUnmounted(() => {
316
- document.body.style.overflow = originOverflow;
317
- });
318
- });
319
- return {
320
- backgroundClass,
321
- overlayClass,
322
- handleBackdropClick,
323
- handleOverlayBubbleCancel
324
- };
325
- }
326
- defineComponent({
327
- name: "DFixedOverlay",
328
- props: fixedOverlayProps,
329
- emits: overlayEmits,
330
- setup(props, ctx) {
331
- const {
332
- backgroundClass,
333
- overlayClass,
334
- handleBackdropClick,
335
- handleOverlayBubbleCancel
336
- } = useOverlayLogic(props, ctx);
337
- return () => createVNode(CommonOverlay, null, {
338
- default: () => [props.visible && createVNode("div", {
339
- "class": backgroundClass.value,
340
- "style": props.backgroundStyle,
341
- "onClick": handleBackdropClick
342
- }, [createVNode("div", {
343
- "class": overlayClass.value,
344
- "style": props.overlayStyle,
345
- "onClick": handleOverlayBubbleCancel
346
- }, [renderSlot(ctx.slots, "default")])])]
347
- });
348
- }
349
- });
350
368
  function getScrollParent(element) {
351
369
  const overflowRegex = /(auto|scroll|hidden)/;
352
370
  for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
@@ -379,6 +397,7 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
379
397
  function useOverlay(props, emit) {
380
398
  const overlayRef = ref();
381
399
  const arrowRef = ref();
400
+ let originParent = null;
382
401
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
383
402
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
384
403
  const staticSide = {
@@ -407,34 +426,43 @@ function useOverlay(props, emit) {
407
426
  })
408
427
  ];
409
428
  props.showArrow && middleware.push(arrow({ element: arrowEl }));
429
+ props.shiftOffset !== void 0 && middleware.push(shift());
410
430
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
411
431
  strategy: "fixed",
412
432
  middleware
413
433
  });
434
+ let applyX = x;
435
+ let applyY = y;
436
+ if (props.shiftOffset !== void 0) {
437
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
438
+ shiftX < 0 && (applyX -= props.shiftOffset);
439
+ shiftX > 0 && (applyX += props.shiftOffset);
440
+ shiftY < 0 && (applyY -= props.shiftOffset);
441
+ shiftY > 0 && (applyY += props.shiftOffset);
442
+ }
414
443
  emit("positionChange", placement);
415
- Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
444
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
416
445
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
417
446
  };
418
447
  watch(() => props.modelValue, () => {
419
- const originParent = getScrollParent(props.origin);
420
448
  if (props.modelValue && props.origin) {
449
+ originParent = getScrollParent(props.origin);
421
450
  nextTick(updatePosition);
422
- originParent.addEventListener("scroll", updatePosition);
451
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
423
452
  originParent !== window && window.addEventListener("scroll", updatePosition);
424
453
  window.addEventListener("resize", updatePosition);
425
454
  } else {
426
- originParent.removeEventListener("scroll", updatePosition);
455
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
427
456
  originParent !== window && window.removeEventListener("scroll", updatePosition);
428
457
  window.removeEventListener("resize", updatePosition);
429
458
  }
430
459
  });
431
460
  onUnmounted(() => {
432
- const originParent = getScrollParent(props.origin);
433
- originParent.removeEventListener("scroll", updatePosition);
461
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
434
462
  originParent !== window && window.removeEventListener("scroll", updatePosition);
435
463
  window.removeEventListener("resize", updatePosition);
436
464
  });
437
- return { arrowRef, overlayRef };
465
+ return { arrowRef, overlayRef, updatePosition };
438
466
  }
439
467
  var flexibleOverlay = "";
440
468
  const FlexibleOverlay = defineComponent({
@@ -445,24 +473,85 @@ const FlexibleOverlay = defineComponent({
445
473
  setup(props, {
446
474
  slots,
447
475
  attrs,
448
- emit
476
+ emit,
477
+ expose
449
478
  }) {
479
+ const ns2 = useNamespace("flexible-overlay");
450
480
  const {
451
481
  arrowRef,
452
- overlayRef
482
+ overlayRef,
483
+ updatePosition
453
484
  } = useOverlay(props, emit);
485
+ expose({
486
+ updatePosition
487
+ });
454
488
  return () => {
455
489
  var _a;
456
490
  return props.modelValue && createVNode("div", mergeProps({
457
491
  "ref": overlayRef,
458
- "class": "devui-flexible-overlay"
492
+ "class": ns2.b()
459
493
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
460
494
  "ref": arrowRef,
461
- "class": "devui-flexible-overlay-arrow"
495
+ "class": ns2.e("arrow")
462
496
  }, null)]);
463
497
  };
464
498
  }
465
499
  });
500
+ const isObject = (val) => val !== null && typeof val === "object";
501
+ const ns = useNamespace("popper-trigger");
502
+ function wrapContent(content) {
503
+ return h("span", { class: ns.b() }, content);
504
+ }
505
+ function getFirstValidChild(nodes) {
506
+ for (const child of nodes) {
507
+ if (isObject(child)) {
508
+ if (child.type === Comment) {
509
+ continue;
510
+ }
511
+ if (child.type === "svg" || child.type === Text) {
512
+ return wrapContent(child);
513
+ }
514
+ if (child.type === Fragment) {
515
+ return getFirstValidChild(child.children);
516
+ }
517
+ return child;
518
+ }
519
+ return wrapContent(child);
520
+ }
521
+ return null;
522
+ }
523
+ var PopperTrigger = defineComponent({
524
+ name: "DPopperTrigger",
525
+ setup(_, ctx) {
526
+ const {
527
+ slots,
528
+ attrs
529
+ } = ctx;
530
+ return () => {
531
+ var _a;
532
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
533
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
534
+ if (!defaultSlot) {
535
+ return null;
536
+ }
537
+ const firstValidChild = getFirstValidChild(defaultSlot);
538
+ if (!firstValidChild) {
539
+ return null;
540
+ }
541
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
542
+ mounted(el) {
543
+ triggerRef.value = el;
544
+ },
545
+ updated(el) {
546
+ triggerRef.value = el;
547
+ },
548
+ unmounted() {
549
+ triggerRef.value = null;
550
+ }
551
+ }]]);
552
+ };
553
+ }
554
+ });
466
555
  var dropdown = "";
467
556
  let dropdownId = 1;
468
557
  var Dropdown = defineComponent({
@@ -473,29 +562,26 @@ var Dropdown = defineComponent({
473
562
  setup(props, {
474
563
  slots,
475
564
  attrs,
476
- emit
565
+ emit,
566
+ expose
477
567
  }) {
478
568
  const {
479
569
  visible,
480
570
  position,
481
571
  align,
482
- offset: offset2
572
+ offset: offset2,
573
+ destroyOnHide,
574
+ shiftOffset,
575
+ showAnimation
483
576
  } = toRefs(props);
484
577
  const origin = ref();
485
578
  const dropdownRef = ref();
579
+ const overlayRef = ref();
486
580
  const id = `dropdown_${dropdownId++}`;
487
581
  const isOpen = ref(false);
488
582
  const currentPosition = ref("bottom");
489
- const handlePositionChange = (pos) => {
490
- currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
491
- };
492
- const styles = computed(() => ({
493
- transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
494
- }));
495
- const classes = computed(() => ({
496
- "fade-in-bottom": isOpen.value && currentPosition.value === "bottom",
497
- "fade-in-top": isOpen.value && currentPosition.value === "top"
498
- }));
583
+ const ns2 = useNamespace("dropdown");
584
+ provide(POPPER_TRIGGER_TOKEN, origin);
499
585
  useDropdownEvent({
500
586
  id,
501
587
  isOpen,
@@ -505,39 +591,57 @@ var Dropdown = defineComponent({
505
591
  emit
506
592
  });
507
593
  useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
508
- return () => {
509
- var _a;
510
- return createVNode(Fragment, null, [createVNode("div", {
511
- "ref": origin,
512
- "class": "devui-dropdown-toggle"
513
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
514
- "to": "body"
594
+ const {
595
+ overlayModelValue,
596
+ overlayShowValue,
597
+ styles,
598
+ classes,
599
+ handlePositionChange
600
+ } = useOverlayProps(props, currentPosition, isOpen);
601
+ watch(overlayShowValue, (overlayShowValueVal) => {
602
+ nextTick(() => {
603
+ if (!destroyOnHide.value && overlayShowValueVal) {
604
+ overlayRef.value.updatePosition();
605
+ }
606
+ });
607
+ });
608
+ expose({
609
+ updatePosition: () => overlayRef.value.updatePosition()
610
+ });
611
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
612
+ default: () => {
613
+ var _a;
614
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
615
+ }
616
+ }), createVNode(Teleport, {
617
+ "to": "body"
618
+ }, {
619
+ default: () => [createVNode(Transition, {
620
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
515
621
  }, {
516
- default: () => [createVNode(Transition, {
517
- "name": `devui-dropdown-fade-${currentPosition.value}`
622
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
623
+ "modelValue": overlayModelValue.value,
624
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
625
+ "ref": overlayRef,
626
+ "origin": origin.value,
627
+ "position": position.value,
628
+ "align": align.value,
629
+ "offset": offset2.value,
630
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
631
+ "onPositionChange": handlePositionChange,
632
+ "class": classes.value,
633
+ "style": styles.value
518
634
  }, {
519
- default: () => [createVNode(FlexibleOverlay, {
520
- "modelValue": isOpen.value,
521
- "onUpdate:modelValue": ($event) => isOpen.value = $event,
522
- "origin": origin.value,
523
- "position": position.value,
524
- "align": align.value,
525
- "offset": offset2.value,
526
- "onPositionChange": handlePositionChange,
527
- "class": classes.value,
528
- "style": styles.value
529
- }, {
530
- default: () => {
531
- var _a2;
532
- return [createVNode("div", mergeProps({
533
- "ref": dropdownRef,
534
- "class": "devui-dropdown-menu-wrap"
535
- }, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
536
- }
537
- })]
538
- })]
539
- })]);
540
- };
635
+ default: () => {
636
+ var _a;
637
+ return [createVNode("div", mergeProps({
638
+ "ref": dropdownRef,
639
+ "class": ns2.e("menu-wrap")
640
+ }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
641
+ }
642
+ }), [[vShow, overlayShowValue.value]])]
643
+ })]
644
+ })]);
541
645
  }
542
646
  });
543
647
  const dropdownMenuProps = {
@@ -564,6 +668,14 @@ const dropdownMenuProps = {
564
668
  clickOutside: {
565
669
  type: Function,
566
670
  default: () => true
671
+ },
672
+ showAnimation: {
673
+ type: Boolean,
674
+ default: true
675
+ },
676
+ overlayClass: {
677
+ type: String,
678
+ default: ""
567
679
  }
568
680
  };
569
681
  var DropdownMenu = defineComponent({
@@ -582,12 +694,15 @@ var DropdownMenu = defineComponent({
582
694
  position,
583
695
  align,
584
696
  offset: offset2,
585
- clickOutside
697
+ clickOutside,
698
+ showAnimation,
699
+ overlayClass
586
700
  } = toRefs(props);
587
701
  const dropdownMenuRef = ref(null);
702
+ const ns2 = useNamespace("dropdown");
588
703
  onClickOutside(dropdownMenuRef, (value) => {
589
- var _a;
590
- if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !origin.value.contains(value.target)) {
704
+ var _a, _b;
705
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
591
706
  emit("update:modelValue", false);
592
707
  }
593
708
  });
@@ -602,7 +717,7 @@ var DropdownMenu = defineComponent({
602
717
  "to": "body"
603
718
  }, {
604
719
  default: () => [createVNode(Transition, {
605
- "name": `devui-dropdown-fade-${currentPosition.value}`
720
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
606
721
  }, {
607
722
  default: () => [createVNode(FlexibleOverlay, {
608
723
  "modelValue": modelValue.value,
@@ -612,13 +727,14 @@ var DropdownMenu = defineComponent({
612
727
  "align": align.value,
613
728
  "offset": offset2.value,
614
729
  "onPositionChange": handlePositionChange,
730
+ "class": overlayClass.value,
615
731
  "style": styles.value
616
732
  }, {
617
733
  default: () => {
618
734
  var _a;
619
735
  return [createVNode("div", mergeProps({
620
736
  "ref": dropdownMenuRef,
621
- "class": "devui-dropdown-menu-wrap"
737
+ "class": ns2.e("menu-wrap")
622
738
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
623
739
  }
624
740
  })]