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

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 (404) 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 +8395 -463
  6. package/auto-complete/index.umd.js +40 -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 +5751 -156
  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 +8110 -278
  21. package/checkbox/index.umd.js +38 -1
  22. package/checkbox/style.css +1 -1
  23. package/{accordion → collapse}/index.d.ts +0 -0
  24. package/collapse/index.es.js +195 -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 +12035 -0
  32. package/date-picker-pro/index.umd.js +38 -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 +191 -5756
  36. package/drawer/index.umd.js +1 -27
  37. package/drawer/style.css +1 -1
  38. package/dropdown/index.es.js +616 -415
  39. package/dropdown/index.umd.js +1 -1
  40. package/dropdown/style.css +1 -1
  41. package/editable-select/index.es.js +779 -211
  42. package/editable-select/index.umd.js +1 -1
  43. package/editable-select/style.css +1 -1
  44. package/form/index.es.js +2405 -2125
  45. package/form/index.umd.js +28 -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 +105 -103
  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 +67 -54
  57. package/image-preview/index.umd.js +1 -1
  58. package/image-preview/style.css +1 -1
  59. package/input/index.es.js +8268 -144
  60. package/input/index.umd.js +38 -1
  61. package/input/style.css +1 -1
  62. package/input-number/index.es.js +260 -192
  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 +86 -70
  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 +3036 -2898
  73. package/mention/index.umd.js +47 -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 +891 -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 +533 -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 +602 -1061
  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 +528 -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 +8013 -180
  213. package/radio/index.umd.js +38 -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 +52 -60
  222. package/ripple/index.umd.js +1 -1
  223. package/search/index.es.js +3885 -1152
  224. package/search/index.umd.js +29 -18
  225. package/search/style.css +1 -1
  226. package/select/index.es.js +9235 -516
  227. package/select/index.umd.js +38 -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 +6219 -232
  236. package/splitter/index.umd.js +27 -1
  237. package/splitter/style.css +1 -1
  238. package/statistic/index.es.js +41 -55
  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 +7818 -64
  251. package/switch/index.umd.js +38 -1
  252. package/switch/style.css +1 -1
  253. package/table/index.es.js +11109 -1451
  254. package/table/index.umd.js +38 -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 +7940 -83
  263. package/textarea/index.umd.js +46 -1
  264. package/textarea/style.css +1 -1
  265. package/time-picker/index.es.js +8953 -632
  266. package/time-picker/index.umd.js +38 -1
  267. package/time-picker/style.css +1 -1
  268. package/{comment → time-select}/index.d.ts +0 -0
  269. package/time-select/index.es.js +9606 -0
  270. package/time-select/index.umd.js +38 -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 +7601 -2508
  282. package/tree/index.umd.js +29 -18
  283. package/tree/style.css +1 -1
  284. package/upload/index.es.js +849 -6143
  285. package/upload/index.umd.js +1 -27
  286. package/upload/style.css +1 -1
  287. package/vue-devui.es.js +20537 -19051
  288. package/vue-devui.umd.js +41 -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.es.js +0 -7340
  397. package/transfer/index.umd.js +0 -27
  398. package/transfer/package.json +0 -7
  399. package/transfer/style.css +0 -1
  400. package/tree-select/index.d.ts +0 -7
  401. package/tree-select/index.es.js +0 -623
  402. package/tree-select/index.umd.js +0 -1
  403. package/tree-select/package.json +0 -7
  404. package/tree-select/style.css +0 -1
