vue-devui 1.0.0-beta.18 → 1.0.0-beta.220801

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 (403) hide show
  1. package/README.md +94 -118
  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 +8349 -426
  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 +45 -20
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5743 -127
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +63 -35
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +8070 -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 +213 -0
  25. package/collapse/index.umd.js +1 -0
  26. package/{back-top → collapse}/package.json +1 -1
  27. package/collapse/style.css +1 -0
  28. package/countdown/index.es.js +60 -19
  29. package/countdown/index.umd.js +1 -1
  30. package/{anchor → date-picker-pro}/index.d.ts +0 -0
  31. package/date-picker-pro/index.es.js +12018 -0
  32. package/date-picker-pro/index.umd.js +27 -0
  33. package/date-picker-pro/package.json +7 -0
  34. package/date-picker-pro/style.css +1 -0
  35. package/drawer/index.es.js +184 -5736
  36. package/drawer/index.umd.js +1 -27
  37. package/drawer/style.css +1 -1
  38. package/dropdown/index.es.js +615 -396
  39. package/dropdown/index.umd.js +1 -1
  40. package/dropdown/style.css +1 -1
  41. package/editable-select/index.es.js +786 -195
  42. package/editable-select/index.umd.js +1 -1
  43. package/editable-select/style.css +1 -1
  44. package/form/index.es.js +2360 -2094
  45. package/form/index.umd.js +17 -17
  46. package/form/style.css +1 -1
  47. package/fullscreen/index.es.js +137 -134
  48. package/fullscreen/index.umd.js +1 -1
  49. package/fullscreen/style.css +1 -1
  50. package/grid/index.es.js +101 -86
  51. package/grid/index.umd.js +1 -1
  52. package/grid/style.css +1 -1
  53. package/icon/index.es.js +199 -56
  54. package/icon/index.umd.js +1 -1
  55. package/icon/style.css +1 -0
  56. package/image-preview/index.es.js +55 -31
  57. package/image-preview/index.umd.js +1 -1
  58. package/image-preview/style.css +1 -1
  59. package/input/index.es.js +8254 -144
  60. package/input/index.umd.js +27 -1
  61. package/input/style.css +1 -1
  62. package/input-number/index.es.js +270 -187
  63. package/input-number/index.umd.js +1 -1
  64. package/input-number/style.css +1 -1
  65. package/layout/index.es.js +40 -25
  66. package/layout/index.umd.js +1 -1
  67. package/layout/style.css +1 -1
  68. package/loading/index.es.js +74 -35
  69. package/loading/index.umd.js +1 -1
  70. package/loading/style.css +1 -1
  71. package/{back-top → mention}/index.d.ts +0 -0
  72. package/{color-picker → mention}/index.es.js +2983 -2861
  73. package/mention/index.umd.js +36 -0
  74. package/{anchor → mention}/package.json +1 -1
  75. package/mention/style.css +1 -0
  76. package/{breadcrumb → menu}/index.d.ts +0 -0
  77. package/menu/index.es.js +870 -0
  78. package/menu/index.umd.js +1 -0
  79. package/{toast → menu}/package.json +1 -1
  80. package/menu/style.css +1 -0
  81. package/{carousel → message}/index.d.ts +0 -0
  82. package/message/index.es.js +538 -0
  83. package/message/index.umd.js +1 -0
  84. package/{comment → message}/package.json +1 -1
  85. package/message/style.css +1 -0
  86. package/modal/index.es.js +598 -1025
  87. package/modal/index.umd.js +1 -1
  88. package/modal/style.css +1 -1
  89. package/{cascader → notification}/index.d.ts +0 -0
  90. package/notification/index.es.js +545 -0
  91. package/notification/index.umd.js +1 -0
  92. package/{accordion → notification}/package.json +1 -1
  93. package/notification/style.css +1 -0
  94. package/nuxt/components/ButtonGroup.js +3 -0
  95. package/nuxt/components/CheckboxButton.js +3 -0
  96. package/nuxt/components/CheckboxGroup.js +3 -0
  97. package/nuxt/components/Collapse.js +3 -0
  98. package/nuxt/components/CollapseItem.js +3 -0
  99. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  100. package/nuxt/components/DatePickerPro.js +3 -0
  101. package/nuxt/components/DropdownMenu.js +3 -0
  102. package/nuxt/components/DropdownPropsKey.js +3 -0
  103. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  104. package/nuxt/components/FORM_TOKEN.js +3 -0
  105. package/nuxt/components/IFileOptions.js +3 -0
  106. package/nuxt/components/IUploadOptions.js +3 -0
  107. package/nuxt/components/Icon.js +1 -0
  108. package/nuxt/components/IconGroup.js +3 -0
  109. package/nuxt/components/LABEL_DATA.js +3 -0
  110. package/nuxt/components/LoadingOptions.js +3 -0
  111. package/nuxt/components/Mention.js +3 -0
  112. package/nuxt/components/Menu.js +3 -0
  113. package/nuxt/components/MenuItem.js +3 -0
  114. package/nuxt/components/Message.js +3 -0
  115. package/nuxt/components/Notification.js +3 -0
  116. package/nuxt/components/NotificationService.js +3 -0
  117. package/nuxt/components/Option.js +3 -0
  118. package/nuxt/components/OptionGroup.js +3 -0
  119. package/nuxt/components/PanelBody.js +3 -0
  120. package/nuxt/components/PanelFooter.js +3 -0
  121. package/nuxt/components/PanelHeader.js +3 -0
  122. package/nuxt/components/RadioButton.js +3 -0
  123. package/nuxt/components/Step.js +3 -0
  124. package/nuxt/components/Steps.js +3 -0
  125. package/nuxt/components/SubMenu.js +3 -0
  126. package/nuxt/components/TABLE_TOKEN.js +3 -0
  127. package/nuxt/components/Tab.js +3 -0
  128. package/nuxt/components/TimeSelect.js +3 -0
  129. package/nuxt/components/Timeline.js +3 -0
  130. package/nuxt/components/TimelineItem.js +3 -0
  131. package/nuxt/components/UploadStatus.js +3 -0
  132. package/nuxt/components/alertProps.js +3 -0
  133. package/nuxt/components/animationInjectionKey.js +3 -0
  134. package/nuxt/components/autoCompleteProps.js +3 -0
  135. package/nuxt/components/avatarProps.js +3 -0
  136. package/nuxt/components/badgeProps.js +3 -0
  137. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  138. package/nuxt/components/buttonGroupProps.js +3 -0
  139. package/nuxt/components/cardProps.js +3 -0
  140. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  141. package/nuxt/components/checkboxGroupProps.js +3 -0
  142. package/nuxt/components/checkboxProps.js +3 -0
  143. package/nuxt/components/colProps.js +3 -0
  144. package/nuxt/components/colPropsBaseClass.js +3 -0
  145. package/nuxt/components/colPropsBaseStyle.js +3 -0
  146. package/nuxt/components/collapseItemProps.js +3 -0
  147. package/nuxt/components/collapseProps.js +3 -0
  148. package/nuxt/components/countdownProps.js +3 -0
  149. package/nuxt/components/datePickerProCommonProps.js +3 -0
  150. package/nuxt/components/datePickerProPanelProps.js +3 -0
  151. package/nuxt/components/datePickerProProps.js +3 -0
  152. package/nuxt/components/dropdownMenuProps.js +3 -0
  153. package/nuxt/components/editableSelectProps.js +3 -0
  154. package/nuxt/components/fixedOverlayProps.js +3 -0
  155. package/nuxt/components/flexibleOverlayProps.js +3 -0
  156. package/nuxt/components/formItemProps.js +3 -0
  157. package/nuxt/components/formProps.js +3 -0
  158. package/nuxt/components/fullscreenProps.js +3 -0
  159. package/nuxt/components/iconProps.js +3 -0
  160. package/nuxt/components/imagePreviewProps.js +3 -0
  161. package/nuxt/components/inputProps.js +3 -0
  162. package/nuxt/components/loadingProps.js +3 -0
  163. package/nuxt/components/mentionProps.js +3 -0
  164. package/nuxt/components/messageProps.js +3 -0
  165. package/nuxt/components/modalProps.js +3 -0
  166. package/nuxt/components/notificationProps.js +3 -0
  167. package/nuxt/components/paginationProps.js +3 -0
  168. package/nuxt/components/panelProps.js +3 -0
  169. package/nuxt/components/popoverProps.js +3 -0
  170. package/nuxt/components/progressProps.js +3 -0
  171. package/nuxt/components/rateProps.js +3 -0
  172. package/nuxt/components/resultProps.js +3 -0
  173. package/nuxt/components/roundInjectionKey.js +3 -0
  174. package/nuxt/components/rowProps.js +3 -0
  175. package/nuxt/components/screenSizes.js +3 -0
  176. package/nuxt/components/searchProps.js +3 -0
  177. package/nuxt/components/skeletonItemProps.js +3 -0
  178. package/nuxt/components/skeletonProps.js +3 -0
  179. package/nuxt/components/sliderProps.js +3 -0
  180. package/nuxt/components/splitterProps.js +3 -0
  181. package/nuxt/components/statisticProps.js +3 -0
  182. package/nuxt/components/stepProps.js +3 -0
  183. package/nuxt/components/stepsProps.js +3 -0
  184. package/nuxt/components/svgIconProps.js +3 -0
  185. package/nuxt/components/switchProps.js +3 -0
  186. package/nuxt/components/tableProps.js +3 -0
  187. package/nuxt/components/tabsProps.js +3 -0
  188. package/nuxt/components/tagProps.js +3 -0
  189. package/nuxt/components/textareaProps.js +3 -0
  190. package/nuxt/components/timeAxisProps.js +3 -0
  191. package/nuxt/components/timerPickerPanelProps.js +3 -0
  192. package/nuxt/components/tooltipProps.js +3 -0
  193. package/nuxt/components/treeNodeProps.js +3 -0
  194. package/nuxt/components/treeProps.js +3 -0
  195. package/nuxt/components/uploadProps.js +3 -0
  196. package/overlay/index.es.js +239 -314
  197. package/overlay/index.umd.js +1 -1
  198. package/overlay/style.css +1 -1
  199. package/package.json +44 -87
  200. package/pagination/index.es.js +331 -153
  201. package/pagination/index.umd.js +1 -1
  202. package/pagination/style.css +1 -1
  203. package/panel/index.es.js +45 -32
  204. package/panel/index.umd.js +1 -1
  205. package/panel/style.css +1 -1
  206. package/popover/index.es.js +6034 -215
  207. package/popover/index.umd.js +27 -1
  208. package/popover/style.css +1 -1
  209. package/progress/index.es.js +110 -56
  210. package/progress/index.umd.js +3 -3
  211. package/progress/style.css +1 -1
  212. package/radio/index.es.js +7974 -157
  213. package/radio/index.umd.js +27 -1
  214. package/radio/style.css +1 -1
  215. package/rate/index.es.js +77 -55
  216. package/rate/index.umd.js +1 -1
  217. package/rate/style.css +1 -1
  218. package/result/index.es.js +186 -57
  219. package/result/index.umd.js +1 -1
  220. package/result/style.css +1 -1
  221. package/ripple/index.es.js +47 -42
  222. package/ripple/index.umd.js +1 -1
  223. package/search/index.es.js +3868 -1149
  224. package/search/index.umd.js +18 -18
  225. package/search/style.css +1 -1
  226. package/select/index.es.js +9191 -493
  227. package/select/index.umd.js +27 -1
  228. package/select/style.css +1 -1
  229. package/skeleton/index.es.js +113 -265
  230. package/skeleton/index.umd.js +1 -1
  231. package/skeleton/style.css +1 -1
  232. package/slider/index.es.js +144 -137
  233. package/slider/index.umd.js +1 -1
  234. package/slider/style.css +1 -1
  235. package/splitter/index.es.js +6220 -226
  236. package/splitter/index.umd.js +27 -1
  237. package/splitter/style.css +1 -1
  238. package/statistic/index.es.js +41 -34
  239. package/statistic/index.umd.js +1 -1
  240. package/statistic/style.css +1 -1
  241. package/status/index.es.js +27 -6
  242. package/status/index.umd.js +1 -1
  243. package/status/style.css +1 -1
  244. package/{color-picker → steps}/index.d.ts +0 -0
  245. package/steps/index.es.js +386 -0
  246. package/steps/index.umd.js +1 -0
  247. package/{gantt → steps}/package.json +1 -1
  248. package/steps/style.css +1 -0
  249. package/style.css +1 -1
  250. package/switch/index.es.js +7804 -64
  251. package/switch/index.umd.js +27 -1
  252. package/switch/style.css +1 -1
  253. package/table/index.es.js +11010 -1367
  254. package/table/index.umd.js +27 -1
  255. package/table/style.css +1 -1
  256. package/tabs/index.es.js +356 -144
  257. package/tabs/index.umd.js +1 -1
  258. package/tabs/style.css +1 -1
  259. package/tag/index.es.js +49 -24
  260. package/tag/index.umd.js +1 -1
  261. package/tag/style.css +1 -1
  262. package/textarea/index.es.js +7924 -83
  263. package/textarea/index.umd.js +35 -1
  264. package/textarea/style.css +1 -1
  265. package/time-picker/index.es.js +8914 -602
  266. package/time-picker/index.umd.js +27 -1
  267. package/time-picker/style.css +1 -1
  268. package/{comment → time-select}/index.d.ts +0 -0
  269. package/{transfer → time-select}/index.es.js +4912 -2667
  270. package/time-select/index.umd.js +27 -0
  271. package/{breadcrumb → time-select}/package.json +1 -1
  272. package/time-select/style.css +1 -0
  273. package/{date-picker → timeline}/index.d.ts +0 -0
  274. package/timeline/index.es.js +427 -0
  275. package/timeline/index.umd.js +1 -0
  276. package/{carousel → timeline}/package.json +1 -1
  277. package/timeline/style.css +1 -0
  278. package/tooltip/index.es.js +5871 -96
  279. package/tooltip/index.umd.js +27 -1
  280. package/tooltip/style.css +1 -1
  281. package/tree/index.es.js +7556 -2491
  282. package/tree/index.umd.js +18 -18
  283. package/tree/style.css +1 -1
  284. package/upload/index.es.js +865 -6117
  285. package/upload/index.umd.js +1 -27
  286. package/upload/style.css +1 -1
  287. package/vue-devui.es.js +20283 -18856
  288. package/vue-devui.umd.js +30 -19
  289. package/accordion/index.es.js +0 -508
  290. package/accordion/index.umd.js +0 -1
  291. package/accordion/style.css +0 -1
  292. package/anchor/index.es.js +0 -263
  293. package/anchor/index.umd.js +0 -1
  294. package/anchor/style.css +0 -1
  295. package/back-top/index.es.js +0 -128
  296. package/back-top/index.umd.js +0 -1
  297. package/back-top/style.css +0 -1
  298. package/breadcrumb/index.es.js +0 -127
  299. package/breadcrumb/index.umd.js +0 -1
  300. package/breadcrumb/style.css +0 -1
  301. package/carousel/index.es.js +0 -329
  302. package/carousel/index.umd.js +0 -1
  303. package/carousel/style.css +0 -1
  304. package/cascader/index.es.js +0 -5963
  305. package/cascader/index.umd.js +0 -27
  306. package/cascader/package.json +0 -7
  307. package/cascader/style.css +0 -1
  308. package/color-picker/index.umd.js +0 -27
  309. package/color-picker/package.json +0 -7
  310. package/color-picker/style.css +0 -1
  311. package/comment/index.es.js +0 -86
  312. package/comment/index.umd.js +0 -1
  313. package/comment/style.css +0 -1
  314. package/date-picker/index.es.js +0 -1171
  315. package/date-picker/index.umd.js +0 -1
  316. package/date-picker/package.json +0 -7
  317. package/date-picker/style.css +0 -1
  318. package/dragdrop/index.d.ts +0 -7
  319. package/dragdrop/index.es.js +0 -157
  320. package/dragdrop/index.umd.js +0 -1
  321. package/dragdrop/package.json +0 -7
  322. package/gantt/index.d.ts +0 -7
  323. package/gantt/index.es.js +0 -523
  324. package/gantt/index.umd.js +0 -1
  325. package/gantt/style.css +0 -1
  326. package/input-icon/index.d.ts +0 -7
  327. package/input-icon/index.es.js +0 -331
  328. package/input-icon/index.umd.js +0 -1
  329. package/input-icon/package.json +0 -7
  330. package/input-icon/style.css +0 -1
  331. package/nav-sprite/index.d.ts +0 -7
  332. package/nav-sprite/index.es.js +0 -68
  333. package/nav-sprite/index.umd.js +0 -1
  334. package/nav-sprite/package.json +0 -7
  335. package/nuxt/components/Accordion.js +0 -3
  336. package/nuxt/components/Anchor.js +0 -3
  337. package/nuxt/components/BackTop.js +0 -3
  338. package/nuxt/components/Breadcrumb.js +0 -3
  339. package/nuxt/components/Carousel.js +0 -3
  340. package/nuxt/components/CarouselItem.js +0 -3
  341. package/nuxt/components/Cascader.js +0 -3
  342. package/nuxt/components/ColorPicker.js +0 -3
  343. package/nuxt/components/Comment.js +0 -3
  344. package/nuxt/components/DatePicker.js +0 -3
  345. package/nuxt/components/FormControl.js +0 -3
  346. package/nuxt/components/FormLabel.js +0 -3
  347. package/nuxt/components/Gantt.js +0 -3
  348. package/nuxt/components/InputIcon.js +0 -3
  349. package/nuxt/components/NavSprite.js +0 -2
  350. package/nuxt/components/QuadrantDiagram.js +0 -3
  351. package/nuxt/components/ReadTip.js +0 -3
  352. package/nuxt/components/StepsGuide.js +0 -3
  353. package/nuxt/components/StickSlider.js +0 -3
  354. package/nuxt/components/Sticky.js +0 -2
  355. package/nuxt/components/TagInput.js +0 -3
  356. package/nuxt/components/TimeAxis.js +0 -3
  357. package/nuxt/components/TimeAxisItem.js +0 -3
  358. package/nuxt/components/Toast.js +0 -3
  359. package/nuxt/components/ToastService.js +0 -3
  360. package/nuxt/components/Transfer.js +0 -3
  361. package/nuxt/components/TreeSelect.js +0 -3
  362. package/quadrant-diagram/index.d.ts +0 -7
  363. package/quadrant-diagram/index.es.js +0 -5728
  364. package/quadrant-diagram/index.umd.js +0 -27
  365. package/quadrant-diagram/package.json +0 -7
  366. package/quadrant-diagram/style.css +0 -1
  367. package/read-tip/index.d.ts +0 -7
  368. package/read-tip/index.es.js +0 -258
  369. package/read-tip/index.umd.js +0 -1
  370. package/read-tip/package.json +0 -7
  371. package/read-tip/style.css +0 -1
  372. package/steps-guide/index.d.ts +0 -7
  373. package/steps-guide/index.es.js +0 -239
  374. package/steps-guide/index.umd.js +0 -1
  375. package/steps-guide/package.json +0 -7
  376. package/steps-guide/style.css +0 -1
  377. package/sticky/index.d.ts +0 -7
  378. package/sticky/index.es.js +0 -197
  379. package/sticky/index.umd.js +0 -1
  380. package/sticky/package.json +0 -7
  381. package/tag-input/index.d.ts +0 -7
  382. package/tag-input/index.es.js +0 -329
  383. package/tag-input/index.umd.js +0 -1
  384. package/tag-input/package.json +0 -7
  385. package/tag-input/style.css +0 -1
  386. package/time-axis/index.d.ts +0 -7
  387. package/time-axis/index.es.js +0 -299
  388. package/time-axis/index.umd.js +0 -1
  389. package/time-axis/package.json +0 -7
  390. package/time-axis/style.css +0 -1
  391. package/toast/index.d.ts +0 -7
  392. package/toast/index.es.js +0 -5918
  393. package/toast/index.umd.js +0 -27
  394. package/toast/style.css +0 -1
  395. package/transfer/index.d.ts +0 -7
  396. package/transfer/index.umd.js +0 -27
  397. package/transfer/package.json +0 -7
  398. package/transfer/style.css +0 -1
  399. package/tree-select/index.d.ts +0 -7
  400. package/tree-select/index.es.js +0 -623
  401. package/tree-select/index.umd.js +0 -1
  402. package/tree-select/package.json +0 -7
  403. package/tree-select/style.css +0 -1
