@pixelium/web-vue 0.0.2-fix → 0.0.3-alpha
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 +42 -0
- package/README.zh.md +6 -3
- package/dist/font.css +1 -1
- package/dist/index.d.ts +1602 -248
- package/dist/normalize.css +2 -0
- package/dist/pixelium-vue-icon-hn.cjs +1 -1
- package/dist/pixelium-vue-icon-hn.css +2 -1
- package/dist/pixelium-vue-icon-hn.js +8533 -8154
- package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.css +2 -1
- package/dist/pixelium-vue-icon-pa.js +10625 -10143
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
- package/dist/pixelium-vue.cjs +2 -2
- package/dist/pixelium-vue.css +2 -1
- package/dist/pixelium-vue.js +7407 -5854
- package/dist/pixelium-vue.umd.cjs +2 -2
- package/es/aside/index.css +1 -0
- package/es/aside/index.js +46 -151
- package/es/auto-complete/draw.d.ts +1 -1
- package/es/auto-complete/draw.js +26 -51
- package/es/auto-complete/index.css +92 -32
- package/es/auto-complete/index.d.ts +12 -15
- package/es/auto-complete/index.js +338 -400
- package/es/auto-complete/type.d.ts +25 -13
- package/es/avatar/css.js +2 -0
- package/es/avatar/draw.d.ts +2 -0
- package/es/avatar/draw.js +11 -0
- package/es/avatar/index.css +49 -0
- package/es/avatar/index.d.ts +15 -0
- package/es/avatar/index.js +110 -0
- package/es/avatar/type.d.ts +34 -0
- package/es/button/draw.d.ts +4 -4
- package/es/button/draw.js +213 -297
- package/es/button/index.css +40 -30
- package/es/button/index.d.ts +0 -4
- package/es/button/index.js +230 -256
- package/es/button/type.d.ts +3 -3
- package/es/button-group/index.css +0 -3
- package/es/button-group/index.d.ts +1 -2
- package/es/button-group/index.js +59 -31
- package/es/button-group/type.d.ts +21 -4
- package/es/checkbox/css.js +2 -0
- package/es/checkbox/draw.d.ts +4 -0
- package/es/checkbox/draw.js +46 -0
- package/es/checkbox/index.css +85 -0
- package/es/checkbox/index.d.ts +31 -0
- package/es/checkbox/index.js +206 -0
- package/es/checkbox/type.d.ts +88 -0
- package/es/checkbox-group/css.js +2 -0
- package/es/checkbox-group/index.css +20 -0
- package/es/checkbox-group/index.d.ts +23 -0
- package/es/checkbox-group/index.js +84 -0
- package/es/checkbox-group/type.d.ts +78 -0
- package/es/col/index.d.ts +2 -2
- package/es/col/index.js +43 -58
- package/es/container/index.css +1 -0
- package/es/container/index.js +18 -31
- package/es/divider/index.js +39 -53
- package/es/empty/index.css +4 -4
- package/es/empty/index.js +16 -71
- package/es/entry.js +102 -0
- package/es/footer/index.css +1 -0
- package/es/footer/index.js +31 -40
- package/es/form/css.js +1 -0
- package/es/form/index.d.ts +27 -0
- package/es/form/index.js +125 -0
- package/es/form/type.d.ts +238 -0
- package/es/form/use-form.d.ts +4 -0
- package/es/form/use-form.js +48 -0
- package/es/form-item/css.js +2 -0
- package/es/form-item/index.css +77 -0
- package/es/form-item/index.d.ts +37 -0
- package/es/form-item/index.js +318 -0
- package/es/form-item/type.d.ts +96 -0
- package/es/grid/index.js +56 -75
- package/es/grid-item/css.js +0 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +85 -121
- package/es/header/index.css +1 -0
- package/es/header/index.js +31 -40
- package/es/icon/index.js +44 -55
- package/es/icons/css-hn.js +0 -1
- package/es/icons/css-pa.js +0 -1
- package/es/icons/icon-hn.js +10337 -15986
- package/es/icons/icon-pa.js +12573 -17447
- package/es/image/css.js +2 -0
- package/es/image/index.css +69 -0
- package/es/image/index.d.ts +35 -0
- package/es/image/index.js +199 -0
- package/es/image/type.d.ts +126 -0
- package/es/index.css +1 -515
- package/es/index.d.ts +22 -2
- package/es/index.js +144 -123
- package/es/input/draw.d.ts +1 -1
- package/es/input/draw.js +26 -51
- package/es/input/index.css +85 -33
- package/es/input/index.d.ts +9 -16
- package/es/input/index.js +319 -423
- package/es/input/type.d.ts +3 -3
- package/es/input-group/index.css +0 -1
- package/es/input-group/index.d.ts +2 -2
- package/es/input-group/index.js +66 -37
- package/es/input-group/type.d.ts +16 -4
- package/es/input-group-label/draw.d.ts +1 -1
- package/es/input-group-label/draw.js +26 -51
- package/es/input-group-label/index.css +33 -22
- package/es/input-group-label/index.d.ts +1 -4
- package/es/input-group-label/index.js +104 -127
- package/es/input-group-label/type.d.ts +3 -3
- package/es/input-number/draw.d.ts +1 -1
- package/es/input-number/draw.js +26 -51
- package/es/input-number/index.css +90 -35
- package/es/input-number/index.d.ts +9 -16
- package/es/input-number/index.js +428 -536
- package/es/input-number/type.d.ts +3 -3
- package/es/input-tag/draw.d.ts +1 -1
- package/es/input-tag/draw.js +26 -48
- package/es/input-tag/index.css +100 -33
- package/es/input-tag/index.d.ts +7 -13
- package/es/input-tag/index.js +442 -467
- package/es/input-tag/type.d.ts +24 -13
- package/es/link/index.js +75 -106
- package/es/main/index.css +4 -0
- package/es/main/index.d.ts +4 -1
- package/es/main/index.js +15 -15
- package/es/main/type.d.ts +7 -0
- package/es/mask/index.js +94 -115
- package/es/message/index.css +1 -1
- package/es/message/index.js +168 -346
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +98 -114
- package/es/message-box/message-box-wrapped.js +33 -46
- package/es/message-box/message-box.js +79 -111
- package/es/option-list/index.css +13 -13
- package/es/option-list/index.d.ts +4 -31
- package/es/option-list/index.js +99 -167
- package/es/option-list/type.d.ts +5 -1
- package/es/pixelate/pixel.d.ts +5 -0
- package/es/pixelate/pixel.js +70 -0
- package/es/pixelate/pixelate.worker.d.ts +1 -0
- package/es/popover/index.d.ts +13 -99
- package/es/popover/index.js +75 -238
- package/es/popover/type.d.ts +7 -2
- package/es/popup/css.js +1 -0
- package/es/popup/index.d.ts +210 -0
- package/es/popup/index.js +203 -0
- package/es/popup/type.d.ts +105 -0
- package/es/popup-content/draw.d.ts +2 -2
- package/es/popup-content/draw.js +98 -143
- package/es/popup-content/index.css +11 -11
- package/es/popup-content/index.d.ts +1 -0
- package/es/popup-content/index.js +253 -1576
- package/es/popup-content/type.d.ts +1 -0
- package/es/popup-trigger/index.d.ts +8 -2
- package/es/popup-trigger/index.js +122 -95
- package/es/popup-trigger/type.d.ts +4 -1
- package/es/popup-wrapper/css.js +2 -0
- package/es/popup-wrapper/index.css +14 -0
- package/es/popup-wrapper/index.d.ts +18 -0
- package/es/popup-wrapper/index.js +67 -0
- package/es/popup-wrapper/type.d.ts +9 -0
- package/es/radio/css.js +1 -0
- package/es/radio/draw.d.ts +4 -0
- package/es/radio/draw.js +47 -0
- package/es/radio/index.d.ts +30 -0
- package/es/radio/index.js +190 -0
- package/es/radio/style.css +73 -0
- package/es/radio/type.d.ts +76 -0
- package/es/radio-group/css.js +2 -0
- package/es/radio-group/index.css +20 -0
- package/es/radio-group/index.d.ts +23 -0
- package/es/radio-group/index.js +77 -0
- package/es/radio-group/type.d.ts +77 -0
- package/es/row/index.js +56 -70
- package/es/select/draw.d.ts +1 -1
- package/es/select/draw.js +26 -51
- package/es/select/index.css +118 -36
- package/es/select/index.d.ts +14 -16
- package/es/select/index.js +625 -675
- package/es/select/type.d.ts +60 -25
- package/es/share/const/event-bus-key.js +1 -6
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +22 -24
- package/es/share/const/provide-key.d.ts +5 -0
- package/es/share/const/provide-key.js +6 -5
- package/es/share/const/style.d.ts +6 -0
- package/es/share/const/style.js +7 -0
- package/es/share/hook/use-cancelable-delay.d.ts +1 -0
- package/es/share/hook/use-cancelable-delay.js +42 -0
- package/es/share/hook/use-click-outside-listener.d.ts +1 -1
- package/es/share/hook/use-click-outside-listener.js +28 -41
- package/es/share/hook/use-composition.js +17 -15
- package/es/share/hook/use-controlled-mode.d.ts +3 -3
- package/es/share/hook/use-controlled-mode.js +20 -23
- package/es/share/hook/use-dark-mode.js +51 -65
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +47 -45
- package/es/share/hook/use-lazy-load.d.ts +10 -0
- package/es/share/hook/use-lazy-load.js +133 -0
- package/es/share/hook/use-props-detect.d.ts +2 -0
- package/es/share/hook/use-resize-observer.d.ts +1 -2
- package/es/share/hook/use-resize-observer.js +28 -20
- package/es/share/hook/use-screen-width.js +27 -36
- package/es/share/hook/use-smooth-transition.d.ts +2 -0
- package/es/share/hook/use-smooth-transition.js +65 -0
- package/es/share/hook/use-textarea-height.js +86 -92
- package/es/share/hook/use-theme-mode.js +41 -42
- package/es/share/hook/use-transition-end.d.ts +2 -0
- package/es/share/hook/use-transition-end.js +12 -0
- package/es/share/hook/use-watch-global-css-var.js +12 -16
- package/es/share/hook/use-window-resize-listener.d.ts +1 -0
- package/es/share/hook/use-window-resize-listener.js +15 -0
- package/es/share/hook/use-z-index.js +30 -27
- package/es/share/style/index.css +5 -0
- package/es/share/type/index.d.ts +18 -3
- package/es/share/util/color.d.ts +5 -3
- package/es/share/util/color.js +156 -149
- package/es/share/util/common.d.ts +7 -2
- package/es/share/util/common.js +127 -65
- package/es/share/util/console.d.ts +3 -3
- package/es/share/util/console.js +10 -7
- package/es/share/util/dom.d.ts +19 -0
- package/es/share/util/dom.js +88 -0
- package/es/share/util/env.d.ts +1 -0
- package/es/share/util/env.js +5 -4
- package/es/share/util/event-bus.js +3 -20
- package/es/share/util/lru-cache.js +29 -33
- package/es/share/util/pixel.d.ts +4 -0
- package/es/share/util/plot.d.ts +8 -3
- package/es/share/util/plot.js +457 -229
- package/es/share/util/reactivity.d.ts +8 -0
- package/es/share/util/reactivity.js +23 -0
- package/es/share/util/render.js +31 -41
- package/es/share/util/theme.d.ts +3 -0
- package/es/share/util/theme.js +77 -57
- package/es/slider/css.js +2 -0
- package/es/slider/draw.d.ts +25 -0
- package/es/slider/draw.js +113 -0
- package/es/slider/index.css +119 -0
- package/es/slider/index.d.ts +66 -0
- package/es/slider/index.js +503 -0
- package/es/slider/type.d.ts +162 -0
- package/es/slider/util.d.ts +37 -0
- package/es/slider/util.js +130 -0
- package/es/space/index.css +24 -29
- package/es/space/index.js +73 -97
- package/es/spin/index.css +18 -17
- package/es/spin/index.js +72 -102
- package/es/spin/type.d.ts +11 -5
- package/es/switch/css.js +2 -0
- package/es/switch/draw.d.ts +2 -0
- package/es/switch/draw.js +18 -0
- package/es/switch/index.css +121 -0
- package/es/switch/index.d.ts +42 -0
- package/es/switch/index.js +259 -0
- package/es/switch/type.d.ts +133 -0
- package/es/tag/draw.d.ts +2 -2
- package/es/tag/draw.js +80 -127
- package/es/tag/index.css +38 -22
- package/es/tag/index.d.ts +2 -2
- package/es/tag/index.js +121 -190
- package/es/tag/type.d.ts +3 -3
- package/es/text-outline/css.js +2 -0
- package/es/text-outline/index.css +4 -0
- package/es/text-outline/index.d.ts +17 -0
- package/es/text-outline/index.js +33 -0
- package/es/text-outline/type.d.ts +23 -0
- package/es/textarea/draw.js +9 -11
- package/es/textarea/index.css +37 -23
- package/es/textarea/index.d.ts +8 -14
- package/es/textarea/index.js +274 -262
- package/es/tooltip/index.d.ts +100 -4
- package/es/tooltip/index.js +70 -226
- package/es/tooltip/type.d.ts +7 -2
- package/es/vendor.js +504 -0
- package/es/virtual-list/css.js +2 -0
- package/es/virtual-list/index.css +25 -0
- package/es/virtual-list/index.d.ts +11 -0
- package/es/virtual-list/index.js +313 -0
- package/es/virtual-list/type.d.ts +26 -0
- package/package.json +10 -16
- package/es/grid-item/index.css +0 -0
- /package/es/message-box/{message-box.css → index.css} +0 -0
|
@@ -1,1578 +1,255 @@
|
|
|
1
1
|
import './css.js'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import { g as A } from "../vendor.js";
|
|
3
|
+
import { t as BORDER_CORNER_RAD_RANGE } from "../share/const/index.js";
|
|
4
|
+
import { n as fillArr } from "../share/util/common.js";
|
|
5
|
+
import { t as inBrowser } from "../share/util/env.js";
|
|
6
|
+
import { i as canvasPreprocess, n as calcPixelSize, r as calcWhenLeaveBaseline, s as floodFill, t as calcBorderCornerCenter } from "../share/util/plot.js";
|
|
7
|
+
import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
|
|
8
|
+
import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
|
|
9
|
+
import { t as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
|
|
10
|
+
import { t as useTransitionEnd } from "../share/hook/use-transition-end.js";
|
|
11
|
+
import { i as getBorderColor, n as drawBorder, r as getBackgroundColor, t as drawArrow } from "./draw.js";
|
|
12
|
+
import { t as popup_wrapper_default } from "../popup-wrapper/index.js";
|
|
13
|
+
import { Transition, computed, createBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeStyle, onMounted, openBlock, ref, renderSlot, shallowRef, toDisplayString, unref, vShow, watch, withCtx, withDirectives } from "vue";
|
|
14
|
+
import { arrow, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
15
|
+
var ANIMATION_DURATION = 250;
|
|
16
|
+
var popup_content_default = /* @__PURE__ */ defineComponent({
|
|
17
|
+
name: "PopupContent",
|
|
18
|
+
__name: "index",
|
|
19
|
+
props: {
|
|
20
|
+
content: null,
|
|
21
|
+
visible: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: void 0
|
|
24
|
+
},
|
|
25
|
+
defaultVisible: { type: Boolean },
|
|
26
|
+
placement: { default: "top" },
|
|
27
|
+
offset: { default: 8 },
|
|
28
|
+
variant: { default: "light" },
|
|
29
|
+
arrow: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
zIndex: null,
|
|
34
|
+
target: null,
|
|
35
|
+
root: { default: "body" },
|
|
36
|
+
borderRadius: null,
|
|
37
|
+
widthEqual: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
contentStyle: null,
|
|
42
|
+
destroyOnHide: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
emits: ["contentMouseenter", "contentMouseleave"],
|
|
48
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
49
|
+
const props = __props;
|
|
50
|
+
const show = ref(false);
|
|
51
|
+
const contentRef = shallowRef(null);
|
|
52
|
+
const arrowRef = shallowRef(null);
|
|
53
|
+
const canvasRef = shallowRef(null);
|
|
54
|
+
const floatingStyles = ref({});
|
|
55
|
+
const arrowStyles = ref({});
|
|
56
|
+
const arrowXOffset = ref(void 0);
|
|
57
|
+
const arrowYOffset = ref(void 0);
|
|
58
|
+
const popupFinalPlacement = ref(void 0);
|
|
59
|
+
const popupRoughPlacement = computed(() => {
|
|
60
|
+
return props.placement.split("-")[0];
|
|
61
|
+
});
|
|
62
|
+
const popupSide = computed(() => {
|
|
63
|
+
return props.placement.split("-")[1] || "middle";
|
|
64
|
+
});
|
|
65
|
+
const contentWidth = ref(void 0);
|
|
66
|
+
async function updatePosition(element) {
|
|
67
|
+
if (!inBrowser()) return;
|
|
68
|
+
if (!contentRef.value || !arrowRef.value || !canvasRef.value) return;
|
|
69
|
+
const contentComputedStyle = getComputedStyle(contentRef.value);
|
|
70
|
+
const contentBorder = parseFloat(contentComputedStyle.borderLeftWidth) + parseFloat(contentComputedStyle.borderRightWidth);
|
|
71
|
+
const addX = contentBorder / 2;
|
|
72
|
+
const addY = (parseFloat(contentComputedStyle.borderTopWidth) + parseFloat(contentComputedStyle.borderBottomWidth)) / 2;
|
|
73
|
+
if ((popupRoughPlacement.value === "top" || popupRoughPlacement.value === "bottom") && props.widthEqual) {
|
|
74
|
+
const elementComputedStyle = getComputedStyle(element);
|
|
75
|
+
const boxSizing = elementComputedStyle.boxSizing;
|
|
76
|
+
const contentBoxSizing = contentComputedStyle.boxSizing;
|
|
77
|
+
const padding = parseFloat(elementComputedStyle.paddingLeft) + parseFloat(elementComputedStyle.paddingRight);
|
|
78
|
+
const contentPadding = parseFloat(contentComputedStyle.paddingLeft) + parseFloat(contentComputedStyle.paddingRight);
|
|
79
|
+
const border = parseFloat(elementComputedStyle.borderLeftWidth) + parseFloat(elementComputedStyle.borderRightWidth);
|
|
80
|
+
const width = parseFloat(elementComputedStyle.width);
|
|
81
|
+
if (boxSizing === "border-box") if (contentBoxSizing === "border-box") contentWidth.value = width;
|
|
82
|
+
else contentWidth.value = width - contentPadding - contentBorder;
|
|
83
|
+
else if (contentBoxSizing === "border-box") contentWidth.value = width + padding + border;
|
|
84
|
+
else contentWidth.value = width - contentPadding - contentBorder + padding + border;
|
|
85
|
+
await nextTick();
|
|
86
|
+
} else contentWidth.value = void 0;
|
|
87
|
+
const pixelSize = calcPixelSize();
|
|
88
|
+
const borderRadius = Math.max(props.borderRadius || pixelSize, pixelSize);
|
|
89
|
+
const ds = Math.max(0, borderRadius - calcWhenLeaveBaseline(pixelSize, borderRadius) + pixelSize) + pixelSize;
|
|
90
|
+
const { x, y, middlewareData, placement } = await computePosition(element, contentRef.value, {
|
|
91
|
+
placement: props.placement,
|
|
92
|
+
middleware: [
|
|
93
|
+
offset(props.offset),
|
|
94
|
+
shift(),
|
|
95
|
+
flip(),
|
|
96
|
+
arrow({
|
|
97
|
+
element: arrowRef.value,
|
|
98
|
+
padding: ds
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
floatingStyles.value = {
|
|
103
|
+
left: `${x}px`,
|
|
104
|
+
top: `${y}px`
|
|
105
|
+
};
|
|
106
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow ?? {};
|
|
107
|
+
popupFinalPlacement.value = placement.split("-")[0];
|
|
108
|
+
arrowStyles.value = {
|
|
109
|
+
left: arrowX ? `${arrowX + addX}px` : void 0,
|
|
110
|
+
top: arrowY ? `${arrowY + addY}px` : void 0
|
|
111
|
+
};
|
|
112
|
+
arrowXOffset.value = arrowX ? arrowX + addX : void 0;
|
|
113
|
+
arrowYOffset.value = arrowY ? arrowY + addY : void 0;
|
|
114
|
+
nextTick(() => {
|
|
115
|
+
if (props.visible) show.value = true;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async function closeHandler() {
|
|
119
|
+
if (show.value === false) return;
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
show.value = false;
|
|
122
|
+
popupFinalPlacement.value = void 0;
|
|
123
|
+
}, ANIMATION_DURATION);
|
|
124
|
+
}
|
|
125
|
+
const doOpen = () => {
|
|
126
|
+
let element = null;
|
|
127
|
+
if (props.target instanceof HTMLElement || props.target instanceof SVGElement) element = props.target;
|
|
128
|
+
else if (props.target && (props.target.el instanceof HTMLElement || props.target.el instanceof SVGElement)) element = props.target.el;
|
|
129
|
+
if (!inBrowser()) return;
|
|
130
|
+
if (element) updatePosition(element);
|
|
131
|
+
};
|
|
132
|
+
const processVisible = (value) => {
|
|
133
|
+
if (!inBrowser()) return;
|
|
134
|
+
if (value) doOpen();
|
|
135
|
+
else closeHandler();
|
|
136
|
+
};
|
|
137
|
+
watch(() => props.visible, () => {
|
|
138
|
+
updateRenderState();
|
|
139
|
+
});
|
|
140
|
+
const emits = __emit;
|
|
141
|
+
const contentMouseenterHandler = (e) => {
|
|
142
|
+
emits("contentMouseenter", e);
|
|
143
|
+
};
|
|
144
|
+
const contentMouseleaveHandler = (e) => {
|
|
145
|
+
emits("contentMouseleave", e);
|
|
146
|
+
};
|
|
147
|
+
const updateRenderState = () => {
|
|
148
|
+
processVisible(!!props.visible);
|
|
149
|
+
};
|
|
150
|
+
__expose({
|
|
151
|
+
updateRenderState,
|
|
152
|
+
content: contentRef
|
|
153
|
+
});
|
|
154
|
+
const darkMode = useDarkMode();
|
|
155
|
+
onMounted(() => {
|
|
156
|
+
nextTick(() => {
|
|
157
|
+
drawPixel();
|
|
158
|
+
processVisible(!!props.visible);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
watch([
|
|
162
|
+
darkMode,
|
|
163
|
+
popupFinalPlacement,
|
|
164
|
+
arrowXOffset,
|
|
165
|
+
arrowYOffset,
|
|
166
|
+
show,
|
|
167
|
+
floatingStyles,
|
|
168
|
+
() => props.variant,
|
|
169
|
+
() => props.arrow
|
|
170
|
+
], () => {
|
|
171
|
+
drawPixel();
|
|
172
|
+
});
|
|
173
|
+
const drawPixel = () => {
|
|
174
|
+
if (!popupFinalPlacement.value) return;
|
|
175
|
+
const preprocessData = canvasPreprocess(contentRef, canvasRef);
|
|
176
|
+
if (!preprocessData) return;
|
|
177
|
+
const { ctx, width, height } = preprocessData;
|
|
178
|
+
const pixelSize = calcPixelSize();
|
|
179
|
+
const borderRadius = fillArr(Math.max(props.borderRadius || pixelSize, pixelSize), 4);
|
|
180
|
+
const offset$1 = props.arrow ? pixelSize * 2 : 0;
|
|
181
|
+
const offsetX = popupFinalPlacement.value === "left" || popupFinalPlacement.value === "right" ? offset$1 : 0;
|
|
182
|
+
const offsetY = popupFinalPlacement.value === "top" || popupFinalPlacement.value === "bottom" ? offset$1 : 0;
|
|
183
|
+
const borderColor = getBorderColor(props.variant);
|
|
184
|
+
const center = calcBorderCornerCenter(borderRadius, width, height, pixelSize, offsetX, offsetY);
|
|
185
|
+
const rad = BORDER_CORNER_RAD_RANGE;
|
|
186
|
+
const offsetTop = popupFinalPlacement.value === "bottom" ? offset$1 : 0;
|
|
187
|
+
const offsetLeft = popupFinalPlacement.value === "right" ? offset$1 : 0;
|
|
188
|
+
if (borderColor) drawBorder(ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, offsetX, offsetY, offsetTop, offsetLeft);
|
|
189
|
+
const backgroundColor = getBackgroundColor(props.variant);
|
|
190
|
+
if (backgroundColor) floodFill(ctx, Math.round((width - offsetX) / 2 + offsetLeft), Math.round((height - offsetY) / 2 + offsetTop), backgroundColor);
|
|
191
|
+
if (props.arrow && borderColor && backgroundColor) drawArrow(ctx, width, height, borderColor, backgroundColor, pixelSize, popupFinalPlacement.value, popupSide.value, arrowXOffset.value || 0, arrowYOffset.value || 0);
|
|
192
|
+
};
|
|
193
|
+
useResizeObserver(contentRef, doOpen);
|
|
194
|
+
useWatchGlobalCssVal(doOpen);
|
|
195
|
+
useTransitionEnd(contentRef, drawPixel);
|
|
196
|
+
return (_ctx, _cache) => {
|
|
197
|
+
return openBlock(), createBlock(popup_wrapper_default, {
|
|
198
|
+
root: props.root,
|
|
199
|
+
zIndex: props.zIndex,
|
|
200
|
+
visible: props.visible,
|
|
201
|
+
"close-delay": ANIMATION_DURATION,
|
|
202
|
+
"destroy-on-hide": props.destroyOnHide
|
|
203
|
+
}, {
|
|
204
|
+
default: withCtx(() => [createVNode(Transition, {
|
|
205
|
+
name: "px-popup-content-fade__" + (popupFinalPlacement.value || popupRoughPlacement.value),
|
|
206
|
+
appear: "",
|
|
207
|
+
persisted: ""
|
|
208
|
+
}, {
|
|
209
|
+
default: withCtx(() => [withDirectives(createElementVNode("div", mergeProps({
|
|
210
|
+
ref_key: "contentRef",
|
|
211
|
+
ref: contentRef,
|
|
212
|
+
class: {
|
|
213
|
+
pixelium: true,
|
|
214
|
+
"px-popup-content": true,
|
|
215
|
+
"px-popup-content__arrow": !!props.arrow,
|
|
216
|
+
[`px-popup-content__${popupFinalPlacement.value || popupRoughPlacement.value}`]: true,
|
|
217
|
+
[`px-popup-content__${props.variant}`]: true
|
|
218
|
+
},
|
|
219
|
+
style: {
|
|
220
|
+
...floatingStyles.value,
|
|
221
|
+
visibility: show.value ? "visible" : "hidden",
|
|
222
|
+
pointerEvents: show.value ? "auto" : "none",
|
|
223
|
+
width: unref(A)(contentWidth.value) ? `${contentWidth.value}px` : void 0,
|
|
224
|
+
...props.contentStyle
|
|
225
|
+
}
|
|
226
|
+
}, _ctx.$attrs, {
|
|
227
|
+
onMouseenter: contentMouseenterHandler,
|
|
228
|
+
onMouseleave: contentMouseleaveHandler
|
|
229
|
+
}), [
|
|
230
|
+
renderSlot(_ctx.$slots, "content", {}, () => [createTextVNode(toDisplayString(props.content), 1)]),
|
|
231
|
+
createElementVNode("div", {
|
|
232
|
+
class: "px-popup-content-arrow",
|
|
233
|
+
style: normalizeStyle(arrowStyles.value),
|
|
234
|
+
ref_key: "arrowRef",
|
|
235
|
+
ref: arrowRef
|
|
236
|
+
}, null, 4),
|
|
237
|
+
createElementVNode("canvas", {
|
|
238
|
+
class: "px-popup-content-canvas",
|
|
239
|
+
ref_key: "canvasRef",
|
|
240
|
+
ref: canvasRef
|
|
241
|
+
}, null, 512)
|
|
242
|
+
], 16), [[vShow, props.visible]])]),
|
|
243
|
+
_: 3
|
|
244
|
+
}, 8, ["name"])]),
|
|
245
|
+
_: 3
|
|
246
|
+
}, 8, [
|
|
247
|
+
"root",
|
|
248
|
+
"zIndex",
|
|
249
|
+
"visible",
|
|
250
|
+
"destroy-on-hide"
|
|
251
|
+
]);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
19
254
|
});
|
|
20
|
-
|
|
21
|
-
left: "right",
|
|
22
|
-
right: "left",
|
|
23
|
-
bottom: "top",
|
|
24
|
-
top: "bottom"
|
|
25
|
-
};
|
|
26
|
-
const oppositeAlignmentMap = {
|
|
27
|
-
start: "end",
|
|
28
|
-
end: "start"
|
|
29
|
-
};
|
|
30
|
-
function clamp(start, value, end) {
|
|
31
|
-
return max(start, min(value, end));
|
|
32
|
-
}
|
|
33
|
-
function evaluate(value, param) {
|
|
34
|
-
return typeof value === "function" ? value(param) : value;
|
|
35
|
-
}
|
|
36
|
-
function getSide(placement) {
|
|
37
|
-
return placement.split("-")[0];
|
|
38
|
-
}
|
|
39
|
-
function getAlignment(placement) {
|
|
40
|
-
return placement.split("-")[1];
|
|
41
|
-
}
|
|
42
|
-
function getOppositeAxis(axis) {
|
|
43
|
-
return axis === "x" ? "y" : "x";
|
|
44
|
-
}
|
|
45
|
-
function getAxisLength(axis) {
|
|
46
|
-
return axis === "y" ? "height" : "width";
|
|
47
|
-
}
|
|
48
|
-
const yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
49
|
-
function getSideAxis(placement) {
|
|
50
|
-
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
51
|
-
}
|
|
52
|
-
function getAlignmentAxis(placement) {
|
|
53
|
-
return getOppositeAxis(getSideAxis(placement));
|
|
54
|
-
}
|
|
55
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
56
|
-
if (rtl === void 0) {
|
|
57
|
-
rtl = false;
|
|
58
|
-
}
|
|
59
|
-
const alignment = getAlignment(placement);
|
|
60
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
61
|
-
const length = getAxisLength(alignmentAxis);
|
|
62
|
-
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
63
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
64
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
65
|
-
}
|
|
66
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
67
|
-
}
|
|
68
|
-
function getExpandedPlacements(placement) {
|
|
69
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
70
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
71
|
-
}
|
|
72
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
73
|
-
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
74
|
-
}
|
|
75
|
-
const lrPlacement = ["left", "right"];
|
|
76
|
-
const rlPlacement = ["right", "left"];
|
|
77
|
-
const tbPlacement = ["top", "bottom"];
|
|
78
|
-
const btPlacement = ["bottom", "top"];
|
|
79
|
-
function getSideList(side, isStart, rtl) {
|
|
80
|
-
switch (side) {
|
|
81
|
-
case "top":
|
|
82
|
-
case "bottom":
|
|
83
|
-
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
84
|
-
return isStart ? lrPlacement : rlPlacement;
|
|
85
|
-
case "left":
|
|
86
|
-
case "right":
|
|
87
|
-
return isStart ? tbPlacement : btPlacement;
|
|
88
|
-
default:
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
93
|
-
const alignment = getAlignment(placement);
|
|
94
|
-
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
95
|
-
if (alignment) {
|
|
96
|
-
list = list.map((side) => side + "-" + alignment);
|
|
97
|
-
if (flipAlignment) {
|
|
98
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return list;
|
|
102
|
-
}
|
|
103
|
-
function getOppositePlacement(placement) {
|
|
104
|
-
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
105
|
-
}
|
|
106
|
-
function expandPaddingObject(padding) {
|
|
107
|
-
return {
|
|
108
|
-
top: 0,
|
|
109
|
-
right: 0,
|
|
110
|
-
bottom: 0,
|
|
111
|
-
left: 0,
|
|
112
|
-
...padding
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function getPaddingObject(padding) {
|
|
116
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
117
|
-
top: padding,
|
|
118
|
-
right: padding,
|
|
119
|
-
bottom: padding,
|
|
120
|
-
left: padding
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function rectToClientRect(rect) {
|
|
124
|
-
const {
|
|
125
|
-
x,
|
|
126
|
-
y,
|
|
127
|
-
width,
|
|
128
|
-
height
|
|
129
|
-
} = rect;
|
|
130
|
-
return {
|
|
131
|
-
width,
|
|
132
|
-
height,
|
|
133
|
-
top: y,
|
|
134
|
-
left: x,
|
|
135
|
-
right: x + width,
|
|
136
|
-
bottom: y + height,
|
|
137
|
-
x,
|
|
138
|
-
y
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
142
|
-
let {
|
|
143
|
-
reference,
|
|
144
|
-
floating
|
|
145
|
-
} = _ref;
|
|
146
|
-
const sideAxis = getSideAxis(placement);
|
|
147
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
148
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
149
|
-
const side = getSide(placement);
|
|
150
|
-
const isVertical = sideAxis === "y";
|
|
151
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
152
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
153
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
154
|
-
let coords;
|
|
155
|
-
switch (side) {
|
|
156
|
-
case "top":
|
|
157
|
-
coords = {
|
|
158
|
-
x: commonX,
|
|
159
|
-
y: reference.y - floating.height
|
|
160
|
-
};
|
|
161
|
-
break;
|
|
162
|
-
case "bottom":
|
|
163
|
-
coords = {
|
|
164
|
-
x: commonX,
|
|
165
|
-
y: reference.y + reference.height
|
|
166
|
-
};
|
|
167
|
-
break;
|
|
168
|
-
case "right":
|
|
169
|
-
coords = {
|
|
170
|
-
x: reference.x + reference.width,
|
|
171
|
-
y: commonY
|
|
172
|
-
};
|
|
173
|
-
break;
|
|
174
|
-
case "left":
|
|
175
|
-
coords = {
|
|
176
|
-
x: reference.x - floating.width,
|
|
177
|
-
y: commonY
|
|
178
|
-
};
|
|
179
|
-
break;
|
|
180
|
-
default:
|
|
181
|
-
coords = {
|
|
182
|
-
x: reference.x,
|
|
183
|
-
y: reference.y
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
switch (getAlignment(placement)) {
|
|
187
|
-
case "start":
|
|
188
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
189
|
-
break;
|
|
190
|
-
case "end":
|
|
191
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
return coords;
|
|
195
|
-
}
|
|
196
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
197
|
-
const {
|
|
198
|
-
placement = "bottom",
|
|
199
|
-
strategy = "absolute",
|
|
200
|
-
middleware = [],
|
|
201
|
-
platform: platform2
|
|
202
|
-
} = config;
|
|
203
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
204
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
205
|
-
let rects = await platform2.getElementRects({
|
|
206
|
-
reference,
|
|
207
|
-
floating,
|
|
208
|
-
strategy
|
|
209
|
-
});
|
|
210
|
-
let {
|
|
211
|
-
x,
|
|
212
|
-
y
|
|
213
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
214
|
-
let statefulPlacement = placement;
|
|
215
|
-
let middlewareData = {};
|
|
216
|
-
let resetCount = 0;
|
|
217
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
218
|
-
const {
|
|
219
|
-
name,
|
|
220
|
-
fn
|
|
221
|
-
} = validMiddleware[i];
|
|
222
|
-
const {
|
|
223
|
-
x: nextX,
|
|
224
|
-
y: nextY,
|
|
225
|
-
data,
|
|
226
|
-
reset
|
|
227
|
-
} = await fn({
|
|
228
|
-
x,
|
|
229
|
-
y,
|
|
230
|
-
initialPlacement: placement,
|
|
231
|
-
placement: statefulPlacement,
|
|
232
|
-
strategy,
|
|
233
|
-
middlewareData,
|
|
234
|
-
rects,
|
|
235
|
-
platform: platform2,
|
|
236
|
-
elements: {
|
|
237
|
-
reference,
|
|
238
|
-
floating
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
x = nextX != null ? nextX : x;
|
|
242
|
-
y = nextY != null ? nextY : y;
|
|
243
|
-
middlewareData = {
|
|
244
|
-
...middlewareData,
|
|
245
|
-
[name]: {
|
|
246
|
-
...middlewareData[name],
|
|
247
|
-
...data
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
if (reset && resetCount <= 50) {
|
|
251
|
-
resetCount++;
|
|
252
|
-
if (typeof reset === "object") {
|
|
253
|
-
if (reset.placement) {
|
|
254
|
-
statefulPlacement = reset.placement;
|
|
255
|
-
}
|
|
256
|
-
if (reset.rects) {
|
|
257
|
-
rects = reset.rects === true ? await platform2.getElementRects({
|
|
258
|
-
reference,
|
|
259
|
-
floating,
|
|
260
|
-
strategy
|
|
261
|
-
}) : reset.rects;
|
|
262
|
-
}
|
|
263
|
-
({
|
|
264
|
-
x,
|
|
265
|
-
y
|
|
266
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
267
|
-
}
|
|
268
|
-
i = -1;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
x,
|
|
273
|
-
y,
|
|
274
|
-
placement: statefulPlacement,
|
|
275
|
-
strategy,
|
|
276
|
-
middlewareData
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
async function detectOverflow(state, options) {
|
|
280
|
-
var _await$platform$isEle;
|
|
281
|
-
if (options === void 0) {
|
|
282
|
-
options = {};
|
|
283
|
-
}
|
|
284
|
-
const {
|
|
285
|
-
x,
|
|
286
|
-
y,
|
|
287
|
-
platform: platform2,
|
|
288
|
-
rects,
|
|
289
|
-
elements,
|
|
290
|
-
strategy
|
|
291
|
-
} = state;
|
|
292
|
-
const {
|
|
293
|
-
boundary = "clippingAncestors",
|
|
294
|
-
rootBoundary = "viewport",
|
|
295
|
-
elementContext = "floating",
|
|
296
|
-
altBoundary = false,
|
|
297
|
-
padding = 0
|
|
298
|
-
} = evaluate(options, state);
|
|
299
|
-
const paddingObject = getPaddingObject(padding);
|
|
300
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
301
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
302
|
-
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
303
|
-
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
304
|
-
boundary,
|
|
305
|
-
rootBoundary,
|
|
306
|
-
strategy
|
|
307
|
-
}));
|
|
308
|
-
const rect = elementContext === "floating" ? {
|
|
309
|
-
x,
|
|
310
|
-
y,
|
|
311
|
-
width: rects.floating.width,
|
|
312
|
-
height: rects.floating.height
|
|
313
|
-
} : rects.reference;
|
|
314
|
-
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
315
|
-
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
316
|
-
x: 1,
|
|
317
|
-
y: 1
|
|
318
|
-
} : {
|
|
319
|
-
x: 1,
|
|
320
|
-
y: 1
|
|
321
|
-
};
|
|
322
|
-
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
323
|
-
elements,
|
|
324
|
-
rect,
|
|
325
|
-
offsetParent,
|
|
326
|
-
strategy
|
|
327
|
-
}) : rect);
|
|
328
|
-
return {
|
|
329
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
330
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
331
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
332
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
const arrow$1 = (options) => ({
|
|
336
|
-
name: "arrow",
|
|
337
|
-
options,
|
|
338
|
-
async fn(state) {
|
|
339
|
-
const {
|
|
340
|
-
x,
|
|
341
|
-
y,
|
|
342
|
-
placement,
|
|
343
|
-
rects,
|
|
344
|
-
platform: platform2,
|
|
345
|
-
elements,
|
|
346
|
-
middlewareData
|
|
347
|
-
} = state;
|
|
348
|
-
const {
|
|
349
|
-
element,
|
|
350
|
-
padding = 0
|
|
351
|
-
} = evaluate(options, state) || {};
|
|
352
|
-
if (element == null) {
|
|
353
|
-
return {};
|
|
354
|
-
}
|
|
355
|
-
const paddingObject = getPaddingObject(padding);
|
|
356
|
-
const coords = {
|
|
357
|
-
x,
|
|
358
|
-
y
|
|
359
|
-
};
|
|
360
|
-
const axis = getAlignmentAxis(placement);
|
|
361
|
-
const length = getAxisLength(axis);
|
|
362
|
-
const arrowDimensions = await platform2.getDimensions(element);
|
|
363
|
-
const isYAxis = axis === "y";
|
|
364
|
-
const minProp = isYAxis ? "top" : "left";
|
|
365
|
-
const maxProp = isYAxis ? "bottom" : "right";
|
|
366
|
-
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
367
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
368
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
369
|
-
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
370
|
-
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
371
|
-
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
372
|
-
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
373
|
-
}
|
|
374
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
375
|
-
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
376
|
-
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
377
|
-
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
378
|
-
const min$1 = minPadding;
|
|
379
|
-
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
380
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
381
|
-
const offset2 = clamp(min$1, center, max2);
|
|
382
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
383
|
-
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
384
|
-
return {
|
|
385
|
-
[axis]: coords[axis] + alignmentOffset,
|
|
386
|
-
data: {
|
|
387
|
-
[axis]: offset2,
|
|
388
|
-
centerOffset: center - offset2 - alignmentOffset,
|
|
389
|
-
...shouldAddOffset && {
|
|
390
|
-
alignmentOffset
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
reset: shouldAddOffset
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
const flip$1 = function(options) {
|
|
398
|
-
if (options === void 0) {
|
|
399
|
-
options = {};
|
|
400
|
-
}
|
|
401
|
-
return {
|
|
402
|
-
name: "flip",
|
|
403
|
-
options,
|
|
404
|
-
async fn(state) {
|
|
405
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
406
|
-
const {
|
|
407
|
-
placement,
|
|
408
|
-
middlewareData,
|
|
409
|
-
rects,
|
|
410
|
-
initialPlacement,
|
|
411
|
-
platform: platform2,
|
|
412
|
-
elements
|
|
413
|
-
} = state;
|
|
414
|
-
const {
|
|
415
|
-
mainAxis: checkMainAxis = true,
|
|
416
|
-
crossAxis: checkCrossAxis = true,
|
|
417
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
418
|
-
fallbackStrategy = "bestFit",
|
|
419
|
-
fallbackAxisSideDirection = "none",
|
|
420
|
-
flipAlignment = true,
|
|
421
|
-
...detectOverflowOptions
|
|
422
|
-
} = evaluate(options, state);
|
|
423
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
424
|
-
return {};
|
|
425
|
-
}
|
|
426
|
-
const side = getSide(placement);
|
|
427
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
428
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
429
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
430
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
431
|
-
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
432
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
433
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
434
|
-
}
|
|
435
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
436
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
437
|
-
const overflows = [];
|
|
438
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
439
|
-
if (checkMainAxis) {
|
|
440
|
-
overflows.push(overflow[side]);
|
|
441
|
-
}
|
|
442
|
-
if (checkCrossAxis) {
|
|
443
|
-
const sides = getAlignmentSides(placement, rects, rtl);
|
|
444
|
-
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
445
|
-
}
|
|
446
|
-
overflowsData = [...overflowsData, {
|
|
447
|
-
placement,
|
|
448
|
-
overflows
|
|
449
|
-
}];
|
|
450
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
451
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
452
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
453
|
-
const nextPlacement = placements[nextIndex];
|
|
454
|
-
if (nextPlacement) {
|
|
455
|
-
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
456
|
-
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
457
|
-
// overflows the main axis.
|
|
458
|
-
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
459
|
-
return {
|
|
460
|
-
data: {
|
|
461
|
-
index: nextIndex,
|
|
462
|
-
overflows: overflowsData
|
|
463
|
-
},
|
|
464
|
-
reset: {
|
|
465
|
-
placement: nextPlacement
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
471
|
-
if (!resetPlacement) {
|
|
472
|
-
switch (fallbackStrategy) {
|
|
473
|
-
case "bestFit": {
|
|
474
|
-
var _overflowsData$filter2;
|
|
475
|
-
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
476
|
-
if (hasFallbackAxisSideDirection) {
|
|
477
|
-
const currentSideAxis = getSideAxis(d.placement);
|
|
478
|
-
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
479
|
-
// reading directions favoring greater width.
|
|
480
|
-
currentSideAxis === "y";
|
|
481
|
-
}
|
|
482
|
-
return true;
|
|
483
|
-
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
484
|
-
if (placement2) {
|
|
485
|
-
resetPlacement = placement2;
|
|
486
|
-
}
|
|
487
|
-
break;
|
|
488
|
-
}
|
|
489
|
-
case "initialPlacement":
|
|
490
|
-
resetPlacement = initialPlacement;
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (placement !== resetPlacement) {
|
|
495
|
-
return {
|
|
496
|
-
reset: {
|
|
497
|
-
placement: resetPlacement
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return {};
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
};
|
|
506
|
-
const originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
507
|
-
async function convertValueToCoords(state, options) {
|
|
508
|
-
const {
|
|
509
|
-
placement,
|
|
510
|
-
platform: platform2,
|
|
511
|
-
elements
|
|
512
|
-
} = state;
|
|
513
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
514
|
-
const side = getSide(placement);
|
|
515
|
-
const alignment = getAlignment(placement);
|
|
516
|
-
const isVertical = getSideAxis(placement) === "y";
|
|
517
|
-
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
518
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
519
|
-
const rawValue = evaluate(options, state);
|
|
520
|
-
let {
|
|
521
|
-
mainAxis,
|
|
522
|
-
crossAxis,
|
|
523
|
-
alignmentAxis
|
|
524
|
-
} = typeof rawValue === "number" ? {
|
|
525
|
-
mainAxis: rawValue,
|
|
526
|
-
crossAxis: 0,
|
|
527
|
-
alignmentAxis: null
|
|
528
|
-
} : {
|
|
529
|
-
mainAxis: rawValue.mainAxis || 0,
|
|
530
|
-
crossAxis: rawValue.crossAxis || 0,
|
|
531
|
-
alignmentAxis: rawValue.alignmentAxis
|
|
532
|
-
};
|
|
533
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
534
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
535
|
-
}
|
|
536
|
-
return isVertical ? {
|
|
537
|
-
x: crossAxis * crossAxisMulti,
|
|
538
|
-
y: mainAxis * mainAxisMulti
|
|
539
|
-
} : {
|
|
540
|
-
x: mainAxis * mainAxisMulti,
|
|
541
|
-
y: crossAxis * crossAxisMulti
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
const offset$1 = function(options) {
|
|
545
|
-
if (options === void 0) {
|
|
546
|
-
options = 0;
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
name: "offset",
|
|
550
|
-
options,
|
|
551
|
-
async fn(state) {
|
|
552
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
553
|
-
const {
|
|
554
|
-
x,
|
|
555
|
-
y,
|
|
556
|
-
placement,
|
|
557
|
-
middlewareData
|
|
558
|
-
} = state;
|
|
559
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
560
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
561
|
-
return {};
|
|
562
|
-
}
|
|
563
|
-
return {
|
|
564
|
-
x: x + diffCoords.x,
|
|
565
|
-
y: y + diffCoords.y,
|
|
566
|
-
data: {
|
|
567
|
-
...diffCoords,
|
|
568
|
-
placement
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
};
|
|
574
|
-
const shift$1 = function(options) {
|
|
575
|
-
if (options === void 0) {
|
|
576
|
-
options = {};
|
|
577
|
-
}
|
|
578
|
-
return {
|
|
579
|
-
name: "shift",
|
|
580
|
-
options,
|
|
581
|
-
async fn(state) {
|
|
582
|
-
const {
|
|
583
|
-
x,
|
|
584
|
-
y,
|
|
585
|
-
placement
|
|
586
|
-
} = state;
|
|
587
|
-
const {
|
|
588
|
-
mainAxis: checkMainAxis = true,
|
|
589
|
-
crossAxis: checkCrossAxis = false,
|
|
590
|
-
limiter = {
|
|
591
|
-
fn: (_ref) => {
|
|
592
|
-
let {
|
|
593
|
-
x: x2,
|
|
594
|
-
y: y2
|
|
595
|
-
} = _ref;
|
|
596
|
-
return {
|
|
597
|
-
x: x2,
|
|
598
|
-
y: y2
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
...detectOverflowOptions
|
|
603
|
-
} = evaluate(options, state);
|
|
604
|
-
const coords = {
|
|
605
|
-
x,
|
|
606
|
-
y
|
|
607
|
-
};
|
|
608
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
609
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
610
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
611
|
-
let mainAxisCoord = coords[mainAxis];
|
|
612
|
-
let crossAxisCoord = coords[crossAxis];
|
|
613
|
-
if (checkMainAxis) {
|
|
614
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
615
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
616
|
-
const min2 = mainAxisCoord + overflow[minSide];
|
|
617
|
-
const max2 = mainAxisCoord - overflow[maxSide];
|
|
618
|
-
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
619
|
-
}
|
|
620
|
-
if (checkCrossAxis) {
|
|
621
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
622
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
623
|
-
const min2 = crossAxisCoord + overflow[minSide];
|
|
624
|
-
const max2 = crossAxisCoord - overflow[maxSide];
|
|
625
|
-
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
626
|
-
}
|
|
627
|
-
const limitedCoords = limiter.fn({
|
|
628
|
-
...state,
|
|
629
|
-
[mainAxis]: mainAxisCoord,
|
|
630
|
-
[crossAxis]: crossAxisCoord
|
|
631
|
-
});
|
|
632
|
-
return {
|
|
633
|
-
...limitedCoords,
|
|
634
|
-
data: {
|
|
635
|
-
x: limitedCoords.x - x,
|
|
636
|
-
y: limitedCoords.y - y,
|
|
637
|
-
enabled: {
|
|
638
|
-
[mainAxis]: checkMainAxis,
|
|
639
|
-
[crossAxis]: checkCrossAxis
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
function hasWindow() {
|
|
647
|
-
return typeof window !== "undefined";
|
|
648
|
-
}
|
|
649
|
-
function getNodeName(node) {
|
|
650
|
-
if (isNode(node)) {
|
|
651
|
-
return (node.nodeName || "").toLowerCase();
|
|
652
|
-
}
|
|
653
|
-
return "#document";
|
|
654
|
-
}
|
|
655
|
-
function getWindow(node) {
|
|
656
|
-
var _node$ownerDocument;
|
|
657
|
-
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
658
|
-
}
|
|
659
|
-
function getDocumentElement(node) {
|
|
660
|
-
var _ref;
|
|
661
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
662
|
-
}
|
|
663
|
-
function isNode(value) {
|
|
664
|
-
if (!hasWindow()) {
|
|
665
|
-
return false;
|
|
666
|
-
}
|
|
667
|
-
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
668
|
-
}
|
|
669
|
-
function isElement(value) {
|
|
670
|
-
if (!hasWindow()) {
|
|
671
|
-
return false;
|
|
672
|
-
}
|
|
673
|
-
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
674
|
-
}
|
|
675
|
-
function isHTMLElement(value) {
|
|
676
|
-
if (!hasWindow()) {
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
|
-
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
680
|
-
}
|
|
681
|
-
function isShadowRoot(value) {
|
|
682
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
686
|
-
}
|
|
687
|
-
const invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
688
|
-
function isOverflowElement(element) {
|
|
689
|
-
const {
|
|
690
|
-
overflow,
|
|
691
|
-
overflowX,
|
|
692
|
-
overflowY,
|
|
693
|
-
display
|
|
694
|
-
} = getComputedStyle$1(element);
|
|
695
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
696
|
-
}
|
|
697
|
-
const tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
698
|
-
function isTableElement(element) {
|
|
699
|
-
return tableElements.has(getNodeName(element));
|
|
700
|
-
}
|
|
701
|
-
const topLayerSelectors = [":popover-open", ":modal"];
|
|
702
|
-
function isTopLayer(element) {
|
|
703
|
-
return topLayerSelectors.some((selector) => {
|
|
704
|
-
try {
|
|
705
|
-
return element.matches(selector);
|
|
706
|
-
} catch (_e) {
|
|
707
|
-
return false;
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
const transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
|
|
712
|
-
const willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
|
|
713
|
-
const containValues = ["paint", "layout", "strict", "content"];
|
|
714
|
-
function isContainingBlock(elementOrCss) {
|
|
715
|
-
const webkit = isWebKit();
|
|
716
|
-
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
717
|
-
return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
|
|
718
|
-
}
|
|
719
|
-
function getContainingBlock(element) {
|
|
720
|
-
let currentNode = getParentNode(element);
|
|
721
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
722
|
-
if (isContainingBlock(currentNode)) {
|
|
723
|
-
return currentNode;
|
|
724
|
-
} else if (isTopLayer(currentNode)) {
|
|
725
|
-
return null;
|
|
726
|
-
}
|
|
727
|
-
currentNode = getParentNode(currentNode);
|
|
728
|
-
}
|
|
729
|
-
return null;
|
|
730
|
-
}
|
|
731
|
-
function isWebKit() {
|
|
732
|
-
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
733
|
-
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
734
|
-
}
|
|
735
|
-
const lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
736
|
-
function isLastTraversableNode(node) {
|
|
737
|
-
return lastTraversableNodeNames.has(getNodeName(node));
|
|
738
|
-
}
|
|
739
|
-
function getComputedStyle$1(element) {
|
|
740
|
-
return getWindow(element).getComputedStyle(element);
|
|
741
|
-
}
|
|
742
|
-
function getNodeScroll(element) {
|
|
743
|
-
if (isElement(element)) {
|
|
744
|
-
return {
|
|
745
|
-
scrollLeft: element.scrollLeft,
|
|
746
|
-
scrollTop: element.scrollTop
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
return {
|
|
750
|
-
scrollLeft: element.scrollX,
|
|
751
|
-
scrollTop: element.scrollY
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function getParentNode(node) {
|
|
755
|
-
if (getNodeName(node) === "html") {
|
|
756
|
-
return node;
|
|
757
|
-
}
|
|
758
|
-
const result = (
|
|
759
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
760
|
-
node.assignedSlot || // DOM Element detected.
|
|
761
|
-
node.parentNode || // ShadowRoot detected.
|
|
762
|
-
isShadowRoot(node) && node.host || // Fallback.
|
|
763
|
-
getDocumentElement(node)
|
|
764
|
-
);
|
|
765
|
-
return isShadowRoot(result) ? result.host : result;
|
|
766
|
-
}
|
|
767
|
-
function getNearestOverflowAncestor(node) {
|
|
768
|
-
const parentNode = getParentNode(node);
|
|
769
|
-
if (isLastTraversableNode(parentNode)) {
|
|
770
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
771
|
-
}
|
|
772
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
773
|
-
return parentNode;
|
|
774
|
-
}
|
|
775
|
-
return getNearestOverflowAncestor(parentNode);
|
|
776
|
-
}
|
|
777
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
778
|
-
var _node$ownerDocument2;
|
|
779
|
-
if (list === void 0) {
|
|
780
|
-
list = [];
|
|
781
|
-
}
|
|
782
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
783
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
784
|
-
const win = getWindow(scrollableAncestor);
|
|
785
|
-
if (isBody) {
|
|
786
|
-
getFrameElement(win);
|
|
787
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], []);
|
|
788
|
-
}
|
|
789
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, []));
|
|
790
|
-
}
|
|
791
|
-
function getFrameElement(win) {
|
|
792
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
793
|
-
}
|
|
794
|
-
function getCssDimensions(element) {
|
|
795
|
-
const css = getComputedStyle$1(element);
|
|
796
|
-
let width = parseFloat(css.width) || 0;
|
|
797
|
-
let height = parseFloat(css.height) || 0;
|
|
798
|
-
const hasOffset = isHTMLElement(element);
|
|
799
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
800
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
801
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
802
|
-
if (shouldFallback) {
|
|
803
|
-
width = offsetWidth;
|
|
804
|
-
height = offsetHeight;
|
|
805
|
-
}
|
|
806
|
-
return {
|
|
807
|
-
width,
|
|
808
|
-
height,
|
|
809
|
-
$: shouldFallback
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
function unwrapElement(element) {
|
|
813
|
-
return !isElement(element) ? element.contextElement : element;
|
|
814
|
-
}
|
|
815
|
-
function getScale(element) {
|
|
816
|
-
const domElement = unwrapElement(element);
|
|
817
|
-
if (!isHTMLElement(domElement)) {
|
|
818
|
-
return createCoords(1);
|
|
819
|
-
}
|
|
820
|
-
const rect = domElement.getBoundingClientRect();
|
|
821
|
-
const {
|
|
822
|
-
width,
|
|
823
|
-
height,
|
|
824
|
-
$
|
|
825
|
-
} = getCssDimensions(domElement);
|
|
826
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
827
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
828
|
-
if (!x || !Number.isFinite(x)) {
|
|
829
|
-
x = 1;
|
|
830
|
-
}
|
|
831
|
-
if (!y || !Number.isFinite(y)) {
|
|
832
|
-
y = 1;
|
|
833
|
-
}
|
|
834
|
-
return {
|
|
835
|
-
x,
|
|
836
|
-
y
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
840
|
-
function getVisualOffsets(element) {
|
|
841
|
-
const win = getWindow(element);
|
|
842
|
-
if (!isWebKit() || !win.visualViewport) {
|
|
843
|
-
return noOffsets;
|
|
844
|
-
}
|
|
845
|
-
return {
|
|
846
|
-
x: win.visualViewport.offsetLeft,
|
|
847
|
-
y: win.visualViewport.offsetTop
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
851
|
-
if (isFixed === void 0) {
|
|
852
|
-
isFixed = false;
|
|
853
|
-
}
|
|
854
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
855
|
-
return false;
|
|
856
|
-
}
|
|
857
|
-
return isFixed;
|
|
858
|
-
}
|
|
859
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
860
|
-
if (includeScale === void 0) {
|
|
861
|
-
includeScale = false;
|
|
862
|
-
}
|
|
863
|
-
if (isFixedStrategy === void 0) {
|
|
864
|
-
isFixedStrategy = false;
|
|
865
|
-
}
|
|
866
|
-
const clientRect = element.getBoundingClientRect();
|
|
867
|
-
const domElement = unwrapElement(element);
|
|
868
|
-
let scale = createCoords(1);
|
|
869
|
-
if (includeScale) {
|
|
870
|
-
if (offsetParent) {
|
|
871
|
-
if (isElement(offsetParent)) {
|
|
872
|
-
scale = getScale(offsetParent);
|
|
873
|
-
}
|
|
874
|
-
} else {
|
|
875
|
-
scale = getScale(element);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
879
|
-
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
880
|
-
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
881
|
-
let width = clientRect.width / scale.x;
|
|
882
|
-
let height = clientRect.height / scale.y;
|
|
883
|
-
if (domElement) {
|
|
884
|
-
const win = getWindow(domElement);
|
|
885
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
886
|
-
let currentWin = win;
|
|
887
|
-
let currentIFrame = getFrameElement(currentWin);
|
|
888
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
889
|
-
const iframeScale = getScale(currentIFrame);
|
|
890
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
891
|
-
const css = getComputedStyle$1(currentIFrame);
|
|
892
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
893
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
894
|
-
x *= iframeScale.x;
|
|
895
|
-
y *= iframeScale.y;
|
|
896
|
-
width *= iframeScale.x;
|
|
897
|
-
height *= iframeScale.y;
|
|
898
|
-
x += left;
|
|
899
|
-
y += top;
|
|
900
|
-
currentWin = getWindow(currentIFrame);
|
|
901
|
-
currentIFrame = getFrameElement(currentWin);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
return rectToClientRect({
|
|
905
|
-
width,
|
|
906
|
-
height,
|
|
907
|
-
x,
|
|
908
|
-
y
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
function getWindowScrollBarX(element, rect) {
|
|
912
|
-
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
913
|
-
if (!rect) {
|
|
914
|
-
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
915
|
-
}
|
|
916
|
-
return rect.left + leftScroll;
|
|
917
|
-
}
|
|
918
|
-
function getHTMLOffset(documentElement, scroll) {
|
|
919
|
-
const htmlRect = documentElement.getBoundingClientRect();
|
|
920
|
-
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
921
|
-
const y = htmlRect.top + scroll.scrollTop;
|
|
922
|
-
return {
|
|
923
|
-
x,
|
|
924
|
-
y
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
928
|
-
let {
|
|
929
|
-
elements,
|
|
930
|
-
rect,
|
|
931
|
-
offsetParent,
|
|
932
|
-
strategy
|
|
933
|
-
} = _ref;
|
|
934
|
-
const isFixed = strategy === "fixed";
|
|
935
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
936
|
-
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
937
|
-
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
938
|
-
return rect;
|
|
939
|
-
}
|
|
940
|
-
let scroll = {
|
|
941
|
-
scrollLeft: 0,
|
|
942
|
-
scrollTop: 0
|
|
943
|
-
};
|
|
944
|
-
let scale = createCoords(1);
|
|
945
|
-
const offsets = createCoords(0);
|
|
946
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
947
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
948
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
949
|
-
scroll = getNodeScroll(offsetParent);
|
|
950
|
-
}
|
|
951
|
-
if (isHTMLElement(offsetParent)) {
|
|
952
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
953
|
-
scale = getScale(offsetParent);
|
|
954
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
955
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
959
|
-
return {
|
|
960
|
-
width: rect.width * scale.x,
|
|
961
|
-
height: rect.height * scale.y,
|
|
962
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
963
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
function getClientRects(element) {
|
|
967
|
-
return Array.from(element.getClientRects());
|
|
968
|
-
}
|
|
969
|
-
function getDocumentRect(element) {
|
|
970
|
-
const html = getDocumentElement(element);
|
|
971
|
-
const scroll = getNodeScroll(element);
|
|
972
|
-
const body = element.ownerDocument.body;
|
|
973
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
974
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
975
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
976
|
-
const y = -scroll.scrollTop;
|
|
977
|
-
if (getComputedStyle$1(body).direction === "rtl") {
|
|
978
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
979
|
-
}
|
|
980
|
-
return {
|
|
981
|
-
width,
|
|
982
|
-
height,
|
|
983
|
-
x,
|
|
984
|
-
y
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
const SCROLLBAR_MAX = 25;
|
|
988
|
-
function getViewportRect(element, strategy) {
|
|
989
|
-
const win = getWindow(element);
|
|
990
|
-
const html = getDocumentElement(element);
|
|
991
|
-
const visualViewport = win.visualViewport;
|
|
992
|
-
let width = html.clientWidth;
|
|
993
|
-
let height = html.clientHeight;
|
|
994
|
-
let x = 0;
|
|
995
|
-
let y = 0;
|
|
996
|
-
if (visualViewport) {
|
|
997
|
-
width = visualViewport.width;
|
|
998
|
-
height = visualViewport.height;
|
|
999
|
-
const visualViewportBased = isWebKit();
|
|
1000
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
1001
|
-
x = visualViewport.offsetLeft;
|
|
1002
|
-
y = visualViewport.offsetTop;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1006
|
-
if (windowScrollbarX <= 0) {
|
|
1007
|
-
const doc = html.ownerDocument;
|
|
1008
|
-
const body = doc.body;
|
|
1009
|
-
const bodyStyles = getComputedStyle(body);
|
|
1010
|
-
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1011
|
-
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1012
|
-
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1013
|
-
width -= clippingStableScrollbarWidth;
|
|
1014
|
-
}
|
|
1015
|
-
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1016
|
-
width += windowScrollbarX;
|
|
1017
|
-
}
|
|
1018
|
-
return {
|
|
1019
|
-
width,
|
|
1020
|
-
height,
|
|
1021
|
-
x,
|
|
1022
|
-
y
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
const absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
1026
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1027
|
-
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1028
|
-
const top = clientRect.top + element.clientTop;
|
|
1029
|
-
const left = clientRect.left + element.clientLeft;
|
|
1030
|
-
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1031
|
-
const width = element.clientWidth * scale.x;
|
|
1032
|
-
const height = element.clientHeight * scale.y;
|
|
1033
|
-
const x = left * scale.x;
|
|
1034
|
-
const y = top * scale.y;
|
|
1035
|
-
return {
|
|
1036
|
-
width,
|
|
1037
|
-
height,
|
|
1038
|
-
x,
|
|
1039
|
-
y
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1043
|
-
let rect;
|
|
1044
|
-
if (clippingAncestor === "viewport") {
|
|
1045
|
-
rect = getViewportRect(element, strategy);
|
|
1046
|
-
} else if (clippingAncestor === "document") {
|
|
1047
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
1048
|
-
} else if (isElement(clippingAncestor)) {
|
|
1049
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1050
|
-
} else {
|
|
1051
|
-
const visualOffsets = getVisualOffsets(element);
|
|
1052
|
-
rect = {
|
|
1053
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
1054
|
-
y: clippingAncestor.y - visualOffsets.y,
|
|
1055
|
-
width: clippingAncestor.width,
|
|
1056
|
-
height: clippingAncestor.height
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
return rectToClientRect(rect);
|
|
1060
|
-
}
|
|
1061
|
-
function hasFixedPositionAncestor(element, stopNode) {
|
|
1062
|
-
const parentNode = getParentNode(element);
|
|
1063
|
-
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1064
|
-
return false;
|
|
1065
|
-
}
|
|
1066
|
-
return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1067
|
-
}
|
|
1068
|
-
function getClippingElementAncestors(element, cache) {
|
|
1069
|
-
const cachedResult = cache.get(element);
|
|
1070
|
-
if (cachedResult) {
|
|
1071
|
-
return cachedResult;
|
|
1072
|
-
}
|
|
1073
|
-
let result = getOverflowAncestors(element, []).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1074
|
-
let currentContainingBlockComputedStyle = null;
|
|
1075
|
-
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
1076
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1077
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1078
|
-
const computedStyle = getComputedStyle$1(currentNode);
|
|
1079
|
-
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1080
|
-
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
1081
|
-
currentContainingBlockComputedStyle = null;
|
|
1082
|
-
}
|
|
1083
|
-
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1084
|
-
if (shouldDropCurrentNode) {
|
|
1085
|
-
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1086
|
-
} else {
|
|
1087
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1088
|
-
}
|
|
1089
|
-
currentNode = getParentNode(currentNode);
|
|
1090
|
-
}
|
|
1091
|
-
cache.set(element, result);
|
|
1092
|
-
return result;
|
|
1093
|
-
}
|
|
1094
|
-
function getClippingRect(_ref) {
|
|
1095
|
-
let {
|
|
1096
|
-
element,
|
|
1097
|
-
boundary,
|
|
1098
|
-
rootBoundary,
|
|
1099
|
-
strategy
|
|
1100
|
-
} = _ref;
|
|
1101
|
-
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1102
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1103
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1104
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1105
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1106
|
-
accRect.top = max(rect.top, accRect.top);
|
|
1107
|
-
accRect.right = min(rect.right, accRect.right);
|
|
1108
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1109
|
-
accRect.left = max(rect.left, accRect.left);
|
|
1110
|
-
return accRect;
|
|
1111
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1112
|
-
return {
|
|
1113
|
-
width: clippingRect.right - clippingRect.left,
|
|
1114
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1115
|
-
x: clippingRect.left,
|
|
1116
|
-
y: clippingRect.top
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
|
-
function getDimensions(element) {
|
|
1120
|
-
const {
|
|
1121
|
-
width,
|
|
1122
|
-
height
|
|
1123
|
-
} = getCssDimensions(element);
|
|
1124
|
-
return {
|
|
1125
|
-
width,
|
|
1126
|
-
height
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1130
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1131
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1132
|
-
const isFixed = strategy === "fixed";
|
|
1133
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1134
|
-
let scroll = {
|
|
1135
|
-
scrollLeft: 0,
|
|
1136
|
-
scrollTop: 0
|
|
1137
|
-
};
|
|
1138
|
-
const offsets = createCoords(0);
|
|
1139
|
-
function setLeftRTLScrollbarOffset() {
|
|
1140
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1141
|
-
}
|
|
1142
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1143
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1144
|
-
scroll = getNodeScroll(offsetParent);
|
|
1145
|
-
}
|
|
1146
|
-
if (isOffsetParentAnElement) {
|
|
1147
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1148
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1149
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1150
|
-
} else if (documentElement) {
|
|
1151
|
-
setLeftRTLScrollbarOffset();
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1155
|
-
setLeftRTLScrollbarOffset();
|
|
1156
|
-
}
|
|
1157
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1158
|
-
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1159
|
-
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1160
|
-
return {
|
|
1161
|
-
x,
|
|
1162
|
-
y,
|
|
1163
|
-
width: rect.width,
|
|
1164
|
-
height: rect.height
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
|
-
function isStaticPositioned(element) {
|
|
1168
|
-
return getComputedStyle$1(element).position === "static";
|
|
1169
|
-
}
|
|
1170
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
1171
|
-
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
|
|
1172
|
-
return null;
|
|
1173
|
-
}
|
|
1174
|
-
if (polyfill) {
|
|
1175
|
-
return polyfill(element);
|
|
1176
|
-
}
|
|
1177
|
-
let rawOffsetParent = element.offsetParent;
|
|
1178
|
-
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1179
|
-
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1180
|
-
}
|
|
1181
|
-
return rawOffsetParent;
|
|
1182
|
-
}
|
|
1183
|
-
function getOffsetParent(element, polyfill) {
|
|
1184
|
-
const win = getWindow(element);
|
|
1185
|
-
if (isTopLayer(element)) {
|
|
1186
|
-
return win;
|
|
1187
|
-
}
|
|
1188
|
-
if (!isHTMLElement(element)) {
|
|
1189
|
-
let svgOffsetParent = getParentNode(element);
|
|
1190
|
-
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1191
|
-
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1192
|
-
return svgOffsetParent;
|
|
1193
|
-
}
|
|
1194
|
-
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1195
|
-
}
|
|
1196
|
-
return win;
|
|
1197
|
-
}
|
|
1198
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1199
|
-
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1200
|
-
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1201
|
-
}
|
|
1202
|
-
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1203
|
-
return win;
|
|
1204
|
-
}
|
|
1205
|
-
return offsetParent || getContainingBlock(element) || win;
|
|
1206
|
-
}
|
|
1207
|
-
const getElementRects = async function(data) {
|
|
1208
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1209
|
-
const getDimensionsFn = this.getDimensions;
|
|
1210
|
-
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1211
|
-
return {
|
|
1212
|
-
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1213
|
-
floating: {
|
|
1214
|
-
x: 0,
|
|
1215
|
-
y: 0,
|
|
1216
|
-
width: floatingDimensions.width,
|
|
1217
|
-
height: floatingDimensions.height
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
};
|
|
1221
|
-
function isRTL(element) {
|
|
1222
|
-
return getComputedStyle$1(element).direction === "rtl";
|
|
1223
|
-
}
|
|
1224
|
-
const platform = {
|
|
1225
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1226
|
-
getDocumentElement,
|
|
1227
|
-
getClippingRect,
|
|
1228
|
-
getOffsetParent,
|
|
1229
|
-
getElementRects,
|
|
1230
|
-
getClientRects,
|
|
1231
|
-
getDimensions,
|
|
1232
|
-
getScale,
|
|
1233
|
-
isElement,
|
|
1234
|
-
isRTL
|
|
1235
|
-
};
|
|
1236
|
-
const offset = offset$1;
|
|
1237
|
-
const shift = shift$1;
|
|
1238
|
-
const flip = flip$1;
|
|
1239
|
-
const arrow = arrow$1;
|
|
1240
|
-
const computePosition = (reference, floating, options) => {
|
|
1241
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1242
|
-
const mergedOptions = {
|
|
1243
|
-
platform,
|
|
1244
|
-
...options
|
|
1245
|
-
};
|
|
1246
|
-
const platformWithCache = {
|
|
1247
|
-
...mergedOptions.platform,
|
|
1248
|
-
_c: cache
|
|
1249
|
-
};
|
|
1250
|
-
return computePosition$1(reference, floating, {
|
|
1251
|
-
...mergedOptions,
|
|
1252
|
-
platform: platformWithCache
|
|
1253
|
-
});
|
|
1254
|
-
};
|
|
1255
|
-
const ANIMATION_DURATION = 250;
|
|
1256
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1257
|
-
...{
|
|
1258
|
-
name: "PopupContent"
|
|
1259
|
-
},
|
|
1260
|
-
__name: "index",
|
|
1261
|
-
props: {
|
|
1262
|
-
content: null,
|
|
1263
|
-
visible: { type: Boolean, default: void 0 },
|
|
1264
|
-
defaultVisible: { type: Boolean },
|
|
1265
|
-
placement: { default: "top" },
|
|
1266
|
-
offset: { default: 8 },
|
|
1267
|
-
variant: { default: "light" },
|
|
1268
|
-
arrow: { type: Boolean, default: true },
|
|
1269
|
-
zIndex: null,
|
|
1270
|
-
target: null,
|
|
1271
|
-
root: { default: "body" },
|
|
1272
|
-
borderRadius: null,
|
|
1273
|
-
widthEqual: { type: Boolean, default: false },
|
|
1274
|
-
contentStyle: null
|
|
1275
|
-
},
|
|
1276
|
-
emits: ["contentMouseenter", "contentMouseleave"],
|
|
1277
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1278
|
-
const props = __props;
|
|
1279
|
-
const [currentZIndex, next] = useZIndex("popup");
|
|
1280
|
-
const show = ref(false);
|
|
1281
|
-
const contentRef = shallowRef(null);
|
|
1282
|
-
const arrowRef = shallowRef(null);
|
|
1283
|
-
const canvasRef = shallowRef(null);
|
|
1284
|
-
const floatingStyles = ref({});
|
|
1285
|
-
const arrowStyles = ref({});
|
|
1286
|
-
const arrowXOffset = ref(void 0);
|
|
1287
|
-
const arrowYOffset = ref(void 0);
|
|
1288
|
-
const popupFinalPlacement = ref(void 0);
|
|
1289
|
-
const popupRoughPlacement = computed(() => {
|
|
1290
|
-
const placement = props.placement.split("-")[0];
|
|
1291
|
-
return placement;
|
|
1292
|
-
});
|
|
1293
|
-
const popupSide = computed(() => {
|
|
1294
|
-
const side = props.placement.split("-")[1];
|
|
1295
|
-
return side || "middle";
|
|
1296
|
-
});
|
|
1297
|
-
const contentWidth = ref(void 0);
|
|
1298
|
-
async function updatePosition(element) {
|
|
1299
|
-
if (!inBrowser()) {
|
|
1300
|
-
return;
|
|
1301
|
-
}
|
|
1302
|
-
if (!contentRef.value || !arrowRef.value || !canvasRef.value) return;
|
|
1303
|
-
const contentComputedStyle = getComputedStyle(contentRef.value);
|
|
1304
|
-
const contentBorder = parseFloat(contentComputedStyle.borderLeftWidth) + parseFloat(contentComputedStyle.borderRightWidth);
|
|
1305
|
-
const addX = contentBorder / 2;
|
|
1306
|
-
const addY = (parseFloat(contentComputedStyle.borderTopWidth) + parseFloat(contentComputedStyle.borderBottomWidth)) / 2;
|
|
1307
|
-
if ((popupRoughPlacement.value === "top" || popupRoughPlacement.value === "bottom") && props.widthEqual) {
|
|
1308
|
-
const elementComputedStyle = getComputedStyle(element);
|
|
1309
|
-
const boxSizing = elementComputedStyle.boxSizing;
|
|
1310
|
-
const contentBoxSizing = contentComputedStyle.boxSizing;
|
|
1311
|
-
const padding = parseFloat(elementComputedStyle.paddingLeft) + parseFloat(elementComputedStyle.paddingRight);
|
|
1312
|
-
const contentPadding = parseFloat(contentComputedStyle.paddingLeft) + parseFloat(contentComputedStyle.paddingRight);
|
|
1313
|
-
const border = parseFloat(elementComputedStyle.borderLeftWidth) + parseFloat(elementComputedStyle.borderRightWidth);
|
|
1314
|
-
const width = parseFloat(elementComputedStyle.width);
|
|
1315
|
-
if (boxSizing === "border-box") {
|
|
1316
|
-
if (contentBoxSizing === "border-box") {
|
|
1317
|
-
contentWidth.value = width;
|
|
1318
|
-
} else {
|
|
1319
|
-
contentWidth.value = width - contentPadding - contentBorder;
|
|
1320
|
-
}
|
|
1321
|
-
} else {
|
|
1322
|
-
if (contentBoxSizing === "border-box") {
|
|
1323
|
-
contentWidth.value = width + padding + border;
|
|
1324
|
-
} else {
|
|
1325
|
-
contentWidth.value = width - contentPadding - contentBorder + padding + border;
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
await nextTick();
|
|
1329
|
-
} else {
|
|
1330
|
-
contentWidth.value = void 0;
|
|
1331
|
-
}
|
|
1332
|
-
const pixelSize = calcPixelSize();
|
|
1333
|
-
const borderRadius = Math.max(props.borderRadius || pixelSize, pixelSize);
|
|
1334
|
-
const ds = Math.max(
|
|
1335
|
-
0,
|
|
1336
|
-
borderRadius - calcWhenLeaveBaseline(pixelSize, borderRadius) + pixelSize
|
|
1337
|
-
);
|
|
1338
|
-
const data = await computePosition(element, contentRef.value, {
|
|
1339
|
-
placement: props.placement,
|
|
1340
|
-
middleware: [
|
|
1341
|
-
offset(props.offset),
|
|
1342
|
-
shift(),
|
|
1343
|
-
flip(),
|
|
1344
|
-
arrow({ element: arrowRef.value, padding: ds })
|
|
1345
|
-
]
|
|
1346
|
-
});
|
|
1347
|
-
const { x, y, middlewareData, placement } = data;
|
|
1348
|
-
floatingStyles.value = {
|
|
1349
|
-
left: `${x}px`,
|
|
1350
|
-
top: `${y}px`
|
|
1351
|
-
};
|
|
1352
|
-
const { x: arrowX, y: arrowY } = middlewareData.arrow ?? {};
|
|
1353
|
-
popupFinalPlacement.value = placement.split("-")[0];
|
|
1354
|
-
arrowStyles.value = {
|
|
1355
|
-
left: arrowX ? `${arrowX + addX}px` : void 0,
|
|
1356
|
-
top: arrowY ? `${arrowY + addY}px` : void 0
|
|
1357
|
-
};
|
|
1358
|
-
arrowXOffset.value = arrowX ? arrowX + addX : void 0;
|
|
1359
|
-
arrowYOffset.value = arrowY ? arrowY + addY : void 0;
|
|
1360
|
-
nextTick(() => {
|
|
1361
|
-
if (props.visible) {
|
|
1362
|
-
show.value = true;
|
|
1363
|
-
}
|
|
1364
|
-
});
|
|
1365
|
-
}
|
|
1366
|
-
async function openHandler(element) {
|
|
1367
|
-
setTimeout(() => {
|
|
1368
|
-
updatePosition(element);
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
async function closeHandler() {
|
|
1372
|
-
setTimeout(() => {
|
|
1373
|
-
show.value = false;
|
|
1374
|
-
popupFinalPlacement.value = void 0;
|
|
1375
|
-
}, ANIMATION_DURATION);
|
|
1376
|
-
}
|
|
1377
|
-
const processVisible = (value) => {
|
|
1378
|
-
if (!inBrowser()) {
|
|
1379
|
-
return;
|
|
1380
|
-
}
|
|
1381
|
-
if (value) {
|
|
1382
|
-
next();
|
|
1383
|
-
if (props.target instanceof HTMLElement) {
|
|
1384
|
-
openHandler(props.target);
|
|
1385
|
-
} else if (props.target && props.target.el instanceof HTMLElement) {
|
|
1386
|
-
openHandler(props.target.el);
|
|
1387
|
-
}
|
|
1388
|
-
} else {
|
|
1389
|
-
closeHandler();
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
|
-
watch(
|
|
1393
|
-
() => props.visible,
|
|
1394
|
-
(val) => {
|
|
1395
|
-
processVisible(!!val);
|
|
1396
|
-
}
|
|
1397
|
-
);
|
|
1398
|
-
const emits = __emit;
|
|
1399
|
-
const contentMouseenterHandler = (e) => {
|
|
1400
|
-
emits("contentMouseenter", e);
|
|
1401
|
-
};
|
|
1402
|
-
const contentMouseleaveHandler = (e) => {
|
|
1403
|
-
emits("contentMouseleave", e);
|
|
1404
|
-
};
|
|
1405
|
-
__expose({
|
|
1406
|
-
updateRenderState: () => {
|
|
1407
|
-
nextTick(() => {
|
|
1408
|
-
processVisible(!!props.visible);
|
|
1409
|
-
});
|
|
1410
|
-
},
|
|
1411
|
-
content: contentRef
|
|
1412
|
-
});
|
|
1413
|
-
const darkMode = useDarkMode();
|
|
1414
|
-
onMounted(() => {
|
|
1415
|
-
nextTick(() => {
|
|
1416
|
-
drawPixel();
|
|
1417
|
-
processVisible(!!props.visible);
|
|
1418
|
-
});
|
|
1419
|
-
});
|
|
1420
|
-
watch(
|
|
1421
|
-
[
|
|
1422
|
-
darkMode,
|
|
1423
|
-
popupFinalPlacement,
|
|
1424
|
-
arrowXOffset,
|
|
1425
|
-
arrowYOffset,
|
|
1426
|
-
show,
|
|
1427
|
-
() => props.variant,
|
|
1428
|
-
() => props.arrow
|
|
1429
|
-
],
|
|
1430
|
-
() => {
|
|
1431
|
-
drawPixel();
|
|
1432
|
-
}
|
|
1433
|
-
);
|
|
1434
|
-
const drawPixel = () => {
|
|
1435
|
-
if (!popupFinalPlacement.value) {
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
const preprocessData = canvasPreprocess(contentRef, canvasRef);
|
|
1439
|
-
if (!preprocessData) {
|
|
1440
|
-
return;
|
|
1441
|
-
}
|
|
1442
|
-
const { ctx, width, height } = preprocessData;
|
|
1443
|
-
const pixelSize = calcPixelSize();
|
|
1444
|
-
const borderRadius = fillArr(Math.max(props.borderRadius || pixelSize, pixelSize), 4);
|
|
1445
|
-
const offset2 = props.arrow ? pixelSize * 3 : 0;
|
|
1446
|
-
const offsetX = popupFinalPlacement.value === "left" || popupFinalPlacement.value === "right" ? offset2 : 0;
|
|
1447
|
-
const offsetY = popupFinalPlacement.value === "top" || popupFinalPlacement.value === "bottom" ? offset2 : 0;
|
|
1448
|
-
const borderColor = getBorderColor(props.variant);
|
|
1449
|
-
const center = calcBorderCornerCenter(
|
|
1450
|
-
borderRadius,
|
|
1451
|
-
width,
|
|
1452
|
-
height,
|
|
1453
|
-
pixelSize,
|
|
1454
|
-
offsetX,
|
|
1455
|
-
offsetY
|
|
1456
|
-
);
|
|
1457
|
-
const rad = BORDER_CORNER_RAD_RANGE;
|
|
1458
|
-
const offsetTop = popupFinalPlacement.value === "bottom" ? offset2 : 0;
|
|
1459
|
-
const offsetLeft = popupFinalPlacement.value === "right" ? offset2 : 0;
|
|
1460
|
-
drawBorder(
|
|
1461
|
-
ctx,
|
|
1462
|
-
width,
|
|
1463
|
-
height,
|
|
1464
|
-
center,
|
|
1465
|
-
borderRadius,
|
|
1466
|
-
rad,
|
|
1467
|
-
borderColor,
|
|
1468
|
-
pixelSize,
|
|
1469
|
-
offsetX,
|
|
1470
|
-
offsetY,
|
|
1471
|
-
offsetTop,
|
|
1472
|
-
offsetLeft
|
|
1473
|
-
);
|
|
1474
|
-
const backgroundColor = getBackgroundColor(props.variant);
|
|
1475
|
-
floodFill(
|
|
1476
|
-
ctx,
|
|
1477
|
-
Math.round((width - offsetX) / 2 + offsetLeft),
|
|
1478
|
-
Math.round((height - offsetY) / 2 + offsetTop),
|
|
1479
|
-
backgroundColor
|
|
1480
|
-
);
|
|
1481
|
-
if (props.arrow) {
|
|
1482
|
-
drawArrow(
|
|
1483
|
-
ctx,
|
|
1484
|
-
width,
|
|
1485
|
-
height,
|
|
1486
|
-
borderColor,
|
|
1487
|
-
backgroundColor,
|
|
1488
|
-
pixelSize,
|
|
1489
|
-
popupFinalPlacement.value,
|
|
1490
|
-
popupSide.value,
|
|
1491
|
-
arrowXOffset.value || 0,
|
|
1492
|
-
arrowYOffset.value || 0
|
|
1493
|
-
);
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
useResizeObserver(contentRef, drawPixel);
|
|
1497
|
-
useWatchGlobalCssVal(drawPixel);
|
|
1498
|
-
return (_ctx, _cache) => {
|
|
1499
|
-
return openBlock(), createBlock(Teleport, {
|
|
1500
|
-
to: props.root || "body"
|
|
1501
|
-
}, [
|
|
1502
|
-
createVNode(Transition, {
|
|
1503
|
-
name: "px-popup-content-fade__" + popupRoughPlacement.value,
|
|
1504
|
-
persisted: ""
|
|
1505
|
-
}, {
|
|
1506
|
-
default: withCtx(() => [
|
|
1507
|
-
withDirectives(createElementVNode(
|
|
1508
|
-
"div",
|
|
1509
|
-
mergeProps({
|
|
1510
|
-
ref_key: "contentRef",
|
|
1511
|
-
ref: contentRef,
|
|
1512
|
-
class: {
|
|
1513
|
-
pixelium: true,
|
|
1514
|
-
"px-popup-content": true,
|
|
1515
|
-
"px-popup-content__arrow": !!props.arrow,
|
|
1516
|
-
[`px-popup-content__${popupFinalPlacement.value || popupRoughPlacement.value}`]: true,
|
|
1517
|
-
[`px-popup-content__${props.variant}`]: true
|
|
1518
|
-
},
|
|
1519
|
-
style: {
|
|
1520
|
-
...floatingStyles.value,
|
|
1521
|
-
visibility: show.value ? "visible" : "hidden",
|
|
1522
|
-
pointerEvents: show.value ? "auto" : "none",
|
|
1523
|
-
zIndex: props.zIndex ?? unref(currentZIndex),
|
|
1524
|
-
width: unref(k)(contentWidth.value) ? `${contentWidth.value}px` : void 0,
|
|
1525
|
-
...props.contentStyle
|
|
1526
|
-
}
|
|
1527
|
-
}, _ctx.$attrs, {
|
|
1528
|
-
onMouseenter: contentMouseenterHandler,
|
|
1529
|
-
onMouseleave: contentMouseleaveHandler
|
|
1530
|
-
}),
|
|
1531
|
-
[
|
|
1532
|
-
renderSlot(_ctx.$slots, "content", {}, () => [
|
|
1533
|
-
createTextVNode(
|
|
1534
|
-
toDisplayString(props.content),
|
|
1535
|
-
1
|
|
1536
|
-
/* TEXT */
|
|
1537
|
-
)
|
|
1538
|
-
]),
|
|
1539
|
-
createElementVNode(
|
|
1540
|
-
"div",
|
|
1541
|
-
{
|
|
1542
|
-
class: "px-popup-content-arrow",
|
|
1543
|
-
style: normalizeStyle(arrowStyles.value),
|
|
1544
|
-
ref_key: "arrowRef",
|
|
1545
|
-
ref: arrowRef
|
|
1546
|
-
},
|
|
1547
|
-
null,
|
|
1548
|
-
4
|
|
1549
|
-
/* STYLE */
|
|
1550
|
-
),
|
|
1551
|
-
createElementVNode(
|
|
1552
|
-
"canvas",
|
|
1553
|
-
{
|
|
1554
|
-
class: "px-popup-content-canvas",
|
|
1555
|
-
ref_key: "canvasRef",
|
|
1556
|
-
ref: canvasRef
|
|
1557
|
-
},
|
|
1558
|
-
null,
|
|
1559
|
-
512
|
|
1560
|
-
/* NEED_PATCH */
|
|
1561
|
-
)
|
|
1562
|
-
],
|
|
1563
|
-
16
|
|
1564
|
-
/* FULL_PROPS */
|
|
1565
|
-
), [
|
|
1566
|
-
[vShow, props.visible]
|
|
1567
|
-
])
|
|
1568
|
-
]),
|
|
1569
|
-
_: 3
|
|
1570
|
-
/* FORWARDED */
|
|
1571
|
-
}, 8, ["name"])
|
|
1572
|
-
], 8, ["to"]);
|
|
1573
|
-
};
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1576
|
-
export {
|
|
1577
|
-
_sfc_main as _
|
|
1578
|
-
};
|
|
255
|
+
export { popup_content_default as t };
|