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.
- package/README.md +100 -72
- package/accordion/index.es.js +525 -39
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +34 -37
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/{time-axis → auto-complete}/index.d.ts +0 -0
- package/auto-complete/index.es.js +983 -0
- package/auto-complete/index.umd.js +1 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/back-top/index.es.js +5 -3
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +13 -19
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/breadcrumb/index.es.js +2 -1
- package/button/index.es.js +296 -117
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +43 -57
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5412 -784
- package/cascader/index.umd.js +27 -1
- package/cascader/style.css +1 -1
- package/checkbox/style.css +1 -1
- package/{toast → color-picker}/index.d.ts +0 -0
- package/color-picker/index.es.js +8196 -0
- package/color-picker/index.umd.js +27 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/comment/index.es.js +42 -13
- package/comment/index.umd.js +1 -1
- package/comment/style.css +1 -1
- package/countdown/index.es.js +27 -17
- package/countdown/index.umd.js +1 -1
- package/countdown/style.css +1 -1
- package/date-picker/index.es.js +48 -66
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.es.js +135 -10
- package/dragdrop/index.umd.js +1 -1
- package/drawer/index.es.js +169 -223
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +463 -300
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +293 -5660
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6210 -531
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +112 -133
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/gantt/index.es.js +6 -18
- package/gantt/index.umd.js +1 -1
- package/gantt/style.css +1 -1
- package/grid/index.es.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +39 -56
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +35 -16
- package/image-preview/index.umd.js +1 -1
- package/input/index.es.js +4 -5
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-icon/index.es.js +42 -41
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +46 -56
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/list/index.d.ts +7 -0
- package/list/index.es.js +39 -0
- package/list/index.umd.js +1 -0
- package/{toast → list}/package.json +1 -1
- package/list/style.css +1 -0
- package/loading/index.es.js +2 -2
- package/modal/index.es.js +304 -765
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.es.js +1 -675
- package/nav-sprite/index.umd.js +1 -1
- package/notification/index.d.ts +7 -0
- package/notification/index.es.js +284 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/CarouselItem.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/List.js +3 -0
- package/nuxt/components/ListItem.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.es.js +156 -205
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +12 -55
- package/pagination/index.es.js +11 -13
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +48 -35
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5954 -189
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +8 -8
- package/progress/index.umd.js +3 -3
- package/quadrant-diagram/index.es.js +5405 -166
- package/quadrant-diagram/index.umd.js +27 -1
- package/radio/index.es.js +8 -14
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +6 -3
- package/read-tip/style.css +1 -1
- package/result/index.es.js +38 -52
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +10 -6
- package/search/index.es.js +5428 -200
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +43 -42
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +4 -6
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5896 -39
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +19 -32
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +6 -3
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +753 -358
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +3 -4
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +4 -3
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +4 -14
- package/tag-input/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-picker/index.es.js +309 -123
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/timeline/index.d.ts +7 -0
- package/{time-axis → timeline}/index.es.js +65 -77
- package/timeline/index.umd.js +1 -0
- package/{time-axis → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +5805 -141
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +6521 -630
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5781 -193
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +138 -39
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +450 -2669
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +14414 -14096
- package/vue-devui.umd.js +19 -19
- package/time-axis/index.umd.js +0 -1
- package/time-axis/style.css +0 -1
- package/toast/index.es.js +0 -2059
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
package/dropdown/index.es.js
CHANGED
|
@@ -17,16 +17,11 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import {
|
|
20
|
+
import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, unref, nextTick, mergeProps, Fragment, withDirectives, vShow } from "vue";
|
|
21
|
+
import { shift, offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
22
|
+
import { onClickOutside } from "@vueuse/core";
|
|
21
23
|
const dropdownProps = {
|
|
22
|
-
|
|
23
|
-
type: Object
|
|
24
|
-
},
|
|
25
|
-
isOpen: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: false
|
|
28
|
-
},
|
|
29
|
-
disabled: {
|
|
24
|
+
visible: {
|
|
30
25
|
type: Boolean,
|
|
31
26
|
default: false
|
|
32
27
|
},
|
|
@@ -38,6 +33,18 @@ const dropdownProps = {
|
|
|
38
33
|
type: String,
|
|
39
34
|
default: "all"
|
|
40
35
|
},
|
|
36
|
+
position: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default: ["bottom"]
|
|
39
|
+
},
|
|
40
|
+
align: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: null
|
|
43
|
+
},
|
|
44
|
+
offset: {
|
|
45
|
+
type: [Number, Object],
|
|
46
|
+
default: 4
|
|
47
|
+
},
|
|
41
48
|
closeOnMouseLeaveMenu: {
|
|
42
49
|
type: Boolean,
|
|
43
50
|
default: false
|
|
@@ -45,11 +52,16 @@ const dropdownProps = {
|
|
|
45
52
|
showAnimation: {
|
|
46
53
|
type: Boolean,
|
|
47
54
|
default: true
|
|
55
|
+
},
|
|
56
|
+
overlayClass: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: ""
|
|
59
|
+
},
|
|
60
|
+
destroyOnHide: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true
|
|
48
63
|
}
|
|
49
64
|
};
|
|
50
|
-
function isComponent(target) {
|
|
51
|
-
return !!(target == null ? void 0 : target.$el);
|
|
52
|
-
}
|
|
53
65
|
function getElement(element) {
|
|
54
66
|
if (element instanceof Element) {
|
|
55
67
|
return element;
|
|
@@ -59,85 +71,158 @@ function getElement(element) {
|
|
|
59
71
|
}
|
|
60
72
|
return null;
|
|
61
73
|
}
|
|
74
|
+
const dropdownMap = /* @__PURE__ */ new Map();
|
|
62
75
|
function subscribeEvent(dom, type, callback) {
|
|
63
76
|
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
64
77
|
return () => {
|
|
65
78
|
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
66
79
|
};
|
|
67
80
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const dropdownElRef = ref();
|
|
76
|
-
const closeByScope = () => {
|
|
77
|
-
if (closeScope.value === "none") {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
visible.value = false;
|
|
81
|
+
const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
82
|
+
let overlayEnter = false;
|
|
83
|
+
let originEnter = false;
|
|
84
|
+
const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
|
|
85
|
+
const toggle = (status) => {
|
|
86
|
+
isOpen.value = status;
|
|
87
|
+
emit("toggle", isOpen.value);
|
|
81
88
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
89
|
+
const handleLeave = async (elementType, closeAll) => {
|
|
90
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
91
|
+
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
85
92
|
return;
|
|
86
93
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
if (closeAll) {
|
|
95
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = item.toggle) == null ? void 0 : _a.call(item);
|
|
99
|
+
}, 0);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
toggle(false);
|
|
103
|
+
};
|
|
104
|
+
watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
|
|
105
|
+
const originEl = getElement(originVal);
|
|
106
|
+
const subscriptions = [];
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
109
|
+
const dropdownValues = [...dropdownMap.values()];
|
|
110
|
+
if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
111
|
+
var _a;
|
|
112
|
+
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
113
|
+
}) && dropdownValues.some((item) => {
|
|
114
|
+
var _a;
|
|
115
|
+
return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
|
|
116
|
+
})) {
|
|
102
117
|
return;
|
|
103
118
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
|
|
123
|
+
(_b = item.toggle) == null ? void 0 : _b.call(item);
|
|
124
|
+
}
|
|
125
|
+
}, 0);
|
|
126
|
+
});
|
|
127
|
+
overlayEnter = false;
|
|
109
128
|
}));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return;
|
|
129
|
+
}, 0);
|
|
130
|
+
if (triggerVal === "click") {
|
|
131
|
+
subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
132
|
+
var _a;
|
|
133
|
+
if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
134
|
+
handleLeave("dropdown", true);
|
|
117
135
|
}
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
}));
|
|
137
|
+
} else if (triggerVal === "hover") {
|
|
120
138
|
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
121
139
|
originEnter = true;
|
|
122
|
-
|
|
140
|
+
toggle(true);
|
|
123
141
|
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
124
142
|
originEnter = false;
|
|
125
|
-
|
|
126
|
-
handleLeave("origin");
|
|
127
|
-
}
|
|
143
|
+
handleLeave("origin");
|
|
128
144
|
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
129
145
|
overlayEnter = true;
|
|
130
|
-
|
|
131
|
-
}), subscribeEvent(dropdownEl, "mouseleave", () => {
|
|
146
|
+
isOpen.value = true;
|
|
147
|
+
}), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
148
|
+
var _a;
|
|
132
149
|
overlayEnter = false;
|
|
133
|
-
|
|
150
|
+
if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
handleLeave("dropdown", true);
|
|
134
154
|
}));
|
|
135
155
|
}
|
|
136
156
|
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
137
157
|
});
|
|
138
|
-
return { dropdownEl: dropdownElRef };
|
|
139
158
|
};
|
|
140
|
-
|
|
159
|
+
function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
|
|
160
|
+
const calcPopDirection = (dropdownEl) => {
|
|
161
|
+
const elementHeight = dropdownEl.offsetHeight;
|
|
162
|
+
const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
|
|
163
|
+
const isBottomEnough = bottomDistance >= elementHeight;
|
|
164
|
+
if (!isBottomEnough) {
|
|
165
|
+
popDirection.value = "top";
|
|
166
|
+
} else {
|
|
167
|
+
popDirection.value = "bottom";
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
watch(visible, (newVal, oldVal) => {
|
|
171
|
+
if (oldVal === void 0) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
isOpen.value = newVal;
|
|
175
|
+
emit("toggle", isOpen.value);
|
|
176
|
+
}, { immediate: true });
|
|
177
|
+
watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
|
|
178
|
+
var _a;
|
|
179
|
+
if (isOpenVal) {
|
|
180
|
+
dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
|
|
181
|
+
menuEl: dropdownEl,
|
|
182
|
+
toggle: () => {
|
|
183
|
+
isOpen.value = false;
|
|
184
|
+
emit("toggle", isOpen.value);
|
|
185
|
+
}
|
|
186
|
+
}));
|
|
187
|
+
for (const value of dropdownMap.values()) {
|
|
188
|
+
if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
|
|
189
|
+
value.child = dropdownEl;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (dropdownEl) {
|
|
194
|
+
calcPopDirection(dropdownEl);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
onMounted(() => {
|
|
198
|
+
dropdownMap.set(id, { toggleEl: origin.value });
|
|
199
|
+
});
|
|
200
|
+
onUnmounted(() => {
|
|
201
|
+
dropdownMap.delete(id);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function useOverlayProps(props, currentPosition, isOpen) {
|
|
205
|
+
const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
|
|
206
|
+
const overlayModelValue = ref(false);
|
|
207
|
+
const overlayShowValue = ref(false);
|
|
208
|
+
const styles = computed(() => ({
|
|
209
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
210
|
+
}));
|
|
211
|
+
const classes = computed(() => ({
|
|
212
|
+
"fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
|
|
213
|
+
"fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
|
|
214
|
+
[`${overlayClass.value}`]: true
|
|
215
|
+
}));
|
|
216
|
+
const handlePositionChange = (pos) => {
|
|
217
|
+
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
218
|
+
};
|
|
219
|
+
watch(isOpen, (isOpenVal) => {
|
|
220
|
+
overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
|
|
221
|
+
overlayShowValue.value = isOpenVal;
|
|
222
|
+
});
|
|
223
|
+
return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
|
|
224
|
+
}
|
|
225
|
+
var baseOverlay = "";
|
|
141
226
|
function _isSlot(s) {
|
|
142
227
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
143
228
|
}
|
|
@@ -161,9 +246,6 @@ const overlayProps = {
|
|
|
161
246
|
visible: {
|
|
162
247
|
type: Boolean
|
|
163
248
|
},
|
|
164
|
-
"onUpdate:visible": {
|
|
165
|
-
type: Function
|
|
166
|
-
},
|
|
167
249
|
backgroundBlock: {
|
|
168
250
|
type: Boolean,
|
|
169
251
|
default: false
|
|
@@ -187,29 +269,14 @@ const overlayProps = {
|
|
|
187
269
|
default: true
|
|
188
270
|
}
|
|
189
271
|
};
|
|
190
|
-
const overlayEmits = ["onUpdate:visible", "backdropClick"];
|
|
191
272
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
192
273
|
overlayStyle: {
|
|
193
274
|
type: [String, Object],
|
|
194
275
|
default: void 0
|
|
195
276
|
}
|
|
196
277
|
});
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
type: Object,
|
|
200
|
-
require: true
|
|
201
|
-
},
|
|
202
|
-
position: {
|
|
203
|
-
type: Object,
|
|
204
|
-
default: () => ({
|
|
205
|
-
originX: "left",
|
|
206
|
-
originY: "top",
|
|
207
|
-
overlayX: "left",
|
|
208
|
-
overlayY: "top"
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
}, overlayProps);
|
|
212
|
-
function useOverlayLogic(props) {
|
|
278
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
279
|
+
function useOverlayLogic(props, ctx) {
|
|
213
280
|
const backgroundClass = computed(() => {
|
|
214
281
|
return [
|
|
215
282
|
"devui-overlay-background",
|
|
@@ -221,11 +288,11 @@ function useOverlayLogic(props) {
|
|
|
221
288
|
return "devui-overlay";
|
|
222
289
|
});
|
|
223
290
|
const handleBackdropClick = (event) => {
|
|
224
|
-
var _a
|
|
291
|
+
var _a;
|
|
225
292
|
event.preventDefault();
|
|
226
293
|
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
227
294
|
if (props.backdropClose) {
|
|
228
|
-
(
|
|
295
|
+
ctx.emit("update:visible", false);
|
|
229
296
|
}
|
|
230
297
|
};
|
|
231
298
|
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
@@ -259,7 +326,8 @@ function useOverlayLogic(props) {
|
|
|
259
326
|
handleOverlayBubbleCancel
|
|
260
327
|
};
|
|
261
328
|
}
|
|
262
|
-
|
|
329
|
+
var fixedOverlay = "";
|
|
330
|
+
defineComponent({
|
|
263
331
|
name: "DFixedOverlay",
|
|
264
332
|
props: fixedOverlayProps,
|
|
265
333
|
emits: overlayEmits,
|
|
@@ -269,9 +337,9 @@ const FixedOverlay = defineComponent({
|
|
|
269
337
|
overlayClass,
|
|
270
338
|
handleBackdropClick,
|
|
271
339
|
handleOverlayBubbleCancel
|
|
272
|
-
} = useOverlayLogic(props);
|
|
340
|
+
} = useOverlayLogic(props, ctx);
|
|
273
341
|
return () => createVNode(CommonOverlay, null, {
|
|
274
|
-
default: () => [
|
|
342
|
+
default: () => [props.visible && createVNode("div", {
|
|
275
343
|
"class": backgroundClass.value,
|
|
276
344
|
"style": props.backgroundStyle,
|
|
277
345
|
"onClick": handleBackdropClick
|
|
@@ -279,252 +347,347 @@ const FixedOverlay = defineComponent({
|
|
|
279
347
|
"class": overlayClass.value,
|
|
280
348
|
"style": props.overlayStyle,
|
|
281
349
|
"onClick": handleOverlayBubbleCancel
|
|
282
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
const FlexibleOverlay = defineComponent({
|
|
287
|
-
name: "DFlexibleOverlay",
|
|
288
|
-
props: flexibleOverlayProps,
|
|
289
|
-
emits: overlayEmits,
|
|
290
|
-
setup(props, ctx) {
|
|
291
|
-
const overlayRef = ref(null);
|
|
292
|
-
const positionedStyle = reactive({
|
|
293
|
-
position: "absolute"
|
|
294
|
-
});
|
|
295
|
-
onMounted(async () => {
|
|
296
|
-
const handleRectChange = (position, rect, origin) => {
|
|
297
|
-
const point = calculatePosition(position, rect, origin);
|
|
298
|
-
positionedStyle.left = `${point.x}px`;
|
|
299
|
-
positionedStyle.top = `${point.y}px`;
|
|
300
|
-
};
|
|
301
|
-
const locationElements = computed(() => {
|
|
302
|
-
const overlay2 = overlayRef.value;
|
|
303
|
-
const origin = getOrigin(props.origin);
|
|
304
|
-
if (!overlay2 || !origin) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
return {
|
|
308
|
-
origin,
|
|
309
|
-
overlay: overlay2
|
|
310
|
-
};
|
|
311
|
-
});
|
|
312
|
-
const visibleRef = toRef(props, "visible");
|
|
313
|
-
const positionRef = toRef(props, "position");
|
|
314
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
315
|
-
if (!visible || !locationElements2) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const {
|
|
319
|
-
origin,
|
|
320
|
-
overlay: overlay2
|
|
321
|
-
} = locationElements2;
|
|
322
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
323
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
324
|
-
onInvalidate(() => {
|
|
325
|
-
unsubscriptions.forEach((fn) => fn());
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
const {
|
|
330
|
-
backgroundClass,
|
|
331
|
-
overlayClass,
|
|
332
|
-
handleBackdropClick,
|
|
333
|
-
handleOverlayBubbleCancel
|
|
334
|
-
} = useOverlayLogic(props);
|
|
335
|
-
return () => createVNode(CommonOverlay, null, {
|
|
336
|
-
default: () => [withDirectives(createVNode("div", {
|
|
337
|
-
"style": props.backgroundStyle,
|
|
338
|
-
"class": backgroundClass.value,
|
|
339
|
-
"onClick": handleBackdropClick
|
|
340
|
-
}, [createVNode("div", {
|
|
341
|
-
"ref": overlayRef,
|
|
342
|
-
"class": overlayClass.value,
|
|
343
|
-
"style": positionedStyle,
|
|
344
|
-
"onClick": handleOverlayBubbleCancel
|
|
345
|
-
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
350
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
346
351
|
});
|
|
347
352
|
}
|
|
348
353
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
height,
|
|
378
|
-
width
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function getOverlayPoint(originPoint, rect, position) {
|
|
382
|
-
let x;
|
|
383
|
-
const {
|
|
384
|
-
width,
|
|
385
|
-
height
|
|
386
|
-
} = rect;
|
|
387
|
-
if (position.overlayX == "center") {
|
|
388
|
-
x = originPoint.x - width / 2;
|
|
389
|
-
} else {
|
|
390
|
-
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
354
|
+
const flexibleOverlayProps = {
|
|
355
|
+
modelValue: {
|
|
356
|
+
type: Boolean,
|
|
357
|
+
default: false
|
|
358
|
+
},
|
|
359
|
+
origin: {
|
|
360
|
+
type: Object,
|
|
361
|
+
require: true
|
|
362
|
+
},
|
|
363
|
+
position: {
|
|
364
|
+
type: Array,
|
|
365
|
+
default: ["bottom"]
|
|
366
|
+
},
|
|
367
|
+
offset: {
|
|
368
|
+
type: [Number, Object],
|
|
369
|
+
default: 8
|
|
370
|
+
},
|
|
371
|
+
align: {
|
|
372
|
+
type: String,
|
|
373
|
+
default: null
|
|
374
|
+
},
|
|
375
|
+
showArrow: {
|
|
376
|
+
type: Boolean,
|
|
377
|
+
default: false
|
|
378
|
+
},
|
|
379
|
+
isArrowCenter: {
|
|
380
|
+
type: Boolean,
|
|
381
|
+
default: true
|
|
391
382
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
383
|
+
};
|
|
384
|
+
function getScrollParent(element) {
|
|
385
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
386
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
387
|
+
const style = window.getComputedStyle(parent);
|
|
388
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
389
|
+
return parent;
|
|
390
|
+
}
|
|
397
391
|
}
|
|
398
|
-
return
|
|
399
|
-
x,
|
|
400
|
-
y
|
|
401
|
-
};
|
|
392
|
+
return window;
|
|
402
393
|
}
|
|
403
|
-
function
|
|
404
|
-
let x;
|
|
405
|
-
if (
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
x
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
y
|
|
394
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
395
|
+
let { x, y } = point;
|
|
396
|
+
if (!isArrowCenter) {
|
|
397
|
+
const { width, height } = originRect;
|
|
398
|
+
if (x && placement.includes("start")) {
|
|
399
|
+
x = 12;
|
|
400
|
+
}
|
|
401
|
+
if (x && placement.includes("end")) {
|
|
402
|
+
x = Math.round(width - 24);
|
|
403
|
+
}
|
|
404
|
+
if (y && placement.includes("start")) {
|
|
405
|
+
y = 10;
|
|
406
|
+
}
|
|
407
|
+
if (y && placement.includes("end")) {
|
|
408
|
+
y = height - 14;
|
|
409
|
+
}
|
|
417
410
|
}
|
|
418
|
-
return {
|
|
419
|
-
x,
|
|
420
|
-
y
|
|
421
|
-
};
|
|
411
|
+
return { x, y };
|
|
422
412
|
}
|
|
423
|
-
function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
413
|
+
function useOverlay(props, emit) {
|
|
414
|
+
const overlayRef = ref();
|
|
415
|
+
const arrowRef = ref();
|
|
416
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
417
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
418
|
+
const staticSide = {
|
|
419
|
+
top: "bottom",
|
|
420
|
+
right: "left",
|
|
421
|
+
bottom: "top",
|
|
422
|
+
left: "right"
|
|
423
|
+
}[placement.split("-")[0]];
|
|
424
|
+
Object.assign(arrowEl.style, {
|
|
425
|
+
left: x ? `${x}px` : "",
|
|
426
|
+
top: y ? `${y}px` : "",
|
|
427
|
+
right: "",
|
|
428
|
+
bottom: "",
|
|
429
|
+
[staticSide]: "-4px"
|
|
430
|
+
});
|
|
431
431
|
};
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
432
|
+
const updatePosition = async () => {
|
|
433
|
+
const hostEl = props.origin;
|
|
434
|
+
const overlayEl = unref(overlayRef.value);
|
|
435
|
+
const arrowEl = unref(arrowRef.value);
|
|
436
|
+
const middleware = [
|
|
437
|
+
shift(),
|
|
438
|
+
offset(props.offset),
|
|
439
|
+
autoPlacement({
|
|
440
|
+
alignment: props.align,
|
|
441
|
+
allowedPlacements: props.position
|
|
442
|
+
})
|
|
443
|
+
];
|
|
444
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
445
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
446
|
+
strategy: "fixed",
|
|
447
|
+
middleware
|
|
448
|
+
});
|
|
449
|
+
emit("positionChange", placement);
|
|
450
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
451
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
440
452
|
};
|
|
453
|
+
watch(() => props.modelValue, () => {
|
|
454
|
+
const originParent = getScrollParent(props.origin);
|
|
455
|
+
if (props.modelValue && props.origin) {
|
|
456
|
+
nextTick(updatePosition);
|
|
457
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
458
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
459
|
+
window.addEventListener("resize", updatePosition);
|
|
460
|
+
} else {
|
|
461
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
462
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
463
|
+
window.removeEventListener("resize", updatePosition);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
onUnmounted(() => {
|
|
467
|
+
const originParent = getScrollParent(props.origin);
|
|
468
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
469
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
470
|
+
window.removeEventListener("resize", updatePosition);
|
|
471
|
+
});
|
|
472
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
441
473
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
474
|
+
var flexibleOverlay = "";
|
|
475
|
+
const FlexibleOverlay = defineComponent({
|
|
476
|
+
name: "DFlexibleOverlay",
|
|
477
|
+
inheritAttrs: false,
|
|
478
|
+
props: flexibleOverlayProps,
|
|
479
|
+
emits: ["update:modelValue", "positionChange"],
|
|
480
|
+
setup(props, {
|
|
481
|
+
slots,
|
|
482
|
+
attrs,
|
|
483
|
+
emit,
|
|
484
|
+
expose
|
|
485
|
+
}) {
|
|
486
|
+
const {
|
|
487
|
+
arrowRef,
|
|
488
|
+
overlayRef,
|
|
489
|
+
updatePosition
|
|
490
|
+
} = useOverlay(props, emit);
|
|
491
|
+
expose({
|
|
492
|
+
updatePosition
|
|
447
493
|
});
|
|
448
|
-
return () =>
|
|
494
|
+
return () => {
|
|
495
|
+
var _a;
|
|
496
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
497
|
+
"ref": overlayRef,
|
|
498
|
+
"class": "devui-flexible-overlay"
|
|
499
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
500
|
+
"ref": arrowRef,
|
|
501
|
+
"class": "devui-flexible-overlay-arrow"
|
|
502
|
+
}, null)]);
|
|
503
|
+
};
|
|
449
504
|
}
|
|
450
|
-
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
FlexibleOverlay.install = function(app) {
|
|
454
|
-
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
455
|
-
};
|
|
456
|
-
FixedOverlay.install = function(app) {
|
|
457
|
-
app.component(FixedOverlay.name, FixedOverlay);
|
|
458
|
-
};
|
|
505
|
+
});
|
|
459
506
|
var dropdown = "";
|
|
507
|
+
let dropdownId = 1;
|
|
460
508
|
var Dropdown = defineComponent({
|
|
461
509
|
name: "DDropdown",
|
|
510
|
+
inheritAttrs: false,
|
|
462
511
|
props: dropdownProps,
|
|
463
|
-
emits: [],
|
|
464
|
-
setup(props,
|
|
512
|
+
emits: ["toggle"],
|
|
513
|
+
setup(props, {
|
|
514
|
+
slots,
|
|
515
|
+
attrs,
|
|
516
|
+
emit,
|
|
517
|
+
expose
|
|
518
|
+
}) {
|
|
465
519
|
const {
|
|
520
|
+
visible,
|
|
521
|
+
position,
|
|
522
|
+
align,
|
|
523
|
+
offset: offset2,
|
|
524
|
+
showAnimation
|
|
525
|
+
} = toRefs(props);
|
|
526
|
+
const origin = ref();
|
|
527
|
+
const dropdownRef = ref();
|
|
528
|
+
const overlayRef = ref();
|
|
529
|
+
const id = `dropdown_${dropdownId++}`;
|
|
530
|
+
const isOpen = ref(false);
|
|
531
|
+
const currentPosition = ref("bottom");
|
|
532
|
+
useDropdownEvent({
|
|
533
|
+
id,
|
|
466
534
|
isOpen,
|
|
467
535
|
origin,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
} = toRefs(props);
|
|
472
|
-
const visible = ref(false);
|
|
473
|
-
watch(isOpen, (value) => {
|
|
474
|
-
visible.value = value;
|
|
475
|
-
}, {
|
|
476
|
-
immediate: true
|
|
536
|
+
dropdownRef,
|
|
537
|
+
props,
|
|
538
|
+
emit
|
|
477
539
|
});
|
|
478
|
-
|
|
479
|
-
originX: "center",
|
|
480
|
-
originY: "bottom",
|
|
481
|
-
overlayX: "center",
|
|
482
|
-
overlayY: "top"
|
|
483
|
-
};
|
|
540
|
+
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
484
541
|
const {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const animatedVisible = computed(() => {
|
|
494
|
-
return props.showAnimation ? visible.value : true;
|
|
542
|
+
overlayModelValue,
|
|
543
|
+
overlayShowValue,
|
|
544
|
+
styles,
|
|
545
|
+
classes,
|
|
546
|
+
handlePositionChange
|
|
547
|
+
} = useOverlayProps(props, currentPosition, isOpen);
|
|
548
|
+
expose({
|
|
549
|
+
updatePosition: () => overlayRef.value.updatePosition()
|
|
495
550
|
});
|
|
496
551
|
return () => {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
"
|
|
500
|
-
"
|
|
501
|
-
|
|
502
|
-
"
|
|
552
|
+
var _a;
|
|
553
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
554
|
+
"ref": origin,
|
|
555
|
+
"class": "devui-dropdown-toggle"
|
|
556
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
557
|
+
"to": "body"
|
|
503
558
|
}, {
|
|
504
559
|
default: () => [createVNode(Transition, {
|
|
505
|
-
"name":
|
|
560
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
506
561
|
}, {
|
|
507
|
-
default: () => {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
562
|
+
default: () => [withDirectives(createVNode(FlexibleOverlay, {
|
|
563
|
+
"modelValue": overlayModelValue.value,
|
|
564
|
+
"onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
|
|
565
|
+
"ref": overlayRef,
|
|
566
|
+
"origin": origin.value,
|
|
567
|
+
"position": position.value,
|
|
568
|
+
"align": align.value,
|
|
569
|
+
"offset": offset2.value,
|
|
570
|
+
"onPositionChange": handlePositionChange,
|
|
571
|
+
"class": classes.value,
|
|
572
|
+
"style": styles.value
|
|
573
|
+
}, {
|
|
574
|
+
default: () => {
|
|
575
|
+
var _a2;
|
|
576
|
+
return [createVNode("div", mergeProps({
|
|
577
|
+
"ref": dropdownRef,
|
|
578
|
+
"class": "devui-dropdown-menu-wrap"
|
|
579
|
+
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
580
|
+
}
|
|
581
|
+
}), [[vShow, overlayShowValue.value]])]
|
|
514
582
|
})]
|
|
515
583
|
})]);
|
|
516
584
|
};
|
|
517
585
|
}
|
|
518
586
|
});
|
|
519
|
-
|
|
520
|
-
|
|
587
|
+
const dropdownMenuProps = {
|
|
588
|
+
modelValue: {
|
|
589
|
+
type: Boolean,
|
|
590
|
+
default: false
|
|
591
|
+
},
|
|
592
|
+
origin: {
|
|
593
|
+
type: Object,
|
|
594
|
+
require: true
|
|
595
|
+
},
|
|
596
|
+
position: {
|
|
597
|
+
type: Array,
|
|
598
|
+
default: ["bottom"]
|
|
599
|
+
},
|
|
600
|
+
align: {
|
|
601
|
+
type: String,
|
|
602
|
+
default: null
|
|
603
|
+
},
|
|
604
|
+
offset: {
|
|
605
|
+
type: [Number, Object],
|
|
606
|
+
default: 4
|
|
607
|
+
},
|
|
608
|
+
clickOutside: {
|
|
609
|
+
type: Function,
|
|
610
|
+
default: () => true
|
|
611
|
+
},
|
|
612
|
+
showAnimation: {
|
|
613
|
+
type: Boolean,
|
|
614
|
+
default: true
|
|
615
|
+
},
|
|
616
|
+
overlayClass: {
|
|
617
|
+
type: String,
|
|
618
|
+
default: ""
|
|
619
|
+
}
|
|
521
620
|
};
|
|
621
|
+
var DropdownMenu = defineComponent({
|
|
622
|
+
name: "DDropdownMenu",
|
|
623
|
+
inheritAttrs: false,
|
|
624
|
+
props: dropdownMenuProps,
|
|
625
|
+
emits: ["update:modelValue"],
|
|
626
|
+
setup(props, {
|
|
627
|
+
slots,
|
|
628
|
+
attrs,
|
|
629
|
+
emit
|
|
630
|
+
}) {
|
|
631
|
+
const {
|
|
632
|
+
modelValue,
|
|
633
|
+
origin,
|
|
634
|
+
position,
|
|
635
|
+
align,
|
|
636
|
+
offset: offset2,
|
|
637
|
+
clickOutside,
|
|
638
|
+
showAnimation,
|
|
639
|
+
overlayClass
|
|
640
|
+
} = toRefs(props);
|
|
641
|
+
const dropdownMenuRef = ref(null);
|
|
642
|
+
onClickOutside(dropdownMenuRef, (value) => {
|
|
643
|
+
var _a, _b;
|
|
644
|
+
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
|
|
645
|
+
emit("update:modelValue", false);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
const currentPosition = ref("bottom");
|
|
649
|
+
const handlePositionChange = (pos) => {
|
|
650
|
+
currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
|
|
651
|
+
};
|
|
652
|
+
const styles = computed(() => ({
|
|
653
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
654
|
+
}));
|
|
655
|
+
return () => createVNode(Teleport, {
|
|
656
|
+
"to": "body"
|
|
657
|
+
}, {
|
|
658
|
+
default: () => [createVNode(Transition, {
|
|
659
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
660
|
+
}, {
|
|
661
|
+
default: () => [createVNode(FlexibleOverlay, {
|
|
662
|
+
"modelValue": modelValue.value,
|
|
663
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
664
|
+
"origin": origin == null ? void 0 : origin.value,
|
|
665
|
+
"position": position.value,
|
|
666
|
+
"align": align.value,
|
|
667
|
+
"offset": offset2.value,
|
|
668
|
+
"onPositionChange": handlePositionChange,
|
|
669
|
+
"class": overlayClass.value,
|
|
670
|
+
"style": styles.value
|
|
671
|
+
}, {
|
|
672
|
+
default: () => {
|
|
673
|
+
var _a;
|
|
674
|
+
return [createVNode("div", mergeProps({
|
|
675
|
+
"ref": dropdownMenuRef,
|
|
676
|
+
"class": "devui-dropdown-menu-wrap"
|
|
677
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
678
|
+
}
|
|
679
|
+
})]
|
|
680
|
+
})]
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
});
|
|
522
684
|
var index = {
|
|
523
685
|
title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
|
|
524
686
|
category: "\u5BFC\u822A",
|
|
525
687
|
status: "10%",
|
|
526
688
|
install(app) {
|
|
527
|
-
app.
|
|
689
|
+
app.component(Dropdown.name, Dropdown);
|
|
690
|
+
app.component(DropdownMenu.name, DropdownMenu);
|
|
528
691
|
}
|
|
529
692
|
};
|
|
530
|
-
export { Dropdown, index as default };
|
|
693
|
+
export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };
|