@@ -17,16 +17,11 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
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 } from "vue";
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
+ import { onClickOutside } from "@vueuse/core";
21
23
  const dropdownProps = {
22
- origin: {
23
- type: Object
24
- },
25
- isOpen: {
26
- type: Boolean,
27
- default: false
28
- },
29
- disabled: {
24
+ visible: {
30
25
  type: Boolean,
31
26
  default: false
32
27
  },
@@ -38,6 +33,21 @@ const dropdownProps = {
38
33
  type: String,
39
34
  default: "all"
40
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
+ shiftOffset: {
49
+ type: Number
50
+ },
41
51
  closeOnMouseLeaveMenu: {
42
52
  type: Boolean,
43
53
  default: false
@@ -46,14 +56,16 @@ const dropdownProps = {
46
56
  type: Boolean,
47
57
  default: true
48
58
  },
49
- width: {
50
- type: [Number, String],
51
- default: "102px"
59
+ overlayClass: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ destroyOnHide: {
64
+ type: Boolean,
65
+ default: true
52
66
  }
53
67
  };
54
- function isComponent(target) {
55
- return !!(target == null ? void 0 : target.$el);
56
- }
68
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
57
69
  function getElement(element) {
58
70
  if (element instanceof Element) {
59
71
  return element;
@@ -63,473 +75,680 @@ function getElement(element) {
63
75
  }
64
76
  return null;
65
77
  }
78
+ const dropdownMap = /* @__PURE__ */ new Map();
66
79
  function subscribeEvent(dom, type, callback) {
67
80
  dom == null ? void 0 : dom.addEventListener(type, callback);
68
81
  return () => {
69
82
  dom == null ? void 0 : dom.removeEventListener(type, callback);
70
83
  };
71
84
  }
72
- const useDropdown = ({
73
- visible,
74
- trigger,
75
- origin,
76
- closeScope,
77
- closeOnMouseLeaveMenu
78
- }) => {
79
- const dropdownElRef = ref();
80
- const closeByScope = () => {
81
- if (closeScope.value === "none") {
82
- return;
83
- }
84
- visible.value = false;
85
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
86
+ let overlayEnter = false;
87
+ let originEnter = false;
88
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
89
+ const toggle = (status) => {
90
+ isOpen.value = status;
91
+ emit("toggle", isOpen.value);
85
92
  };
86
- watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
87
- const originEl = getElement(origin2);
88
- if (!originEl || !dropdownEl) {
93
+ const handleLeave = async (elementType, closeAll) => {
94
+ await new Promise((resolve) => setTimeout(resolve, 50));
95
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
89
96
  return;
90
97
  }
91
- const subscriptions = [
92
- subscribeEvent(dropdownEl, "click", () => {
93
- if (closeScope.value === "all") {
94
- visible.value = false;
95
- }
96
- })
97
- ];
98
- if (trigger2 === "click") {
99
- subscriptions.push(subscribeEvent(originEl, "click", () => visible.value = !visible.value), subscribeEvent(document, "click", (e) => {
100
- if (!visible.value) {
101
- return;
102
- }
103
- const target = e.target;
104
- const isContain = originEl.contains(target) || dropdownEl.contains(target);
105
- if (isContain) {
98
+ if (closeAll) {
99
+ [...dropdownMap.values()].reverse().forEach((item) => {
100
+ setTimeout(() => {
101
+ var _a;
102
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
103
+ }, 0);
104
+ });
105
+ }
106
+ toggle(false);
107
+ };
108
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
109
+ const originEl = getElement(originVal);
110
+ const subscriptions = [];
111
+ setTimeout(() => {
112
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
113
+ const dropdownValues = [...dropdownMap.values()];
114
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
115
+ var _a;
116
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
117
+ }) && dropdownValues.some((item) => {
118
+ var _a;
119
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
120
+ })) {
106
121
  return;
107
122
  }
108
- closeByScope();
109
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
110
- if (closeOnMouseLeaveMenu.value) {
111
- visible.value = false;
112
- }
123
+ [...dropdownMap.values()].reverse().forEach((item) => {
124
+ setTimeout(() => {
125
+ var _a, _b;
126
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
127
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
128
+ }
129
+ }, 0);
130
+ });
131
+ overlayEnter = false;
113
132
  }));
114
- } else if (trigger2 === "hover") {
115
- let overlayEnter = false;
116
- let originEnter = false;
117
- const handleLeave = async (elementType) => {
118
- await new Promise((resolve) => setTimeout(resolve, 50));
119
- if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
120
- return;
133
+ }, 0);
134
+ if (triggerVal === "click") {
135
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
136
+ var _a;
137
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
138
+ handleLeave("dropdown", true);
121
139
  }
122
- closeByScope();
123
- };
140
+ }));
141
+ } else if (triggerVal === "hover") {
124
142
  subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
125
143
  originEnter = true;
126
- visible.value = true;
144
+ toggle(true);
127
145
  }), subscribeEvent(originEl, "mouseleave", () => {
128
146
  originEnter = false;
129
- if (!closeOnMouseLeaveMenu.value) {
130
- handleLeave("origin");
131
- }
147
+ handleLeave("origin");
132
148
  }), subscribeEvent(dropdownEl, "mouseenter", () => {
133
149
  overlayEnter = true;
134
- visible.value = true;
135
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
150
+ isOpen.value = true;
151
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
152
+ var _a;
136
153
  overlayEnter = false;
137
- handleLeave("dropdown");
154
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
155
+ return;
156
+ }
157
+ handleLeave("dropdown", true);
138
158
  }));
