@helsenorge/designsystem-react 11.2.0-beta.0 → 11.3.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/Button.js +6 -8
- package/Button.js.map +1 -1
- package/CHANGELOG.md +928 -1496
- package/Close.js +21 -6
- package/Close.js.map +1 -1
- package/Drawer.js +370 -0
- package/Drawer.js.map +1 -0
- package/HelpBubble.js +78 -0
- package/HelpBubble.js.map +1 -0
- package/InfoTeaser.js +75 -0
- package/InfoTeaser.js.map +1 -0
- package/LazyIcon.js +1 -1
- package/LazyIcon.js.map +1 -1
- package/LazyIllustration.js +1 -1
- package/LazyIllustration.js.map +1 -1
- package/Panel.js +38 -5
- package/Panel.js.map +1 -1
- package/PopOver.js +141 -3589
- package/PopOver.js.map +1 -1
- package/components/ArticleTeaser/ArticleTeaser.d.ts +23 -0
- package/components/ArticleTeaser/ArticleTeaser.test.d.ts +1 -0
- package/components/ArticleTeaser/index.d.ts +3 -0
- package/components/ArticleTeaser/index.js +67 -0
- package/components/ArticleTeaser/index.js.map +1 -0
- package/components/ArticleTeaser/resourceHelper.d.ts +3 -0
- package/components/ArticleTeaser/styles.module.scss +79 -0
- package/components/ArticleTeaser/styles.module.scss.d.ts +13 -0
- package/components/Close/Close.d.ts +1 -1
- package/components/Close/styles.module.scss +51 -20
- package/components/Close/styles.module.scss.d.ts +3 -0
- package/components/Drawer/Drawer.d.ts +7 -1
- package/components/Drawer/index.js +1 -348
- package/components/Drawer/index.js.map +1 -1
- package/components/Drawer/styles.module.scss +44 -5
- package/components/Drawer/styles.module.scss.d.ts +2 -0
- package/components/Dropdown/index.js +1 -3
- package/components/Dropdown/index.js.map +1 -1
- package/components/HelpBubble/HelpBubble.d.ts +9 -7
- package/components/HelpBubble/index.js +3 -47
- package/components/HelpBubble/index.js.map +1 -1
- package/components/HelpBubble/styles.module.scss +7 -5
- package/components/HelpBubble/styles.module.scss.d.ts +1 -0
- package/components/HelpDrawer/HelpDrawer.d.ts +8 -0
- package/components/HelpDrawer/HelpDrawer.test.d.ts +1 -0
- package/components/HelpDrawer/index.d.ts +3 -0
- package/components/HelpDrawer/index.js +10 -0
- package/components/HelpDrawer/index.js.map +1 -0
- package/components/HelpDrawer/styles.module.scss +16 -0
- package/components/HelpDrawer/styles.module.scss.d.ts +10 -0
- package/components/HelpPanel/styles.module.scss +2 -3
- package/components/HelpTeaser/HelpTeaser.d.ts +20 -0
- package/components/HelpTeaser/HelpTeaser.test.d.ts +1 -0
- package/components/HelpTeaser/index.d.ts +3 -0
- package/components/HelpTeaser/index.js +25 -0
- package/components/HelpTeaser/index.js.map +1 -0
- package/components/HelpTeaser/styles.module.scss +22 -0
- package/components/HelpTeaser/styles.module.scss.d.ts +10 -0
- package/components/HelpTooltip/index.js +2 -2
- package/components/HelpTooltip/index.js.map +1 -1
- package/components/HighlightPanel/styles.module.scss +0 -1
- package/components/Icons/AdditionalIconInformation.d.ts +1 -1
- package/components/Icons/AdditionalIconInformation.js +1 -1
- package/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/components/Icons/IconNames.d.ts +1 -1
- package/components/Icons/IconNames.js +1 -0
- package/components/Icons/IconNames.js.map +1 -1
- package/components/Icons/Toddler.d.ts +4 -0
- package/components/Icons/Toddler.js +10 -0
- package/components/Icons/Toddler.js.map +1 -0
- package/components/Illustrations/BabyMobile.d.ts +8 -0
- package/components/Illustrations/BabyMobile.js +11 -0
- package/components/Illustrations/BabyMobile.js.map +1 -0
- package/components/Illustrations/BabyMobileMedium.d.ts +4 -0
- package/components/Illustrations/BabyMobileMedium.js +424 -0
- package/components/Illustrations/BabyMobileMedium.js.map +1 -0
- package/components/Illustrations/Child.d.ts +12 -0
- package/components/Illustrations/Child.js +11 -0
- package/components/Illustrations/Child.js.map +1 -0
- package/components/Illustrations/ChildMedium.d.ts +4 -0
- package/components/Illustrations/ChildMedium.js +185 -0
- package/components/Illustrations/ChildMedium.js.map +1 -0
- package/components/Illustrations/GiveBabyFood.d.ts +11 -0
- package/components/Illustrations/GiveBabyFood.js +11 -0
- package/components/Illustrations/GiveBabyFood.js.map +1 -0
- package/components/Illustrations/GiveBabyFoodMedium.d.ts +4 -0
- package/components/Illustrations/GiveBabyFoodMedium.js +377 -0
- package/components/Illustrations/GiveBabyFoodMedium.js.map +1 -0
- package/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/components/Illustrations/IllustrationNames.js +15 -1
- package/components/Illustrations/IllustrationNames.js.map +1 -1
- package/components/Illustrations/Stroller.d.ts +12 -0
- package/components/Illustrations/Stroller.js +11 -0
- package/components/Illustrations/Stroller.js.map +1 -0
- package/components/Illustrations/StrollerMedium.d.ts +4 -0
- package/components/Illustrations/StrollerMedium.js +236 -0
- package/components/Illustrations/StrollerMedium.js.map +1 -0
- package/components/InfoTeaser/InfoTeaser.d.ts +28 -0
- package/components/InfoTeaser/InfoTeaser.test.d.ts +1 -0
- package/components/InfoTeaser/index.d.ts +3 -0
- package/components/InfoTeaser/index.js +5 -0
- package/components/InfoTeaser/index.js.map +1 -0
- package/components/InfoTeaser/resourceHelper.d.ts +3 -0
- package/components/InfoTeaser/styles.module.scss +98 -0
- package/components/InfoTeaser/styles.module.scss.d.ts +15 -0
- package/components/Modal/styles.module.scss +3 -1
- package/components/Panel/Panel.d.ts +3 -0
- package/components/Panel/resourceHelper.d.ts +3 -0
- package/components/Panel/styles.module.scss +6 -6
- package/components/PopMenu/index.js +24 -15
- package/components/PopMenu/index.js.map +1 -1
- package/components/PopMenu/styles.module.scss +10 -9
- package/components/PopMenu/styles.module.scss.d.ts +1 -0
- package/components/PopOver/PopOver.d.ts +5 -9
- package/components/PopOver/index.js +3 -3
- package/components/PopOver/styles.module.scss +53 -11
- package/components/PopOver/styles.module.scss.d.ts +5 -0
- package/constants.d.ts +2 -0
- package/constants.js +2 -0
- package/constants.js.map +1 -1
- package/designsystem-react.css +20 -6
- package/hooks/useBreakpoint.js +10 -28
- package/hooks/useBreakpoint.js.map +1 -1
- package/hooks/useIsMobileBreakpoint.d.ts +1 -0
- package/hooks/useIsMobileBreakpoint.js +10 -0
- package/hooks/useIsMobileBreakpoint.js.map +1 -0
- package/package.json +1 -1
- package/resources/HN.Designsystem.ArticleTeaser.en-GB.json.d.ts +7 -0
- package/resources/HN.Designsystem.ArticleTeaser.nb-NO.json.d.ts +7 -0
- package/resources/HN.Designsystem.Dropdown.nb-NO.json.d.ts +1 -2
- package/resources/HN.Designsystem.InfoTeaser.en-GB.json.d.ts +7 -0
- package/resources/HN.Designsystem.InfoTeaser.nb-NO.json.d.ts +7 -0
- package/resources/HN.Designsystem.Panel.en-GB.json.d.ts +7 -0
- package/resources/HN.Designsystem.Panel.nb-NO.json.d.ts +7 -0
- package/scss/_font-mixins.scss +0 -22
- package/scss/supernova/styles/colors.css +20 -6
- package/scss/supernova/styles/typography.css +2 -2
- package/scss/typography.module.scss +0 -8
- package/scss/typography.module.scss.d.ts +0 -2
- package/scss/typography.stories.tsx +0 -8
package/PopOver.js
CHANGED
|
@@ -1,3649 +1,201 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import React__default, { useLayoutEffect, useEffect, useRef } from "react";
|
|
4
|
-
import * as ReactDOM from "react-dom";
|
|
2
|
+
import React__default, { useRef, useState, useEffect } from "react";
|
|
5
3
|
import classNames from "classnames";
|
|
6
4
|
import { ZIndex, AnalyticsId } from "./constants.js";
|
|
5
|
+
import { useInterval } from "./hooks/useInterval.js";
|
|
6
|
+
import { useIsVisible } from "./hooks/useIsVisible.js";
|
|
7
|
+
import { useLayoutEvent } from "./hooks/useLayoutEvent.js";
|
|
8
|
+
import { useSize } from "./hooks/useSize.js";
|
|
9
|
+
import { mergeRefs } from "./utils/refs.js";
|
|
7
10
|
import styles from "./components/PopOver/styles.module.scss";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
function getDocumentElement(node) {
|
|
22
|
-
var _ref;
|
|
23
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
24
|
-
}
|
|
25
|
-
function isNode(value) {
|
|
26
|
-
if (!hasWindow()) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
30
|
-
}
|
|
31
|
-
function isElement(value) {
|
|
32
|
-
if (!hasWindow()) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
36
|
-
}
|
|
37
|
-
function isHTMLElement(value) {
|
|
38
|
-
if (!hasWindow()) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
42
|
-
}
|
|
43
|
-
function isShadowRoot(value) {
|
|
44
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
48
|
-
}
|
|
49
|
-
function isOverflowElement(element) {
|
|
50
|
-
const {
|
|
51
|
-
overflow,
|
|
52
|
-
overflowX,
|
|
53
|
-
overflowY,
|
|
54
|
-
display
|
|
55
|
-
} = getComputedStyle$1(element);
|
|
56
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
|
57
|
-
}
|
|
58
|
-
function isTableElement(element) {
|
|
59
|
-
return ["table", "td", "th"].includes(getNodeName(element));
|
|
60
|
-
}
|
|
61
|
-
function isTopLayer(element) {
|
|
62
|
-
return [":popover-open", ":modal"].some((selector) => {
|
|
63
|
-
try {
|
|
64
|
-
return element.matches(selector);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function isContainingBlock(elementOrCss) {
|
|
71
|
-
const webkit = isWebKit();
|
|
72
|
-
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
73
|
-
return ["transform", "translate", "scale", "rotate", "perspective"].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) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
|
|
74
|
-
}
|
|
75
|
-
function getContainingBlock(element) {
|
|
76
|
-
let currentNode = getParentNode(element);
|
|
77
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
78
|
-
if (isContainingBlock(currentNode)) {
|
|
79
|
-
return currentNode;
|
|
80
|
-
} else if (isTopLayer(currentNode)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
currentNode = getParentNode(currentNode);
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
function isWebKit() {
|
|
88
|
-
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
89
|
-
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
90
|
-
}
|
|
91
|
-
function isLastTraversableNode(node) {
|
|
92
|
-
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
93
|
-
}
|
|
94
|
-
function getComputedStyle$1(element) {
|
|
95
|
-
return getWindow(element).getComputedStyle(element);
|
|
96
|
-
}
|
|
97
|
-
function getNodeScroll(element) {
|
|
98
|
-
if (isElement(element)) {
|
|
99
|
-
return {
|
|
100
|
-
scrollLeft: element.scrollLeft,
|
|
101
|
-
scrollTop: element.scrollTop
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
scrollLeft: element.scrollX,
|
|
106
|
-
scrollTop: element.scrollY
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function getParentNode(node) {
|
|
110
|
-
if (getNodeName(node) === "html") {
|
|
111
|
-
return node;
|
|
112
|
-
}
|
|
113
|
-
const result = (
|
|
114
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
115
|
-
node.assignedSlot || // DOM Element detected.
|
|
116
|
-
node.parentNode || // ShadowRoot detected.
|
|
117
|
-
isShadowRoot(node) && node.host || // Fallback.
|
|
118
|
-
getDocumentElement(node)
|
|
119
|
-
);
|
|
120
|
-
return isShadowRoot(result) ? result.host : result;
|
|
121
|
-
}
|
|
122
|
-
function getNearestOverflowAncestor(node) {
|
|
123
|
-
const parentNode = getParentNode(node);
|
|
124
|
-
if (isLastTraversableNode(parentNode)) {
|
|
125
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
126
|
-
}
|
|
127
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
128
|
-
return parentNode;
|
|
129
|
-
}
|
|
130
|
-
return getNearestOverflowAncestor(parentNode);
|
|
131
|
-
}
|
|
132
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
133
|
-
var _node$ownerDocument2;
|
|
134
|
-
if (list === void 0) {
|
|
135
|
-
list = [];
|
|
136
|
-
}
|
|
137
|
-
if (traverseIframes === void 0) {
|
|
138
|
-
traverseIframes = true;
|
|
139
|
-
}
|
|
140
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
141
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
142
|
-
const win = getWindow(scrollableAncestor);
|
|
143
|
-
if (isBody) {
|
|
144
|
-
const frameElement = getFrameElement(win);
|
|
145
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
146
|
-
}
|
|
147
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
148
|
-
}
|
|
149
|
-
function getFrameElement(win) {
|
|
150
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
151
|
-
}
|
|
152
|
-
const sides = ["top", "right", "bottom", "left"];
|
|
153
|
-
const min = Math.min;
|
|
154
|
-
const max = Math.max;
|
|
155
|
-
const round = Math.round;
|
|
156
|
-
const floor = Math.floor;
|
|
157
|
-
const createCoords = (v) => ({
|
|
158
|
-
x: v,
|
|
159
|
-
y: v
|
|
160
|
-
});
|
|
161
|
-
const oppositeSideMap = {
|
|
162
|
-
left: "right",
|
|
163
|
-
right: "left",
|
|
164
|
-
bottom: "top",
|
|
165
|
-
top: "bottom"
|
|
166
|
-
};
|
|
167
|
-
const oppositeAlignmentMap = {
|
|
168
|
-
start: "end",
|
|
169
|
-
end: "start"
|
|
170
|
-
};
|
|
171
|
-
function clamp(start, value, end) {
|
|
172
|
-
return max(start, min(value, end));
|
|
173
|
-
}
|
|
174
|
-
function evaluate(value, param) {
|
|
175
|
-
return typeof value === "function" ? value(param) : value;
|
|
176
|
-
}
|
|
177
|
-
function getSide(placement) {
|
|
178
|
-
return placement.split("-")[0];
|
|
179
|
-
}
|
|
180
|
-
function getAlignment(placement) {
|
|
181
|
-
return placement.split("-")[1];
|
|
182
|
-
}
|
|
183
|
-
function getOppositeAxis(axis) {
|
|
184
|
-
return axis === "x" ? "y" : "x";
|
|
185
|
-
}
|
|
186
|
-
function getAxisLength(axis) {
|
|
187
|
-
return axis === "y" ? "height" : "width";
|
|
188
|
-
}
|
|
189
|
-
function getSideAxis(placement) {
|
|
190
|
-
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
|
|
191
|
-
}
|
|
192
|
-
function getAlignmentAxis(placement) {
|
|
193
|
-
return getOppositeAxis(getSideAxis(placement));
|
|
194
|
-
}
|
|
195
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
196
|
-
if (rtl === void 0) {
|
|
197
|
-
rtl = false;
|
|
198
|
-
}
|
|
199
|
-
const alignment = getAlignment(placement);
|
|
200
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
201
|
-
const length = getAxisLength(alignmentAxis);
|
|
202
|
-
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
203
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
204
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
205
|
-
}
|
|
206
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
207
|
-
}
|
|
208
|
-
function getExpandedPlacements(placement) {
|
|
209
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
210
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
211
|
-
}
|
|
212
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
213
|
-
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
214
|
-
}
|
|
215
|
-
function getSideList(side, isStart, rtl) {
|
|
216
|
-
const lr = ["left", "right"];
|
|
217
|
-
const rl = ["right", "left"];
|
|
218
|
-
const tb = ["top", "bottom"];
|
|
219
|
-
const bt = ["bottom", "top"];
|
|
220
|
-
switch (side) {
|
|
221
|
-
case "top":
|
|
222
|
-
case "bottom":
|
|
223
|
-
if (rtl) return isStart ? rl : lr;
|
|
224
|
-
return isStart ? lr : rl;
|
|
225
|
-
case "left":
|
|
226
|
-
case "right":
|
|
227
|
-
return isStart ? tb : bt;
|
|
228
|
-
default:
|
|
229
|
-
return [];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
233
|
-
const alignment = getAlignment(placement);
|
|
234
|
-
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
235
|
-
if (alignment) {
|
|
236
|
-
list = list.map((side) => side + "-" + alignment);
|
|
237
|
-
if (flipAlignment) {
|
|
238
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return list;
|
|
242
|
-
}
|
|
243
|
-
function getOppositePlacement(placement) {
|
|
244
|
-
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
245
|
-
}
|
|
246
|
-
function expandPaddingObject(padding) {
|
|
247
|
-
return {
|
|
248
|
-
top: 0,
|
|
249
|
-
right: 0,
|
|
250
|
-
bottom: 0,
|
|
251
|
-
left: 0,
|
|
252
|
-
...padding
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function getPaddingObject(padding) {
|
|
256
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
257
|
-
top: padding,
|
|
258
|
-
right: padding,
|
|
259
|
-
bottom: padding,
|
|
260
|
-
left: padding
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function rectToClientRect(rect) {
|
|
264
|
-
const {
|
|
265
|
-
x,
|
|
266
|
-
y,
|
|
267
|
-
width,
|
|
268
|
-
height
|
|
269
|
-
} = rect;
|
|
270
|
-
return {
|
|
271
|
-
width,
|
|
272
|
-
height,
|
|
273
|
-
top: y,
|
|
274
|
-
left: x,
|
|
275
|
-
right: x + width,
|
|
276
|
-
bottom: y + height,
|
|
277
|
-
x,
|
|
278
|
-
y
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
/*!
|
|
282
|
-
* tabbable 6.2.0
|
|
283
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
284
|
-
*/
|
|
285
|
-
var candidateSelectors = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"];
|
|
286
|
-
var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
|
|
287
|
-
var NoElement = typeof Element === "undefined";
|
|
288
|
-
var matches = NoElement ? function() {
|
|
289
|
-
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
290
|
-
var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
|
|
291
|
-
var _element$getRootNode;
|
|
292
|
-
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
293
|
-
} : function(element) {
|
|
294
|
-
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
295
|
-
};
|
|
296
|
-
var isInert = function isInert2(node, lookUp) {
|
|
297
|
-
var _node$getAttribute;
|
|
298
|
-
if (lookUp === void 0) {
|
|
299
|
-
lookUp = true;
|
|
300
|
-
}
|
|
301
|
-
var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
|
|
302
|
-
var inert = inertAtt === "" || inertAtt === "true";
|
|
303
|
-
var result = inert || lookUp && node && isInert2(node.parentNode);
|
|
304
|
-
return result;
|
|
305
|
-
};
|
|
306
|
-
var isContentEditable = function isContentEditable2(node) {
|
|
307
|
-
var _node$getAttribute2;
|
|
308
|
-
var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
|
|
309
|
-
return attValue === "" || attValue === "true";
|
|
310
|
-
};
|
|
311
|
-
var getCandidates = function getCandidates2(el, includeContainer, filter) {
|
|
312
|
-
if (isInert(el)) {
|
|
313
|
-
return [];
|
|
314
|
-
}
|
|
315
|
-
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
316
|
-
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
317
|
-
candidates.unshift(el);
|
|
318
|
-
}
|
|
319
|
-
candidates = candidates.filter(filter);
|
|
320
|
-
return candidates;
|
|
321
|
-
};
|
|
322
|
-
var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) {
|
|
323
|
-
var candidates = [];
|
|
324
|
-
var elementsToCheck = Array.from(elements);
|
|
325
|
-
while (elementsToCheck.length) {
|
|
326
|
-
var element = elementsToCheck.shift();
|
|
327
|
-
if (isInert(element, false)) {
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
if (element.tagName === "SLOT") {
|
|
331
|
-
var assigned = element.assignedElements();
|
|
332
|
-
var content = assigned.length ? assigned : element.children;
|
|
333
|
-
var nestedCandidates = getCandidatesIteratively2(content, true, options);
|
|
334
|
-
if (options.flatten) {
|
|
335
|
-
candidates.push.apply(candidates, nestedCandidates);
|
|
336
|
-
} else {
|
|
337
|
-
candidates.push({
|
|
338
|
-
scopeParent: element,
|
|
339
|
-
candidates: nestedCandidates
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
} else {
|
|
343
|
-
var validCandidate = matches.call(element, candidateSelector);
|
|
344
|
-
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
345
|
-
candidates.push(element);
|
|
346
|
-
}
|
|
347
|
-
var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
|
|
348
|
-
typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
|
|
349
|
-
var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
|
|
350
|
-
if (shadowRoot && validShadowRoot) {
|
|
351
|
-
var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
352
|
-
if (options.flatten) {
|
|
353
|
-
candidates.push.apply(candidates, _nestedCandidates);
|
|
354
|
-
} else {
|
|
355
|
-
candidates.push({
|
|
356
|
-
scopeParent: element,
|
|
357
|
-
candidates: _nestedCandidates
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
} else {
|
|
361
|
-
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
return candidates;
|
|
366
|
-
};
|
|
367
|
-
var hasTabIndex = function hasTabIndex2(node) {
|
|
368
|
-
return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
|
|
369
|
-
};
|
|
370
|
-
var getTabIndex = function getTabIndex2(node) {
|
|
371
|
-
if (!node) {
|
|
372
|
-
throw new Error("No node provided");
|
|
373
|
-
}
|
|
374
|
-
if (node.tabIndex < 0) {
|
|
375
|
-
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
|
|
376
|
-
return 0;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return node.tabIndex;
|
|
380
|
-
};
|
|
381
|
-
var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
|
|
382
|
-
var tabIndex = getTabIndex(node);
|
|
383
|
-
if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
|
|
384
|
-
return 0;
|
|
385
|
-
}
|
|
386
|
-
return tabIndex;
|
|
387
|
-
};
|
|
388
|
-
var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
|
|
389
|
-
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
390
|
-
};
|
|
391
|
-
var isInput = function isInput2(node) {
|
|
392
|
-
return node.tagName === "INPUT";
|
|
393
|
-
};
|
|
394
|
-
var isHiddenInput = function isHiddenInput2(node) {
|
|
395
|
-
return isInput(node) && node.type === "hidden";
|
|
396
|
-
};
|
|
397
|
-
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
398
|
-
var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
399
|
-
return child.tagName === "SUMMARY";
|
|
400
|
-
});
|
|
401
|
-
return r;
|
|
402
|
-
};
|
|
403
|
-
var getCheckedRadio = function getCheckedRadio2(nodes, form) {
|
|
404
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
405
|
-
if (nodes[i].checked && nodes[i].form === form) {
|
|
406
|
-
return nodes[i];
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
var isTabbableRadio = function isTabbableRadio2(node) {
|
|
411
|
-
if (!node.name) {
|
|
412
|
-
return true;
|
|
413
|
-
}
|
|
414
|
-
var radioScope = node.form || getRootNode(node);
|
|
415
|
-
var queryRadios = function queryRadios2(name) {
|
|
416
|
-
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
417
|
-
};
|
|
418
|
-
var radioSet;
|
|
419
|
-
if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
|
|
420
|
-
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
11
|
+
const BUBBLE_WIDTH_PX = 373;
|
|
12
|
+
const WINDOW_MARGIN_PX = 12;
|
|
13
|
+
const BUBBLE_VERTICAL_OFFSET_PX = 16;
|
|
14
|
+
const ARROW_WIDTH_PX = 20;
|
|
15
|
+
const ARROW_VERTICAL_OFFSET_PX = 4;
|
|
16
|
+
const ARROW_HORIZONTAL_MARGIN_PX = 12;
|
|
17
|
+
const getVerticalPosition = (controllerSize, bubbleSize, variant) => {
|
|
18
|
+
if (variant !== PopOverVariant.positionautomatic) {
|
|
19
|
+
return variant;
|
|
20
|
+
}
|
|
21
|
+
if (controllerSize.top > bubbleSize.height + BUBBLE_VERTICAL_OFFSET_PX) {
|
|
22
|
+
return PopOverVariant.positionabove;
|
|
421
23
|
} else {
|
|
422
|
-
|
|
423
|
-
radioSet = queryRadios(node.name);
|
|
424
|
-
} catch (err) {
|
|
425
|
-
console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
24
|
+
return PopOverVariant.positionbelow;
|
|
428
25
|
}
|
|
429
|
-
var checked = getCheckedRadio(radioSet, node.form);
|
|
430
|
-
return !checked || checked === node;
|
|
431
|
-
};
|
|
432
|
-
var isRadio = function isRadio2(node) {
|
|
433
|
-
return isInput(node) && node.type === "radio";
|
|
434
26
|
};
|
|
435
|
-
|
|
436
|
-
|
|
27
|
+
const getControllerLeftCenterPx = (controllerSize) => controllerSize.left + controllerSize.width / 2;
|
|
28
|
+
const getControllerRightCenterPx = (controllerSize) => document.documentElement.clientWidth - controllerSize.right + controllerSize.width / 2;
|
|
29
|
+
const getBubbleLeftPx = (controllerSize, bubbleSize) => {
|
|
30
|
+
const controllerHorizontalCenterPx = getControllerLeftCenterPx(controllerSize);
|
|
31
|
+
return controllerHorizontalCenterPx - bubbleSize.width / 2;
|
|
437
32
|
};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
442
|
-
var attached = false;
|
|
443
|
-
if (nodeRoot && nodeRoot !== node) {
|
|
444
|
-
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
445
|
-
attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
|
|
446
|
-
while (!attached && nodeRootHost) {
|
|
447
|
-
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
448
|
-
nodeRoot = getRootNode(nodeRootHost);
|
|
449
|
-
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
450
|
-
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return attached;
|
|
33
|
+
const getBubbleRightPx = (controllerSize, bubbleSize) => {
|
|
34
|
+
const bubbleLeftPx = getBubbleLeftPx(controllerSize, bubbleSize);
|
|
35
|
+
return bubbleLeftPx + bubbleSize.width;
|
|
454
36
|
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return
|
|
458
|
-
};
|
|
459
|
-
var isHidden = function isHidden2(node, _ref) {
|
|
460
|
-
var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
|
|
461
|
-
if (getComputedStyle(node).visibility === "hidden") {
|
|
462
|
-
return true;
|
|
463
|
-
}
|
|
464
|
-
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
465
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
466
|
-
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
467
|
-
return true;
|
|
468
|
-
}
|
|
469
|
-
if (!displayCheck || displayCheck === "full" || displayCheck === "legacy-full") {
|
|
470
|
-
if (typeof getShadowRoot === "function") {
|
|
471
|
-
var originalNode = node;
|
|
472
|
-
while (node) {
|
|
473
|
-
var parentElement = node.parentElement;
|
|
474
|
-
var rootNode = getRootNode(node);
|
|
475
|
-
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
|
|
476
|
-
return isZeroArea(node);
|
|
477
|
-
} else if (node.assignedSlot) {
|
|
478
|
-
node = node.assignedSlot;
|
|
479
|
-
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
480
|
-
node = rootNode.host;
|
|
481
|
-
} else {
|
|
482
|
-
node = parentElement;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
node = originalNode;
|
|
486
|
-
}
|
|
487
|
-
if (isNodeAttached(node)) {
|
|
488
|
-
return !node.getClientRects().length;
|
|
489
|
-
}
|
|
490
|
-
if (displayCheck !== "legacy-full") {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
} else if (displayCheck === "non-zero-area") {
|
|
494
|
-
return isZeroArea(node);
|
|
495
|
-
}
|
|
496
|
-
return false;
|
|
37
|
+
const getBubbleLeftVisible = (controllerSize, bubbleSize) => {
|
|
38
|
+
const bubbleLeftPx = getBubbleLeftPx(controllerSize, bubbleSize);
|
|
39
|
+
return bubbleLeftPx > WINDOW_MARGIN_PX;
|
|
497
40
|
};
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
while (parentNode) {
|
|
502
|
-
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
503
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
504
|
-
var child = parentNode.children.item(i);
|
|
505
|
-
if (child.tagName === "LEGEND") {
|
|
506
|
-
return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return true;
|
|
510
|
-
}
|
|
511
|
-
parentNode = parentNode.parentElement;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return false;
|
|
41
|
+
const getBubbleRightIsVisible = (controllerSize, bubbleSize) => {
|
|
42
|
+
const bubbleRightPx = getBubbleRightPx(controllerSize, bubbleSize);
|
|
43
|
+
return bubbleRightPx < document.documentElement.clientWidth - WINDOW_MARGIN_PX;
|
|
515
44
|
};
|
|
516
|
-
|
|
517
|
-
if (
|
|
518
|
-
|
|
519
|
-
// note related to `candidateSelectors`)
|
|
520
|
-
isInert(node) || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
521
|
-
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
522
|
-
return false;
|
|
45
|
+
const getHorizontalPosition = (controllerSize, bubbleSize) => {
|
|
46
|
+
if (!getBubbleRightIsVisible(controllerSize, bubbleSize)) {
|
|
47
|
+
return "right";
|
|
523
48
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
|
|
527
|
-
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
528
|
-
return false;
|
|
49
|
+
if (!getBubbleLeftVisible(controllerSize, bubbleSize)) {
|
|
50
|
+
return "left";
|
|
529
51
|
}
|
|
530
|
-
return
|
|
52
|
+
return "floating";
|
|
531
53
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return false;
|
|
54
|
+
const getBubbleAbovePx = (controllerSize, bubbleSize) => controllerSize.top - BUBBLE_VERTICAL_OFFSET_PX - bubbleSize.height;
|
|
55
|
+
const getBubbleBelowPx = (controllerSize) => controllerSize.bottom + BUBBLE_VERTICAL_OFFSET_PX;
|
|
56
|
+
const getBubbleWidth = () => document.documentElement.clientWidth - WINDOW_MARGIN_PX * 2;
|
|
57
|
+
const getBubbleFitsInWindow = () => {
|
|
58
|
+
return document.documentElement.clientWidth > BUBBLE_WIDTH_PX + WINDOW_MARGIN_PX * 2;
|
|
538
59
|
};
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
549
|
-
} else {
|
|
550
|
-
orderedTabbables.push({
|
|
551
|
-
documentOrder: i,
|
|
552
|
-
tabIndex: candidateTabindex,
|
|
553
|
-
item,
|
|
554
|
-
isScope,
|
|
555
|
-
content: elements
|
|
556
|
-
});
|
|
60
|
+
const getArrowTopxPx = (controllerSize) => controllerSize.top - BUBBLE_VERTICAL_OFFSET_PX - ARROW_VERTICAL_OFFSET_PX;
|
|
61
|
+
const getArrowLeftPx = (controllerSize) => getControllerLeftCenterPx(controllerSize) - ARROW_WIDTH_PX / 2;
|
|
62
|
+
const getArrowRightPx = (controllerSize) => getControllerRightCenterPx(controllerSize) - ARROW_WIDTH_PX / 2;
|
|
63
|
+
const getBubblePosition = (controllerSize, bubbleSize, variant) => {
|
|
64
|
+
const horizontalPosition = getHorizontalPosition(controllerSize, bubbleSize);
|
|
65
|
+
const verticalPosition = getVerticalPosition(controllerSize, bubbleSize, variant);
|
|
66
|
+
if (horizontalPosition === "left") {
|
|
67
|
+
if (verticalPosition === PopOverVariant.positionabove) {
|
|
68
|
+
return "leftabove";
|
|
557
69
|
}
|
|
558
|
-
|
|
559
|
-
return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
|
|
560
|
-
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
561
|
-
return acc;
|
|
562
|
-
}, []).concat(regularTabbables);
|
|
563
|
-
};
|
|
564
|
-
var tabbable = function tabbable2(container, options) {
|
|
565
|
-
options = options || {};
|
|
566
|
-
var candidates;
|
|
567
|
-
if (options.getShadowRoot) {
|
|
568
|
-
candidates = getCandidatesIteratively([container], options.includeContainer, {
|
|
569
|
-
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
570
|
-
flatten: false,
|
|
571
|
-
getShadowRoot: options.getShadowRoot,
|
|
572
|
-
shadowRootFilter: isValidShadowRootTabbable
|
|
573
|
-
});
|
|
574
|
-
} else {
|
|
575
|
-
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
576
|
-
}
|
|
577
|
-
return sortByOrder(candidates);
|
|
578
|
-
};
|
|
579
|
-
var focusable = function focusable2(container, options) {
|
|
580
|
-
options = options || {};
|
|
581
|
-
var candidates;
|
|
582
|
-
if (options.getShadowRoot) {
|
|
583
|
-
candidates = getCandidatesIteratively([container], options.includeContainer, {
|
|
584
|
-
filter: isNodeMatchingSelectorFocusable.bind(null, options),
|
|
585
|
-
flatten: true,
|
|
586
|
-
getShadowRoot: options.getShadowRoot
|
|
587
|
-
});
|
|
588
|
-
} else {
|
|
589
|
-
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
|
|
590
|
-
}
|
|
591
|
-
return candidates;
|
|
592
|
-
};
|
|
593
|
-
var isTabbable = function isTabbable2(node, options) {
|
|
594
|
-
options = options || {};
|
|
595
|
-
if (!node) {
|
|
596
|
-
throw new Error("No node provided");
|
|
597
|
-
}
|
|
598
|
-
if (matches.call(node, candidateSelector) === false) {
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
601
|
-
return isNodeMatchingSelectorTabbable(options, node);
|
|
602
|
-
};
|
|
603
|
-
function getPlatform() {
|
|
604
|
-
const uaData = navigator.userAgentData;
|
|
605
|
-
if (uaData != null && uaData.platform) {
|
|
606
|
-
return uaData.platform;
|
|
607
|
-
}
|
|
608
|
-
return navigator.platform;
|
|
609
|
-
}
|
|
610
|
-
function getUserAgent() {
|
|
611
|
-
const uaData = navigator.userAgentData;
|
|
612
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
613
|
-
return uaData.brands.map((_ref) => {
|
|
614
|
-
let {
|
|
615
|
-
brand,
|
|
616
|
-
version
|
|
617
|
-
} = _ref;
|
|
618
|
-
return brand + "/" + version;
|
|
619
|
-
}).join(" ");
|
|
620
|
-
}
|
|
621
|
-
return navigator.userAgent;
|
|
622
|
-
}
|
|
623
|
-
function isSafari() {
|
|
624
|
-
return /apple/i.test(navigator.vendor);
|
|
625
|
-
}
|
|
626
|
-
function isAndroid() {
|
|
627
|
-
const re = /android/i;
|
|
628
|
-
return re.test(getPlatform()) || re.test(getUserAgent());
|
|
629
|
-
}
|
|
630
|
-
function isJSDOM() {
|
|
631
|
-
return getUserAgent().includes("jsdom/");
|
|
632
|
-
}
|
|
633
|
-
const FOCUSABLE_ATTRIBUTE$1 = "data-floating-ui-focusable";
|
|
634
|
-
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
635
|
-
function activeElement(doc) {
|
|
636
|
-
let activeElement2 = doc.activeElement;
|
|
637
|
-
while (((_activeElement = activeElement2) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
|
|
638
|
-
var _activeElement;
|
|
639
|
-
activeElement2 = activeElement2.shadowRoot.activeElement;
|
|
70
|
+
return "leftbelow";
|
|
640
71
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
if (!parent || !child) {
|
|
645
|
-
return false;
|
|
646
|
-
}
|
|
647
|
-
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
|
|
648
|
-
if (parent.contains(child)) {
|
|
649
|
-
return true;
|
|
650
|
-
}
|
|
651
|
-
if (rootNode && isShadowRoot(rootNode)) {
|
|
652
|
-
let next = child;
|
|
653
|
-
while (next) {
|
|
654
|
-
if (parent === next) {
|
|
655
|
-
return true;
|
|
656
|
-
}
|
|
657
|
-
next = next.parentNode || next.host;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return false;
|
|
661
|
-
}
|
|
662
|
-
function getTarget(event) {
|
|
663
|
-
if ("composedPath" in event) {
|
|
664
|
-
return event.composedPath()[0];
|
|
665
|
-
}
|
|
666
|
-
return event.target;
|
|
667
|
-
}
|
|
668
|
-
function isEventTargetWithin(event, node) {
|
|
669
|
-
if (node == null) {
|
|
670
|
-
return false;
|
|
671
|
-
}
|
|
672
|
-
if ("composedPath" in event) {
|
|
673
|
-
return event.composedPath().includes(node);
|
|
674
|
-
}
|
|
675
|
-
const e = event;
|
|
676
|
-
return e.target != null && node.contains(e.target);
|
|
677
|
-
}
|
|
678
|
-
function isRootElement(element) {
|
|
679
|
-
return element.matches("html,body");
|
|
680
|
-
}
|
|
681
|
-
function getDocument$1(node) {
|
|
682
|
-
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
683
|
-
}
|
|
684
|
-
function isTypeableElement(element) {
|
|
685
|
-
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
686
|
-
}
|
|
687
|
-
function isTypeableCombobox(element) {
|
|
688
|
-
if (!element) return false;
|
|
689
|
-
return element.getAttribute("role") === "combobox" && isTypeableElement(element);
|
|
690
|
-
}
|
|
691
|
-
function getFloatingFocusElement(floatingElement) {
|
|
692
|
-
if (!floatingElement) {
|
|
693
|
-
return null;
|
|
694
|
-
}
|
|
695
|
-
return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE$1) ? floatingElement : floatingElement.querySelector("[" + FOCUSABLE_ATTRIBUTE$1 + "]") || floatingElement;
|
|
696
|
-
}
|
|
697
|
-
function getNodeChildren(nodes, id, onlyOpenChildren) {
|
|
698
|
-
if (onlyOpenChildren === void 0) {
|
|
699
|
-
onlyOpenChildren = true;
|
|
700
|
-
}
|
|
701
|
-
let allChildren = nodes.filter((node) => {
|
|
702
|
-
var _node$context;
|
|
703
|
-
return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
|
|
704
|
-
});
|
|
705
|
-
let currentChildren = allChildren;
|
|
706
|
-
while (currentChildren.length) {
|
|
707
|
-
currentChildren = onlyOpenChildren ? nodes.filter((node) => {
|
|
708
|
-
var _currentChildren;
|
|
709
|
-
return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some((n) => {
|
|
710
|
-
var _node$context2;
|
|
711
|
-
return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
|
|
712
|
-
});
|
|
713
|
-
}) : nodes;
|
|
714
|
-
allChildren = allChildren.concat(currentChildren);
|
|
715
|
-
}
|
|
716
|
-
return allChildren;
|
|
717
|
-
}
|
|
718
|
-
function getNodeAncestors(nodes, id) {
|
|
719
|
-
var _nodes$find;
|
|
720
|
-
let allAncestors = [];
|
|
721
|
-
let currentParentId = (_nodes$find = nodes.find((node) => node.id === id)) == null ? void 0 : _nodes$find.parentId;
|
|
722
|
-
while (currentParentId) {
|
|
723
|
-
const currentNode = nodes.find((node) => node.id === currentParentId);
|
|
724
|
-
currentParentId = currentNode == null ? void 0 : currentNode.parentId;
|
|
725
|
-
if (currentNode) {
|
|
726
|
-
allAncestors = allAncestors.concat(currentNode);
|
|
72
|
+
if (horizontalPosition === "right") {
|
|
73
|
+
if (verticalPosition === PopOverVariant.positionabove) {
|
|
74
|
+
return "rightabove";
|
|
727
75
|
}
|
|
76
|
+
return "rightbelow";
|
|
728
77
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
function stopEvent(event) {
|
|
732
|
-
event.preventDefault();
|
|
733
|
-
event.stopPropagation();
|
|
734
|
-
}
|
|
735
|
-
function isReactEvent(event) {
|
|
736
|
-
return "nativeEvent" in event;
|
|
737
|
-
}
|
|
738
|
-
function isVirtualClick(event) {
|
|
739
|
-
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
740
|
-
return true;
|
|
78
|
+
if (verticalPosition === PopOverVariant.positionabove) {
|
|
79
|
+
return "floatingabove";
|
|
741
80
|
}
|
|
742
|
-
|
|
743
|
-
return event.type === "click" && event.buttons === 1;
|
|
744
|
-
}
|
|
745
|
-
return event.detail === 0 && !event.pointerType;
|
|
746
|
-
}
|
|
747
|
-
function isVirtualPointerEvent(event) {
|
|
748
|
-
if (isJSDOM()) return false;
|
|
749
|
-
return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
|
|
750
|
-
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
|
|
751
|
-
}
|
|
752
|
-
function isMouseLikePointerType(pointerType, strict) {
|
|
753
|
-
const values = ["mouse", "pen"];
|
|
754
|
-
return values.includes(pointerType);
|
|
755
|
-
}
|
|
756
|
-
var index$1 = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
757
|
-
const SafeReact$1 = {
|
|
758
|
-
...React
|
|
81
|
+
return "floatingbelow";
|
|
759
82
|
};
|
|
760
|
-
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
});
|
|
765
|
-
return ref;
|
|
766
|
-
}
|
|
767
|
-
const useInsertionEffect = SafeReact$1.useInsertionEffect;
|
|
768
|
-
const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
|
|
769
|
-
function useEffectEvent(callback) {
|
|
770
|
-
const ref = React.useRef(() => {
|
|
771
|
-
if (process.env.NODE_ENV !== "production") {
|
|
772
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
useSafeInsertionEffect(() => {
|
|
776
|
-
ref.current = callback;
|
|
777
|
-
});
|
|
778
|
-
return React.useCallback(function() {
|
|
779
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
780
|
-
args[_key] = arguments[_key];
|
|
781
|
-
}
|
|
782
|
-
return ref.current == null ? void 0 : ref.current(...args);
|
|
783
|
-
}, []);
|
|
784
|
-
}
|
|
785
|
-
const getTabbableOptions = () => ({
|
|
786
|
-
getShadowRoot: true,
|
|
787
|
-
displayCheck: (
|
|
788
|
-
// JSDOM does not support the `tabbable` library. To solve this we can
|
|
789
|
-
// check if `ResizeObserver` is a real function (not polyfilled), which
|
|
790
|
-
// determines if the current environment is JSDOM-like.
|
|
791
|
-
typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
|
|
792
|
-
)
|
|
793
|
-
});
|
|
794
|
-
function getTabbableIn(container, dir) {
|
|
795
|
-
const list = tabbable(container, getTabbableOptions());
|
|
796
|
-
const len = list.length;
|
|
797
|
-
if (len === 0) return;
|
|
798
|
-
const active = activeElement(getDocument$1(container));
|
|
799
|
-
const index2 = list.indexOf(active);
|
|
800
|
-
const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
|
|
801
|
-
return list[nextIndex];
|
|
802
|
-
}
|
|
803
|
-
function getNextTabbable(referenceElement) {
|
|
804
|
-
return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
|
|
805
|
-
}
|
|
806
|
-
function getPreviousTabbable(referenceElement) {
|
|
807
|
-
return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
|
|
808
|
-
}
|
|
809
|
-
function isOutsideEvent(event, container) {
|
|
810
|
-
const containerElement = container || event.currentTarget;
|
|
811
|
-
const relatedTarget = event.relatedTarget;
|
|
812
|
-
return !relatedTarget || !contains(containerElement, relatedTarget);
|
|
813
|
-
}
|
|
814
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
815
|
-
let {
|
|
816
|
-
reference,
|
|
817
|
-
floating
|
|
818
|
-
} = _ref;
|
|
819
|
-
const sideAxis = getSideAxis(placement);
|
|
820
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
821
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
822
|
-
const side = getSide(placement);
|
|
823
|
-
const isVertical = sideAxis === "y";
|
|
824
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
825
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
826
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
827
|
-
let coords;
|
|
828
|
-
switch (side) {
|
|
829
|
-
case "top":
|
|
830
|
-
coords = {
|
|
831
|
-
x: commonX,
|
|
832
|
-
y: reference.y - floating.height
|
|
833
|
-
};
|
|
834
|
-
break;
|
|
835
|
-
case "bottom":
|
|
836
|
-
coords = {
|
|
837
|
-
x: commonX,
|
|
838
|
-
y: reference.y + reference.height
|
|
839
|
-
};
|
|
840
|
-
break;
|
|
841
|
-
case "right":
|
|
842
|
-
coords = {
|
|
843
|
-
x: reference.x + reference.width,
|
|
844
|
-
y: commonY
|
|
845
|
-
};
|
|
846
|
-
break;
|
|
847
|
-
case "left":
|
|
848
|
-
coords = {
|
|
849
|
-
x: reference.x - floating.width,
|
|
850
|
-
y: commonY
|
|
851
|
-
};
|
|
852
|
-
break;
|
|
853
|
-
default:
|
|
854
|
-
coords = {
|
|
855
|
-
x: reference.x,
|
|
856
|
-
y: reference.y
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
switch (getAlignment(placement)) {
|
|
860
|
-
case "start":
|
|
861
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
862
|
-
break;
|
|
863
|
-
case "end":
|
|
864
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
return coords;
|
|
868
|
-
}
|
|
869
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
870
|
-
const {
|
|
871
|
-
placement = "bottom",
|
|
872
|
-
strategy = "absolute",
|
|
873
|
-
middleware = [],
|
|
874
|
-
platform: platform2
|
|
875
|
-
} = config;
|
|
876
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
877
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
878
|
-
let rects = await platform2.getElementRects({
|
|
879
|
-
reference,
|
|
880
|
-
floating,
|
|
881
|
-
strategy
|
|
882
|
-
});
|
|
883
|
-
let {
|
|
884
|
-
x,
|
|
885
|
-
y
|
|
886
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
887
|
-
let statefulPlacement = placement;
|
|
888
|
-
let middlewareData = {};
|
|
889
|
-
let resetCount = 0;
|
|
890
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
891
|
-
const {
|
|
892
|
-
name,
|
|
893
|
-
fn
|
|
894
|
-
} = validMiddleware[i];
|
|
895
|
-
const {
|
|
896
|
-
x: nextX,
|
|
897
|
-
y: nextY,
|
|
898
|
-
data,
|
|
899
|
-
reset
|
|
900
|
-
} = await fn({
|
|
901
|
-
x,
|
|
902
|
-
y,
|
|
903
|
-
initialPlacement: placement,
|
|
904
|
-
placement: statefulPlacement,
|
|
905
|
-
strategy,
|
|
906
|
-
middlewareData,
|
|
907
|
-
rects,
|
|
908
|
-
platform: platform2,
|
|
909
|
-
elements: {
|
|
910
|
-
reference,
|
|
911
|
-
floating
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
x = nextX != null ? nextX : x;
|
|
915
|
-
y = nextY != null ? nextY : y;
|
|
916
|
-
middlewareData = {
|
|
917
|
-
...middlewareData,
|
|
918
|
-
[name]: {
|
|
919
|
-
...middlewareData[name],
|
|
920
|
-
...data
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
if (reset && resetCount <= 50) {
|
|
924
|
-
resetCount++;
|
|
925
|
-
if (typeof reset === "object") {
|
|
926
|
-
if (reset.placement) {
|
|
927
|
-
statefulPlacement = reset.placement;
|
|
928
|
-
}
|
|
929
|
-
if (reset.rects) {
|
|
930
|
-
rects = reset.rects === true ? await platform2.getElementRects({
|
|
931
|
-
reference,
|
|
932
|
-
floating,
|
|
933
|
-
strategy
|
|
934
|
-
}) : reset.rects;
|
|
935
|
-
}
|
|
936
|
-
({
|
|
937
|
-
x,
|
|
938
|
-
y
|
|
939
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
940
|
-
}
|
|
941
|
-
i = -1;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
return {
|
|
945
|
-
x,
|
|
946
|
-
y,
|
|
947
|
-
placement: statefulPlacement,
|
|
948
|
-
strategy,
|
|
949
|
-
middlewareData
|
|
950
|
-
};
|
|
951
|
-
};
|
|
952
|
-
async function detectOverflow(state, options) {
|
|
953
|
-
var _await$platform$isEle;
|
|
954
|
-
if (options === void 0) {
|
|
955
|
-
options = {};
|
|
956
|
-
}
|
|
957
|
-
const {
|
|
958
|
-
x,
|
|
959
|
-
y,
|
|
960
|
-
platform: platform2,
|
|
961
|
-
rects,
|
|
962
|
-
elements,
|
|
963
|
-
strategy
|
|
964
|
-
} = state;
|
|
965
|
-
const {
|
|
966
|
-
boundary = "clippingAncestors",
|
|
967
|
-
rootBoundary = "viewport",
|
|
968
|
-
elementContext = "floating",
|
|
969
|
-
altBoundary = false,
|
|
970
|
-
padding = 0
|
|
971
|
-
} = evaluate(options, state);
|
|
972
|
-
const paddingObject = getPaddingObject(padding);
|
|
973
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
974
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
975
|
-
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
976
|
-
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)),
|
|
977
|
-
boundary,
|
|
978
|
-
rootBoundary,
|
|
979
|
-
strategy
|
|
980
|
-
}));
|
|
981
|
-
const rect = elementContext === "floating" ? {
|
|
982
|
-
x,
|
|
983
|
-
y,
|
|
984
|
-
width: rects.floating.width,
|
|
985
|
-
height: rects.floating.height
|
|
986
|
-
} : rects.reference;
|
|
987
|
-
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
988
|
-
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
989
|
-
x: 1,
|
|
990
|
-
y: 1
|
|
991
|
-
} : {
|
|
992
|
-
x: 1,
|
|
993
|
-
y: 1
|
|
994
|
-
};
|
|
995
|
-
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
996
|
-
elements,
|
|
997
|
-
rect,
|
|
998
|
-
offsetParent,
|
|
999
|
-
strategy
|
|
1000
|
-
}) : rect);
|
|
1001
|
-
return {
|
|
1002
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1003
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1004
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1005
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1006
|
-
};
|
|
1007
|
-
}
|
|
1008
|
-
const arrow$3 = (options) => ({
|
|
1009
|
-
name: "arrow",
|
|
1010
|
-
options,
|
|
1011
|
-
async fn(state) {
|
|
1012
|
-
const {
|
|
1013
|
-
x,
|
|
1014
|
-
y,
|
|
1015
|
-
placement,
|
|
1016
|
-
rects,
|
|
1017
|
-
platform: platform2,
|
|
1018
|
-
elements,
|
|
1019
|
-
middlewareData
|
|
1020
|
-
} = state;
|
|
1021
|
-
const {
|
|
1022
|
-
element,
|
|
1023
|
-
padding = 0
|
|
1024
|
-
} = evaluate(options, state) || {};
|
|
1025
|
-
if (element == null) {
|
|
1026
|
-
return {};
|
|
1027
|
-
}
|
|
1028
|
-
const paddingObject = getPaddingObject(padding);
|
|
1029
|
-
const coords = {
|
|
1030
|
-
x,
|
|
1031
|
-
y
|
|
1032
|
-
};
|
|
1033
|
-
const axis = getAlignmentAxis(placement);
|
|
1034
|
-
const length = getAxisLength(axis);
|
|
1035
|
-
const arrowDimensions = await platform2.getDimensions(element);
|
|
1036
|
-
const isYAxis = axis === "y";
|
|
1037
|
-
const minProp = isYAxis ? "top" : "left";
|
|
1038
|
-
const maxProp = isYAxis ? "bottom" : "right";
|
|
1039
|
-
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
1040
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1041
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
1042
|
-
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
1043
|
-
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1044
|
-
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
1045
|
-
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1046
|
-
}
|
|
1047
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1048
|
-
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1049
|
-
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
1050
|
-
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
1051
|
-
const min$1 = minPadding;
|
|
1052
|
-
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
1053
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1054
|
-
const offset2 = clamp(min$1, center, max2);
|
|
1055
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1056
|
-
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
83
|
+
const getBubbleStyle = (controllerSize, bubbleSize, variant) => {
|
|
84
|
+
const bubblePosition = getBubblePosition(controllerSize, bubbleSize, variant);
|
|
85
|
+
const bubbleWidth = !getBubbleFitsInWindow() ? getBubbleWidth() : void 0;
|
|
86
|
+
if (bubblePosition === "leftabove") {
|
|
1057
87
|
return {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
centerOffset: center - offset2 - alignmentOffset,
|
|
1062
|
-
...shouldAddOffset && {
|
|
1063
|
-
alignmentOffset
|
|
1064
|
-
}
|
|
1065
|
-
},
|
|
1066
|
-
reset: shouldAddOffset
|
|
88
|
+
left: WINDOW_MARGIN_PX,
|
|
89
|
+
top: getBubbleAbovePx(controllerSize, bubbleSize),
|
|
90
|
+
width: bubbleWidth
|
|
1067
91
|
};
|
|
1068
92
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
if (options === void 0) {
|
|
1072
|
-
options = {};
|
|
93
|
+
if (bubblePosition === "leftbelow") {
|
|
94
|
+
return { left: WINDOW_MARGIN_PX, top: getBubbleBelowPx(controllerSize), width: bubbleWidth };
|
|
1073
95
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
options,
|
|
1077
|
-
async fn(state) {
|
|
1078
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
1079
|
-
const {
|
|
1080
|
-
placement,
|
|
1081
|
-
middlewareData,
|
|
1082
|
-
rects,
|
|
1083
|
-
initialPlacement,
|
|
1084
|
-
platform: platform2,
|
|
1085
|
-
elements
|
|
1086
|
-
} = state;
|
|
1087
|
-
const {
|
|
1088
|
-
mainAxis: checkMainAxis = true,
|
|
1089
|
-
crossAxis: checkCrossAxis = true,
|
|
1090
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
1091
|
-
fallbackStrategy = "bestFit",
|
|
1092
|
-
fallbackAxisSideDirection = "none",
|
|
1093
|
-
flipAlignment = true,
|
|
1094
|
-
...detectOverflowOptions
|
|
1095
|
-
} = evaluate(options, state);
|
|
1096
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1097
|
-
return {};
|
|
1098
|
-
}
|
|
1099
|
-
const side = getSide(placement);
|
|
1100
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1101
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1102
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
1103
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1104
|
-
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
1105
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1106
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1107
|
-
}
|
|
1108
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1109
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1110
|
-
const overflows = [];
|
|
1111
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1112
|
-
if (checkMainAxis) {
|
|
1113
|
-
overflows.push(overflow[side]);
|
|
1114
|
-
}
|
|
1115
|
-
if (checkCrossAxis) {
|
|
1116
|
-
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
1117
|
-
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
1118
|
-
}
|
|
1119
|
-
overflowsData = [...overflowsData, {
|
|
1120
|
-
placement,
|
|
1121
|
-
overflows
|
|
1122
|
-
}];
|
|
1123
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
1124
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
1125
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1126
|
-
const nextPlacement = placements[nextIndex];
|
|
1127
|
-
if (nextPlacement) {
|
|
1128
|
-
return {
|
|
1129
|
-
data: {
|
|
1130
|
-
index: nextIndex,
|
|
1131
|
-
overflows: overflowsData
|
|
1132
|
-
},
|
|
1133
|
-
reset: {
|
|
1134
|
-
placement: nextPlacement
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
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;
|
|
1139
|
-
if (!resetPlacement) {
|
|
1140
|
-
switch (fallbackStrategy) {
|
|
1141
|
-
case "bestFit": {
|
|
1142
|
-
var _overflowsData$filter2;
|
|
1143
|
-
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
1144
|
-
if (hasFallbackAxisSideDirection) {
|
|
1145
|
-
const currentSideAxis = getSideAxis(d.placement);
|
|
1146
|
-
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
1147
|
-
// reading directions favoring greater width.
|
|
1148
|
-
currentSideAxis === "y";
|
|
1149
|
-
}
|
|
1150
|
-
return true;
|
|
1151
|
-
}).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];
|
|
1152
|
-
if (placement2) {
|
|
1153
|
-
resetPlacement = placement2;
|
|
1154
|
-
}
|
|
1155
|
-
break;
|
|
1156
|
-
}
|
|
1157
|
-
case "initialPlacement":
|
|
1158
|
-
resetPlacement = initialPlacement;
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
if (placement !== resetPlacement) {
|
|
1163
|
-
return {
|
|
1164
|
-
reset: {
|
|
1165
|
-
placement: resetPlacement
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
return {};
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
};
|
|
1174
|
-
function getSideOffsets(overflow, rect) {
|
|
1175
|
-
return {
|
|
1176
|
-
top: overflow.top - rect.height,
|
|
1177
|
-
right: overflow.right - rect.width,
|
|
1178
|
-
bottom: overflow.bottom - rect.height,
|
|
1179
|
-
left: overflow.left - rect.width
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
function isAnySideFullyClipped(overflow) {
|
|
1183
|
-
return sides.some((side) => overflow[side] >= 0);
|
|
1184
|
-
}
|
|
1185
|
-
const hide$2 = function(options) {
|
|
1186
|
-
if (options === void 0) {
|
|
1187
|
-
options = {};
|
|
96
|
+
if (bubblePosition === "rightabove") {
|
|
97
|
+
return { right: WINDOW_MARGIN_PX, top: getBubbleAbovePx(controllerSize, bubbleSize), width: bubbleWidth };
|
|
1188
98
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
options,
|
|
1192
|
-
async fn(state) {
|
|
1193
|
-
const {
|
|
1194
|
-
rects
|
|
1195
|
-
} = state;
|
|
1196
|
-
const {
|
|
1197
|
-
strategy = "referenceHidden",
|
|
1198
|
-
...detectOverflowOptions
|
|
1199
|
-
} = evaluate(options, state);
|
|
1200
|
-
switch (strategy) {
|
|
1201
|
-
case "referenceHidden": {
|
|
1202
|
-
const overflow = await detectOverflow(state, {
|
|
1203
|
-
...detectOverflowOptions,
|
|
1204
|
-
elementContext: "reference"
|
|
1205
|
-
});
|
|
1206
|
-
const offsets = getSideOffsets(overflow, rects.reference);
|
|
1207
|
-
return {
|
|
1208
|
-
data: {
|
|
1209
|
-
referenceHiddenOffsets: offsets,
|
|
1210
|
-
referenceHidden: isAnySideFullyClipped(offsets)
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
case "escaped": {
|
|
1215
|
-
const overflow = await detectOverflow(state, {
|
|
1216
|
-
...detectOverflowOptions,
|
|
1217
|
-
altBoundary: true
|
|
1218
|
-
});
|
|
1219
|
-
const offsets = getSideOffsets(overflow, rects.floating);
|
|
1220
|
-
return {
|
|
1221
|
-
data: {
|
|
1222
|
-
escapedOffsets: offsets,
|
|
1223
|
-
escaped: isAnySideFullyClipped(offsets)
|
|
1224
|
-
}
|
|
1225
|
-
};
|
|
1226
|
-
}
|
|
1227
|
-
default: {
|
|
1228
|
-
return {};
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
};
|
|
1234
|
-
async function convertValueToCoords(state, options) {
|
|
1235
|
-
const {
|
|
1236
|
-
placement,
|
|
1237
|
-
platform: platform2,
|
|
1238
|
-
elements
|
|
1239
|
-
} = state;
|
|
1240
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
1241
|
-
const side = getSide(placement);
|
|
1242
|
-
const alignment = getAlignment(placement);
|
|
1243
|
-
const isVertical = getSideAxis(placement) === "y";
|
|
1244
|
-
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
1245
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1246
|
-
const rawValue = evaluate(options, state);
|
|
1247
|
-
let {
|
|
1248
|
-
mainAxis,
|
|
1249
|
-
crossAxis,
|
|
1250
|
-
alignmentAxis
|
|
1251
|
-
} = typeof rawValue === "number" ? {
|
|
1252
|
-
mainAxis: rawValue,
|
|
1253
|
-
crossAxis: 0,
|
|
1254
|
-
alignmentAxis: null
|
|
1255
|
-
} : {
|
|
1256
|
-
mainAxis: rawValue.mainAxis || 0,
|
|
1257
|
-
crossAxis: rawValue.crossAxis || 0,
|
|
1258
|
-
alignmentAxis: rawValue.alignmentAxis
|
|
1259
|
-
};
|
|
1260
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
1261
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
99
|
+
if (bubblePosition === "rightbelow") {
|
|
100
|
+
return { right: WINDOW_MARGIN_PX, top: getBubbleBelowPx(controllerSize), width: bubbleWidth };
|
|
1262
101
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
y: mainAxis * mainAxisMulti
|
|
1266
|
-
} : {
|
|
1267
|
-
x: mainAxis * mainAxisMulti,
|
|
1268
|
-
y: crossAxis * crossAxisMulti
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
const offset$2 = function(options) {
|
|
1272
|
-
if (options === void 0) {
|
|
1273
|
-
options = 0;
|
|
102
|
+
if (bubblePosition === "floatingbelow") {
|
|
103
|
+
return { left: getBubbleLeftPx(controllerSize, bubbleSize), top: getBubbleBelowPx(controllerSize), width: bubbleWidth };
|
|
1274
104
|
}
|
|
1275
|
-
return {
|
|
1276
|
-
name: "offset",
|
|
1277
|
-
options,
|
|
1278
|
-
async fn(state) {
|
|
1279
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
1280
|
-
const {
|
|
1281
|
-
x,
|
|
1282
|
-
y,
|
|
1283
|
-
placement,
|
|
1284
|
-
middlewareData
|
|
1285
|
-
} = state;
|
|
1286
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
1287
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1288
|
-
return {};
|
|
1289
|
-
}
|
|
1290
|
-
return {
|
|
1291
|
-
x: x + diffCoords.x,
|
|
1292
|
-
y: y + diffCoords.y,
|
|
1293
|
-
data: {
|
|
1294
|
-
...diffCoords,
|
|
1295
|
-
placement
|
|
1296
|
-
}
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
105
|
+
return { left: getBubbleLeftPx(controllerSize, bubbleSize), top: getBubbleAbovePx(controllerSize, bubbleSize), width: bubbleWidth };
|
|
1300
106
|
};
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
async fn(state) {
|
|
1309
|
-
const {
|
|
1310
|
-
x,
|
|
1311
|
-
y,
|
|
1312
|
-
placement
|
|
1313
|
-
} = state;
|
|
1314
|
-
const {
|
|
1315
|
-
mainAxis: checkMainAxis = true,
|
|
1316
|
-
crossAxis: checkCrossAxis = false,
|
|
1317
|
-
limiter = {
|
|
1318
|
-
fn: (_ref) => {
|
|
1319
|
-
let {
|
|
1320
|
-
x: x2,
|
|
1321
|
-
y: y2
|
|
1322
|
-
} = _ref;
|
|
1323
|
-
return {
|
|
1324
|
-
x: x2,
|
|
1325
|
-
y: y2
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
...detectOverflowOptions
|
|
1330
|
-
} = evaluate(options, state);
|
|
1331
|
-
const coords = {
|
|
1332
|
-
x,
|
|
1333
|
-
y
|
|
1334
|
-
};
|
|
1335
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1336
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
1337
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
1338
|
-
let mainAxisCoord = coords[mainAxis];
|
|
1339
|
-
let crossAxisCoord = coords[crossAxis];
|
|
1340
|
-
if (checkMainAxis) {
|
|
1341
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
1342
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
1343
|
-
const min2 = mainAxisCoord + overflow[minSide];
|
|
1344
|
-
const max2 = mainAxisCoord - overflow[maxSide];
|
|
1345
|
-
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
1346
|
-
}
|
|
1347
|
-
if (checkCrossAxis) {
|
|
1348
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
1349
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
1350
|
-
const min2 = crossAxisCoord + overflow[minSide];
|
|
1351
|
-
const max2 = crossAxisCoord - overflow[maxSide];
|
|
1352
|
-
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
1353
|
-
}
|
|
1354
|
-
const limitedCoords = limiter.fn({
|
|
1355
|
-
...state,
|
|
1356
|
-
[mainAxis]: mainAxisCoord,
|
|
1357
|
-
[crossAxis]: crossAxisCoord
|
|
1358
|
-
});
|
|
107
|
+
const getArrowStyle = (bubbleStyle, controllerSize, verticalPosition) => {
|
|
108
|
+
const leftPx = getArrowLeftPx(controllerSize);
|
|
109
|
+
const rightPx = getArrowRightPx(controllerSize);
|
|
110
|
+
const minLeftPx = bubbleStyle.left + ARROW_HORIZONTAL_MARGIN_PX;
|
|
111
|
+
const minRightPx = bubbleStyle.right + ARROW_HORIZONTAL_MARGIN_PX;
|
|
112
|
+
if (bubbleStyle.right) {
|
|
113
|
+
if (verticalPosition === PopOverVariant.positionabove) {
|
|
1359
114
|
return {
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
x: limitedCoords.x - x,
|
|
1363
|
-
y: limitedCoords.y - y,
|
|
1364
|
-
enabled: {
|
|
1365
|
-
[mainAxis]: checkMainAxis,
|
|
1366
|
-
[crossAxis]: checkCrossAxis
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
};
|
|
1373
|
-
function getCssDimensions(element) {
|
|
1374
|
-
const css = getComputedStyle$1(element);
|
|
1375
|
-
let width = parseFloat(css.width) || 0;
|
|
1376
|
-
let height = parseFloat(css.height) || 0;
|
|
1377
|
-
const hasOffset = isHTMLElement(element);
|
|
1378
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1379
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1380
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1381
|
-
if (shouldFallback) {
|
|
1382
|
-
width = offsetWidth;
|
|
1383
|
-
height = offsetHeight;
|
|
1384
|
-
}
|
|
1385
|
-
return {
|
|
1386
|
-
width,
|
|
1387
|
-
height,
|
|
1388
|
-
$: shouldFallback
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
function unwrapElement(element) {
|
|
1392
|
-
return !isElement(element) ? element.contextElement : element;
|
|
1393
|
-
}
|
|
1394
|
-
function getScale(element) {
|
|
1395
|
-
const domElement = unwrapElement(element);
|
|
1396
|
-
if (!isHTMLElement(domElement)) {
|
|
1397
|
-
return createCoords(1);
|
|
1398
|
-
}
|
|
1399
|
-
const rect = domElement.getBoundingClientRect();
|
|
1400
|
-
const {
|
|
1401
|
-
width,
|
|
1402
|
-
height,
|
|
1403
|
-
$
|
|
1404
|
-
} = getCssDimensions(domElement);
|
|
1405
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1406
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1407
|
-
if (!x || !Number.isFinite(x)) {
|
|
1408
|
-
x = 1;
|
|
1409
|
-
}
|
|
1410
|
-
if (!y || !Number.isFinite(y)) {
|
|
1411
|
-
y = 1;
|
|
1412
|
-
}
|
|
1413
|
-
return {
|
|
1414
|
-
x,
|
|
1415
|
-
y
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
1419
|
-
function getVisualOffsets(element) {
|
|
1420
|
-
const win = getWindow(element);
|
|
1421
|
-
if (!isWebKit() || !win.visualViewport) {
|
|
1422
|
-
return noOffsets;
|
|
1423
|
-
}
|
|
1424
|
-
return {
|
|
1425
|
-
x: win.visualViewport.offsetLeft,
|
|
1426
|
-
y: win.visualViewport.offsetTop
|
|
1427
|
-
};
|
|
1428
|
-
}
|
|
1429
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1430
|
-
if (isFixed === void 0) {
|
|
1431
|
-
isFixed = false;
|
|
1432
|
-
}
|
|
1433
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1434
|
-
return false;
|
|
1435
|
-
}
|
|
1436
|
-
return isFixed;
|
|
1437
|
-
}
|
|
1438
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1439
|
-
if (includeScale === void 0) {
|
|
1440
|
-
includeScale = false;
|
|
1441
|
-
}
|
|
1442
|
-
if (isFixedStrategy === void 0) {
|
|
1443
|
-
isFixedStrategy = false;
|
|
1444
|
-
}
|
|
1445
|
-
const clientRect = element.getBoundingClientRect();
|
|
1446
|
-
const domElement = unwrapElement(element);
|
|
1447
|
-
let scale = createCoords(1);
|
|
1448
|
-
if (includeScale) {
|
|
1449
|
-
if (offsetParent) {
|
|
1450
|
-
if (isElement(offsetParent)) {
|
|
1451
|
-
scale = getScale(offsetParent);
|
|
1452
|
-
}
|
|
1453
|
-
} else {
|
|
1454
|
-
scale = getScale(element);
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1458
|
-
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1459
|
-
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1460
|
-
let width = clientRect.width / scale.x;
|
|
1461
|
-
let height = clientRect.height / scale.y;
|
|
1462
|
-
if (domElement) {
|
|
1463
|
-
const win = getWindow(domElement);
|
|
1464
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1465
|
-
let currentWin = win;
|
|
1466
|
-
let currentIFrame = getFrameElement(currentWin);
|
|
1467
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1468
|
-
const iframeScale = getScale(currentIFrame);
|
|
1469
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1470
|
-
const css = getComputedStyle$1(currentIFrame);
|
|
1471
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1472
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1473
|
-
x *= iframeScale.x;
|
|
1474
|
-
y *= iframeScale.y;
|
|
1475
|
-
width *= iframeScale.x;
|
|
1476
|
-
height *= iframeScale.y;
|
|
1477
|
-
x += left;
|
|
1478
|
-
y += top;
|
|
1479
|
-
currentWin = getWindow(currentIFrame);
|
|
1480
|
-
currentIFrame = getFrameElement(currentWin);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
return rectToClientRect({
|
|
1484
|
-
width,
|
|
1485
|
-
height,
|
|
1486
|
-
x,
|
|
1487
|
-
y
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
function getWindowScrollBarX(element, rect) {
|
|
1491
|
-
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1492
|
-
if (!rect) {
|
|
1493
|
-
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1494
|
-
}
|
|
1495
|
-
return rect.left + leftScroll;
|
|
1496
|
-
}
|
|
1497
|
-
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
1498
|
-
if (ignoreScrollbarX === void 0) {
|
|
1499
|
-
ignoreScrollbarX = false;
|
|
1500
|
-
}
|
|
1501
|
-
const htmlRect = documentElement.getBoundingClientRect();
|
|
1502
|
-
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
|
|
1503
|
-
// RTL <body> scrollbar.
|
|
1504
|
-
getWindowScrollBarX(documentElement, htmlRect)
|
|
1505
|
-
));
|
|
1506
|
-
const y = htmlRect.top + scroll.scrollTop;
|
|
1507
|
-
return {
|
|
1508
|
-
x,
|
|
1509
|
-
y
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1513
|
-
let {
|
|
1514
|
-
elements,
|
|
1515
|
-
rect,
|
|
1516
|
-
offsetParent,
|
|
1517
|
-
strategy
|
|
1518
|
-
} = _ref;
|
|
1519
|
-
const isFixed = strategy === "fixed";
|
|
1520
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1521
|
-
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1522
|
-
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1523
|
-
return rect;
|
|
1524
|
-
}
|
|
1525
|
-
let scroll = {
|
|
1526
|
-
scrollLeft: 0,
|
|
1527
|
-
scrollTop: 0
|
|
1528
|
-
};
|
|
1529
|
-
let scale = createCoords(1);
|
|
1530
|
-
const offsets = createCoords(0);
|
|
1531
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1532
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1533
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1534
|
-
scroll = getNodeScroll(offsetParent);
|
|
1535
|
-
}
|
|
1536
|
-
if (isHTMLElement(offsetParent)) {
|
|
1537
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1538
|
-
scale = getScale(offsetParent);
|
|
1539
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1540
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
1544
|
-
return {
|
|
1545
|
-
width: rect.width * scale.x,
|
|
1546
|
-
height: rect.height * scale.y,
|
|
1547
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1548
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1551
|
-
function getClientRects(element) {
|
|
1552
|
-
return Array.from(element.getClientRects());
|
|
1553
|
-
}
|
|
1554
|
-
function getDocumentRect(element) {
|
|
1555
|
-
const html = getDocumentElement(element);
|
|
1556
|
-
const scroll = getNodeScroll(element);
|
|
1557
|
-
const body = element.ownerDocument.body;
|
|
1558
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1559
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1560
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1561
|
-
const y = -scroll.scrollTop;
|
|
1562
|
-
if (getComputedStyle$1(body).direction === "rtl") {
|
|
1563
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1564
|
-
}
|
|
1565
|
-
return {
|
|
1566
|
-
width,
|
|
1567
|
-
height,
|
|
1568
|
-
x,
|
|
1569
|
-
y
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
function getViewportRect(element, strategy) {
|
|
1573
|
-
const win = getWindow(element);
|
|
1574
|
-
const html = getDocumentElement(element);
|
|
1575
|
-
const visualViewport = win.visualViewport;
|
|
1576
|
-
let width = html.clientWidth;
|
|
1577
|
-
let height = html.clientHeight;
|
|
1578
|
-
let x = 0;
|
|
1579
|
-
let y = 0;
|
|
1580
|
-
if (visualViewport) {
|
|
1581
|
-
width = visualViewport.width;
|
|
1582
|
-
height = visualViewport.height;
|
|
1583
|
-
const visualViewportBased = isWebKit();
|
|
1584
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
1585
|
-
x = visualViewport.offsetLeft;
|
|
1586
|
-
y = visualViewport.offsetTop;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
return {
|
|
1590
|
-
width,
|
|
1591
|
-
height,
|
|
1592
|
-
x,
|
|
1593
|
-
y
|
|
1594
|
-
};
|
|
1595
|
-
}
|
|
1596
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1597
|
-
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1598
|
-
const top = clientRect.top + element.clientTop;
|
|
1599
|
-
const left = clientRect.left + element.clientLeft;
|
|
1600
|
-
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1601
|
-
const width = element.clientWidth * scale.x;
|
|
1602
|
-
const height = element.clientHeight * scale.y;
|
|
1603
|
-
const x = left * scale.x;
|
|
1604
|
-
const y = top * scale.y;
|
|
1605
|
-
return {
|
|
1606
|
-
width,
|
|
1607
|
-
height,
|
|
1608
|
-
x,
|
|
1609
|
-
y
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1613
|
-
let rect;
|
|
1614
|
-
if (clippingAncestor === "viewport") {
|
|
1615
|
-
rect = getViewportRect(element, strategy);
|
|
1616
|
-
} else if (clippingAncestor === "document") {
|
|
1617
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
1618
|
-
} else if (isElement(clippingAncestor)) {
|
|
1619
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1620
|
-
} else {
|
|
1621
|
-
const visualOffsets = getVisualOffsets(element);
|
|
1622
|
-
rect = {
|
|
1623
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
1624
|
-
y: clippingAncestor.y - visualOffsets.y,
|
|
1625
|
-
width: clippingAncestor.width,
|
|
1626
|
-
height: clippingAncestor.height
|
|
1627
|
-
};
|
|
1628
|
-
}
|
|
1629
|
-
return rectToClientRect(rect);
|
|
1630
|
-
}
|
|
1631
|
-
function hasFixedPositionAncestor(element, stopNode) {
|
|
1632
|
-
const parentNode = getParentNode(element);
|
|
1633
|
-
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1634
|
-
return false;
|
|
1635
|
-
}
|
|
1636
|
-
return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1637
|
-
}
|
|
1638
|
-
function getClippingElementAncestors(element, cache) {
|
|
1639
|
-
const cachedResult = cache.get(element);
|
|
1640
|
-
if (cachedResult) {
|
|
1641
|
-
return cachedResult;
|
|
1642
|
-
}
|
|
1643
|
-
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1644
|
-
let currentContainingBlockComputedStyle = null;
|
|
1645
|
-
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
1646
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1647
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1648
|
-
const computedStyle = getComputedStyle$1(currentNode);
|
|
1649
|
-
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1650
|
-
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
1651
|
-
currentContainingBlockComputedStyle = null;
|
|
1652
|
-
}
|
|
1653
|
-
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1654
|
-
if (shouldDropCurrentNode) {
|
|
1655
|
-
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1656
|
-
} else {
|
|
1657
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1658
|
-
}
|
|
1659
|
-
currentNode = getParentNode(currentNode);
|
|
1660
|
-
}
|
|
1661
|
-
cache.set(element, result);
|
|
1662
|
-
return result;
|
|
1663
|
-
}
|
|
1664
|
-
function getClippingRect(_ref) {
|
|
1665
|
-
let {
|
|
1666
|
-
element,
|
|
1667
|
-
boundary,
|
|
1668
|
-
rootBoundary,
|
|
1669
|
-
strategy
|
|
1670
|
-
} = _ref;
|
|
1671
|
-
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1672
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1673
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1674
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1675
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1676
|
-
accRect.top = max(rect.top, accRect.top);
|
|
1677
|
-
accRect.right = min(rect.right, accRect.right);
|
|
1678
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1679
|
-
accRect.left = max(rect.left, accRect.left);
|
|
1680
|
-
return accRect;
|
|
1681
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1682
|
-
return {
|
|
1683
|
-
width: clippingRect.right - clippingRect.left,
|
|
1684
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1685
|
-
x: clippingRect.left,
|
|
1686
|
-
y: clippingRect.top
|
|
1687
|
-
};
|
|
1688
|
-
}
|
|
1689
|
-
function getDimensions(element) {
|
|
1690
|
-
const {
|
|
1691
|
-
width,
|
|
1692
|
-
height
|
|
1693
|
-
} = getCssDimensions(element);
|
|
1694
|
-
return {
|
|
1695
|
-
width,
|
|
1696
|
-
height
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1700
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1701
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1702
|
-
const isFixed = strategy === "fixed";
|
|
1703
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1704
|
-
let scroll = {
|
|
1705
|
-
scrollLeft: 0,
|
|
1706
|
-
scrollTop: 0
|
|
1707
|
-
};
|
|
1708
|
-
const offsets = createCoords(0);
|
|
1709
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1710
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1711
|
-
scroll = getNodeScroll(offsetParent);
|
|
1712
|
-
}
|
|
1713
|
-
if (isOffsetParentAnElement) {
|
|
1714
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1715
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1716
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1717
|
-
} else if (documentElement) {
|
|
1718
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1722
|
-
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1723
|
-
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1724
|
-
return {
|
|
1725
|
-
x,
|
|
1726
|
-
y,
|
|
1727
|
-
width: rect.width,
|
|
1728
|
-
height: rect.height
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
function isStaticPositioned(element) {
|
|
1732
|
-
return getComputedStyle$1(element).position === "static";
|
|
1733
|
-
}
|
|
1734
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
1735
|
-
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
|
|
1736
|
-
return null;
|
|
1737
|
-
}
|
|
1738
|
-
if (polyfill) {
|
|
1739
|
-
return polyfill(element);
|
|
1740
|
-
}
|
|
1741
|
-
let rawOffsetParent = element.offsetParent;
|
|
1742
|
-
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1743
|
-
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1744
|
-
}
|
|
1745
|
-
return rawOffsetParent;
|
|
1746
|
-
}
|
|
1747
|
-
function getOffsetParent(element, polyfill) {
|
|
1748
|
-
const win = getWindow(element);
|
|
1749
|
-
if (isTopLayer(element)) {
|
|
1750
|
-
return win;
|
|
1751
|
-
}
|
|
1752
|
-
if (!isHTMLElement(element)) {
|
|
1753
|
-
let svgOffsetParent = getParentNode(element);
|
|
1754
|
-
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1755
|
-
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1756
|
-
return svgOffsetParent;
|
|
1757
|
-
}
|
|
1758
|
-
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1759
|
-
}
|
|
1760
|
-
return win;
|
|
1761
|
-
}
|
|
1762
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1763
|
-
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1764
|
-
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1765
|
-
}
|
|
1766
|
-
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1767
|
-
return win;
|
|
1768
|
-
}
|
|
1769
|
-
return offsetParent || getContainingBlock(element) || win;
|
|
1770
|
-
}
|
|
1771
|
-
const getElementRects = async function(data) {
|
|
1772
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1773
|
-
const getDimensionsFn = this.getDimensions;
|
|
1774
|
-
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1775
|
-
return {
|
|
1776
|
-
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1777
|
-
floating: {
|
|
1778
|
-
x: 0,
|
|
1779
|
-
y: 0,
|
|
1780
|
-
width: floatingDimensions.width,
|
|
1781
|
-
height: floatingDimensions.height
|
|
1782
|
-
}
|
|
1783
|
-
};
|
|
1784
|
-
};
|
|
1785
|
-
function isRTL(element) {
|
|
1786
|
-
return getComputedStyle$1(element).direction === "rtl";
|
|
1787
|
-
}
|
|
1788
|
-
const platform = {
|
|
1789
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1790
|
-
getDocumentElement,
|
|
1791
|
-
getClippingRect,
|
|
1792
|
-
getOffsetParent,
|
|
1793
|
-
getElementRects,
|
|
1794
|
-
getClientRects,
|
|
1795
|
-
getDimensions,
|
|
1796
|
-
getScale,
|
|
1797
|
-
isElement,
|
|
1798
|
-
isRTL
|
|
1799
|
-
};
|
|
1800
|
-
function rectsAreEqual(a, b) {
|
|
1801
|
-
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1802
|
-
}
|
|
1803
|
-
function observeMove(element, onMove) {
|
|
1804
|
-
let io = null;
|
|
1805
|
-
let timeoutId;
|
|
1806
|
-
const root = getDocumentElement(element);
|
|
1807
|
-
function cleanup() {
|
|
1808
|
-
var _io;
|
|
1809
|
-
clearTimeout(timeoutId);
|
|
1810
|
-
(_io = io) == null || _io.disconnect();
|
|
1811
|
-
io = null;
|
|
1812
|
-
}
|
|
1813
|
-
function refresh(skip, threshold) {
|
|
1814
|
-
if (skip === void 0) {
|
|
1815
|
-
skip = false;
|
|
1816
|
-
}
|
|
1817
|
-
if (threshold === void 0) {
|
|
1818
|
-
threshold = 1;
|
|
1819
|
-
}
|
|
1820
|
-
cleanup();
|
|
1821
|
-
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1822
|
-
const {
|
|
1823
|
-
left,
|
|
1824
|
-
top,
|
|
1825
|
-
width,
|
|
1826
|
-
height
|
|
1827
|
-
} = elementRectForRootMargin;
|
|
1828
|
-
if (!skip) {
|
|
1829
|
-
onMove();
|
|
1830
|
-
}
|
|
1831
|
-
if (!width || !height) {
|
|
1832
|
-
return;
|
|
1833
|
-
}
|
|
1834
|
-
const insetTop = floor(top);
|
|
1835
|
-
const insetRight = floor(root.clientWidth - (left + width));
|
|
1836
|
-
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1837
|
-
const insetLeft = floor(left);
|
|
1838
|
-
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1839
|
-
const options = {
|
|
1840
|
-
rootMargin,
|
|
1841
|
-
threshold: max(0, min(1, threshold)) || 1
|
|
1842
|
-
};
|
|
1843
|
-
let isFirstUpdate = true;
|
|
1844
|
-
function handleObserve(entries) {
|
|
1845
|
-
const ratio = entries[0].intersectionRatio;
|
|
1846
|
-
if (ratio !== threshold) {
|
|
1847
|
-
if (!isFirstUpdate) {
|
|
1848
|
-
return refresh();
|
|
1849
|
-
}
|
|
1850
|
-
if (!ratio) {
|
|
1851
|
-
timeoutId = setTimeout(() => {
|
|
1852
|
-
refresh(false, 1e-7);
|
|
1853
|
-
}, 1e3);
|
|
1854
|
-
} else {
|
|
1855
|
-
refresh(false, ratio);
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
1859
|
-
refresh();
|
|
1860
|
-
}
|
|
1861
|
-
isFirstUpdate = false;
|
|
1862
|
-
}
|
|
1863
|
-
try {
|
|
1864
|
-
io = new IntersectionObserver(handleObserve, {
|
|
1865
|
-
...options,
|
|
1866
|
-
// Handle <iframe>s
|
|
1867
|
-
root: root.ownerDocument
|
|
1868
|
-
});
|
|
1869
|
-
} catch (e) {
|
|
1870
|
-
io = new IntersectionObserver(handleObserve, options);
|
|
1871
|
-
}
|
|
1872
|
-
io.observe(element);
|
|
1873
|
-
}
|
|
1874
|
-
refresh(true);
|
|
1875
|
-
return cleanup;
|
|
1876
|
-
}
|
|
1877
|
-
function autoUpdate(reference, floating, update, options) {
|
|
1878
|
-
if (options === void 0) {
|
|
1879
|
-
options = {};
|
|
1880
|
-
}
|
|
1881
|
-
const {
|
|
1882
|
-
ancestorScroll = true,
|
|
1883
|
-
ancestorResize = true,
|
|
1884
|
-
elementResize = typeof ResizeObserver === "function",
|
|
1885
|
-
layoutShift = typeof IntersectionObserver === "function",
|
|
1886
|
-
animationFrame = false
|
|
1887
|
-
} = options;
|
|
1888
|
-
const referenceEl = unwrapElement(reference);
|
|
1889
|
-
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
|
1890
|
-
ancestors.forEach((ancestor) => {
|
|
1891
|
-
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
1892
|
-
passive: true
|
|
1893
|
-
});
|
|
1894
|
-
ancestorResize && ancestor.addEventListener("resize", update);
|
|
1895
|
-
});
|
|
1896
|
-
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1897
|
-
let reobserveFrame = -1;
|
|
1898
|
-
let resizeObserver = null;
|
|
1899
|
-
if (elementResize) {
|
|
1900
|
-
resizeObserver = new ResizeObserver((_ref) => {
|
|
1901
|
-
let [firstEntry] = _ref;
|
|
1902
|
-
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1903
|
-
resizeObserver.unobserve(floating);
|
|
1904
|
-
cancelAnimationFrame(reobserveFrame);
|
|
1905
|
-
reobserveFrame = requestAnimationFrame(() => {
|
|
1906
|
-
var _resizeObserver;
|
|
1907
|
-
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
update();
|
|
1911
|
-
});
|
|
1912
|
-
if (referenceEl && !animationFrame) {
|
|
1913
|
-
resizeObserver.observe(referenceEl);
|
|
1914
|
-
}
|
|
1915
|
-
resizeObserver.observe(floating);
|
|
1916
|
-
}
|
|
1917
|
-
let frameId;
|
|
1918
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1919
|
-
if (animationFrame) {
|
|
1920
|
-
frameLoop();
|
|
1921
|
-
}
|
|
1922
|
-
function frameLoop() {
|
|
1923
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1924
|
-
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
1925
|
-
update();
|
|
1926
|
-
}
|
|
1927
|
-
prevRefRect = nextRefRect;
|
|
1928
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1929
|
-
}
|
|
1930
|
-
update();
|
|
1931
|
-
return () => {
|
|
1932
|
-
var _resizeObserver2;
|
|
1933
|
-
ancestors.forEach((ancestor) => {
|
|
1934
|
-
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
1935
|
-
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
1936
|
-
});
|
|
1937
|
-
cleanupIo == null || cleanupIo();
|
|
1938
|
-
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1939
|
-
resizeObserver = null;
|
|
1940
|
-
if (animationFrame) {
|
|
1941
|
-
cancelAnimationFrame(frameId);
|
|
1942
|
-
}
|
|
1943
|
-
};
|
|
1944
|
-
}
|
|
1945
|
-
const offset$1 = offset$2;
|
|
1946
|
-
const shift$1 = shift$2;
|
|
1947
|
-
const flip$1 = flip$2;
|
|
1948
|
-
const hide$1 = hide$2;
|
|
1949
|
-
const arrow$2 = arrow$3;
|
|
1950
|
-
const computePosition = (reference, floating, options) => {
|
|
1951
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1952
|
-
const mergedOptions = {
|
|
1953
|
-
platform,
|
|
1954
|
-
...options
|
|
1955
|
-
};
|
|
1956
|
-
const platformWithCache = {
|
|
1957
|
-
...mergedOptions.platform,
|
|
1958
|
-
_c: cache
|
|
1959
|
-
};
|
|
1960
|
-
return computePosition$1(reference, floating, {
|
|
1961
|
-
...mergedOptions,
|
|
1962
|
-
platform: platformWithCache
|
|
1963
|
-
});
|
|
1964
|
-
};
|
|
1965
|
-
var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
1966
|
-
function deepEqual(a, b) {
|
|
1967
|
-
if (a === b) {
|
|
1968
|
-
return true;
|
|
1969
|
-
}
|
|
1970
|
-
if (typeof a !== typeof b) {
|
|
1971
|
-
return false;
|
|
1972
|
-
}
|
|
1973
|
-
if (typeof a === "function" && a.toString() === b.toString()) {
|
|
1974
|
-
return true;
|
|
1975
|
-
}
|
|
1976
|
-
let length;
|
|
1977
|
-
let i;
|
|
1978
|
-
let keys;
|
|
1979
|
-
if (a && b && typeof a === "object") {
|
|
1980
|
-
if (Array.isArray(a)) {
|
|
1981
|
-
length = a.length;
|
|
1982
|
-
if (length !== b.length) return false;
|
|
1983
|
-
for (i = length; i-- !== 0; ) {
|
|
1984
|
-
if (!deepEqual(a[i], b[i])) {
|
|
1985
|
-
return false;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
return true;
|
|
1989
|
-
}
|
|
1990
|
-
keys = Object.keys(a);
|
|
1991
|
-
length = keys.length;
|
|
1992
|
-
if (length !== Object.keys(b).length) {
|
|
1993
|
-
return false;
|
|
1994
|
-
}
|
|
1995
|
-
for (i = length; i-- !== 0; ) {
|
|
1996
|
-
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
1997
|
-
return false;
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
for (i = length; i-- !== 0; ) {
|
|
2001
|
-
const key = keys[i];
|
|
2002
|
-
if (key === "_owner" && a.$$typeof) {
|
|
2003
|
-
continue;
|
|
2004
|
-
}
|
|
2005
|
-
if (!deepEqual(a[key], b[key])) {
|
|
2006
|
-
return false;
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
return true;
|
|
2010
|
-
}
|
|
2011
|
-
return a !== a && b !== b;
|
|
2012
|
-
}
|
|
2013
|
-
function getDPR(element) {
|
|
2014
|
-
if (typeof window === "undefined") {
|
|
2015
|
-
return 1;
|
|
2016
|
-
}
|
|
2017
|
-
const win = element.ownerDocument.defaultView || window;
|
|
2018
|
-
return win.devicePixelRatio || 1;
|
|
2019
|
-
}
|
|
2020
|
-
function roundByDPR(element, value) {
|
|
2021
|
-
const dpr = getDPR(element);
|
|
2022
|
-
return Math.round(value * dpr) / dpr;
|
|
2023
|
-
}
|
|
2024
|
-
function useLatestRef(value) {
|
|
2025
|
-
const ref = React.useRef(value);
|
|
2026
|
-
index(() => {
|
|
2027
|
-
ref.current = value;
|
|
2028
|
-
});
|
|
2029
|
-
return ref;
|
|
2030
|
-
}
|
|
2031
|
-
function useFloating$1(options) {
|
|
2032
|
-
if (options === void 0) {
|
|
2033
|
-
options = {};
|
|
2034
|
-
}
|
|
2035
|
-
const {
|
|
2036
|
-
placement = "bottom",
|
|
2037
|
-
strategy = "absolute",
|
|
2038
|
-
middleware = [],
|
|
2039
|
-
platform: platform2,
|
|
2040
|
-
elements: {
|
|
2041
|
-
reference: externalReference,
|
|
2042
|
-
floating: externalFloating
|
|
2043
|
-
} = {},
|
|
2044
|
-
transform = true,
|
|
2045
|
-
whileElementsMounted,
|
|
2046
|
-
open
|
|
2047
|
-
} = options;
|
|
2048
|
-
const [data, setData] = React.useState({
|
|
2049
|
-
x: 0,
|
|
2050
|
-
y: 0,
|
|
2051
|
-
strategy,
|
|
2052
|
-
placement,
|
|
2053
|
-
middlewareData: {},
|
|
2054
|
-
isPositioned: false
|
|
2055
|
-
});
|
|
2056
|
-
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
2057
|
-
if (!deepEqual(latestMiddleware, middleware)) {
|
|
2058
|
-
setLatestMiddleware(middleware);
|
|
2059
|
-
}
|
|
2060
|
-
const [_reference, _setReference] = React.useState(null);
|
|
2061
|
-
const [_floating, _setFloating] = React.useState(null);
|
|
2062
|
-
const setReference = React.useCallback((node) => {
|
|
2063
|
-
if (node !== referenceRef.current) {
|
|
2064
|
-
referenceRef.current = node;
|
|
2065
|
-
_setReference(node);
|
|
2066
|
-
}
|
|
2067
|
-
}, []);
|
|
2068
|
-
const setFloating = React.useCallback((node) => {
|
|
2069
|
-
if (node !== floatingRef.current) {
|
|
2070
|
-
floatingRef.current = node;
|
|
2071
|
-
_setFloating(node);
|
|
2072
|
-
}
|
|
2073
|
-
}, []);
|
|
2074
|
-
const referenceEl = externalReference || _reference;
|
|
2075
|
-
const floatingEl = externalFloating || _floating;
|
|
2076
|
-
const referenceRef = React.useRef(null);
|
|
2077
|
-
const floatingRef = React.useRef(null);
|
|
2078
|
-
const dataRef = React.useRef(data);
|
|
2079
|
-
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
2080
|
-
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
2081
|
-
const platformRef = useLatestRef(platform2);
|
|
2082
|
-
const openRef = useLatestRef(open);
|
|
2083
|
-
const update = React.useCallback(() => {
|
|
2084
|
-
if (!referenceRef.current || !floatingRef.current) {
|
|
2085
|
-
return;
|
|
2086
|
-
}
|
|
2087
|
-
const config = {
|
|
2088
|
-
placement,
|
|
2089
|
-
strategy,
|
|
2090
|
-
middleware: latestMiddleware
|
|
2091
|
-
};
|
|
2092
|
-
if (platformRef.current) {
|
|
2093
|
-
config.platform = platformRef.current;
|
|
2094
|
-
}
|
|
2095
|
-
computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
|
|
2096
|
-
const fullData = {
|
|
2097
|
-
...data2,
|
|
2098
|
-
// The floating element's position may be recomputed while it's closed
|
|
2099
|
-
// but still mounted (such as when transitioning out). To ensure
|
|
2100
|
-
// `isPositioned` will be `false` initially on the next open, avoid
|
|
2101
|
-
// setting it to `true` when `open === false` (must be specified).
|
|
2102
|
-
isPositioned: openRef.current !== false
|
|
2103
|
-
};
|
|
2104
|
-
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
2105
|
-
dataRef.current = fullData;
|
|
2106
|
-
ReactDOM.flushSync(() => {
|
|
2107
|
-
setData(fullData);
|
|
2108
|
-
});
|
|
2109
|
-
}
|
|
2110
|
-
});
|
|
2111
|
-
}, [latestMiddleware, placement, strategy, platformRef, openRef]);
|
|
2112
|
-
index(() => {
|
|
2113
|
-
if (open === false && dataRef.current.isPositioned) {
|
|
2114
|
-
dataRef.current.isPositioned = false;
|
|
2115
|
-
setData((data2) => ({
|
|
2116
|
-
...data2,
|
|
2117
|
-
isPositioned: false
|
|
2118
|
-
}));
|
|
2119
|
-
}
|
|
2120
|
-
}, [open]);
|
|
2121
|
-
const isMountedRef = React.useRef(false);
|
|
2122
|
-
index(() => {
|
|
2123
|
-
isMountedRef.current = true;
|
|
2124
|
-
return () => {
|
|
2125
|
-
isMountedRef.current = false;
|
|
2126
|
-
};
|
|
2127
|
-
}, []);
|
|
2128
|
-
index(() => {
|
|
2129
|
-
if (referenceEl) referenceRef.current = referenceEl;
|
|
2130
|
-
if (floatingEl) floatingRef.current = floatingEl;
|
|
2131
|
-
if (referenceEl && floatingEl) {
|
|
2132
|
-
if (whileElementsMountedRef.current) {
|
|
2133
|
-
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
2134
|
-
}
|
|
2135
|
-
update();
|
|
2136
|
-
}
|
|
2137
|
-
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
2138
|
-
const refs = React.useMemo(() => ({
|
|
2139
|
-
reference: referenceRef,
|
|
2140
|
-
floating: floatingRef,
|
|
2141
|
-
setReference,
|
|
2142
|
-
setFloating
|
|
2143
|
-
}), [setReference, setFloating]);
|
|
2144
|
-
const elements = React.useMemo(() => ({
|
|
2145
|
-
reference: referenceEl,
|
|
2146
|
-
floating: floatingEl
|
|
2147
|
-
}), [referenceEl, floatingEl]);
|
|
2148
|
-
const floatingStyles = React.useMemo(() => {
|
|
2149
|
-
const initialStyles = {
|
|
2150
|
-
position: strategy,
|
|
2151
|
-
left: 0,
|
|
2152
|
-
top: 0
|
|
2153
|
-
};
|
|
2154
|
-
if (!elements.floating) {
|
|
2155
|
-
return initialStyles;
|
|
2156
|
-
}
|
|
2157
|
-
const x = roundByDPR(elements.floating, data.x);
|
|
2158
|
-
const y = roundByDPR(elements.floating, data.y);
|
|
2159
|
-
if (transform) {
|
|
2160
|
-
return {
|
|
2161
|
-
...initialStyles,
|
|
2162
|
-
transform: "translate(" + x + "px, " + y + "px)",
|
|
2163
|
-
...getDPR(elements.floating) >= 1.5 && {
|
|
2164
|
-
willChange: "transform"
|
|
2165
|
-
}
|
|
115
|
+
right: rightPx > minRightPx ? rightPx : minRightPx,
|
|
116
|
+
top: getArrowTopxPx(controllerSize)
|
|
2166
117
|
};
|
|
2167
118
|
}
|
|
2168
119
|
return {
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
top: y
|
|
2172
|
-
};
|
|
2173
|
-
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
2174
|
-
return React.useMemo(() => ({
|
|
2175
|
-
...data,
|
|
2176
|
-
update,
|
|
2177
|
-
refs,
|
|
2178
|
-
elements,
|
|
2179
|
-
floatingStyles
|
|
2180
|
-
}), [data, update, refs, elements, floatingStyles]);
|
|
2181
|
-
}
|
|
2182
|
-
const arrow$1 = (options) => {
|
|
2183
|
-
function isRef(value) {
|
|
2184
|
-
return {}.hasOwnProperty.call(value, "current");
|
|
2185
|
-
}
|
|
2186
|
-
return {
|
|
2187
|
-
name: "arrow",
|
|
2188
|
-
options,
|
|
2189
|
-
fn(state) {
|
|
2190
|
-
const {
|
|
2191
|
-
element,
|
|
2192
|
-
padding
|
|
2193
|
-
} = typeof options === "function" ? options(state) : options;
|
|
2194
|
-
if (element && isRef(element)) {
|
|
2195
|
-
if (element.current != null) {
|
|
2196
|
-
return arrow$2({
|
|
2197
|
-
element: element.current,
|
|
2198
|
-
padding
|
|
2199
|
-
}).fn(state);
|
|
2200
|
-
}
|
|
2201
|
-
return {};
|
|
2202
|
-
}
|
|
2203
|
-
if (element) {
|
|
2204
|
-
return arrow$2({
|
|
2205
|
-
element,
|
|
2206
|
-
padding
|
|
2207
|
-
}).fn(state);
|
|
2208
|
-
}
|
|
2209
|
-
return {};
|
|
2210
|
-
}
|
|
2211
|
-
};
|
|
2212
|
-
};
|
|
2213
|
-
const offset = (options, deps) => ({
|
|
2214
|
-
...offset$1(options),
|
|
2215
|
-
options: [options, deps]
|
|
2216
|
-
});
|
|
2217
|
-
const shift = (options, deps) => ({
|
|
2218
|
-
...shift$1(options),
|
|
2219
|
-
options: [options, deps]
|
|
2220
|
-
});
|
|
2221
|
-
const flip = (options, deps) => ({
|
|
2222
|
-
...flip$1(options),
|
|
2223
|
-
options: [options, deps]
|
|
2224
|
-
});
|
|
2225
|
-
const hide = (options, deps) => ({
|
|
2226
|
-
...hide$1(options),
|
|
2227
|
-
options: [options, deps]
|
|
2228
|
-
});
|
|
2229
|
-
const arrow = (options, deps) => ({
|
|
2230
|
-
...arrow$1(options),
|
|
2231
|
-
options: [options, deps]
|
|
2232
|
-
});
|
|
2233
|
-
const FOCUSABLE_ATTRIBUTE = "data-floating-ui-focusable";
|
|
2234
|
-
const ACTIVE_KEY = "active";
|
|
2235
|
-
const SELECTED_KEY = "selected";
|
|
2236
|
-
const SafeReact = {
|
|
2237
|
-
...React
|
|
2238
|
-
};
|
|
2239
|
-
let serverHandoffComplete = false;
|
|
2240
|
-
let count = 0;
|
|
2241
|
-
const genId = () => (
|
|
2242
|
-
// Ensure the id is unique with multiple independent versions of Floating UI
|
|
2243
|
-
// on <React 18
|
|
2244
|
-
"floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
|
|
2245
|
-
);
|
|
2246
|
-
function useFloatingId() {
|
|
2247
|
-
const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
|
|
2248
|
-
index$1(() => {
|
|
2249
|
-
if (id == null) {
|
|
2250
|
-
setId(genId());
|
|
2251
|
-
}
|
|
2252
|
-
}, []);
|
|
2253
|
-
React.useEffect(() => {
|
|
2254
|
-
serverHandoffComplete = true;
|
|
2255
|
-
}, []);
|
|
2256
|
-
return id;
|
|
2257
|
-
}
|
|
2258
|
-
const useReactId = SafeReact.useId;
|
|
2259
|
-
const useId = useReactId || useFloatingId;
|
|
2260
|
-
let devMessageSet;
|
|
2261
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2262
|
-
devMessageSet = /* @__PURE__ */ new Set();
|
|
2263
|
-
}
|
|
2264
|
-
function warn() {
|
|
2265
|
-
var _devMessageSet;
|
|
2266
|
-
for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2267
|
-
messages[_key] = arguments[_key];
|
|
2268
|
-
}
|
|
2269
|
-
const message = "Floating UI: " + messages.join(" ");
|
|
2270
|
-
if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
|
|
2271
|
-
var _devMessageSet2;
|
|
2272
|
-
(_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
|
|
2273
|
-
console.warn(message);
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
function error() {
|
|
2277
|
-
var _devMessageSet3;
|
|
2278
|
-
for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2279
|
-
messages[_key2] = arguments[_key2];
|
|
2280
|
-
}
|
|
2281
|
-
const message = "Floating UI: " + messages.join(" ");
|
|
2282
|
-
if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
|
|
2283
|
-
var _devMessageSet4;
|
|
2284
|
-
(_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
|
|
2285
|
-
console.error(message);
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
const FloatingArrow = /* @__PURE__ */ React.forwardRef(function FloatingArrow2(props, ref) {
|
|
2289
|
-
const {
|
|
2290
|
-
context: {
|
|
2291
|
-
placement,
|
|
2292
|
-
elements: {
|
|
2293
|
-
floating
|
|
2294
|
-
},
|
|
2295
|
-
middlewareData: {
|
|
2296
|
-
arrow: arrow2,
|
|
2297
|
-
shift: shift2
|
|
2298
|
-
}
|
|
2299
|
-
},
|
|
2300
|
-
width = 14,
|
|
2301
|
-
height = 7,
|
|
2302
|
-
tipRadius = 0,
|
|
2303
|
-
strokeWidth = 0,
|
|
2304
|
-
staticOffset,
|
|
2305
|
-
stroke,
|
|
2306
|
-
d,
|
|
2307
|
-
style: {
|
|
2308
|
-
transform,
|
|
2309
|
-
...restStyle
|
|
2310
|
-
} = {},
|
|
2311
|
-
...rest
|
|
2312
|
-
} = props;
|
|
2313
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2314
|
-
if (!ref) {
|
|
2315
|
-
warn("The `ref` prop is required for `FloatingArrow`.");
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
const clipPathId = useId();
|
|
2319
|
-
const [isRTL2, setIsRTL] = React.useState(false);
|
|
2320
|
-
index$1(() => {
|
|
2321
|
-
if (!floating) return;
|
|
2322
|
-
const isRTL3 = getComputedStyle$1(floating).direction === "rtl";
|
|
2323
|
-
if (isRTL3) {
|
|
2324
|
-
setIsRTL(true);
|
|
2325
|
-
}
|
|
2326
|
-
}, [floating]);
|
|
2327
|
-
if (!floating) {
|
|
2328
|
-
return null;
|
|
2329
|
-
}
|
|
2330
|
-
const [side, alignment] = placement.split("-");
|
|
2331
|
-
const isVerticalSide = side === "top" || side === "bottom";
|
|
2332
|
-
let computedStaticOffset = staticOffset;
|
|
2333
|
-
if (isVerticalSide && shift2 != null && shift2.x || !isVerticalSide && shift2 != null && shift2.y) {
|
|
2334
|
-
computedStaticOffset = null;
|
|
2335
|
-
}
|
|
2336
|
-
const computedStrokeWidth = strokeWidth * 2;
|
|
2337
|
-
const halfStrokeWidth = computedStrokeWidth / 2;
|
|
2338
|
-
const svgX = width / 2 * (tipRadius / -8 + 1);
|
|
2339
|
-
const svgY = height / 2 * tipRadius / 4;
|
|
2340
|
-
const isCustomShape = !!d;
|
|
2341
|
-
const yOffsetProp = computedStaticOffset && alignment === "end" ? "bottom" : "top";
|
|
2342
|
-
let xOffsetProp = computedStaticOffset && alignment === "end" ? "right" : "left";
|
|
2343
|
-
if (computedStaticOffset && isRTL2) {
|
|
2344
|
-
xOffsetProp = alignment === "end" ? "left" : "right";
|
|
2345
|
-
}
|
|
2346
|
-
const arrowX = (arrow2 == null ? void 0 : arrow2.x) != null ? computedStaticOffset || arrow2.x : "";
|
|
2347
|
-
const arrowY = (arrow2 == null ? void 0 : arrow2.y) != null ? computedStaticOffset || arrow2.y : "";
|
|
2348
|
-
const dValue = d || "M0,0" + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + " Z";
|
|
2349
|
-
const rotation = {
|
|
2350
|
-
top: isCustomShape ? "rotate(180deg)" : "",
|
|
2351
|
-
left: isCustomShape ? "rotate(90deg)" : "rotate(-90deg)",
|
|
2352
|
-
bottom: isCustomShape ? "" : "rotate(180deg)",
|
|
2353
|
-
right: isCustomShape ? "rotate(-90deg)" : "rotate(90deg)"
|
|
2354
|
-
}[side];
|
|
2355
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
2356
|
-
...rest,
|
|
2357
|
-
"aria-hidden": true,
|
|
2358
|
-
ref,
|
|
2359
|
-
width: isCustomShape ? width : width + computedStrokeWidth,
|
|
2360
|
-
height: width,
|
|
2361
|
-
viewBox: "0 0 " + width + " " + (height > width ? height : width),
|
|
2362
|
-
style: {
|
|
2363
|
-
position: "absolute",
|
|
2364
|
-
pointerEvents: "none",
|
|
2365
|
-
[xOffsetProp]: arrowX,
|
|
2366
|
-
[yOffsetProp]: arrowY,
|
|
2367
|
-
[side]: isVerticalSide || isCustomShape ? "100%" : "calc(100% - " + computedStrokeWidth / 2 + "px)",
|
|
2368
|
-
transform: [rotation, transform].filter((t) => !!t).join(" "),
|
|
2369
|
-
...restStyle
|
|
2370
|
-
},
|
|
2371
|
-
children: [computedStrokeWidth > 0 && /* @__PURE__ */ jsx("path", {
|
|
2372
|
-
clipPath: "url(#" + clipPathId + ")",
|
|
2373
|
-
fill: "none",
|
|
2374
|
-
stroke,
|
|
2375
|
-
strokeWidth: computedStrokeWidth + (d ? 0 : 1),
|
|
2376
|
-
d: dValue
|
|
2377
|
-
}), /* @__PURE__ */ jsx("path", {
|
|
2378
|
-
stroke: computedStrokeWidth && !d ? rest.fill : "none",
|
|
2379
|
-
d: dValue
|
|
2380
|
-
}), /* @__PURE__ */ jsx("clipPath", {
|
|
2381
|
-
id: clipPathId,
|
|
2382
|
-
children: /* @__PURE__ */ jsx("rect", {
|
|
2383
|
-
x: -halfStrokeWidth,
|
|
2384
|
-
y: halfStrokeWidth * (isCustomShape ? -1 : 1),
|
|
2385
|
-
width: width + computedStrokeWidth,
|
|
2386
|
-
height: width
|
|
2387
|
-
})
|
|
2388
|
-
})]
|
|
2389
|
-
});
|
|
2390
|
-
});
|
|
2391
|
-
function createEventEmitter() {
|
|
2392
|
-
const map = /* @__PURE__ */ new Map();
|
|
2393
|
-
return {
|
|
2394
|
-
emit(event, data) {
|
|
2395
|
-
var _map$get;
|
|
2396
|
-
(_map$get = map.get(event)) == null || _map$get.forEach((listener) => listener(data));
|
|
2397
|
-
},
|
|
2398
|
-
on(event, listener) {
|
|
2399
|
-
if (!map.has(event)) {
|
|
2400
|
-
map.set(event, /* @__PURE__ */ new Set());
|
|
2401
|
-
}
|
|
2402
|
-
map.get(event).add(listener);
|
|
2403
|
-
},
|
|
2404
|
-
off(event, listener) {
|
|
2405
|
-
var _map$get2;
|
|
2406
|
-
(_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
|
|
2407
|
-
}
|
|
2408
|
-
};
|
|
2409
|
-
}
|
|
2410
|
-
const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
|
|
2411
|
-
const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
|
|
2412
|
-
const useFloatingParentNodeId = () => {
|
|
2413
|
-
var _React$useContext;
|
|
2414
|
-
return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
|
|
2415
|
-
};
|
|
2416
|
-
const useFloatingTree = () => React.useContext(FloatingTreeContext);
|
|
2417
|
-
function createAttribute(name) {
|
|
2418
|
-
return "data-floating-ui-" + name;
|
|
2419
|
-
}
|
|
2420
|
-
let rafId = 0;
|
|
2421
|
-
function enqueueFocus(el, options) {
|
|
2422
|
-
if (options === void 0) {
|
|
2423
|
-
options = {};
|
|
2424
|
-
}
|
|
2425
|
-
const {
|
|
2426
|
-
preventScroll = false,
|
|
2427
|
-
cancelPrevious = true,
|
|
2428
|
-
sync = false
|
|
2429
|
-
} = options;
|
|
2430
|
-
cancelPrevious && cancelAnimationFrame(rafId);
|
|
2431
|
-
const exec = () => el == null ? void 0 : el.focus({
|
|
2432
|
-
preventScroll
|
|
2433
|
-
});
|
|
2434
|
-
if (sync) {
|
|
2435
|
-
exec();
|
|
2436
|
-
} else {
|
|
2437
|
-
rafId = requestAnimationFrame(exec);
|
|
2438
|
-
}
|
|
2439
|
-
}
|
|
2440
|
-
function getDocument(node) {
|
|
2441
|
-
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
2442
|
-
}
|
|
2443
|
-
let counterMap = /* @__PURE__ */ new WeakMap();
|
|
2444
|
-
let uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
|
|
2445
|
-
let markerMap = {};
|
|
2446
|
-
let lockCount$1 = 0;
|
|
2447
|
-
const supportsInert = () => typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype;
|
|
2448
|
-
const unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
|
|
2449
|
-
const correctElements = (parent, targets) => targets.map((target) => {
|
|
2450
|
-
if (parent.contains(target)) {
|
|
2451
|
-
return target;
|
|
2452
|
-
}
|
|
2453
|
-
const correctedTarget = unwrapHost(target);
|
|
2454
|
-
if (parent.contains(correctedTarget)) {
|
|
2455
|
-
return correctedTarget;
|
|
2456
|
-
}
|
|
2457
|
-
return null;
|
|
2458
|
-
}).filter((x) => x != null);
|
|
2459
|
-
function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
|
|
2460
|
-
const markerName = "data-floating-ui-inert";
|
|
2461
|
-
const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
|
|
2462
|
-
const avoidElements = correctElements(body, uncorrectedAvoidElements);
|
|
2463
|
-
const elementsToKeep = /* @__PURE__ */ new Set();
|
|
2464
|
-
const elementsToStop = new Set(avoidElements);
|
|
2465
|
-
const hiddenElements = [];
|
|
2466
|
-
if (!markerMap[markerName]) {
|
|
2467
|
-
markerMap[markerName] = /* @__PURE__ */ new WeakMap();
|
|
2468
|
-
}
|
|
2469
|
-
const markerCounter = markerMap[markerName];
|
|
2470
|
-
avoidElements.forEach(keep);
|
|
2471
|
-
deep(body);
|
|
2472
|
-
elementsToKeep.clear();
|
|
2473
|
-
function keep(el) {
|
|
2474
|
-
if (!el || elementsToKeep.has(el)) {
|
|
2475
|
-
return;
|
|
2476
|
-
}
|
|
2477
|
-
elementsToKeep.add(el);
|
|
2478
|
-
el.parentNode && keep(el.parentNode);
|
|
2479
|
-
}
|
|
2480
|
-
function deep(parent) {
|
|
2481
|
-
if (!parent || elementsToStop.has(parent)) {
|
|
2482
|
-
return;
|
|
2483
|
-
}
|
|
2484
|
-
[].forEach.call(parent.children, (node) => {
|
|
2485
|
-
if (getNodeName(node) === "script") return;
|
|
2486
|
-
if (elementsToKeep.has(node)) {
|
|
2487
|
-
deep(node);
|
|
2488
|
-
} else {
|
|
2489
|
-
const attr = controlAttribute ? node.getAttribute(controlAttribute) : null;
|
|
2490
|
-
const alreadyHidden = attr !== null && attr !== "false";
|
|
2491
|
-
const currentCounterValue = counterMap.get(node) || 0;
|
|
2492
|
-
const counterValue = controlAttribute ? currentCounterValue + 1 : currentCounterValue;
|
|
2493
|
-
const markerValue = (markerCounter.get(node) || 0) + 1;
|
|
2494
|
-
counterMap.set(node, counterValue);
|
|
2495
|
-
markerCounter.set(node, markerValue);
|
|
2496
|
-
hiddenElements.push(node);
|
|
2497
|
-
if (counterValue === 1 && alreadyHidden) {
|
|
2498
|
-
uncontrolledElementsSet.add(node);
|
|
2499
|
-
}
|
|
2500
|
-
if (markerValue === 1) {
|
|
2501
|
-
node.setAttribute(markerName, "");
|
|
2502
|
-
}
|
|
2503
|
-
if (!alreadyHidden && controlAttribute) {
|
|
2504
|
-
node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2508
|
-
}
|
|
2509
|
-
lockCount$1++;
|
|
2510
|
-
return () => {
|
|
2511
|
-
hiddenElements.forEach((element) => {
|
|
2512
|
-
const currentCounterValue = counterMap.get(element) || 0;
|
|
2513
|
-
const counterValue = controlAttribute ? currentCounterValue - 1 : currentCounterValue;
|
|
2514
|
-
const markerValue = (markerCounter.get(element) || 0) - 1;
|
|
2515
|
-
counterMap.set(element, counterValue);
|
|
2516
|
-
markerCounter.set(element, markerValue);
|
|
2517
|
-
if (!counterValue) {
|
|
2518
|
-
if (!uncontrolledElementsSet.has(element) && controlAttribute) {
|
|
2519
|
-
element.removeAttribute(controlAttribute);
|
|
2520
|
-
}
|
|
2521
|
-
uncontrolledElementsSet.delete(element);
|
|
2522
|
-
}
|
|
2523
|
-
if (!markerValue) {
|
|
2524
|
-
element.removeAttribute(markerName);
|
|
2525
|
-
}
|
|
2526
|
-
});
|
|
2527
|
-
lockCount$1--;
|
|
2528
|
-
if (!lockCount$1) {
|
|
2529
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
2530
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
2531
|
-
uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
|
|
2532
|
-
markerMap = {};
|
|
2533
|
-
}
|
|
2534
|
-
};
|
|
2535
|
-
}
|
|
2536
|
-
function markOthers(avoidElements, ariaHidden, inert) {
|
|
2537
|
-
if (ariaHidden === void 0) {
|
|
2538
|
-
ariaHidden = false;
|
|
2539
|
-
}
|
|
2540
|
-
if (inert === void 0) {
|
|
2541
|
-
inert = false;
|
|
2542
|
-
}
|
|
2543
|
-
const body = getDocument(avoidElements[0]).body;
|
|
2544
|
-
return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll("[aria-live]"))), body, ariaHidden, inert);
|
|
2545
|
-
}
|
|
2546
|
-
const HIDDEN_STYLES = {
|
|
2547
|
-
border: 0,
|
|
2548
|
-
clip: "rect(0 0 0 0)",
|
|
2549
|
-
height: "1px",
|
|
2550
|
-
margin: "-1px",
|
|
2551
|
-
overflow: "hidden",
|
|
2552
|
-
padding: 0,
|
|
2553
|
-
position: "fixed",
|
|
2554
|
-
whiteSpace: "nowrap",
|
|
2555
|
-
width: "1px",
|
|
2556
|
-
top: 0,
|
|
2557
|
-
left: 0
|
|
2558
|
-
};
|
|
2559
|
-
const FocusGuard = /* @__PURE__ */ React.forwardRef(function FocusGuard2(props, ref) {
|
|
2560
|
-
const [role, setRole] = React.useState();
|
|
2561
|
-
index$1(() => {
|
|
2562
|
-
if (isSafari()) {
|
|
2563
|
-
setRole("button");
|
|
2564
|
-
}
|
|
2565
|
-
}, []);
|
|
2566
|
-
const restProps = {
|
|
2567
|
-
ref,
|
|
2568
|
-
tabIndex: 0,
|
|
2569
|
-
// Role is only for VoiceOver
|
|
2570
|
-
role,
|
|
2571
|
-
"aria-hidden": role ? void 0 : true,
|
|
2572
|
-
[createAttribute("focus-guard")]: "",
|
|
2573
|
-
style: HIDDEN_STYLES
|
|
2574
|
-
};
|
|
2575
|
-
return /* @__PURE__ */ jsx("span", {
|
|
2576
|
-
...props,
|
|
2577
|
-
...restProps
|
|
2578
|
-
});
|
|
2579
|
-
});
|
|
2580
|
-
const PortalContext = /* @__PURE__ */ React.createContext(null);
|
|
2581
|
-
const usePortalContext = () => React.useContext(PortalContext);
|
|
2582
|
-
function useLiteMergeRefs(refs) {
|
|
2583
|
-
return React.useMemo(() => {
|
|
2584
|
-
return (value) => {
|
|
2585
|
-
refs.forEach((ref) => {
|
|
2586
|
-
if (ref) {
|
|
2587
|
-
ref.current = value;
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
120
|
+
right: rightPx > minRightPx ? rightPx : minRightPx,
|
|
121
|
+
top: controllerSize.bottom
|
|
2590
122
|
};
|
|
2591
|
-
}, refs);
|
|
2592
|
-
}
|
|
2593
|
-
const LIST_LIMIT = 20;
|
|
2594
|
-
let previouslyFocusedElements = [];
|
|
2595
|
-
function addPreviouslyFocusedElement(element) {
|
|
2596
|
-
previouslyFocusedElements = previouslyFocusedElements.filter((el) => el.isConnected);
|
|
2597
|
-
if (element && getNodeName(element) !== "body") {
|
|
2598
|
-
previouslyFocusedElements.push(element);
|
|
2599
|
-
if (previouslyFocusedElements.length > LIST_LIMIT) {
|
|
2600
|
-
previouslyFocusedElements = previouslyFocusedElements.slice(-20);
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
|
-
function getPreviouslyFocusedElement() {
|
|
2605
|
-
return previouslyFocusedElements.slice().reverse().find((el) => el.isConnected);
|
|
2606
|
-
}
|
|
2607
|
-
function getFirstTabbableElement(container) {
|
|
2608
|
-
const tabbableOptions = getTabbableOptions();
|
|
2609
|
-
if (isTabbable(container, tabbableOptions)) {
|
|
2610
|
-
return container;
|
|
2611
123
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
if (!orderRef.current.includes("floating") && !((_floatingFocusElement = floatingFocusElement.getAttribute("role")) != null && _floatingFocusElement.includes("dialog"))) {
|
|
2617
|
-
return;
|
|
2618
|
-
}
|
|
2619
|
-
const options = getTabbableOptions();
|
|
2620
|
-
const focusableElements = focusable(floatingFocusElement, options);
|
|
2621
|
-
const tabbableContent = focusableElements.filter((element) => {
|
|
2622
|
-
const dataTabIndex = element.getAttribute("data-tabindex") || "";
|
|
2623
|
-
return isTabbable(element, options) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
|
|
2624
|
-
});
|
|
2625
|
-
const tabIndex = floatingFocusElement.getAttribute("tabindex");
|
|
2626
|
-
if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
|
|
2627
|
-
if (tabIndex !== "0") {
|
|
2628
|
-
floatingFocusElement.setAttribute("tabindex", "0");
|
|
2629
|
-
}
|
|
2630
|
-
} else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
|
|
2631
|
-
floatingFocusElement.setAttribute("tabindex", "-1");
|
|
2632
|
-
floatingFocusElement.setAttribute("data-tabindex", "-1");
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
const VisuallyHiddenDismiss = /* @__PURE__ */ React.forwardRef(function VisuallyHiddenDismiss2(props, ref) {
|
|
2636
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2637
|
-
...props,
|
|
2638
|
-
type: "button",
|
|
2639
|
-
ref,
|
|
2640
|
-
tabIndex: -1,
|
|
2641
|
-
style: HIDDEN_STYLES
|
|
2642
|
-
});
|
|
2643
|
-
});
|
|
2644
|
-
function FloatingFocusManager(props) {
|
|
2645
|
-
const {
|
|
2646
|
-
context,
|
|
2647
|
-
children,
|
|
2648
|
-
disabled = false,
|
|
2649
|
-
order = ["content"],
|
|
2650
|
-
guards: _guards = true,
|
|
2651
|
-
initialFocus = 0,
|
|
2652
|
-
returnFocus = true,
|
|
2653
|
-
restoreFocus = false,
|
|
2654
|
-
modal = true,
|
|
2655
|
-
visuallyHiddenDismiss = false,
|
|
2656
|
-
closeOnFocusOut = true,
|
|
2657
|
-
outsideElementsInert = false,
|
|
2658
|
-
getInsideElements: _getInsideElements = () => []
|
|
2659
|
-
} = props;
|
|
2660
|
-
const {
|
|
2661
|
-
open,
|
|
2662
|
-
onOpenChange,
|
|
2663
|
-
events,
|
|
2664
|
-
dataRef,
|
|
2665
|
-
elements: {
|
|
2666
|
-
domReference,
|
|
2667
|
-
floating
|
|
2668
|
-
}
|
|
2669
|
-
} = context;
|
|
2670
|
-
const getNodeId = useEffectEvent(() => {
|
|
2671
|
-
var _dataRef$current$floa;
|
|
2672
|
-
return (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
|
|
2673
|
-
});
|
|
2674
|
-
const getInsideElements = useEffectEvent(_getInsideElements);
|
|
2675
|
-
const ignoreInitialFocus = typeof initialFocus === "number" && initialFocus < 0;
|
|
2676
|
-
const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
|
|
2677
|
-
const inertSupported = supportsInert();
|
|
2678
|
-
const guards = inertSupported ? _guards : true;
|
|
2679
|
-
const useInert = !guards || inertSupported && outsideElementsInert;
|
|
2680
|
-
const orderRef = useLatestRef$1(order);
|
|
2681
|
-
const initialFocusRef = useLatestRef$1(initialFocus);
|
|
2682
|
-
const returnFocusRef = useLatestRef$1(returnFocus);
|
|
2683
|
-
const tree = useFloatingTree();
|
|
2684
|
-
const portalContext = usePortalContext();
|
|
2685
|
-
const startDismissButtonRef = React.useRef(null);
|
|
2686
|
-
const endDismissButtonRef = React.useRef(null);
|
|
2687
|
-
const preventReturnFocusRef = React.useRef(false);
|
|
2688
|
-
const isPointerDownRef = React.useRef(false);
|
|
2689
|
-
const tabbableIndexRef = React.useRef(-1);
|
|
2690
|
-
const isInsidePortal = portalContext != null;
|
|
2691
|
-
const floatingFocusElement = getFloatingFocusElement(floating);
|
|
2692
|
-
const getTabbableContent = useEffectEvent(function(container) {
|
|
2693
|
-
if (container === void 0) {
|
|
2694
|
-
container = floatingFocusElement;
|
|
2695
|
-
}
|
|
2696
|
-
return container ? tabbable(container, getTabbableOptions()) : [];
|
|
2697
|
-
});
|
|
2698
|
-
const getTabbableElements = useEffectEvent((container) => {
|
|
2699
|
-
const content = getTabbableContent(container);
|
|
2700
|
-
return orderRef.current.map((type) => {
|
|
2701
|
-
if (domReference && type === "reference") {
|
|
2702
|
-
return domReference;
|
|
2703
|
-
}
|
|
2704
|
-
if (floatingFocusElement && type === "floating") {
|
|
2705
|
-
return floatingFocusElement;
|
|
2706
|
-
}
|
|
2707
|
-
return content;
|
|
2708
|
-
}).filter(Boolean).flat();
|
|
2709
|
-
});
|
|
2710
|
-
React.useEffect(() => {
|
|
2711
|
-
if (disabled) return;
|
|
2712
|
-
if (!modal) return;
|
|
2713
|
-
function onKeyDown(event) {
|
|
2714
|
-
if (event.key === "Tab") {
|
|
2715
|
-
if (contains(floatingFocusElement, activeElement(getDocument$1(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
|
|
2716
|
-
stopEvent(event);
|
|
2717
|
-
}
|
|
2718
|
-
const els = getTabbableElements();
|
|
2719
|
-
const target = getTarget(event);
|
|
2720
|
-
if (orderRef.current[0] === "reference" && target === domReference) {
|
|
2721
|
-
stopEvent(event);
|
|
2722
|
-
if (event.shiftKey) {
|
|
2723
|
-
enqueueFocus(els[els.length - 1]);
|
|
2724
|
-
} else {
|
|
2725
|
-
enqueueFocus(els[1]);
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
if (orderRef.current[1] === "floating" && target === floatingFocusElement && event.shiftKey) {
|
|
2729
|
-
stopEvent(event);
|
|
2730
|
-
enqueueFocus(els[0]);
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
const doc = getDocument$1(floatingFocusElement);
|
|
2735
|
-
doc.addEventListener("keydown", onKeyDown);
|
|
2736
|
-
return () => {
|
|
2737
|
-
doc.removeEventListener("keydown", onKeyDown);
|
|
2738
|
-
};
|
|
2739
|
-
}, [disabled, domReference, floatingFocusElement, modal, orderRef, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
|
|
2740
|
-
React.useEffect(() => {
|
|
2741
|
-
if (disabled) return;
|
|
2742
|
-
if (!floating) return;
|
|
2743
|
-
function handleFocusIn(event) {
|
|
2744
|
-
const target = getTarget(event);
|
|
2745
|
-
const tabbableContent = getTabbableContent();
|
|
2746
|
-
const tabbableIndex = tabbableContent.indexOf(target);
|
|
2747
|
-
if (tabbableIndex !== -1) {
|
|
2748
|
-
tabbableIndexRef.current = tabbableIndex;
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
floating.addEventListener("focusin", handleFocusIn);
|
|
2752
|
-
return () => {
|
|
2753
|
-
floating.removeEventListener("focusin", handleFocusIn);
|
|
2754
|
-
};
|
|
2755
|
-
}, [disabled, floating, getTabbableContent]);
|
|
2756
|
-
React.useEffect(() => {
|
|
2757
|
-
if (disabled) return;
|
|
2758
|
-
if (!closeOnFocusOut) return;
|
|
2759
|
-
function handlePointerDown() {
|
|
2760
|
-
isPointerDownRef.current = true;
|
|
2761
|
-
setTimeout(() => {
|
|
2762
|
-
isPointerDownRef.current = false;
|
|
2763
|
-
});
|
|
2764
|
-
}
|
|
2765
|
-
function handleFocusOutside(event) {
|
|
2766
|
-
const relatedTarget = event.relatedTarget;
|
|
2767
|
-
const currentTarget = event.currentTarget;
|
|
2768
|
-
queueMicrotask(() => {
|
|
2769
|
-
const nodeId = getNodeId();
|
|
2770
|
-
const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute("focus-guard")) || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => {
|
|
2771
|
-
var _node$context, _node$context2;
|
|
2772
|
-
return contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget);
|
|
2773
|
-
}) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => {
|
|
2774
|
-
var _node$context3, _node$context4, _node$context5;
|
|
2775
|
-
return [(_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating, getFloatingFocusElement((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.floating)].includes(relatedTarget) || ((_node$context5 = node.context) == null ? void 0 : _node$context5.elements.domReference) === relatedTarget;
|
|
2776
|
-
})));
|
|
2777
|
-
if (currentTarget === domReference && floatingFocusElement) {
|
|
2778
|
-
handleTabIndex(floatingFocusElement, orderRef);
|
|
2779
|
-
}
|
|
2780
|
-
if (restoreFocus && movedToUnrelatedNode && activeElement(getDocument$1(floatingFocusElement)) === getDocument$1(floatingFocusElement).body) {
|
|
2781
|
-
if (isHTMLElement(floatingFocusElement)) {
|
|
2782
|
-
floatingFocusElement.focus();
|
|
2783
|
-
}
|
|
2784
|
-
const prevTabbableIndex = tabbableIndexRef.current;
|
|
2785
|
-
const tabbableContent = getTabbableContent();
|
|
2786
|
-
const nodeToFocus = tabbableContent[prevTabbableIndex] || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
|
|
2787
|
-
if (isHTMLElement(nodeToFocus)) {
|
|
2788
|
-
nodeToFocus.focus();
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
|
|
2792
|
-
relatedTarget !== getPreviouslyFocusedElement()) {
|
|
2793
|
-
preventReturnFocusRef.current = true;
|
|
2794
|
-
onOpenChange(false, event, "focus-out");
|
|
2795
|
-
}
|
|
2796
|
-
});
|
|
2797
|
-
}
|
|
2798
|
-
if (floating && isHTMLElement(domReference)) {
|
|
2799
|
-
domReference.addEventListener("focusout", handleFocusOutside);
|
|
2800
|
-
domReference.addEventListener("pointerdown", handlePointerDown);
|
|
2801
|
-
floating.addEventListener("focusout", handleFocusOutside);
|
|
2802
|
-
return () => {
|
|
2803
|
-
domReference.removeEventListener("focusout", handleFocusOutside);
|
|
2804
|
-
domReference.removeEventListener("pointerdown", handlePointerDown);
|
|
2805
|
-
floating.removeEventListener("focusout", handleFocusOutside);
|
|
2806
|
-
};
|
|
2807
|
-
}
|
|
2808
|
-
}, [disabled, domReference, floating, floatingFocusElement, modal, tree, portalContext, onOpenChange, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef]);
|
|
2809
|
-
const beforeGuardRef = React.useRef(null);
|
|
2810
|
-
const afterGuardRef = React.useRef(null);
|
|
2811
|
-
const mergedBeforeGuardRef = useLiteMergeRefs([beforeGuardRef, portalContext == null ? void 0 : portalContext.beforeInsideRef]);
|
|
2812
|
-
const mergedAfterGuardRef = useLiteMergeRefs([afterGuardRef, portalContext == null ? void 0 : portalContext.afterInsideRef]);
|
|
2813
|
-
React.useEffect(() => {
|
|
2814
|
-
var _portalContext$portal, _ancestors$find;
|
|
2815
|
-
if (disabled) return;
|
|
2816
|
-
if (!floating) return;
|
|
2817
|
-
const portalNodes = Array.from((portalContext == null || (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute("portal") + "]")) || []);
|
|
2818
|
-
const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
|
|
2819
|
-
const ancestorFloatingNodes = tree && !modal ? ancestors.map((node) => {
|
|
2820
|
-
var _node$context6;
|
|
2821
|
-
return (_node$context6 = node.context) == null ? void 0 : _node$context6.elements.floating;
|
|
2822
|
-
}) : [];
|
|
2823
|
-
const rootAncestorComboboxDomReference = (_ancestors$find = ancestors.find((node) => {
|
|
2824
|
-
var _node$context7;
|
|
2825
|
-
return isTypeableCombobox(((_node$context7 = node.context) == null ? void 0 : _node$context7.elements.domReference) || null);
|
|
2826
|
-
})) == null || (_ancestors$find = _ancestors$find.context) == null ? void 0 : _ancestors$find.elements.domReference;
|
|
2827
|
-
const insideElements = [floating, rootAncestorComboboxDomReference, ...portalNodes, ...ancestorFloatingNodes, ...getInsideElements(), startDismissButtonRef.current, endDismissButtonRef.current, beforeGuardRef.current, afterGuardRef.current, portalContext == null ? void 0 : portalContext.beforeOutsideRef.current, portalContext == null ? void 0 : portalContext.afterOutsideRef.current, orderRef.current.includes("reference") || isUntrappedTypeableCombobox ? domReference : null].filter((x) => x != null);
|
|
2828
|
-
const cleanup = modal || isUntrappedTypeableCombobox ? markOthers(insideElements, !useInert, useInert) : markOthers(insideElements);
|
|
2829
|
-
return () => {
|
|
2830
|
-
cleanup();
|
|
2831
|
-
};
|
|
2832
|
-
}, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards, useInert, tree, getNodeId, getInsideElements]);
|
|
2833
|
-
index$1(() => {
|
|
2834
|
-
if (disabled || !isHTMLElement(floatingFocusElement)) return;
|
|
2835
|
-
const doc = getDocument$1(floatingFocusElement);
|
|
2836
|
-
const previouslyFocusedElement = activeElement(doc);
|
|
2837
|
-
queueMicrotask(() => {
|
|
2838
|
-
const focusableElements = getTabbableElements(floatingFocusElement);
|
|
2839
|
-
const initialFocusValue = initialFocusRef.current;
|
|
2840
|
-
const elToFocus = (typeof initialFocusValue === "number" ? focusableElements[initialFocusValue] : initialFocusValue.current) || floatingFocusElement;
|
|
2841
|
-
const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
|
|
2842
|
-
if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) {
|
|
2843
|
-
enqueueFocus(elToFocus, {
|
|
2844
|
-
preventScroll: elToFocus === floatingFocusElement
|
|
2845
|
-
});
|
|
2846
|
-
}
|
|
2847
|
-
});
|
|
2848
|
-
}, [disabled, open, floatingFocusElement, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
|
|
2849
|
-
index$1(() => {
|
|
2850
|
-
if (disabled || !floatingFocusElement) return;
|
|
2851
|
-
let preventReturnFocusScroll = false;
|
|
2852
|
-
const doc = getDocument$1(floatingFocusElement);
|
|
2853
|
-
const previouslyFocusedElement = activeElement(doc);
|
|
2854
|
-
addPreviouslyFocusedElement(previouslyFocusedElement);
|
|
2855
|
-
function onOpenChange2(_ref) {
|
|
2856
|
-
let {
|
|
2857
|
-
reason,
|
|
2858
|
-
event,
|
|
2859
|
-
nested
|
|
2860
|
-
} = _ref;
|
|
2861
|
-
if (["hover", "safe-polygon"].includes(reason) && event.type === "mouseleave") {
|
|
2862
|
-
preventReturnFocusRef.current = true;
|
|
2863
|
-
}
|
|
2864
|
-
if (reason !== "outside-press") return;
|
|
2865
|
-
if (nested) {
|
|
2866
|
-
preventReturnFocusRef.current = false;
|
|
2867
|
-
preventReturnFocusScroll = true;
|
|
2868
|
-
} else if (isVirtualClick(event) || isVirtualPointerEvent(event)) {
|
|
2869
|
-
preventReturnFocusRef.current = false;
|
|
2870
|
-
} else {
|
|
2871
|
-
let isPreventScrollSupported = false;
|
|
2872
|
-
document.createElement("div").focus({
|
|
2873
|
-
get preventScroll() {
|
|
2874
|
-
isPreventScrollSupported = true;
|
|
2875
|
-
return false;
|
|
2876
|
-
}
|
|
2877
|
-
});
|
|
2878
|
-
if (isPreventScrollSupported) {
|
|
2879
|
-
preventReturnFocusRef.current = false;
|
|
2880
|
-
preventReturnFocusScroll = true;
|
|
2881
|
-
} else {
|
|
2882
|
-
preventReturnFocusRef.current = true;
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
events.on("openchange", onOpenChange2);
|
|
2887
|
-
const fallbackEl = doc.createElement("span");
|
|
2888
|
-
fallbackEl.setAttribute("tabindex", "-1");
|
|
2889
|
-
fallbackEl.setAttribute("aria-hidden", "true");
|
|
2890
|
-
Object.assign(fallbackEl.style, HIDDEN_STYLES);
|
|
2891
|
-
if (isInsidePortal && domReference) {
|
|
2892
|
-
domReference.insertAdjacentElement("afterend", fallbackEl);
|
|
2893
|
-
}
|
|
2894
|
-
function getReturnElement() {
|
|
2895
|
-
if (typeof returnFocusRef.current === "boolean") {
|
|
2896
|
-
const el = domReference || getPreviouslyFocusedElement();
|
|
2897
|
-
return el && el.isConnected ? el : fallbackEl;
|
|
2898
|
-
}
|
|
2899
|
-
return returnFocusRef.current.current || fallbackEl;
|
|
2900
|
-
}
|
|
2901
|
-
return () => {
|
|
2902
|
-
events.off("openchange", onOpenChange2);
|
|
2903
|
-
const activeEl = activeElement(doc);
|
|
2904
|
-
const isFocusInsideFloatingTree = contains(floating, activeEl) || tree && getNodeChildren(tree.nodesRef.current, getNodeId()).some((node) => {
|
|
2905
|
-
var _node$context8;
|
|
2906
|
-
return contains((_node$context8 = node.context) == null ? void 0 : _node$context8.elements.floating, activeEl);
|
|
2907
|
-
});
|
|
2908
|
-
const returnElement = getReturnElement();
|
|
2909
|
-
queueMicrotask(() => {
|
|
2910
|
-
const tabbableReturnElement = getFirstTabbableElement(returnElement);
|
|
2911
|
-
if (
|
|
2912
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2913
|
-
returnFocusRef.current && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
|
|
2914
|
-
// since it likely entered a different element which should be
|
|
2915
|
-
// respected: https://github.com/floating-ui/floating-ui/issues/2607
|
|
2916
|
-
(tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)
|
|
2917
|
-
) {
|
|
2918
|
-
tabbableReturnElement.focus({
|
|
2919
|
-
preventScroll: preventReturnFocusScroll
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
fallbackEl.remove();
|
|
2923
|
-
});
|
|
2924
|
-
};
|
|
2925
|
-
}, [disabled, floating, floatingFocusElement, returnFocusRef, dataRef, events, tree, isInsidePortal, domReference, getNodeId]);
|
|
2926
|
-
React.useEffect(() => {
|
|
2927
|
-
queueMicrotask(() => {
|
|
2928
|
-
preventReturnFocusRef.current = false;
|
|
2929
|
-
});
|
|
2930
|
-
}, [disabled]);
|
|
2931
|
-
index$1(() => {
|
|
2932
|
-
if (disabled) return;
|
|
2933
|
-
if (!portalContext) return;
|
|
2934
|
-
portalContext.setFocusManagerState({
|
|
2935
|
-
modal,
|
|
2936
|
-
closeOnFocusOut,
|
|
2937
|
-
open,
|
|
2938
|
-
onOpenChange,
|
|
2939
|
-
domReference
|
|
2940
|
-
});
|
|
2941
|
-
return () => {
|
|
2942
|
-
portalContext.setFocusManagerState(null);
|
|
124
|
+
if (verticalPosition === PopOverVariant.positionabove) {
|
|
125
|
+
return {
|
|
126
|
+
left: leftPx > minLeftPx ? leftPx : minLeftPx,
|
|
127
|
+
top: getArrowTopxPx(controllerSize)
|
|
2943
128
|
};
|
|
2944
|
-
}, [disabled, portalContext, modal, open, onOpenChange, closeOnFocusOut, domReference]);
|
|
2945
|
-
index$1(() => {
|
|
2946
|
-
if (disabled) return;
|
|
2947
|
-
if (!floatingFocusElement) return;
|
|
2948
|
-
handleTabIndex(floatingFocusElement, orderRef);
|
|
2949
|
-
}, [disabled, floatingFocusElement, orderRef]);
|
|
2950
|
-
function renderDismissButton(location) {
|
|
2951
|
-
if (disabled || !visuallyHiddenDismiss || !modal) {
|
|
2952
|
-
return null;
|
|
2953
|
-
}
|
|
2954
|
-
return /* @__PURE__ */ jsx(VisuallyHiddenDismiss, {
|
|
2955
|
-
ref: location === "start" ? startDismissButtonRef : endDismissButtonRef,
|
|
2956
|
-
onClick: (event) => onOpenChange(false, event.nativeEvent),
|
|
2957
|
-
children: typeof visuallyHiddenDismiss === "string" ? visuallyHiddenDismiss : "Dismiss"
|
|
2958
|
-
});
|
|
2959
|
-
}
|
|
2960
|
-
const shouldRenderGuards = !disabled && guards && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
|
|
2961
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2962
|
-
children: [shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
|
|
2963
|
-
"data-type": "inside",
|
|
2964
|
-
ref: mergedBeforeGuardRef,
|
|
2965
|
-
onFocus: (event) => {
|
|
2966
|
-
if (modal) {
|
|
2967
|
-
const els = getTabbableElements();
|
|
2968
|
-
enqueueFocus(order[0] === "reference" ? els[0] : els[els.length - 1]);
|
|
2969
|
-
} else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
|
|
2970
|
-
preventReturnFocusRef.current = false;
|
|
2971
|
-
if (isOutsideEvent(event, portalContext.portalNode)) {
|
|
2972
|
-
const nextTabbable = getNextTabbable(domReference);
|
|
2973
|
-
nextTabbable == null || nextTabbable.focus();
|
|
2974
|
-
} else {
|
|
2975
|
-
var _portalContext$before;
|
|
2976
|
-
(_portalContext$before = portalContext.beforeOutsideRef.current) == null || _portalContext$before.focus();
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
}
|
|
2980
|
-
}), !isUntrappedTypeableCombobox && renderDismissButton("start"), children, renderDismissButton("end"), shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
|
|
2981
|
-
"data-type": "inside",
|
|
2982
|
-
ref: mergedAfterGuardRef,
|
|
2983
|
-
onFocus: (event) => {
|
|
2984
|
-
if (modal) {
|
|
2985
|
-
enqueueFocus(getTabbableElements()[0]);
|
|
2986
|
-
} else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
|
|
2987
|
-
if (closeOnFocusOut) {
|
|
2988
|
-
preventReturnFocusRef.current = true;
|
|
2989
|
-
}
|
|
2990
|
-
if (isOutsideEvent(event, portalContext.portalNode)) {
|
|
2991
|
-
const prevTabbable = getPreviousTabbable(domReference);
|
|
2992
|
-
prevTabbable == null || prevTabbable.focus();
|
|
2993
|
-
} else {
|
|
2994
|
-
var _portalContext$afterO;
|
|
2995
|
-
(_portalContext$afterO = portalContext.afterOutsideRef.current) == null || _portalContext$afterO.focus();
|
|
2996
|
-
}
|
|
2997
|
-
}
|
|
2998
|
-
}
|
|
2999
|
-
})]
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
function isButtonTarget(event) {
|
|
3003
|
-
return isHTMLElement(event.target) && event.target.tagName === "BUTTON";
|
|
3004
|
-
}
|
|
3005
|
-
function isAnchorTarget(event) {
|
|
3006
|
-
return isHTMLElement(event.target) && event.target.tagName === "A";
|
|
3007
|
-
}
|
|
3008
|
-
function isSpaceIgnored(element) {
|
|
3009
|
-
return isTypeableElement(element);
|
|
3010
|
-
}
|
|
3011
|
-
function useClick(context, props) {
|
|
3012
|
-
if (props === void 0) {
|
|
3013
|
-
props = {};
|
|
3014
129
|
}
|
|
3015
|
-
const {
|
|
3016
|
-
open,
|
|
3017
|
-
onOpenChange,
|
|
3018
|
-
dataRef,
|
|
3019
|
-
elements: {
|
|
3020
|
-
domReference
|
|
3021
|
-
}
|
|
3022
|
-
} = context;
|
|
3023
|
-
const {
|
|
3024
|
-
enabled = true,
|
|
3025
|
-
event: eventOption = "click",
|
|
3026
|
-
toggle = true,
|
|
3027
|
-
ignoreMouse = false,
|
|
3028
|
-
keyboardHandlers = true,
|
|
3029
|
-
stickIfOpen = true
|
|
3030
|
-
} = props;
|
|
3031
|
-
const pointerTypeRef = React.useRef();
|
|
3032
|
-
const didKeyDownRef = React.useRef(false);
|
|
3033
|
-
const reference = React.useMemo(() => ({
|
|
3034
|
-
onPointerDown(event) {
|
|
3035
|
-
pointerTypeRef.current = event.pointerType;
|
|
3036
|
-
},
|
|
3037
|
-
onMouseDown(event) {
|
|
3038
|
-
const pointerType = pointerTypeRef.current;
|
|
3039
|
-
if (event.button !== 0) return;
|
|
3040
|
-
if (eventOption === "click") return;
|
|
3041
|
-
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
3042
|
-
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "mousedown" : true)) {
|
|
3043
|
-
onOpenChange(false, event.nativeEvent, "click");
|
|
3044
|
-
} else {
|
|
3045
|
-
event.preventDefault();
|
|
3046
|
-
onOpenChange(true, event.nativeEvent, "click");
|
|
3047
|
-
}
|
|
3048
|
-
},
|
|
3049
|
-
onClick(event) {
|
|
3050
|
-
const pointerType = pointerTypeRef.current;
|
|
3051
|
-
if (eventOption === "mousedown" && pointerTypeRef.current) {
|
|
3052
|
-
pointerTypeRef.current = void 0;
|
|
3053
|
-
return;
|
|
3054
|
-
}
|
|
3055
|
-
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
3056
|
-
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "click" : true)) {
|
|
3057
|
-
onOpenChange(false, event.nativeEvent, "click");
|
|
3058
|
-
} else {
|
|
3059
|
-
onOpenChange(true, event.nativeEvent, "click");
|
|
3060
|
-
}
|
|
3061
|
-
},
|
|
3062
|
-
onKeyDown(event) {
|
|
3063
|
-
pointerTypeRef.current = void 0;
|
|
3064
|
-
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
3065
|
-
return;
|
|
3066
|
-
}
|
|
3067
|
-
if (event.key === " " && !isSpaceIgnored(domReference)) {
|
|
3068
|
-
event.preventDefault();
|
|
3069
|
-
didKeyDownRef.current = true;
|
|
3070
|
-
}
|
|
3071
|
-
if (isAnchorTarget(event)) {
|
|
3072
|
-
return;
|
|
3073
|
-
}
|
|
3074
|
-
if (event.key === "Enter") {
|
|
3075
|
-
if (open && toggle) {
|
|
3076
|
-
onOpenChange(false, event.nativeEvent, "click");
|
|
3077
|
-
} else {
|
|
3078
|
-
onOpenChange(true, event.nativeEvent, "click");
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
},
|
|
3082
|
-
onKeyUp(event) {
|
|
3083
|
-
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
3084
|
-
return;
|
|
3085
|
-
}
|
|
3086
|
-
if (event.key === " " && didKeyDownRef.current) {
|
|
3087
|
-
didKeyDownRef.current = false;
|
|
3088
|
-
if (open && toggle) {
|
|
3089
|
-
onOpenChange(false, event.nativeEvent, "click");
|
|
3090
|
-
} else {
|
|
3091
|
-
onOpenChange(true, event.nativeEvent, "click");
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
}), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);
|
|
3096
|
-
return React.useMemo(() => enabled ? {
|
|
3097
|
-
reference
|
|
3098
|
-
} : {}, [enabled, reference]);
|
|
3099
|
-
}
|
|
3100
|
-
const bubbleHandlerKeys = {
|
|
3101
|
-
pointerdown: "onPointerDown",
|
|
3102
|
-
mousedown: "onMouseDown",
|
|
3103
|
-
click: "onClick"
|
|
3104
|
-
};
|
|
3105
|
-
const captureHandlerKeys = {
|
|
3106
|
-
pointerdown: "onPointerDownCapture",
|
|
3107
|
-
mousedown: "onMouseDownCapture",
|
|
3108
|
-
click: "onClickCapture"
|
|
3109
|
-
};
|
|
3110
|
-
const normalizeProp = (normalizable) => {
|
|
3111
|
-
var _normalizable$escapeK, _normalizable$outside;
|
|
3112
130
|
return {
|
|
3113
|
-
|
|
3114
|
-
|
|
131
|
+
left: leftPx > minLeftPx ? leftPx : minLeftPx,
|
|
132
|
+
top: controllerSize.bottom
|
|
3115
133
|
};
|
|
3116
134
|
};
|
|
3117
|
-
function useDismiss(context, props) {
|
|
3118
|
-
if (props === void 0) {
|
|
3119
|
-
props = {};
|
|
3120
|
-
}
|
|
3121
|
-
const {
|
|
3122
|
-
open,
|
|
3123
|
-
onOpenChange,
|
|
3124
|
-
elements,
|
|
3125
|
-
dataRef
|
|
3126
|
-
} = context;
|
|
3127
|
-
const {
|
|
3128
|
-
enabled = true,
|
|
3129
|
-
escapeKey = true,
|
|
3130
|
-
outsidePress: unstable_outsidePress = true,
|
|
3131
|
-
outsidePressEvent = "pointerdown",
|
|
3132
|
-
referencePress = false,
|
|
3133
|
-
referencePressEvent = "pointerdown",
|
|
3134
|
-
ancestorScroll = false,
|
|
3135
|
-
bubbles,
|
|
3136
|
-
capture
|
|
3137
|
-
} = props;
|
|
3138
|
-
const tree = useFloatingTree();
|
|
3139
|
-
const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === "function" ? unstable_outsidePress : () => false);
|
|
3140
|
-
const outsidePress = typeof unstable_outsidePress === "function" ? outsidePressFn : unstable_outsidePress;
|
|
3141
|
-
const insideReactTreeRef = React.useRef(false);
|
|
3142
|
-
const endedOrStartedInsideRef = React.useRef(false);
|
|
3143
|
-
const {
|
|
3144
|
-
escapeKey: escapeKeyBubbles,
|
|
3145
|
-
outsidePress: outsidePressBubbles
|
|
3146
|
-
} = normalizeProp(bubbles);
|
|
3147
|
-
const {
|
|
3148
|
-
escapeKey: escapeKeyCapture,
|
|
3149
|
-
outsidePress: outsidePressCapture
|
|
3150
|
-
} = normalizeProp(capture);
|
|
3151
|
-
const isComposingRef = React.useRef(false);
|
|
3152
|
-
const closeOnEscapeKeyDown = useEffectEvent((event) => {
|
|
3153
|
-
var _dataRef$current$floa;
|
|
3154
|
-
if (!open || !enabled || !escapeKey || event.key !== "Escape") {
|
|
3155
|
-
return;
|
|
3156
|
-
}
|
|
3157
|
-
if (isComposingRef.current) {
|
|
3158
|
-
return;
|
|
3159
|
-
}
|
|
3160
|
-
const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
|
|
3161
|
-
const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
|
|
3162
|
-
if (!escapeKeyBubbles) {
|
|
3163
|
-
event.stopPropagation();
|
|
3164
|
-
if (children.length > 0) {
|
|
3165
|
-
let shouldDismiss = true;
|
|
3166
|
-
children.forEach((child) => {
|
|
3167
|
-
var _child$context;
|
|
3168
|
-
if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
|
|
3169
|
-
shouldDismiss = false;
|
|
3170
|
-
return;
|
|
3171
|
-
}
|
|
3172
|
-
});
|
|
3173
|
-
if (!shouldDismiss) {
|
|
3174
|
-
return;
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
}
|
|
3178
|
-
onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, "escape-key");
|
|
3179
|
-
});
|
|
3180
|
-
const closeOnEscapeKeyDownCapture = useEffectEvent((event) => {
|
|
3181
|
-
var _getTarget2;
|
|
3182
|
-
const callback = () => {
|
|
3183
|
-
var _getTarget;
|
|
3184
|
-
closeOnEscapeKeyDown(event);
|
|
3185
|
-
(_getTarget = getTarget(event)) == null || _getTarget.removeEventListener("keydown", callback);
|
|
3186
|
-
};
|
|
3187
|
-
(_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener("keydown", callback);
|
|
3188
|
-
});
|
|
3189
|
-
const closeOnPressOutside = useEffectEvent((event) => {
|
|
3190
|
-
var _dataRef$current$floa2;
|
|
3191
|
-
const insideReactTree = insideReactTreeRef.current;
|
|
3192
|
-
insideReactTreeRef.current = false;
|
|
3193
|
-
const endedOrStartedInside = endedOrStartedInsideRef.current;
|
|
3194
|
-
endedOrStartedInsideRef.current = false;
|
|
3195
|
-
if (outsidePressEvent === "click" && endedOrStartedInside) {
|
|
3196
|
-
return;
|
|
3197
|
-
}
|
|
3198
|
-
if (insideReactTree) {
|
|
3199
|
-
return;
|
|
3200
|
-
}
|
|
3201
|
-
if (typeof outsidePress === "function" && !outsidePress(event)) {
|
|
3202
|
-
return;
|
|
3203
|
-
}
|
|
3204
|
-
const target = getTarget(event);
|
|
3205
|
-
const inertSelector = "[" + createAttribute("inert") + "]";
|
|
3206
|
-
const markers = getDocument$1(elements.floating).querySelectorAll(inertSelector);
|
|
3207
|
-
let targetRootAncestor = isElement(target) ? target : null;
|
|
3208
|
-
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
3209
|
-
const nextParent = getParentNode(targetRootAncestor);
|
|
3210
|
-
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
|
|
3211
|
-
break;
|
|
3212
|
-
}
|
|
3213
|
-
targetRootAncestor = nextParent;
|
|
3214
|
-
}
|
|
3215
|
-
if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
3216
|
-
!contains(target, elements.floating) && // If the target root element contains none of the markers, then the
|
|
3217
|
-
// element was injected after the floating element rendered.
|
|
3218
|
-
Array.from(markers).every((marker) => !contains(targetRootAncestor, marker))) {
|
|
3219
|
-
return;
|
|
3220
|
-
}
|
|
3221
|
-
if (isHTMLElement(target) && floating) {
|
|
3222
|
-
const lastTraversableNode = isLastTraversableNode(target);
|
|
3223
|
-
const style = getComputedStyle$1(target);
|
|
3224
|
-
const scrollRe = /auto|scroll/;
|
|
3225
|
-
const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
|
|
3226
|
-
const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
|
|
3227
|
-
const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
3228
|
-
const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
3229
|
-
const isRTL2 = style.direction === "rtl";
|
|
3230
|
-
const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
|
|
3231
|
-
const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
|
|
3232
|
-
if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
|
|
3233
|
-
return;
|
|
3234
|
-
}
|
|
3235
|
-
}
|
|
3236
|
-
const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
|
|
3237
|
-
const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
|
|
3238
|
-
var _node$context;
|
|
3239
|
-
return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
|
|
3240
|
-
});
|
|
3241
|
-
if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
|
|
3242
|
-
return;
|
|
3243
|
-
}
|
|
3244
|
-
const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
|
|
3245
|
-
if (children.length > 0) {
|
|
3246
|
-
let shouldDismiss = true;
|
|
3247
|
-
children.forEach((child) => {
|
|
3248
|
-
var _child$context2;
|
|
3249
|
-
if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
|
|
3250
|
-
shouldDismiss = false;
|
|
3251
|
-
return;
|
|
3252
|
-
}
|
|
3253
|
-
});
|
|
3254
|
-
if (!shouldDismiss) {
|
|
3255
|
-
return;
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
onOpenChange(false, event, "outside-press");
|
|
3259
|
-
});
|
|
3260
|
-
const closeOnPressOutsideCapture = useEffectEvent((event) => {
|
|
3261
|
-
var _getTarget4;
|
|
3262
|
-
const callback = () => {
|
|
3263
|
-
var _getTarget3;
|
|
3264
|
-
closeOnPressOutside(event);
|
|
3265
|
-
(_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
|
|
3266
|
-
};
|
|
3267
|
-
(_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
|
|
3268
|
-
});
|
|
3269
|
-
React.useEffect(() => {
|
|
3270
|
-
if (!open || !enabled) {
|
|
3271
|
-
return;
|
|
3272
|
-
}
|
|
3273
|
-
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
3274
|
-
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
3275
|
-
let compositionTimeout = -1;
|
|
3276
|
-
function onScroll(event) {
|
|
3277
|
-
onOpenChange(false, event, "ancestor-scroll");
|
|
3278
|
-
}
|
|
3279
|
-
function handleCompositionStart() {
|
|
3280
|
-
window.clearTimeout(compositionTimeout);
|
|
3281
|
-
isComposingRef.current = true;
|
|
3282
|
-
}
|
|
3283
|
-
function handleCompositionEnd() {
|
|
3284
|
-
compositionTimeout = window.setTimeout(
|
|
3285
|
-
() => {
|
|
3286
|
-
isComposingRef.current = false;
|
|
3287
|
-
},
|
|
3288
|
-
// 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
|
|
3289
|
-
// Only apply to WebKit for the test to remain 0ms.
|
|
3290
|
-
isWebKit() ? 5 : 0
|
|
3291
|
-
);
|
|
3292
|
-
}
|
|
3293
|
-
const doc = getDocument$1(elements.floating);
|
|
3294
|
-
if (escapeKey) {
|
|
3295
|
-
doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
3296
|
-
doc.addEventListener("compositionstart", handleCompositionStart);
|
|
3297
|
-
doc.addEventListener("compositionend", handleCompositionEnd);
|
|
3298
|
-
}
|
|
3299
|
-
outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
3300
|
-
let ancestors = [];
|
|
3301
|
-
if (ancestorScroll) {
|
|
3302
|
-
if (isElement(elements.domReference)) {
|
|
3303
|
-
ancestors = getOverflowAncestors(elements.domReference);
|
|
3304
|
-
}
|
|
3305
|
-
if (isElement(elements.floating)) {
|
|
3306
|
-
ancestors = ancestors.concat(getOverflowAncestors(elements.floating));
|
|
3307
|
-
}
|
|
3308
|
-
if (!isElement(elements.reference) && elements.reference && elements.reference.contextElement) {
|
|
3309
|
-
ancestors = ancestors.concat(getOverflowAncestors(elements.reference.contextElement));
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
ancestors = ancestors.filter((ancestor) => {
|
|
3313
|
-
var _doc$defaultView;
|
|
3314
|
-
return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
|
|
3315
|
-
});
|
|
3316
|
-
ancestors.forEach((ancestor) => {
|
|
3317
|
-
ancestor.addEventListener("scroll", onScroll, {
|
|
3318
|
-
passive: true
|
|
3319
|
-
});
|
|
3320
|
-
});
|
|
3321
|
-
return () => {
|
|
3322
|
-
if (escapeKey) {
|
|
3323
|
-
doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
3324
|
-
doc.removeEventListener("compositionstart", handleCompositionStart);
|
|
3325
|
-
doc.removeEventListener("compositionend", handleCompositionEnd);
|
|
3326
|
-
}
|
|
3327
|
-
outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
3328
|
-
ancestors.forEach((ancestor) => {
|
|
3329
|
-
ancestor.removeEventListener("scroll", onScroll);
|
|
3330
|
-
});
|
|
3331
|
-
window.clearTimeout(compositionTimeout);
|
|
3332
|
-
};
|
|
3333
|
-
}, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
|
|
3334
|
-
React.useEffect(() => {
|
|
3335
|
-
insideReactTreeRef.current = false;
|
|
3336
|
-
}, [outsidePress, outsidePressEvent]);
|
|
3337
|
-
const reference = React.useMemo(() => ({
|
|
3338
|
-
onKeyDown: closeOnEscapeKeyDown,
|
|
3339
|
-
...referencePress && {
|
|
3340
|
-
[bubbleHandlerKeys[referencePressEvent]]: (event) => {
|
|
3341
|
-
onOpenChange(false, event.nativeEvent, "reference-press");
|
|
3342
|
-
},
|
|
3343
|
-
...referencePressEvent !== "click" && {
|
|
3344
|
-
onClick(event) {
|
|
3345
|
-
onOpenChange(false, event.nativeEvent, "reference-press");
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3348
|
-
}
|
|
3349
|
-
}), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
|
|
3350
|
-
const floating = React.useMemo(() => ({
|
|
3351
|
-
onKeyDown: closeOnEscapeKeyDown,
|
|
3352
|
-
onMouseDown() {
|
|
3353
|
-
endedOrStartedInsideRef.current = true;
|
|
3354
|
-
},
|
|
3355
|
-
onMouseUp() {
|
|
3356
|
-
endedOrStartedInsideRef.current = true;
|
|
3357
|
-
},
|
|
3358
|
-
[captureHandlerKeys[outsidePressEvent]]: () => {
|
|
3359
|
-
insideReactTreeRef.current = true;
|
|
3360
|
-
}
|
|
3361
|
-
}), [closeOnEscapeKeyDown, outsidePressEvent]);
|
|
3362
|
-
return React.useMemo(() => enabled ? {
|
|
3363
|
-
reference,
|
|
3364
|
-
floating
|
|
3365
|
-
} : {}, [enabled, reference, floating]);
|
|
3366
|
-
}
|
|
3367
|
-
function useFloatingRootContext(options) {
|
|
3368
|
-
const {
|
|
3369
|
-
open = false,
|
|
3370
|
-
onOpenChange: onOpenChangeProp,
|
|
3371
|
-
elements: elementsProp
|
|
3372
|
-
} = options;
|
|
3373
|
-
const floatingId = useId();
|
|
3374
|
-
const dataRef = React.useRef({});
|
|
3375
|
-
const [events] = React.useState(() => createEventEmitter());
|
|
3376
|
-
const nested = useFloatingParentNodeId() != null;
|
|
3377
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3378
|
-
const optionDomReference = elementsProp.reference;
|
|
3379
|
-
if (optionDomReference && !isElement(optionDomReference)) {
|
|
3380
|
-
error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
|
|
3384
|
-
const onOpenChange = useEffectEvent((open2, event, reason) => {
|
|
3385
|
-
dataRef.current.openEvent = open2 ? event : void 0;
|
|
3386
|
-
events.emit("openchange", {
|
|
3387
|
-
open: open2,
|
|
3388
|
-
event,
|
|
3389
|
-
reason,
|
|
3390
|
-
nested
|
|
3391
|
-
});
|
|
3392
|
-
onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
|
|
3393
|
-
});
|
|
3394
|
-
const refs = React.useMemo(() => ({
|
|
3395
|
-
setPositionReference
|
|
3396
|
-
}), []);
|
|
3397
|
-
const elements = React.useMemo(() => ({
|
|
3398
|
-
reference: positionReference || elementsProp.reference || null,
|
|
3399
|
-
floating: elementsProp.floating || null,
|
|
3400
|
-
domReference: elementsProp.reference
|
|
3401
|
-
}), [positionReference, elementsProp.reference, elementsProp.floating]);
|
|
3402
|
-
return React.useMemo(() => ({
|
|
3403
|
-
dataRef,
|
|
3404
|
-
open,
|
|
3405
|
-
onOpenChange,
|
|
3406
|
-
elements,
|
|
3407
|
-
events,
|
|
3408
|
-
floatingId,
|
|
3409
|
-
refs
|
|
3410
|
-
}), [open, onOpenChange, elements, events, floatingId, refs]);
|
|
3411
|
-
}
|
|
3412
|
-
function useFloating(options) {
|
|
3413
|
-
if (options === void 0) {
|
|
3414
|
-
options = {};
|
|
3415
|
-
}
|
|
3416
|
-
const {
|
|
3417
|
-
nodeId
|
|
3418
|
-
} = options;
|
|
3419
|
-
const internalRootContext = useFloatingRootContext({
|
|
3420
|
-
...options,
|
|
3421
|
-
elements: {
|
|
3422
|
-
reference: null,
|
|
3423
|
-
floating: null,
|
|
3424
|
-
...options.elements
|
|
3425
|
-
}
|
|
3426
|
-
});
|
|
3427
|
-
const rootContext = options.rootContext || internalRootContext;
|
|
3428
|
-
const computedElements = rootContext.elements;
|
|
3429
|
-
const [_domReference, setDomReference] = React.useState(null);
|
|
3430
|
-
const [positionReference, _setPositionReference] = React.useState(null);
|
|
3431
|
-
const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
|
|
3432
|
-
const domReference = optionDomReference || _domReference;
|
|
3433
|
-
const domReferenceRef = React.useRef(null);
|
|
3434
|
-
const tree = useFloatingTree();
|
|
3435
|
-
index$1(() => {
|
|
3436
|
-
if (domReference) {
|
|
3437
|
-
domReferenceRef.current = domReference;
|
|
3438
|
-
}
|
|
3439
|
-
}, [domReference]);
|
|
3440
|
-
const position = useFloating$1({
|
|
3441
|
-
...options,
|
|
3442
|
-
elements: {
|
|
3443
|
-
...computedElements,
|
|
3444
|
-
...positionReference && {
|
|
3445
|
-
reference: positionReference
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
});
|
|
3449
|
-
const setPositionReference = React.useCallback((node) => {
|
|
3450
|
-
const computedPositionReference = isElement(node) ? {
|
|
3451
|
-
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
3452
|
-
getClientRects: () => node.getClientRects(),
|
|
3453
|
-
contextElement: node
|
|
3454
|
-
} : node;
|
|
3455
|
-
_setPositionReference(computedPositionReference);
|
|
3456
|
-
position.refs.setReference(computedPositionReference);
|
|
3457
|
-
}, [position.refs]);
|
|
3458
|
-
const setReference = React.useCallback((node) => {
|
|
3459
|
-
if (isElement(node) || node === null) {
|
|
3460
|
-
domReferenceRef.current = node;
|
|
3461
|
-
setDomReference(node);
|
|
3462
|
-
}
|
|
3463
|
-
if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
|
|
3464
|
-
// `null` to support `positionReference` + an unstable `reference`
|
|
3465
|
-
// callback ref.
|
|
3466
|
-
node !== null && !isElement(node)) {
|
|
3467
|
-
position.refs.setReference(node);
|
|
3468
|
-
}
|
|
3469
|
-
}, [position.refs]);
|
|
3470
|
-
const refs = React.useMemo(() => ({
|
|
3471
|
-
...position.refs,
|
|
3472
|
-
setReference,
|
|
3473
|
-
setPositionReference,
|
|
3474
|
-
domReference: domReferenceRef
|
|
3475
|
-
}), [position.refs, setReference, setPositionReference]);
|
|
3476
|
-
const elements = React.useMemo(() => ({
|
|
3477
|
-
...position.elements,
|
|
3478
|
-
domReference
|
|
3479
|
-
}), [position.elements, domReference]);
|
|
3480
|
-
const context = React.useMemo(() => ({
|
|
3481
|
-
...position,
|
|
3482
|
-
...rootContext,
|
|
3483
|
-
refs,
|
|
3484
|
-
elements,
|
|
3485
|
-
nodeId
|
|
3486
|
-
}), [position, refs, elements, nodeId, rootContext]);
|
|
3487
|
-
index$1(() => {
|
|
3488
|
-
rootContext.dataRef.current.floatingContext = context;
|
|
3489
|
-
const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
|
|
3490
|
-
if (node) {
|
|
3491
|
-
node.context = context;
|
|
3492
|
-
}
|
|
3493
|
-
});
|
|
3494
|
-
return React.useMemo(() => ({
|
|
3495
|
-
...position,
|
|
3496
|
-
context,
|
|
3497
|
-
refs,
|
|
3498
|
-
elements
|
|
3499
|
-
}), [position, refs, elements, context]);
|
|
3500
|
-
}
|
|
3501
|
-
function mergeProps(userProps, propsList, elementKey) {
|
|
3502
|
-
const map = /* @__PURE__ */ new Map();
|
|
3503
|
-
const isItem = elementKey === "item";
|
|
3504
|
-
let domUserProps = userProps;
|
|
3505
|
-
if (isItem && userProps) {
|
|
3506
|
-
const {
|
|
3507
|
-
[ACTIVE_KEY]: _,
|
|
3508
|
-
[SELECTED_KEY]: __,
|
|
3509
|
-
...validProps
|
|
3510
|
-
} = userProps;
|
|
3511
|
-
domUserProps = validProps;
|
|
3512
|
-
}
|
|
3513
|
-
return {
|
|
3514
|
-
...elementKey === "floating" && {
|
|
3515
|
-
tabIndex: -1,
|
|
3516
|
-
[FOCUSABLE_ATTRIBUTE]: ""
|
|
3517
|
-
},
|
|
3518
|
-
...domUserProps,
|
|
3519
|
-
...propsList.map((value) => {
|
|
3520
|
-
const propsOrGetProps = value ? value[elementKey] : null;
|
|
3521
|
-
if (typeof propsOrGetProps === "function") {
|
|
3522
|
-
return userProps ? propsOrGetProps(userProps) : null;
|
|
3523
|
-
}
|
|
3524
|
-
return propsOrGetProps;
|
|
3525
|
-
}).concat(userProps).reduce((acc, props) => {
|
|
3526
|
-
if (!props) {
|
|
3527
|
-
return acc;
|
|
3528
|
-
}
|
|
3529
|
-
Object.entries(props).forEach((_ref) => {
|
|
3530
|
-
let [key, value] = _ref;
|
|
3531
|
-
if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
|
|
3532
|
-
return;
|
|
3533
|
-
}
|
|
3534
|
-
if (key.indexOf("on") === 0) {
|
|
3535
|
-
if (!map.has(key)) {
|
|
3536
|
-
map.set(key, []);
|
|
3537
|
-
}
|
|
3538
|
-
if (typeof value === "function") {
|
|
3539
|
-
var _map$get;
|
|
3540
|
-
(_map$get = map.get(key)) == null || _map$get.push(value);
|
|
3541
|
-
acc[key] = function() {
|
|
3542
|
-
var _map$get2;
|
|
3543
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3544
|
-
args[_key] = arguments[_key];
|
|
3545
|
-
}
|
|
3546
|
-
return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
|
|
3547
|
-
};
|
|
3548
|
-
}
|
|
3549
|
-
} else {
|
|
3550
|
-
acc[key] = value;
|
|
3551
|
-
}
|
|
3552
|
-
});
|
|
3553
|
-
return acc;
|
|
3554
|
-
}, {})
|
|
3555
|
-
};
|
|
3556
|
-
}
|
|
3557
|
-
function useInteractions(propsList) {
|
|
3558
|
-
if (propsList === void 0) {
|
|
3559
|
-
propsList = [];
|
|
3560
|
-
}
|
|
3561
|
-
const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
|
|
3562
|
-
const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
|
|
3563
|
-
const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
|
|
3564
|
-
const getReferenceProps = React.useCallback(
|
|
3565
|
-
(userProps) => mergeProps(userProps, propsList, "reference"),
|
|
3566
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3567
|
-
referenceDeps
|
|
3568
|
-
);
|
|
3569
|
-
const getFloatingProps = React.useCallback(
|
|
3570
|
-
(userProps) => mergeProps(userProps, propsList, "floating"),
|
|
3571
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3572
|
-
floatingDeps
|
|
3573
|
-
);
|
|
3574
|
-
const getItemProps = React.useCallback(
|
|
3575
|
-
(userProps) => mergeProps(userProps, propsList, "item"),
|
|
3576
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3577
|
-
itemDeps
|
|
3578
|
-
);
|
|
3579
|
-
return React.useMemo(() => ({
|
|
3580
|
-
getReferenceProps,
|
|
3581
|
-
getFloatingProps,
|
|
3582
|
-
getItemProps
|
|
3583
|
-
}), [getReferenceProps, getFloatingProps, getItemProps]);
|
|
3584
|
-
}
|
|
3585
135
|
var PopOverVariant = /* @__PURE__ */ ((PopOverVariant2) => {
|
|
3586
136
|
PopOverVariant2["positionautomatic"] = "positionautomatic";
|
|
3587
137
|
PopOverVariant2["positionbelow"] = "positionbelow";
|
|
3588
138
|
PopOverVariant2["positionabove"] = "positionabove";
|
|
3589
139
|
return PopOverVariant2;
|
|
3590
140
|
})(PopOverVariant || {});
|
|
3591
|
-
const PopOver = React__default.forwardRef((props) => {
|
|
3592
|
-
var _a;
|
|
141
|
+
const PopOver = React__default.forwardRef((props, ref) => {
|
|
3593
142
|
const {
|
|
3594
143
|
id,
|
|
3595
144
|
children,
|
|
3596
145
|
controllerRef,
|
|
146
|
+
popOverRef,
|
|
147
|
+
show = false,
|
|
3597
148
|
className = "",
|
|
3598
149
|
variant = "positionautomatic",
|
|
3599
|
-
|
|
150
|
+
role,
|
|
3600
151
|
testId,
|
|
3601
|
-
|
|
3602
|
-
|
|
152
|
+
arrowClassName,
|
|
153
|
+
zIndex = ZIndex.PopOver
|
|
3603
154
|
} = props;
|
|
3604
|
-
const
|
|
155
|
+
const bubbleRef = popOverRef || useRef(null);
|
|
3605
156
|
const arrowRef = useRef(null);
|
|
3606
|
-
const
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
157
|
+
const bubbleSize = useSize(bubbleRef);
|
|
158
|
+
const [controllerSize, setControllerSize] = useState();
|
|
159
|
+
const controllerisVisible = useIsVisible(bubbleRef, 0);
|
|
160
|
+
const updateControllerSize = () => {
|
|
161
|
+
var _a;
|
|
162
|
+
setControllerSize((_a = controllerRef.current) == null ? void 0 : _a.getBoundingClientRect());
|
|
163
|
+
};
|
|
164
|
+
useInterval(updateControllerSize, 500);
|
|
165
|
+
useLayoutEvent(updateControllerSize, ["scroll", "resize"], 10);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
updateControllerSize();
|
|
168
|
+
}, []);
|
|
169
|
+
const isTooltip = role === "tooltip";
|
|
170
|
+
const popOverClasses = classNames(styles.popover, { [styles["popover--visible"]]: isTooltip ? show : controllerisVisible }, className);
|
|
171
|
+
const verticalPosition = controllerSize && bubbleSize && getVerticalPosition(controllerSize, bubbleSize, variant);
|
|
172
|
+
const arrowClasses = classNames(styles.popover__arrow, arrowClassName, {
|
|
173
|
+
[styles["popover__arrow--over"]]: verticalPosition === "positionbelow",
|
|
174
|
+
[styles["popover__arrow--under"]]: verticalPosition === "positionabove",
|
|
175
|
+
[styles["popover__arrow--visible"]]: isTooltip ? show : controllerisVisible
|
|
176
|
+
});
|
|
177
|
+
const bubbleStyle = controllerSize && bubbleSize && getBubbleStyle(controllerSize, bubbleSize, variant);
|
|
178
|
+
const arrowStyle = bubbleStyle && controllerSize && verticalPosition && getArrowStyle(bubbleStyle, controllerSize, verticalPosition);
|
|
179
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
id,
|
|
184
|
+
ref: mergeRefs([ref, bubbleRef]),
|
|
185
|
+
className: popOverClasses,
|
|
186
|
+
style: { ...bubbleStyle, zIndex },
|
|
187
|
+
"data-testid": testId,
|
|
188
|
+
"data-analyticsid": AnalyticsId.PopOver,
|
|
189
|
+
role,
|
|
190
|
+
children
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { ref: arrowRef, className: arrowClasses, style: { ...arrowStyle, zIndex } })
|
|
194
|
+
] });
|
|
3643
195
|
});
|
|
3644
196
|
PopOver.displayName = "PopOver";
|
|
3645
197
|
export {
|
|
3646
|
-
|
|
3647
|
-
|
|
198
|
+
PopOverVariant as P,
|
|
199
|
+
PopOver as a
|
|
3648
200
|
};
|
|
3649
201
|
//# sourceMappingURL=PopOver.js.map
|