vue-devui 1.0.0-beta.7 → 1.0.0-pre.0

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