139
159
  }
140
160
  onInvalidate(() => subscriptions.forEach((v) => v()));
141
161
  });
142
- return { dropdownEl: dropdownElRef };
143
162
  };
144
- var overlay = "";
145
- function _isSlot(s) {
146
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
163
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
164
+ const calcPopDirection = (dropdownEl) => {
165
+ const elementHeight = dropdownEl.offsetHeight;
166
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
167
+ const isBottomEnough = bottomDistance >= elementHeight;
168
+ if (!isBottomEnough) {
169
+ popDirection.value = "top";
170
+ } else {
171
+ popDirection.value = "bottom";
172
+ }
173
+ };
174
+ watch(visible, (newVal, oldVal) => {
175
+ if (oldVal === void 0) {
176
+ return;
177
+ }
178
+ isOpen.value = newVal;
179
+ emit("toggle", isOpen.value);
180
+ }, { immediate: true });
181
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
182
+ var _a;
183
+ if (isOpenVal) {
184
+ dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
185
+ menuEl: dropdownEl,
186
+ toggle: () => {
187
+ isOpen.value = false;
188
+ emit("toggle", isOpen.value);
189
+ }
190
+ }));
191
+ for (const value of dropdownMap.values()) {
192
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
193
+ value.child = dropdownEl;
194
+ }
195
+ }
196
+ }
197
+ if (dropdownEl) {
198
+ calcPopDirection(dropdownEl);
199
+ }
200
+ });
201
+ onMounted(() => {
202
+ dropdownMap.set(id, { toggleEl: origin.value });
203
+ });
204
+ onUnmounted(() => {
205
+ dropdownMap.delete(id);
206
+ });
147
207
  }