@@ -1,32 +1,8 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { ref, watch, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, withDirectives, vShow, reactive, toRef, isRef, toRefs } from "vue";
1
+ import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode, Transition, mergeProps, nextTick, unref, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, provide, Teleport, vShow } from "vue";
2
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
3
+ import { onClickOutside } from "@vueuse/core";
21
4
  const dropdownProps = {
22
- origin: {
23
- type: Object
24
- },
25
- isOpen: {
26
- type: Boolean,
27
- default: false
28
- },
29
- disabled: {
5
+ visible: {
30
6
  type: Boolean,
31
7
  default: false
32
8
  },
@@ -38,6 +14,21 @@ const dropdownProps = {
38
14
  type: String,
39
15
  default: "all"
40
16
  },
17
+ position: {
18
+ type: Array,
19
+ default: ["bottom"]
20
+ },
21
+ align: {
22
+ type: String,
23
+ default: null
24
+ },
25
+ offset: {
26
+ type: [Number, Object],
27
+ default: 4
28
+ },
29
+ shiftOffset: {
30
+ type: Number
31
+ },
41
32
  closeOnMouseLeaveMenu: {
42
33
  type: Boolean,
43
34
  default: false
@@ -46,14 +37,16 @@ const dropdownProps = {
46
37
  type: Boolean,
47
38
  default: true
48
39
  },
49
- width: {
50
- type: [Number, String],
51
- default: "102px"
40
+ overlayClass: {
41
+ type: String,
42
+ default: ""
43
+ },
44
+ destroyOnHide: {
45
+ type: Boolean,
46
+ default: true
52
47
  }
53
48
  };
54
- function isComponent(target) {
55
- return !!(target == null ? void 0 : target.$el);
56
- }
49
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
57
50
  function getElement(element) {
58
51
  if (element instanceof Element) {
59
52
  return element;
@@ -63,473 +56,681 @@ function getElement(element) {
63
56
  }
64
57
  return null;
65
58
  }
59
+ const dropdownMap = /* @__PURE__ */ new Map();
66
60
  function subscribeEvent(dom, type, callback) {
67
61
  dom == null ? void 0 : dom.addEventListener(type, callback);
68
62
  return () => {
69
63
  dom == null ? void 0 : dom.removeEventListener(type, callback);
70
64
  };
71
65
  }
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;
66
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
67
+ let overlayEnter = false;
68
+ let originEnter = false;
69
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
70
+ const toggle = (status) => {
71
+ isOpen.value = status;
72
+ emit("toggle", isOpen.value);
85
73
  };
86
- watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
87
- const originEl = getElement(origin2);
88
- if (!originEl || !dropdownEl) {
74
+ const handleLeave = async (elementType, closeAll) => {
75
+ await new Promise((resolve) => setTimeout(resolve, 50));
76
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
89
77
  return;
90
78
  }
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) {
79
+ if (closeAll) {
80
+ [...dropdownMap.values()].reverse().forEach((item) => {
81
+ setTimeout(() => {
82
+ var _a;
83
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
84
+ }, 0);
85
+ });
86
+ }
87
+ toggle(false);
88
+ };
89
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
90
+ const originEl = getElement(originVal);
91
+ const subscriptions = [];
92
+ setTimeout(() => {
93
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
94
+ const dropdownValues = [...dropdownMap.values()];
95
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
96
+ var _a;
97
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
98
+ }) && dropdownValues.some((item) => {
99
+ var _a;
100
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
101
+ })) {
106
102
  return;
107
103
  }
108
- closeByScope();
109
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
110
- if (closeOnMouseLeaveMenu.value) {
111
- visible.value = false;
112
- }
104
+ [...dropdownMap.values()].reverse().forEach((item) => {
105
+ setTimeout(() => {
106
+ var _a, _b;
107
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
108
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
109
+ }
110
+ }, 0);
111
+ });
112
+ overlayEnter = false;
113
113
  }));
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;
114
+ }, 0);
115
+ if (triggerVal === "click") {
116
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
117
+ var _a;
118
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
119
+ handleLeave("dropdown", true);
121
120
  }
122
- closeByScope();
123
- };
121
+ }));
122
+ } else if (triggerVal === "hover") {
124
123
  subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
125
124
  originEnter = true;
126
- visible.value = true;
125
+ toggle(true);
127
126
  }), subscribeEvent(originEl, "mouseleave", () => {
128
127
  originEnter = false;
129
- if (!closeOnMouseLeaveMenu.value) {
130
- handleLeave("origin");
131
- }
128
+ handleLeave("origin");
132
129
  }), subscribeEvent(dropdownEl, "mouseenter", () => {
133
130
  overlayEnter = true;
134
- visible.value = true;
135
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
131
+ isOpen.value = true;
132
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
133
+ var _a;
136
134
  overlayEnter = false;
137
- handleLeave("dropdown");
135
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
136
+ return;
137
+ }
138
+ handleLeave("dropdown", true);
138
139
  }));
139
140
  }
140
141
  onInvalidate(() => subscriptions.forEach((v) => v()));
141
142
  });
142
- return { dropdownEl: dropdownElRef };
143
143
  };
144
- var overlay = "";
145
- function _isSlot(s) {
146
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
147
- }
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
- })]
144
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
145
+ const calcPopDirection = (dropdownEl) => {
146
+ const elementHeight = dropdownEl.offsetHeight;
147
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
148
+ const isBottomEnough = bottomDistance >= elementHeight;
149
+ if (!isBottomEnough) {
150
+ popDirection.value = "top";
151
+ } else {
152
+ popDirection.value = "bottom";
153
+ }
154
+ };
155
+ watch(visible, (newVal, oldVal) => {
156
+ if (oldVal === void 0) {
157
+ return;
158
+ }
159
+ isOpen.value = newVal;
160
+ emit("toggle", isOpen.value);
161
+ }, { immediate: true });
162
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
163
+ var _a;
164
+ if (isOpenVal) {
165
+ dropdownMap.set(id, {
166
+ ...dropdownMap.get(id),
167
+ menuEl: dropdownEl,
168
+ toggle: () => {
169
+ isOpen.value = false;
170
+ emit("toggle", isOpen.value);
171
+ }
160
172
  });
161
- };
162
- }
163
- });
164
- const overlayProps = {
165
- visible: {
166
- type: Boolean
167
- },
168
- backgroundBlock: {
173
+ for (const value of dropdownMap.values()) {
174
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
175
+ value.child = dropdownEl;
176
+ }
177
+ }
178
+ }
179
+ if (dropdownEl) {
180
+ calcPopDirection(dropdownEl);
181
+ }
182
+ });
183
+ onMounted(() => {
184
+ dropdownMap.set(id, { toggleEl: origin.value });
185
+ });
186
+ onUnmounted(() => {
187
+ dropdownMap.delete(id);
188
+ });
189
+ }
190
+ function useOverlayProps(props, currentPosition, isOpen) {
191
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
192
+ const overlayModelValue = ref(false);
193
+ const overlayShowValue = ref(false);
194
+ const styles = computed(() => ({
195
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
196
+ }));
197
+ const classes = computed(() => ({
198
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
199
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
200
+ [`${overlayClass.value}`]: true
201
+ }));
202
+ const handlePositionChange = (pos) => {
203
+ currentPosition.value = pos.includes("top") || pos.includes("right-end") || pos.includes("left-end") ? "top" : "bottom";
204
+ };
205
+ watch(isOpen, (isOpenVal) => {
206
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
207
+ overlayShowValue.value = isOpenVal;
208
+ });
209
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
210
+ }
211
+ const fixedOverlayProps = {
212
+ modelValue: {
169
213
  type: Boolean,
170
214
  default: false
171
215
  },
172
- backgroundClass: {
173
- type: String,
174
- default: ""
175
- },
176
- backgroundStyle: {
177
- type: [String, Object]
178
- },
179
- onBackdropClick: {
180
- type: Function
181
- },
182
- backdropClose: {
216
+ lockScroll: {
183
217
  type: Boolean,
184
218
  default: true
185
219
  },
186
- hasBackdrop: {
220
+ closeOnClickOverlay: {
187
221
  type: Boolean,
188
222
  default: true
189
223
  }
190
224
  };
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
- })
225
+ function lockScroll() {
226
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
227
+ const scrollTop = document.documentElement.scrollTop;
228
+ const style = document.documentElement.getAttribute("style");
229
+ document.documentElement.style.position = "fixed";
230
+ document.documentElement.style.top = `-${scrollTop}px`;
231
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
232
+ document.documentElement.style.overflowY = "scroll";
233
+ return () => {
234
+ if (style) {
235
+ document.documentElement.setAttribute("style", style);
236
+ } else {
237
+ document.documentElement.removeAttribute("style");
238
+ }
239
+ document.documentElement.scrollTop = scrollTop;
240
+ };
211
241
  }
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;
242
+ return;
243
+ }
244
+ function useFixedOverlay(props, ctx) {
245
+ let lockScrollCb;
246
+ const onClick = (event) => {
226
247
  event.preventDefault();
227
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
228
- if (props.backdropClose) {
229
- ctx.emit("update:visible", false);
248
+ ctx.emit("click", event);
249
+ if (props.closeOnClickOverlay) {
250
+ ctx.emit("update:modelValue", false);
230
251
  }
231
252
  };
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
- });
253
+ const removeBodyAdditions = () => {
254
+ lockScrollCb == null ? void 0 : lockScrollCb();
255
+ };
256
+ watch(() => props.modelValue, (val) => {
257
+ if (val) {
258
+ props.lockScroll && (lockScrollCb = lockScroll());
259
+ } else {
260
+ removeBodyAdditions();
261
+ }
255
262
  });
