vue-devui 1.0.0-beta.9 → 1.0.0-rc.1

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 (294) hide show
  1. package/README.md +100 -72
  2. package/accordion/index.es.js +525 -39
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.es.js +34 -37
  6. package/alert/index.umd.js +1 -1
  7. package/alert/style.css +1 -1
  8. package/{time-axis → auto-complete}/index.d.ts +0 -0
  9. package/auto-complete/index.es.js +983 -0
  10. package/auto-complete/index.umd.js +1 -0
  11. package/auto-complete/package.json +7 -0
  12. package/auto-complete/style.css +1 -0
  13. package/back-top/index.es.js +5 -3
  14. package/back-top/index.umd.js +1 -1
  15. package/badge/index.es.js +13 -19
  16. package/badge/index.umd.js +1 -1
  17. package/badge/style.css +1 -1
  18. package/breadcrumb/index.es.js +2 -1
  19. package/button/index.es.js +296 -117
  20. package/button/index.umd.js +1 -1
  21. package/button/style.css +1 -1
  22. package/carousel/index.es.js +43 -57
  23. package/carousel/index.umd.js +1 -1
  24. package/cascader/index.es.js +5412 -784
  25. package/cascader/index.umd.js +27 -1
  26. package/cascader/style.css +1 -1
  27. package/checkbox/style.css +1 -1
  28. package/{toast → color-picker}/index.d.ts +0 -0
  29. package/color-picker/index.es.js +8196 -0
  30. package/color-picker/index.umd.js +27 -0
  31. package/color-picker/package.json +7 -0
  32. package/color-picker/style.css +1 -0
  33. package/comment/index.es.js +42 -13
  34. package/comment/index.umd.js +1 -1
  35. package/comment/style.css +1 -1
  36. package/countdown/index.es.js +27 -17
  37. package/countdown/index.umd.js +1 -1
  38. package/countdown/style.css +1 -1
  39. package/date-picker/index.es.js +48 -66
  40. package/date-picker/index.umd.js +1 -1
  41. package/date-picker/style.css +1 -1
  42. package/dragdrop/index.es.js +135 -10
  43. package/dragdrop/index.umd.js +1 -1
  44. package/drawer/index.es.js +169 -223
  45. package/drawer/index.umd.js +1 -1
  46. package/drawer/style.css +1 -1
  47. package/dropdown/index.es.js +463 -300
  48. package/dropdown/index.umd.js +1 -1
  49. package/dropdown/style.css +1 -1
  50. package/editable-select/index.es.js +293 -5660
  51. package/editable-select/index.umd.js +1 -27
  52. package/editable-select/style.css +1 -1
  53. package/form/index.es.js +6210 -531
  54. package/form/index.umd.js +27 -1
  55. package/form/style.css +1 -1
  56. package/fullscreen/index.es.js +112 -133
  57. package/fullscreen/index.umd.js +1 -1
  58. package/fullscreen/style.css +1 -1
  59. package/gantt/index.es.js +6 -18
  60. package/gantt/index.umd.js +1 -1
  61. package/gantt/style.css +1 -1
  62. package/grid/index.es.js +1 -1
  63. package/grid/style.css +1 -1
  64. package/icon/index.es.js +39 -56
  65. package/icon/index.umd.js +1 -1
  66. package/image-preview/index.es.js +35 -16
  67. package/image-preview/index.umd.js +1 -1
  68. package/input/index.es.js +4 -5
  69. package/input/index.umd.js +1 -1
  70. package/input/style.css +1 -1
  71. package/input-icon/index.es.js +42 -41
  72. package/input-icon/index.umd.js +1 -1
  73. package/input-icon/style.css +1 -1
  74. package/input-number/index.es.js +46 -56
  75. package/input-number/index.umd.js +1 -1
  76. package/input-number/style.css +1 -1
  77. package/list/index.d.ts +7 -0
  78. package/list/index.es.js +39 -0
  79. package/list/index.umd.js +1 -0
  80. package/{toast → list}/package.json +1 -1
  81. package/list/style.css +1 -0
  82. package/loading/index.es.js +2 -2
  83. package/modal/index.es.js +304 -765
  84. package/modal/index.umd.js +1 -1
  85. package/modal/style.css +1 -1
  86. package/nav-sprite/index.es.js +1 -675
  87. package/nav-sprite/index.umd.js +1 -1
  88. package/notification/index.d.ts +7 -0
  89. package/notification/index.es.js +284 -0
  90. package/notification/index.umd.js +1 -0
  91. package/notification/package.json +7 -0
  92. package/notification/style.css +1 -0
  93. package/nuxt/components/Accordion.js +3 -0
  94. package/nuxt/components/Alert.js +3 -0
  95. package/nuxt/components/Anchor.js +3 -0
  96. package/nuxt/components/Aside.js +3 -0
  97. package/nuxt/components/AutoComplete.js +3 -0
  98. package/nuxt/components/Avatar.js +3 -0
  99. package/nuxt/components/BackTop.js +3 -0
  100. package/nuxt/components/Badge.js +3 -0
  101. package/nuxt/components/Breadcrumb.js +3 -0
  102. package/nuxt/components/Button.js +3 -0
  103. package/nuxt/components/Card.js +3 -0
  104. package/nuxt/components/Carousel.js +3 -0
  105. package/nuxt/components/CarouselItem.js +3 -0
  106. package/nuxt/components/Cascader.js +3 -0
  107. package/nuxt/components/Checkbox.js +3 -0
  108. package/nuxt/components/Col.js +3 -0
  109. package/nuxt/components/ColorPicker.js +3 -0
  110. package/nuxt/components/Column.js +3 -0
  111. package/nuxt/components/Comment.js +3 -0
  112. package/nuxt/components/Content.js +3 -0
  113. package/nuxt/components/Countdown.js +3 -0
  114. package/nuxt/components/DatePicker.js +3 -0
  115. package/nuxt/components/Drawer.js +3 -0
  116. package/nuxt/components/DrawerService.js +3 -0
  117. package/nuxt/components/Dropdown.js +3 -0
  118. package/nuxt/components/DropdownMenu.js +3 -0
  119. package/nuxt/components/EditableSelect.js +3 -0
  120. package/nuxt/components/FixedOverlay.js +3 -0
  121. package/nuxt/components/FlexibleOverlay.js +3 -0
  122. package/nuxt/components/Footer.js +3 -0
  123. package/nuxt/components/Form.js +3 -0
  124. package/nuxt/components/FormControl.js +3 -0
  125. package/nuxt/components/FormItem.js +3 -0
  126. package/nuxt/components/FormLabel.js +3 -0
  127. package/nuxt/components/FormOperation.js +3 -0
  128. package/nuxt/components/Fullscreen.js +3 -0
  129. package/nuxt/components/Gantt.js +3 -0
  130. package/nuxt/components/Header.js +3 -0
  131. package/nuxt/components/IFileOptions.js +3 -0
  132. package/nuxt/components/IUploadOptions.js +3 -0
  133. package/nuxt/components/Icon.js +2 -0
  134. package/nuxt/components/ImagePreviewService.js +3 -0
  135. package/nuxt/components/Input.js +3 -0
  136. package/nuxt/components/InputIcon.js +3 -0
  137. package/nuxt/components/InputNumber.js +3 -0
  138. package/nuxt/components/Layout.js +3 -0
  139. package/nuxt/components/List.js +3 -0
  140. package/nuxt/components/ListItem.js +3 -0
  141. package/nuxt/components/Loading.js +3 -0
  142. package/nuxt/components/LoadingService.js +3 -0
  143. package/nuxt/components/Modal.js +3 -0
  144. package/nuxt/components/NavSprite.js +2 -0
  145. package/nuxt/components/Notification.js +3 -0
  146. package/nuxt/components/NotificationService.js +3 -0
  147. package/nuxt/components/Pagination.js +3 -0
  148. package/nuxt/components/Panel.js +3 -0
  149. package/nuxt/components/PanelBody.js +3 -0
  150. package/nuxt/components/PanelFooter.js +3 -0
  151. package/nuxt/components/PanelHeader.js +3 -0
  152. package/nuxt/components/Popover.js +3 -0
  153. package/nuxt/components/Progress.js +3 -0
  154. package/nuxt/components/QuadrantDiagram.js +3 -0
  155. package/nuxt/components/Radio.js +3 -0
  156. package/nuxt/components/RadioGroup.js +3 -0
  157. package/nuxt/components/Rate.js +3 -0
  158. package/nuxt/components/ReadTip.js +3 -0
  159. package/nuxt/components/Result.js +3 -0
  160. package/nuxt/components/Row.js +3 -0
  161. package/nuxt/components/Search.js +3 -0
  162. package/nuxt/components/Select.js +3 -0
  163. package/nuxt/components/Skeleton.js +3 -0
  164. package/nuxt/components/SkeletonItem.js +3 -0
  165. package/nuxt/components/Slider.js +3 -0
  166. package/nuxt/components/Splitter.js +3 -0
  167. package/nuxt/components/Statistic.js +3 -0
  168. package/nuxt/components/Status.js +3 -0
  169. package/nuxt/components/StepsGuide.js +3 -0
  170. package/nuxt/components/StickSlider.js +3 -0
  171. package/nuxt/components/Sticky.js +2 -0
  172. package/nuxt/components/Switch.js +3 -0
  173. package/nuxt/components/Table.js +3 -0
  174. package/nuxt/components/Tabs.js +3 -0
  175. package/nuxt/components/Tag.js +3 -0
  176. package/nuxt/components/TagInput.js +3 -0
  177. package/nuxt/components/Textarea.js +3 -0
  178. package/nuxt/components/TimePicker.js +3 -0
  179. package/nuxt/components/Timeline.js +3 -0
  180. package/nuxt/components/TimelineItem.js +3 -0
  181. package/nuxt/components/Tooltip.js +3 -0
  182. package/nuxt/components/Transfer.js +3 -0
  183. package/nuxt/components/Tree.js +3 -0
  184. package/nuxt/components/TreeSelect.js +3 -0
  185. package/nuxt/components/Upload.js +3 -0
  186. package/nuxt/components/UploadStatus.js +3 -0
  187. package/nuxt/components/alertProps.js +3 -0
  188. package/nuxt/components/badgeProps.js +3 -0
  189. package/nuxt/components/buttonProps.js +3 -0
  190. package/nuxt/components/dropdownMenuProps.js +3 -0
  191. package/nuxt/components/fixedOverlayProps.js +3 -0
  192. package/nuxt/components/flexibleOverlayProps.js +3 -0
  193. package/nuxt/components/fullscreenProps.js +3 -0
  194. package/nuxt/components/iconProps.js +2 -0
  195. package/nuxt/components/notificationProps.js +3 -0
  196. package/nuxt/components/overlayEmits.js +3 -0
  197. package/nuxt/components/overlayProps.js +3 -0
  198. package/nuxt/components/paginationProps.js +3 -0
  199. package/nuxt/components/panelProps.js +3 -0
  200. package/nuxt/components/popoverProps.js +3 -0
  201. package/nuxt/components/searchProps.js +3 -0
  202. package/nuxt/components/tooltipProps.js +3 -0
  203. package/nuxt/components/uploadProps.js +3 -0
  204. package/nuxt/index.js +13 -0
  205. package/overlay/index.es.js +156 -205
  206. package/overlay/index.umd.js +1 -1
  207. package/overlay/style.css +1 -1
  208. package/package.json +12 -55
  209. package/pagination/index.es.js +11 -13
  210. package/pagination/index.umd.js +1 -1
  211. package/pagination/style.css +1 -1
  212. package/panel/index.es.js +48 -35
  213. package/panel/index.umd.js +1 -1
  214. package/popover/index.es.js +5954 -189
  215. package/popover/index.umd.js +27 -1
  216. package/popover/style.css +1 -1
  217. package/progress/index.es.js +8 -8
  218. package/progress/index.umd.js +3 -3
  219. package/quadrant-diagram/index.es.js +5405 -166
  220. package/quadrant-diagram/index.umd.js +27 -1
  221. package/radio/index.es.js +8 -14
  222. package/radio/index.umd.js +1 -1
  223. package/radio/style.css +1 -1
  224. package/read-tip/index.es.js +6 -3
  225. package/read-tip/style.css +1 -1
  226. package/result/index.es.js +38 -52
  227. package/result/index.umd.js +1 -1
  228. package/ripple/index.es.js +10 -6
  229. package/search/index.es.js +5428 -200
  230. package/search/index.umd.js +27 -1
  231. package/search/style.css +1 -1
  232. package/select/index.es.js +43 -42
  233. package/select/index.umd.js +1 -1
  234. package/select/style.css +1 -1
  235. package/skeleton/index.es.js +17 -17
  236. package/skeleton/index.umd.js +1 -1
  237. package/slider/index.es.js +4 -6
  238. package/slider/index.umd.js +1 -1
  239. package/slider/style.css +1 -1
  240. package/splitter/index.es.js +5896 -39
  241. package/splitter/index.umd.js +27 -1
  242. package/splitter/style.css +1 -1
  243. package/statistic/index.es.js +19 -32
  244. package/statistic/index.umd.js +1 -1
  245. package/statistic/style.css +1 -1
  246. package/status/index.es.js +1 -4
  247. package/status/index.umd.js +1 -1
  248. package/status/style.css +1 -1
  249. package/steps-guide/index.es.js +6 -3
  250. package/sticky/index.umd.js +1 -1
  251. package/style.css +1 -1
  252. package/table/index.es.js +753 -358
  253. package/table/index.umd.js +1 -1
  254. package/table/style.css +1 -1
  255. package/tabs/index.es.js +3 -4
  256. package/tabs/index.umd.js +1 -1
  257. package/tabs/style.css +1 -1
  258. package/tag/index.es.js +4 -3
  259. package/tag/index.umd.js +1 -1
  260. package/tag/style.css +1 -1
  261. package/tag-input/index.es.js +4 -14
  262. package/tag-input/index.umd.js +1 -1
  263. package/textarea/style.css +1 -1
  264. package/{theme → theme/theme.scss} +0 -0
  265. package/time-picker/index.es.js +309 -123
  266. package/time-picker/index.umd.js +1 -1
  267. package/time-picker/style.css +1 -1
  268. package/timeline/index.d.ts +7 -0
  269. package/{time-axis → timeline}/index.es.js +65 -77
  270. package/timeline/index.umd.js +1 -0
  271. package/{time-axis → timeline}/package.json +1 -1
  272. package/timeline/style.css +1 -0
  273. package/tooltip/index.es.js +5805 -141
  274. package/tooltip/index.umd.js +27 -1
  275. package/tooltip/style.css +1 -1
  276. package/transfer/index.es.js +6521 -630
  277. package/transfer/index.umd.js +27 -1
  278. package/transfer/style.css +1 -1
  279. package/tree/index.es.js +5781 -193
  280. package/tree/index.umd.js +27 -1
  281. package/tree/style.css +1 -1
  282. package/tree-select/index.es.js +138 -39
  283. package/tree-select/index.umd.js +1 -1
  284. package/tree-select/style.css +1 -1
  285. package/upload/index.es.js +450 -2669
  286. package/upload/index.umd.js +1 -1
  287. package/upload/style.css +1 -1
  288. package/vue-devui.es.js +14414 -14096
  289. package/vue-devui.umd.js +19 -19
  290. package/time-axis/index.umd.js +0 -1
  291. package/time-axis/style.css +0 -1
  292. package/toast/index.es.js +0 -2059
  293. package/toast/index.umd.js +0 -1
  294. package/toast/style.css +0 -1
package/table/index.es.js CHANGED
@@ -17,7 +17,13 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide, Teleport, Transition, renderSlot, isVNode, onMounted, onUnmounted, withDirectives, vShow, reactive, isRef, toRefs, Fragment, shallowRef, getCurrentInstance, createTextVNode, resolveDirective, onBeforeMount, h, onBeforeUnmount } from "vue";
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
24
+ import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide, toRefs, onMounted, onUnmounted, Teleport, Transition, renderSlot, isVNode, unref, nextTick, Fragment, withDirectives, vShow, shallowRef, getCurrentInstance, createTextVNode, resolveDirective, reactive, onBeforeMount, h, onBeforeUnmount, render } from "vue";
25
+ import { shift, offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
26
+ import { onClickOutside } from "@vueuse/core";
21
27
  const TableProps = {
22
28
  data: {
23
29
  type: Array,
@@ -151,7 +157,7 @@ const createColumnGenerator = () => {
151
157
  const _columns = ref([]);
152
158
  const insertColumn = (column) => {
153
159
  _columns.value.push(column);
154
- _columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
160
+ _columns.value.sort((a, b) => a.order - b.order);
155
161
  };
156
162
  const sortColumn = () => {
157
163
  _columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
@@ -205,7 +211,7 @@ const createSelection = (dataSource, _data) => {
205
211
  };
206
212
  };
207
213
  const createSorter = (dataSource, _data) => {
208
- const sortData = (field, direction, compareFn = (field2, a, b) => a[field2] > b[field2]) => {
214
+ const sortData = (field, direction, compareFn = (fieldKey, a, b) => a[fieldKey] > b[fieldKey]) => {
209
215
  if (direction === "ASC") {
210
216
  _data.value = _data.value.sort((a, b) => compareFn(field, a, b) ? 1 : -1);
211
217
  } else if (direction === "DESC") {
@@ -217,13 +223,13 @@ const createSorter = (dataSource, _data) => {
217
223
  return { sortData };
218
224
  };
219
225
  const createFilter = (dataSource, _data) => {
220
- const fieldSet = new Set();
226
+ const fieldSet = /* @__PURE__ */ new Set();
221
227
  const filterData = (field, results) => {
222
228
  fieldSet.add(field);
223
229
  const fields = [...fieldSet];
224
230
  _data.value = dataSource.value.filter((item) => {
225
- return fields.reduce((prev, field2) => {
226
- return prev && results.indexOf(item[field2]) !== -1;
231
+ return fields.reduce((prev, fieldKey) => {
232
+ return prev && results.indexOf(item[fieldKey]) !== -1;
227
233
  }, true);
228
234
  });
229
235
  };
@@ -682,14 +688,7 @@ const Sort = defineComponent({
682
688
  }
683
689
  });
684
690
  const dropdownProps = {
685
- origin: {
686
- type: Object
687
- },
688
- isOpen: {
689
- type: Boolean,
690
- default: false
691
- },
692
- disabled: {
691
+ visible: {
693
692
  type: Boolean,
694
693
  default: false
695
694
  },
@@ -701,6 +700,18 @@ const dropdownProps = {
701
700
  type: String,
702
701
  default: "all"
703
702
  },
703
+ position: {
704
+ type: Array,
705
+ default: ["bottom"]
706
+ },
707
+ align: {
708
+ type: String,
709
+ default: null
710
+ },
711
+ offset: {
712
+ type: [Number, Object],
713
+ default: 4
714
+ },
704
715
  closeOnMouseLeaveMenu: {
705
716
  type: Boolean,
706
717
  default: false
@@ -708,11 +719,16 @@ const dropdownProps = {
708
719
  showAnimation: {
709
720
  type: Boolean,
710
721
  default: true
722
+ },
723
+ overlayClass: {
724
+ type: String,
725
+ default: ""
726
+ },
727
+ destroyOnHide: {
728
+ type: Boolean,
729
+ default: true
711
730
  }
712
731
  };
713
- function isComponent(target) {
714
- return !!(target == null ? void 0 : target.$el);
715
- }
716
732
  function getElement(element) {
717
733
  if (element instanceof Element) {
718
734
  return element;
@@ -722,85 +738,158 @@ function getElement(element) {
722
738
  }
723
739
  return null;
724
740
  }
741
+ const dropdownMap = /* @__PURE__ */ new Map();
725
742
  function subscribeEvent(dom, type, callback) {
726
743
  dom == null ? void 0 : dom.addEventListener(type, callback);
727
744
  return () => {
728
745
  dom == null ? void 0 : dom.removeEventListener(type, callback);
729
746
  };
730
747
  }
731
- const useDropdown = ({
732
- visible,
733
- trigger,
734
- origin,
735
- closeScope,
736
- closeOnMouseLeaveMenu
737
- }) => {
738
- const dropdownElRef = ref();
739
- const closeByScope = () => {
740
- if (closeScope.value === "none") {
741
- return;
742
- }
743
- visible.value = false;
748
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
749
+ let overlayEnter = false;
750
+ let originEnter = false;
751
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
752
+ const toggle = (status) => {
753
+ isOpen.value = status;
754
+ emit("toggle", isOpen.value);
744
755
  };
745
- watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
746
- const originEl = getElement(origin2);
747
- if (!originEl || !dropdownEl) {
756
+ const handleLeave = async (elementType, closeAll) => {
757
+ await new Promise((resolve) => setTimeout(resolve, 50));
758
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
748
759
  return;
749
760
  }
750
- const subscriptions = [
751
- subscribeEvent(dropdownEl, "click", () => {
752
- if (closeScope.value === "all") {
753
- visible.value = false;
754
- }
755
- })
756
- ];
757
- if (trigger2 === "click") {
758
- subscriptions.push(subscribeEvent(originEl, "click", () => visible.value = !visible.value), subscribeEvent(document, "click", (e) => {
759
- if (!visible.value) {
760
- return;
761
- }
762
- const target = e.target;
763
- const isContain = originEl.contains(target) || dropdownEl.contains(target);
764
- if (isContain) {
761
+ if (closeAll) {
762
+ [...dropdownMap.values()].reverse().forEach((item) => {
763
+ setTimeout(() => {
764
+ var _a;
765
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
766
+ }, 0);
767
+ });
768
+ }
769
+ toggle(false);
770
+ };
771
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
772
+ const originEl = getElement(originVal);
773
+ const subscriptions = [];
774
+ setTimeout(() => {
775
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
776
+ const dropdownValues = [...dropdownMap.values()];
777
+ if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
778
+ var _a;
779
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
780
+ }) && dropdownValues.some((item) => {
781
+ var _a;
782
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
783
+ })) {
765
784
  return;
766
785
  }
767
- closeByScope();
768
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
769
- if (closeOnMouseLeaveMenu.value) {
770
- visible.value = false;
771
- }
786
+ [...dropdownMap.values()].reverse().forEach((item) => {
787
+ setTimeout(() => {
788
+ var _a, _b;
789
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
790
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
791
+ }
792
+ }, 0);
793
+ });
794
+ overlayEnter = false;
772
795
  }));
773
- } else if (trigger2 === "hover") {
774
- let overlayEnter = false;
775
- let originEnter = false;
776
- const handleLeave = async (elementType) => {
777
- await new Promise((resolve) => setTimeout(resolve, 50));
778
- if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
779
- return;
796
+ }, 0);
797
+ if (triggerVal === "click") {
798
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
799
+ var _a;
800
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
801
+ handleLeave("dropdown", true);
780
802
  }
781
- closeByScope();
782
- };
803
+ }));
804
+ } else if (triggerVal === "hover") {
783
805
  subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
784
806
  originEnter = true;
785
- visible.value = true;
807
+ toggle(true);
786
808
  }), subscribeEvent(originEl, "mouseleave", () => {
787
809
  originEnter = false;
788
- if (!closeOnMouseLeaveMenu.value) {
789
- handleLeave("origin");
790
- }
810
+ handleLeave("origin");
791
811
  }), subscribeEvent(dropdownEl, "mouseenter", () => {
792
812
  overlayEnter = true;
793
- visible.value = true;
794
- }), subscribeEvent(dropdownEl, "mouseleave", () => {
813
+ isOpen.value = true;
814
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
815
+ var _a;
795
816
  overlayEnter = false;
796
- handleLeave("dropdown");
817
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
818
+ return;
819
+ }
820
+ handleLeave("dropdown", true);
797
821
  }));
798
822
  }
799
823
  onInvalidate(() => subscriptions.forEach((v) => v()));
800
824
  });
801
- return { dropdownEl: dropdownElRef };
802
825
  };
803
- var overlay = "";
826
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
827
+ const calcPopDirection = (dropdownEl) => {
828
+ const elementHeight = dropdownEl.offsetHeight;
829
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
830
+ const isBottomEnough = bottomDistance >= elementHeight;
831
+ if (!isBottomEnough) {
832
+ popDirection.value = "top";
833
+ } else {
834
+ popDirection.value = "bottom";
835
+ }
836
+ };
837
+ watch(visible, (newVal, oldVal) => {
838
+ if (oldVal === void 0) {
839
+ return;
840
+ }
841
+ isOpen.value = newVal;
842
+ emit("toggle", isOpen.value);
843
+ }, { immediate: true });
844
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
845
+ var _a;
846
+ if (isOpenVal) {
847
+ dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
848
+ menuEl: dropdownEl,
849
+ toggle: () => {
850
+ isOpen.value = false;
851
+ emit("toggle", isOpen.value);
852
+ }
853
+ }));
854
+ for (const value of dropdownMap.values()) {
855
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
856
+ value.child = dropdownEl;
857
+ }
858
+ }
859
+ }
860
+ if (dropdownEl) {
861
+ calcPopDirection(dropdownEl);
862
+ }
863
+ });
864
+ onMounted(() => {
865
+ dropdownMap.set(id, { toggleEl: origin.value });
866
+ });
867
+ onUnmounted(() => {
868
+ dropdownMap.delete(id);
869
+ });
870
+ }
871
+ function useOverlayProps(props, currentPosition, isOpen) {
872
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
873
+ const overlayModelValue = ref(false);
874
+ const overlayShowValue = ref(false);
875
+ const styles = computed(() => ({
876
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
877
+ }));
878
+ const classes = computed(() => ({
879
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
880
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
881
+ [`${overlayClass.value}`]: true
882
+ }));
883
+ const handlePositionChange = (pos) => {
884
+ currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
885
+ };
886
+ watch(isOpen, (isOpenVal) => {
887
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
888
+ overlayShowValue.value = isOpenVal;
889
+ });
890
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
891
+ }
892
+ var baseOverlay = "";
804
893
  function _isSlot(s) {
805
894
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
806
895
  }