148
- const CommonOverlay = defineComponent({
149
- setup(props, ctx) {
150
- return () => {
151
- let _slot;
152
- return createVNode(Teleport, {
153
- "to": "#d-overlay-anchor"
154
- }, {
155
- default: () => [createVNode(Transition, {
156
- "name": "devui-overlay-fade"
157
- }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
158
- default: () => [_slot]
159
- })]
160
- });
161
- };
162
- }
163
- });
164
- const overlayProps = {
165
- visible: {
166
- type: Boolean
167
- },
168
- backgroundBlock: {
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("right-end") || pos.includes("left-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 };
228
+ }
229
+ const fixedOverlayProps = {
230
+ modelValue: {
169
231
  type: Boolean,
170
232
  default: false
171
233
  },
172
- backgroundClass: {
173
- type: String,
174
- default: ""
175
- },
176
- backgroundStyle: {
177
- type: [String, Object]
178
- },
179
- onBackdropClick: {
180
- type: Function
181
- },
182
- backdropClose: {
234
+ lockScroll: {
183
235
  type: Boolean,
184
236
  default: true
185
237
  },
186
- hasBackdrop: {
238
+ closeOnClickOverlay: {
187
239
  type: Boolean,
188
240
  default: true
189
241
  }
190
242
  };
191
- const overlayEmits = ["update:visible", "backdropClick"];
192
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
193
- overlayStyle: {
194
- type: [String, Object],
195
- default: void 0
196
- }
197
- });
198
- const flexibleOverlayProps = __spreadValues({
199
- origin: {
200
- type: Object,
201
- require: true
202
- },
203
- position: {
204
- type: Object,
205
- default: () => ({
206
- originX: "left",
207
- originY: "top",
208
- overlayX: "left",
209
- overlayY: "top"
210
- })
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
+ };
211
259
  }
212
- }, overlayProps);
213
- function useOverlayLogic(props, ctx) {
214
- const backgroundClass = computed(() => {
215
- return [
216
- "devui-overlay-background",
217
- props.backgroundClass,
218
- !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
219
- ];
220
- });
221
- const overlayClass = computed(() => {
222
- return "devui-overlay";
223
- });
224
- const handleBackdropClick = (event) => {
225
- var _a;
260
+ return;
261
+ }
262
+ function useFixedOverlay(props, ctx) {
263
+ let lockScrollCb;
264
+ const onClick = (event) => {
226
265
  event.preventDefault();
227
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
228
- if (props.backdropClose) {
229
- ctx.emit("update:visible", false);
266
+ ctx.emit("click", event);
267
+ if (props.closeOnClickOverlay) {
268
+ ctx.emit("update:modelValue", false);
230
269
  }
231
270
  };
232
- const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
233
- onMounted(() => {
234
- const body = document.body;
235
- const originOverflow = body.style.overflow;
236
- const originPosition = body.style.position;
237
- watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
238
- if (backgroundBlock) {
239
- const top = body.getBoundingClientRect().y;
240
- if (visible) {
241
- body.style.overflowY = "scroll";
242
- body.style.position = visible ? "fixed" : "";
243
- body.style.top = `${top}px`;
244
- } else {
245
- body.style.overflowY = originOverflow;
246
- body.style.position = originPosition;
247
- body.style.top = "";
248
- window.scrollTo(0, -top);
249
- }
250
- }
251
- });
252
- onUnmounted(() => {
253
- document.body.style.overflow = originOverflow;
254
- });
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
+ }
255
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) : "";
256
300
  return {
257
- backgroundClass,
258
- overlayClass,
259
- handleBackdropClick,
260
- handleOverlayBubbleCancel
301
+ b,
302
+ e,
303
+ m,
304
+ em
261
305
  };
262
306
  }
263
- const FixedOverlay = defineComponent({
307
+ var fixedOverlay = "";
308
+ defineComponent({
264
309
  name: "DFixedOverlay",
310
+ inheritAttrs: false,
265
311
  props: fixedOverlayProps,
266
- emits: overlayEmits,
312
+ emits: ["update:modelValue", "click"],
267
313
  setup(props, ctx) {
268
314
  const {
269
- backgroundClass,
270
- overlayClass,
271
- handleBackdropClick,
272
- handleOverlayBubbleCancel
273
- } = useOverlayLogic(props, ctx);
274
- return () => createVNode(CommonOverlay, null, {
275
- default: () => [withDirectives(createVNode("div", {
276
- "class": backgroundClass.value,
277
- "style": props.backgroundStyle,
278
- "onClick": handleBackdropClick
279
- }, [createVNode("div", {
280
- "class": overlayClass.value,
281
- "style": props.overlayStyle,
282
- "onClick": handleOverlayBubbleCancel
283
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
284
- });
285
- }
286
- });
287
- const FlexibleOverlay = defineComponent({
288
- name: "DFlexibleOverlay",
289
- props: flexibleOverlayProps,
290
- emits: overlayEmits,
291
- setup(props, ctx) {
292
- const overlayRef = ref(null);
293
- const positionedStyle = reactive({
294
- position: "absolute"
295
- });
296
- onMounted(async () => {
297
- const handleRectChange = (position, rect, origin) => {
298
- const point = calculatePosition(position, rect, origin);
299
- positionedStyle.left = `${point.x}px`;
300
- positionedStyle.top = `${point.y}px`;
301
- };
302
- const locationElements = computed(() => {
303
- const overlay2 = overlayRef.value;
304
- const origin = getOrigin(props.origin);
305
- if (!overlay2 || !origin) {
306
- return;
307
- }
308
- return {
309
- origin,
310
- overlay: overlay2
311
- };
312
- });
313
- const visibleRef = toRef(props, "visible");
314
- const positionRef = toRef(props, "position");
315
- watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
316
- if (!visible || !locationElements2) {
317
- return;
318
- }
319
- const {
320
- origin,
321
- overlay: overlay2
322
- } = locationElements2;
323
- handleRectChange(position, overlay2.getBoundingClientRect(), origin);
324
- const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
325
- onInvalidate(() => {
326
- unsubscriptions.forEach((fn) => fn());
327
- });
328
- });
329
- });
315
+ modelValue
316
+ } = toRefs(props);
317
+ const ns2 = useNamespace("fixed-overlay");
330
318
  const {
331
- backgroundClass,
332
- overlayClass,
333
- handleBackdropClick,
334
- handleOverlayBubbleCancel
335
- } = useOverlayLogic(props, ctx);
336
- return () => createVNode(CommonOverlay, null, {
337
- default: () => [withDirectives(createVNode("div", {
338
- "style": props.backgroundStyle,
339
- "class": backgroundClass.value,
340
- "onClick": handleBackdropClick
341
- }, [createVNode("div", {
342
- "ref": overlayRef,
343
- "class": overlayClass.value,
344
- "style": positionedStyle,
345
- "onClick": handleOverlayBubbleCancel
346
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
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
+ }
347
332
  });
348
333
  }
349
334
  });
350
- function getOrigin(origin) {
351
- if (origin instanceof Element) {
352
- return origin;
353
- }
354
- if (isRef(origin)) {
355
- return getElement(origin.value);
356
- }
357
- if (isComponent(origin)) {
358
- return getElement(origin);
335
+ const flexibleOverlayProps = {
336
+ modelValue: {
337
+ type: Boolean,
338
+ default: false
339
+ },
340
+ origin: {
341
+ type: Object,
342
+ require: true
343
+ },
344
+ position: {
345
+ type: Array,
346
+ default: ["bottom"]
347
+ },
348
+ offset: {
349
+ type: [Number, Object],
350
+ default: 8
351
+ },
352
+ shiftOffset: {
353
+ type: Number
354
+ },
355
+ align: {
356
+ type: String,
357
+ default: null
358
+ },
359
+ showArrow: {
360
+ type: Boolean,
361
+ default: false
362
+ },
363
+ isArrowCenter: {
364
+ type: Boolean,
365
+ default: true
359
366
  }
360
- return origin;
361
- }
362
- function calculatePosition(position, rect, origin) {
363
- const originRect = getOriginRect(origin);
364
- const originPoint = getOriginRelativePoint(originRect, position);
365
- return getOverlayPoint(originPoint, rect, position);
366
- }
367
- function getOriginRect(origin) {
368
- if (origin instanceof Element) {
369
- return origin.getBoundingClientRect();
367
+ };
368
+ function getScrollParent(element) {
369
+ const overflowRegex = /(auto|scroll|hidden)/;
370
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
371
+ const style = window.getComputedStyle(parent);
372
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
373
+ return parent;
374
+ }
370
375
  }
371
- const width = origin.width || 0;
372
- const height = origin.height || 0;
373
- return {
374
- top: origin.y,
375
- bottom: origin.y + height,
376
- left: origin.x,
377
- right: origin.x + width,
378
- height,
379
- width
380
- };
376
+ return window;
381
377
  }
382
- function getOverlayPoint(originPoint, rect, position) {
383
- let x;
384
- const {
385
- width,
386
- height
387
- } = rect;
388
- if (position.overlayX == "center") {
389
- x = originPoint.x - width / 2;
390
- } else {
391
- x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
392
- }
393
- let y;
394
- if (position.overlayY == "center") {
395
- y = originPoint.y - height / 2;
396
- } else {
397
- y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
378
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
379
+ let { x, y } = point;
380
+ if (!isArrowCenter) {
381
+ const { width, height } = originRect;
382
+ if (x && placement.includes("start")) {
383
+ x = 12;
384
+ }
385
+ if (x && placement.includes("end")) {
386
+ x = Math.round(width - 24);
387
+ }
388
+ if (y && placement.includes("start")) {
389
+ y = 10;
390
+ }
391
+ if (y && placement.includes("end")) {
392
+ y = height - 14;
393
+ }
398
394
  }
399
- return {
400
- x,
401
- y
402
- };
395
+ return { x, y };
403
396
  }
404
- function getOriginRelativePoint(originRect, position) {
405
- let x;
406
- if (position.originX == "center") {
407
- x = originRect.left + originRect.width / 2;
408
- } else {
409
- const startX = originRect.left;
410
- const endX = originRect.right;
411
- x = position.originX == "left" ? startX : endX;
412
- }
413
- let y;
414
- if (position.originY == "center") {
415
- y = originRect.top + originRect.height / 2;
416
- } else {
417
- y = position.originY == "top" ? originRect.top : originRect.bottom;
418
- }
419
- return {
420
- x,
421
- y
397
+ function useOverlay(props, emit) {
398
+ const overlayRef = ref();
399
+ const arrowRef = ref();
400
+ let originParent = null;
401
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
402
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
403
+ const staticSide = {
404
+ top: "bottom",
405
+ right: "left",
406
+ bottom: "top",
407
+ left: "right"
408
+ }[placement.split("-")[0]];
409
+ Object.assign(arrowEl.style, {
410
+ left: x ? `${x}px` : "",
411
+ top: y ? `${y}px` : "",
412
+ right: "",
413
+ bottom: "",
414
+ [staticSide]: "-4px"
415
+ });
422
416
  };
423
- }
424
- function subscribeLayoutEvent(event) {
425
- window.addEventListener("scroll", event, true);
426
- window.addEventListener("resize", event);
427
- window.addEventListener("orientationchange", event);
428
- return () => {
429
- window.removeEventListener("scroll", event, true);
430
- window.removeEventListener("resize", event);
431
- window.removeEventListener("orientationchange", event);
417
+ const updatePosition = async () => {
418
+ const hostEl = props.origin;
419
+ const overlayEl = unref(overlayRef.value);
420
+ const arrowEl = unref(arrowRef.value);
421
+ const middleware = [
422
+ offset(props.offset),
423
+ autoPlacement({
424
+ alignment: props.align,
425
+ allowedPlacements: props.position
426
+ })
427
+ ];
428
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
429
+ props.shiftOffset !== void 0 && middleware.push(shift());
430
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
431
+ strategy: "fixed",
432
+ middleware
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
+ }
443
+ emit("positionChange", placement);
444
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
445
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
432
446
  };
447
+ watch(() => props.modelValue, () => {
448
+ if (props.modelValue && props.origin) {
449
+ originParent = getScrollParent(props.origin);
450
+ nextTick(updatePosition);
451
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
452
+ originParent !== window && window.addEventListener("scroll", updatePosition);
453
+ window.addEventListener("resize", updatePosition);
454
+ } else {
455
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
456
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
457
+ window.removeEventListener("resize", updatePosition);
458
+ }
459
+ });
460
+ onUnmounted(() => {
461
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
462
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
463
+ window.removeEventListener("resize", updatePosition);
464
+ });
465
+ return { arrowRef, overlayRef, updatePosition };
433
466
  }
434
- function subscribeOverlayResize(overlay2, callback) {
435
- if (overlay2 instanceof Element) {
436
- const resizeObserver = new ResizeObserver(callback);
437
- resizeObserver.observe(overlay2);
438
- return () => resizeObserver.disconnect();
467
+ var flexibleOverlay = "";
468
+ const FlexibleOverlay = defineComponent({
469
+ name: "DFlexibleOverlay",
470
+ inheritAttrs: false,
471
+ props: flexibleOverlayProps,
472
+ emits: ["update:modelValue", "positionChange"],
473
+ setup(props, {
474
+ slots,
475
+ attrs,
476
+ emit,
477
+ expose
478
+ }) {
479
+ const ns2 = useNamespace("flexible-overlay");
480
+ const {
481
+ arrowRef,
482
+ overlayRef,
483
+ updatePosition
484
+ } = useOverlay(props, emit);
485
+ expose({
486
+ updatePosition
487
+ });
488
+ return () => {
489
+ var _a;
490
+ return props.modelValue && createVNode("div", mergeProps({
491
+ "ref": overlayRef,
492
+ "class": ns2.b()
493
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
494
+ "ref": arrowRef,
495
+ "class": ns2.e("arrow")
496
+ }, null)]);
497
+ };
439
498
  }
440
- return () => {
441
- };
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);
442
504
  }
443
- function subscribeOriginResize(origin, callback) {
444
- if (origin instanceof Element) {
445
- const observer = new MutationObserver(callback);
446
- observer.observe(origin, {
447
- attributeFilter: ["style"]
448
- });
449
- return () => observer.disconnect();
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);
450
520
  }
451
- return () => {
452
- };
521
+ return null;
453
522
  }
454
- FlexibleOverlay.install = function(app) {
455
- app.component(FlexibleOverlay.name, FlexibleOverlay);
456
- };
457
- FixedOverlay.install = function(app) {
458
- app.component(FixedOverlay.name, FixedOverlay);
459
- };
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
+ });
460
555
  var dropdown = "";
556
+ let dropdownId = 1;
461
557
  var Dropdown = defineComponent({
462
558
  name: "DDropdown",
559
+ inheritAttrs: false,
463
560
  props: dropdownProps,
464
- emits: [],
465
- setup(props, ctx) {
561
+ emits: ["toggle"],
562
+ setup(props, {
563
+ slots,
564
+ attrs,
565
+ emit,
566
+ expose
567
+ }) {
466
568
  const {
569
+ visible,
570
+ position,
571
+ align,
572
+ offset: offset2,
573
+ destroyOnHide,
574
+ shiftOffset,
575
+ showAnimation
576
+ } = toRefs(props);
577
+ const origin = ref();
578
+ const dropdownRef = ref();
579
+ const overlayRef = ref();
580
+ const id = `dropdown_${dropdownId++}`;
581
+ const isOpen = ref(false);
582
+ const currentPosition = ref("bottom");
583
+ const ns2 = useNamespace("dropdown");
584
+ provide(POPPER_TRIGGER_TOKEN, origin);
585
+ useDropdownEvent({
586
+ id,
467
587
  isOpen,
468
588
  origin,
469
- trigger,
470
- closeScope,
471
- closeOnMouseLeaveMenu
472
- } = toRefs(props);
473
- const visible = ref(false);
474
- watch(isOpen, (value) => {
475
- visible.value = value;
476
- }, {
477
- immediate: true
589
+ dropdownRef,
590
+ props,
591
+ emit
478
592
  });
479
- const position = {
480
- originX: "center",
481
- originY: "bottom",
482
- overlayX: "center",
483
- overlayY: "top"
484
- };
593
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
485
594
  const {
486
- dropdownEl
487
- } = useDropdown({
488
- visible,
489
- origin,
490
- trigger,
491
- closeScope,
492
- closeOnMouseLeaveMenu
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
+ });
493
607
  });
494
- const animatedVisible = computed(() => {
495
- return props.showAnimation ? visible.value : true;
608
+ expose({
609
+ updatePosition: () => overlayRef.value.updatePosition()
496
610
  });
497
- const wrapStyle = computed(() => typeof props.width === "string" ? {
498
- width: props.width
499
- } : {
500
- width: `${props.width}px`
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}`) : ""
621
+ }, {
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
634
+ }, {
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
+ })]);
645
+ }
646
+ });
647
+ const dropdownMenuProps = {
648
+ modelValue: {
649
+ type: Boolean,
650
+ default: false
651
+ },
652
+ origin: {
653
+ type: Object,
654
+ require: true
655
+ },
656
+ position: {
657
+ type: Array,
658
+ default: ["bottom"]
659
+ },
660
+ align: {
661
+ type: String,
662
+ default: null
663
+ },
664
+ offset: {
665
+ type: [Number, Object],
666
+ default: 4
667
+ },
668
+ clickOutside: {
669
+ type: Function,
670
+ default: () => true
671
+ },
672
+ showAnimation: {
673
+ type: Boolean,
674
+ default: true
675
+ },
676
+ overlayClass: {
677
+ type: String,
678
+ default: ""
679
+ }
680
+ };
681
+ var DropdownMenu = defineComponent({
682
+ name: "DDropdownMenu",
683
+ inheritAttrs: false,
684
+ props: dropdownMenuProps,
685
+ emits: ["update:modelValue"],
686
+ setup(props, {
687
+ slots,
688
+ attrs,
689
+ emit
690
+ }) {
691
+ const {
692
+ modelValue,
693
+ origin,
694
+ position,
695
+ align,
696
+ offset: offset2,
697
+ clickOutside,
698
+ showAnimation,
699
+ overlayClass
700
+ } = toRefs(props);
701
+ const dropdownMenuRef = ref(null);
702
+ const ns2 = useNamespace("dropdown");
703
+ onClickOutside(dropdownMenuRef, (value) => {
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))) {
706
+ emit("update:modelValue", false);
707
+ }
501
708
  });
502
- return () => createVNode(FlexibleOverlay, {
503
- "origin": props.origin,
504
- "visible": visible.value,
505
- "onUpdate:visible": ($event) => visible.value = $event,
506
- "position": position,
507
- "hasBackdrop": false
709
+ const currentPosition = ref("bottom");
710
+ const handlePositionChange = (pos) => {
711
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
712
+ };
713
+ const styles = computed(() => ({
714
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
715
+ }));
716
+ return () => createVNode(Teleport, {
717
+ "to": "body"
508
718
  }, {
509
719
  default: () => [createVNode(Transition, {
510
- "name": "devui-dropdown-fade"
720
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
511
721
  }, {
512
- default: () => {
513
- var _a, _b;
514
- return [withDirectives(createVNode("div", {
515
- "ref": dropdownEl,
516
- "class": "devui-dropdown-menu-wrap",
517
- "style": wrapStyle.value
518
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
519
- }
722
+ default: () => [createVNode(FlexibleOverlay, {
723
+ "modelValue": modelValue.value,
724
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
725
+ "origin": origin == null ? void 0 : origin.value,
726
+ "position": position.value,
727
+ "align": align.value,
728
+ "offset": offset2.value,
729
+ "onPositionChange": handlePositionChange,
730
+ "class": overlayClass.value,
731
+ "style": styles.value
732
+ }, {
733
+ default: () => {
734
+ var _a;
735
+ return [createVNode("div", mergeProps({
736
+ "ref": dropdownMenuRef,
737
+ "class": ns2.e("menu-wrap")
738
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
739
+ }
740
+ })]
520
741
  })]
521
742
  });
522
743
  }
523
744
  });
524
- Dropdown.install = function(app) {
525
- app.component(Dropdown.name, Dropdown);
526
- };
527
745
  var index = {
528
746
  title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
529
747
  category: "\u5BFC\u822A",
530
- status: "10%",
748
+ status: "50%",
531
749
  install(app) {
532
- app.use(Dropdown);
750
+ app.component(Dropdown.name, Dropdown);
751
+ app.component(DropdownMenu.name, DropdownMenu);
533
752
  }
534
753
  };
535
- export { Dropdown, index as default };
754
+ export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };