@vritti/quantum-ui 0.5.9 → 0.6.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/dist/Avatar.js +1 -1
- package/dist/Checkbox2.js +1 -1
- package/dist/{CurrencyField.js → CurrencyFieldFilter.js} +150 -6
- package/dist/CurrencyFieldFilter.js.map +1 -0
- package/dist/CurrencySelector.js.map +1 -1
- package/dist/DatePicker.js +15 -0
- package/dist/DatePicker.js.map +1 -1
- package/dist/DateRangePicker.js +135 -9
- package/dist/DateRangePicker.js.map +1 -1
- package/dist/DateTimePicker.js +2 -2
- package/dist/DateTimePicker.js.map +1 -1
- package/dist/DetailSectionSkeleton.js +1 -1
- package/dist/ISOCountrySelect.js.map +1 -1
- package/dist/IconSelect.js +255 -269
- package/dist/IconSelect.js.map +1 -1
- package/dist/LocaleSelector.js.map +1 -1
- package/dist/PieChart.js +13 -9
- package/dist/PieChart.js.map +1 -1
- package/dist/Progress.js +1 -1
- package/dist/RadioGroup.js +1 -1
- package/dist/RelativeDayStrip.js +83 -0
- package/dist/RelativeDayStrip.js.map +1 -0
- package/dist/Select.js +25 -8
- package/dist/Select.js.map +1 -1
- package/dist/SelectFilter.js +27 -12
- package/dist/SelectFilter.js.map +1 -1
- package/dist/Switch.js +1 -1
- package/dist/TimezoneSelector.js.map +1 -1
- package/dist/assets/quantum-ui.css +8 -0
- package/dist/banknote.js +19 -0
- package/dist/banknote.js.map +1 -0
- package/dist/components/CurrencyField.js +1 -1
- package/dist/components/DateFilter.js +17 -74
- package/dist/components/DateFilter.js.map +1 -1
- package/dist/components/DateRangePicker.js +1 -1
- package/dist/components/FormattedDate.js +3 -3
- package/dist/components/FormattedDate.js.map +1 -1
- package/dist/dropdown-menu.js +3 -3
- package/dist/hooks/index.js +3 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index13.js +2 -2
- package/dist/index14.js +281 -22
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +22 -281
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +3 -3
- package/dist/index17.js +1 -1
- package/dist/index26.js +229 -34
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +1099 -206
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +2481 -1035
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +35 -2569
- package/dist/index29.js.map +1 -1
- package/dist/index30.js +2 -2
- package/dist/index35.js +4 -4
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts +27 -0
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts.map +1 -0
- package/dist/lib/components/CurrencyField/index.d.ts +2 -0
- package/dist/lib/components/CurrencyField/index.d.ts.map +1 -1
- package/dist/lib/components/DateFilter/DateFilter.d.ts +14 -6
- package/dist/lib/components/DateFilter/DateFilter.d.ts.map +1 -1
- package/dist/lib/components/DateFilter/index.d.ts +2 -2
- package/dist/lib/components/DateFilter/index.d.ts.map +1 -1
- package/dist/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/lib/components/DatePicker/RelativeDayStrip.d.ts +28 -0
- package/dist/lib/components/DatePicker/RelativeDayStrip.d.ts.map +1 -0
- package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts +28 -0
- package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts.map +1 -0
- package/dist/lib/components/DateRangePicker/index.d.ts +2 -0
- package/dist/lib/components/DateRangePicker/index.d.ts.map +1 -1
- package/dist/lib/components/PieChart/PieChart.d.ts +3 -1
- package/dist/lib/components/PieChart/PieChart.d.ts.map +1 -1
- package/dist/lib/components/Select/SelectFilter.d.ts +17 -4
- package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +2 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts +4 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/hooks/useMultiSelect.d.ts +2 -1
- package/dist/lib/components/Select/hooks/useMultiSelect.d.ts.map +1 -1
- package/dist/lib/components/index.d.ts +1 -1
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/hooks/index.d.ts +4 -3
- package/dist/lib/hooks/index.d.ts.map +1 -1
- package/dist/lib/hooks/useCategoricalColors.d.ts +3 -0
- package/dist/lib/hooks/useCategoricalColors.d.ts.map +1 -0
- package/dist/lib/hooks/useFormatters.d.ts +4 -1
- package/dist/lib/hooks/useFormatters.d.ts.map +1 -1
- package/dist/lib/hooks/useWorkspaceCurrency.d.ts +2 -0
- package/dist/lib/hooks/useWorkspaceCurrency.d.ts.map +1 -0
- package/dist/lib/hooks/useWorkspaceTimeZone.d.ts +2 -0
- package/dist/lib/hooks/useWorkspaceTimeZone.d.ts.map +1 -0
- package/dist/lib/selects/currency/CurrencyFilter.d.ts +3 -5
- package/dist/lib/selects/currency/CurrencyFilter.d.ts.map +1 -1
- package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts +3 -4
- package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts.map +1 -1
- package/dist/lib/selects/locale/LocaleFilter.d.ts +3 -4
- package/dist/lib/selects/locale/LocaleFilter.d.ts.map +1 -1
- package/dist/lib/selects/timezone/TimezoneFilter.d.ts +3 -4
- package/dist/lib/selects/timezone/TimezoneFilter.d.ts.map +1 -1
- package/dist/lib/types/table-filter.d.ts +8 -2
- package/dist/lib/types/table-filter.d.ts.map +1 -1
- package/dist/lib/types/utility.d.ts +2 -0
- package/dist/lib/types/utility.d.ts.map +1 -0
- package/dist/lib/utils/colors.d.ts +8 -0
- package/dist/lib/utils/colors.d.ts.map +1 -1
- package/dist/lib/utils/currency.d.ts +2 -2
- package/dist/lib/utils/currency.d.ts.map +1 -1
- package/dist/lib/utils/format.d.ts +2 -2
- package/dist/lib/utils/format.d.ts.map +1 -1
- package/dist/lib/utils/timezone.d.ts +2 -2
- package/dist/lib/utils/timezone.d.ts.map +1 -1
- package/dist/popover.js +1 -1
- package/dist/separator2.js +1 -1
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts +2 -2
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts.map +1 -1
- package/dist/types/table-filter.js.map +1 -1
- package/dist/types/utility.js +2 -0
- package/dist/types/utility.js.map +1 -0
- package/dist/useCategoricalColors.js +20 -0
- package/dist/useCategoricalColors.js.map +1 -0
- package/dist/useDataTable.js +2 -2
- package/dist/useDataTable.js.map +1 -1
- package/dist/useFormatters.js +13 -13
- package/dist/useFormatters.js.map +1 -1
- package/dist/useWorkspaceTimeZone.js +10 -0
- package/dist/useWorkspaceTimeZone.js.map +1 -0
- package/dist/utils/colors.js +187 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/currency.js +12 -12
- package/dist/utils/currency.js.map +1 -1
- package/dist/utils/format.js +6 -6
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/timezone.js +12 -12
- package/dist/utils/timezone.js.map +1 -1
- package/package.json +5 -1
- package/dist/CurrencyField.js.map +0 -1
- package/dist/lib/hooks/useBUCurrency.d.ts +0 -2
- package/dist/lib/hooks/useBUCurrency.d.ts.map +0 -1
- package/dist/lib/hooks/useBUTimezone.d.ts +0 -2
- package/dist/lib/hooks/useBUTimezone.d.ts.map +0 -1
- package/dist/useBUTimezone.js +0 -10
- package/dist/useBUTimezone.js.map +0 -1
package/dist/index28.js
CHANGED
|
@@ -1,1129 +1,2575 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { useLayoutEffect } from 'react';
|
|
3
|
+
import * as ReactDOM from 'react-dom';
|
|
4
4
|
import { P as Primitive } from './index20.js';
|
|
5
|
-
import { u as useCallbackRef$1 } from './index31.js';
|
|
6
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { u as useComposedRefs } from './index12.js';
|
|
7
|
+
import { c as createContextScope } from './index21.js';
|
|
8
|
+
import { u as useCallbackRef } from './index31.js';
|
|
9
|
+
import { u as useLayoutEffect2 } from './index25.js';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
|
|
22
|
-
const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
|
|
23
|
-
const lastFocusedElementRef = React.useRef(null);
|
|
24
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
25
|
-
const focusScope = React.useRef({
|
|
26
|
-
paused: false,
|
|
27
|
-
pause() {
|
|
28
|
-
this.paused = true;
|
|
29
|
-
},
|
|
30
|
-
resume() {
|
|
31
|
-
this.paused = false;
|
|
32
|
-
}
|
|
33
|
-
}).current;
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
if (trapped) {
|
|
36
|
-
let handleFocusIn2 = function(event) {
|
|
37
|
-
if (focusScope.paused || !container) return;
|
|
38
|
-
const target = event.target;
|
|
39
|
-
if (container.contains(target)) {
|
|
40
|
-
lastFocusedElementRef.current = target;
|
|
41
|
-
} else {
|
|
42
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
43
|
-
}
|
|
44
|
-
}, handleFocusOut2 = function(event) {
|
|
45
|
-
if (focusScope.paused || !container) return;
|
|
46
|
-
const relatedTarget = event.relatedTarget;
|
|
47
|
-
if (relatedTarget === null) return;
|
|
48
|
-
if (!container.contains(relatedTarget)) {
|
|
49
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
50
|
-
}
|
|
51
|
-
}, handleMutations2 = function(mutations) {
|
|
52
|
-
const focusedElement = document.activeElement;
|
|
53
|
-
if (focusedElement !== document.body) return;
|
|
54
|
-
for (const mutation of mutations) {
|
|
55
|
-
if (mutation.removedNodes.length > 0) focus(container);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
document.addEventListener("focusin", handleFocusIn2);
|
|
59
|
-
document.addEventListener("focusout", handleFocusOut2);
|
|
60
|
-
const mutationObserver = new MutationObserver(handleMutations2);
|
|
61
|
-
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
62
|
-
return () => {
|
|
63
|
-
document.removeEventListener("focusin", handleFocusIn2);
|
|
64
|
-
document.removeEventListener("focusout", handleFocusOut2);
|
|
65
|
-
mutationObserver.disconnect();
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}, [trapped, container, focusScope.paused]);
|
|
69
|
-
React.useEffect(() => {
|
|
70
|
-
if (container) {
|
|
71
|
-
focusScopesStack.add(focusScope);
|
|
72
|
-
const previouslyFocusedElement = document.activeElement;
|
|
73
|
-
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
74
|
-
if (!hasFocusedCandidate) {
|
|
75
|
-
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
76
|
-
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
77
|
-
container.dispatchEvent(mountEvent);
|
|
78
|
-
if (!mountEvent.defaultPrevented) {
|
|
79
|
-
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
80
|
-
if (document.activeElement === previouslyFocusedElement) {
|
|
81
|
-
focus(container);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return () => {
|
|
86
|
-
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
87
|
-
setTimeout(() => {
|
|
88
|
-
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
89
|
-
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
90
|
-
container.dispatchEvent(unmountEvent);
|
|
91
|
-
if (!unmountEvent.defaultPrevented) {
|
|
92
|
-
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
93
|
-
}
|
|
94
|
-
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
95
|
-
focusScopesStack.remove(focusScope);
|
|
96
|
-
}, 0);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
100
|
-
const handleKeyDown = React.useCallback(
|
|
101
|
-
(event) => {
|
|
102
|
-
if (!loop && !trapped) return;
|
|
103
|
-
if (focusScope.paused) return;
|
|
104
|
-
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
105
|
-
const focusedElement = document.activeElement;
|
|
106
|
-
if (isTabKey && focusedElement) {
|
|
107
|
-
const container2 = event.currentTarget;
|
|
108
|
-
const [first, last] = getTabbableEdges(container2);
|
|
109
|
-
const hasTabbableElementsInside = first && last;
|
|
110
|
-
if (!hasTabbableElementsInside) {
|
|
111
|
-
if (focusedElement === container2) event.preventDefault();
|
|
112
|
-
} else {
|
|
113
|
-
if (!event.shiftKey && focusedElement === last) {
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
if (loop) focus(first, { select: true });
|
|
116
|
-
} else if (event.shiftKey && focusedElement === first) {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
if (loop) focus(last, { select: true });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
[loop, trapped, focusScope.paused]
|
|
124
|
-
);
|
|
125
|
-
return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
11
|
+
/**
|
|
12
|
+
* Custom positioning reference element.
|
|
13
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
17
|
+
const min = Math.min;
|
|
18
|
+
const max = Math.max;
|
|
19
|
+
const round = Math.round;
|
|
20
|
+
const floor = Math.floor;
|
|
21
|
+
const createCoords = v => ({
|
|
22
|
+
x: v,
|
|
23
|
+
y: v
|
|
126
24
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
function getTabbableEdges(container) {
|
|
136
|
-
const candidates = getTabbableCandidates(container);
|
|
137
|
-
const first = findVisible(candidates, container);
|
|
138
|
-
const last = findVisible(candidates.reverse(), container);
|
|
139
|
-
return [first, last];
|
|
140
|
-
}
|
|
141
|
-
function getTabbableCandidates(container) {
|
|
142
|
-
const nodes = [];
|
|
143
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
144
|
-
acceptNode: (node) => {
|
|
145
|
-
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
146
|
-
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
147
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
151
|
-
return nodes;
|
|
25
|
+
const oppositeSideMap = {
|
|
26
|
+
left: 'right',
|
|
27
|
+
right: 'left',
|
|
28
|
+
bottom: 'top',
|
|
29
|
+
top: 'bottom'
|
|
30
|
+
};
|
|
31
|
+
function clamp(start, value, end) {
|
|
32
|
+
return max(start, min(value, end));
|
|
152
33
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
34
|
+
function evaluate(value, param) {
|
|
35
|
+
return typeof value === 'function' ? value(param) : value;
|
|
36
|
+
}
|
|
37
|
+
function getSide(placement) {
|
|
38
|
+
return placement.split('-')[0];
|
|
39
|
+
}
|
|
40
|
+
function getAlignment(placement) {
|
|
41
|
+
return placement.split('-')[1];
|
|
42
|
+
}
|
|
43
|
+
function getOppositeAxis(axis) {
|
|
44
|
+
return axis === 'x' ? 'y' : 'x';
|
|
157
45
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
46
|
+
function getAxisLength(axis) {
|
|
47
|
+
return axis === 'y' ? 'height' : 'width';
|
|
48
|
+
}
|
|
49
|
+
function getSideAxis(placement) {
|
|
50
|
+
const firstChar = placement[0];
|
|
51
|
+
return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
|
|
52
|
+
}
|
|
53
|
+
function getAlignmentAxis(placement) {
|
|
54
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
55
|
+
}
|
|
56
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
57
|
+
if (rtl === void 0) {
|
|
58
|
+
rtl = false;
|
|
59
|
+
}
|
|
60
|
+
const alignment = getAlignment(placement);
|
|
61
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
62
|
+
const length = getAxisLength(alignmentAxis);
|
|
63
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
64
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
65
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
164
66
|
}
|
|
165
|
-
return
|
|
67
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
166
68
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
69
|
+
function getExpandedPlacements(placement) {
|
|
70
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
71
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
169
72
|
}
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
73
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
74
|
+
return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
|
|
75
|
+
}
|
|
76
|
+
const lrPlacement = ['left', 'right'];
|
|
77
|
+
const rlPlacement = ['right', 'left'];
|
|
78
|
+
const tbPlacement = ['top', 'bottom'];
|
|
79
|
+
const btPlacement = ['bottom', 'top'];
|
|
80
|
+
function getSideList(side, isStart, rtl) {
|
|
81
|
+
switch (side) {
|
|
82
|
+
case 'top':
|
|
83
|
+
case 'bottom':
|
|
84
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
85
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
86
|
+
case 'left':
|
|
87
|
+
case 'right':
|
|
88
|
+
return isStart ? tbPlacement : btPlacement;
|
|
89
|
+
default:
|
|
90
|
+
return [];
|
|
176
91
|
}
|
|
177
92
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
let
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
activeFocusScope?.pause();
|
|
186
|
-
}
|
|
187
|
-
stack = arrayRemove(stack, focusScope);
|
|
188
|
-
stack.unshift(focusScope);
|
|
189
|
-
},
|
|
190
|
-
remove(focusScope) {
|
|
191
|
-
stack = arrayRemove(stack, focusScope);
|
|
192
|
-
stack[0]?.resume();
|
|
93
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
94
|
+
const alignment = getAlignment(placement);
|
|
95
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
96
|
+
if (alignment) {
|
|
97
|
+
list = list.map(side => side + "-" + alignment);
|
|
98
|
+
if (flipAlignment) {
|
|
99
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
193
100
|
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function arrayRemove(array, item) {
|
|
197
|
-
const updatedArray = [...array];
|
|
198
|
-
const index = updatedArray.indexOf(item);
|
|
199
|
-
if (index !== -1) {
|
|
200
|
-
updatedArray.splice(index, 1);
|
|
201
101
|
}
|
|
202
|
-
return
|
|
102
|
+
return list;
|
|
203
103
|
}
|
|
204
|
-
function
|
|
205
|
-
|
|
104
|
+
function getOppositePlacement(placement) {
|
|
105
|
+
const side = getSide(placement);
|
|
106
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
206
107
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return () => {
|
|
216
|
-
if (count === 1) {
|
|
217
|
-
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
218
|
-
}
|
|
219
|
-
count--;
|
|
220
|
-
};
|
|
221
|
-
}, []);
|
|
108
|
+
function expandPaddingObject(padding) {
|
|
109
|
+
return {
|
|
110
|
+
top: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
bottom: 0,
|
|
113
|
+
left: 0,
|
|
114
|
+
...padding
|
|
115
|
+
};
|
|
222
116
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
***************************************************************************** */
|
|
248
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var __assign = function() {
|
|
252
|
-
__assign = Object.assign || function __assign(t) {
|
|
253
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
254
|
-
s = arguments[i];
|
|
255
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
256
|
-
}
|
|
257
|
-
return t;
|
|
117
|
+
function getPaddingObject(padding) {
|
|
118
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
119
|
+
top: padding,
|
|
120
|
+
right: padding,
|
|
121
|
+
bottom: padding,
|
|
122
|
+
left: padding
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function rectToClientRect(rect) {
|
|
126
|
+
const {
|
|
127
|
+
x,
|
|
128
|
+
y,
|
|
129
|
+
width,
|
|
130
|
+
height
|
|
131
|
+
} = rect;
|
|
132
|
+
return {
|
|
133
|
+
width,
|
|
134
|
+
height,
|
|
135
|
+
top: y,
|
|
136
|
+
left: x,
|
|
137
|
+
right: x + width,
|
|
138
|
+
bottom: y + height,
|
|
139
|
+
x,
|
|
140
|
+
y
|
|
258
141
|
};
|
|
259
|
-
return __assign.apply(this, arguments);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
function __rest(s, e) {
|
|
263
|
-
var t = {};
|
|
264
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
265
|
-
t[p] = s[p];
|
|
266
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
267
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
268
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
269
|
-
t[p[i]] = s[p[i]];
|
|
270
|
-
}
|
|
271
|
-
return t;
|
|
272
142
|
}
|
|
273
143
|
|
|
274
|
-
function
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
144
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
145
|
+
let {
|
|
146
|
+
reference,
|
|
147
|
+
floating
|
|
148
|
+
} = _ref;
|
|
149
|
+
const sideAxis = getSideAxis(placement);
|
|
150
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
151
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
152
|
+
const side = getSide(placement);
|
|
153
|
+
const isVertical = sideAxis === 'y';
|
|
154
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
155
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
156
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
157
|
+
let coords;
|
|
158
|
+
switch (side) {
|
|
159
|
+
case 'top':
|
|
160
|
+
coords = {
|
|
161
|
+
x: commonX,
|
|
162
|
+
y: reference.y - floating.height
|
|
163
|
+
};
|
|
164
|
+
break;
|
|
165
|
+
case 'bottom':
|
|
166
|
+
coords = {
|
|
167
|
+
x: commonX,
|
|
168
|
+
y: reference.y + reference.height
|
|
169
|
+
};
|
|
170
|
+
break;
|
|
171
|
+
case 'right':
|
|
172
|
+
coords = {
|
|
173
|
+
x: reference.x + reference.width,
|
|
174
|
+
y: commonY
|
|
175
|
+
};
|
|
176
|
+
break;
|
|
177
|
+
case 'left':
|
|
178
|
+
coords = {
|
|
179
|
+
x: reference.x - floating.width,
|
|
180
|
+
y: commonY
|
|
181
|
+
};
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
coords = {
|
|
185
|
+
x: reference.x,
|
|
186
|
+
y: reference.y
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
switch (getAlignment(placement)) {
|
|
190
|
+
case 'start':
|
|
191
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
192
|
+
break;
|
|
193
|
+
case 'end':
|
|
194
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
195
|
+
break;
|
|
280
196
|
}
|
|
281
|
-
return
|
|
197
|
+
return coords;
|
|
282
198
|
}
|
|
283
199
|
|
|
284
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
285
|
-
var e = new Error(message);
|
|
286
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
var zeroRightClassName = 'right-scroll-bar-position';
|
|
290
|
-
var fullWidthClassName = 'width-before-scroll-bar';
|
|
291
|
-
var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
|
292
200
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* Assigns a value for a given ref, no matter of the ref format
|
|
300
|
-
* @param {RefObject} ref - a callback function or ref object
|
|
301
|
-
* @param value - a new value
|
|
302
|
-
*
|
|
303
|
-
* @see https://github.com/theKashey/use-callback-ref#assignref
|
|
304
|
-
* @example
|
|
305
|
-
* const refObject = useRef();
|
|
306
|
-
* const refFn = (ref) => {....}
|
|
307
|
-
*
|
|
308
|
-
* assignRef(refObject, "refValue");
|
|
309
|
-
* assignRef(refFn, "refValue");
|
|
201
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
202
|
+
* element is overflowing a given clipping boundary on each side.
|
|
203
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
204
|
+
* - negative = how many pixels left before it will overflow
|
|
205
|
+
* - 0 = lies flush with the boundary
|
|
206
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
310
207
|
*/
|
|
311
|
-
function
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
208
|
+
async function detectOverflow(state, options) {
|
|
209
|
+
var _await$platform$isEle;
|
|
210
|
+
if (options === void 0) {
|
|
211
|
+
options = {};
|
|
212
|
+
}
|
|
213
|
+
const {
|
|
214
|
+
x,
|
|
215
|
+
y,
|
|
216
|
+
platform,
|
|
217
|
+
rects,
|
|
218
|
+
elements,
|
|
219
|
+
strategy
|
|
220
|
+
} = state;
|
|
221
|
+
const {
|
|
222
|
+
boundary = 'clippingAncestors',
|
|
223
|
+
rootBoundary = 'viewport',
|
|
224
|
+
elementContext = 'floating',
|
|
225
|
+
altBoundary = false,
|
|
226
|
+
padding = 0
|
|
227
|
+
} = evaluate(options, state);
|
|
228
|
+
const paddingObject = getPaddingObject(padding);
|
|
229
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
230
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
231
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
232
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
233
|
+
boundary,
|
|
234
|
+
rootBoundary,
|
|
235
|
+
strategy
|
|
236
|
+
}));
|
|
237
|
+
const rect = elementContext === 'floating' ? {
|
|
238
|
+
x,
|
|
239
|
+
y,
|
|
240
|
+
width: rects.floating.width,
|
|
241
|
+
height: rects.floating.height
|
|
242
|
+
} : rects.reference;
|
|
243
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
244
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
245
|
+
x: 1,
|
|
246
|
+
y: 1
|
|
247
|
+
} : {
|
|
248
|
+
x: 1,
|
|
249
|
+
y: 1
|
|
250
|
+
};
|
|
251
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
252
|
+
elements,
|
|
253
|
+
rect,
|
|
254
|
+
offsetParent,
|
|
255
|
+
strategy
|
|
256
|
+
}) : rect);
|
|
257
|
+
return {
|
|
258
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
259
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
260
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
261
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
262
|
+
};
|
|
319
263
|
}
|
|
320
264
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
* @param initialValue - initial ref value
|
|
324
|
-
* @param {Function} callback - a callback to run when value changes
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
|
328
|
-
* ref.current = 1;
|
|
329
|
-
* // prints 0 -> 1
|
|
330
|
-
*
|
|
331
|
-
* @see https://reactjs.org/docs/hooks-reference.html#useref
|
|
332
|
-
* @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
333
|
-
* @returns {MutableRefObject}
|
|
334
|
-
*/
|
|
335
|
-
function useCallbackRef(initialValue, callback) {
|
|
336
|
-
var ref = useState(function () { return ({
|
|
337
|
-
// value
|
|
338
|
-
value: initialValue,
|
|
339
|
-
// last callback
|
|
340
|
-
callback: callback,
|
|
341
|
-
// "memoized" public interface
|
|
342
|
-
facade: {
|
|
343
|
-
get current() {
|
|
344
|
-
return ref.value;
|
|
345
|
-
},
|
|
346
|
-
set current(value) {
|
|
347
|
-
var last = ref.value;
|
|
348
|
-
if (last !== value) {
|
|
349
|
-
ref.value = value;
|
|
350
|
-
ref.callback(value, last);
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
}); })[0];
|
|
355
|
-
// update callback
|
|
356
|
-
ref.callback = callback;
|
|
357
|
-
return ref.facade;
|
|
358
|
-
}
|
|
265
|
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
|
266
|
+
const MAX_RESET_COUNT = 50;
|
|
359
267
|
|
|
360
|
-
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
361
|
-
var currentValues = new WeakMap();
|
|
362
268
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
|
|
269
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
270
|
+
* next to a given reference element.
|
|
366
271
|
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* @example
|
|
370
|
-
* const Component = React.forwardRef((props, ref) => {
|
|
371
|
-
* const ownRef = useRef();
|
|
372
|
-
* const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
|
|
373
|
-
* return <div ref={domRef}>...</div>
|
|
374
|
-
* }
|
|
272
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
273
|
+
* write one for the platform you are using Floating UI with.
|
|
375
274
|
*/
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
275
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
276
|
+
const {
|
|
277
|
+
placement = 'bottom',
|
|
278
|
+
strategy = 'absolute',
|
|
279
|
+
middleware = [],
|
|
280
|
+
platform
|
|
281
|
+
} = config;
|
|
282
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
283
|
+
...platform,
|
|
284
|
+
detectOverflow
|
|
285
|
+
};
|
|
286
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
287
|
+
let rects = await platform.getElementRects({
|
|
288
|
+
reference,
|
|
289
|
+
floating,
|
|
290
|
+
strategy
|
|
291
|
+
});
|
|
292
|
+
let {
|
|
293
|
+
x,
|
|
294
|
+
y
|
|
295
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
296
|
+
let statefulPlacement = placement;
|
|
297
|
+
let resetCount = 0;
|
|
298
|
+
const middlewareData = {};
|
|
299
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
300
|
+
const currentMiddleware = middleware[i];
|
|
301
|
+
if (!currentMiddleware) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
const {
|
|
305
|
+
name,
|
|
306
|
+
fn
|
|
307
|
+
} = currentMiddleware;
|
|
308
|
+
const {
|
|
309
|
+
x: nextX,
|
|
310
|
+
y: nextY,
|
|
311
|
+
data,
|
|
312
|
+
reset
|
|
313
|
+
} = await fn({
|
|
314
|
+
x,
|
|
315
|
+
y,
|
|
316
|
+
initialPlacement: placement,
|
|
317
|
+
placement: statefulPlacement,
|
|
318
|
+
strategy,
|
|
319
|
+
middlewareData,
|
|
320
|
+
rects,
|
|
321
|
+
platform: platformWithDetectOverflow,
|
|
322
|
+
elements: {
|
|
323
|
+
reference,
|
|
324
|
+
floating
|
|
325
|
+
}
|
|
379
326
|
});
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
var nextRefs_1 = new Set(refs);
|
|
386
|
-
var current_1 = callbackRef.current;
|
|
387
|
-
prevRefs_1.forEach(function (ref) {
|
|
388
|
-
if (!nextRefs_1.has(ref)) {
|
|
389
|
-
assignRef(ref, null);
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
nextRefs_1.forEach(function (ref) {
|
|
393
|
-
if (!prevRefs_1.has(ref)) {
|
|
394
|
-
assignRef(ref, current_1);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
currentValues.set(callbackRef, refs);
|
|
399
|
-
}, [refs]);
|
|
400
|
-
return callbackRef;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function ItoI(a) {
|
|
404
|
-
return a;
|
|
405
|
-
}
|
|
406
|
-
function innerCreateMedium(defaults, middleware) {
|
|
407
|
-
if (middleware === void 0) { middleware = ItoI; }
|
|
408
|
-
var buffer = [];
|
|
409
|
-
var assigned = false;
|
|
410
|
-
var medium = {
|
|
411
|
-
read: function () {
|
|
412
|
-
if (assigned) {
|
|
413
|
-
throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
|
|
414
|
-
}
|
|
415
|
-
if (buffer.length) {
|
|
416
|
-
return buffer[buffer.length - 1];
|
|
417
|
-
}
|
|
418
|
-
return defaults;
|
|
419
|
-
},
|
|
420
|
-
useMedium: function (data) {
|
|
421
|
-
var item = middleware(data, assigned);
|
|
422
|
-
buffer.push(item);
|
|
423
|
-
return function () {
|
|
424
|
-
buffer = buffer.filter(function (x) { return x !== item; });
|
|
425
|
-
};
|
|
426
|
-
},
|
|
427
|
-
assignSyncMedium: function (cb) {
|
|
428
|
-
assigned = true;
|
|
429
|
-
while (buffer.length) {
|
|
430
|
-
var cbs = buffer;
|
|
431
|
-
buffer = [];
|
|
432
|
-
cbs.forEach(cb);
|
|
433
|
-
}
|
|
434
|
-
buffer = {
|
|
435
|
-
push: function (x) { return cb(x); },
|
|
436
|
-
filter: function () { return buffer; },
|
|
437
|
-
};
|
|
438
|
-
},
|
|
439
|
-
assignMedium: function (cb) {
|
|
440
|
-
assigned = true;
|
|
441
|
-
var pendingQueue = [];
|
|
442
|
-
if (buffer.length) {
|
|
443
|
-
var cbs = buffer;
|
|
444
|
-
buffer = [];
|
|
445
|
-
cbs.forEach(cb);
|
|
446
|
-
pendingQueue = buffer;
|
|
447
|
-
}
|
|
448
|
-
var executeQueue = function () {
|
|
449
|
-
var cbs = pendingQueue;
|
|
450
|
-
pendingQueue = [];
|
|
451
|
-
cbs.forEach(cb);
|
|
452
|
-
};
|
|
453
|
-
var cycle = function () { return Promise.resolve().then(executeQueue); };
|
|
454
|
-
cycle();
|
|
455
|
-
buffer = {
|
|
456
|
-
push: function (x) {
|
|
457
|
-
pendingQueue.push(x);
|
|
458
|
-
cycle();
|
|
459
|
-
},
|
|
460
|
-
filter: function (filter) {
|
|
461
|
-
pendingQueue = pendingQueue.filter(filter);
|
|
462
|
-
return buffer;
|
|
463
|
-
},
|
|
464
|
-
};
|
|
465
|
-
},
|
|
327
|
+
x = nextX != null ? nextX : x;
|
|
328
|
+
y = nextY != null ? nextY : y;
|
|
329
|
+
middlewareData[name] = {
|
|
330
|
+
...middlewareData[name],
|
|
331
|
+
...data
|
|
466
332
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
333
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
334
|
+
resetCount++;
|
|
335
|
+
if (typeof reset === 'object') {
|
|
336
|
+
if (reset.placement) {
|
|
337
|
+
statefulPlacement = reset.placement;
|
|
338
|
+
}
|
|
339
|
+
if (reset.rects) {
|
|
340
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
341
|
+
reference,
|
|
342
|
+
floating,
|
|
343
|
+
strategy
|
|
344
|
+
}) : reset.rects;
|
|
345
|
+
}
|
|
346
|
+
({
|
|
347
|
+
x,
|
|
348
|
+
y
|
|
349
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
350
|
+
}
|
|
351
|
+
i = -1;
|
|
485
352
|
}
|
|
486
|
-
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
x,
|
|
356
|
+
y,
|
|
357
|
+
placement: statefulPlacement,
|
|
358
|
+
strategy,
|
|
359
|
+
middlewareData
|
|
360
|
+
};
|
|
487
361
|
};
|
|
488
|
-
SideCar$1.isSideCarExport = true;
|
|
489
|
-
function exportSidecar(medium, exported) {
|
|
490
|
-
medium.useMedium(exported);
|
|
491
|
-
return SideCar$1;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
var effectCar = createSidecarMedium();
|
|
495
362
|
|
|
496
|
-
var nothing = function () {
|
|
497
|
-
return;
|
|
498
|
-
};
|
|
499
363
|
/**
|
|
500
|
-
*
|
|
364
|
+
* Provides data to position an inner element of the floating element so that it
|
|
365
|
+
* appears centered to the reference element.
|
|
366
|
+
* @see https://floating-ui.com/docs/arrow
|
|
501
367
|
*/
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
};
|
|
522
|
-
RemoveScroll.classNames = {
|
|
523
|
-
fullWidth: fullWidthClassName,
|
|
524
|
-
zeroRight: zeroRightClassName,
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
var getNonce = function () {
|
|
528
|
-
if (typeof __webpack_nonce__ !== 'undefined') {
|
|
529
|
-
return __webpack_nonce__;
|
|
368
|
+
const arrow$3 = options => ({
|
|
369
|
+
name: 'arrow',
|
|
370
|
+
options,
|
|
371
|
+
async fn(state) {
|
|
372
|
+
const {
|
|
373
|
+
x,
|
|
374
|
+
y,
|
|
375
|
+
placement,
|
|
376
|
+
rects,
|
|
377
|
+
platform,
|
|
378
|
+
elements,
|
|
379
|
+
middlewareData
|
|
380
|
+
} = state;
|
|
381
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
382
|
+
const {
|
|
383
|
+
element,
|
|
384
|
+
padding = 0
|
|
385
|
+
} = evaluate(options, state) || {};
|
|
386
|
+
if (element == null) {
|
|
387
|
+
return {};
|
|
530
388
|
}
|
|
531
|
-
|
|
532
|
-
|
|
389
|
+
const paddingObject = getPaddingObject(padding);
|
|
390
|
+
const coords = {
|
|
391
|
+
x,
|
|
392
|
+
y
|
|
393
|
+
};
|
|
394
|
+
const axis = getAlignmentAxis(placement);
|
|
395
|
+
const length = getAxisLength(axis);
|
|
396
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
397
|
+
const isYAxis = axis === 'y';
|
|
398
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
399
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
400
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
401
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
402
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
403
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
404
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
533
405
|
|
|
534
|
-
|
|
535
|
-
if (!
|
|
536
|
-
|
|
537
|
-
var tag = document.createElement('style');
|
|
538
|
-
tag.type = 'text/css';
|
|
539
|
-
var nonce = getNonce();
|
|
540
|
-
if (nonce) {
|
|
541
|
-
tag.setAttribute('nonce', nonce);
|
|
542
|
-
}
|
|
543
|
-
return tag;
|
|
544
|
-
}
|
|
545
|
-
function injectStyles(tag, css) {
|
|
546
|
-
// @ts-ignore
|
|
547
|
-
if (tag.styleSheet) {
|
|
548
|
-
// @ts-ignore
|
|
549
|
-
tag.styleSheet.cssText = css;
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
tag.appendChild(document.createTextNode(css));
|
|
406
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
407
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
408
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
553
409
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
410
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
411
|
+
|
|
412
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
413
|
+
// centered, modify the padding so that it is centered.
|
|
414
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
415
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
416
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
417
|
+
|
|
418
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
419
|
+
// point is outside the floating element's bounds.
|
|
420
|
+
const min$1 = minPadding;
|
|
421
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
422
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
423
|
+
const offset = clamp(min$1, center, max);
|
|
424
|
+
|
|
425
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
426
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
427
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
428
|
+
// a single reset is performed when this is true.
|
|
429
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
430
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
562
431
|
return {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
remove: function () {
|
|
573
|
-
counter--;
|
|
574
|
-
if (!counter && stylesheet) {
|
|
575
|
-
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
|
576
|
-
stylesheet = null;
|
|
577
|
-
}
|
|
578
|
-
},
|
|
432
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
433
|
+
data: {
|
|
434
|
+
[axis]: offset,
|
|
435
|
+
centerOffset: center - offset - alignmentOffset,
|
|
436
|
+
...(shouldAddOffset && {
|
|
437
|
+
alignmentOffset
|
|
438
|
+
})
|
|
439
|
+
},
|
|
440
|
+
reset: shouldAddOffset
|
|
579
441
|
};
|
|
580
|
-
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
581
444
|
|
|
582
445
|
/**
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* const useStyle = styleHookSingleton();
|
|
588
|
-
* ///
|
|
589
|
-
* useStyle('body { overflow: hidden}');
|
|
446
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
447
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
448
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
449
|
+
* @see https://floating-ui.com/docs/flip
|
|
590
450
|
*/
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
451
|
+
const flip$2 = function (options) {
|
|
452
|
+
if (options === void 0) {
|
|
453
|
+
options = {};
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
name: 'flip',
|
|
457
|
+
options,
|
|
458
|
+
async fn(state) {
|
|
459
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
460
|
+
const {
|
|
461
|
+
placement,
|
|
462
|
+
middlewareData,
|
|
463
|
+
rects,
|
|
464
|
+
initialPlacement,
|
|
465
|
+
platform,
|
|
466
|
+
elements
|
|
467
|
+
} = state;
|
|
468
|
+
const {
|
|
469
|
+
mainAxis: checkMainAxis = true,
|
|
470
|
+
crossAxis: checkCrossAxis = true,
|
|
471
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
472
|
+
fallbackStrategy = 'bestFit',
|
|
473
|
+
fallbackAxisSideDirection = 'none',
|
|
474
|
+
flipAlignment = true,
|
|
475
|
+
...detectOverflowOptions
|
|
476
|
+
} = evaluate(options, state);
|
|
477
|
+
|
|
478
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
479
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
480
|
+
// work.
|
|
481
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
482
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
483
|
+
return {};
|
|
484
|
+
}
|
|
485
|
+
const side = getSide(placement);
|
|
486
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
487
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
488
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
489
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
490
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
491
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
492
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
493
|
+
}
|
|
494
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
495
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
496
|
+
const overflows = [];
|
|
497
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
498
|
+
if (checkMainAxis) {
|
|
499
|
+
overflows.push(overflow[side]);
|
|
500
|
+
}
|
|
501
|
+
if (checkCrossAxis) {
|
|
502
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
503
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
504
|
+
}
|
|
505
|
+
overflowsData = [...overflowsData, {
|
|
506
|
+
placement,
|
|
507
|
+
overflows
|
|
508
|
+
}];
|
|
509
|
+
|
|
510
|
+
// One or more sides is overflowing.
|
|
511
|
+
if (!overflows.every(side => side <= 0)) {
|
|
512
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
513
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
514
|
+
const nextPlacement = placements[nextIndex];
|
|
515
|
+
if (nextPlacement) {
|
|
516
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
517
|
+
if (!ignoreCrossAxisOverflow ||
|
|
518
|
+
// We leave the current main axis only if every placement on that axis
|
|
519
|
+
// overflows the main axis.
|
|
520
|
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
521
|
+
// Try next placement and re-run the lifecycle.
|
|
522
|
+
return {
|
|
523
|
+
data: {
|
|
524
|
+
index: nextIndex,
|
|
525
|
+
overflows: overflowsData
|
|
526
|
+
},
|
|
527
|
+
reset: {
|
|
528
|
+
placement: nextPlacement
|
|
529
|
+
}
|
|
598
530
|
};
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
};
|
|
531
|
+
}
|
|
532
|
+
}
|
|
602
533
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
* - styles are removed when the last instance is unmounted
|
|
607
|
-
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
|
|
608
|
-
*/
|
|
609
|
-
var styleSingleton = function () {
|
|
610
|
-
var useStyle = styleHookSingleton();
|
|
611
|
-
var Sheet = function (_a) {
|
|
612
|
-
var styles = _a.styles, dynamic = _a.dynamic;
|
|
613
|
-
useStyle(styles, dynamic);
|
|
614
|
-
return null;
|
|
615
|
-
};
|
|
616
|
-
return Sheet;
|
|
617
|
-
};
|
|
534
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
535
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
536
|
+
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;
|
|
618
537
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
538
|
+
// Otherwise fallback.
|
|
539
|
+
if (!resetPlacement) {
|
|
540
|
+
switch (fallbackStrategy) {
|
|
541
|
+
case 'bestFit':
|
|
542
|
+
{
|
|
543
|
+
var _overflowsData$filter2;
|
|
544
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
545
|
+
if (hasFallbackAxisSideDirection) {
|
|
546
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
547
|
+
return currentSideAxis === initialSideAxis ||
|
|
548
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
549
|
+
// reading directions favoring greater width.
|
|
550
|
+
currentSideAxis === 'y';
|
|
551
|
+
}
|
|
552
|
+
return true;
|
|
553
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
554
|
+
if (placement) {
|
|
555
|
+
resetPlacement = placement;
|
|
556
|
+
}
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case 'initialPlacement':
|
|
560
|
+
resetPlacement = initialPlacement;
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (placement !== resetPlacement) {
|
|
565
|
+
return {
|
|
566
|
+
reset: {
|
|
567
|
+
placement: resetPlacement
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return {};
|
|
637
573
|
}
|
|
638
|
-
|
|
639
|
-
var documentWidth = document.documentElement.clientWidth;
|
|
640
|
-
var windowWidth = window.innerWidth;
|
|
641
|
-
return {
|
|
642
|
-
left: offsets[0],
|
|
643
|
-
top: offsets[1],
|
|
644
|
-
right: offsets[2],
|
|
645
|
-
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
|
|
646
|
-
};
|
|
574
|
+
};
|
|
647
575
|
};
|
|
648
576
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
"\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
|
661
|
-
gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
|
|
662
|
-
]
|
|
663
|
-
.filter(Boolean)
|
|
664
|
-
.join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
|
665
|
-
};
|
|
666
|
-
var getCurrentUseCounter = function () {
|
|
667
|
-
var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
|
|
668
|
-
return isFinite(counter) ? counter : 0;
|
|
669
|
-
};
|
|
670
|
-
var useLockAttribute = function () {
|
|
671
|
-
React.useEffect(function () {
|
|
672
|
-
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
673
|
-
return function () {
|
|
674
|
-
var newCounter = getCurrentUseCounter() - 1;
|
|
675
|
-
if (newCounter <= 0) {
|
|
676
|
-
document.body.removeAttribute(lockAttribute);
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
document.body.setAttribute(lockAttribute, newCounter.toString());
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
}, []);
|
|
683
|
-
};
|
|
577
|
+
function getSideOffsets(overflow, rect) {
|
|
578
|
+
return {
|
|
579
|
+
top: overflow.top - rect.height,
|
|
580
|
+
right: overflow.right - rect.width,
|
|
581
|
+
bottom: overflow.bottom - rect.height,
|
|
582
|
+
left: overflow.left - rect.width
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function isAnySideFullyClipped(overflow) {
|
|
586
|
+
return sides.some(side => overflow[side] >= 0);
|
|
587
|
+
}
|
|
684
588
|
/**
|
|
685
|
-
*
|
|
589
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
590
|
+
* when it is not in the same clipping context as the reference element.
|
|
591
|
+
* @see https://floating-ui.com/docs/hide
|
|
686
592
|
*/
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
593
|
+
const hide$2 = function (options) {
|
|
594
|
+
if (options === void 0) {
|
|
595
|
+
options = {};
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
name: 'hide',
|
|
599
|
+
options,
|
|
600
|
+
async fn(state) {
|
|
601
|
+
const {
|
|
602
|
+
rects,
|
|
603
|
+
platform
|
|
604
|
+
} = state;
|
|
605
|
+
const {
|
|
606
|
+
strategy = 'referenceHidden',
|
|
607
|
+
...detectOverflowOptions
|
|
608
|
+
} = evaluate(options, state);
|
|
609
|
+
switch (strategy) {
|
|
610
|
+
case 'referenceHidden':
|
|
611
|
+
{
|
|
612
|
+
const overflow = await platform.detectOverflow(state, {
|
|
613
|
+
...detectOverflowOptions,
|
|
614
|
+
elementContext: 'reference'
|
|
615
|
+
});
|
|
616
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
617
|
+
return {
|
|
618
|
+
data: {
|
|
619
|
+
referenceHiddenOffsets: offsets,
|
|
620
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
case 'escaped':
|
|
625
|
+
{
|
|
626
|
+
const overflow = await platform.detectOverflow(state, {
|
|
627
|
+
...detectOverflowOptions,
|
|
628
|
+
altBoundary: true
|
|
629
|
+
});
|
|
630
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
631
|
+
return {
|
|
632
|
+
data: {
|
|
633
|
+
escapedOffsets: offsets,
|
|
634
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
default:
|
|
639
|
+
{
|
|
640
|
+
return {};
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
697
645
|
};
|
|
698
646
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
647
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
648
|
+
|
|
649
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
650
|
+
// Derivable.
|
|
651
|
+
|
|
652
|
+
async function convertValueToCoords(state, options) {
|
|
653
|
+
const {
|
|
654
|
+
placement,
|
|
655
|
+
platform,
|
|
656
|
+
elements
|
|
657
|
+
} = state;
|
|
658
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
659
|
+
const side = getSide(placement);
|
|
660
|
+
const alignment = getAlignment(placement);
|
|
661
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
662
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
663
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
664
|
+
const rawValue = evaluate(options, state);
|
|
665
|
+
|
|
666
|
+
// eslint-disable-next-line prefer-const
|
|
667
|
+
let {
|
|
668
|
+
mainAxis,
|
|
669
|
+
crossAxis,
|
|
670
|
+
alignmentAxis
|
|
671
|
+
} = typeof rawValue === 'number' ? {
|
|
672
|
+
mainAxis: rawValue,
|
|
673
|
+
crossAxis: 0,
|
|
674
|
+
alignmentAxis: null
|
|
675
|
+
} : {
|
|
676
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
677
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
678
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
679
|
+
};
|
|
680
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
681
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
682
|
+
}
|
|
683
|
+
return isVertical ? {
|
|
684
|
+
x: crossAxis * crossAxisMulti,
|
|
685
|
+
y: mainAxis * mainAxisMulti
|
|
686
|
+
} : {
|
|
687
|
+
x: mainAxis * mainAxisMulti,
|
|
688
|
+
y: crossAxis * crossAxisMulti
|
|
689
|
+
};
|
|
716
690
|
}
|
|
717
|
-
var nonPassive = passiveSupported ? { passive: false } : false;
|
|
718
691
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
692
|
+
/**
|
|
693
|
+
* Modifies the placement by translating the floating element along the
|
|
694
|
+
* specified axes.
|
|
695
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
696
|
+
* object may be passed.
|
|
697
|
+
* @see https://floating-ui.com/docs/offset
|
|
698
|
+
*/
|
|
699
|
+
const offset$2 = function (options) {
|
|
700
|
+
if (options === void 0) {
|
|
701
|
+
options = 0;
|
|
702
|
+
}
|
|
703
|
+
return {
|
|
704
|
+
name: 'offset',
|
|
705
|
+
options,
|
|
706
|
+
async fn(state) {
|
|
707
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
708
|
+
const {
|
|
709
|
+
x,
|
|
710
|
+
y,
|
|
711
|
+
placement,
|
|
712
|
+
middlewareData
|
|
713
|
+
} = state;
|
|
714
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
715
|
+
|
|
716
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
717
|
+
// then we don't need to change the positioning coordinates.
|
|
718
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
719
|
+
return {};
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
x: x + diffCoords.x,
|
|
723
|
+
y: y + diffCoords.y,
|
|
724
|
+
data: {
|
|
725
|
+
...diffCoords,
|
|
726
|
+
placement
|
|
727
|
+
}
|
|
728
|
+
};
|
|
726
729
|
}
|
|
727
|
-
|
|
728
|
-
return (
|
|
729
|
-
// not-not-scrollable
|
|
730
|
-
styles[overflow] !== 'hidden' &&
|
|
731
|
-
// contains scroll inside self
|
|
732
|
-
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
|
|
730
|
+
};
|
|
733
731
|
};
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
735
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
736
|
+
* @see https://floating-ui.com/docs/shift
|
|
737
|
+
*/
|
|
738
|
+
const shift$2 = function (options) {
|
|
739
|
+
if (options === void 0) {
|
|
740
|
+
options = {};
|
|
741
|
+
}
|
|
742
|
+
return {
|
|
743
|
+
name: 'shift',
|
|
744
|
+
options,
|
|
745
|
+
async fn(state) {
|
|
746
|
+
const {
|
|
747
|
+
x,
|
|
748
|
+
y,
|
|
749
|
+
placement,
|
|
750
|
+
platform
|
|
751
|
+
} = state;
|
|
752
|
+
const {
|
|
753
|
+
mainAxis: checkMainAxis = true,
|
|
754
|
+
crossAxis: checkCrossAxis = false,
|
|
755
|
+
limiter = {
|
|
756
|
+
fn: _ref => {
|
|
757
|
+
let {
|
|
758
|
+
x,
|
|
759
|
+
y
|
|
760
|
+
} = _ref;
|
|
761
|
+
return {
|
|
762
|
+
x,
|
|
763
|
+
y
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
...detectOverflowOptions
|
|
768
|
+
} = evaluate(options, state);
|
|
769
|
+
const coords = {
|
|
770
|
+
x,
|
|
771
|
+
y
|
|
772
|
+
};
|
|
773
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
774
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
775
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
776
|
+
let mainAxisCoord = coords[mainAxis];
|
|
777
|
+
let crossAxisCoord = coords[crossAxis];
|
|
778
|
+
if (checkMainAxis) {
|
|
779
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
780
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
781
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
782
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
783
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
784
|
+
}
|
|
785
|
+
if (checkCrossAxis) {
|
|
786
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
787
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
788
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
789
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
790
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
791
|
+
}
|
|
792
|
+
const limitedCoords = limiter.fn({
|
|
793
|
+
...state,
|
|
794
|
+
[mainAxis]: mainAxisCoord,
|
|
795
|
+
[crossAxis]: crossAxisCoord
|
|
796
|
+
});
|
|
797
|
+
return {
|
|
798
|
+
...limitedCoords,
|
|
799
|
+
data: {
|
|
800
|
+
x: limitedCoords.x - x,
|
|
801
|
+
y: limitedCoords.y - y,
|
|
802
|
+
enabled: {
|
|
803
|
+
[mainAxis]: checkMainAxis,
|
|
804
|
+
[crossAxis]: checkCrossAxis
|
|
805
|
+
}
|
|
750
806
|
}
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
};
|
|
755
|
-
var getVScrollVariables = function (_a) {
|
|
756
|
-
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
757
|
-
return [
|
|
758
|
-
scrollTop,
|
|
759
|
-
scrollHeight,
|
|
760
|
-
clientHeight,
|
|
761
|
-
];
|
|
762
|
-
};
|
|
763
|
-
var getHScrollVariables = function (_a) {
|
|
764
|
-
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
765
|
-
return [
|
|
766
|
-
scrollLeft,
|
|
767
|
-
scrollWidth,
|
|
768
|
-
clientWidth,
|
|
769
|
-
];
|
|
770
|
-
};
|
|
771
|
-
var elementCouldBeScrolled = function (axis, node) {
|
|
772
|
-
return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
773
|
-
};
|
|
774
|
-
var getScrollVariables = function (axis, node) {
|
|
775
|
-
return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
776
|
-
};
|
|
777
|
-
var getDirectionFactor = function (axis, direction) {
|
|
778
|
-
/**
|
|
779
|
-
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
|
|
780
|
-
* and then increasingly negative as you scroll towards the end of the content.
|
|
781
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
|
782
|
-
*/
|
|
783
|
-
return axis === 'h' && direction === 'rtl' ? -1 : 1;
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
};
|
|
784
810
|
};
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
811
|
+
/**
|
|
812
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
813
|
+
*/
|
|
814
|
+
const limitShift$2 = function (options) {
|
|
815
|
+
if (options === void 0) {
|
|
816
|
+
options = {};
|
|
817
|
+
}
|
|
818
|
+
return {
|
|
819
|
+
options,
|
|
820
|
+
fn(state) {
|
|
821
|
+
const {
|
|
822
|
+
x,
|
|
823
|
+
y,
|
|
824
|
+
placement,
|
|
825
|
+
rects,
|
|
826
|
+
middlewareData
|
|
827
|
+
} = state;
|
|
828
|
+
const {
|
|
829
|
+
offset = 0,
|
|
830
|
+
mainAxis: checkMainAxis = true,
|
|
831
|
+
crossAxis: checkCrossAxis = true
|
|
832
|
+
} = evaluate(options, state);
|
|
833
|
+
const coords = {
|
|
834
|
+
x,
|
|
835
|
+
y
|
|
836
|
+
};
|
|
837
|
+
const crossAxis = getSideAxis(placement);
|
|
838
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
839
|
+
let mainAxisCoord = coords[mainAxis];
|
|
840
|
+
let crossAxisCoord = coords[crossAxis];
|
|
841
|
+
const rawOffset = evaluate(offset, state);
|
|
842
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
|
843
|
+
mainAxis: rawOffset,
|
|
844
|
+
crossAxis: 0
|
|
845
|
+
} : {
|
|
846
|
+
mainAxis: 0,
|
|
847
|
+
crossAxis: 0,
|
|
848
|
+
...rawOffset
|
|
849
|
+
};
|
|
850
|
+
if (checkMainAxis) {
|
|
851
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
852
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
853
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
854
|
+
if (mainAxisCoord < limitMin) {
|
|
855
|
+
mainAxisCoord = limitMin;
|
|
856
|
+
} else if (mainAxisCoord > limitMax) {
|
|
857
|
+
mainAxisCoord = limitMax;
|
|
798
858
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
859
|
+
}
|
|
860
|
+
if (checkCrossAxis) {
|
|
861
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
862
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
863
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
864
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
865
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
866
|
+
if (crossAxisCoord < limitMin) {
|
|
867
|
+
crossAxisCoord = limitMin;
|
|
868
|
+
} else if (crossAxisCoord > limitMax) {
|
|
869
|
+
crossAxisCoord = limitMax;
|
|
806
870
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
// portaled content
|
|
813
|
-
(!targetInLock && target !== document.body) ||
|
|
814
|
-
// self content
|
|
815
|
-
(targetInLock && (endTarget.contains(target) || endTarget === target)));
|
|
816
|
-
// handle epsilon around 0 (non standard zoom levels)
|
|
817
|
-
if (isDeltaPositive &&
|
|
818
|
-
((Math.abs(availableScroll) < 1) || (false))) {
|
|
819
|
-
shouldCancelScroll = true;
|
|
820
|
-
}
|
|
821
|
-
else if (!isDeltaPositive &&
|
|
822
|
-
((Math.abs(availableScrollTop) < 1) || (false))) {
|
|
823
|
-
shouldCancelScroll = true;
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
[mainAxis]: mainAxisCoord,
|
|
874
|
+
[crossAxis]: crossAxisCoord
|
|
875
|
+
};
|
|
824
876
|
}
|
|
825
|
-
|
|
877
|
+
};
|
|
826
878
|
};
|
|
827
879
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
else {
|
|
891
|
-
|
|
892
|
-
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
893
|
-
// other axis might be not scrollable
|
|
894
|
-
}
|
|
895
|
-
if (!canBeScrolledInMainDirection) {
|
|
896
|
-
return false;
|
|
897
|
-
}
|
|
898
|
-
if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
|
|
899
|
-
activeAxis.current = currentAxis;
|
|
900
|
-
}
|
|
901
|
-
if (!currentAxis) {
|
|
902
|
-
return true;
|
|
903
|
-
}
|
|
904
|
-
var cancelingAxis = activeAxis.current || currentAxis;
|
|
905
|
-
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
|
|
906
|
-
}, []);
|
|
907
|
-
var shouldPrevent = React.useCallback(function (_event) {
|
|
908
|
-
var event = _event;
|
|
909
|
-
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
|
910
|
-
// not the last active
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
|
914
|
-
var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); })[0];
|
|
915
|
-
// self event, and should be canceled
|
|
916
|
-
if (sourceEvent && sourceEvent.should) {
|
|
917
|
-
if (event.cancelable) {
|
|
918
|
-
event.preventDefault();
|
|
919
|
-
}
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
// outside or shard event
|
|
923
|
-
if (!sourceEvent) {
|
|
924
|
-
var shardNodes = (lastProps.current.shards || [])
|
|
925
|
-
.map(extractRef)
|
|
926
|
-
.filter(Boolean)
|
|
927
|
-
.filter(function (node) { return node.contains(event.target); });
|
|
928
|
-
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
929
|
-
if (shouldStop) {
|
|
930
|
-
if (event.cancelable) {
|
|
931
|
-
event.preventDefault();
|
|
932
|
-
}
|
|
933
|
-
}
|
|
880
|
+
/**
|
|
881
|
+
* Provides data that allows you to change the size of the floating element —
|
|
882
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
883
|
+
* width of the reference element.
|
|
884
|
+
* @see https://floating-ui.com/docs/size
|
|
885
|
+
*/
|
|
886
|
+
const size$2 = function (options) {
|
|
887
|
+
if (options === void 0) {
|
|
888
|
+
options = {};
|
|
889
|
+
}
|
|
890
|
+
return {
|
|
891
|
+
name: 'size',
|
|
892
|
+
options,
|
|
893
|
+
async fn(state) {
|
|
894
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
895
|
+
const {
|
|
896
|
+
placement,
|
|
897
|
+
rects,
|
|
898
|
+
platform,
|
|
899
|
+
elements
|
|
900
|
+
} = state;
|
|
901
|
+
const {
|
|
902
|
+
apply = () => {},
|
|
903
|
+
...detectOverflowOptions
|
|
904
|
+
} = evaluate(options, state);
|
|
905
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
906
|
+
const side = getSide(placement);
|
|
907
|
+
const alignment = getAlignment(placement);
|
|
908
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
909
|
+
const {
|
|
910
|
+
width,
|
|
911
|
+
height
|
|
912
|
+
} = rects.floating;
|
|
913
|
+
let heightSide;
|
|
914
|
+
let widthSide;
|
|
915
|
+
if (side === 'top' || side === 'bottom') {
|
|
916
|
+
heightSide = side;
|
|
917
|
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
918
|
+
} else {
|
|
919
|
+
widthSide = side;
|
|
920
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
921
|
+
}
|
|
922
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
923
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
924
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
925
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
926
|
+
const noShift = !state.middlewareData.shift;
|
|
927
|
+
let availableHeight = overflowAvailableHeight;
|
|
928
|
+
let availableWidth = overflowAvailableWidth;
|
|
929
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
930
|
+
availableWidth = maximumClippingWidth;
|
|
931
|
+
}
|
|
932
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
933
|
+
availableHeight = maximumClippingHeight;
|
|
934
|
+
}
|
|
935
|
+
if (noShift && !alignment) {
|
|
936
|
+
const xMin = max(overflow.left, 0);
|
|
937
|
+
const xMax = max(overflow.right, 0);
|
|
938
|
+
const yMin = max(overflow.top, 0);
|
|
939
|
+
const yMax = max(overflow.bottom, 0);
|
|
940
|
+
if (isYAxis) {
|
|
941
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
942
|
+
} else {
|
|
943
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
934
944
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
var scrollWheel = React.useCallback(function (event) {
|
|
948
|
-
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
949
|
-
}, []);
|
|
950
|
-
var scrollTouchMove = React.useCallback(function (event) {
|
|
951
|
-
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
952
|
-
}, []);
|
|
953
|
-
React.useEffect(function () {
|
|
954
|
-
lockStack.push(Style);
|
|
955
|
-
props.setCallbacks({
|
|
956
|
-
onScrollCapture: scrollWheel,
|
|
957
|
-
onWheelCapture: scrollWheel,
|
|
958
|
-
onTouchMoveCapture: scrollTouchMove,
|
|
959
|
-
});
|
|
960
|
-
document.addEventListener('wheel', shouldPrevent, nonPassive);
|
|
961
|
-
document.addEventListener('touchmove', shouldPrevent, nonPassive);
|
|
962
|
-
document.addEventListener('touchstart', scrollTouchStart, nonPassive);
|
|
963
|
-
return function () {
|
|
964
|
-
lockStack = lockStack.filter(function (inst) { return inst !== Style; });
|
|
965
|
-
document.removeEventListener('wheel', shouldPrevent, nonPassive);
|
|
966
|
-
document.removeEventListener('touchmove', shouldPrevent, nonPassive);
|
|
967
|
-
document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
|
|
945
|
+
}
|
|
946
|
+
await apply({
|
|
947
|
+
...state,
|
|
948
|
+
availableWidth,
|
|
949
|
+
availableHeight
|
|
950
|
+
});
|
|
951
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
952
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
953
|
+
return {
|
|
954
|
+
reset: {
|
|
955
|
+
rects: true
|
|
956
|
+
}
|
|
968
957
|
};
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
function
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
958
|
+
}
|
|
959
|
+
return {};
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
function hasWindow() {
|
|
965
|
+
return typeof window !== 'undefined';
|
|
966
|
+
}
|
|
967
|
+
function getNodeName(node) {
|
|
968
|
+
if (isNode(node)) {
|
|
969
|
+
return (node.nodeName || '').toLowerCase();
|
|
970
|
+
}
|
|
971
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
972
|
+
// returning `#document` an infinite loop won't occur.
|
|
973
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
974
|
+
return '#document';
|
|
975
|
+
}
|
|
976
|
+
function getWindow(node) {
|
|
977
|
+
var _node$ownerDocument;
|
|
978
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
979
|
+
}
|
|
980
|
+
function getDocumentElement(node) {
|
|
981
|
+
var _ref;
|
|
982
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
983
|
+
}
|
|
984
|
+
function isNode(value) {
|
|
985
|
+
if (!hasWindow()) {
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
989
|
+
}
|
|
990
|
+
function isElement(value) {
|
|
991
|
+
if (!hasWindow()) {
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
995
|
+
}
|
|
996
|
+
function isHTMLElement(value) {
|
|
997
|
+
if (!hasWindow()) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1001
|
+
}
|
|
1002
|
+
function isShadowRoot(value) {
|
|
1003
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
1004
|
+
return false;
|
|
1005
|
+
}
|
|
1006
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1007
|
+
}
|
|
1008
|
+
function isOverflowElement(element) {
|
|
1009
|
+
const {
|
|
1010
|
+
overflow,
|
|
1011
|
+
overflowX,
|
|
1012
|
+
overflowY,
|
|
1013
|
+
display
|
|
1014
|
+
} = getComputedStyle$1(element);
|
|
1015
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
|
|
1016
|
+
}
|
|
1017
|
+
function isTableElement(element) {
|
|
1018
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
1019
|
+
}
|
|
1020
|
+
function isTopLayer(element) {
|
|
1021
|
+
try {
|
|
1022
|
+
if (element.matches(':popover-open')) {
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
} catch (_e) {
|
|
1026
|
+
// no-op
|
|
1027
|
+
}
|
|
1028
|
+
try {
|
|
1029
|
+
return element.matches(':modal');
|
|
1030
|
+
} catch (_e) {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
1035
|
+
const containRe = /paint|layout|strict|content/;
|
|
1036
|
+
const isNotNone = value => !!value && value !== 'none';
|
|
1037
|
+
let isWebKitValue;
|
|
1038
|
+
function isContainingBlock(elementOrCss) {
|
|
1039
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1040
|
+
|
|
1041
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1042
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
1043
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
|
1044
|
+
}
|
|
1045
|
+
function getContainingBlock(element) {
|
|
1046
|
+
let currentNode = getParentNode(element);
|
|
1047
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1048
|
+
if (isContainingBlock(currentNode)) {
|
|
1049
|
+
return currentNode;
|
|
1050
|
+
} else if (isTopLayer(currentNode)) {
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
currentNode = getParentNode(currentNode);
|
|
1054
|
+
}
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
function isWebKit() {
|
|
1058
|
+
if (isWebKitValue == null) {
|
|
1059
|
+
isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
|
1060
|
+
}
|
|
1061
|
+
return isWebKitValue;
|
|
1062
|
+
}
|
|
1063
|
+
function isLastTraversableNode(node) {
|
|
1064
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
1065
|
+
}
|
|
1066
|
+
function getComputedStyle$1(element) {
|
|
1067
|
+
return getWindow(element).getComputedStyle(element);
|
|
1068
|
+
}
|
|
1069
|
+
function getNodeScroll(element) {
|
|
1070
|
+
if (isElement(element)) {
|
|
1071
|
+
return {
|
|
1072
|
+
scrollLeft: element.scrollLeft,
|
|
1073
|
+
scrollTop: element.scrollTop
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
return {
|
|
1077
|
+
scrollLeft: element.scrollX,
|
|
1078
|
+
scrollTop: element.scrollY
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
function getParentNode(node) {
|
|
1082
|
+
if (getNodeName(node) === 'html') {
|
|
1083
|
+
return node;
|
|
1084
|
+
}
|
|
1085
|
+
const result =
|
|
1086
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1087
|
+
node.assignedSlot ||
|
|
1088
|
+
// DOM Element detected.
|
|
1089
|
+
node.parentNode ||
|
|
1090
|
+
// ShadowRoot detected.
|
|
1091
|
+
isShadowRoot(node) && node.host ||
|
|
1092
|
+
// Fallback.
|
|
1093
|
+
getDocumentElement(node);
|
|
1094
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1095
|
+
}
|
|
1096
|
+
function getNearestOverflowAncestor(node) {
|
|
1097
|
+
const parentNode = getParentNode(node);
|
|
1098
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1099
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1100
|
+
}
|
|
1101
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1102
|
+
return parentNode;
|
|
1103
|
+
}
|
|
1104
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1105
|
+
}
|
|
1106
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1107
|
+
var _node$ownerDocument2;
|
|
1108
|
+
if (list === void 0) {
|
|
1109
|
+
list = [];
|
|
1110
|
+
}
|
|
1111
|
+
if (traverseIframes === void 0) {
|
|
1112
|
+
traverseIframes = true;
|
|
1113
|
+
}
|
|
1114
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1115
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1116
|
+
const win = getWindow(scrollableAncestor);
|
|
1117
|
+
if (isBody) {
|
|
1118
|
+
const frameElement = getFrameElement(win);
|
|
1119
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1120
|
+
} else {
|
|
1121
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function getFrameElement(win) {
|
|
1125
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function getCssDimensions(element) {
|
|
1129
|
+
const css = getComputedStyle$1(element);
|
|
1130
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
1131
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
1132
|
+
let width = parseFloat(css.width) || 0;
|
|
1133
|
+
let height = parseFloat(css.height) || 0;
|
|
1134
|
+
const hasOffset = isHTMLElement(element);
|
|
1135
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1136
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1137
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1138
|
+
if (shouldFallback) {
|
|
1139
|
+
width = offsetWidth;
|
|
1140
|
+
height = offsetHeight;
|
|
1141
|
+
}
|
|
1142
|
+
return {
|
|
1143
|
+
width,
|
|
1144
|
+
height,
|
|
1145
|
+
$: shouldFallback
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function unwrapElement(element) {
|
|
1150
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function getScale(element) {
|
|
1154
|
+
const domElement = unwrapElement(element);
|
|
1155
|
+
if (!isHTMLElement(domElement)) {
|
|
1156
|
+
return createCoords(1);
|
|
1157
|
+
}
|
|
1158
|
+
const rect = domElement.getBoundingClientRect();
|
|
1159
|
+
const {
|
|
1160
|
+
width,
|
|
1161
|
+
height,
|
|
1162
|
+
$
|
|
1163
|
+
} = getCssDimensions(domElement);
|
|
1164
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1165
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1166
|
+
|
|
1167
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
1168
|
+
|
|
1169
|
+
if (!x || !Number.isFinite(x)) {
|
|
1170
|
+
x = 1;
|
|
1171
|
+
}
|
|
1172
|
+
if (!y || !Number.isFinite(y)) {
|
|
1173
|
+
y = 1;
|
|
1174
|
+
}
|
|
1175
|
+
return {
|
|
1176
|
+
x,
|
|
1177
|
+
y
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
1182
|
+
function getVisualOffsets(element) {
|
|
1183
|
+
const win = getWindow(element);
|
|
1184
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1185
|
+
return noOffsets;
|
|
1186
|
+
}
|
|
1187
|
+
return {
|
|
1188
|
+
x: win.visualViewport.offsetLeft,
|
|
1189
|
+
y: win.visualViewport.offsetTop
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1193
|
+
if (isFixed === void 0) {
|
|
1194
|
+
isFixed = false;
|
|
1195
|
+
}
|
|
1196
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
return isFixed;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1203
|
+
if (includeScale === void 0) {
|
|
1204
|
+
includeScale = false;
|
|
1205
|
+
}
|
|
1206
|
+
if (isFixedStrategy === void 0) {
|
|
1207
|
+
isFixedStrategy = false;
|
|
1208
|
+
}
|
|
1209
|
+
const clientRect = element.getBoundingClientRect();
|
|
1210
|
+
const domElement = unwrapElement(element);
|
|
1211
|
+
let scale = createCoords(1);
|
|
1212
|
+
if (includeScale) {
|
|
1213
|
+
if (offsetParent) {
|
|
1214
|
+
if (isElement(offsetParent)) {
|
|
1215
|
+
scale = getScale(offsetParent);
|
|
1216
|
+
}
|
|
1217
|
+
} else {
|
|
1218
|
+
scale = getScale(element);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1222
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1223
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1224
|
+
let width = clientRect.width / scale.x;
|
|
1225
|
+
let height = clientRect.height / scale.y;
|
|
1226
|
+
if (domElement) {
|
|
1227
|
+
const win = getWindow(domElement);
|
|
1228
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1229
|
+
let currentWin = win;
|
|
1230
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1231
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1232
|
+
const iframeScale = getScale(currentIFrame);
|
|
1233
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1234
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1235
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1236
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1237
|
+
x *= iframeScale.x;
|
|
1238
|
+
y *= iframeScale.y;
|
|
1239
|
+
width *= iframeScale.x;
|
|
1240
|
+
height *= iframeScale.y;
|
|
1241
|
+
x += left;
|
|
1242
|
+
y += top;
|
|
1243
|
+
currentWin = getWindow(currentIFrame);
|
|
1244
|
+
currentIFrame = getFrameElement(currentWin);
|
|
983
1245
|
}
|
|
984
|
-
|
|
1246
|
+
}
|
|
1247
|
+
return rectToClientRect({
|
|
1248
|
+
width,
|
|
1249
|
+
height,
|
|
1250
|
+
x,
|
|
1251
|
+
y
|
|
1252
|
+
});
|
|
985
1253
|
}
|
|
986
1254
|
|
|
987
|
-
|
|
1255
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1256
|
+
// incorrect for RTL.
|
|
1257
|
+
function getWindowScrollBarX(element, rect) {
|
|
1258
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1259
|
+
if (!rect) {
|
|
1260
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1261
|
+
}
|
|
1262
|
+
return rect.left + leftScroll;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1266
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1267
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1268
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1269
|
+
return {
|
|
1270
|
+
x,
|
|
1271
|
+
y
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1276
|
+
let {
|
|
1277
|
+
elements,
|
|
1278
|
+
rect,
|
|
1279
|
+
offsetParent,
|
|
1280
|
+
strategy
|
|
1281
|
+
} = _ref;
|
|
1282
|
+
const isFixed = strategy === 'fixed';
|
|
1283
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1284
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1285
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1286
|
+
return rect;
|
|
1287
|
+
}
|
|
1288
|
+
let scroll = {
|
|
1289
|
+
scrollLeft: 0,
|
|
1290
|
+
scrollTop: 0
|
|
1291
|
+
};
|
|
1292
|
+
let scale = createCoords(1);
|
|
1293
|
+
const offsets = createCoords(0);
|
|
1294
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1295
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1296
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1297
|
+
scroll = getNodeScroll(offsetParent);
|
|
1298
|
+
}
|
|
1299
|
+
if (isOffsetParentAnElement) {
|
|
1300
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1301
|
+
scale = getScale(offsetParent);
|
|
1302
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1303
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1307
|
+
return {
|
|
1308
|
+
width: rect.width * scale.x,
|
|
1309
|
+
height: rect.height * scale.y,
|
|
1310
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1311
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
988
1314
|
|
|
989
|
-
|
|
990
|
-
|
|
1315
|
+
function getClientRects(element) {
|
|
1316
|
+
return Array.from(element.getClientRects());
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
1320
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1321
|
+
function getDocumentRect(element) {
|
|
1322
|
+
const html = getDocumentElement(element);
|
|
1323
|
+
const scroll = getNodeScroll(element);
|
|
1324
|
+
const body = element.ownerDocument.body;
|
|
1325
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1326
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1327
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1328
|
+
const y = -scroll.scrollTop;
|
|
1329
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
1330
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1331
|
+
}
|
|
1332
|
+
return {
|
|
1333
|
+
width,
|
|
1334
|
+
height,
|
|
1335
|
+
x,
|
|
1336
|
+
y
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
|
1341
|
+
// calculation is affected by unusual styles.
|
|
1342
|
+
// Most scrollbars leave 15-18px of space.
|
|
1343
|
+
const SCROLLBAR_MAX = 25;
|
|
1344
|
+
function getViewportRect(element, strategy) {
|
|
1345
|
+
const win = getWindow(element);
|
|
1346
|
+
const html = getDocumentElement(element);
|
|
1347
|
+
const visualViewport = win.visualViewport;
|
|
1348
|
+
let width = html.clientWidth;
|
|
1349
|
+
let height = html.clientHeight;
|
|
1350
|
+
let x = 0;
|
|
1351
|
+
let y = 0;
|
|
1352
|
+
if (visualViewport) {
|
|
1353
|
+
width = visualViewport.width;
|
|
1354
|
+
height = visualViewport.height;
|
|
1355
|
+
const visualViewportBased = isWebKit();
|
|
1356
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1357
|
+
x = visualViewport.offsetLeft;
|
|
1358
|
+
y = visualViewport.offsetTop;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1362
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
|
1363
|
+
// visual width of the <html> but this is not considered in the size
|
|
1364
|
+
// of `html.clientWidth`.
|
|
1365
|
+
if (windowScrollbarX <= 0) {
|
|
1366
|
+
const doc = html.ownerDocument;
|
|
1367
|
+
const body = doc.body;
|
|
1368
|
+
const bodyStyles = getComputedStyle(body);
|
|
1369
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1370
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1371
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1372
|
+
width -= clippingStableScrollbarWidth;
|
|
1373
|
+
}
|
|
1374
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1375
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
|
1376
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
|
1377
|
+
width += windowScrollbarX;
|
|
1378
|
+
}
|
|
1379
|
+
return {
|
|
1380
|
+
width,
|
|
1381
|
+
height,
|
|
1382
|
+
x,
|
|
1383
|
+
y
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1388
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1389
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1390
|
+
const top = clientRect.top + element.clientTop;
|
|
1391
|
+
const left = clientRect.left + element.clientLeft;
|
|
1392
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1393
|
+
const width = element.clientWidth * scale.x;
|
|
1394
|
+
const height = element.clientHeight * scale.y;
|
|
1395
|
+
const x = left * scale.x;
|
|
1396
|
+
const y = top * scale.y;
|
|
1397
|
+
return {
|
|
1398
|
+
width,
|
|
1399
|
+
height,
|
|
1400
|
+
x,
|
|
1401
|
+
y
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1405
|
+
let rect;
|
|
1406
|
+
if (clippingAncestor === 'viewport') {
|
|
1407
|
+
rect = getViewportRect(element, strategy);
|
|
1408
|
+
} else if (clippingAncestor === 'document') {
|
|
1409
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1410
|
+
} else if (isElement(clippingAncestor)) {
|
|
1411
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1412
|
+
} else {
|
|
1413
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1414
|
+
rect = {
|
|
1415
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1416
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1417
|
+
width: clippingAncestor.width,
|
|
1418
|
+
height: clippingAncestor.height
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
return rectToClientRect(rect);
|
|
1422
|
+
}
|
|
1423
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1424
|
+
const parentNode = getParentNode(element);
|
|
1425
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1432
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1433
|
+
// of the given element up the tree.
|
|
1434
|
+
function getClippingElementAncestors(element, cache) {
|
|
1435
|
+
const cachedResult = cache.get(element);
|
|
1436
|
+
if (cachedResult) {
|
|
1437
|
+
return cachedResult;
|
|
1438
|
+
}
|
|
1439
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1440
|
+
let currentContainingBlockComputedStyle = null;
|
|
1441
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
1442
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
991
1443
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1444
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1445
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1446
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1447
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1448
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1449
|
+
currentContainingBlockComputedStyle = null;
|
|
995
1450
|
}
|
|
996
|
-
|
|
997
|
-
|
|
1451
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1452
|
+
if (shouldDropCurrentNode) {
|
|
1453
|
+
// Drop non-containing blocks.
|
|
1454
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1455
|
+
} else {
|
|
1456
|
+
// Record last containing block for next iteration.
|
|
1457
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1458
|
+
}
|
|
1459
|
+
currentNode = getParentNode(currentNode);
|
|
1460
|
+
}
|
|
1461
|
+
cache.set(element, result);
|
|
1462
|
+
return result;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
1466
|
+
// clipping ancestors.
|
|
1467
|
+
function getClippingRect(_ref) {
|
|
1468
|
+
let {
|
|
1469
|
+
element,
|
|
1470
|
+
boundary,
|
|
1471
|
+
rootBoundary,
|
|
1472
|
+
strategy
|
|
1473
|
+
} = _ref;
|
|
1474
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1475
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1476
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
1477
|
+
let top = firstRect.top;
|
|
1478
|
+
let right = firstRect.right;
|
|
1479
|
+
let bottom = firstRect.bottom;
|
|
1480
|
+
let left = firstRect.left;
|
|
1481
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
1482
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
1483
|
+
top = max(rect.top, top);
|
|
1484
|
+
right = min(rect.right, right);
|
|
1485
|
+
bottom = min(rect.bottom, bottom);
|
|
1486
|
+
left = max(rect.left, left);
|
|
1487
|
+
}
|
|
1488
|
+
return {
|
|
1489
|
+
width: right - left,
|
|
1490
|
+
height: bottom - top,
|
|
1491
|
+
x: left,
|
|
1492
|
+
y: top
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function getDimensions(element) {
|
|
1497
|
+
const {
|
|
1498
|
+
width,
|
|
1499
|
+
height
|
|
1500
|
+
} = getCssDimensions(element);
|
|
1501
|
+
return {
|
|
1502
|
+
width,
|
|
1503
|
+
height
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1508
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1509
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1510
|
+
const isFixed = strategy === 'fixed';
|
|
1511
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1512
|
+
let scroll = {
|
|
1513
|
+
scrollLeft: 0,
|
|
1514
|
+
scrollTop: 0
|
|
1515
|
+
};
|
|
1516
|
+
const offsets = createCoords(0);
|
|
1517
|
+
|
|
1518
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
1519
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
1520
|
+
function setLeftRTLScrollbarOffset() {
|
|
1521
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1522
|
+
}
|
|
1523
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1524
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1525
|
+
scroll = getNodeScroll(offsetParent);
|
|
1526
|
+
}
|
|
1527
|
+
if (isOffsetParentAnElement) {
|
|
1528
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1529
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1530
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1531
|
+
} else if (documentElement) {
|
|
1532
|
+
setLeftRTLScrollbarOffset();
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1536
|
+
setLeftRTLScrollbarOffset();
|
|
1537
|
+
}
|
|
1538
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1539
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1540
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1541
|
+
return {
|
|
1542
|
+
x,
|
|
1543
|
+
y,
|
|
1544
|
+
width: rect.width,
|
|
1545
|
+
height: rect.height
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function isStaticPositioned(element) {
|
|
1550
|
+
return getComputedStyle$1(element).position === 'static';
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1554
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1555
|
+
return null;
|
|
1556
|
+
}
|
|
1557
|
+
if (polyfill) {
|
|
1558
|
+
return polyfill(element);
|
|
1559
|
+
}
|
|
1560
|
+
let rawOffsetParent = element.offsetParent;
|
|
1561
|
+
|
|
1562
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
1563
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
1564
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
1565
|
+
// non-static.
|
|
1566
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1567
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1568
|
+
}
|
|
1569
|
+
return rawOffsetParent;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1573
|
+
// such as table ancestors and cross browser bugs.
|
|
1574
|
+
function getOffsetParent(element, polyfill) {
|
|
1575
|
+
const win = getWindow(element);
|
|
1576
|
+
if (isTopLayer(element)) {
|
|
1577
|
+
return win;
|
|
1578
|
+
}
|
|
1579
|
+
if (!isHTMLElement(element)) {
|
|
1580
|
+
let svgOffsetParent = getParentNode(element);
|
|
1581
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1582
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1583
|
+
return svgOffsetParent;
|
|
1584
|
+
}
|
|
1585
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1586
|
+
}
|
|
1587
|
+
return win;
|
|
1588
|
+
}
|
|
1589
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1590
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1591
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1592
|
+
}
|
|
1593
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1594
|
+
return win;
|
|
1595
|
+
}
|
|
1596
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
const getElementRects = async function (data) {
|
|
1600
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1601
|
+
const getDimensionsFn = this.getDimensions;
|
|
1602
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1603
|
+
return {
|
|
1604
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1605
|
+
floating: {
|
|
1606
|
+
x: 0,
|
|
1607
|
+
y: 0,
|
|
1608
|
+
width: floatingDimensions.width,
|
|
1609
|
+
height: floatingDimensions.height
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
998
1612
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1613
|
+
|
|
1614
|
+
function isRTL(element) {
|
|
1615
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
const platform = {
|
|
1619
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1620
|
+
getDocumentElement,
|
|
1621
|
+
getClippingRect,
|
|
1622
|
+
getOffsetParent,
|
|
1623
|
+
getElementRects,
|
|
1624
|
+
getClientRects,
|
|
1625
|
+
getDimensions,
|
|
1626
|
+
getScale,
|
|
1627
|
+
isElement,
|
|
1628
|
+
isRTL
|
|
1005
1629
|
};
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1630
|
+
|
|
1631
|
+
function rectsAreEqual(a, b) {
|
|
1632
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// https://samthor.au/2021/observing-dom/
|
|
1636
|
+
function observeMove(element, onMove) {
|
|
1637
|
+
let io = null;
|
|
1638
|
+
let timeoutId;
|
|
1639
|
+
const root = getDocumentElement(element);
|
|
1640
|
+
function cleanup() {
|
|
1641
|
+
var _io;
|
|
1642
|
+
clearTimeout(timeoutId);
|
|
1643
|
+
(_io = io) == null || _io.disconnect();
|
|
1644
|
+
io = null;
|
|
1645
|
+
}
|
|
1646
|
+
function refresh(skip, threshold) {
|
|
1647
|
+
if (skip === void 0) {
|
|
1648
|
+
skip = false;
|
|
1649
|
+
}
|
|
1650
|
+
if (threshold === void 0) {
|
|
1651
|
+
threshold = 1;
|
|
1652
|
+
}
|
|
1653
|
+
cleanup();
|
|
1654
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1655
|
+
const {
|
|
1656
|
+
left,
|
|
1657
|
+
top,
|
|
1658
|
+
width,
|
|
1659
|
+
height
|
|
1660
|
+
} = elementRectForRootMargin;
|
|
1661
|
+
if (!skip) {
|
|
1662
|
+
onMove();
|
|
1663
|
+
}
|
|
1664
|
+
if (!width || !height) {
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
const insetTop = floor(top);
|
|
1668
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1669
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1670
|
+
const insetLeft = floor(left);
|
|
1671
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1672
|
+
const options = {
|
|
1673
|
+
rootMargin,
|
|
1674
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1675
|
+
};
|
|
1676
|
+
let isFirstUpdate = true;
|
|
1677
|
+
function handleObserve(entries) {
|
|
1678
|
+
const ratio = entries[0].intersectionRatio;
|
|
1679
|
+
if (ratio !== threshold) {
|
|
1680
|
+
if (!isFirstUpdate) {
|
|
1681
|
+
return refresh();
|
|
1011
1682
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1683
|
+
if (!ratio) {
|
|
1684
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
1685
|
+
// to prevent an infinite loop of updates.
|
|
1686
|
+
timeoutId = setTimeout(() => {
|
|
1687
|
+
refresh(false, 1e-7);
|
|
1688
|
+
}, 1000);
|
|
1689
|
+
} else {
|
|
1690
|
+
refresh(false, ratio);
|
|
1015
1691
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1692
|
+
}
|
|
1693
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
1694
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
1695
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
1696
|
+
// area anymore. This can happen under performance constraints. This may
|
|
1697
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
1698
|
+
// work around this, we compare the element's bounding rect now with
|
|
1699
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
1700
|
+
// are not equal then the element moved, so we refresh.
|
|
1701
|
+
refresh();
|
|
1702
|
+
}
|
|
1703
|
+
isFirstUpdate = false;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1707
|
+
// error.
|
|
1708
|
+
try {
|
|
1709
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1710
|
+
...options,
|
|
1711
|
+
// Handle <iframe>s
|
|
1712
|
+
root: root.ownerDocument
|
|
1713
|
+
});
|
|
1714
|
+
} catch (_e) {
|
|
1715
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1716
|
+
}
|
|
1717
|
+
io.observe(element);
|
|
1718
|
+
}
|
|
1719
|
+
refresh(true);
|
|
1720
|
+
return cleanup;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1021
1723
|
/**
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
* @
|
|
1026
|
-
*
|
|
1027
|
-
* @
|
|
1724
|
+
* Automatically updates the position of the floating element when necessary.
|
|
1725
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
1726
|
+
* visible on the screen.
|
|
1727
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
1728
|
+
* removed from the DOM or hidden from the screen.
|
|
1729
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
1028
1730
|
*/
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1731
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1732
|
+
if (options === void 0) {
|
|
1733
|
+
options = {};
|
|
1734
|
+
}
|
|
1735
|
+
const {
|
|
1736
|
+
ancestorScroll = true,
|
|
1737
|
+
ancestorResize = true,
|
|
1738
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1739
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1740
|
+
animationFrame = false
|
|
1741
|
+
} = options;
|
|
1742
|
+
const referenceEl = unwrapElement(reference);
|
|
1743
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
|
|
1744
|
+
ancestors.forEach(ancestor => {
|
|
1745
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1746
|
+
passive: true
|
|
1747
|
+
});
|
|
1748
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1749
|
+
});
|
|
1750
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1751
|
+
let reobserveFrame = -1;
|
|
1752
|
+
let resizeObserver = null;
|
|
1753
|
+
if (elementResize) {
|
|
1754
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1755
|
+
let [firstEntry] = _ref;
|
|
1756
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
1757
|
+
// Prevent update loops when using the `size` middleware.
|
|
1758
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1759
|
+
resizeObserver.unobserve(floating);
|
|
1760
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1761
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1762
|
+
var _resizeObserver;
|
|
1763
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
update();
|
|
1767
|
+
});
|
|
1768
|
+
if (referenceEl && !animationFrame) {
|
|
1769
|
+
resizeObserver.observe(referenceEl);
|
|
1770
|
+
}
|
|
1771
|
+
if (floating) {
|
|
1772
|
+
resizeObserver.observe(floating);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
let frameId;
|
|
1776
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1777
|
+
if (animationFrame) {
|
|
1778
|
+
frameLoop();
|
|
1779
|
+
}
|
|
1780
|
+
function frameLoop() {
|
|
1781
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1782
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
1783
|
+
update();
|
|
1033
1784
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1785
|
+
prevRefRect = nextRefRect;
|
|
1786
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1787
|
+
}
|
|
1788
|
+
update();
|
|
1789
|
+
return () => {
|
|
1790
|
+
var _resizeObserver2;
|
|
1791
|
+
ancestors.forEach(ancestor => {
|
|
1792
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1793
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1794
|
+
});
|
|
1795
|
+
cleanupIo == null || cleanupIo();
|
|
1796
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1797
|
+
resizeObserver = null;
|
|
1798
|
+
if (animationFrame) {
|
|
1799
|
+
cancelAnimationFrame(frameId);
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Modifies the placement by translating the floating element along the
|
|
1806
|
+
* specified axes.
|
|
1807
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1808
|
+
* object may be passed.
|
|
1809
|
+
* @see https://floating-ui.com/docs/offset
|
|
1810
|
+
*/
|
|
1811
|
+
const offset$1 = offset$2;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1815
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1816
|
+
* @see https://floating-ui.com/docs/shift
|
|
1817
|
+
*/
|
|
1818
|
+
const shift$1 = shift$2;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1822
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1823
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1824
|
+
* @see https://floating-ui.com/docs/flip
|
|
1825
|
+
*/
|
|
1826
|
+
const flip$1 = flip$2;
|
|
1827
|
+
|
|
1828
|
+
/**
|
|
1829
|
+
* Provides data that allows you to change the size of the floating element —
|
|
1830
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1831
|
+
* width of the reference element.
|
|
1832
|
+
* @see https://floating-ui.com/docs/size
|
|
1833
|
+
*/
|
|
1834
|
+
const size$1 = size$2;
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
1838
|
+
* when it is not in the same clipping context as the reference element.
|
|
1839
|
+
* @see https://floating-ui.com/docs/hide
|
|
1840
|
+
*/
|
|
1841
|
+
const hide$1 = hide$2;
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1845
|
+
* appears centered to the reference element.
|
|
1846
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1847
|
+
*/
|
|
1848
|
+
const arrow$2 = arrow$3;
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1852
|
+
*/
|
|
1853
|
+
const limitShift$1 = limitShift$2;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1857
|
+
* next to a given reference element.
|
|
1858
|
+
*/
|
|
1859
|
+
const computePosition = (reference, floating, options) => {
|
|
1860
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
1861
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
1862
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
1863
|
+
const cache = new Map();
|
|
1864
|
+
const mergedOptions = {
|
|
1865
|
+
platform,
|
|
1866
|
+
...options
|
|
1867
|
+
};
|
|
1868
|
+
const platformWithCache = {
|
|
1869
|
+
...mergedOptions.platform,
|
|
1870
|
+
_c: cache
|
|
1871
|
+
};
|
|
1872
|
+
return computePosition$1(reference, floating, {
|
|
1873
|
+
...mergedOptions,
|
|
1874
|
+
platform: platformWithCache
|
|
1875
|
+
});
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
var isClient = typeof document !== 'undefined';
|
|
1879
|
+
|
|
1880
|
+
var noop = function noop() {};
|
|
1881
|
+
var index = isClient ? useLayoutEffect : noop;
|
|
1882
|
+
|
|
1883
|
+
// Fork of `fast-deep-equal` that only does the comparisons we need and compares
|
|
1884
|
+
// functions
|
|
1885
|
+
function deepEqual(a, b) {
|
|
1886
|
+
if (a === b) {
|
|
1887
|
+
return true;
|
|
1888
|
+
}
|
|
1889
|
+
if (typeof a !== typeof b) {
|
|
1890
|
+
return false;
|
|
1891
|
+
}
|
|
1892
|
+
if (typeof a === 'function' && a.toString() === b.toString()) {
|
|
1893
|
+
return true;
|
|
1894
|
+
}
|
|
1895
|
+
let length;
|
|
1896
|
+
let i;
|
|
1897
|
+
let keys;
|
|
1898
|
+
if (a && b && typeof a === 'object') {
|
|
1899
|
+
if (Array.isArray(a)) {
|
|
1900
|
+
length = a.length;
|
|
1901
|
+
if (length !== b.length) return false;
|
|
1902
|
+
for (i = length; i-- !== 0;) {
|
|
1903
|
+
if (!deepEqual(a[i], b[i])) {
|
|
1904
|
+
return false;
|
|
1041
1905
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1906
|
+
}
|
|
1907
|
+
return true;
|
|
1908
|
+
}
|
|
1909
|
+
keys = Object.keys(a);
|
|
1910
|
+
length = keys.length;
|
|
1911
|
+
if (length !== Object.keys(b).length) {
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
for (i = length; i-- !== 0;) {
|
|
1915
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
1916
|
+
return false;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
for (i = length; i-- !== 0;) {
|
|
1920
|
+
const key = keys[i];
|
|
1921
|
+
if (key === '_owner' && a.$$typeof) {
|
|
1922
|
+
continue;
|
|
1923
|
+
}
|
|
1924
|
+
if (!deepEqual(a[key], b[key])) {
|
|
1925
|
+
return false;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
return true;
|
|
1929
|
+
}
|
|
1930
|
+
return a !== a && b !== b;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
function getDPR(element) {
|
|
1934
|
+
if (typeof window === 'undefined') {
|
|
1935
|
+
return 1;
|
|
1936
|
+
}
|
|
1937
|
+
const win = element.ownerDocument.defaultView || window;
|
|
1938
|
+
return win.devicePixelRatio || 1;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
function roundByDPR(element, value) {
|
|
1942
|
+
const dpr = getDPR(element);
|
|
1943
|
+
return Math.round(value * dpr) / dpr;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
function useLatestRef(value) {
|
|
1947
|
+
const ref = React.useRef(value);
|
|
1948
|
+
index(() => {
|
|
1949
|
+
ref.current = value;
|
|
1950
|
+
});
|
|
1951
|
+
return ref;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* Provides data to position a floating element.
|
|
1956
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
1957
|
+
*/
|
|
1958
|
+
function useFloating(options) {
|
|
1959
|
+
if (options === void 0) {
|
|
1960
|
+
options = {};
|
|
1961
|
+
}
|
|
1962
|
+
const {
|
|
1963
|
+
placement = 'bottom',
|
|
1964
|
+
strategy = 'absolute',
|
|
1965
|
+
middleware = [],
|
|
1966
|
+
platform,
|
|
1967
|
+
elements: {
|
|
1968
|
+
reference: externalReference,
|
|
1969
|
+
floating: externalFloating
|
|
1970
|
+
} = {},
|
|
1971
|
+
transform = true,
|
|
1972
|
+
whileElementsMounted,
|
|
1973
|
+
open
|
|
1974
|
+
} = options;
|
|
1975
|
+
const [data, setData] = React.useState({
|
|
1976
|
+
x: 0,
|
|
1977
|
+
y: 0,
|
|
1978
|
+
strategy,
|
|
1979
|
+
placement,
|
|
1980
|
+
middlewareData: {},
|
|
1981
|
+
isPositioned: false
|
|
1982
|
+
});
|
|
1983
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
1984
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
1985
|
+
setLatestMiddleware(middleware);
|
|
1986
|
+
}
|
|
1987
|
+
const [_reference, _setReference] = React.useState(null);
|
|
1988
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
1989
|
+
const setReference = React.useCallback(node => {
|
|
1990
|
+
if (node !== referenceRef.current) {
|
|
1991
|
+
referenceRef.current = node;
|
|
1992
|
+
_setReference(node);
|
|
1993
|
+
}
|
|
1994
|
+
}, []);
|
|
1995
|
+
const setFloating = React.useCallback(node => {
|
|
1996
|
+
if (node !== floatingRef.current) {
|
|
1997
|
+
floatingRef.current = node;
|
|
1998
|
+
_setFloating(node);
|
|
1999
|
+
}
|
|
2000
|
+
}, []);
|
|
2001
|
+
const referenceEl = externalReference || _reference;
|
|
2002
|
+
const floatingEl = externalFloating || _floating;
|
|
2003
|
+
const referenceRef = React.useRef(null);
|
|
2004
|
+
const floatingRef = React.useRef(null);
|
|
2005
|
+
const dataRef = React.useRef(data);
|
|
2006
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
2007
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
2008
|
+
const platformRef = useLatestRef(platform);
|
|
2009
|
+
const openRef = useLatestRef(open);
|
|
2010
|
+
const update = React.useCallback(() => {
|
|
2011
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
const config = {
|
|
2015
|
+
placement,
|
|
2016
|
+
strategy,
|
|
2017
|
+
middleware: latestMiddleware
|
|
1044
2018
|
};
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
markerCounter.set(node, markerValue);
|
|
1062
|
-
hiddenNodes.push(node);
|
|
1063
|
-
if (counterValue === 1 && alreadyHidden) {
|
|
1064
|
-
uncontrolledNodes.set(node, true);
|
|
1065
|
-
}
|
|
1066
|
-
if (markerValue === 1) {
|
|
1067
|
-
node.setAttribute(markerName, 'true');
|
|
1068
|
-
}
|
|
1069
|
-
if (!alreadyHidden) {
|
|
1070
|
-
node.setAttribute(controlAttribute, 'true');
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
catch (e) {
|
|
1074
|
-
console.error('aria-hidden: cannot operate on ', node, e);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
2019
|
+
if (platformRef.current) {
|
|
2020
|
+
config.platform = platformRef.current;
|
|
2021
|
+
}
|
|
2022
|
+
computePosition(referenceRef.current, floatingRef.current, config).then(data => {
|
|
2023
|
+
const fullData = {
|
|
2024
|
+
...data,
|
|
2025
|
+
// The floating element's position may be recomputed while it's closed
|
|
2026
|
+
// but still mounted (such as when transitioning out). To ensure
|
|
2027
|
+
// `isPositioned` will be `false` initially on the next open, avoid
|
|
2028
|
+
// setting it to `true` when `open === false` (must be specified).
|
|
2029
|
+
isPositioned: openRef.current !== false
|
|
2030
|
+
};
|
|
2031
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
2032
|
+
dataRef.current = fullData;
|
|
2033
|
+
ReactDOM.flushSync(() => {
|
|
2034
|
+
setData(fullData);
|
|
1077
2035
|
});
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
}, [latestMiddleware, placement, strategy, platformRef, openRef]);
|
|
2039
|
+
index(() => {
|
|
2040
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
2041
|
+
dataRef.current.isPositioned = false;
|
|
2042
|
+
setData(data => ({
|
|
2043
|
+
...data,
|
|
2044
|
+
isPositioned: false
|
|
2045
|
+
}));
|
|
2046
|
+
}
|
|
2047
|
+
}, [open]);
|
|
2048
|
+
const isMountedRef = React.useRef(false);
|
|
2049
|
+
index(() => {
|
|
2050
|
+
isMountedRef.current = true;
|
|
2051
|
+
return () => {
|
|
2052
|
+
isMountedRef.current = false;
|
|
1078
2053
|
};
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
2054
|
+
}, []);
|
|
2055
|
+
index(() => {
|
|
2056
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
2057
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
2058
|
+
if (referenceEl && floatingEl) {
|
|
2059
|
+
if (whileElementsMountedRef.current) {
|
|
2060
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
2061
|
+
}
|
|
2062
|
+
update();
|
|
2063
|
+
}
|
|
2064
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
2065
|
+
const refs = React.useMemo(() => ({
|
|
2066
|
+
reference: referenceRef,
|
|
2067
|
+
floating: floatingRef,
|
|
2068
|
+
setReference,
|
|
2069
|
+
setFloating
|
|
2070
|
+
}), [setReference, setFloating]);
|
|
2071
|
+
const elements = React.useMemo(() => ({
|
|
2072
|
+
reference: referenceEl,
|
|
2073
|
+
floating: floatingEl
|
|
2074
|
+
}), [referenceEl, floatingEl]);
|
|
2075
|
+
const floatingStyles = React.useMemo(() => {
|
|
2076
|
+
const initialStyles = {
|
|
2077
|
+
position: strategy,
|
|
2078
|
+
left: 0,
|
|
2079
|
+
top: 0
|
|
1106
2080
|
};
|
|
2081
|
+
if (!elements.floating) {
|
|
2082
|
+
return initialStyles;
|
|
2083
|
+
}
|
|
2084
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
2085
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
2086
|
+
if (transform) {
|
|
2087
|
+
return {
|
|
2088
|
+
...initialStyles,
|
|
2089
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
2090
|
+
...(getDPR(elements.floating) >= 1.5 && {
|
|
2091
|
+
willChange: 'transform'
|
|
2092
|
+
})
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
return {
|
|
2096
|
+
position: strategy,
|
|
2097
|
+
left: x,
|
|
2098
|
+
top: y
|
|
2099
|
+
};
|
|
2100
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
2101
|
+
return React.useMemo(() => ({
|
|
2102
|
+
...data,
|
|
2103
|
+
update,
|
|
2104
|
+
refs,
|
|
2105
|
+
elements,
|
|
2106
|
+
floatingStyles
|
|
2107
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
/**
|
|
2111
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2112
|
+
* appears centered to the reference element.
|
|
2113
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
2114
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2115
|
+
*/
|
|
2116
|
+
const arrow$1 = options => {
|
|
2117
|
+
function isRef(value) {
|
|
2118
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
2119
|
+
}
|
|
2120
|
+
return {
|
|
2121
|
+
name: 'arrow',
|
|
2122
|
+
options,
|
|
2123
|
+
fn(state) {
|
|
2124
|
+
const {
|
|
2125
|
+
element,
|
|
2126
|
+
padding
|
|
2127
|
+
} = typeof options === 'function' ? options(state) : options;
|
|
2128
|
+
if (element && isRef(element)) {
|
|
2129
|
+
if (element.current != null) {
|
|
2130
|
+
return arrow$2({
|
|
2131
|
+
element: element.current,
|
|
2132
|
+
padding
|
|
2133
|
+
}).fn(state);
|
|
2134
|
+
}
|
|
2135
|
+
return {};
|
|
2136
|
+
}
|
|
2137
|
+
if (element) {
|
|
2138
|
+
return arrow$2({
|
|
2139
|
+
element,
|
|
2140
|
+
padding
|
|
2141
|
+
}).fn(state);
|
|
2142
|
+
}
|
|
2143
|
+
return {};
|
|
2144
|
+
}
|
|
2145
|
+
};
|
|
2146
|
+
};
|
|
2147
|
+
|
|
2148
|
+
/**
|
|
2149
|
+
* Modifies the placement by translating the floating element along the
|
|
2150
|
+
* specified axes.
|
|
2151
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
2152
|
+
* object may be passed.
|
|
2153
|
+
* @see https://floating-ui.com/docs/offset
|
|
2154
|
+
*/
|
|
2155
|
+
const offset = (options, deps) => {
|
|
2156
|
+
const result = offset$1(options);
|
|
2157
|
+
return {
|
|
2158
|
+
name: result.name,
|
|
2159
|
+
fn: result.fn,
|
|
2160
|
+
options: [options, deps]
|
|
2161
|
+
};
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
2166
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
2167
|
+
* @see https://floating-ui.com/docs/shift
|
|
2168
|
+
*/
|
|
2169
|
+
const shift = (options, deps) => {
|
|
2170
|
+
const result = shift$1(options);
|
|
2171
|
+
return {
|
|
2172
|
+
name: result.name,
|
|
2173
|
+
fn: result.fn,
|
|
2174
|
+
options: [options, deps]
|
|
2175
|
+
};
|
|
1107
2176
|
};
|
|
2177
|
+
|
|
2178
|
+
/**
|
|
2179
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
2180
|
+
*/
|
|
2181
|
+
const limitShift = (options, deps) => {
|
|
2182
|
+
const result = limitShift$1(options);
|
|
2183
|
+
return {
|
|
2184
|
+
fn: result.fn,
|
|
2185
|
+
options: [options, deps]
|
|
2186
|
+
};
|
|
2187
|
+
};
|
|
2188
|
+
|
|
2189
|
+
/**
|
|
2190
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2191
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2192
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2193
|
+
* @see https://floating-ui.com/docs/flip
|
|
2194
|
+
*/
|
|
2195
|
+
const flip = (options, deps) => {
|
|
2196
|
+
const result = flip$1(options);
|
|
2197
|
+
return {
|
|
2198
|
+
name: result.name,
|
|
2199
|
+
fn: result.fn,
|
|
2200
|
+
options: [options, deps]
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
|
|
1108
2204
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
* @
|
|
1113
|
-
* @return {Undo} undo command
|
|
2205
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2206
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2207
|
+
* width of the reference element.
|
|
2208
|
+
* @see https://floating-ui.com/docs/size
|
|
1114
2209
|
*/
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
2210
|
+
const size = (options, deps) => {
|
|
2211
|
+
const result = size$1(options);
|
|
2212
|
+
return {
|
|
2213
|
+
name: result.name,
|
|
2214
|
+
fn: result.fn,
|
|
2215
|
+
options: [options, deps]
|
|
2216
|
+
};
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
2221
|
+
* when it is not in the same clipping context as the reference element.
|
|
2222
|
+
* @see https://floating-ui.com/docs/hide
|
|
2223
|
+
*/
|
|
2224
|
+
const hide = (options, deps) => {
|
|
2225
|
+
const result = hide$1(options);
|
|
2226
|
+
return {
|
|
2227
|
+
name: result.name,
|
|
2228
|
+
fn: result.fn,
|
|
2229
|
+
options: [options, deps]
|
|
2230
|
+
};
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2235
|
+
* appears centered to the reference element.
|
|
2236
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
2237
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2238
|
+
*/
|
|
2239
|
+
const arrow = (options, deps) => {
|
|
2240
|
+
const result = arrow$1(options);
|
|
2241
|
+
return {
|
|
2242
|
+
name: result.name,
|
|
2243
|
+
fn: result.fn,
|
|
2244
|
+
options: [options, deps]
|
|
2245
|
+
};
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
// src/arrow.tsx
|
|
2249
|
+
var NAME = "Arrow";
|
|
2250
|
+
var Arrow$1 = React.forwardRef((props, forwardedRef) => {
|
|
2251
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
2252
|
+
return /* @__PURE__ */ jsx(
|
|
2253
|
+
Primitive.svg,
|
|
2254
|
+
{
|
|
2255
|
+
...arrowProps,
|
|
2256
|
+
ref: forwardedRef,
|
|
2257
|
+
width,
|
|
2258
|
+
height,
|
|
2259
|
+
viewBox: "0 0 30 10",
|
|
2260
|
+
preserveAspectRatio: "none",
|
|
2261
|
+
children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
|
|
1121
2262
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
2263
|
+
);
|
|
2264
|
+
});
|
|
2265
|
+
Arrow$1.displayName = NAME;
|
|
2266
|
+
var Root = Arrow$1;
|
|
2267
|
+
|
|
2268
|
+
// packages/react/use-size/src/use-size.tsx
|
|
2269
|
+
function useSize(element) {
|
|
2270
|
+
const [size, setSize] = React.useState(void 0);
|
|
2271
|
+
useLayoutEffect2(() => {
|
|
2272
|
+
if (element) {
|
|
2273
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
2274
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2275
|
+
if (!Array.isArray(entries)) {
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
if (!entries.length) {
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
const entry = entries[0];
|
|
2282
|
+
let width;
|
|
2283
|
+
let height;
|
|
2284
|
+
if ("borderBoxSize" in entry) {
|
|
2285
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
2286
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
2287
|
+
width = borderSize["inlineSize"];
|
|
2288
|
+
height = borderSize["blockSize"];
|
|
2289
|
+
} else {
|
|
2290
|
+
width = element.offsetWidth;
|
|
2291
|
+
height = element.offsetHeight;
|
|
2292
|
+
}
|
|
2293
|
+
setSize({ width, height });
|
|
2294
|
+
});
|
|
2295
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
2296
|
+
return () => resizeObserver.unobserve(element);
|
|
2297
|
+
} else {
|
|
2298
|
+
setSize(void 0);
|
|
2299
|
+
}
|
|
2300
|
+
}, [element]);
|
|
2301
|
+
return size;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
var POPPER_NAME = "Popper";
|
|
2305
|
+
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
2306
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
2307
|
+
var Popper = (props) => {
|
|
2308
|
+
const { __scopePopper, children } = props;
|
|
2309
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
2310
|
+
return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
|
1126
2311
|
};
|
|
2312
|
+
Popper.displayName = POPPER_NAME;
|
|
2313
|
+
var ANCHOR_NAME = "PopperAnchor";
|
|
2314
|
+
var PopperAnchor = React.forwardRef(
|
|
2315
|
+
(props, forwardedRef) => {
|
|
2316
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
2317
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
2318
|
+
const ref = React.useRef(null);
|
|
2319
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
2320
|
+
const anchorRef = React.useRef(null);
|
|
2321
|
+
React.useEffect(() => {
|
|
2322
|
+
const previousAnchor = anchorRef.current;
|
|
2323
|
+
anchorRef.current = virtualRef?.current || ref.current;
|
|
2324
|
+
if (previousAnchor !== anchorRef.current) {
|
|
2325
|
+
context.onAnchorChange(anchorRef.current);
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
|
|
2329
|
+
}
|
|
2330
|
+
);
|
|
2331
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
2332
|
+
var CONTENT_NAME = "PopperContent";
|
|
2333
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
|
|
2334
|
+
var PopperContent = React.forwardRef(
|
|
2335
|
+
(props, forwardedRef) => {
|
|
2336
|
+
const {
|
|
2337
|
+
__scopePopper,
|
|
2338
|
+
side = "bottom",
|
|
2339
|
+
sideOffset = 0,
|
|
2340
|
+
align = "center",
|
|
2341
|
+
alignOffset = 0,
|
|
2342
|
+
arrowPadding = 0,
|
|
2343
|
+
avoidCollisions = true,
|
|
2344
|
+
collisionBoundary = [],
|
|
2345
|
+
collisionPadding: collisionPaddingProp = 0,
|
|
2346
|
+
sticky = "partial",
|
|
2347
|
+
hideWhenDetached = false,
|
|
2348
|
+
updatePositionStrategy = "optimized",
|
|
2349
|
+
onPlaced,
|
|
2350
|
+
...contentProps
|
|
2351
|
+
} = props;
|
|
2352
|
+
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
2353
|
+
const [content, setContent] = React.useState(null);
|
|
2354
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
2355
|
+
const [arrow$1, setArrow] = React.useState(null);
|
|
2356
|
+
const arrowSize = useSize(arrow$1);
|
|
2357
|
+
const arrowWidth = arrowSize?.width ?? 0;
|
|
2358
|
+
const arrowHeight = arrowSize?.height ?? 0;
|
|
2359
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
2360
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
|
|
2361
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
2362
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
2363
|
+
const detectOverflowOptions = {
|
|
2364
|
+
padding: collisionPadding,
|
|
2365
|
+
boundary: boundary.filter(isNotNull),
|
|
2366
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
2367
|
+
altBoundary: hasExplicitBoundaries
|
|
2368
|
+
};
|
|
2369
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
|
|
2370
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
2371
|
+
strategy: "fixed",
|
|
2372
|
+
placement: desiredPlacement,
|
|
2373
|
+
whileElementsMounted: (...args) => {
|
|
2374
|
+
const cleanup = autoUpdate(...args, {
|
|
2375
|
+
animationFrame: updatePositionStrategy === "always"
|
|
2376
|
+
});
|
|
2377
|
+
return cleanup;
|
|
2378
|
+
},
|
|
2379
|
+
elements: {
|
|
2380
|
+
reference: context.anchor
|
|
2381
|
+
},
|
|
2382
|
+
middleware: [
|
|
2383
|
+
offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
|
|
2384
|
+
avoidCollisions && shift({
|
|
2385
|
+
mainAxis: true,
|
|
2386
|
+
crossAxis: false,
|
|
2387
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
2388
|
+
...detectOverflowOptions
|
|
2389
|
+
}),
|
|
2390
|
+
avoidCollisions && flip({ ...detectOverflowOptions }),
|
|
2391
|
+
size({
|
|
2392
|
+
...detectOverflowOptions,
|
|
2393
|
+
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
2394
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
2395
|
+
const contentStyle = elements.floating.style;
|
|
2396
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
2397
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
2398
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
2399
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
2400
|
+
}
|
|
2401
|
+
}),
|
|
2402
|
+
arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
|
|
2403
|
+
transformOrigin({ arrowWidth, arrowHeight }),
|
|
2404
|
+
hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
|
|
2405
|
+
]
|
|
2406
|
+
});
|
|
2407
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
2408
|
+
const handlePlaced = useCallbackRef(onPlaced);
|
|
2409
|
+
useLayoutEffect2(() => {
|
|
2410
|
+
if (isPositioned) {
|
|
2411
|
+
handlePlaced?.();
|
|
2412
|
+
}
|
|
2413
|
+
}, [isPositioned, handlePlaced]);
|
|
2414
|
+
const arrowX = middlewareData.arrow?.x;
|
|
2415
|
+
const arrowY = middlewareData.arrow?.y;
|
|
2416
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
2417
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
2418
|
+
useLayoutEffect2(() => {
|
|
2419
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
2420
|
+
}, [content]);
|
|
2421
|
+
return /* @__PURE__ */ jsx(
|
|
2422
|
+
"div",
|
|
2423
|
+
{
|
|
2424
|
+
ref: refs.setFloating,
|
|
2425
|
+
"data-radix-popper-content-wrapper": "",
|
|
2426
|
+
style: {
|
|
2427
|
+
...floatingStyles,
|
|
2428
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
2429
|
+
// keep off the page when measuring
|
|
2430
|
+
minWidth: "max-content",
|
|
2431
|
+
zIndex: contentZIndex,
|
|
2432
|
+
["--radix-popper-transform-origin"]: [
|
|
2433
|
+
middlewareData.transformOrigin?.x,
|
|
2434
|
+
middlewareData.transformOrigin?.y
|
|
2435
|
+
].join(" "),
|
|
2436
|
+
// hide the content if using the hide middleware and should be hidden
|
|
2437
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
|
2438
|
+
// as if the PopperContent isn't there at all
|
|
2439
|
+
...middlewareData.hide?.referenceHidden && {
|
|
2440
|
+
visibility: "hidden",
|
|
2441
|
+
pointerEvents: "none"
|
|
2442
|
+
}
|
|
2443
|
+
},
|
|
2444
|
+
dir: props.dir,
|
|
2445
|
+
children: /* @__PURE__ */ jsx(
|
|
2446
|
+
PopperContentProvider,
|
|
2447
|
+
{
|
|
2448
|
+
scope: __scopePopper,
|
|
2449
|
+
placedSide,
|
|
2450
|
+
onArrowChange: setArrow,
|
|
2451
|
+
arrowX,
|
|
2452
|
+
arrowY,
|
|
2453
|
+
shouldHideArrow: cannotCenterArrow,
|
|
2454
|
+
children: /* @__PURE__ */ jsx(
|
|
2455
|
+
Primitive.div,
|
|
2456
|
+
{
|
|
2457
|
+
"data-side": placedSide,
|
|
2458
|
+
"data-align": placedAlign,
|
|
2459
|
+
...contentProps,
|
|
2460
|
+
ref: composedRefs,
|
|
2461
|
+
style: {
|
|
2462
|
+
...contentProps.style,
|
|
2463
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
2464
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
2465
|
+
animation: !isPositioned ? "none" : void 0
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
)
|
|
2469
|
+
}
|
|
2470
|
+
)
|
|
2471
|
+
}
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
);
|
|
2475
|
+
PopperContent.displayName = CONTENT_NAME;
|
|
2476
|
+
var ARROW_NAME = "PopperArrow";
|
|
2477
|
+
var OPPOSITE_SIDE = {
|
|
2478
|
+
top: "bottom",
|
|
2479
|
+
right: "left",
|
|
2480
|
+
bottom: "top",
|
|
2481
|
+
left: "right"
|
|
2482
|
+
};
|
|
2483
|
+
var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
2484
|
+
const { __scopePopper, ...arrowProps } = props;
|
|
2485
|
+
const contentContext = useContentContext(ARROW_NAME, __scopePopper);
|
|
2486
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
2487
|
+
return (
|
|
2488
|
+
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
2489
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
2490
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
2491
|
+
/* @__PURE__ */ jsx(
|
|
2492
|
+
"span",
|
|
2493
|
+
{
|
|
2494
|
+
ref: contentContext.onArrowChange,
|
|
2495
|
+
style: {
|
|
2496
|
+
position: "absolute",
|
|
2497
|
+
left: contentContext.arrowX,
|
|
2498
|
+
top: contentContext.arrowY,
|
|
2499
|
+
[baseSide]: 0,
|
|
2500
|
+
transformOrigin: {
|
|
2501
|
+
top: "",
|
|
2502
|
+
right: "0 0",
|
|
2503
|
+
bottom: "center 0",
|
|
2504
|
+
left: "100% 0"
|
|
2505
|
+
}[contentContext.placedSide],
|
|
2506
|
+
transform: {
|
|
2507
|
+
top: "translateY(100%)",
|
|
2508
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
2509
|
+
bottom: `rotate(180deg)`,
|
|
2510
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
2511
|
+
}[contentContext.placedSide],
|
|
2512
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
2513
|
+
},
|
|
2514
|
+
children: /* @__PURE__ */ jsx(
|
|
2515
|
+
Root,
|
|
2516
|
+
{
|
|
2517
|
+
...arrowProps,
|
|
2518
|
+
ref: forwardedRef,
|
|
2519
|
+
style: {
|
|
2520
|
+
...arrowProps.style,
|
|
2521
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
2522
|
+
display: "block"
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
)
|
|
2526
|
+
}
|
|
2527
|
+
)
|
|
2528
|
+
);
|
|
2529
|
+
});
|
|
2530
|
+
PopperArrow.displayName = ARROW_NAME;
|
|
2531
|
+
function isNotNull(value) {
|
|
2532
|
+
return value !== null;
|
|
2533
|
+
}
|
|
2534
|
+
var transformOrigin = (options) => ({
|
|
2535
|
+
name: "transformOrigin",
|
|
2536
|
+
options,
|
|
2537
|
+
fn(data) {
|
|
2538
|
+
const { placement, rects, middlewareData } = data;
|
|
2539
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
2540
|
+
const isArrowHidden = cannotCenterArrow;
|
|
2541
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
2542
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
2543
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
2544
|
+
const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
|
|
2545
|
+
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
|
2546
|
+
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
|
2547
|
+
let x = "";
|
|
2548
|
+
let y = "";
|
|
2549
|
+
if (placedSide === "bottom") {
|
|
2550
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2551
|
+
y = `${-arrowHeight}px`;
|
|
2552
|
+
} else if (placedSide === "top") {
|
|
2553
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2554
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
|
2555
|
+
} else if (placedSide === "right") {
|
|
2556
|
+
x = `${-arrowHeight}px`;
|
|
2557
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2558
|
+
} else if (placedSide === "left") {
|
|
2559
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
|
2560
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2561
|
+
}
|
|
2562
|
+
return { data: { x, y } };
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2565
|
+
function getSideAndAlignFromPlacement(placement) {
|
|
2566
|
+
const [side, align = "center"] = placement.split("-");
|
|
2567
|
+
return [side, align];
|
|
2568
|
+
}
|
|
2569
|
+
var Root2 = Popper;
|
|
2570
|
+
var Anchor = PopperAnchor;
|
|
2571
|
+
var Content = PopperContent;
|
|
2572
|
+
var Arrow = PopperArrow;
|
|
1127
2573
|
|
|
1128
|
-
export {
|
|
2574
|
+
export { Anchor as A, Content as C, Root2 as R, Arrow as a, isHTMLElement as b, createPopperScope as c, useFloating as d, isElement as e, floor as f, getOverflowAncestors as g, isWebKit as h, isShadowRoot as i, isLastTraversableNode as j, getParentNode as k, getComputedStyle$1 as l, isNode as m, getNodeName as n, autoUpdate as o, offset as p, flip as q, shift as s, useSize as u };
|
|
1129
2575
|
//# sourceMappingURL=index28.js.map
|