@@ -824,9 +913,6 @@ const overlayProps = {
824
913
  visible: {
825
914
  type: Boolean
826
915
  },
827
- "onUpdate:visible": {
828
- type: Function
829
- },
830
916
  backgroundBlock: {
831
917
  type: Boolean,
832
918
  default: false
@@ -850,29 +936,14 @@ const overlayProps = {
850
936
  default: true
851
937
  }
852
938
  };
853
- const overlayEmits = ["onUpdate:visible", "backdropClick"];
854
939
  const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
855
940
  overlayStyle: {
856
941
  type: [String, Object],
857
942
  default: void 0
858
943
  }
859
944
  });
860
- const flexibleOverlayProps = __spreadValues({
861
- origin: {
862
- type: Object,
863
- require: true
864
- },
865
- position: {
866
- type: Object,
867
- default: () => ({
868
- originX: "left",
869
- originY: "top",
870
- overlayX: "left",
871
- overlayY: "top"
872
- })
873
- }
874
- }, overlayProps);
875
- function useOverlayLogic(props) {
945
+ const overlayEmits = ["update:visible", "backdropClick"];
946
+ function useOverlayLogic(props, ctx) {
876
947
  const backgroundClass = computed(() => {
877
948
  return [
878
949
  "devui-overlay-background",
@@ -884,11 +955,11 @@ function useOverlayLogic(props) {
884
955
  return "devui-overlay";
885
956
  });
886
957
  const handleBackdropClick = (event) => {
887
- var _a, _b;
958
+ var _a;
888
959
  event.preventDefault();
889
960
  (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
890
961
  if (props.backdropClose) {
891
- (_b = props["onUpdate:visible"]) == null ? void 0 : _b.call(props, false);
962
+ ctx.emit("update:visible", false);
892
963
  }
893
964
  };
894
965
  const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
@@ -922,7 +993,8 @@ function useOverlayLogic(props) {
922
993
  handleOverlayBubbleCancel
923
994
  };
924
995
  }
925
- const FixedOverlay = defineComponent({
996
+ var fixedOverlay = "";
997
+ defineComponent({
926
998
  name: "DFixedOverlay",
927
999
  props: fixedOverlayProps,
928
1000
  emits: overlayEmits,
@@ -932,9 +1004,9 @@ const FixedOverlay = defineComponent({
932
1004
  overlayClass,
933
1005
  handleBackdropClick,
934
1006
  handleOverlayBubbleCancel
935
- } = useOverlayLogic(props);
1007
+ } = useOverlayLogic(props, ctx);
936
1008
  return () => createVNode(CommonOverlay, null, {
937
- default: () => [withDirectives(createVNode("div", {
1009
+ default: () => [props.visible && createVNode("div", {
938
1010
  "class": backgroundClass.value,
939
1011
  "style": props.backgroundStyle,
940
1012
  "onClick": handleBackdropClick
@@ -942,246 +1014,340 @@ const FixedOverlay = defineComponent({
942
1014
  "class": overlayClass.value,
943
1015
  "style": props.overlayStyle,
944
1016
  "onClick": handleOverlayBubbleCancel
945
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
1017
+ }, [renderSlot(ctx.slots, "default")])])]
946
1018
  });
947
1019
  }
948
1020
  });
949
- const FlexibleOverlay = defineComponent({
950
- name: "DFlexibleOverlay",
951
- props: flexibleOverlayProps,
952
- emits: overlayEmits,
953
- setup(props, ctx) {
954
- const overlayRef = ref(null);
955
- const positionedStyle = reactive({
956
- position: "absolute"
957
- });
958
- onMounted(async () => {
959
- const handleRectChange = (position, rect, origin) => {
960
- const point = calculatePosition(position, rect, origin);
961
- positionedStyle.left = `${point.x}px`;
962
- positionedStyle.top = `${point.y}px`;
963
- };
964
- const locationElements = computed(() => {
965
- const overlay2 = overlayRef.value;
966
- const origin = getOrigin(props.origin);
967
- if (!overlay2 || !origin) {
968
- return;
969
- }
970
- return {
971
- origin,
972
- overlay: overlay2
973
- };
974
- });
975
- const visibleRef = toRef(props, "visible");
976
- const positionRef = toRef(props, "position");
977
- watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
978
- if (!visible || !locationElements2) {
979
- return;
980
- }
981
- const {
982
- origin,
983
- overlay: overlay2
984
- } = locationElements2;
985
- handleRectChange(position, overlay2.getBoundingClientRect(), origin);
986
- const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
987
- onInvalidate(() => {
988
- unsubscriptions.forEach((fn) => fn());
989
- });
990
- });
991
- });
992
- const {
993
- backgroundClass,
994
- overlayClass,
995
- handleBackdropClick,
996
- handleOverlayBubbleCancel
997
- } = useOverlayLogic(props);
998
- return () => createVNode(CommonOverlay, null, {
999
- default: () => [withDirectives(createVNode("div", {
1000
- "style": props.backgroundStyle,
1001
- "class": backgroundClass.value,
1002
- "onClick": handleBackdropClick
1003
- }, [createVNode("div", {
1004
- "ref": overlayRef,
1005
- "class": overlayClass.value,
1006
- "style": positionedStyle,
1007
- "onClick": handleOverlayBubbleCancel
1008
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
1009
- });
1010
- }
1011
- });
1012
- function getOrigin(origin) {
1013
- if (origin instanceof Element) {
1014
- return origin;
1015
- }
1016
- if (isRef(origin)) {
1017
- return getElement(origin.value);
1018
- }
1019
- if (isComponent(origin)) {
1020
- return getElement(origin);
1021
- }
1022
- return origin;
1023
- }
1024
- function calculatePosition(position, rect, origin) {
1025
- const originRect = getOriginRect(origin);
1026
- const originPoint = getOriginRelativePoint(originRect, position);
1027
- return getOverlayPoint(originPoint, rect, position);
1028
- }
1029
- function getOriginRect(origin) {
1030
- if (origin instanceof Element) {
1031
- return origin.getBoundingClientRect();
1032
- }
1033
- const width = origin.width || 0;
1034
- const height = origin.height || 0;
1035
- return {
1036
- top: origin.y,
1037
- bottom: origin.y + height,
1038
- left: origin.x,
1039
- right: origin.x + width,
1040
- height,
1041
- width
1042
- };
1043
- }
1044
- function getOverlayPoint(originPoint, rect, position) {
1045
- let x;
1046
- const {
1047
- width,
1048
- height
1049
- } = rect;
1050
- if (position.overlayX == "center") {
1051
- x = originPoint.x - width / 2;
1052
- } else {
1053
- x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
1021
+ const flexibleOverlayProps = {
1022
+ modelValue: {
1023
+ type: Boolean,
1024
+ default: false
1025
+ },
1026
+ origin: {
1027
+ type: Object,
1028
+ require: true
1029
+ },
1030
+ position: {
1031
+ type: Array,
1032
+ default: ["bottom"]
1033
+ },
1034
+ offset: {
1035
+ type: [Number, Object],
1036
+ default: 8
1037
+ },
1038
+ align: {
1039
+ type: String,
1040
+ default: null
1041
+ },
1042
+ showArrow: {
1043
+ type: Boolean,
1044
+ default: false
1045
+ },
1046
+ isArrowCenter: {
1047
+ type: Boolean,
1048
+ default: true
1054
1049
  }
1055
- let y;
1056
- if (position.overlayY == "center") {
1057
- y = originPoint.y - height / 2;
1058
- } else {
1059
- y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
1050
+ };
1051
+ function getScrollParent(element) {
1052
+ const overflowRegex = /(auto|scroll|hidden)/;
1053
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
1054
+ const style = window.getComputedStyle(parent);
1055
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
1056
+ return parent;
1057
+ }
1060
1058
  }
1061
- return {
1062
- x,
1063
- y
1064
- };
1059
+ return window;
1065
1060
  }
1066
- function getOriginRelativePoint(originRect, position) {
1067
- let x;
1068
- if (position.originX == "center") {
1069
- x = originRect.left + originRect.width / 2;
1070
- } else {
1071
- const startX = originRect.left;
1072
- const endX = originRect.right;
1073
- x = position.originX == "left" ? startX : endX;
1074
- }
1075
- let y;
1076
- if (position.originY == "center") {
1077
- y = originRect.top + originRect.height / 2;
1078
- } else {
1079
- y = position.originY == "top" ? originRect.top : originRect.bottom;
1061
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
1062
+ let { x, y } = point;
1063
+ if (!isArrowCenter) {
1064
+ const { width, height } = originRect;
1065
+ if (x && placement.includes("start")) {
1066
+ x = 12;
1067
+ }
1068
+ if (x && placement.includes("end")) {
1069
+ x = Math.round(width - 24);
1070
+ }
1071
+ if (y && placement.includes("start")) {
1072
+ y = 10;
1073
+ }
1074
+ if (y && placement.includes("end")) {
1075
+ y = height - 14;
1076
+ }
1080
1077
  }
1081
- return {
1082
- x,
1083
- y
1084
- };
1078
+ return { x, y };
1085
1079
  }
1086
- function subscribeLayoutEvent(event) {
1087
- window.addEventListener("scroll", event, true);
1088
- window.addEventListener("resize", event);
1089
- window.addEventListener("orientationchange", event);
1090
- return () => {
1091
- window.removeEventListener("scroll", event, true);
1092
- window.removeEventListener("resize", event);
1093
- window.removeEventListener("orientationchange", event);
1080
+ function useOverlay(props, emit) {
1081
+ const overlayRef = ref();
1082
+ const arrowRef = ref();
1083
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
1084
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
1085
+ const staticSide = {
1086
+ top: "bottom",
1087
+ right: "left",
1088
+ bottom: "top",
1089
+ left: "right"
1090
+ }[placement.split("-")[0]];
1091
+ Object.assign(arrowEl.style, {
1092
+ left: x ? `${x}px` : "",
1093
+ top: y ? `${y}px` : "",
1094
+ right: "",
1095
+ bottom: "",
1096
+ [staticSide]: "-4px"
1097
+ });
1094
1098
  };
1095
- }
1096
- function subscribeOverlayResize(overlay2, callback) {
1097
- if (overlay2 instanceof Element) {
1098
- const resizeObserver = new ResizeObserver(callback);
1099
- resizeObserver.observe(overlay2);
1100
- return () => resizeObserver.disconnect();
1101
- }
1102
- return () => {
1099
+ const updatePosition = async () => {
1100
+ const hostEl = props.origin;
1101
+ const overlayEl = unref(overlayRef.value);
1102
+ const arrowEl = unref(arrowRef.value);
1103
+ const middleware = [
1104
+ shift(),
1105
+ offset(props.offset),
1106
+ autoPlacement({
1107
+ alignment: props.align,
1108
+ allowedPlacements: props.position
1109
+ })
1110
+ ];
1111
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
1112
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
1113
+ strategy: "fixed",
1114
+ middleware
1115
+ });
1116
+ emit("positionChange", placement);
1117
+ Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
1118
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
1103
1119
  };
1120
+ watch(() => props.modelValue, () => {
1121
+ const originParent = getScrollParent(props.origin);
1122
+ if (props.modelValue && props.origin) {
1123
+ nextTick(updatePosition);
1124
+ originParent.addEventListener("scroll", updatePosition);
1125
+ originParent !== window && window.addEventListener("scroll", updatePosition);
1126
+ window.addEventListener("resize", updatePosition);
1127
+ } else {
1128
+ originParent.removeEventListener("scroll", updatePosition);
1129
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
1130
+ window.removeEventListener("resize", updatePosition);
1131
+ }
1132
+ });
1133
+ onUnmounted(() => {
1134
+ const originParent = getScrollParent(props.origin);
1135
+ originParent.removeEventListener("scroll", updatePosition);
1136
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
1137
+ window.removeEventListener("resize", updatePosition);
1138
+ });
1139
+ return { arrowRef, overlayRef, updatePosition };
1104
1140
  }
1105
- function subscribeOriginResize(origin, callback) {
1106
- if (origin instanceof Element) {
1107
- const observer = new MutationObserver(callback);
1108
- observer.observe(origin, {
1109
- attributeFilter: ["style"]
1141
+ var flexibleOverlay = "";
1142
+ const FlexibleOverlay = defineComponent({
1143
+ name: "DFlexibleOverlay",
1144
+ inheritAttrs: false,
1145
+ props: flexibleOverlayProps,
1146
+ emits: ["update:modelValue", "positionChange"],
1147
+ setup(props, {
1148
+ slots,
1149
+ attrs,
1150
+ emit,
1151
+ expose
1152
+ }) {
1153
+ const {
1154
+ arrowRef,
1155
+ overlayRef,
1156
+ updatePosition
1157
+ } = useOverlay(props, emit);
1158
+ expose({
1159
+ updatePosition
1110
1160
  });
1111
- return () => observer.disconnect();
1161
+ return () => {
1162
+ var _a;
1163
+ return props.modelValue && createVNode("div", mergeProps({
1164
+ "ref": overlayRef,
1165
+ "class": "devui-flexible-overlay"
1166
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
1167
+ "ref": arrowRef,
1168
+ "class": "devui-flexible-overlay-arrow"
1169
+ }, null)]);
1170
+ };
1112
1171
  }
1113
- return () => {
1114
- };
1115
- }
1116
- FlexibleOverlay.install = function(app) {
1117
- app.component(FlexibleOverlay.name, FlexibleOverlay);
1118
- };
1119
- FixedOverlay.install = function(app) {
1120
- app.component(FixedOverlay.name, FixedOverlay);
1121
- };
1172
+ });
1122
1173
  var dropdown = "";
1174
+ let dropdownId = 1;
1123
1175
  var Dropdown = defineComponent({
1124
1176
  name: "DDropdown",
1177
+ inheritAttrs: false,
1125
1178
  props: dropdownProps,
1126
- emits: [],
1127
- setup(props, ctx) {
1179
+ emits: ["toggle"],
1180
+ setup(props, {
1181
+ slots,
1182
+ attrs,
1183
+ emit,
1184
+ expose
1185
+ }) {
1128
1186
  const {
1187
+ visible,
1188
+ position,
1189
+ align,
1190
+ offset: offset2,
1191
+ showAnimation
1192
+ } = toRefs(props);
1193
+ const origin = ref();
1194
+ const dropdownRef = ref();
1195
+ const overlayRef = ref();
1196
+ const id = `dropdown_${dropdownId++}`;
1197
+ const isOpen = ref(false);
1198
+ const currentPosition = ref("bottom");
1199
+ useDropdownEvent({
1200
+ id,
1129
1201
  isOpen,
1130
1202
  origin,
1131
- trigger,
1132
- closeScope,
1133
- closeOnMouseLeaveMenu
1134
- } = toRefs(props);
1135
- const visible = ref(false);
1136
- watch(isOpen, (value) => {
1137
- visible.value = value;
1138
- }, {
1139
- immediate: true
1203
+ dropdownRef,
1204
+ props,
1205
+ emit
1140
1206
  });
1141
- const position = {
1142
- originX: "center",
1143
- originY: "bottom",
1144
- overlayX: "center",
1145
- overlayY: "top"
1146
- };
1207
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
1147
1208
  const {
1148
- dropdownEl
1149
- } = useDropdown({
1150
- visible,
1151
- origin,
1152
- trigger,
1153
- closeScope,
1154
- closeOnMouseLeaveMenu
1155
- });
1156
- const animatedVisible = computed(() => {
1157
- return props.showAnimation ? visible.value : true;
1209
+ overlayModelValue,
1210
+ overlayShowValue,
1211
+ styles,
1212
+ classes,
1213
+ handlePositionChange
1214
+ } = useOverlayProps(props, currentPosition, isOpen);
1215
+ expose({
1216
+ updatePosition: () => overlayRef.value.updatePosition()
1158
1217
  });
1159
1218
  return () => {
1160
- return createVNode(Fragment, null, [createVNode(FlexibleOverlay, {
1161
- "origin": props.origin,
1162
- "visible": visible.value,
1163
- "onUpdate:visible": ($event) => visible.value = $event,
1164
- "position": position,
1165
- "hasBackdrop": false
1219
+ var _a;
1220
+ return createVNode(Fragment, null, [createVNode("div", {
1221
+ "ref": origin,
1222
+ "class": "devui-dropdown-toggle"
1223
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
1224
+ "to": "body"
1166
1225
  }, {
1167
1226
  default: () => [createVNode(Transition, {
1168
- "name": "devui-dropdown-fade"
1227
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
1169
1228
  }, {
1170
- default: () => {
1171
- var _a, _b;
1172
- return [withDirectives(createVNode("div", {
1173
- "ref": dropdownEl,
1174
- "style": "min-width:102px"
1175
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
1176
- }
1229
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
1230
+ "modelValue": overlayModelValue.value,
1231
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
1232
+ "ref": overlayRef,
1233
+ "origin": origin.value,
1234
+ "position": position.value,
1235
+ "align": align.value,
1236
+ "offset": offset2.value,
1237
+ "onPositionChange": handlePositionChange,
1238
+ "class": classes.value,
1239
+ "style": styles.value
1240
+ }, {
1241
+ default: () => {
1242
+ var _a2;
1243
+ return [createVNode("div", mergeProps({
1244
+ "ref": dropdownRef,
1245
+ "class": "devui-dropdown-menu-wrap"
1246
+ }, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
1247
+ }
1248
+ }), [[vShow, overlayShowValue.value]])]
1177
1249
  })]
1178
1250
  })]);
1179
1251
  };
1180
1252
  }
1181
1253
  });
1182
- Dropdown.install = function(app) {
1183
- app.component(Dropdown.name, Dropdown);
1254
+ const dropdownMenuProps = {
1255
+ modelValue: {
1256
+ type: Boolean,
1257
+ default: false
1258
+ },
1259
+ origin: {
1260
+ type: Object,
1261
+ require: true
1262
+ },
1263
+ position: {
1264
+ type: Array,
1265
+ default: ["bottom"]
1266
+ },
1267
+ align: {
1268
+ type: String,
1269
+ default: null
1270
+ },
1271
+ offset: {
1272
+ type: [Number, Object],
1273
+ default: 4
1274
+ },
1275
+ clickOutside: {
1276
+ type: Function,
1277
+ default: () => true
1278
+ },
1279
+ showAnimation: {
1280
+ type: Boolean,
1281
+ default: true
1282
+ },
1283
+ overlayClass: {
1284
+ type: String,
1285
+ default: ""
1286
+ }
1184
1287
  };
1288
+ defineComponent({
1289
+ name: "DDropdownMenu",
1290
+ inheritAttrs: false,
1291
+ props: dropdownMenuProps,
1292
+ emits: ["update:modelValue"],
1293
+ setup(props, {
1294
+ slots,
1295
+ attrs,
1296
+ emit
1297
+ }) {
1298
+ const {
1299
+ modelValue,
1300
+ origin,
1301
+ position,
1302
+ align,
1303
+ offset: offset2,
1304
+ clickOutside,
1305
+ showAnimation,
1306
+ overlayClass
1307
+ } = toRefs(props);
1308
+ const dropdownMenuRef = ref(null);
1309
+ onClickOutside(dropdownMenuRef, (value) => {
1310
+ var _a, _b;
1311
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
1312
+ emit("update:modelValue", false);
1313
+ }
1314
+ });
1315
+ const currentPosition = ref("bottom");
1316
+ const handlePositionChange = (pos) => {
1317
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
1318
+ };
1319
+ const styles = computed(() => ({
1320
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
1321
+ }));
1322
+ return () => createVNode(Teleport, {
1323
+ "to": "body"
1324
+ }, {
1325
+ default: () => [createVNode(Transition, {
1326
+ "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
1327
+ }, {
1328
+ default: () => [createVNode(FlexibleOverlay, {
1329
+ "modelValue": modelValue.value,
1330
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
1331
+ "origin": origin == null ? void 0 : origin.value,
1332
+ "position": position.value,
1333
+ "align": align.value,
1334
+ "offset": offset2.value,
1335
+ "onPositionChange": handlePositionChange,
1336
+ "class": overlayClass.value,
1337
+ "style": styles.value
1338
+ }, {
1339
+ default: () => {
1340
+ var _a;
1341
+ return [createVNode("div", mergeProps({
1342
+ "ref": dropdownMenuRef,
1343
+ "class": "devui-dropdown-menu-wrap"
1344
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
1345
+ }
1346
+ })]
1347
+ })]
1348
+ });
1349
+ }
1350
+ });
1185
1351
  var filter = "";
1186
1352
  const Filter = defineComponent({
1187
1353
  props: {
@@ -1415,48 +1581,74 @@ const TD = defineComponent({
1415
1581
  }, [column.value.renderCell(props.row, props.index)]);
1416
1582
  }
1417
1583
  });
1418
- var table = "";
1419
- var Table = defineComponent({
1420
- name: "DTable",
1421
- props: TableProps,
1422
- setup(props, ctx) {
1423
- const table2 = getCurrentInstance();
1424
- const store = createStore(toRef(props, "data"));
1425
- table2.store = store;
1426
- provide(TABLE_TOKEN, table2);
1427
- const {
1428
- classes,
1429
- style
1430
- } = useTable(props);
1431
- const isEmpty = computed(() => props.data.length === 0);
1432
- const fixHeaderCompo = computed(() => {
1584
+ var FixHeader = defineComponent({
1585
+ props: {
1586
+ classes: {
1587
+ type: Object,
1588
+ default: () => ({})
1589
+ },
1590
+ isEmpty: {
1591
+ type: Boolean
1592
+ }
1593
+ },
1594
+ setup(props) {
1595
+ return () => {
1433
1596
  return createVNode("div", {
1434
1597
  "class": "devui-table-view"
1435
1598
  }, [createVNode("div", {
1436
- "style": "overflow: hidden scroll;"
1599
+ "style": "overflow:hidden scroll;"
1437
1600
  }, [createVNode("table", {
1438
- "class": classes.value,
1601
+ "class": props.classes,
1439
1602
  "cellpadding": "0",
1440
1603
  "cellspacing": "0"
1441
1604
  }, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
1442
1605
  "class": "scroll-view"
1443
1606
  }, [createVNode("table", {
1444
- "class": classes.value,
1607
+ "class": props.classes,
1445
1608
  "cellpadding": "0",
1446
1609
  "cellspacing": "0"
1447
- }, [createVNode(ColGroup, null, null), !isEmpty.value && createVNode(TableBody, {
1610
+ }, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
1448
1611
  "style": "flex: 1"
1449
1612
  }, null)])])]);
1450
- });
1451
- const normalHeaderCompo = computed(() => {
1613
+ };
1614
+ }
1615
+ });
1616
+ var NormalHeader = defineComponent({
1617
+ props: {
1618
+ classes: {
1619
+ type: Object,
1620
+ default: () => ({})
1621
+ },
1622
+ isEmpty: {
1623
+ type: Boolean
1624
+ }
1625
+ },
1626
+ setup(props) {
1627
+ return () => {
1452
1628
  return createVNode("table", {
1453
- "class": classes.value,
1629
+ "class": props.classes,
1454
1630
  "cellpadding": "0",
1455
1631
  "cellspacing": "0"
1456
1632
  }, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
1457
- "style": "position: relative"
1458
- }, null), !isEmpty.value && createVNode(TableBody, null, null)]);
1459
- });
1633
+ "style": "position:relative"
1634
+ }, null), !props.isEmpty && createVNode(TableBody, null, null)]);
1635
+ };
1636
+ }
1637
+ });
1638
+ var table = "";
1639
+ var Table = defineComponent({
1640
+ name: "DTable",
1641
+ props: TableProps,
1642
+ setup(props, ctx) {
1643
+ const table2 = getCurrentInstance();
1644
+ const store = createStore(toRef(props, "data"));
1645
+ table2.store = store;
1646
+ provide(TABLE_TOKEN, table2);
1647
+ const {
1648
+ classes,
1649
+ style
1650
+ } = useTable(props);
1651
+ const isEmpty2 = computed(() => props.data.length === 0);
1460
1652
  ctx.expose({
1461
1653
  getCheckedRows() {
1462
1654
  return store.getCheckedRows();
@@ -1465,7 +1657,13 @@ var Table = defineComponent({
1465
1657
  return () => withDirectives(createVNode("div", {
1466
1658
  "class": "devui-table-wrapper",
1467
1659
  "style": style.value
1468
- }, [ctx.slots.default(), props.fixHeader ? fixHeaderCompo.value : normalHeaderCompo.value, isEmpty.value && createVNode("div", {
1660
+ }, [ctx.slots.default(), props.fixHeader ? createVNode(FixHeader, {
1661
+ "classes": classes.value,
1662
+ "is-empty": isEmpty2.value
1663
+ }, null) : createVNode(NormalHeader, {
1664
+ "classes": classes.value,
1665
+ "is-empty": isEmpty2.value
1666
+ }, null), isEmpty2.value && createVNode("div", {
1469
1667
  "class": "devui-table-empty"
1470
1668
  }, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
1471
1669
  }
@@ -1530,6 +1728,9 @@ function formatWidth(width) {
1530
1728
  function formatMinWidth(minWidth) {
1531
1729
  return formatWidth(minWidth) || 80;
1532
1730
  }
1731
+ function defaultRenderHeader() {
1732
+ return h("span", { class: "title" }, this.header);
1733
+ }
1533
1734
  function createColumn(props, templates) {
1534
1735
  const {
1535
1736
  field,
@@ -1547,31 +1748,38 @@ function createColumn(props, templates) {
1547
1748
  fixedRight
1548
1749
  } = props;
1549
1750
  const column = reactive({});
1550
- watch([field, header2, order], ([field2, header22, order2]) => {
1551
- column.field = field2;
1552
- column.header = header22;
1553
- column.order = order2;
1751
+ function defaultRenderCell(rowData, index2) {
1752
+ var _a, _b;
1753
+ const value = rowData[this.field];
1754
+ if (templates.default) {
1755
+ return templates.default(rowData);
1756
+ }
1757
+ if (this.formatter) {
1758
+ return this.formatter(rowData, value, index2);
1759
+ }
1760
+ return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
1761
+ }
1762
+ watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
1763
+ column.field = fieldVal;
1764
+ column.header = headerVal;
1765
+ column.order = orderVal;
1554
1766
  }, { immediate: true });
1555
- watch([sortable, compareFn], ([sortable2, compareFn2]) => {
1556
- column.sortable = sortable2;
1557
- column.compareFn = compareFn2;
1767
+ watch([sortable, compareFn], ([sortableVal, compareFnVal]) => {
1768
+ column.sortable = sortableVal;
1769
+ column.compareFn = compareFnVal;
1558
1770
  });
1559
- watch([
1560
- filterable,
1561
- filterList,
1562
- filterMultiple
1563
- ], ([filterable2, filterList2, filterMultiple2]) => {
1564
- column.filterable = filterable2;
1565
- column.filterMultiple = filterMultiple2;
1566
- column.filterList = filterList2;
1771
+ watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
1772
+ column.filterable = filterableVal;
1773
+ column.filterMultiple = filterMultipleVal;
1774
+ column.filterList = filterListVal;
1567
1775
  }, { immediate: true });
1568
1776
  watch([fixedLeft, fixedRight], ([left, right]) => {
1569
1777
  column.fixedLeft = left;
1570
1778
  column.fixedRight = right;
1571
1779
  }, { immediate: true });
1572
- watch([width, minWidth], ([width2, minWidth2]) => {
1573
- column.width = formatWidth(width2);
1574
- column.minWidth = formatMinWidth(minWidth2);
1780
+ watch([width, minWidth], ([widthVal, minWidthVal]) => {
1781
+ column.width = formatWidth(widthVal);
1782
+ column.minWidth = formatMinWidth(minWidthVal);
1575
1783
  column.realWidth = column.width || column.minWidth;
1576
1784
  });
1577
1785
  onBeforeMount(() => {
@@ -1583,17 +1791,6 @@ function createColumn(props, templates) {
1583
1791
  });
1584
1792
  return column;
1585
1793
  }
1586
- function defaultRenderHeader() {
1587
- return h("span", { class: "title" }, this.header);
1588
- }
1589
- function defaultRenderCell(rowData, index2) {
1590
- var _a, _b;
1591
- const value = rowData[this.field];
1592
- if (this.formatter) {
1593
- return this.formatter(rowData, value, index2);
1594
- }
1595
- return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
1596
- }
1597
1794
  var Column = defineComponent({
1598
1795
  name: "DColumn",
1599
1796
  props: TableColumnProps,
@@ -1614,7 +1811,205 @@ var Column = defineComponent({
1614
1811
  return null;
1615
1812
  }
1616
1813
  });
1814
+ class View {
1815
+ constructor() {
1816
+ __publicField(this, "top", "50%");
1817
+ __publicField(this, "left", "50%");
1818
+ }
1819
+ }
1820
+ const componentProps = {
1821
+ message: String,
1822
+ backdrop: Boolean,
1823
+ view: {
1824
+ type: Object,
1825
+ default: () => new View()
1826
+ },
1827
+ zIndex: Number,
1828
+ isFull: {
1829
+ type: Boolean,
1830
+ default: false
1831
+ }
1832
+ };
1833
+ class LoadingProps {
1834
+ constructor() {
1835
+ __publicField(this, "target");
1836
+ __publicField(this, "message");
1837
+ __publicField(this, "loadingTemplateRef");
1838
+ __publicField(this, "backdrop", true);
1839
+ __publicField(this, "positionType", "relative");
1840
+ __publicField(this, "view", new View());
1841
+ __publicField(this, "zIndex");
1842
+ }
1843
+ }
1844
+ var loading = "";
1845
+ var Loading = defineComponent({
1846
+ name: "DLoading",
1847
+ inheritAttrs: false,
1848
+ props: componentProps,
1849
+ setup(props) {
1850
+ const style = {
1851
+ top: props.view.top,
1852
+ left: props.view.left,
1853
+ zIndex: props.zIndex
1854
+ };
1855
+ if (!props.message) {
1856
+ style.background = "none";
1857
+ }
1858
+ const isShow = ref(false);
1859
+ const open = () => {
1860
+ isShow.value = true;
1861
+ };
1862
+ const close = () => {
1863
+ isShow.value = false;
1864
+ };
1865
+ return {
1866
+ style,
1867
+ isShow,
1868
+ open,
1869
+ close
1870
+ };
1871
+ },
1872
+ render() {
1873
+ var _a;
1874
+ const {
1875
+ isShow,
1876
+ isFull,
1877
+ backdrop,
1878
+ style,
1879
+ message,
1880
+ $slots
1881
+ } = this;
1882
+ return isShow && createVNode("div", {
1883
+ "class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
1884
+ }, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
1885
+ "class": "devui-loading-wrapper"
1886
+ }, [backdrop ? createVNode("div", {
1887
+ "class": "devui-loading-mask"
1888
+ }, null) : null, createVNode("div", {
1889
+ "style": style,
1890
+ "class": "devui-loading-area"
1891
+ }, [createVNode("div", {
1892
+ "class": "devui-busy-default-spinner"
1893
+ }, [createVNode("div", {
1894
+ "class": "devui-loading-bar1"
1895
+ }, null), createVNode("div", {
1896
+ "class": "devui-loading-bar2"
1897
+ }, null), createVNode("div", {
1898
+ "class": "devui-loading-bar3"
1899
+ }, null), createVNode("div", {
1900
+ "class": "devui-loading-bar4"
1901
+ }, null)]), message ? createVNode("span", {
1902
+ "class": "devui-loading-text"
1903
+ }, [message]) : null])])]);
1904
+ }
1905
+ });
1906
+ const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
1907
+ function createComponent(Component, props, children = null) {
1908
+ const vnode = h(Component, __spreadValues({}, props), children);
1909
+ const container = document.createElement("div");
1910
+ vnode[COMPONENT_CONTAINER_SYMBOL] = container;
1911
+ render(vnode, container);
1912
+ return vnode.component;
1913
+ }
1914
+ function unmountComponent(ComponnetInstance) {
1915
+ render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
1916
+ }
1917
+ const loadingConstructor = defineComponent(Loading);
1918
+ const cacheInstance = /* @__PURE__ */ new WeakSet();
1919
+ const isEmpty = (val) => {
1920
+ if (!val)
1921
+ return true;
1922
+ if (Array.isArray(val))
1923
+ return val.length === 0;
1924
+ if (val instanceof Set || val instanceof Map)
1925
+ return val.size === 0;
1926
+ if (val instanceof Promise)
1927
+ return false;
1928
+ if (typeof val === "object") {
1929
+ try {
1930
+ return Object.keys(val).length === 0;
1931
+ } catch (e) {
1932
+ return false;
1933
+ }
1934
+ }
1935
+ return false;
1936
+ };
1937
+ const getType = (vari) => {
1938
+ return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
1939
+ };
1940
+ const isPromise = (value) => {
1941
+ const type = getType(value);
1942
+ switch (type) {
1943
+ case "promise":
1944
+ return [value];
1945
+ case "array":
1946
+ if (value.some((val) => getType(val) !== "promise")) {
1947
+ console.error(new TypeError("Binding values should all be of type Promise"));
1948
+ return "error";
1949
+ }
1950
+ return value;
1951
+ default:
1952
+ return false;
1953
+ }
1954
+ };
1955
+ const unmount = (el) => {
1956
+ cacheInstance.delete(el);
1957
+ el.instance.proxy.close();
1958
+ unmountComponent(el.instance);
1959
+ };
1960
+ const toggleLoading = (el, binding) => {
1961
+ if (binding.value) {
1962
+ const vals = isPromise(binding.value);
1963
+ if (vals === "error")
1964
+ return;
1965
+ el.instance.proxy.open();
1966
+ el.appendChild(el.mask);
1967
+ cacheInstance.add(el);
1968
+ if (vals) {
1969
+ Promise.all(vals).catch((err) => {
1970
+ console.error(new Error("Promise handling errors"), err);
1971
+ }).finally(() => {
1972
+ unmount(el);
1973
+ });
1974
+ }
1975
+ } else {
1976
+ unmount(el);
1977
+ }
1978
+ };
1979
+ const removeAttribute = (el) => {
1980
+ el.removeAttribute("zindex");
1981
+ el.removeAttribute("positiontype");
1982
+ el.removeAttribute("backdrop");
1983
+ el.removeAttribute("message");
1984
+ el.removeAttribute("view");
1985
+ el.removeAttribute("loadingtemplateref");
1986
+ };
1987
+ const handleProps = (el, vprops) => {
1988
+ const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
1989
+ const loadingTemplateRef = props.loadingTemplateRef;
1990
+ const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
1991
+ el.style.position = props.positionType;
1992
+ el.options = props;
1993
+ el.instance = loadingInstance;
1994
+ el.mask = loadingInstance.proxy.$el;
1995
+ };
1996
+ const loadingDirective = {
1997
+ mounted: function(el, binding, vnode) {
1998
+ handleProps(el, vnode.props);
1999
+ removeAttribute(el);
2000
+ !isEmpty(binding.value) && toggleLoading(el, binding);
2001
+ },
2002
+ updated: function(el, binding, vnode) {
2003
+ if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
2004
+ return;
2005
+ !cacheInstance.has(el) && handleProps(el, vnode.props);
2006
+ removeAttribute(el);
2007
+ toggleLoading(el, binding);
2008
+ }
2009
+ };
2010
+ defineComponent(Loading);
1617
2011
  Table.install = function(app) {
2012
+ app.directive("dLoading", loadingDirective);
1618
2013
  app.component(Table.name, Table);
1619
2014
  app.component(Column.name, Column);
1620
2015
  };