263
+ onUnmounted(removeBodyAdditions);
264
+ return { onClick };
265
+ }
266
+ function createBem(namespace, element, modifier) {
267
+ let cls = namespace;
268
+ if (element) {
269
+ cls += `__${element}`;
270
+ }
271
+ if (modifier) {
272
+ cls += `--${modifier}`;
273
+ }
274
+ return cls;
275
+ }
276
+ function useNamespace(block, needDot = false) {
277
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
278
+ const b = () => createBem(namespace);
279
+ const e = (element) => element ? createBem(namespace, element) : "";
280
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
281
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
256
282
  return {
257
- backgroundClass,
258
- overlayClass,
259
- handleBackdropClick,
260
- handleOverlayBubbleCancel
283
+ b,
284
+ e,
285
+ m,
286
+ em
261
287
  };
262
288
  }
263
- const FixedOverlay = defineComponent({
289
+ var fixedOverlay = "";
290
+ defineComponent({
264
291
  name: "DFixedOverlay",
292
+ inheritAttrs: false,
265
293
  props: fixedOverlayProps,
266
- emits: overlayEmits,
294
+ emits: ["update:modelValue", "click"],
267
295
  setup(props, ctx) {
268
296
  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
- });
297
+ modelValue
298
+ } = toRefs(props);
299
+ const ns2 = useNamespace("fixed-overlay");
330
300
  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]])]
301
+ onClick
302
+ } = useFixedOverlay(props, ctx);
303
+ return () => createVNode(Transition, {
304
+ "name": ns2.m("fade")
305
+ }, {
306
+ default: () => {
307
+ var _a, _b;
308
+ return [modelValue.value && createVNode("div", mergeProps({
309
+ "class": ns2.b()
310
+ }, ctx.attrs, {
311
+ "onClick": onClick
312
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
313
+ }
347
314
  });
348
315
  }
349
316
  });
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);
317
+ const flexibleOverlayProps = {
318
+ modelValue: {
319
+ type: Boolean,
320
+ default: false
321
+ },
322
+ origin: {
323
+ type: Object,
324
+ require: true
325
+ },
326
+ position: {
327
+ type: Array,
328
+ default: ["bottom"]
329
+ },
330
+ offset: {
331
+ type: [Number, Object],
332
+ default: 8
333
+ },
334
+ shiftOffset: {
335
+ type: Number
336
+ },
337
+ align: {
338
+ type: String,
339
+ default: null
340
+ },
341
+ showArrow: {
342
+ type: Boolean,
343
+ default: false
344
+ },
345
+ isArrowCenter: {
346
+ type: Boolean,
347
+ default: true
359
348
  }
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();
349
+ };
350
+ function getScrollParent(element) {
351
+ const overflowRegex = /(auto|scroll|hidden)/;
352
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
353
+ const style = window.getComputedStyle(parent);
354
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
355
+ return parent;
356
+ }
370
357
  }
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
- };
358
+ return window;
381
359
  }
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;
360
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
361
+ let { x, y } = point;
362
+ if (!isArrowCenter) {
363
+ const { width, height } = originRect;
364
+ if (x && placement.includes("start")) {
365
+ x = 12;
366
+ }
367
+ if (x && placement.includes("end")) {
368
+ x = Math.round(width - 24);
369
+ }
370
+ if (y && placement.includes("start")) {
371
+ y = 10;
372
+ }
373
+ if (y && placement.includes("end")) {
374
+ y = height - 14;
375
+ }
398
376
  }
