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