@wix/site-ui 1.30.0 → 1.31.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/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/8750.js
ADDED
|
@@ -0,0 +1,1920 @@
|
|
|
1
|
+
import { getOppositePlacement, round, getAxisLength as floating_ui_utils_getAxisLength, clamp as floating_ui_utils_clamp, createCoords, rectToClientRect as floating_ui_utils_rectToClientRect, getOppositeAxisPlacements, getSideAxis as floating_ui_utils_getSideAxis, sides as floating_ui_utils_sides, floor, getExpandedPlacements, getAlignmentSides as floating_ui_utils_getAlignmentSides, getAlignment as floating_ui_utils_getAlignment, getOppositeAxis, getAlignmentAxis as floating_ui_utils_getAlignmentAxis, getSide as floating_ui_utils_getSide, evaluate as floating_ui_utils_evaluate, getPaddingObject as floating_ui_utils_getPaddingObject, max as floating_ui_utils_max, min as floating_ui_utils_min } from "./3319.js";
|
|
2
|
+
import { isWebKit, getNodeName, isHTMLElement, getFrameElement, getComputedStyle as floating_ui_utils_dom_getComputedStyle, isOverflowElement, isTopLayer, getContainingBlock, getNodeScroll, isTableElement, isLastTraversableNode, getOverflowAncestors, getDocumentElement, getWindow, isElement, isContainingBlock, getParentNode } from "./3829.js";
|
|
3
|
+
import { useId } from "./6046.js";
|
|
4
|
+
import { useFloatingParentNodeId, useFloatingTree } from "./285.js";
|
|
5
|
+
import { useRefWithInit, useRenderElement, EMPTY_OBJECT } from "./8272.js";
|
|
6
|
+
import { PopupTriggerMap, FloatingRootStore } from "./5992.js";
|
|
7
|
+
import { useIsoLayoutEffect } from "./6499.js";
|
|
8
|
+
import { ownerDocument } from "./9829.js";
|
|
9
|
+
import { useStableCallback } from "./7541.js";
|
|
10
|
+
import { useValueAsRef } from "./4707.js";
|
|
11
|
+
import { useDirection } from "./9863.js";
|
|
12
|
+
import { DISABLED_TRANSITIONS_STYLE, popupStateMapping } from "./4388.js";
|
|
13
|
+
import * as __rspack_external_react from "react";
|
|
14
|
+
import * as __rspack_external_react_dom_7136dc57 from "react-dom";
|
|
15
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
16
|
+
let { reference, floating } = _ref;
|
|
17
|
+
const sideAxis = floating_ui_utils_getSideAxis(placement);
|
|
18
|
+
const alignmentAxis = floating_ui_utils_getAlignmentAxis(placement);
|
|
19
|
+
const alignLength = floating_ui_utils_getAxisLength(alignmentAxis);
|
|
20
|
+
const side = floating_ui_utils_getSide(placement);
|
|
21
|
+
const isVertical = 'y' === sideAxis;
|
|
22
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
23
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
24
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
25
|
+
let coords;
|
|
26
|
+
switch(side){
|
|
27
|
+
case 'top':
|
|
28
|
+
coords = {
|
|
29
|
+
x: commonX,
|
|
30
|
+
y: reference.y - floating.height
|
|
31
|
+
};
|
|
32
|
+
break;
|
|
33
|
+
case 'bottom':
|
|
34
|
+
coords = {
|
|
35
|
+
x: commonX,
|
|
36
|
+
y: reference.y + reference.height
|
|
37
|
+
};
|
|
38
|
+
break;
|
|
39
|
+
case 'right':
|
|
40
|
+
coords = {
|
|
41
|
+
x: reference.x + reference.width,
|
|
42
|
+
y: commonY
|
|
43
|
+
};
|
|
44
|
+
break;
|
|
45
|
+
case 'left':
|
|
46
|
+
coords = {
|
|
47
|
+
x: reference.x - floating.width,
|
|
48
|
+
y: commonY
|
|
49
|
+
};
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
coords = {
|
|
53
|
+
x: reference.x,
|
|
54
|
+
y: reference.y
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
switch(floating_ui_utils_getAlignment(placement)){
|
|
58
|
+
case 'start':
|
|
59
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
60
|
+
break;
|
|
61
|
+
case 'end':
|
|
62
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
return coords;
|
|
66
|
+
}
|
|
67
|
+
async function detectOverflow(state, options) {
|
|
68
|
+
var _await$platform$isEle;
|
|
69
|
+
if (void 0 === options) options = {};
|
|
70
|
+
const { x, y, platform, rects, elements, strategy } = state;
|
|
71
|
+
const { boundary = 'clippingAncestors', rootBoundary = 'viewport', elementContext = 'floating', altBoundary = false, padding = 0 } = floating_ui_utils_evaluate(options, state);
|
|
72
|
+
const paddingObject = floating_ui_utils_getPaddingObject(padding);
|
|
73
|
+
const altContext = 'floating' === elementContext ? 'reference' : 'floating';
|
|
74
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
75
|
+
const clippingClientRect = floating_ui_utils_rectToClientRect(await platform.getClippingRect({
|
|
76
|
+
element: (null != (_await$platform$isEle = await (null == platform.isElement ? void 0 : platform.isElement(element))) ? _await$platform$isEle : true) ? element : element.contextElement || await (null == platform.getDocumentElement ? void 0 : platform.getDocumentElement(elements.floating)),
|
|
77
|
+
boundary,
|
|
78
|
+
rootBoundary,
|
|
79
|
+
strategy
|
|
80
|
+
}));
|
|
81
|
+
const rect = 'floating' === elementContext ? {
|
|
82
|
+
x,
|
|
83
|
+
y,
|
|
84
|
+
width: rects.floating.width,
|
|
85
|
+
height: rects.floating.height
|
|
86
|
+
} : rects.reference;
|
|
87
|
+
const offsetParent = await (null == platform.getOffsetParent ? void 0 : platform.getOffsetParent(elements.floating));
|
|
88
|
+
const offsetScale = await (null == platform.isElement ? void 0 : platform.isElement(offsetParent)) ? await (null == platform.getScale ? void 0 : platform.getScale(offsetParent)) || {
|
|
89
|
+
x: 1,
|
|
90
|
+
y: 1
|
|
91
|
+
} : {
|
|
92
|
+
x: 1,
|
|
93
|
+
y: 1
|
|
94
|
+
};
|
|
95
|
+
const elementClientRect = floating_ui_utils_rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
96
|
+
elements,
|
|
97
|
+
rect,
|
|
98
|
+
offsetParent,
|
|
99
|
+
strategy
|
|
100
|
+
}) : rect);
|
|
101
|
+
return {
|
|
102
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
103
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
104
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
105
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const MAX_RESET_COUNT = 50;
|
|
109
|
+
const computePosition = async (reference, floating, config)=>{
|
|
110
|
+
const { placement = 'bottom', strategy = 'absolute', middleware = [], platform } = config;
|
|
111
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
112
|
+
...platform,
|
|
113
|
+
detectOverflow: detectOverflow
|
|
114
|
+
};
|
|
115
|
+
const rtl = await (null == platform.isRTL ? void 0 : platform.isRTL(floating));
|
|
116
|
+
let rects = await platform.getElementRects({
|
|
117
|
+
reference,
|
|
118
|
+
floating,
|
|
119
|
+
strategy
|
|
120
|
+
});
|
|
121
|
+
let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
|
|
122
|
+
let statefulPlacement = placement;
|
|
123
|
+
let resetCount = 0;
|
|
124
|
+
const middlewareData = {};
|
|
125
|
+
for(let i = 0; i < middleware.length; i++){
|
|
126
|
+
const currentMiddleware = middleware[i];
|
|
127
|
+
if (!currentMiddleware) continue;
|
|
128
|
+
const { name, fn } = currentMiddleware;
|
|
129
|
+
const { x: nextX, y: nextY, data, reset } = await fn({
|
|
130
|
+
x,
|
|
131
|
+
y,
|
|
132
|
+
initialPlacement: placement,
|
|
133
|
+
placement: statefulPlacement,
|
|
134
|
+
strategy,
|
|
135
|
+
middlewareData,
|
|
136
|
+
rects,
|
|
137
|
+
platform: platformWithDetectOverflow,
|
|
138
|
+
elements: {
|
|
139
|
+
reference,
|
|
140
|
+
floating
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
x = null != nextX ? nextX : x;
|
|
144
|
+
y = null != nextY ? nextY : y;
|
|
145
|
+
middlewareData[name] = {
|
|
146
|
+
...middlewareData[name],
|
|
147
|
+
...data
|
|
148
|
+
};
|
|
149
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
150
|
+
resetCount++;
|
|
151
|
+
if ('object' == typeof reset) {
|
|
152
|
+
if (reset.placement) statefulPlacement = reset.placement;
|
|
153
|
+
if (reset.rects) rects = true === reset.rects ? await platform.getElementRects({
|
|
154
|
+
reference,
|
|
155
|
+
floating,
|
|
156
|
+
strategy
|
|
157
|
+
}) : reset.rects;
|
|
158
|
+
({ x, y } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
159
|
+
}
|
|
160
|
+
i = -1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
x,
|
|
165
|
+
y,
|
|
166
|
+
placement: statefulPlacement,
|
|
167
|
+
strategy,
|
|
168
|
+
middlewareData
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const flip = function(options) {
|
|
172
|
+
if (void 0 === options) options = {};
|
|
173
|
+
return {
|
|
174
|
+
name: 'flip',
|
|
175
|
+
options,
|
|
176
|
+
async fn (state) {
|
|
177
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
178
|
+
const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
|
|
179
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = 'bestFit', fallbackAxisSideDirection = 'none', flipAlignment = true, ...detectOverflowOptions } = floating_ui_utils_evaluate(options, state);
|
|
180
|
+
if (null != (_middlewareData$arrow = middlewareData.arrow) && _middlewareData$arrow.alignmentOffset) return {};
|
|
181
|
+
const side = floating_ui_utils_getSide(placement);
|
|
182
|
+
const initialSideAxis = floating_ui_utils_getSideAxis(initialPlacement);
|
|
183
|
+
const isBasePlacement = floating_ui_utils_getSide(initialPlacement) === initialPlacement;
|
|
184
|
+
const rtl = await (null == platform.isRTL ? void 0 : platform.isRTL(elements.floating));
|
|
185
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [
|
|
186
|
+
getOppositePlacement(initialPlacement)
|
|
187
|
+
] : getExpandedPlacements(initialPlacement));
|
|
188
|
+
const hasFallbackAxisSideDirection = 'none' !== fallbackAxisSideDirection;
|
|
189
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
190
|
+
const placements = [
|
|
191
|
+
initialPlacement,
|
|
192
|
+
...fallbackPlacements
|
|
193
|
+
];
|
|
194
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
195
|
+
const overflows = [];
|
|
196
|
+
let overflowsData = (null == (_middlewareData$flip = middlewareData.flip) ? void 0 : _middlewareData$flip.overflows) || [];
|
|
197
|
+
if (checkMainAxis) overflows.push(overflow[side]);
|
|
198
|
+
if (checkCrossAxis) {
|
|
199
|
+
const sides = floating_ui_utils_getAlignmentSides(placement, rects, rtl);
|
|
200
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
201
|
+
}
|
|
202
|
+
overflowsData = [
|
|
203
|
+
...overflowsData,
|
|
204
|
+
{
|
|
205
|
+
placement,
|
|
206
|
+
overflows
|
|
207
|
+
}
|
|
208
|
+
];
|
|
209
|
+
if (!overflows.every((side)=>side <= 0)) {
|
|
210
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
211
|
+
const nextIndex = ((null == (_middlewareData$flip2 = middlewareData.flip) ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
212
|
+
const nextPlacement = placements[nextIndex];
|
|
213
|
+
if (nextPlacement) {
|
|
214
|
+
const ignoreCrossAxisOverflow = 'alignment' === checkCrossAxis ? initialSideAxis !== floating_ui_utils_getSideAxis(nextPlacement) : false;
|
|
215
|
+
if (!ignoreCrossAxisOverflow || overflowsData.every((d)=>floating_ui_utils_getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return {
|
|
216
|
+
data: {
|
|
217
|
+
index: nextIndex,
|
|
218
|
+
overflows: overflowsData
|
|
219
|
+
},
|
|
220
|
+
reset: {
|
|
221
|
+
placement: nextPlacement
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
let resetPlacement = null == (_overflowsData$filter = overflowsData.filter((d)=>d.overflows[0] <= 0).sort((a, b)=>a.overflows[1] - b.overflows[1])[0]) ? void 0 : _overflowsData$filter.placement;
|
|
226
|
+
if (!resetPlacement) switch(fallbackStrategy){
|
|
227
|
+
case 'bestFit':
|
|
228
|
+
{
|
|
229
|
+
var _overflowsData$filter2;
|
|
230
|
+
const placement = null == (_overflowsData$filter2 = overflowsData.filter((d)=>{
|
|
231
|
+
if (hasFallbackAxisSideDirection) {
|
|
232
|
+
const currentSideAxis = floating_ui_utils_getSideAxis(d.placement);
|
|
233
|
+
return currentSideAxis === initialSideAxis || 'y' === currentSideAxis;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
}).map((d)=>[
|
|
237
|
+
d.placement,
|
|
238
|
+
d.overflows.filter((overflow)=>overflow > 0).reduce((acc, overflow)=>acc + overflow, 0)
|
|
239
|
+
]).sort((a, b)=>a[1] - b[1])[0]) ? void 0 : _overflowsData$filter2[0];
|
|
240
|
+
if (placement) resetPlacement = placement;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case 'initialPlacement':
|
|
244
|
+
resetPlacement = initialPlacement;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
if (placement !== resetPlacement) return {
|
|
248
|
+
reset: {
|
|
249
|
+
placement: resetPlacement
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return {};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
function getSideOffsets(overflow, rect) {
|
|
258
|
+
return {
|
|
259
|
+
top: overflow.top - rect.height,
|
|
260
|
+
right: overflow.right - rect.width,
|
|
261
|
+
bottom: overflow.bottom - rect.height,
|
|
262
|
+
left: overflow.left - rect.width
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function isAnySideFullyClipped(overflow) {
|
|
266
|
+
return floating_ui_utils_sides.some((side)=>overflow[side] >= 0);
|
|
267
|
+
}
|
|
268
|
+
const hide = function(options) {
|
|
269
|
+
if (void 0 === options) options = {};
|
|
270
|
+
return {
|
|
271
|
+
name: 'hide',
|
|
272
|
+
options,
|
|
273
|
+
async fn (state) {
|
|
274
|
+
const { rects, platform } = state;
|
|
275
|
+
const { strategy = 'referenceHidden', ...detectOverflowOptions } = floating_ui_utils_evaluate(options, state);
|
|
276
|
+
switch(strategy){
|
|
277
|
+
case 'referenceHidden':
|
|
278
|
+
{
|
|
279
|
+
const overflow = await platform.detectOverflow(state, {
|
|
280
|
+
...detectOverflowOptions,
|
|
281
|
+
elementContext: 'reference'
|
|
282
|
+
});
|
|
283
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
284
|
+
return {
|
|
285
|
+
data: {
|
|
286
|
+
referenceHiddenOffsets: offsets,
|
|
287
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
case 'escaped':
|
|
292
|
+
{
|
|
293
|
+
const overflow = await platform.detectOverflow(state, {
|
|
294
|
+
...detectOverflowOptions,
|
|
295
|
+
altBoundary: true
|
|
296
|
+
});
|
|
297
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
298
|
+
return {
|
|
299
|
+
data: {
|
|
300
|
+
escapedOffsets: offsets,
|
|
301
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
default:
|
|
306
|
+
return {};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const originSides = /*#__PURE__*/ new Set([
|
|
312
|
+
'left',
|
|
313
|
+
'top'
|
|
314
|
+
]);
|
|
315
|
+
async function convertValueToCoords(state, options) {
|
|
316
|
+
const { placement, platform, elements } = state;
|
|
317
|
+
const rtl = await (null == platform.isRTL ? void 0 : platform.isRTL(elements.floating));
|
|
318
|
+
const side = floating_ui_utils_getSide(placement);
|
|
319
|
+
const alignment = floating_ui_utils_getAlignment(placement);
|
|
320
|
+
const isVertical = 'y' === floating_ui_utils_getSideAxis(placement);
|
|
321
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
322
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
323
|
+
const rawValue = floating_ui_utils_evaluate(options, state);
|
|
324
|
+
let { mainAxis, crossAxis, alignmentAxis } = 'number' == typeof rawValue ? {
|
|
325
|
+
mainAxis: rawValue,
|
|
326
|
+
crossAxis: 0,
|
|
327
|
+
alignmentAxis: null
|
|
328
|
+
} : {
|
|
329
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
330
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
331
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
332
|
+
};
|
|
333
|
+
if (alignment && 'number' == typeof alignmentAxis) crossAxis = 'end' === alignment ? -1 * alignmentAxis : alignmentAxis;
|
|
334
|
+
return isVertical ? {
|
|
335
|
+
x: crossAxis * crossAxisMulti,
|
|
336
|
+
y: mainAxis * mainAxisMulti
|
|
337
|
+
} : {
|
|
338
|
+
x: mainAxis * mainAxisMulti,
|
|
339
|
+
y: crossAxis * crossAxisMulti
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
const floating_ui_core_offset = function(options) {
|
|
343
|
+
if (void 0 === options) options = 0;
|
|
344
|
+
return {
|
|
345
|
+
name: 'offset',
|
|
346
|
+
options,
|
|
347
|
+
async fn (state) {
|
|
348
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
349
|
+
const { x, y, placement, middlewareData } = state;
|
|
350
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
351
|
+
if (placement === (null == (_middlewareData$offse = middlewareData.offset) ? void 0 : _middlewareData$offse.placement) && null != (_middlewareData$arrow = middlewareData.arrow) && _middlewareData$arrow.alignmentOffset) return {};
|
|
352
|
+
return {
|
|
353
|
+
x: x + diffCoords.x,
|
|
354
|
+
y: y + diffCoords.y,
|
|
355
|
+
data: {
|
|
356
|
+
...diffCoords,
|
|
357
|
+
placement
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
const shift = function(options) {
|
|
364
|
+
if (void 0 === options) options = {};
|
|
365
|
+
return {
|
|
366
|
+
name: 'shift',
|
|
367
|
+
options,
|
|
368
|
+
async fn (state) {
|
|
369
|
+
const { x, y, placement, platform } = state;
|
|
370
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = {
|
|
371
|
+
fn: (_ref)=>{
|
|
372
|
+
let { x, y } = _ref;
|
|
373
|
+
return {
|
|
374
|
+
x,
|
|
375
|
+
y
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}, ...detectOverflowOptions } = floating_ui_utils_evaluate(options, state);
|
|
379
|
+
const coords = {
|
|
380
|
+
x,
|
|
381
|
+
y
|
|
382
|
+
};
|
|
383
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
384
|
+
const crossAxis = floating_ui_utils_getSideAxis(floating_ui_utils_getSide(placement));
|
|
385
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
386
|
+
let mainAxisCoord = coords[mainAxis];
|
|
387
|
+
let crossAxisCoord = coords[crossAxis];
|
|
388
|
+
if (checkMainAxis) {
|
|
389
|
+
const minSide = 'y' === mainAxis ? 'top' : 'left';
|
|
390
|
+
const maxSide = 'y' === mainAxis ? 'bottom' : 'right';
|
|
391
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
392
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
393
|
+
mainAxisCoord = floating_ui_utils_clamp(min, mainAxisCoord, max);
|
|
394
|
+
}
|
|
395
|
+
if (checkCrossAxis) {
|
|
396
|
+
const minSide = 'y' === crossAxis ? 'top' : 'left';
|
|
397
|
+
const maxSide = 'y' === crossAxis ? 'bottom' : 'right';
|
|
398
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
399
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
400
|
+
crossAxisCoord = floating_ui_utils_clamp(min, crossAxisCoord, max);
|
|
401
|
+
}
|
|
402
|
+
const limitedCoords = limiter.fn({
|
|
403
|
+
...state,
|
|
404
|
+
[mainAxis]: mainAxisCoord,
|
|
405
|
+
[crossAxis]: crossAxisCoord
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
...limitedCoords,
|
|
409
|
+
data: {
|
|
410
|
+
x: limitedCoords.x - x,
|
|
411
|
+
y: limitedCoords.y - y,
|
|
412
|
+
enabled: {
|
|
413
|
+
[mainAxis]: checkMainAxis,
|
|
414
|
+
[crossAxis]: checkCrossAxis
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
const limitShift = function(options) {
|
|
422
|
+
if (void 0 === options) options = {};
|
|
423
|
+
return {
|
|
424
|
+
options,
|
|
425
|
+
fn (state) {
|
|
426
|
+
const { x, y, placement, rects, middlewareData } = state;
|
|
427
|
+
const { offset = 0, mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true } = floating_ui_utils_evaluate(options, state);
|
|
428
|
+
const coords = {
|
|
429
|
+
x,
|
|
430
|
+
y
|
|
431
|
+
};
|
|
432
|
+
const crossAxis = floating_ui_utils_getSideAxis(placement);
|
|
433
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
434
|
+
let mainAxisCoord = coords[mainAxis];
|
|
435
|
+
let crossAxisCoord = coords[crossAxis];
|
|
436
|
+
const rawOffset = floating_ui_utils_evaluate(offset, state);
|
|
437
|
+
const computedOffset = 'number' == typeof rawOffset ? {
|
|
438
|
+
mainAxis: rawOffset,
|
|
439
|
+
crossAxis: 0
|
|
440
|
+
} : {
|
|
441
|
+
mainAxis: 0,
|
|
442
|
+
crossAxis: 0,
|
|
443
|
+
...rawOffset
|
|
444
|
+
};
|
|
445
|
+
if (checkMainAxis) {
|
|
446
|
+
const len = 'y' === mainAxis ? 'height' : 'width';
|
|
447
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
448
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
449
|
+
if (mainAxisCoord < limitMin) mainAxisCoord = limitMin;
|
|
450
|
+
else if (mainAxisCoord > limitMax) mainAxisCoord = limitMax;
|
|
451
|
+
}
|
|
452
|
+
if (checkCrossAxis) {
|
|
453
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
454
|
+
const len = 'y' === mainAxis ? 'width' : 'height';
|
|
455
|
+
const isOriginSide = originSides.has(floating_ui_utils_getSide(placement));
|
|
456
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? (null == (_middlewareData$offse = middlewareData.offset) ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
457
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (null == (_middlewareData$offse2 = middlewareData.offset) ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
458
|
+
if (crossAxisCoord < limitMin) crossAxisCoord = limitMin;
|
|
459
|
+
else if (crossAxisCoord > limitMax) crossAxisCoord = limitMax;
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
[mainAxis]: mainAxisCoord,
|
|
463
|
+
[crossAxis]: crossAxisCoord
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
const size = function(options) {
|
|
469
|
+
if (void 0 === options) options = {};
|
|
470
|
+
return {
|
|
471
|
+
name: 'size',
|
|
472
|
+
options,
|
|
473
|
+
async fn (state) {
|
|
474
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
475
|
+
const { placement, rects, platform, elements } = state;
|
|
476
|
+
const { apply = ()=>{}, ...detectOverflowOptions } = floating_ui_utils_evaluate(options, state);
|
|
477
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
478
|
+
const side = floating_ui_utils_getSide(placement);
|
|
479
|
+
const alignment = floating_ui_utils_getAlignment(placement);
|
|
480
|
+
const isYAxis = 'y' === floating_ui_utils_getSideAxis(placement);
|
|
481
|
+
const { width, height } = rects.floating;
|
|
482
|
+
let heightSide;
|
|
483
|
+
let widthSide;
|
|
484
|
+
if ('top' === side || 'bottom' === side) {
|
|
485
|
+
heightSide = side;
|
|
486
|
+
widthSide = alignment === (await (null == platform.isRTL ? void 0 : platform.isRTL(elements.floating)) ? 'start' : 'end') ? 'left' : 'right';
|
|
487
|
+
} else {
|
|
488
|
+
widthSide = side;
|
|
489
|
+
heightSide = 'end' === alignment ? 'top' : 'bottom';
|
|
490
|
+
}
|
|
491
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
492
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
493
|
+
const overflowAvailableHeight = floating_ui_utils_min(height - overflow[heightSide], maximumClippingHeight);
|
|
494
|
+
const overflowAvailableWidth = floating_ui_utils_min(width - overflow[widthSide], maximumClippingWidth);
|
|
495
|
+
const noShift = !state.middlewareData.shift;
|
|
496
|
+
let availableHeight = overflowAvailableHeight;
|
|
497
|
+
let availableWidth = overflowAvailableWidth;
|
|
498
|
+
if (null != (_state$middlewareData = state.middlewareData.shift) && _state$middlewareData.enabled.x) availableWidth = maximumClippingWidth;
|
|
499
|
+
if (null != (_state$middlewareData2 = state.middlewareData.shift) && _state$middlewareData2.enabled.y) availableHeight = maximumClippingHeight;
|
|
500
|
+
if (noShift && !alignment) {
|
|
501
|
+
const xMin = floating_ui_utils_max(overflow.left, 0);
|
|
502
|
+
const xMax = floating_ui_utils_max(overflow.right, 0);
|
|
503
|
+
const yMin = floating_ui_utils_max(overflow.top, 0);
|
|
504
|
+
const yMax = floating_ui_utils_max(overflow.bottom, 0);
|
|
505
|
+
if (isYAxis) availableWidth = width - 2 * (0 !== xMin || 0 !== xMax ? xMin + xMax : floating_ui_utils_max(overflow.left, overflow.right));
|
|
506
|
+
else availableHeight = height - 2 * (0 !== yMin || 0 !== yMax ? yMin + yMax : floating_ui_utils_max(overflow.top, overflow.bottom));
|
|
507
|
+
}
|
|
508
|
+
await apply({
|
|
509
|
+
...state,
|
|
510
|
+
availableWidth,
|
|
511
|
+
availableHeight
|
|
512
|
+
});
|
|
513
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
514
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) return {
|
|
515
|
+
reset: {
|
|
516
|
+
rects: true
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
return {};
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
function getCssDimensions(element) {
|
|
524
|
+
const css = floating_ui_utils_dom_getComputedStyle(element);
|
|
525
|
+
let width = parseFloat(css.width) || 0;
|
|
526
|
+
let height = parseFloat(css.height) || 0;
|
|
527
|
+
const hasOffset = isHTMLElement(element);
|
|
528
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
529
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
530
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
531
|
+
if (shouldFallback) {
|
|
532
|
+
width = offsetWidth;
|
|
533
|
+
height = offsetHeight;
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
width,
|
|
537
|
+
height,
|
|
538
|
+
$: shouldFallback
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function unwrapElement(element) {
|
|
542
|
+
return isElement(element) ? element : element.contextElement;
|
|
543
|
+
}
|
|
544
|
+
function getScale(element) {
|
|
545
|
+
const domElement = unwrapElement(element);
|
|
546
|
+
if (!isHTMLElement(domElement)) return createCoords(1);
|
|
547
|
+
const rect = domElement.getBoundingClientRect();
|
|
548
|
+
const { width, height, $ } = getCssDimensions(domElement);
|
|
549
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
550
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
551
|
+
if (!x || !Number.isFinite(x)) x = 1;
|
|
552
|
+
if (!y || !Number.isFinite(y)) y = 1;
|
|
553
|
+
return {
|
|
554
|
+
x,
|
|
555
|
+
y
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
const noOffsets = /*#__PURE__*/ createCoords(0);
|
|
559
|
+
function getVisualOffsets(element) {
|
|
560
|
+
const win = getWindow(element);
|
|
561
|
+
if (!isWebKit() || !win.visualViewport) return noOffsets;
|
|
562
|
+
return {
|
|
563
|
+
x: win.visualViewport.offsetLeft,
|
|
564
|
+
y: win.visualViewport.offsetTop
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
568
|
+
if (void 0 === isFixed) isFixed = false;
|
|
569
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) return false;
|
|
570
|
+
return isFixed;
|
|
571
|
+
}
|
|
572
|
+
function floating_ui_dom_getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
573
|
+
if (void 0 === includeScale) includeScale = false;
|
|
574
|
+
if (void 0 === isFixedStrategy) isFixedStrategy = false;
|
|
575
|
+
const clientRect = element.getBoundingClientRect();
|
|
576
|
+
const domElement = unwrapElement(element);
|
|
577
|
+
let scale = createCoords(1);
|
|
578
|
+
if (includeScale) if (offsetParent) {
|
|
579
|
+
if (isElement(offsetParent)) scale = getScale(offsetParent);
|
|
580
|
+
} else scale = getScale(element);
|
|
581
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
582
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
583
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
584
|
+
let width = clientRect.width / scale.x;
|
|
585
|
+
let height = clientRect.height / scale.y;
|
|
586
|
+
if (domElement) {
|
|
587
|
+
const win = getWindow(domElement);
|
|
588
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
589
|
+
let currentWin = win;
|
|
590
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
591
|
+
while(currentIFrame && offsetParent && offsetWin !== currentWin){
|
|
592
|
+
const iframeScale = getScale(currentIFrame);
|
|
593
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
594
|
+
const css = floating_ui_utils_dom_getComputedStyle(currentIFrame);
|
|
595
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
596
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
597
|
+
x *= iframeScale.x;
|
|
598
|
+
y *= iframeScale.y;
|
|
599
|
+
width *= iframeScale.x;
|
|
600
|
+
height *= iframeScale.y;
|
|
601
|
+
x += left;
|
|
602
|
+
y += top;
|
|
603
|
+
currentWin = getWindow(currentIFrame);
|
|
604
|
+
currentIFrame = getFrameElement(currentWin);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return floating_ui_utils_rectToClientRect({
|
|
608
|
+
width,
|
|
609
|
+
height,
|
|
610
|
+
x,
|
|
611
|
+
y
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
function getWindowScrollBarX(element, rect) {
|
|
615
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
616
|
+
if (!rect) return floating_ui_dom_getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
617
|
+
return rect.left + leftScroll;
|
|
618
|
+
}
|
|
619
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
620
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
621
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
622
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
623
|
+
return {
|
|
624
|
+
x,
|
|
625
|
+
y
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
629
|
+
let { elements, rect, offsetParent, strategy } = _ref;
|
|
630
|
+
const isFixed = 'fixed' === strategy;
|
|
631
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
632
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
633
|
+
if (offsetParent === documentElement || topLayer && isFixed) return rect;
|
|
634
|
+
let scroll = {
|
|
635
|
+
scrollLeft: 0,
|
|
636
|
+
scrollTop: 0
|
|
637
|
+
};
|
|
638
|
+
let scale = createCoords(1);
|
|
639
|
+
const offsets = createCoords(0);
|
|
640
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
641
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
642
|
+
if ('body' !== getNodeName(offsetParent) || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
643
|
+
if (isOffsetParentAnElement) {
|
|
644
|
+
const offsetRect = floating_ui_dom_getBoundingClientRect(offsetParent);
|
|
645
|
+
scale = getScale(offsetParent);
|
|
646
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
647
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
const htmlOffset = !documentElement || isOffsetParentAnElement || isFixed ? createCoords(0) : getHTMLOffset(documentElement, scroll);
|
|
651
|
+
return {
|
|
652
|
+
width: rect.width * scale.x,
|
|
653
|
+
height: rect.height * scale.y,
|
|
654
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
655
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function getClientRects(element) {
|
|
659
|
+
return Array.from(element.getClientRects());
|
|
660
|
+
}
|
|
661
|
+
function getDocumentRect(element) {
|
|
662
|
+
const html = getDocumentElement(element);
|
|
663
|
+
const scroll = getNodeScroll(element);
|
|
664
|
+
const body = element.ownerDocument.body;
|
|
665
|
+
const width = floating_ui_utils_max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
666
|
+
const height = floating_ui_utils_max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
667
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
668
|
+
const y = -scroll.scrollTop;
|
|
669
|
+
if ('rtl' === floating_ui_utils_dom_getComputedStyle(body).direction) x += floating_ui_utils_max(html.clientWidth, body.clientWidth) - width;
|
|
670
|
+
return {
|
|
671
|
+
width,
|
|
672
|
+
height,
|
|
673
|
+
x,
|
|
674
|
+
y
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const SCROLLBAR_MAX = 25;
|
|
678
|
+
function getViewportRect(element, strategy) {
|
|
679
|
+
const win = getWindow(element);
|
|
680
|
+
const html = getDocumentElement(element);
|
|
681
|
+
const visualViewport = win.visualViewport;
|
|
682
|
+
let width = html.clientWidth;
|
|
683
|
+
let height = html.clientHeight;
|
|
684
|
+
let x = 0;
|
|
685
|
+
let y = 0;
|
|
686
|
+
if (visualViewport) {
|
|
687
|
+
width = visualViewport.width;
|
|
688
|
+
height = visualViewport.height;
|
|
689
|
+
const visualViewportBased = isWebKit();
|
|
690
|
+
if (!visualViewportBased || visualViewportBased && 'fixed' === strategy) {
|
|
691
|
+
x = visualViewport.offsetLeft;
|
|
692
|
+
y = visualViewport.offsetTop;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
696
|
+
if (windowScrollbarX <= 0) {
|
|
697
|
+
const doc = html.ownerDocument;
|
|
698
|
+
const body = doc.body;
|
|
699
|
+
const bodyStyles = getComputedStyle(body);
|
|
700
|
+
const bodyMarginInline = 'CSS1Compat' === doc.compatMode ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
701
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
702
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) width -= clippingStableScrollbarWidth;
|
|
703
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) width += windowScrollbarX;
|
|
704
|
+
return {
|
|
705
|
+
width,
|
|
706
|
+
height,
|
|
707
|
+
x,
|
|
708
|
+
y
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
712
|
+
const clientRect = floating_ui_dom_getBoundingClientRect(element, true, 'fixed' === strategy);
|
|
713
|
+
const top = clientRect.top + element.clientTop;
|
|
714
|
+
const left = clientRect.left + element.clientLeft;
|
|
715
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
716
|
+
const width = element.clientWidth * scale.x;
|
|
717
|
+
const height = element.clientHeight * scale.y;
|
|
718
|
+
const x = left * scale.x;
|
|
719
|
+
const y = top * scale.y;
|
|
720
|
+
return {
|
|
721
|
+
width,
|
|
722
|
+
height,
|
|
723
|
+
x,
|
|
724
|
+
y
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
728
|
+
let rect;
|
|
729
|
+
if ('viewport' === clippingAncestor) rect = getViewportRect(element, strategy);
|
|
730
|
+
else if ('document' === clippingAncestor) rect = getDocumentRect(getDocumentElement(element));
|
|
731
|
+
else if (isElement(clippingAncestor)) rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
732
|
+
else {
|
|
733
|
+
const visualOffsets = getVisualOffsets(element);
|
|
734
|
+
rect = {
|
|
735
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
736
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
737
|
+
width: clippingAncestor.width,
|
|
738
|
+
height: clippingAncestor.height
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
return floating_ui_utils_rectToClientRect(rect);
|
|
742
|
+
}
|
|
743
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
744
|
+
const parentNode = getParentNode(element);
|
|
745
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) return false;
|
|
746
|
+
return 'fixed' === floating_ui_utils_dom_getComputedStyle(parentNode).position || hasFixedPositionAncestor(parentNode, stopNode);
|
|
747
|
+
}
|
|
748
|
+
function getClippingElementAncestors(element, cache) {
|
|
749
|
+
const cachedResult = cache.get(element);
|
|
750
|
+
if (cachedResult) return cachedResult;
|
|
751
|
+
let result = getOverflowAncestors(element, [], false).filter((el)=>isElement(el) && 'body' !== getNodeName(el));
|
|
752
|
+
let currentContainingBlockComputedStyle = null;
|
|
753
|
+
const elementIsFixed = 'fixed' === floating_ui_utils_dom_getComputedStyle(element).position;
|
|
754
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
755
|
+
while(isElement(currentNode) && !isLastTraversableNode(currentNode)){
|
|
756
|
+
const computedStyle = floating_ui_utils_dom_getComputedStyle(currentNode);
|
|
757
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
758
|
+
if (!currentNodeIsContaining && 'fixed' === computedStyle.position) currentContainingBlockComputedStyle = null;
|
|
759
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && 'static' === computedStyle.position && !!currentContainingBlockComputedStyle && ('absolute' === currentContainingBlockComputedStyle.position || 'fixed' === currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
760
|
+
if (shouldDropCurrentNode) result = result.filter((ancestor)=>ancestor !== currentNode);
|
|
761
|
+
else currentContainingBlockComputedStyle = computedStyle;
|
|
762
|
+
currentNode = getParentNode(currentNode);
|
|
763
|
+
}
|
|
764
|
+
cache.set(element, result);
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
function getClippingRect(_ref) {
|
|
768
|
+
let { element, boundary, rootBoundary, strategy } = _ref;
|
|
769
|
+
const elementClippingAncestors = 'clippingAncestors' === boundary ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
770
|
+
const clippingAncestors = [
|
|
771
|
+
...elementClippingAncestors,
|
|
772
|
+
rootBoundary
|
|
773
|
+
];
|
|
774
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
775
|
+
let top = firstRect.top;
|
|
776
|
+
let right = firstRect.right;
|
|
777
|
+
let bottom = firstRect.bottom;
|
|
778
|
+
let left = firstRect.left;
|
|
779
|
+
for(let i = 1; i < clippingAncestors.length; i++){
|
|
780
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
781
|
+
top = floating_ui_utils_max(rect.top, top);
|
|
782
|
+
right = floating_ui_utils_min(rect.right, right);
|
|
783
|
+
bottom = floating_ui_utils_min(rect.bottom, bottom);
|
|
784
|
+
left = floating_ui_utils_max(rect.left, left);
|
|
785
|
+
}
|
|
786
|
+
return {
|
|
787
|
+
width: right - left,
|
|
788
|
+
height: bottom - top,
|
|
789
|
+
x: left,
|
|
790
|
+
y: top
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function getDimensions(element) {
|
|
794
|
+
const { width, height } = getCssDimensions(element);
|
|
795
|
+
return {
|
|
796
|
+
width,
|
|
797
|
+
height
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
801
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
802
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
803
|
+
const isFixed = 'fixed' === strategy;
|
|
804
|
+
const rect = floating_ui_dom_getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
805
|
+
let scroll = {
|
|
806
|
+
scrollLeft: 0,
|
|
807
|
+
scrollTop: 0
|
|
808
|
+
};
|
|
809
|
+
const offsets = createCoords(0);
|
|
810
|
+
function setLeftRTLScrollbarOffset() {
|
|
811
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
812
|
+
}
|
|
813
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
814
|
+
if ('body' !== getNodeName(offsetParent) || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
815
|
+
if (isOffsetParentAnElement) {
|
|
816
|
+
const offsetRect = floating_ui_dom_getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
817
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
818
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
819
|
+
} else if (documentElement) setLeftRTLScrollbarOffset();
|
|
820
|
+
}
|
|
821
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) setLeftRTLScrollbarOffset();
|
|
822
|
+
const htmlOffset = !documentElement || isOffsetParentAnElement || isFixed ? createCoords(0) : getHTMLOffset(documentElement, scroll);
|
|
823
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
824
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
825
|
+
return {
|
|
826
|
+
x,
|
|
827
|
+
y,
|
|
828
|
+
width: rect.width,
|
|
829
|
+
height: rect.height
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function isStaticPositioned(element) {
|
|
833
|
+
return 'static' === floating_ui_utils_dom_getComputedStyle(element).position;
|
|
834
|
+
}
|
|
835
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
836
|
+
if (!isHTMLElement(element) || 'fixed' === floating_ui_utils_dom_getComputedStyle(element).position) return null;
|
|
837
|
+
if (polyfill) return polyfill(element);
|
|
838
|
+
let rawOffsetParent = element.offsetParent;
|
|
839
|
+
if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
840
|
+
return rawOffsetParent;
|
|
841
|
+
}
|
|
842
|
+
function getOffsetParent(element, polyfill) {
|
|
843
|
+
const win = getWindow(element);
|
|
844
|
+
if (isTopLayer(element)) return win;
|
|
845
|
+
if (!isHTMLElement(element)) {
|
|
846
|
+
let svgOffsetParent = getParentNode(element);
|
|
847
|
+
while(svgOffsetParent && !isLastTraversableNode(svgOffsetParent)){
|
|
848
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
|
|
849
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
850
|
+
}
|
|
851
|
+
return win;
|
|
852
|
+
}
|
|
853
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
854
|
+
while(offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent))offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
855
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
|
|
856
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
857
|
+
}
|
|
858
|
+
const getElementRects = async function(data) {
|
|
859
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
860
|
+
const getDimensionsFn = this.getDimensions;
|
|
861
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
862
|
+
return {
|
|
863
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
864
|
+
floating: {
|
|
865
|
+
x: 0,
|
|
866
|
+
y: 0,
|
|
867
|
+
width: floatingDimensions.width,
|
|
868
|
+
height: floatingDimensions.height
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
function isRTL(element) {
|
|
873
|
+
return 'rtl' === floating_ui_utils_dom_getComputedStyle(element).direction;
|
|
874
|
+
}
|
|
875
|
+
const floating_ui_dom_platform = {
|
|
876
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
877
|
+
getDocumentElement: getDocumentElement,
|
|
878
|
+
getClippingRect: getClippingRect,
|
|
879
|
+
getOffsetParent: getOffsetParent,
|
|
880
|
+
getElementRects: getElementRects,
|
|
881
|
+
getClientRects: getClientRects,
|
|
882
|
+
getDimensions: getDimensions,
|
|
883
|
+
getScale: getScale,
|
|
884
|
+
isElement: isElement,
|
|
885
|
+
isRTL: isRTL
|
|
886
|
+
};
|
|
887
|
+
function rectsAreEqual(a, b) {
|
|
888
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
889
|
+
}
|
|
890
|
+
function observeMove(element, onMove) {
|
|
891
|
+
let io = null;
|
|
892
|
+
let timeoutId;
|
|
893
|
+
const root = getDocumentElement(element);
|
|
894
|
+
function cleanup() {
|
|
895
|
+
var _io;
|
|
896
|
+
clearTimeout(timeoutId);
|
|
897
|
+
null == (_io = io) || _io.disconnect();
|
|
898
|
+
io = null;
|
|
899
|
+
}
|
|
900
|
+
function refresh(skip, threshold) {
|
|
901
|
+
if (void 0 === skip) skip = false;
|
|
902
|
+
if (void 0 === threshold) threshold = 1;
|
|
903
|
+
cleanup();
|
|
904
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
905
|
+
const { left, top, width, height } = elementRectForRootMargin;
|
|
906
|
+
if (!skip) onMove();
|
|
907
|
+
if (!width || !height) return;
|
|
908
|
+
const insetTop = floor(top);
|
|
909
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
910
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
911
|
+
const insetLeft = floor(left);
|
|
912
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
913
|
+
const options = {
|
|
914
|
+
rootMargin,
|
|
915
|
+
threshold: floating_ui_utils_max(0, floating_ui_utils_min(1, threshold)) || 1
|
|
916
|
+
};
|
|
917
|
+
let isFirstUpdate = true;
|
|
918
|
+
function handleObserve(entries) {
|
|
919
|
+
const ratio = entries[0].intersectionRatio;
|
|
920
|
+
if (ratio !== threshold) {
|
|
921
|
+
if (!isFirstUpdate) return refresh();
|
|
922
|
+
if (ratio) refresh(false, ratio);
|
|
923
|
+
else timeoutId = setTimeout(()=>{
|
|
924
|
+
refresh(false, 1e-7);
|
|
925
|
+
}, 1000);
|
|
926
|
+
}
|
|
927
|
+
if (1 === ratio && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) refresh();
|
|
928
|
+
isFirstUpdate = false;
|
|
929
|
+
}
|
|
930
|
+
try {
|
|
931
|
+
io = new IntersectionObserver(handleObserve, {
|
|
932
|
+
...options,
|
|
933
|
+
root: root.ownerDocument
|
|
934
|
+
});
|
|
935
|
+
} catch (_e) {
|
|
936
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
937
|
+
}
|
|
938
|
+
io.observe(element);
|
|
939
|
+
}
|
|
940
|
+
refresh(true);
|
|
941
|
+
return cleanup;
|
|
942
|
+
}
|
|
943
|
+
function autoUpdate(reference, floating, update, options) {
|
|
944
|
+
if (void 0 === options) options = {};
|
|
945
|
+
const { ancestorScroll = true, ancestorResize = true, elementResize = 'function' == typeof ResizeObserver, layoutShift = 'function' == typeof IntersectionObserver, animationFrame = false } = options;
|
|
946
|
+
const referenceEl = unwrapElement(reference);
|
|
947
|
+
const ancestors = ancestorScroll || ancestorResize ? [
|
|
948
|
+
...referenceEl ? getOverflowAncestors(referenceEl) : [],
|
|
949
|
+
...floating ? getOverflowAncestors(floating) : []
|
|
950
|
+
] : [];
|
|
951
|
+
ancestors.forEach((ancestor)=>{
|
|
952
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
953
|
+
passive: true
|
|
954
|
+
});
|
|
955
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
956
|
+
});
|
|
957
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
958
|
+
let reobserveFrame = -1;
|
|
959
|
+
let resizeObserver = null;
|
|
960
|
+
if (elementResize) {
|
|
961
|
+
resizeObserver = new ResizeObserver((_ref)=>{
|
|
962
|
+
let [firstEntry] = _ref;
|
|
963
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
964
|
+
resizeObserver.unobserve(floating);
|
|
965
|
+
cancelAnimationFrame(reobserveFrame);
|
|
966
|
+
reobserveFrame = requestAnimationFrame(()=>{
|
|
967
|
+
var _resizeObserver;
|
|
968
|
+
null == (_resizeObserver = resizeObserver) || _resizeObserver.observe(floating);
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
update();
|
|
972
|
+
});
|
|
973
|
+
if (referenceEl && !animationFrame) resizeObserver.observe(referenceEl);
|
|
974
|
+
if (floating) resizeObserver.observe(floating);
|
|
975
|
+
}
|
|
976
|
+
let frameId;
|
|
977
|
+
let prevRefRect = animationFrame ? floating_ui_dom_getBoundingClientRect(reference) : null;
|
|
978
|
+
if (animationFrame) frameLoop();
|
|
979
|
+
function frameLoop() {
|
|
980
|
+
const nextRefRect = floating_ui_dom_getBoundingClientRect(reference);
|
|
981
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) update();
|
|
982
|
+
prevRefRect = nextRefRect;
|
|
983
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
984
|
+
}
|
|
985
|
+
update();
|
|
986
|
+
return ()=>{
|
|
987
|
+
var _resizeObserver2;
|
|
988
|
+
ancestors.forEach((ancestor)=>{
|
|
989
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
990
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
991
|
+
});
|
|
992
|
+
null == cleanupIo || cleanupIo();
|
|
993
|
+
null == (_resizeObserver2 = resizeObserver) || _resizeObserver2.disconnect();
|
|
994
|
+
resizeObserver = null;
|
|
995
|
+
if (animationFrame) cancelAnimationFrame(frameId);
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
const floating_ui_dom_offset = floating_ui_core_offset;
|
|
999
|
+
const floating_ui_dom_shift = shift;
|
|
1000
|
+
const floating_ui_dom_flip = flip;
|
|
1001
|
+
const floating_ui_dom_size = size;
|
|
1002
|
+
const floating_ui_dom_hide = hide;
|
|
1003
|
+
const floating_ui_dom_limitShift = limitShift;
|
|
1004
|
+
const floating_ui_dom_computePosition = (reference, floating, options)=>{
|
|
1005
|
+
const cache = new Map();
|
|
1006
|
+
const mergedOptions = {
|
|
1007
|
+
platform: floating_ui_dom_platform,
|
|
1008
|
+
...options
|
|
1009
|
+
};
|
|
1010
|
+
const platformWithCache = {
|
|
1011
|
+
...mergedOptions.platform,
|
|
1012
|
+
_c: cache
|
|
1013
|
+
};
|
|
1014
|
+
return computePosition(reference, floating, {
|
|
1015
|
+
...mergedOptions,
|
|
1016
|
+
platform: platformWithCache
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
var isClient = "u" > typeof document;
|
|
1020
|
+
var floating_ui_react_dom_noop = function() {};
|
|
1021
|
+
var index = isClient ? __rspack_external_react.useLayoutEffect : floating_ui_react_dom_noop;
|
|
1022
|
+
function deepEqual(a, b) {
|
|
1023
|
+
if (a === b) return true;
|
|
1024
|
+
if (typeof a !== typeof b) return false;
|
|
1025
|
+
if ('function' == typeof a && a.toString() === b.toString()) return true;
|
|
1026
|
+
let length;
|
|
1027
|
+
let i;
|
|
1028
|
+
let keys;
|
|
1029
|
+
if (a && b && 'object' == typeof a) {
|
|
1030
|
+
if (Array.isArray(a)) {
|
|
1031
|
+
length = a.length;
|
|
1032
|
+
if (length !== b.length) return false;
|
|
1033
|
+
for(i = length; 0 !== i--;)if (!deepEqual(a[i], b[i])) return false;
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
keys = Object.keys(a);
|
|
1037
|
+
length = keys.length;
|
|
1038
|
+
if (length !== Object.keys(b).length) return false;
|
|
1039
|
+
for(i = length; 0 !== i--;)if (!({}).hasOwnProperty.call(b, keys[i])) return false;
|
|
1040
|
+
for(i = length; 0 !== i--;){
|
|
1041
|
+
const key = keys[i];
|
|
1042
|
+
if ('_owner' !== key || !a.$$typeof) {
|
|
1043
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return true;
|
|
1047
|
+
}
|
|
1048
|
+
return a !== a && b !== b;
|
|
1049
|
+
}
|
|
1050
|
+
function getDPR(element) {
|
|
1051
|
+
if ("u" < typeof window) return 1;
|
|
1052
|
+
const win = element.ownerDocument.defaultView || window;
|
|
1053
|
+
return win.devicePixelRatio || 1;
|
|
1054
|
+
}
|
|
1055
|
+
function roundByDPR(element, value) {
|
|
1056
|
+
const dpr = getDPR(element);
|
|
1057
|
+
return Math.round(value * dpr) / dpr;
|
|
1058
|
+
}
|
|
1059
|
+
function useLatestRef(value) {
|
|
1060
|
+
const ref = __rspack_external_react.useRef(value);
|
|
1061
|
+
index(()=>{
|
|
1062
|
+
ref.current = value;
|
|
1063
|
+
});
|
|
1064
|
+
return ref;
|
|
1065
|
+
}
|
|
1066
|
+
function useFloating(options) {
|
|
1067
|
+
if (void 0 === options) options = {};
|
|
1068
|
+
const { placement = 'bottom', strategy = 'absolute', middleware = [], platform, elements: { reference: externalReference, floating: externalFloating } = {}, transform = true, whileElementsMounted, open } = options;
|
|
1069
|
+
const [data, setData] = __rspack_external_react.useState({
|
|
1070
|
+
x: 0,
|
|
1071
|
+
y: 0,
|
|
1072
|
+
strategy,
|
|
1073
|
+
placement,
|
|
1074
|
+
middlewareData: {},
|
|
1075
|
+
isPositioned: false
|
|
1076
|
+
});
|
|
1077
|
+
const [latestMiddleware, setLatestMiddleware] = __rspack_external_react.useState(middleware);
|
|
1078
|
+
if (!deepEqual(latestMiddleware, middleware)) setLatestMiddleware(middleware);
|
|
1079
|
+
const [_reference, _setReference] = __rspack_external_react.useState(null);
|
|
1080
|
+
const [_floating, _setFloating] = __rspack_external_react.useState(null);
|
|
1081
|
+
const setReference = __rspack_external_react.useCallback((node)=>{
|
|
1082
|
+
if (node !== referenceRef.current) {
|
|
1083
|
+
referenceRef.current = node;
|
|
1084
|
+
_setReference(node);
|
|
1085
|
+
}
|
|
1086
|
+
}, []);
|
|
1087
|
+
const setFloating = __rspack_external_react.useCallback((node)=>{
|
|
1088
|
+
if (node !== floatingRef.current) {
|
|
1089
|
+
floatingRef.current = node;
|
|
1090
|
+
_setFloating(node);
|
|
1091
|
+
}
|
|
1092
|
+
}, []);
|
|
1093
|
+
const referenceEl = externalReference || _reference;
|
|
1094
|
+
const floatingEl = externalFloating || _floating;
|
|
1095
|
+
const referenceRef = __rspack_external_react.useRef(null);
|
|
1096
|
+
const floatingRef = __rspack_external_react.useRef(null);
|
|
1097
|
+
const dataRef = __rspack_external_react.useRef(data);
|
|
1098
|
+
const hasWhileElementsMounted = null != whileElementsMounted;
|
|
1099
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
1100
|
+
const platformRef = useLatestRef(platform);
|
|
1101
|
+
const openRef = useLatestRef(open);
|
|
1102
|
+
const update = __rspack_external_react.useCallback(()=>{
|
|
1103
|
+
if (!referenceRef.current || !floatingRef.current) return;
|
|
1104
|
+
const config = {
|
|
1105
|
+
placement,
|
|
1106
|
+
strategy,
|
|
1107
|
+
middleware: latestMiddleware
|
|
1108
|
+
};
|
|
1109
|
+
if (platformRef.current) config.platform = platformRef.current;
|
|
1110
|
+
floating_ui_dom_computePosition(referenceRef.current, floatingRef.current, config).then((data)=>{
|
|
1111
|
+
const fullData = {
|
|
1112
|
+
...data,
|
|
1113
|
+
isPositioned: false !== openRef.current
|
|
1114
|
+
};
|
|
1115
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
1116
|
+
dataRef.current = fullData;
|
|
1117
|
+
__rspack_external_react_dom_7136dc57.flushSync(()=>{
|
|
1118
|
+
setData(fullData);
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
}, [
|
|
1123
|
+
latestMiddleware,
|
|
1124
|
+
placement,
|
|
1125
|
+
strategy,
|
|
1126
|
+
platformRef,
|
|
1127
|
+
openRef
|
|
1128
|
+
]);
|
|
1129
|
+
index(()=>{
|
|
1130
|
+
if (false === open && dataRef.current.isPositioned) {
|
|
1131
|
+
dataRef.current.isPositioned = false;
|
|
1132
|
+
setData((data)=>({
|
|
1133
|
+
...data,
|
|
1134
|
+
isPositioned: false
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
}, [
|
|
1138
|
+
open
|
|
1139
|
+
]);
|
|
1140
|
+
const isMountedRef = __rspack_external_react.useRef(false);
|
|
1141
|
+
index(()=>{
|
|
1142
|
+
isMountedRef.current = true;
|
|
1143
|
+
return ()=>{
|
|
1144
|
+
isMountedRef.current = false;
|
|
1145
|
+
};
|
|
1146
|
+
}, []);
|
|
1147
|
+
index(()=>{
|
|
1148
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
1149
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
1150
|
+
if (referenceEl && floatingEl) {
|
|
1151
|
+
if (whileElementsMountedRef.current) return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
1152
|
+
update();
|
|
1153
|
+
}
|
|
1154
|
+
}, [
|
|
1155
|
+
referenceEl,
|
|
1156
|
+
floatingEl,
|
|
1157
|
+
update,
|
|
1158
|
+
whileElementsMountedRef,
|
|
1159
|
+
hasWhileElementsMounted
|
|
1160
|
+
]);
|
|
1161
|
+
const refs = __rspack_external_react.useMemo(()=>({
|
|
1162
|
+
reference: referenceRef,
|
|
1163
|
+
floating: floatingRef,
|
|
1164
|
+
setReference,
|
|
1165
|
+
setFloating
|
|
1166
|
+
}), [
|
|
1167
|
+
setReference,
|
|
1168
|
+
setFloating
|
|
1169
|
+
]);
|
|
1170
|
+
const elements = __rspack_external_react.useMemo(()=>({
|
|
1171
|
+
reference: referenceEl,
|
|
1172
|
+
floating: floatingEl
|
|
1173
|
+
}), [
|
|
1174
|
+
referenceEl,
|
|
1175
|
+
floatingEl
|
|
1176
|
+
]);
|
|
1177
|
+
const floatingStyles = __rspack_external_react.useMemo(()=>{
|
|
1178
|
+
const initialStyles = {
|
|
1179
|
+
position: strategy,
|
|
1180
|
+
left: 0,
|
|
1181
|
+
top: 0
|
|
1182
|
+
};
|
|
1183
|
+
if (!elements.floating) return initialStyles;
|
|
1184
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
1185
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
1186
|
+
if (transform) return {
|
|
1187
|
+
...initialStyles,
|
|
1188
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
1189
|
+
...getDPR(elements.floating) >= 1.5 && {
|
|
1190
|
+
willChange: 'transform'
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
return {
|
|
1194
|
+
position: strategy,
|
|
1195
|
+
left: x,
|
|
1196
|
+
top: y
|
|
1197
|
+
};
|
|
1198
|
+
}, [
|
|
1199
|
+
strategy,
|
|
1200
|
+
transform,
|
|
1201
|
+
elements.floating,
|
|
1202
|
+
data.x,
|
|
1203
|
+
data.y
|
|
1204
|
+
]);
|
|
1205
|
+
return __rspack_external_react.useMemo(()=>({
|
|
1206
|
+
...data,
|
|
1207
|
+
update,
|
|
1208
|
+
refs,
|
|
1209
|
+
elements,
|
|
1210
|
+
floatingStyles
|
|
1211
|
+
}), [
|
|
1212
|
+
data,
|
|
1213
|
+
update,
|
|
1214
|
+
refs,
|
|
1215
|
+
elements,
|
|
1216
|
+
floatingStyles
|
|
1217
|
+
]);
|
|
1218
|
+
}
|
|
1219
|
+
const floating_ui_react_dom_offset = (options, deps)=>{
|
|
1220
|
+
const result = floating_ui_dom_offset(options);
|
|
1221
|
+
return {
|
|
1222
|
+
name: result.name,
|
|
1223
|
+
fn: result.fn,
|
|
1224
|
+
options: [
|
|
1225
|
+
options,
|
|
1226
|
+
deps
|
|
1227
|
+
]
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
const floating_ui_react_dom_shift = (options, deps)=>{
|
|
1231
|
+
const result = floating_ui_dom_shift(options);
|
|
1232
|
+
return {
|
|
1233
|
+
name: result.name,
|
|
1234
|
+
fn: result.fn,
|
|
1235
|
+
options: [
|
|
1236
|
+
options,
|
|
1237
|
+
deps
|
|
1238
|
+
]
|
|
1239
|
+
};
|
|
1240
|
+
};
|
|
1241
|
+
const floating_ui_react_dom_limitShift = (options, deps)=>{
|
|
1242
|
+
const result = floating_ui_dom_limitShift(options);
|
|
1243
|
+
return {
|
|
1244
|
+
fn: result.fn,
|
|
1245
|
+
options: [
|
|
1246
|
+
options,
|
|
1247
|
+
deps
|
|
1248
|
+
]
|
|
1249
|
+
};
|
|
1250
|
+
};
|
|
1251
|
+
const floating_ui_react_dom_flip = (options, deps)=>{
|
|
1252
|
+
const result = floating_ui_dom_flip(options);
|
|
1253
|
+
return {
|
|
1254
|
+
name: result.name,
|
|
1255
|
+
fn: result.fn,
|
|
1256
|
+
options: [
|
|
1257
|
+
options,
|
|
1258
|
+
deps
|
|
1259
|
+
]
|
|
1260
|
+
};
|
|
1261
|
+
};
|
|
1262
|
+
const floating_ui_react_dom_size = (options, deps)=>{
|
|
1263
|
+
const result = floating_ui_dom_size(options);
|
|
1264
|
+
return {
|
|
1265
|
+
name: result.name,
|
|
1266
|
+
fn: result.fn,
|
|
1267
|
+
options: [
|
|
1268
|
+
options,
|
|
1269
|
+
deps
|
|
1270
|
+
]
|
|
1271
|
+
};
|
|
1272
|
+
};
|
|
1273
|
+
const floating_ui_react_dom_hide = (options, deps)=>{
|
|
1274
|
+
const result = floating_ui_dom_hide(options);
|
|
1275
|
+
return {
|
|
1276
|
+
name: result.name,
|
|
1277
|
+
fn: result.fn,
|
|
1278
|
+
options: [
|
|
1279
|
+
options,
|
|
1280
|
+
deps
|
|
1281
|
+
]
|
|
1282
|
+
};
|
|
1283
|
+
};
|
|
1284
|
+
function useFloatingRootContext(options) {
|
|
1285
|
+
const { open = false, onOpenChange, elements = {} } = options;
|
|
1286
|
+
const floatingId = useId();
|
|
1287
|
+
const nested = null != useFloatingParentNodeId();
|
|
1288
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
1289
|
+
const optionDomReference = elements.reference;
|
|
1290
|
+
if (optionDomReference && !isElement(optionDomReference)) console.error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `context.setPositionReference()`', 'instead.');
|
|
1291
|
+
}
|
|
1292
|
+
const store = useRefWithInit(()=>new FloatingRootStore({
|
|
1293
|
+
open,
|
|
1294
|
+
transitionStatus: void 0,
|
|
1295
|
+
onOpenChange,
|
|
1296
|
+
referenceElement: elements.reference ?? null,
|
|
1297
|
+
floatingElement: elements.floating ?? null,
|
|
1298
|
+
triggerElements: new PopupTriggerMap(),
|
|
1299
|
+
floatingId,
|
|
1300
|
+
syncOnly: false,
|
|
1301
|
+
nested
|
|
1302
|
+
})).current;
|
|
1303
|
+
useIsoLayoutEffect(()=>{
|
|
1304
|
+
const valuesToSync = {
|
|
1305
|
+
open,
|
|
1306
|
+
floatingId
|
|
1307
|
+
};
|
|
1308
|
+
if (void 0 !== elements.reference) {
|
|
1309
|
+
valuesToSync.referenceElement = elements.reference;
|
|
1310
|
+
valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
|
|
1311
|
+
}
|
|
1312
|
+
if (void 0 !== elements.floating) valuesToSync.floatingElement = elements.floating;
|
|
1313
|
+
store.update(valuesToSync);
|
|
1314
|
+
}, [
|
|
1315
|
+
open,
|
|
1316
|
+
floatingId,
|
|
1317
|
+
elements.reference,
|
|
1318
|
+
elements.floating,
|
|
1319
|
+
store
|
|
1320
|
+
]);
|
|
1321
|
+
store.context.onOpenChange = onOpenChange;
|
|
1322
|
+
store.context.nested = nested;
|
|
1323
|
+
return store;
|
|
1324
|
+
}
|
|
1325
|
+
function useFloating_useFloating(options = {}) {
|
|
1326
|
+
const { nodeId, externalTree } = options;
|
|
1327
|
+
const internalStore = useFloatingRootContext(options);
|
|
1328
|
+
const store = options.rootContext || internalStore;
|
|
1329
|
+
const referenceElement = store.useState('referenceElement');
|
|
1330
|
+
const floatingElement = store.useState('floatingElement');
|
|
1331
|
+
const domReferenceElement = store.useState('domReferenceElement');
|
|
1332
|
+
const open = store.useState('open');
|
|
1333
|
+
const floatingId = store.useState('floatingId');
|
|
1334
|
+
const [positionReference, setPositionReferenceRaw] = __rspack_external_react.useState(null);
|
|
1335
|
+
const [localDomReference, setLocalDomReference] = __rspack_external_react.useState(void 0);
|
|
1336
|
+
const [localFloatingElement, setLocalFloatingElement] = __rspack_external_react.useState(void 0);
|
|
1337
|
+
const domReferenceRef = __rspack_external_react.useRef(null);
|
|
1338
|
+
const tree = useFloatingTree(externalTree);
|
|
1339
|
+
const storeElements = __rspack_external_react.useMemo(()=>({
|
|
1340
|
+
reference: referenceElement,
|
|
1341
|
+
floating: floatingElement,
|
|
1342
|
+
domReference: domReferenceElement
|
|
1343
|
+
}), [
|
|
1344
|
+
referenceElement,
|
|
1345
|
+
floatingElement,
|
|
1346
|
+
domReferenceElement
|
|
1347
|
+
]);
|
|
1348
|
+
const position = useFloating({
|
|
1349
|
+
...options,
|
|
1350
|
+
elements: {
|
|
1351
|
+
...storeElements,
|
|
1352
|
+
...positionReference && {
|
|
1353
|
+
reference: positionReference
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
|
|
1358
|
+
const syncedFloatingElement = void 0 === localFloatingElement ? store.state.floatingElement : localFloatingElement;
|
|
1359
|
+
store.useSyncedValue('referenceElement', localDomReference ?? null);
|
|
1360
|
+
store.useSyncedValue('domReferenceElement', void 0 === localDomReference ? domReferenceElement : localDomReferenceElement);
|
|
1361
|
+
store.useSyncedValue('floatingElement', syncedFloatingElement);
|
|
1362
|
+
const setPositionReference = __rspack_external_react.useCallback((node)=>{
|
|
1363
|
+
const computedPositionReference = isElement(node) ? {
|
|
1364
|
+
getBoundingClientRect: ()=>node.getBoundingClientRect(),
|
|
1365
|
+
getClientRects: ()=>node.getClientRects(),
|
|
1366
|
+
contextElement: node
|
|
1367
|
+
} : node;
|
|
1368
|
+
setPositionReferenceRaw(computedPositionReference);
|
|
1369
|
+
position.refs.setReference(computedPositionReference);
|
|
1370
|
+
}, [
|
|
1371
|
+
position.refs
|
|
1372
|
+
]);
|
|
1373
|
+
const setReference = __rspack_external_react.useCallback((node)=>{
|
|
1374
|
+
if (isElement(node) || null === node) {
|
|
1375
|
+
domReferenceRef.current = node;
|
|
1376
|
+
setLocalDomReference(node);
|
|
1377
|
+
}
|
|
1378
|
+
if (isElement(position.refs.reference.current) || null === position.refs.reference.current || null !== node && !isElement(node)) position.refs.setReference(node);
|
|
1379
|
+
}, [
|
|
1380
|
+
position.refs,
|
|
1381
|
+
setLocalDomReference
|
|
1382
|
+
]);
|
|
1383
|
+
const setFloating = __rspack_external_react.useCallback((node)=>{
|
|
1384
|
+
setLocalFloatingElement(node);
|
|
1385
|
+
position.refs.setFloating(node);
|
|
1386
|
+
}, [
|
|
1387
|
+
position.refs
|
|
1388
|
+
]);
|
|
1389
|
+
const refs = __rspack_external_react.useMemo(()=>({
|
|
1390
|
+
...position.refs,
|
|
1391
|
+
setReference,
|
|
1392
|
+
setFloating,
|
|
1393
|
+
setPositionReference,
|
|
1394
|
+
domReference: domReferenceRef
|
|
1395
|
+
}), [
|
|
1396
|
+
position.refs,
|
|
1397
|
+
setReference,
|
|
1398
|
+
setFloating,
|
|
1399
|
+
setPositionReference
|
|
1400
|
+
]);
|
|
1401
|
+
const elements = __rspack_external_react.useMemo(()=>({
|
|
1402
|
+
...position.elements,
|
|
1403
|
+
domReference: domReferenceElement
|
|
1404
|
+
}), [
|
|
1405
|
+
position.elements,
|
|
1406
|
+
domReferenceElement
|
|
1407
|
+
]);
|
|
1408
|
+
const context = __rspack_external_react.useMemo(()=>({
|
|
1409
|
+
...position,
|
|
1410
|
+
dataRef: store.context.dataRef,
|
|
1411
|
+
open,
|
|
1412
|
+
onOpenChange: store.setOpen,
|
|
1413
|
+
events: store.context.events,
|
|
1414
|
+
floatingId,
|
|
1415
|
+
refs,
|
|
1416
|
+
elements,
|
|
1417
|
+
nodeId,
|
|
1418
|
+
rootStore: store
|
|
1419
|
+
}), [
|
|
1420
|
+
position,
|
|
1421
|
+
refs,
|
|
1422
|
+
elements,
|
|
1423
|
+
nodeId,
|
|
1424
|
+
store,
|
|
1425
|
+
open,
|
|
1426
|
+
floatingId
|
|
1427
|
+
]);
|
|
1428
|
+
useIsoLayoutEffect(()=>{
|
|
1429
|
+
if (domReferenceElement) domReferenceRef.current = domReferenceElement;
|
|
1430
|
+
}, [
|
|
1431
|
+
domReferenceElement
|
|
1432
|
+
]);
|
|
1433
|
+
useIsoLayoutEffect(()=>{
|
|
1434
|
+
store.context.dataRef.current.floatingContext = context;
|
|
1435
|
+
const node = tree?.nodesRef.current.find((n)=>n.id === nodeId);
|
|
1436
|
+
if (node) node.context = context;
|
|
1437
|
+
});
|
|
1438
|
+
return __rspack_external_react.useMemo(()=>({
|
|
1439
|
+
...position,
|
|
1440
|
+
context,
|
|
1441
|
+
refs,
|
|
1442
|
+
elements,
|
|
1443
|
+
rootStore: store
|
|
1444
|
+
}), [
|
|
1445
|
+
position,
|
|
1446
|
+
refs,
|
|
1447
|
+
elements,
|
|
1448
|
+
context,
|
|
1449
|
+
store
|
|
1450
|
+
]);
|
|
1451
|
+
}
|
|
1452
|
+
const baseArrow = (options)=>({
|
|
1453
|
+
name: 'arrow',
|
|
1454
|
+
options,
|
|
1455
|
+
async fn (state) {
|
|
1456
|
+
const { x, y, placement, rects, platform, elements, middlewareData } = state;
|
|
1457
|
+
const { element, padding = 0, offsetParent = 'real' } = floating_ui_utils_evaluate(options, state) || {};
|
|
1458
|
+
if (null == element) return {};
|
|
1459
|
+
const paddingObject = floating_ui_utils_getPaddingObject(padding);
|
|
1460
|
+
const coords = {
|
|
1461
|
+
x,
|
|
1462
|
+
y
|
|
1463
|
+
};
|
|
1464
|
+
const axis = floating_ui_utils_getAlignmentAxis(placement);
|
|
1465
|
+
const length = floating_ui_utils_getAxisLength(axis);
|
|
1466
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1467
|
+
const isYAxis = 'y' === axis;
|
|
1468
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
1469
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
1470
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
1471
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1472
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1473
|
+
const arrowOffsetParent = 'real' === offsetParent ? await platform.getOffsetParent?.(element) : elements.floating;
|
|
1474
|
+
let clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1475
|
+
if (!clientSize || !await platform.isElement?.(arrowOffsetParent)) clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1476
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1477
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1478
|
+
const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
|
|
1479
|
+
const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
|
|
1480
|
+
const min = minPadding;
|
|
1481
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1482
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1483
|
+
const offset = floating_ui_utils_clamp(min, center, max);
|
|
1484
|
+
const shouldAddOffset = !middlewareData.arrow && null != floating_ui_utils_getAlignment(placement) && center !== offset && rects.reference[length] / 2 - (center < min ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1485
|
+
const alignmentOffset = shouldAddOffset ? center < min ? center - min : center - max : 0;
|
|
1486
|
+
return {
|
|
1487
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
1488
|
+
data: {
|
|
1489
|
+
[axis]: offset,
|
|
1490
|
+
centerOffset: center - offset - alignmentOffset,
|
|
1491
|
+
...shouldAddOffset && {
|
|
1492
|
+
alignmentOffset
|
|
1493
|
+
}
|
|
1494
|
+
},
|
|
1495
|
+
reset: shouldAddOffset
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
const arrow_arrow = (options, deps)=>({
|
|
1500
|
+
...baseArrow(options),
|
|
1501
|
+
options: [
|
|
1502
|
+
options,
|
|
1503
|
+
deps
|
|
1504
|
+
]
|
|
1505
|
+
});
|
|
1506
|
+
const hideMiddleware_hide = {
|
|
1507
|
+
name: 'hide',
|
|
1508
|
+
async fn (state) {
|
|
1509
|
+
const { width, height, x, y } = state.rects.reference;
|
|
1510
|
+
const anchorHidden = 0 === width && 0 === height && 0 === x && 0 === y;
|
|
1511
|
+
const nativeHideResult = await floating_ui_react_dom_hide().fn(state);
|
|
1512
|
+
return {
|
|
1513
|
+
data: {
|
|
1514
|
+
referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
const DEFAULT_SIDES = {
|
|
1520
|
+
sideX: 'left',
|
|
1521
|
+
sideY: 'top'
|
|
1522
|
+
};
|
|
1523
|
+
const adaptiveOriginMiddleware_adaptiveOrigin = {
|
|
1524
|
+
name: 'adaptiveOrigin',
|
|
1525
|
+
async fn (state) {
|
|
1526
|
+
const { x: rawX, y: rawY, rects: { floating: floatRect }, elements: { floating }, platform, strategy, placement } = state;
|
|
1527
|
+
const win = getWindow(floating);
|
|
1528
|
+
const styles = win.getComputedStyle(floating);
|
|
1529
|
+
const hasTransition = '0s' !== styles.transitionDuration && '' !== styles.transitionDuration;
|
|
1530
|
+
if (!hasTransition) return {
|
|
1531
|
+
x: rawX,
|
|
1532
|
+
y: rawY,
|
|
1533
|
+
data: DEFAULT_SIDES
|
|
1534
|
+
};
|
|
1535
|
+
const offsetParent = await platform.getOffsetParent?.(floating);
|
|
1536
|
+
let offsetDimensions = {
|
|
1537
|
+
width: 0,
|
|
1538
|
+
height: 0
|
|
1539
|
+
};
|
|
1540
|
+
if ('fixed' === strategy && win?.visualViewport) offsetDimensions = {
|
|
1541
|
+
width: win.visualViewport.width,
|
|
1542
|
+
height: win.visualViewport.height
|
|
1543
|
+
};
|
|
1544
|
+
else if (offsetParent === win) {
|
|
1545
|
+
const doc = ownerDocument(floating);
|
|
1546
|
+
offsetDimensions = {
|
|
1547
|
+
width: doc.documentElement.clientWidth,
|
|
1548
|
+
height: doc.documentElement.clientHeight
|
|
1549
|
+
};
|
|
1550
|
+
} else if (await platform.isElement?.(offsetParent)) offsetDimensions = await platform.getDimensions(offsetParent);
|
|
1551
|
+
const currentSide = floating_ui_utils_getSide(placement);
|
|
1552
|
+
let x = rawX;
|
|
1553
|
+
let y = rawY;
|
|
1554
|
+
if ('left' === currentSide) x = offsetDimensions.width - (rawX + floatRect.width);
|
|
1555
|
+
if ('top' === currentSide) y = offsetDimensions.height - (rawY + floatRect.height);
|
|
1556
|
+
const sideX = 'left' === currentSide ? 'right' : DEFAULT_SIDES.sideX;
|
|
1557
|
+
const sideY = 'top' === currentSide ? 'bottom' : DEFAULT_SIDES.sideY;
|
|
1558
|
+
return {
|
|
1559
|
+
x,
|
|
1560
|
+
y,
|
|
1561
|
+
data: {
|
|
1562
|
+
sideX,
|
|
1563
|
+
sideY
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
function getLogicalSide(sideParam, renderedSide, isRtl) {
|
|
1569
|
+
const isLogicalSideParam = 'inline-start' === sideParam || 'inline-end' === sideParam;
|
|
1570
|
+
const logicalRight = isRtl ? 'inline-start' : 'inline-end';
|
|
1571
|
+
const logicalLeft = isRtl ? 'inline-end' : 'inline-start';
|
|
1572
|
+
return ({
|
|
1573
|
+
top: 'top',
|
|
1574
|
+
right: isLogicalSideParam ? logicalRight : 'right',
|
|
1575
|
+
bottom: 'bottom',
|
|
1576
|
+
left: isLogicalSideParam ? logicalLeft : 'left'
|
|
1577
|
+
})[renderedSide];
|
|
1578
|
+
}
|
|
1579
|
+
function getOffsetData(state, sideParam, isRtl) {
|
|
1580
|
+
const { rects, placement } = state;
|
|
1581
|
+
const data = {
|
|
1582
|
+
side: getLogicalSide(sideParam, floating_ui_utils_getSide(placement), isRtl),
|
|
1583
|
+
align: floating_ui_utils_getAlignment(placement) || 'center',
|
|
1584
|
+
anchor: {
|
|
1585
|
+
width: rects.reference.width,
|
|
1586
|
+
height: rects.reference.height
|
|
1587
|
+
},
|
|
1588
|
+
positioner: {
|
|
1589
|
+
width: rects.floating.width,
|
|
1590
|
+
height: rects.floating.height
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
return data;
|
|
1594
|
+
}
|
|
1595
|
+
function useAnchorPositioning(params) {
|
|
1596
|
+
const { anchor, positionMethod = 'absolute', side: sideParam = 'bottom', sideOffset = 0, align = 'center', alignOffset = 0, collisionBoundary, collisionPadding: collisionPaddingParam = 5, sticky = false, arrowPadding = 5, disableAnchorTracking = false, inline: inlineMiddleware, keepMounted = false, floatingRootContext, mounted, collisionAvoidance, shiftCrossAxis = false, nodeId, adaptiveOrigin, lazyFlip = false, externalTree } = params;
|
|
1597
|
+
const [mountSide, setMountSide] = __rspack_external_react.useState(null);
|
|
1598
|
+
if (!mounted && null !== mountSide) setMountSide(null);
|
|
1599
|
+
const collisionAvoidanceSide = collisionAvoidance.side || 'flip';
|
|
1600
|
+
const collisionAvoidanceAlign = collisionAvoidance.align || 'flip';
|
|
1601
|
+
const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || 'end';
|
|
1602
|
+
const anchorFn = 'function' == typeof anchor ? anchor : void 0;
|
|
1603
|
+
const anchorFnCallback = useStableCallback(anchorFn);
|
|
1604
|
+
const anchorDep = anchorFn ? anchorFnCallback : anchor;
|
|
1605
|
+
const anchorValueRef = useValueAsRef(anchor);
|
|
1606
|
+
const mountedRef = useValueAsRef(mounted);
|
|
1607
|
+
const direction = useDirection();
|
|
1608
|
+
const isRtl = 'rtl' === direction;
|
|
1609
|
+
const side = mountSide || ({
|
|
1610
|
+
top: 'top',
|
|
1611
|
+
right: 'right',
|
|
1612
|
+
bottom: 'bottom',
|
|
1613
|
+
left: 'left',
|
|
1614
|
+
'inline-end': isRtl ? 'left' : 'right',
|
|
1615
|
+
'inline-start': isRtl ? 'right' : 'left'
|
|
1616
|
+
})[sideParam];
|
|
1617
|
+
const placement = 'center' === align ? side : `${side}-${align}`;
|
|
1618
|
+
let collisionPadding = collisionPaddingParam;
|
|
1619
|
+
const bias = 1;
|
|
1620
|
+
const biasTop = 'bottom' === sideParam ? bias : 0;
|
|
1621
|
+
const biasBottom = 'top' === sideParam ? bias : 0;
|
|
1622
|
+
const biasLeft = 'right' === sideParam ? bias : 0;
|
|
1623
|
+
const biasRight = 'left' === sideParam ? bias : 0;
|
|
1624
|
+
if ('number' == typeof collisionPadding) collisionPadding = {
|
|
1625
|
+
top: collisionPadding + biasTop,
|
|
1626
|
+
right: collisionPadding + biasRight,
|
|
1627
|
+
bottom: collisionPadding + biasBottom,
|
|
1628
|
+
left: collisionPadding + biasLeft
|
|
1629
|
+
};
|
|
1630
|
+
else if (collisionPadding) collisionPadding = {
|
|
1631
|
+
top: (collisionPadding.top || 0) + biasTop,
|
|
1632
|
+
right: (collisionPadding.right || 0) + biasRight,
|
|
1633
|
+
bottom: (collisionPadding.bottom || 0) + biasBottom,
|
|
1634
|
+
left: (collisionPadding.left || 0) + biasLeft
|
|
1635
|
+
};
|
|
1636
|
+
const commonCollisionProps = {
|
|
1637
|
+
boundary: 'clipping-ancestors' === collisionBoundary ? 'clippingAncestors' : collisionBoundary,
|
|
1638
|
+
padding: collisionPadding
|
|
1639
|
+
};
|
|
1640
|
+
const arrowRef = __rspack_external_react.useRef(null);
|
|
1641
|
+
const sideOffsetRef = useValueAsRef(sideOffset);
|
|
1642
|
+
const alignOffsetRef = useValueAsRef(alignOffset);
|
|
1643
|
+
const sideOffsetDep = 'function' != typeof sideOffset ? sideOffset : 0;
|
|
1644
|
+
const alignOffsetDep = 'function' != typeof alignOffset ? alignOffset : 0;
|
|
1645
|
+
const middleware = [];
|
|
1646
|
+
if (inlineMiddleware) middleware.push(inlineMiddleware);
|
|
1647
|
+
middleware.push(floating_ui_react_dom_offset((state)=>{
|
|
1648
|
+
const data = getOffsetData(state, sideParam, isRtl);
|
|
1649
|
+
const sideAxis = 'function' == typeof sideOffsetRef.current ? sideOffsetRef.current(data) : sideOffsetRef.current;
|
|
1650
|
+
const alignAxis = 'function' == typeof alignOffsetRef.current ? alignOffsetRef.current(data) : alignOffsetRef.current;
|
|
1651
|
+
return {
|
|
1652
|
+
mainAxis: sideAxis,
|
|
1653
|
+
crossAxis: alignAxis,
|
|
1654
|
+
alignmentAxis: alignAxis
|
|
1655
|
+
};
|
|
1656
|
+
}, [
|
|
1657
|
+
sideOffsetDep,
|
|
1658
|
+
alignOffsetDep,
|
|
1659
|
+
isRtl,
|
|
1660
|
+
sideParam
|
|
1661
|
+
]));
|
|
1662
|
+
const shiftDisabled = 'none' === collisionAvoidanceAlign && 'shift' !== collisionAvoidanceSide;
|
|
1663
|
+
const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || 'shift' === collisionAvoidanceSide);
|
|
1664
|
+
const flipMiddleware = 'none' === collisionAvoidanceSide ? null : floating_ui_react_dom_flip({
|
|
1665
|
+
...commonCollisionProps,
|
|
1666
|
+
padding: {
|
|
1667
|
+
top: collisionPadding.top + bias,
|
|
1668
|
+
right: collisionPadding.right + bias,
|
|
1669
|
+
bottom: collisionPadding.bottom + bias,
|
|
1670
|
+
left: collisionPadding.left + bias
|
|
1671
|
+
},
|
|
1672
|
+
mainAxis: !shiftCrossAxis && 'flip' === collisionAvoidanceSide,
|
|
1673
|
+
crossAxis: 'flip' === collisionAvoidanceAlign ? 'alignment' : false,
|
|
1674
|
+
fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
|
|
1675
|
+
});
|
|
1676
|
+
const shiftMiddleware = shiftDisabled ? null : floating_ui_react_dom_shift((data)=>{
|
|
1677
|
+
const html = ownerDocument(data.elements.floating).documentElement;
|
|
1678
|
+
return {
|
|
1679
|
+
...commonCollisionProps,
|
|
1680
|
+
rootBoundary: shiftCrossAxis ? {
|
|
1681
|
+
x: 0,
|
|
1682
|
+
y: 0,
|
|
1683
|
+
width: html.clientWidth,
|
|
1684
|
+
height: html.clientHeight
|
|
1685
|
+
} : void 0,
|
|
1686
|
+
mainAxis: 'none' !== collisionAvoidanceAlign,
|
|
1687
|
+
crossAxis: crossAxisShiftEnabled,
|
|
1688
|
+
limiter: sticky || shiftCrossAxis ? void 0 : floating_ui_react_dom_limitShift((limitData)=>{
|
|
1689
|
+
if (!arrowRef.current) return {};
|
|
1690
|
+
const { width, height } = arrowRef.current.getBoundingClientRect();
|
|
1691
|
+
const sideAxis = floating_ui_utils_getSideAxis(floating_ui_utils_getSide(limitData.placement));
|
|
1692
|
+
const arrowSize = 'y' === sideAxis ? width : height;
|
|
1693
|
+
const offsetAmount = 'y' === sideAxis ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
|
|
1694
|
+
return {
|
|
1695
|
+
offset: arrowSize / 2 + offsetAmount / 2
|
|
1696
|
+
};
|
|
1697
|
+
})
|
|
1698
|
+
};
|
|
1699
|
+
}, [
|
|
1700
|
+
commonCollisionProps,
|
|
1701
|
+
sticky,
|
|
1702
|
+
shiftCrossAxis,
|
|
1703
|
+
collisionPadding,
|
|
1704
|
+
collisionAvoidanceAlign
|
|
1705
|
+
]);
|
|
1706
|
+
if ('shift' === collisionAvoidanceSide || 'shift' === collisionAvoidanceAlign || 'center' === align) middleware.push(shiftMiddleware, flipMiddleware);
|
|
1707
|
+
else middleware.push(flipMiddleware, shiftMiddleware);
|
|
1708
|
+
middleware.push(floating_ui_react_dom_size({
|
|
1709
|
+
...commonCollisionProps,
|
|
1710
|
+
apply ({ elements: { floating }, availableWidth, availableHeight, rects }) {
|
|
1711
|
+
if (!mountedRef.current) return;
|
|
1712
|
+
const floatingStyle = floating.style;
|
|
1713
|
+
floatingStyle.setProperty('--available-width', `${availableWidth}px`);
|
|
1714
|
+
floatingStyle.setProperty('--available-height', `${availableHeight}px`);
|
|
1715
|
+
const dpr = getWindow(floating).devicePixelRatio || 1;
|
|
1716
|
+
const { x, y, width, height } = rects.reference;
|
|
1717
|
+
const anchorWidth = (Math.round((x + width) * dpr) - Math.round(x * dpr)) / dpr;
|
|
1718
|
+
const anchorHeight = (Math.round((y + height) * dpr) - Math.round(y * dpr)) / dpr;
|
|
1719
|
+
floatingStyle.setProperty('--anchor-width', `${anchorWidth}px`);
|
|
1720
|
+
floatingStyle.setProperty('--anchor-height', `${anchorHeight}px`);
|
|
1721
|
+
}
|
|
1722
|
+
}), arrow_arrow((state)=>({
|
|
1723
|
+
element: arrowRef.current || ownerDocument(state.elements.floating).createElement('div'),
|
|
1724
|
+
padding: arrowPadding,
|
|
1725
|
+
offsetParent: 'floating'
|
|
1726
|
+
}), [
|
|
1727
|
+
arrowPadding
|
|
1728
|
+
]), {
|
|
1729
|
+
name: 'transformOrigin',
|
|
1730
|
+
fn (state) {
|
|
1731
|
+
const { elements, middlewareData, placement: renderedPlacement, rects, y } = state;
|
|
1732
|
+
const currentRenderedSide = floating_ui_utils_getSide(renderedPlacement);
|
|
1733
|
+
const currentRenderedAxis = floating_ui_utils_getSideAxis(currentRenderedSide);
|
|
1734
|
+
const arrowEl = arrowRef.current;
|
|
1735
|
+
const arrowX = middlewareData.arrow?.x || 0;
|
|
1736
|
+
const arrowY = middlewareData.arrow?.y || 0;
|
|
1737
|
+
const arrowWidth = arrowEl?.clientWidth || 0;
|
|
1738
|
+
const arrowHeight = arrowEl?.clientHeight || 0;
|
|
1739
|
+
const transformX = arrowX + arrowWidth / 2;
|
|
1740
|
+
const transformY = arrowY + arrowHeight / 2;
|
|
1741
|
+
const shiftY = Math.abs(middlewareData.shift?.y || 0);
|
|
1742
|
+
const halfAnchorHeight = rects.reference.height / 2;
|
|
1743
|
+
const sideOffsetValue = 'function' == typeof sideOffset ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
|
|
1744
|
+
const isOverlappingAnchor = shiftY > sideOffsetValue;
|
|
1745
|
+
const adjacentTransformOrigin = {
|
|
1746
|
+
top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
|
|
1747
|
+
bottom: `${transformX}px ${-sideOffsetValue}px`,
|
|
1748
|
+
left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
|
|
1749
|
+
right: `${-sideOffsetValue}px ${transformY}px`
|
|
1750
|
+
}[currentRenderedSide];
|
|
1751
|
+
const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y}px`;
|
|
1752
|
+
elements.floating.style.setProperty('--transform-origin', crossAxisShiftEnabled && 'y' === currentRenderedAxis && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
|
|
1753
|
+
return {};
|
|
1754
|
+
}
|
|
1755
|
+
}, hideMiddleware_hide, adaptiveOrigin);
|
|
1756
|
+
useIsoLayoutEffect(()=>{
|
|
1757
|
+
if (!mounted && floatingRootContext) floatingRootContext.update({
|
|
1758
|
+
referenceElement: null,
|
|
1759
|
+
floatingElement: null,
|
|
1760
|
+
domReferenceElement: null,
|
|
1761
|
+
positionReference: null
|
|
1762
|
+
});
|
|
1763
|
+
}, [
|
|
1764
|
+
mounted,
|
|
1765
|
+
floatingRootContext
|
|
1766
|
+
]);
|
|
1767
|
+
const autoUpdateOptions = __rspack_external_react.useMemo(()=>({
|
|
1768
|
+
elementResize: !disableAnchorTracking && "u" > typeof ResizeObserver,
|
|
1769
|
+
layoutShift: !disableAnchorTracking && "u" > typeof IntersectionObserver
|
|
1770
|
+
}), [
|
|
1771
|
+
disableAnchorTracking
|
|
1772
|
+
]);
|
|
1773
|
+
const { refs, elements, x, y, middlewareData, update, placement: renderedPlacement, context, isPositioned, floatingStyles: originalFloatingStyles } = useFloating_useFloating({
|
|
1774
|
+
rootContext: floatingRootContext,
|
|
1775
|
+
open: keepMounted ? mounted : void 0,
|
|
1776
|
+
placement,
|
|
1777
|
+
middleware,
|
|
1778
|
+
strategy: positionMethod,
|
|
1779
|
+
whileElementsMounted: keepMounted ? void 0 : (...args)=>autoUpdate(...args, autoUpdateOptions),
|
|
1780
|
+
nodeId,
|
|
1781
|
+
externalTree
|
|
1782
|
+
});
|
|
1783
|
+
const { sideX, sideY } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
|
|
1784
|
+
const resolvedPosition = isPositioned ? positionMethod : 'fixed';
|
|
1785
|
+
const floatingStyles = __rspack_external_react.useMemo(()=>{
|
|
1786
|
+
const base = adaptiveOrigin ? {
|
|
1787
|
+
position: resolvedPosition,
|
|
1788
|
+
[sideX]: x,
|
|
1789
|
+
[sideY]: y
|
|
1790
|
+
} : {
|
|
1791
|
+
position: resolvedPosition,
|
|
1792
|
+
...originalFloatingStyles
|
|
1793
|
+
};
|
|
1794
|
+
if (!isPositioned) base.opacity = 0;
|
|
1795
|
+
return base;
|
|
1796
|
+
}, [
|
|
1797
|
+
adaptiveOrigin,
|
|
1798
|
+
resolvedPosition,
|
|
1799
|
+
sideX,
|
|
1800
|
+
x,
|
|
1801
|
+
sideY,
|
|
1802
|
+
y,
|
|
1803
|
+
originalFloatingStyles,
|
|
1804
|
+
isPositioned
|
|
1805
|
+
]);
|
|
1806
|
+
const registeredPositionReferenceRef = __rspack_external_react.useRef(null);
|
|
1807
|
+
useIsoLayoutEffect(()=>{
|
|
1808
|
+
if (!mounted) return;
|
|
1809
|
+
const anchorValue = anchorValueRef.current;
|
|
1810
|
+
const resolvedAnchor = 'function' == typeof anchorValue ? anchorValue() : anchorValue;
|
|
1811
|
+
const unwrappedElement = (useAnchorPositioning_isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
|
|
1812
|
+
const finalAnchor = unwrappedElement || null;
|
|
1813
|
+
if (finalAnchor !== registeredPositionReferenceRef.current) {
|
|
1814
|
+
refs.setPositionReference(finalAnchor);
|
|
1815
|
+
registeredPositionReferenceRef.current = finalAnchor;
|
|
1816
|
+
}
|
|
1817
|
+
}, [
|
|
1818
|
+
mounted,
|
|
1819
|
+
refs,
|
|
1820
|
+
anchorDep,
|
|
1821
|
+
anchorValueRef
|
|
1822
|
+
]);
|
|
1823
|
+
__rspack_external_react.useEffect(()=>{
|
|
1824
|
+
if (!mounted) return;
|
|
1825
|
+
const anchorValue = anchorValueRef.current;
|
|
1826
|
+
if ('function' == typeof anchorValue) return;
|
|
1827
|
+
if (useAnchorPositioning_isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
|
|
1828
|
+
refs.setPositionReference(anchorValue.current);
|
|
1829
|
+
registeredPositionReferenceRef.current = anchorValue.current;
|
|
1830
|
+
}
|
|
1831
|
+
}, [
|
|
1832
|
+
mounted,
|
|
1833
|
+
refs,
|
|
1834
|
+
anchorDep,
|
|
1835
|
+
anchorValueRef
|
|
1836
|
+
]);
|
|
1837
|
+
__rspack_external_react.useEffect(()=>{
|
|
1838
|
+
if (keepMounted && mounted && elements.domReference && elements.floating) return autoUpdate(elements.domReference, elements.floating, update, autoUpdateOptions);
|
|
1839
|
+
}, [
|
|
1840
|
+
keepMounted,
|
|
1841
|
+
mounted,
|
|
1842
|
+
elements,
|
|
1843
|
+
update,
|
|
1844
|
+
autoUpdateOptions
|
|
1845
|
+
]);
|
|
1846
|
+
const renderedSide = floating_ui_utils_getSide(renderedPlacement);
|
|
1847
|
+
const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
|
|
1848
|
+
const renderedAlign = floating_ui_utils_getAlignment(renderedPlacement) || 'center';
|
|
1849
|
+
const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
|
|
1850
|
+
useIsoLayoutEffect(()=>{
|
|
1851
|
+
if (lazyFlip && mounted && isPositioned) setMountSide(renderedSide);
|
|
1852
|
+
}, [
|
|
1853
|
+
lazyFlip,
|
|
1854
|
+
mounted,
|
|
1855
|
+
isPositioned,
|
|
1856
|
+
renderedSide
|
|
1857
|
+
]);
|
|
1858
|
+
const arrowStyles = __rspack_external_react.useMemo(()=>({
|
|
1859
|
+
position: 'absolute',
|
|
1860
|
+
top: middlewareData.arrow?.y,
|
|
1861
|
+
left: middlewareData.arrow?.x
|
|
1862
|
+
}), [
|
|
1863
|
+
middlewareData.arrow
|
|
1864
|
+
]);
|
|
1865
|
+
const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
|
|
1866
|
+
return __rspack_external_react.useMemo(()=>({
|
|
1867
|
+
positionerStyles: floatingStyles,
|
|
1868
|
+
arrowStyles,
|
|
1869
|
+
arrowRef,
|
|
1870
|
+
arrowUncentered,
|
|
1871
|
+
side: logicalRenderedSide,
|
|
1872
|
+
align: renderedAlign,
|
|
1873
|
+
physicalSide: renderedSide,
|
|
1874
|
+
anchorHidden,
|
|
1875
|
+
refs,
|
|
1876
|
+
context,
|
|
1877
|
+
isPositioned,
|
|
1878
|
+
update
|
|
1879
|
+
}), [
|
|
1880
|
+
floatingStyles,
|
|
1881
|
+
arrowStyles,
|
|
1882
|
+
arrowRef,
|
|
1883
|
+
arrowUncentered,
|
|
1884
|
+
logicalRenderedSide,
|
|
1885
|
+
renderedAlign,
|
|
1886
|
+
renderedSide,
|
|
1887
|
+
anchorHidden,
|
|
1888
|
+
refs,
|
|
1889
|
+
context,
|
|
1890
|
+
isPositioned,
|
|
1891
|
+
update
|
|
1892
|
+
]);
|
|
1893
|
+
}
|
|
1894
|
+
function useAnchorPositioning_isRef(param) {
|
|
1895
|
+
return null != param && 'current' in param;
|
|
1896
|
+
}
|
|
1897
|
+
function getDisabledMountTransitionStyles(transitionStatus) {
|
|
1898
|
+
return 'starting' === transitionStatus ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
|
|
1899
|
+
}
|
|
1900
|
+
function usePositioner(componentProps, state, { styles, transitionStatus, props, refs, hidden, inert = false }) {
|
|
1901
|
+
const style = {
|
|
1902
|
+
...styles
|
|
1903
|
+
};
|
|
1904
|
+
if (inert) style.pointerEvents = 'none';
|
|
1905
|
+
return useRenderElement('div', componentProps, {
|
|
1906
|
+
state,
|
|
1907
|
+
ref: refs,
|
|
1908
|
+
props: [
|
|
1909
|
+
{
|
|
1910
|
+
role: 'presentation',
|
|
1911
|
+
hidden,
|
|
1912
|
+
style
|
|
1913
|
+
},
|
|
1914
|
+
getDisabledMountTransitionStyles(transitionStatus),
|
|
1915
|
+
props
|
|
1916
|
+
],
|
|
1917
|
+
stateAttributesMapping: popupStateMapping
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
export { adaptiveOriginMiddleware_adaptiveOrigin, floating_ui_dom_platform, getDisabledMountTransitionStyles, useAnchorPositioning, useFloatingRootContext, usePositioner };
|