399
- return {
400
- x,
401
- y
402
- };
377
+ return { x, y };
403
378
  }
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
379
+ function useOverlay(props, emit) {
380
+ const overlayRef = ref();
381
+ const arrowRef = ref();
382
+ let originParent = null;
383
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
384
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
385
+ const staticSide = {
386
+ top: "bottom",
387
+ right: "left",
388
+ bottom: "top",
389
+ left: "right"
390
+ }[placement.split("-")[0]];
391
+ Object.assign(arrowEl.style, {
392
+ left: x ? `${x}px` : "",
393
+ top: y ? `${y}px` : "",
394
+ right: "",
395
+ bottom: "",
396
+ [staticSide]: "-4px"
397
+ });
422
398
  };
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);
399
+ const updatePosition = async () => {
400
+ const hostEl = props.origin;
401
+ const overlayEl = unref(overlayRef.value);
402
+ const arrowEl = unref(arrowRef.value);
403
+ const middleware = [
404
+ offset(props.offset),
405
+ autoPlacement({
406
+ alignment: props.align,
407
+ allowedPlacements: props.position
408
+ })
409
+ ];
410
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
411
+ props.shiftOffset !== void 0 && middleware.push(shift());
412
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
413
+ strategy: "fixed",
414
+ middleware
415
+ });
416
+ let applyX = x;
417
+ let applyY = y;
418
+ if (props.shiftOffset !== void 0) {
419
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
420
+ shiftX < 0 && (applyX -= props.shiftOffset);
421
+ shiftX > 0 && (applyX += props.shiftOffset);
422
+ shiftY < 0 && (applyY -= props.shiftOffset);
423
+ shiftY > 0 && (applyY += props.shiftOffset);
424
+ }
425
+ emit("positionChange", placement);
426
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
427
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
432
428
  };
429
+ watch(() => props.modelValue, () => {
430
+ if (props.modelValue && props.origin) {
431
+ originParent = getScrollParent(props.origin);
432
+ nextTick(updatePosition);
433
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
434
+ originParent !== window && window.addEventListener("scroll", updatePosition);
435
+ window.addEventListener("resize", updatePosition);
436
+ } else {
437
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
438
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
439
+ window.removeEventListener("resize", updatePosition);
440
+ }
441
+ });
442
+ onUnmounted(() => {
443
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
444
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
445
+ window.removeEventListener("resize", updatePosition);
446
+ });
447
+ return { arrowRef, overlayRef, updatePosition };
433
448
  }
434
- function subscribeOverlayResize(overlay2, callback) {
435
- if (overlay2 instanceof Element) {
436
- const resizeObserver = new ResizeObserver(callback);
437
- resizeObserver.observe(overlay2);
438
- return () => resizeObserver.disconnect();
449
+ var flexibleOverlay = "";
450
+ const FlexibleOverlay = defineComponent({
451
+ name: "DFlexibleOverlay",
452
+ inheritAttrs: false,
453
+ props: flexibleOverlayProps,
454
+ emits: ["update:modelValue", "positionChange"],
455
+ setup(props, {
456
+ slots,
457
+ attrs,
458
+ emit,
459
+ expose
460
+ }) {
461
+ const ns2 = useNamespace("flexible-overlay");
462
+ const {
463
+ arrowRef,
464
+ overlayRef,
465
+ updatePosition
466
+ } = useOverlay(props, emit);
467
+ expose({
468
+ updatePosition
469
+ });
470
+ return () => {
471
+ var _a;
472
+ return props.modelValue && createVNode("div", mergeProps({
473
+ "ref": overlayRef,
474
+ "class": ns2.b()
475
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
476
+ "ref": arrowRef,
477
+ "class": ns2.e("arrow")
478
+ }, null)]);
479
+ };
439
480
  }
440
- return () => {
441
- };
481
+ });
482
+ const isObject = (val) => val !== null && typeof val === "object";
483
+ const ns = useNamespace("popper-trigger");
484
+ function wrapContent(content) {
485
+ return h("span", { class: ns.b() }, content);
442
486
  }
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();
487
+ function getFirstValidChild(nodes) {
488
+ for (const child of nodes) {
489
+ if (isObject(child)) {
490
+ if (child.type === Comment) {
491
+ continue;
492
+ }
493
+ if (child.type === "svg" || child.type === Text) {
494
+ return wrapContent(child);
495
+ }
496
+ if (child.type === Fragment) {
497
+ return getFirstValidChild(child.children);
498
+ }
499
+ return child;
500
+ }
501
+ return wrapContent(child);
450
502
  }
451
- return () => {
452
- };
503
+ return null;
453
504
  }
454
- FlexibleOverlay.install = function(app) {
455
- app.component(FlexibleOverlay.name, FlexibleOverlay);
456
- };
457
- FixedOverlay.install = function(app) {
458
- app.component(FixedOverlay.name, FixedOverlay);
459
- };
505
+ var PopperTrigger = defineComponent({
506
+ name: "DPopperTrigger",
507
+ setup(_, ctx) {
508
+ const {
509
+ slots,
510
+ attrs
511
+ } = ctx;
512
+ return () => {
513
+ var _a;
514
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
515
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
516
+ if (!defaultSlot) {
517
+ return null;
518
+ }
519
+ const firstValidChild = getFirstValidChild(defaultSlot);
520
+ if (!firstValidChild) {
521
+ return null;
522
+ }
523
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
524
+ mounted(el) {
525
+ triggerRef.value = el;
526
+ },
527
+ updated(el) {
528
+ triggerRef.value = el;
529
+ },
530
+ unmounted() {
531
+ triggerRef.value = null;
532
+ }
533
+ }]]);
534
+ };
535
+ }
536
+ });
460
537
  var dropdown = "";
