vue-devui 1.0.0-beta.9 → 1.0.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -66
- package/accordion/index.es.js +522 -39
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +6 -7
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/{toast → auto-complete}/index.d.ts +0 -0
- package/auto-complete/index.es.js +976 -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 +1 -1
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +12 -18
- package/badge/index.umd.js +1 -1
- package/button/index.es.js +262 -82
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +7 -6
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5392 -772
- package/cascader/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +8187 -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 -18
- package/countdown/index.umd.js +1 -1
- package/countdown/style.css +1 -1
- package/date-picker/index.es.js +10 -11
- 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 +408 -300
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +293 -5663
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6129 -461
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +110 -128
- 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 +2 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +33 -15
- 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 +6 -6
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +2 -1
- package/input-number/index.umd.js +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 +293 -759
- 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 +286 -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/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/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.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/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/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/popoverProps.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 +142 -198
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +10 -18
- package/pagination/index.es.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +3 -3
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5947 -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 +5 -5
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.es.js +2 -1
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +1 -1
- package/search/index.es.js +5426 -195
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +3 -2
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/slider/index.es.js +2 -5
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5881 -36
- 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/style.css +1 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +698 -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 +2 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +0 -12
- package/tag-input/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-axis/index.es.js +2 -1
- package/time-axis/index.umd.js +1 -1
- package/time-picker/index.es.js +269 -84
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/tooltip/index.es.js +5798 -141
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +6522 -638
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5775 -192
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +130 -35
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +463 -2680
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +14261 -14065
- package/vue-devui.umd.js +19 -19
- package/toast/index.es.js +0 -2059
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
package/nuxt/index.js
ADDED
package/overlay/index.es.js
CHANGED
|
@@ -17,7 +17,8 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted,
|
|
20
|
+
import { defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, nextTick, unref, mergeProps } from "vue";
|
|
21
|
+
import { offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
21
22
|
var overlay = "";
|
|
22
23
|
function _isSlot(s) {
|
|
23
24
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
@@ -42,9 +43,6 @@ const overlayProps = {
|
|
|
42
43
|
visible: {
|
|
43
44
|
type: Boolean
|
|
44
45
|
},
|
|
45
|
-
"onUpdate:visible": {
|
|
46
|
-
type: Function
|
|
47
|
-
},
|
|
48
46
|
backgroundBlock: {
|
|
49
47
|
type: Boolean,
|
|
50
48
|
default: false
|
|
@@ -68,29 +66,44 @@ const overlayProps = {
|
|
|
68
66
|
default: true
|
|
69
67
|
}
|
|
70
68
|
};
|
|
71
|
-
const overlayEmits = ["
|
|
69
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
72
70
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
73
71
|
overlayStyle: {
|
|
74
72
|
type: [String, Object],
|
|
75
73
|
default: void 0
|
|
76
74
|
}
|
|
77
75
|
});
|
|
78
|
-
const flexibleOverlayProps =
|
|
76
|
+
const flexibleOverlayProps = {
|
|
77
|
+
modelValue: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
79
81
|
origin: {
|
|
80
82
|
type: Object,
|
|
81
83
|
require: true
|
|
82
84
|
},
|
|
83
85
|
position: {
|
|
84
|
-
type:
|
|
85
|
-
default:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
type: Array,
|
|
87
|
+
default: ["bottom"]
|
|
88
|
+
},
|
|
89
|
+
offset: {
|
|
90
|
+
type: [Number, Object],
|
|
91
|
+
default: 8
|
|
92
|
+
},
|
|
93
|
+
align: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: null
|
|
96
|
+
},
|
|
97
|
+
showArrow: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false
|
|
100
|
+
},
|
|
101
|
+
isArrowCenter: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
91
104
|
}
|
|
92
|
-
}
|
|
93
|
-
function useOverlayLogic(props) {
|
|
105
|
+
};
|
|
106
|
+
function useOverlayLogic(props, ctx) {
|
|
94
107
|
const backgroundClass = computed(() => {
|
|
95
108
|
return [
|
|
96
109
|
"devui-overlay-background",
|
|
@@ -102,11 +115,11 @@ function useOverlayLogic(props) {
|
|
|
102
115
|
return "devui-overlay";
|
|
103
116
|
});
|
|
104
117
|
const handleBackdropClick = (event) => {
|
|
105
|
-
var _a
|
|
118
|
+
var _a;
|
|
106
119
|
event.preventDefault();
|
|
107
120
|
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
108
121
|
if (props.backdropClose) {
|
|
109
|
-
(
|
|
122
|
+
ctx.emit("update:visible", false);
|
|
110
123
|
}
|
|
111
124
|
};
|
|
112
125
|
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
@@ -150,9 +163,9 @@ const FixedOverlay = defineComponent({
|
|
|
150
163
|
overlayClass,
|
|
151
164
|
handleBackdropClick,
|
|
152
165
|
handleOverlayBubbleCancel
|
|
153
|
-
} = useOverlayLogic(props);
|
|
166
|
+
} = useOverlayLogic(props, ctx);
|
|
154
167
|
return () => createVNode(CommonOverlay, null, {
|
|
155
|
-
default: () => [
|
|
168
|
+
default: () => [props.visible && createVNode("div", {
|
|
156
169
|
"class": backgroundClass.value,
|
|
157
170
|
"style": props.backgroundStyle,
|
|
158
171
|
"onClick": handleBackdropClick
|
|
@@ -160,203 +173,134 @@ const FixedOverlay = defineComponent({
|
|
|
160
173
|
"class": overlayClass.value,
|
|
161
174
|
"style": props.overlayStyle,
|
|
162
175
|
"onClick": handleOverlayBubbleCancel
|
|
163
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
176
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
164
177
|
});
|
|
165
178
|
}
|
|
166
179
|
});
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
function getScrollParent(element) {
|
|
181
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
182
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
183
|
+
const style = window.getComputedStyle(parent);
|
|
184
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
185
|
+
return parent;
|
|
186
|
+
}
|
|
173
187
|
}
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
return window;
|
|
189
|
+
}
|
|
190
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
191
|
+
let { x, y } = point;
|
|
192
|
+
if (!isArrowCenter) {
|
|
193
|
+
const { width, height } = originRect;
|
|
194
|
+
if (x && placement.includes("start")) {
|
|
195
|
+
x = 12;
|
|
196
|
+
}
|
|
197
|
+
if (x && placement.includes("end")) {
|
|
198
|
+
x = Math.round(width - 24);
|
|
199
|
+
}
|
|
200
|
+
if (y && placement.includes("start")) {
|
|
201
|
+
y = 10;
|
|
202
|
+
}
|
|
203
|
+
if (y && placement.includes("end")) {
|
|
204
|
+
y = height - 14;
|
|
205
|
+
}
|
|
176
206
|
}
|
|
177
|
-
return
|
|
207
|
+
return { x, y };
|
|
208
|
+
}
|
|
209
|
+
function useOverlay(props, emit) {
|
|
210
|
+
const overlayRef = ref();
|
|
211
|
+
const arrowRef = ref();
|
|
212
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
213
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
214
|
+
const staticSide = {
|
|
215
|
+
top: "bottom",
|
|
216
|
+
right: "left",
|
|
217
|
+
bottom: "top",
|
|
218
|
+
left: "right"
|
|
219
|
+
}[placement.split("-")[0]];
|
|
220
|
+
Object.assign(arrowEl.style, {
|
|
221
|
+
left: x ? `${x}px` : "",
|
|
222
|
+
top: y ? `${y}px` : "",
|
|
223
|
+
right: "",
|
|
224
|
+
bottom: "",
|
|
225
|
+
[staticSide]: "-4px"
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
const updatePosition = async () => {
|
|
229
|
+
const hostEl = props.origin;
|
|
230
|
+
const overlayEl = unref(overlayRef.value);
|
|
231
|
+
const arrowEl = unref(arrowRef.value);
|
|
232
|
+
const middleware = [
|
|
233
|
+
offset(props.offset),
|
|
234
|
+
autoPlacement({
|
|
235
|
+
alignment: props.align,
|
|
236
|
+
allowedPlacements: props.position
|
|
237
|
+
})
|
|
238
|
+
];
|
|
239
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
240
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
241
|
+
strategy: "fixed",
|
|
242
|
+
middleware
|
|
243
|
+
});
|
|
244
|
+
emit("positionChange", placement);
|
|
245
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
246
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
247
|
+
};
|
|
248
|
+
watch(() => props.modelValue, () => {
|
|
249
|
+
const originParent = getScrollParent(props.origin);
|
|
250
|
+
if (props.modelValue && props.origin) {
|
|
251
|
+
nextTick(updatePosition);
|
|
252
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
253
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
254
|
+
window.addEventListener("resize", updatePosition);
|
|
255
|
+
} else {
|
|
256
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
257
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
258
|
+
window.removeEventListener("resize", updatePosition);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
onUnmounted(() => {
|
|
262
|
+
const originParent = getScrollParent(props.origin);
|
|
263
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
264
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
265
|
+
window.removeEventListener("resize", updatePosition);
|
|
266
|
+
});
|
|
267
|
+
return { arrowRef, overlayRef };
|
|
178
268
|
}
|
|
269
|
+
var flexibleOverlay = "";
|
|
179
270
|
const FlexibleOverlay = defineComponent({
|
|
180
271
|
name: "DFlexibleOverlay",
|
|
272
|
+
inheritAttrs: false,
|
|
181
273
|
props: flexibleOverlayProps,
|
|
182
|
-
emits:
|
|
183
|
-
setup(props,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
onMounted(async () => {
|
|
189
|
-
const handleRectChange = (position, rect, origin) => {
|
|
190
|
-
const point = calculatePosition(position, rect, origin);
|
|
191
|
-
positionedStyle.left = `${point.x}px`;
|
|
192
|
-
positionedStyle.top = `${point.y}px`;
|
|
193
|
-
};
|
|
194
|
-
const locationElements = computed(() => {
|
|
195
|
-
const overlay2 = overlayRef.value;
|
|
196
|
-
const origin = getOrigin(props.origin);
|
|
197
|
-
if (!overlay2 || !origin) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
origin,
|
|
202
|
-
overlay: overlay2
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
const visibleRef = toRef(props, "visible");
|
|
206
|
-
const positionRef = toRef(props, "position");
|
|
207
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
208
|
-
if (!visible || !locationElements2) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const {
|
|
212
|
-
origin,
|
|
213
|
-
overlay: overlay2
|
|
214
|
-
} = locationElements2;
|
|
215
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
216
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
217
|
-
onInvalidate(() => {
|
|
218
|
-
unsubscriptions.forEach((fn) => fn());
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
274
|
+
emits: ["update:modelValue", "positionChange"],
|
|
275
|
+
setup(props, {
|
|
276
|
+
slots,
|
|
277
|
+
attrs,
|
|
278
|
+
emit
|
|
279
|
+
}) {
|
|
222
280
|
const {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
default: () => [withDirectives(createVNode("div", {
|
|
230
|
-
"style": props.backgroundStyle,
|
|
231
|
-
"class": backgroundClass.value,
|
|
232
|
-
"onClick": handleBackdropClick
|
|
233
|
-
}, [createVNode("div", {
|
|
281
|
+
arrowRef,
|
|
282
|
+
overlayRef
|
|
283
|
+
} = useOverlay(props, emit);
|
|
284
|
+
return () => {
|
|
285
|
+
var _a;
|
|
286
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
234
287
|
"ref": overlayRef,
|
|
235
|
-
"class":
|
|
236
|
-
|
|
237
|
-
"
|
|
238
|
-
|
|
239
|
-
|
|
288
|
+
"class": "devui-flexible-overlay"
|
|
289
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
290
|
+
"ref": arrowRef,
|
|
291
|
+
"class": "devui-flexible-overlay-arrow"
|
|
292
|
+
}, null)]);
|
|
293
|
+
};
|
|
240
294
|
}
|
|
241
295
|
});
|
|
242
|
-
function getOrigin(origin) {
|
|
243
|
-
if (origin instanceof Element) {
|
|
244
|
-
return origin;
|
|
245
|
-
}
|
|
246
|
-
if (isRef(origin)) {
|
|
247
|
-
return getElement(origin.value);
|
|
248
|
-
}
|
|
249
|
-
if (isComponent(origin)) {
|
|
250
|
-
return getElement(origin);
|
|
251
|
-
}
|
|
252
|
-
return origin;
|
|
253
|
-
}
|
|
254
|
-
function calculatePosition(position, rect, origin) {
|
|
255
|
-
const originRect = getOriginRect(origin);
|
|
256
|
-
const originPoint = getOriginRelativePoint(originRect, position);
|
|
257
|
-
return getOverlayPoint(originPoint, rect, position);
|
|
258
|
-
}
|
|
259
|
-
function getOriginRect(origin) {
|
|
260
|
-
if (origin instanceof Element) {
|
|
261
|
-
return origin.getBoundingClientRect();
|
|
262
|
-
}
|
|
263
|
-
const width = origin.width || 0;
|
|
264
|
-
const height = origin.height || 0;
|
|
265
|
-
return {
|
|
266
|
-
top: origin.y,
|
|
267
|
-
bottom: origin.y + height,
|
|
268
|
-
left: origin.x,
|
|
269
|
-
right: origin.x + width,
|
|
270
|
-
height,
|
|
271
|
-
width
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
function getOverlayPoint(originPoint, rect, position) {
|
|
275
|
-
let x;
|
|
276
|
-
const {
|
|
277
|
-
width,
|
|
278
|
-
height
|
|
279
|
-
} = rect;
|
|
280
|
-
if (position.overlayX == "center") {
|
|
281
|
-
x = originPoint.x - width / 2;
|
|
282
|
-
} else {
|
|
283
|
-
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
284
|
-
}
|
|
285
|
-
let y;
|
|
286
|
-
if (position.overlayY == "center") {
|
|
287
|
-
y = originPoint.y - height / 2;
|
|
288
|
-
} else {
|
|
289
|
-
y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
x,
|
|
293
|
-
y
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
function getOriginRelativePoint(originRect, position) {
|
|
297
|
-
let x;
|
|
298
|
-
if (position.originX == "center") {
|
|
299
|
-
x = originRect.left + originRect.width / 2;
|
|
300
|
-
} else {
|
|
301
|
-
const startX = originRect.left;
|
|
302
|
-
const endX = originRect.right;
|
|
303
|
-
x = position.originX == "left" ? startX : endX;
|
|
304
|
-
}
|
|
305
|
-
let y;
|
|
306
|
-
if (position.originY == "center") {
|
|
307
|
-
y = originRect.top + originRect.height / 2;
|
|
308
|
-
} else {
|
|
309
|
-
y = position.originY == "top" ? originRect.top : originRect.bottom;
|
|
310
|
-
}
|
|
311
|
-
return {
|
|
312
|
-
x,
|
|
313
|
-
y
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function subscribeLayoutEvent(event) {
|
|
317
|
-
window.addEventListener("scroll", event, true);
|
|
318
|
-
window.addEventListener("resize", event);
|
|
319
|
-
window.addEventListener("orientationchange", event);
|
|
320
|
-
return () => {
|
|
321
|
-
window.removeEventListener("scroll", event, true);
|
|
322
|
-
window.removeEventListener("resize", event);
|
|
323
|
-
window.removeEventListener("orientationchange", event);
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
function subscribeOverlayResize(overlay2, callback) {
|
|
327
|
-
if (overlay2 instanceof Element) {
|
|
328
|
-
const resizeObserver = new ResizeObserver(callback);
|
|
329
|
-
resizeObserver.observe(overlay2);
|
|
330
|
-
return () => resizeObserver.disconnect();
|
|
331
|
-
}
|
|
332
|
-
return () => {
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function subscribeOriginResize(origin, callback) {
|
|
336
|
-
if (origin instanceof Element) {
|
|
337
|
-
const observer = new MutationObserver(callback);
|
|
338
|
-
observer.observe(origin, {
|
|
339
|
-
attributeFilter: ["style"]
|
|
340
|
-
});
|
|
341
|
-
return () => observer.disconnect();
|
|
342
|
-
}
|
|
343
|
-
return () => {
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
296
|
const inBrowser = typeof window !== "undefined";
|
|
347
|
-
FlexibleOverlay.install = function(app) {
|
|
348
|
-
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
349
|
-
};
|
|
350
|
-
FixedOverlay.install = function(app) {
|
|
351
|
-
app.component(FixedOverlay.name, FixedOverlay);
|
|
352
|
-
};
|
|
353
297
|
var index = {
|
|
354
298
|
title: "Overlay \u906E\u7F69\u5C42",
|
|
355
299
|
category: "\u901A\u7528",
|
|
356
300
|
status: "100%",
|
|
357
301
|
install(app) {
|
|
358
|
-
app.
|
|
359
|
-
app.
|
|
302
|
+
app.component(FixedOverlay.name, FixedOverlay);
|
|
303
|
+
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
360
304
|
if (inBrowser && !document.getElementById("d-overlay-anchor")) {
|
|
361
305
|
const overlayAnchor = document.createElement("div");
|
|
362
306
|
overlayAnchor.setAttribute("id", "d-overlay-anchor");
|
|
@@ -368,4 +312,4 @@ var index = {
|
|
|
368
312
|
}
|
|
369
313
|
}
|
|
370
314
|
};
|
|
371
|
-
export { FixedOverlay, FlexibleOverlay, index as default };
|
|
315
|
+
export { FixedOverlay, FlexibleOverlay, index as default, fixedOverlayProps, flexibleOverlayProps, overlayEmits, overlayProps };
|