vue-devui 1.0.0-rc.0 → 1.0.0-rc.3
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 +55 -113
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.es.js +143 -103
- package/auto-complete/index.umd.js +5 -1
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +77 -81
- package/avatar/index.umd.js +1 -1
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +43 -43
- package/button/index.umd.js +1 -1
- package/card/index.es.js +3 -6
- package/card/index.umd.js +1 -1
- package/checkbox/index.es.js +5 -11
- package/checkbox/index.umd.js +1 -1
- package/comment/index.es.js +2 -5
- package/comment/index.umd.js +1 -1
- package/countdown/index.es.js +5 -7
- package/countdown/index.umd.js +1 -1
- package/editable-select/index.es.js +124 -168
- package/editable-select/index.umd.js +1 -1
- package/fullscreen/index.es.js +13 -16
- package/fullscreen/index.umd.js +1 -1
- package/grid/index.es.js +30 -36
- package/grid/index.umd.js +1 -1
- package/icon/index.es.js +39 -57
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +21 -20
- package/image-preview/index.umd.js +1 -1
- package/input/index.es.js +2 -5
- package/input/index.umd.js +1 -1
- package/layout/index.es.js +6 -21
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +20 -12
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +135 -122
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +38 -40
- package/notification/index.umd.js +1 -1
- package/nuxt/components/DropdownPropsKey.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/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/commentProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/readTipProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tagInputProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/overlay/index.es.js +49 -42
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -43
- package/pagination/index.es.js +24 -25
- package/pagination/index.umd.js +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +51 -44
- package/popover/index.umd.js +12 -12
- package/popover/style.css +1 -1
- package/progress/index.es.js +34 -36
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +11 -11
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +4 -7
- package/rate/index.umd.js +1 -1
- package/read-tip/index.es.js +8 -8
- package/read-tip/index.umd.js +1 -1
- package/result/index.es.js +40 -58
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +47 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +13 -16
- package/search/index.umd.js +8 -8
- package/skeleton/index.es.js +20 -23
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +60 -59
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +223 -171
- package/splitter/index.umd.js +13 -13
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +7 -18
- package/statistic/index.umd.js +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +3 -6
- package/switch/index.umd.js +1 -1
- package/tag/index.es.js +15 -18
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +7 -8
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.es.js +2 -5
- package/textarea/index.umd.js +1 -1
- package/{accordion → timeline}/index.d.ts +0 -0
- package/{time-axis → timeline}/index.es.js +64 -83
- package/timeline/index.umd.js +1 -0
- package/{anchor → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/upload/index.es.js +98 -97
- package/upload/index.umd.js +1 -1
- package/vue-devui.es.js +12477 -24991
- package/vue-devui.umd.js +24 -20
- package/accordion/index.es.js +0 -720
- package/accordion/index.umd.js +0 -1
- package/accordion/package.json +0 -7
- package/accordion/style.css +0 -1
- package/anchor/index.d.ts +0 -7
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -128
- package/back-top/index.umd.js +0 -1
- package/back-top/package.json +0 -7
- package/back-top/style.css +0 -1
- package/breadcrumb/index.d.ts +0 -7
- package/breadcrumb/index.es.js +0 -127
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/package.json +0 -7
- package/breadcrumb/style.css +0 -1
- package/carousel/index.d.ts +0 -7
- package/carousel/index.es.js +0 -329
- package/carousel/index.umd.js +0 -1
- package/carousel/package.json +0 -7
- package/carousel/style.css +0 -1
- package/cascader/index.d.ts +0 -7
- package/cascader/index.es.js +0 -5963
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.d.ts +0 -7
- package/color-picker/index.es.js +0 -8187
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/date-picker/index.d.ts +0 -7
- package/date-picker/index.es.js +0 -1171
- package/date-picker/index.umd.js +0 -1
- package/date-picker/package.json +0 -7
- package/date-picker/style.css +0 -1
- package/dragdrop/index.d.ts +0 -7
- package/dragdrop/index.es.js +0 -157
- package/dragdrop/index.umd.js +0 -1
- package/dragdrop/package.json +0 -7
- package/drawer/index.d.ts +0 -7
- package/drawer/index.es.js +0 -234
- package/drawer/index.umd.js +0 -1
- package/drawer/package.json +0 -7
- package/drawer/style.css +0 -1
- package/dropdown/index.d.ts +0 -7
- package/dropdown/index.es.js +0 -638
- package/dropdown/index.umd.js +0 -1
- package/dropdown/package.json +0 -7
- package/dropdown/style.css +0 -1
- package/form/index.d.ts +0 -7
- package/form/index.es.js +0 -7865
- package/form/index.umd.js +0 -27
- package/form/package.json +0 -7
- package/form/style.css +0 -1
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/package.json +0 -7
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -331
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/input-number/index.d.ts +0 -7
- package/input-number/index.es.js +0 -240
- package/input-number/index.umd.js +0 -1
- package/input-number/package.json +0 -7
- package/input-number/style.css +0 -1
- package/list/index.d.ts +0 -7
- package/list/index.es.js +0 -39
- package/list/index.umd.js +0 -1
- package/list/package.json +0 -7
- package/list/style.css +0 -1
- package/nav-sprite/index.d.ts +0 -7
- package/nav-sprite/index.es.js +0 -68
- package/nav-sprite/index.umd.js +0 -1
- package/nav-sprite/package.json +0 -7
- package/nuxt/components/Accordion.js +0 -3
- package/nuxt/components/Anchor.js +0 -3
- package/nuxt/components/BackTop.js +0 -3
- package/nuxt/components/Breadcrumb.js +0 -3
- package/nuxt/components/Carousel.js +0 -3
- package/nuxt/components/CarouselItem.js +0 -3
- package/nuxt/components/Cascader.js +0 -3
- package/nuxt/components/ColorPicker.js +0 -3
- package/nuxt/components/Column.js +0 -3
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/Drawer.js +0 -3
- package/nuxt/components/DrawerService.js +0 -3
- package/nuxt/components/Dropdown.js +0 -3
- package/nuxt/components/DropdownMenu.js +0 -3
- package/nuxt/components/Form.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormItem.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/FormOperation.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/InputNumber.js +0 -3
- package/nuxt/components/List.js +0 -3
- package/nuxt/components/ListItem.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/Select.js +0 -3
- package/nuxt/components/StepsGuide.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/Sticky.js +0 -2
- package/nuxt/components/Table.js +0 -3
- package/nuxt/components/Tabs.js +0 -3
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/TimePicker.js +0 -3
- package/nuxt/components/Tooltip.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/Tree.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/nuxt/components/dropdownMenuProps.js +0 -3
- package/nuxt/components/tooltipProps.js +0 -3
- package/quadrant-diagram/index.d.ts +0 -7
- package/quadrant-diagram/index.es.js +0 -5728
- package/quadrant-diagram/index.umd.js +0 -27
- package/quadrant-diagram/package.json +0 -7
- package/quadrant-diagram/style.css +0 -1
- package/select/index.d.ts +0 -7
- package/select/index.es.js +0 -706
- package/select/index.umd.js +0 -1
- package/select/package.json +0 -7
- package/select/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -239
- package/steps-guide/index.umd.js +0 -1
- package/steps-guide/package.json +0 -7
- package/steps-guide/style.css +0 -1
- package/sticky/index.d.ts +0 -7
- package/sticky/index.es.js +0 -197
- package/sticky/index.umd.js +0 -1
- package/sticky/package.json +0 -7
- package/table/index.d.ts +0 -7
- package/table/index.es.js +0 -1969
- package/table/index.umd.js +0 -1
- package/table/package.json +0 -7
- package/table/style.css +0 -1
- package/tabs/index.d.ts +0 -7
- package/tabs/index.es.js +0 -194
- package/tabs/index.umd.js +0 -1
- package/tabs/package.json +0 -7
- package/tabs/style.css +0 -1
- package/time-axis/index.d.ts +0 -7
- package/time-axis/index.umd.js +0 -1
- package/time-axis/package.json +0 -7
- package/time-axis/style.css +0 -1
- package/time-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1237
- package/time-picker/index.umd.js +0 -1
- package/time-picker/package.json +0 -7
- package/time-picker/style.css +0 -1
- package/tooltip/index.d.ts +0 -7
- package/tooltip/index.es.js +0 -5828
- package/tooltip/index.umd.js +0 -27
- package/tooltip/package.json +0 -7
- package/tooltip/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.es.js +0 -7608
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree/index.d.ts +0 -7
- package/tree/index.es.js +0 -6490
- package/tree/index.umd.js +0 -27
- package/tree/package.json +0 -7
- package/tree/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -623
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
package/dropdown/index.es.js
DELETED
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { toRefs, watch, onMounted, onUnmounted, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, ref, nextTick, unref, mergeProps, Fragment } from "vue";
|
|
21
|
-
import { offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
22
|
-
import { onClickOutside } from "@vueuse/core";
|
|
23
|
-
const dropdownProps = {
|
|
24
|
-
visible: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: false
|
|
27
|
-
},
|
|
28
|
-
trigger: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: "click"
|
|
31
|
-
},
|
|
32
|
-
closeScope: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: "all"
|
|
35
|
-
},
|
|
36
|
-
position: {
|
|
37
|
-
type: Array,
|
|
38
|
-
default: ["bottom"]
|
|
39
|
-
},
|
|
40
|
-
align: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: null
|
|
43
|
-
},
|
|
44
|
-
offset: {
|
|
45
|
-
type: [Number, Object],
|
|
46
|
-
default: 4
|
|
47
|
-
},
|
|
48
|
-
closeOnMouseLeaveMenu: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
function getElement(element) {
|
|
54
|
-
if (element instanceof Element) {
|
|
55
|
-
return element;
|
|
56
|
-
}
|
|
57
|
-
if (element && typeof element === "object" && element.$el instanceof Element) {
|
|
58
|
-
return element.$el;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const dropdownMap = /* @__PURE__ */ new Map();
|
|
63
|
-
function subscribeEvent(dom, type, callback) {
|
|
64
|
-
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
65
|
-
return () => {
|
|
66
|
-
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
70
|
-
let overlayEnter = false;
|
|
71
|
-
let originEnter = false;
|
|
72
|
-
const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
|
|
73
|
-
const toggle = (status) => {
|
|
74
|
-
isOpen.value = status;
|
|
75
|
-
emit("toggle", isOpen.value);
|
|
76
|
-
};
|
|
77
|
-
const handleLeave = async (elementType, e) => {
|
|
78
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
79
|
-
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (e) {
|
|
83
|
-
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
var _a;
|
|
86
|
-
(_a = item.toggle) == null ? void 0 : _a.call(item);
|
|
87
|
-
}, 0);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
toggle(false);
|
|
91
|
-
};
|
|
92
|
-
watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
|
|
93
|
-
const originEl = getElement(originVal);
|
|
94
|
-
const subscriptions = [];
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
97
|
-
const dropdownValues = [...dropdownMap.values()];
|
|
98
|
-
if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
99
|
-
var _a;
|
|
100
|
-
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
101
|
-
}) && dropdownValues.some((item) => {
|
|
102
|
-
var _a;
|
|
103
|
-
return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
|
|
104
|
-
})) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
var _a, _b;
|
|
110
|
-
if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
|
|
111
|
-
(_b = item.toggle) == null ? void 0 : _b.call(item);
|
|
112
|
-
}
|
|
113
|
-
}, 0);
|
|
114
|
-
});
|
|
115
|
-
overlayEnter = false;
|
|
116
|
-
}));
|
|
117
|
-
}, 0);
|
|
118
|
-
if (triggerVal === "click") {
|
|
119
|
-
subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
120
|
-
var _a;
|
|
121
|
-
if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
122
|
-
handleLeave("dropdown", e);
|
|
123
|
-
}
|
|
124
|
-
}));
|
|
125
|
-
} else if (triggerVal === "hover") {
|
|
126
|
-
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
127
|
-
originEnter = true;
|
|
128
|
-
toggle(true);
|
|
129
|
-
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
130
|
-
originEnter = false;
|
|
131
|
-
handleLeave("origin");
|
|
132
|
-
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
133
|
-
overlayEnter = true;
|
|
134
|
-
isOpen.value = true;
|
|
135
|
-
}), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
136
|
-
var _a;
|
|
137
|
-
overlayEnter = false;
|
|
138
|
-
if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
handleLeave("dropdown", e);
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
|
|
148
|
-
const calcPopDirection = (dropdownEl) => {
|
|
149
|
-
const elementHeight = dropdownEl.offsetHeight;
|
|
150
|
-
const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
|
|
151
|
-
const isBottomEnough = bottomDistance >= elementHeight;
|
|
152
|
-
if (!isBottomEnough) {
|
|
153
|
-
popDirection.value = "top";
|
|
154
|
-
} else {
|
|
155
|
-
popDirection.value = "bottom";
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
watch(visible, (newVal, oldVal) => {
|
|
159
|
-
if (oldVal === void 0) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
isOpen.value = newVal;
|
|
163
|
-
emit("toggle", isOpen.value);
|
|
164
|
-
}, { immediate: true });
|
|
165
|
-
watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
|
|
166
|
-
var _a;
|
|
167
|
-
if (isOpenVal) {
|
|
168
|
-
dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
|
|
169
|
-
menuEl: dropdownEl,
|
|
170
|
-
toggle: () => {
|
|
171
|
-
isOpen.value = false;
|
|
172
|
-
emit("toggle", isOpen.value);
|
|
173
|
-
}
|
|
174
|
-
}));
|
|
175
|
-
for (const value of dropdownMap.values()) {
|
|
176
|
-
if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
|
|
177
|
-
value.child = dropdownEl;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (dropdownEl) {
|
|
182
|
-
calcPopDirection(dropdownEl);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
onMounted(() => {
|
|
186
|
-
dropdownMap.set(id, { toggleEl: origin.value });
|
|
187
|
-
});
|
|
188
|
-
onUnmounted(() => {
|
|
189
|
-
dropdownMap.delete(id);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
var overlay = "";
|
|
193
|
-
function _isSlot(s) {
|
|
194
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
195
|
-
}
|
|
196
|
-
const CommonOverlay = defineComponent({
|
|
197
|
-
setup(props, ctx) {
|
|
198
|
-
return () => {
|
|
199
|
-
let _slot;
|
|
200
|
-
return createVNode(Teleport, {
|
|
201
|
-
"to": "#d-overlay-anchor"
|
|
202
|
-
}, {
|
|
203
|
-
default: () => [createVNode(Transition, {
|
|
204
|
-
"name": "devui-overlay-fade"
|
|
205
|
-
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
206
|
-
default: () => [_slot]
|
|
207
|
-
})]
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
const overlayProps = {
|
|
213
|
-
visible: {
|
|
214
|
-
type: Boolean
|
|
215
|
-
},
|
|
216
|
-
backgroundBlock: {
|
|
217
|
-
type: Boolean,
|
|
218
|
-
default: false
|
|
219
|
-
},
|
|
220
|
-
backgroundClass: {
|
|
221
|
-
type: String,
|
|
222
|
-
default: ""
|
|
223
|
-
},
|
|
224
|
-
backgroundStyle: {
|
|
225
|
-
type: [String, Object]
|
|
226
|
-
},
|
|
227
|
-
onBackdropClick: {
|
|
228
|
-
type: Function
|
|
229
|
-
},
|
|
230
|
-
backdropClose: {
|
|
231
|
-
type: Boolean,
|
|
232
|
-
default: true
|
|
233
|
-
},
|
|
234
|
-
hasBackdrop: {
|
|
235
|
-
type: Boolean,
|
|
236
|
-
default: true
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
240
|
-
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
241
|
-
overlayStyle: {
|
|
242
|
-
type: [String, Object],
|
|
243
|
-
default: void 0
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
const flexibleOverlayProps = {
|
|
247
|
-
modelValue: {
|
|
248
|
-
type: Boolean,
|
|
249
|
-
default: false
|
|
250
|
-
},
|
|
251
|
-
origin: {
|
|
252
|
-
type: Object,
|
|
253
|
-
require: true
|
|
254
|
-
},
|
|
255
|
-
position: {
|
|
256
|
-
type: Array,
|
|
257
|
-
default: ["bottom"]
|
|
258
|
-
},
|
|
259
|
-
offset: {
|
|
260
|
-
type: [Number, Object],
|
|
261
|
-
default: 8
|
|
262
|
-
},
|
|
263
|
-
align: {
|
|
264
|
-
type: String,
|
|
265
|
-
default: null
|
|
266
|
-
},
|
|
267
|
-
showArrow: {
|
|
268
|
-
type: Boolean,
|
|
269
|
-
default: false
|
|
270
|
-
},
|
|
271
|
-
isArrowCenter: {
|
|
272
|
-
type: Boolean,
|
|
273
|
-
default: true
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
function useOverlayLogic(props, ctx) {
|
|
277
|
-
const backgroundClass = computed(() => {
|
|
278
|
-
return [
|
|
279
|
-
"devui-overlay-background",
|
|
280
|
-
props.backgroundClass,
|
|
281
|
-
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
282
|
-
];
|
|
283
|
-
});
|
|
284
|
-
const overlayClass = computed(() => {
|
|
285
|
-
return "devui-overlay";
|
|
286
|
-
});
|
|
287
|
-
const handleBackdropClick = (event) => {
|
|
288
|
-
var _a;
|
|
289
|
-
event.preventDefault();
|
|
290
|
-
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
291
|
-
if (props.backdropClose) {
|
|
292
|
-
ctx.emit("update:visible", false);
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
296
|
-
onMounted(() => {
|
|
297
|
-
const body = document.body;
|
|
298
|
-
const originOverflow = body.style.overflow;
|
|
299
|
-
const originPosition = body.style.position;
|
|
300
|
-
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
301
|
-
if (backgroundBlock) {
|
|
302
|
-
const top = body.getBoundingClientRect().y;
|
|
303
|
-
if (visible) {
|
|
304
|
-
body.style.overflowY = "scroll";
|
|
305
|
-
body.style.position = visible ? "fixed" : "";
|
|
306
|
-
body.style.top = `${top}px`;
|
|
307
|
-
} else {
|
|
308
|
-
body.style.overflowY = originOverflow;
|
|
309
|
-
body.style.position = originPosition;
|
|
310
|
-
body.style.top = "";
|
|
311
|
-
window.scrollTo(0, -top);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
onUnmounted(() => {
|
|
316
|
-
document.body.style.overflow = originOverflow;
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
return {
|
|
320
|
-
backgroundClass,
|
|
321
|
-
overlayClass,
|
|
322
|
-
handleBackdropClick,
|
|
323
|
-
handleOverlayBubbleCancel
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
defineComponent({
|
|
327
|
-
name: "DFixedOverlay",
|
|
328
|
-
props: fixedOverlayProps,
|
|
329
|
-
emits: overlayEmits,
|
|
330
|
-
setup(props, ctx) {
|
|
331
|
-
const {
|
|
332
|
-
backgroundClass,
|
|
333
|
-
overlayClass,
|
|
334
|
-
handleBackdropClick,
|
|
335
|
-
handleOverlayBubbleCancel
|
|
336
|
-
} = useOverlayLogic(props, ctx);
|
|
337
|
-
return () => createVNode(CommonOverlay, null, {
|
|
338
|
-
default: () => [props.visible && createVNode("div", {
|
|
339
|
-
"class": backgroundClass.value,
|
|
340
|
-
"style": props.backgroundStyle,
|
|
341
|
-
"onClick": handleBackdropClick
|
|
342
|
-
}, [createVNode("div", {
|
|
343
|
-
"class": overlayClass.value,
|
|
344
|
-
"style": props.overlayStyle,
|
|
345
|
-
"onClick": handleOverlayBubbleCancel
|
|
346
|
-
}, [renderSlot(ctx.slots, "default")])])]
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
function getScrollParent(element) {
|
|
351
|
-
const overflowRegex = /(auto|scroll|hidden)/;
|
|
352
|
-
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
353
|
-
const style = window.getComputedStyle(parent);
|
|
354
|
-
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
355
|
-
return parent;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return window;
|
|
359
|
-
}
|
|
360
|
-
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
361
|
-
let { x, y } = point;
|
|
362
|
-
if (!isArrowCenter) {
|
|
363
|
-
const { width, height } = originRect;
|
|
364
|
-
if (x && placement.includes("start")) {
|
|
365
|
-
x = 12;
|
|
366
|
-
}
|
|
367
|
-
if (x && placement.includes("end")) {
|
|
368
|
-
x = Math.round(width - 24);
|
|
369
|
-
}
|
|
370
|
-
if (y && placement.includes("start")) {
|
|
371
|
-
y = 10;
|
|
372
|
-
}
|
|
373
|
-
if (y && placement.includes("end")) {
|
|
374
|
-
y = height - 14;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return { x, y };
|
|
378
|
-
}
|
|
379
|
-
function useOverlay(props, emit) {
|
|
380
|
-
const overlayRef = ref();
|
|
381
|
-
const arrowRef = ref();
|
|
382
|
-
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
383
|
-
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
384
|
-
const staticSide = {
|
|
385
|
-
top: "bottom",
|
|
386
|
-
right: "left",
|
|
387
|
-
bottom: "top",
|
|
388
|
-
left: "right"
|
|
389
|
-
}[placement.split("-")[0]];
|
|
390
|
-
Object.assign(arrowEl.style, {
|
|
391
|
-
left: x ? `${x}px` : "",
|
|
392
|
-
top: y ? `${y}px` : "",
|
|
393
|
-
right: "",
|
|
394
|
-
bottom: "",
|
|
395
|
-
[staticSide]: "-4px"
|
|
396
|
-
});
|
|
397
|
-
};
|
|
398
|
-
const updatePosition = async () => {
|
|
399
|
-
const hostEl = props.origin;
|
|
400
|
-
const overlayEl = unref(overlayRef.value);
|
|
401
|
-
const arrowEl = unref(arrowRef.value);
|
|
402
|
-
const middleware = [
|
|
403
|
-
offset(props.offset),
|
|
404
|
-
autoPlacement({
|
|
405
|
-
alignment: props.align,
|
|
406
|
-
allowedPlacements: props.position
|
|
407
|
-
})
|
|
408
|
-
];
|
|
409
|
-
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
410
|
-
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
411
|
-
strategy: "fixed",
|
|
412
|
-
middleware
|
|
413
|
-
});
|
|
414
|
-
emit("positionChange", placement);
|
|
415
|
-
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
416
|
-
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
417
|
-
};
|
|
418
|
-
watch(() => props.modelValue, () => {
|
|
419
|
-
const originParent = getScrollParent(props.origin);
|
|
420
|
-
if (props.modelValue && props.origin) {
|
|
421
|
-
nextTick(updatePosition);
|
|
422
|
-
originParent.addEventListener("scroll", updatePosition);
|
|
423
|
-
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
424
|
-
window.addEventListener("resize", updatePosition);
|
|
425
|
-
} else {
|
|
426
|
-
originParent.removeEventListener("scroll", updatePosition);
|
|
427
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
428
|
-
window.removeEventListener("resize", updatePosition);
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
onUnmounted(() => {
|
|
432
|
-
const originParent = getScrollParent(props.origin);
|
|
433
|
-
originParent.removeEventListener("scroll", updatePosition);
|
|
434
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
435
|
-
window.removeEventListener("resize", updatePosition);
|
|
436
|
-
});
|
|
437
|
-
return { arrowRef, overlayRef };
|
|
438
|
-
}
|
|
439
|
-
var flexibleOverlay = "";
|
|
440
|
-
const FlexibleOverlay = defineComponent({
|
|
441
|
-
name: "DFlexibleOverlay",
|
|
442
|
-
inheritAttrs: false,
|
|
443
|
-
props: flexibleOverlayProps,
|
|
444
|
-
emits: ["update:modelValue", "positionChange"],
|
|
445
|
-
setup(props, {
|
|
446
|
-
slots,
|
|
447
|
-
attrs,
|
|
448
|
-
emit
|
|
449
|
-
}) {
|
|
450
|
-
const {
|
|
451
|
-
arrowRef,
|
|
452
|
-
overlayRef
|
|
453
|
-
} = useOverlay(props, emit);
|
|
454
|
-
return () => {
|
|
455
|
-
var _a;
|
|
456
|
-
return props.modelValue && createVNode("div", mergeProps({
|
|
457
|
-
"ref": overlayRef,
|
|
458
|
-
"class": "devui-flexible-overlay"
|
|
459
|
-
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
460
|
-
"ref": arrowRef,
|
|
461
|
-
"class": "devui-flexible-overlay-arrow"
|
|
462
|
-
}, null)]);
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
var dropdown = "";
|
|
467
|
-
let dropdownId = 1;
|
|
468
|
-
var Dropdown = defineComponent({
|
|
469
|
-
name: "DDropdown",
|
|
470
|
-
inheritAttrs: false,
|
|
471
|
-
props: dropdownProps,
|
|
472
|
-
emits: ["toggle"],
|
|
473
|
-
setup(props, {
|
|
474
|
-
slots,
|
|
475
|
-
attrs,
|
|
476
|
-
emit
|
|
477
|
-
}) {
|
|
478
|
-
const {
|
|
479
|
-
visible,
|
|
480
|
-
position,
|
|
481
|
-
align,
|
|
482
|
-
offset: offset2
|
|
483
|
-
} = toRefs(props);
|
|
484
|
-
const origin = ref();
|
|
485
|
-
const dropdownRef = ref();
|
|
486
|
-
const id = `dropdown_${dropdownId++}`;
|
|
487
|
-
const isOpen = ref(false);
|
|
488
|
-
const currentPosition = ref("bottom");
|
|
489
|
-
const handlePositionChange = (pos) => {
|
|
490
|
-
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
491
|
-
};
|
|
492
|
-
const styles = computed(() => ({
|
|
493
|
-
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
494
|
-
}));
|
|
495
|
-
const classes = computed(() => ({
|
|
496
|
-
"fade-in-bottom": isOpen.value && currentPosition.value === "bottom",
|
|
497
|
-
"fade-in-top": isOpen.value && currentPosition.value === "top"
|
|
498
|
-
}));
|
|
499
|
-
useDropdownEvent({
|
|
500
|
-
id,
|
|
501
|
-
isOpen,
|
|
502
|
-
origin,
|
|
503
|
-
dropdownRef,
|
|
504
|
-
props,
|
|
505
|
-
emit
|
|
506
|
-
});
|
|
507
|
-
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
508
|
-
return () => {
|
|
509
|
-
var _a;
|
|
510
|
-
return createVNode(Fragment, null, [createVNode("div", {
|
|
511
|
-
"ref": origin,
|
|
512
|
-
"class": "devui-dropdown-toggle"
|
|
513
|
-
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
514
|
-
"to": "body"
|
|
515
|
-
}, {
|
|
516
|
-
default: () => [createVNode(Transition, {
|
|
517
|
-
"name": `devui-dropdown-fade-${currentPosition.value}`
|
|
518
|
-
}, {
|
|
519
|
-
default: () => [createVNode(FlexibleOverlay, {
|
|
520
|
-
"modelValue": isOpen.value,
|
|
521
|
-
"onUpdate:modelValue": ($event) => isOpen.value = $event,
|
|
522
|
-
"origin": origin.value,
|
|
523
|
-
"position": position.value,
|
|
524
|
-
"align": align.value,
|
|
525
|
-
"offset": offset2.value,
|
|
526
|
-
"onPositionChange": handlePositionChange,
|
|
527
|
-
"class": classes.value,
|
|
528
|
-
"style": styles.value
|
|
529
|
-
}, {
|
|
530
|
-
default: () => {
|
|
531
|
-
var _a2;
|
|
532
|
-
return [createVNode("div", mergeProps({
|
|
533
|
-
"ref": dropdownRef,
|
|
534
|
-
"class": "devui-dropdown-menu-wrap"
|
|
535
|
-
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
536
|
-
}
|
|
537
|
-
})]
|
|
538
|
-
})]
|
|
539
|
-
})]);
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
const dropdownMenuProps = {
|
|
544
|
-
modelValue: {
|
|
545
|
-
type: Boolean,
|
|
546
|
-
default: false
|
|
547
|
-
},
|
|
548
|
-
origin: {
|
|
549
|
-
type: Object,
|
|
550
|
-
require: true
|
|
551
|
-
},
|
|
552
|
-
position: {
|
|
553
|
-
type: Array,
|
|
554
|
-
default: ["bottom"]
|
|
555
|
-
},
|
|
556
|
-
align: {
|
|
557
|
-
type: String,
|
|
558
|
-
default: null
|
|
559
|
-
},
|
|
560
|
-
offset: {
|
|
561
|
-
type: [Number, Object],
|
|
562
|
-
default: 4
|
|
563
|
-
},
|
|
564
|
-
clickOutside: {
|
|
565
|
-
type: Function,
|
|
566
|
-
default: () => true
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
var DropdownMenu = defineComponent({
|
|
570
|
-
name: "DDropdownMenu",
|
|
571
|
-
inheritAttrs: false,
|
|
572
|
-
props: dropdownMenuProps,
|
|
573
|
-
emits: ["update:modelValue"],
|
|
574
|
-
setup(props, {
|
|
575
|
-
slots,
|
|
576
|
-
attrs,
|
|
577
|
-
emit
|
|
578
|
-
}) {
|
|
579
|
-
const {
|
|
580
|
-
modelValue,
|
|
581
|
-
origin,
|
|
582
|
-
position,
|
|
583
|
-
align,
|
|
584
|
-
offset: offset2,
|
|
585
|
-
clickOutside
|
|
586
|
-
} = toRefs(props);
|
|
587
|
-
const dropdownMenuRef = ref(null);
|
|
588
|
-
onClickOutside(dropdownMenuRef, (value) => {
|
|
589
|
-
var _a;
|
|
590
|
-
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !origin.value.contains(value.target)) {
|
|
591
|
-
emit("update:modelValue", false);
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
const currentPosition = ref("bottom");
|
|
595
|
-
const handlePositionChange = (pos) => {
|
|
596
|
-
currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
|
|
597
|
-
};
|
|
598
|
-
const styles = computed(() => ({
|
|
599
|
-
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
600
|
-
}));
|
|
601
|
-
return () => createVNode(Teleport, {
|
|
602
|
-
"to": "body"
|
|
603
|
-
}, {
|
|
604
|
-
default: () => [createVNode(Transition, {
|
|
605
|
-
"name": `devui-dropdown-fade-${currentPosition.value}`
|
|
606
|
-
}, {
|
|
607
|
-
default: () => [createVNode(FlexibleOverlay, {
|
|
608
|
-
"modelValue": modelValue.value,
|
|
609
|
-
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
610
|
-
"origin": origin == null ? void 0 : origin.value,
|
|
611
|
-
"position": position.value,
|
|
612
|
-
"align": align.value,
|
|
613
|
-
"offset": offset2.value,
|
|
614
|
-
"onPositionChange": handlePositionChange,
|
|
615
|
-
"style": styles.value
|
|
616
|
-
}, {
|
|
617
|
-
default: () => {
|
|
618
|
-
var _a;
|
|
619
|
-
return [createVNode("div", mergeProps({
|
|
620
|
-
"ref": dropdownMenuRef,
|
|
621
|
-
"class": "devui-dropdown-menu-wrap"
|
|
622
|
-
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
623
|
-
}
|
|
624
|
-
})]
|
|
625
|
-
})]
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
var index = {
|
|
630
|
-
title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
|
|
631
|
-
category: "\u5BFC\u822A",
|
|
632
|
-
status: "10%",
|
|
633
|
-
install(app) {
|
|
634
|
-
app.component(Dropdown.name, Dropdown);
|
|
635
|
-
app.component(DropdownMenu.name, DropdownMenu);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
export { Dropdown, DropdownMenu, index as default, dropdownMenuProps };
|
package/dropdown/index.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var te=Object.defineProperty,oe=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var $=(u,e,p)=>e in u?te(u,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):u[e]=p,D=(u,e)=>{for(var p in e||(e={}))le.call(e,p)&&$(u,p,e[p]);if(R)for(var p of R(e))ae.call(e,p)&&$(u,p,e[p]);return u},T=(u,e)=>oe(u,ne(e));(function(u,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("@floating-ui/dom"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@floating-ui/dom","@vueuse/core"],e):(u=typeof globalThis!="undefined"?globalThis:u||self,e(u.index={},u.Vue,u.dom,u.core))})(this,function(u,e,p,_){"use strict";const F={visible:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},closeOnMouseLeaveMenu:{type:Boolean,default:!1}};function q(t){return t instanceof Element?t:t&&typeof t=="object"&&t.$el instanceof Element?t.$el:null}const h=new Map;function B(t,n,l){return t==null||t.addEventListener(n,l),()=>{t==null||t.removeEventListener(n,l)}}const U=({id:t,isOpen:n,origin:l,dropdownRef:s,props:c,emit:a})=>{let o=!1,d=!1;const{trigger:f,closeScope:r,closeOnMouseLeaveMenu:g}=e.toRefs(c),i=b=>{n.value=b,a("toggle",n.value)},y=async(b,m)=>{await new Promise(v=>setTimeout(v,50)),!(b==="origin"&&o||b==="dropdown"&&d)&&(m&&[...h.values()].reverse().forEach(v=>{setTimeout(()=>{var C;(C=v.toggle)==null||C.call(v)},0)}),i(!1))};e.watch([f,l,s],([b,m,v],C,P)=>{const S=q(m),O=[];setTimeout(()=>{O.push(B(document,"click",w=>{const k=[...h.values()];!n.value||r.value==="none"||v.contains(w.target)&&r.value==="blank"||k.some(V=>{var E;return(E=V.toggleEl)==null?void 0:E.contains(w.target)})&&k.some(V=>{var E;return(E=V.menuEl)==null?void 0:E.contains(w.target)})||([...h.values()].reverse().forEach(V=>{setTimeout(()=>{var E,L;((E=V.toggleEl)==null?void 0:E.contains(w.target))||(L=V.toggle)==null||L.call(V)},0)}),o=!1)}))},0),b==="click"?O.push(B(S,"click",()=>i(!n.value)),B(v,"mouseleave",w=>{var k;g.value&&!((k=h.get(t).child)==null?void 0:k.contains(w.relatedTarget))&&y("dropdown",w)})):b==="hover"&&O.push(B(S,"mouseenter",()=>{d=!0,i(!0)}),B(S,"mouseleave",()=>{d=!1,y("origin")}),B(v,"mouseenter",()=>{o=!0,n.value=!0}),B(v,"mouseleave",w=>{var k;o=!1,!(w.relatedTarget&&((S==null?void 0:S.contains(w.relatedTarget))||((k=h.get(t).child)==null?void 0:k.contains(w.relatedTarget))))&&y("dropdown",w)})),P(()=>O.forEach(w=>w()))})};function z(t,n,l,s,c,a,o){const d=f=>{const r=f.offsetHeight;window.innerHeight-s.value.getBoundingClientRect().bottom>=r?a.value="bottom":a.value="top"};e.watch(n,(f,r)=>{r!==void 0&&(l.value=f,o("toggle",l.value))},{immediate:!0}),e.watch([l,c],([f,r])=>{var g;if(f){h.set(t,T(D({},h.get(t)),{menuEl:r,toggle:()=>{l.value=!1,o("toggle",l.value)}}));for(const i of h.values())((g=i.menuEl)==null?void 0:g.contains(s.value))&&(i.child=r)}r&&d(r)}),e.onMounted(()=>{h.set(t,{toggleEl:s.value})}),e.onUnmounted(()=>{h.delete(t)})}var re="";function H(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const Y=e.defineComponent({setup(t,n){return()=>{let l;return e.createVNode(e.Teleport,{to:"#d-overlay-anchor"},{default:()=>[e.createVNode(e.Transition,{name:"devui-overlay-fade"},H(l=e.renderSlot(n.slots,"default"))?l:{default:()=>[l]})]})}}}),I={visible:{type:Boolean},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},onBackdropClick:{type:Function},backdropClose:{type:Boolean,default:!0},hasBackdrop:{type:Boolean,default:!0}},X=["update:visible","backdropClick"],G=T(D({},I),{overlayStyle:{type:[String,Object],default:void 0}}),J={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},offset:{type:[Number,Object],default:8},align:{type:String,default:null},showArrow:{type:Boolean,default:!1},isArrowCenter:{type:Boolean,default:!0}};function K(t,n){const l=e.computed(()=>["devui-overlay-background",t.backgroundClass,t.hasBackdrop?"devui-overlay-background__color":"devui-overlay-background__disabled"]),s=e.computed(()=>"devui-overlay"),c=o=>{var d;o.preventDefault(),(d=t.onBackdropClick)==null||d.call(t),t.backdropClose&&n.emit("update:visible",!1)},a=o=>o.cancelBubble=!0;return e.onMounted(()=>{const o=document.body,d=o.style.overflow,f=o.style.position;e.watch([()=>t.visible,()=>t.backgroundBlock],([r,g])=>{if(g){const i=o.getBoundingClientRect().y;r?(o.style.overflowY="scroll",o.style.position=r?"fixed":"",o.style.top=`${i}px`):(o.style.overflowY=d,o.style.position=f,o.style.top="",window.scrollTo(0,-i))}}),e.onUnmounted(()=>{document.body.style.overflow=d})}),{backgroundClass:l,overlayClass:s,handleBackdropClick:c,handleOverlayBubbleCancel:a}}e.defineComponent({name:"DFixedOverlay",props:G,emits:X,setup(t,n){const{backgroundClass:l,overlayClass:s,handleBackdropClick:c,handleOverlayBubbleCancel:a}=K(t,n);return()=>e.createVNode(Y,null,{default:()=>[t.visible&&e.createVNode("div",{class:l.value,style:t.backgroundStyle,onClick:c},[e.createVNode("div",{class:s.value,style:t.overlayStyle,onClick:a},[e.renderSlot(n.slots,"default")])])]})}});function M(t){const n=/(auto|scroll|hidden)/;for(let l=t;l=l.parentElement;l.parentElement!==document.body){const s=window.getComputedStyle(l);if(n.test(s.overflow+s.overflowX+s.overflowY))return l}return window}function Q(t,n,l,s){let{x:c,y:a}=n;if(!t){const{width:o,height:d}=s;c&&l.includes("start")&&(c=12),c&&l.includes("end")&&(c=Math.round(o-24)),a&&l.includes("start")&&(a=10),a&&l.includes("end")&&(a=d-14)}return{x:c,y:a}}function W(t,n){const l=e.ref(),s=e.ref(),c=(o,d,f,r)=>{const{x:g,y:i}=Q(t.isArrowCenter,f,d,r.getBoundingClientRect()),y={top:"bottom",right:"left",bottom:"top",left:"right"}[d.split("-")[0]];Object.assign(o.style,{left:g?`${g}px`:"",top:i?`${i}px`:"",right:"",bottom:"",[y]:"-4px"})},a=async()=>{const o=t.origin,d=e.unref(l.value),f=e.unref(s.value),r=[p.offset(t.offset),p.autoPlacement({alignment:t.align,allowedPlacements:t.position})];t.showArrow&&r.push(p.arrow({element:f}));const{x:g,y:i,placement:y,middlewareData:b}=await p.computePosition(o,d,{strategy:"fixed",middleware:r});n("positionChange",y),Object.assign(d.style,{top:`${i}px`,left:`${g}px`}),t.showArrow&&c(f,y,b.arrow,d)};return e.watch(()=>t.modelValue,()=>{const o=M(t.origin);t.modelValue&&t.origin?(e.nextTick(a),o.addEventListener("scroll",a),o!==window&&window.addEventListener("scroll",a),window.addEventListener("resize",a)):(o.removeEventListener("scroll",a),o!==window&&window.removeEventListener("scroll",a),window.removeEventListener("resize",a))}),e.onUnmounted(()=>{const o=M(t.origin);o.removeEventListener("scroll",a),o!==window&&window.removeEventListener("scroll",a),window.removeEventListener("resize",a)}),{arrowRef:s,overlayRef:l}}var ie="";const j=e.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:J,emits:["update:modelValue","positionChange"],setup(t,{slots:n,attrs:l,emit:s}){const{arrowRef:c,overlayRef:a}=W(t,s);return()=>{var o;return t.modelValue&&e.createVNode("div",e.mergeProps({ref:a,class:"devui-flexible-overlay"},l),[(o=n.default)==null?void 0:o.call(n),t.showArrow&&e.createVNode("div",{ref:c,class:"devui-flexible-overlay-arrow"},null)])}}});var se="";let Z=1;var N=e.defineComponent({name:"DDropdown",inheritAttrs:!1,props:F,emits:["toggle"],setup(t,{slots:n,attrs:l,emit:s}){const{visible:c,position:a,align:o,offset:d}=e.toRefs(t),f=e.ref(),r=e.ref(),g=`dropdown_${Z++}`,i=e.ref(!1),y=e.ref("bottom"),b=C=>{y.value=C.includes("top")||C.includes("end")?"top":"bottom"},m=e.computed(()=>({transformOrigin:y.value==="top"?"0% 100%":"0% 0%"})),v=e.computed(()=>({"fade-in-bottom":i.value&&y.value==="bottom","fade-in-top":i.value&&y.value==="top"}));return U({id:g,isOpen:i,origin:f,dropdownRef:r,props:t,emit:s}),z(g,c,i,f,r,y,s),()=>{var C;return e.createVNode(e.Fragment,null,[e.createVNode("div",{ref:f,class:"devui-dropdown-toggle"},[(C=n.default)==null?void 0:C.call(n)]),e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:`devui-dropdown-fade-${y.value}`},{default:()=>[e.createVNode(j,{modelValue:i.value,"onUpdate:modelValue":P=>i.value=P,origin:f.value,position:a.value,align:o.value,offset:d.value,onPositionChange:b,class:v.value,style:m.value},{default:()=>{var P;return[e.createVNode("div",e.mergeProps({ref:r,class:"devui-dropdown-menu-wrap"},l),[(P=n.menu)==null?void 0:P.call(n)])]}})]})]})])}}});const A={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},clickOutside:{type:Function,default:()=>!0}};var x=e.defineComponent({name:"DDropdownMenu",inheritAttrs:!1,props:A,emits:["update:modelValue"],setup(t,{slots:n,attrs:l,emit:s}){const{modelValue:c,origin:a,position:o,align:d,offset:f,clickOutside:r}=e.toRefs(t),g=e.ref(null);_.onClickOutside(g,m=>{var v;((v=r.value)==null?void 0:v.call(r))&&!a.value.contains(m.target)&&s("update:modelValue",!1)});const i=e.ref("bottom"),y=m=>{i.value=m.split("-")[0]==="top"?"top":"bottom"},b=e.computed(()=>({transformOrigin:i.value==="top"?"0% 100%":"0% 0%"}));return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:`devui-dropdown-fade-${i.value}`},{default:()=>[e.createVNode(j,{modelValue:c.value,"onUpdate:modelValue":m=>c.value=m,origin:a==null?void 0:a.value,position:o.value,align:d.value,offset:f.value,onPositionChange:y,style:b.value},{default:()=>{var m;return[e.createVNode("div",e.mergeProps({ref:g,class:"devui-dropdown-menu-wrap"},l),[(m=n.default)==null?void 0:m.call(n)])]}})]})]})}}),ee={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"10%",install(t){t.component(N.name,N),t.component(x.name,x)}};u.Dropdown=N,u.DropdownMenu=x,u.default=ee,u.dropdownMenuProps=A,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module"});
|
package/dropdown/package.json
DELETED
package/dropdown/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.devui-overlay-background{position:fixed;top:0;left:0;height:100vh;width:100vw;display:flex}.devui-overlay-background__color{background:rgba(0,0,0,.4)}.devui-overlay-background .devui-overlay{position:relative;z-index:1000;pointer-events:auto}.devui-overlay-background__disabled{pointer-events:none}@keyframes d-overlay-fade{0%{opacity:0}to{opacity:1}}.devui-overlay-fade-enter{opacity:0}.devui-overlay-fade-enter-active{animation-name:d-overlay-fade;animation-duration:.3s}.devui-overlay-fade-leave{opacity:1}.devui-overlay-fade-leave-active{animation-name:d-overlay-fade;animation-duration:.3s;animation-direction:reverse}.devui-flexible-overlay{position:fixed;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-connected-overlay-bg, #ffffff);box-shadow:var(--devui-shadow-connected-overlay, 0 2px 8px 0) var(--devui-shadow, rgba(0, 0, 0, .2));z-index:1000}.devui-flexible-overlay-arrow{position:absolute;width:8px;height:8px;transform:rotate(45deg);background-color:inherit}.devui-dropdown-toggle{display:inline-block}.devui-dropdown span.icon-chevron-down,.devui-dropdown span.icon-select-arrow{display:inline-block;vertical-align:text-top}.devui-dropdown-menu-wrap .devui-dropdown-menu{width:100%}.devui-dropdown-animation span.icon-chevron-down,.devui-dropdown-animation span.icon-select-arrow{transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-dropdown.open span.icon-chevron-down,.devui-dropdown.open span.icon-select-arrow{transform:rotate(180deg)}.fade-in-top{animation:fadeInTop .2s cubic-bezier(.16,.75,.5,1)}.fade-in-bottom{animation:fadeInBottom .2s cubic-bezier(.16,.75,.5,1)}@keyframes fadeInTop{0%{opacity:.8;transform:scaleY(.8) translateY(4px)}to{opacity:1;transform:scaleY(.9999) translateY(0)}}@keyframes fadeInBottom{0%{opacity:.8;transform:scaleY(.8) translateY(-4px)}to{opacity:1;transform:scaleY(.9999) translateY(0)}}.devui-dropdown-fade-bottom-enter-from,.devui-dropdown-fade-bottom-leave-to{opacity:.8;transform:scaleY(.8) translateY(-4px)}.devui-dropdown-fade-bottom-enter-to,.devui-dropdown-fade-bottom-leave-from{opacity:1;transform:scaleY(.9999) translateY(0)}.devui-dropdown-fade-bottom-enter-active{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.devui-dropdown-fade-bottom-leave-active{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}.devui-dropdown-fade-top-enter-from,.devui-dropdown-fade-top-leave-to{opacity:.8;transform:scaleY(.8) translateY(4px)}.devui-dropdown-fade-top-enter-to,.devui-dropdown-fade-top-leave-from{opacity:1;transform:scaleY(.9999) translateY(0)}.devui-dropdown-fade-top-enter-active{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.devui-dropdown-fade-top-leave-active{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
|