538
+ let dropdownId = 1;
461
539
  var Dropdown = defineComponent({
462
540
  name: "DDropdown",
541
+ inheritAttrs: false,
463
542
  props: dropdownProps,
464
- emits: [],
465
- setup(props, ctx) {
543
+ emits: ["toggle"],
544
+ setup(props, {
545
+ slots,
546
+ attrs,
547
+ emit,
548
+ expose
549
+ }) {
466
550
  const {
551
+ visible,
552
+ position,
553
+ align,
554
+ offset: offset2,
555
+ destroyOnHide,
556
+ shiftOffset,
557
+ showAnimation
558
+ } = toRefs(props);
559
+ const origin = ref();
560
+ const dropdownRef = ref();
561
+ const overlayRef = ref();
562
+ const id = `dropdown_${dropdownId++}`;
563
+ const isOpen = ref(false);
564
+ const currentPosition = ref("bottom");
565
+ const ns2 = useNamespace("dropdown");
566
+ provide(POPPER_TRIGGER_TOKEN, origin);
567
+ useDropdownEvent({
568
+ id,
467
569
  isOpen,
468
570
  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
571
+ dropdownRef,
572
+ props,
573
+ emit
478
574
  });
479
- const position = {
480
- originX: "center",
481
- originY: "bottom",
482
- overlayX: "center",
483
- overlayY: "top"
484
- };
575
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
485
576
  const {
486
- dropdownEl
487
- } = useDropdown({
488
- visible,
489
- origin,
490
- trigger,
491
- closeScope,
492
- closeOnMouseLeaveMenu
577
+ overlayModelValue,
578
+ overlayShowValue,
579
+ styles,
580
+ classes,
581
+ handlePositionChange
582
+ } = useOverlayProps(props, currentPosition, isOpen);
583
+ watch(overlayShowValue, (overlayShowValueVal) => {
584
+ nextTick(() => {
585
+ if (!destroyOnHide.value && overlayShowValueVal) {
586
+ overlayRef.value.updatePosition();
587
+ }
588
+ });
493
589
  });
494
- const animatedVisible = computed(() => {
495
- return props.showAnimation ? visible.value : true;
590
+ expose({
591
+ updatePosition: () => overlayRef.value.updatePosition()
496
592
  });
497
- const wrapStyle = computed(() => typeof props.width === "string" ? {
498
- width: props.width
499
- } : {
500
- width: `${props.width}px`
593
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
594
+ default: () => {
595
+ var _a;
596
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
597
+ }
598
+ }), createVNode(Teleport, {
599
+ "to": "body"
600
+ }, {
601
+ default: () => [createVNode(Transition, {
602
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
603
+ }, {
604
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
605
+ "modelValue": overlayModelValue.value,
606
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
607
+ "ref": overlayRef,
608
+ "origin": origin.value,
609
+ "position": position.value,
610
+ "align": align.value,
611
+ "offset": offset2.value,
612
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
613
+ "onPositionChange": handlePositionChange,
614
+ "class": classes.value,
615
+ "style": styles.value
616
+ }, {
617
+ default: () => {
618
+ var _a;
619
+ return [createVNode("div", mergeProps({
620
+ "ref": dropdownRef,
621
+ "class": ns2.e("menu-wrap")
622
+ }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
623
+ }
624
+ }), [[vShow, overlayShowValue.value]])]
625
+ })]
626
+ })]);
627
+ }
628
+ });
629
+ const dropdownMenuProps = {
630
+ modelValue: {
631
+ type: Boolean,
632
+ default: false
633
+ },
634
+ origin: {
635
+ type: Object,
636
+ require: true
637
+ },
638
+ position: {
639
+ type: Array,
640
+ default: ["bottom"]
641
+ },
642
+ align: {
643
+ type: String,
644
+ default: null
645
+ },
646
+ offset: {
647
+ type: [Number, Object],
648
+ default: 4
649
+ },
650
+ clickOutside: {
651
+ type: Function,
652
+ default: () => true
653
+ },
654
+ showAnimation: {
655
+ type: Boolean,
656
+ default: true
657
+ },
658
+ overlayClass: {
659
+ type: String,
660
+ default: ""
661
+ }
662
+ };
663
+ var DropdownMenu = defineComponent({
664
+ name: "DDropdownMenu",
665
+ inheritAttrs: false,
666
+ props: dropdownMenuProps,
667
+ emits: ["update:modelValue"],
668
+ setup(props, {
669
+ slots,
670
+ attrs,
671
+ emit
672
+ }) {
673
+ const {
674
+ modelValue,
675
+ origin,
676
+ position,
677
+ align,
678
+ offset: offset2,
679
+ clickOutside,
680
+ showAnimation,
681
+ overlayClass
682
+ } = toRefs(props);
683
+ const dropdownMenuRef = ref(null);
684
+ const ns2 = useNamespace("dropdown");
685
+ onClickOutside(dropdownMenuRef, (value) => {
686
+ var _a, _b;
687
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
688
+ emit("update:modelValue", false);
689
+ }
501
690
  });
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
691
+ const currentPosition = ref("bottom");
692
+ const handlePositionChange = (pos) => {
693
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
694
+ };
695
+ const styles = computed(() => ({
696
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
697
+ }));
698
+ return () => createVNode(Teleport, {
699
+ "to": "body"
508
700
  }, {
509
701
  default: () => [createVNode(Transition, {
510
- "name": "devui-dropdown-fade"
702
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
511
703
  }, {
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
- }
704
+ default: () => [createVNode(FlexibleOverlay, {
705
+ "modelValue": modelValue.value,
706
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
707
+ "origin": origin == null ? void 0 : origin.value,
708
+ "position": position.value,
709
+ "align": align.value,
710
+ "offset": offset2.value,
711
+ "onPositionChange": handlePositionChange,
712
+ "class": overlayClass.value,
713
+ "style": styles.value
714
+ }, {
715
+ default: () => {
716
+ var _a;
717
+ return [createVNode("div", mergeProps({
718
+ "ref": dropdownMenuRef,
719
+ "class": ns2.e("menu-wrap")
720
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
721
+ }
722
+ })]
520
723
  })]
521
724
  });
522
725
  }
523
726
  });
524
- Dropdown.install = function(app) {
525
- app.component(Dropdown.name, Dropdown);
526
- };
527
727
  var index = {
528
728
  title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
529
729
  category: "\u5BFC\u822A",
530
- status: "10%",
730
+ status: "50%",
531
731
  install(app) {
532
- app.use(Dropdown);
732
+ app.component(Dropdown.name, Dropdown);
733
+ app.component(DropdownMenu.name, DropdownMenu);
533
734
  }
534
735
  };
535
- export { Dropdown, index as default };
736
+ export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };