react-tooltip 5.8.2-beta.3 → 5.8.2
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/react-tooltip.cjs.js +1886 -2159
- package/dist/react-tooltip.cjs.min.js +3 -3
- package/dist/react-tooltip.d.ts +7 -3
- package/dist/react-tooltip.esm.js +1887 -2154
- package/dist/react-tooltip.esm.min.js +3 -3
- package/dist/react-tooltip.umd.js +1886 -2159
- package/dist/react-tooltip.umd.min.js +3 -3
- package/package.json +1 -1
|
@@ -8,1515 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
10
10
|
|
|
11
|
-
function getAlignment(placement) {
|
|
12
|
-
return placement.split('-')[1];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getLengthFromAxis(axis) {
|
|
16
|
-
return axis === 'y' ? 'height' : 'width';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getSide(placement) {
|
|
20
|
-
return placement.split('-')[0];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getMainAxisFromPlacement(placement) {
|
|
24
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
28
|
-
let {
|
|
29
|
-
reference,
|
|
30
|
-
floating
|
|
31
|
-
} = _ref;
|
|
32
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
33
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
34
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
35
|
-
const length = getLengthFromAxis(mainAxis);
|
|
36
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
37
|
-
const side = getSide(placement);
|
|
38
|
-
const isVertical = mainAxis === 'x';
|
|
39
|
-
let coords;
|
|
40
|
-
switch (side) {
|
|
41
|
-
case 'top':
|
|
42
|
-
coords = {
|
|
43
|
-
x: commonX,
|
|
44
|
-
y: reference.y - floating.height
|
|
45
|
-
};
|
|
46
|
-
break;
|
|
47
|
-
case 'bottom':
|
|
48
|
-
coords = {
|
|
49
|
-
x: commonX,
|
|
50
|
-
y: reference.y + reference.height
|
|
51
|
-
};
|
|
52
|
-
break;
|
|
53
|
-
case 'right':
|
|
54
|
-
coords = {
|
|
55
|
-
x: reference.x + reference.width,
|
|
56
|
-
y: commonY
|
|
57
|
-
};
|
|
58
|
-
break;
|
|
59
|
-
case 'left':
|
|
60
|
-
coords = {
|
|
61
|
-
x: reference.x - floating.width,
|
|
62
|
-
y: commonY
|
|
63
|
-
};
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
coords = {
|
|
67
|
-
x: reference.x,
|
|
68
|
-
y: reference.y
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
switch (getAlignment(placement)) {
|
|
72
|
-
case 'start':
|
|
73
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
74
|
-
break;
|
|
75
|
-
case 'end':
|
|
76
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
return coords;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
84
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
85
|
-
*
|
|
86
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
87
|
-
* write one for the platform you are using Floating UI with.
|
|
88
|
-
*/
|
|
89
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
90
|
-
const {
|
|
91
|
-
placement = 'bottom',
|
|
92
|
-
strategy = 'absolute',
|
|
93
|
-
middleware = [],
|
|
94
|
-
platform
|
|
95
|
-
} = config;
|
|
96
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
97
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
98
|
-
{
|
|
99
|
-
if (platform == null) {
|
|
100
|
-
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
|
|
101
|
-
}
|
|
102
|
-
if (validMiddleware.filter(_ref => {
|
|
103
|
-
let {
|
|
104
|
-
name
|
|
105
|
-
} = _ref;
|
|
106
|
-
return name === 'autoPlacement' || name === 'flip';
|
|
107
|
-
}).length > 1) {
|
|
108
|
-
throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
|
|
109
|
-
}
|
|
110
|
-
if (!reference || !floating) {
|
|
111
|
-
console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
let rects = await platform.getElementRects({
|
|
115
|
-
reference,
|
|
116
|
-
floating,
|
|
117
|
-
strategy
|
|
118
|
-
});
|
|
119
|
-
let {
|
|
120
|
-
x,
|
|
121
|
-
y
|
|
122
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
123
|
-
let statefulPlacement = placement;
|
|
124
|
-
let middlewareData = {};
|
|
125
|
-
let resetCount = 0;
|
|
126
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
127
|
-
const {
|
|
128
|
-
name,
|
|
129
|
-
fn
|
|
130
|
-
} = validMiddleware[i];
|
|
131
|
-
const {
|
|
132
|
-
x: nextX,
|
|
133
|
-
y: nextY,
|
|
134
|
-
data,
|
|
135
|
-
reset
|
|
136
|
-
} = await fn({
|
|
137
|
-
x,
|
|
138
|
-
y,
|
|
139
|
-
initialPlacement: placement,
|
|
140
|
-
placement: statefulPlacement,
|
|
141
|
-
strategy,
|
|
142
|
-
middlewareData,
|
|
143
|
-
rects,
|
|
144
|
-
platform,
|
|
145
|
-
elements: {
|
|
146
|
-
reference,
|
|
147
|
-
floating
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
x = nextX != null ? nextX : x;
|
|
151
|
-
y = nextY != null ? nextY : y;
|
|
152
|
-
middlewareData = {
|
|
153
|
-
...middlewareData,
|
|
154
|
-
[name]: {
|
|
155
|
-
...middlewareData[name],
|
|
156
|
-
...data
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
{
|
|
160
|
-
if (resetCount > 50) {
|
|
161
|
-
console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (reset && resetCount <= 50) {
|
|
165
|
-
resetCount++;
|
|
166
|
-
if (typeof reset === 'object') {
|
|
167
|
-
if (reset.placement) {
|
|
168
|
-
statefulPlacement = reset.placement;
|
|
169
|
-
}
|
|
170
|
-
if (reset.rects) {
|
|
171
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
172
|
-
reference,
|
|
173
|
-
floating,
|
|
174
|
-
strategy
|
|
175
|
-
}) : reset.rects;
|
|
176
|
-
}
|
|
177
|
-
({
|
|
178
|
-
x,
|
|
179
|
-
y
|
|
180
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
181
|
-
}
|
|
182
|
-
i = -1;
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
x,
|
|
188
|
-
y,
|
|
189
|
-
placement: statefulPlacement,
|
|
190
|
-
strategy,
|
|
191
|
-
middlewareData
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
function expandPaddingObject(padding) {
|
|
196
|
-
return {
|
|
197
|
-
top: 0,
|
|
198
|
-
right: 0,
|
|
199
|
-
bottom: 0,
|
|
200
|
-
left: 0,
|
|
201
|
-
...padding
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function getSideObjectFromPadding(padding) {
|
|
206
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
207
|
-
top: padding,
|
|
208
|
-
right: padding,
|
|
209
|
-
bottom: padding,
|
|
210
|
-
left: padding
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function rectToClientRect(rect) {
|
|
215
|
-
return {
|
|
216
|
-
...rect,
|
|
217
|
-
top: rect.y,
|
|
218
|
-
left: rect.x,
|
|
219
|
-
right: rect.x + rect.width,
|
|
220
|
-
bottom: rect.y + rect.height
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
226
|
-
* element is overflowing a given clipping boundary.
|
|
227
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
228
|
-
* - negative = how many pixels left before it will overflow
|
|
229
|
-
* - 0 = lies flush with the boundary
|
|
230
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
231
|
-
*/
|
|
232
|
-
async function detectOverflow(middlewareArguments, options) {
|
|
233
|
-
var _await$platform$isEle;
|
|
234
|
-
if (options === void 0) {
|
|
235
|
-
options = {};
|
|
236
|
-
}
|
|
237
|
-
const {
|
|
238
|
-
x,
|
|
239
|
-
y,
|
|
240
|
-
platform,
|
|
241
|
-
rects,
|
|
242
|
-
elements,
|
|
243
|
-
strategy
|
|
244
|
-
} = middlewareArguments;
|
|
245
|
-
const {
|
|
246
|
-
boundary = 'clippingAncestors',
|
|
247
|
-
rootBoundary = 'viewport',
|
|
248
|
-
elementContext = 'floating',
|
|
249
|
-
altBoundary = false,
|
|
250
|
-
padding = 0
|
|
251
|
-
} = options;
|
|
252
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
253
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
254
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
255
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
256
|
-
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))),
|
|
257
|
-
boundary,
|
|
258
|
-
rootBoundary,
|
|
259
|
-
strategy
|
|
260
|
-
}));
|
|
261
|
-
const rect = elementContext === 'floating' ? {
|
|
262
|
-
...rects.floating,
|
|
263
|
-
x,
|
|
264
|
-
y
|
|
265
|
-
} : rects.reference;
|
|
266
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
267
|
-
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
268
|
-
x: 1,
|
|
269
|
-
y: 1
|
|
270
|
-
} : {
|
|
271
|
-
x: 1,
|
|
272
|
-
y: 1
|
|
273
|
-
};
|
|
274
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
275
|
-
rect,
|
|
276
|
-
offsetParent,
|
|
277
|
-
strategy
|
|
278
|
-
}) : rect);
|
|
279
|
-
return {
|
|
280
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
281
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
282
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
283
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const min$1 = Math.min;
|
|
288
|
-
const max$1 = Math.max;
|
|
289
|
-
|
|
290
|
-
function within(min$1$1, value, max$1$1) {
|
|
291
|
-
return max$1(min$1$1, min$1(value, max$1$1));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Positions an inner element of the floating element such that it is centered
|
|
296
|
-
* to the reference element.
|
|
297
|
-
* @see https://floating-ui.com/docs/arrow
|
|
298
|
-
*/
|
|
299
|
-
const arrow = options => ({
|
|
300
|
-
name: 'arrow',
|
|
301
|
-
options,
|
|
302
|
-
async fn(middlewareArguments) {
|
|
303
|
-
// Since `element` is required, we don't Partial<> the type.
|
|
304
|
-
const {
|
|
305
|
-
element,
|
|
306
|
-
padding = 0
|
|
307
|
-
} = options || {};
|
|
308
|
-
const {
|
|
309
|
-
x,
|
|
310
|
-
y,
|
|
311
|
-
placement,
|
|
312
|
-
rects,
|
|
313
|
-
platform
|
|
314
|
-
} = middlewareArguments;
|
|
315
|
-
if (element == null) {
|
|
316
|
-
{
|
|
317
|
-
console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
|
|
318
|
-
}
|
|
319
|
-
return {};
|
|
320
|
-
}
|
|
321
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
322
|
-
const coords = {
|
|
323
|
-
x,
|
|
324
|
-
y
|
|
325
|
-
};
|
|
326
|
-
const axis = getMainAxisFromPlacement(placement);
|
|
327
|
-
const length = getLengthFromAxis(axis);
|
|
328
|
-
const arrowDimensions = await platform.getDimensions(element);
|
|
329
|
-
const minProp = axis === 'y' ? 'top' : 'left';
|
|
330
|
-
const maxProp = axis === 'y' ? 'bottom' : 'right';
|
|
331
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
332
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
333
|
-
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
334
|
-
let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
335
|
-
if (clientSize === 0) {
|
|
336
|
-
clientSize = rects.floating[length];
|
|
337
|
-
}
|
|
338
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
339
|
-
|
|
340
|
-
// Make sure the arrow doesn't overflow the floating element if the center
|
|
341
|
-
// point is outside the floating element's bounds.
|
|
342
|
-
const min = paddingObject[minProp];
|
|
343
|
-
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
344
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
345
|
-
const offset = within(min, center, max);
|
|
346
|
-
|
|
347
|
-
// If the reference is small enough that the arrow's padding causes it to
|
|
348
|
-
// to point to nothing for an aligned placement, adjust the offset of the
|
|
349
|
-
// floating element itself. This stops `shift()` from taking action, but can
|
|
350
|
-
// be worked around by calling it again after the `arrow()` if desired.
|
|
351
|
-
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
|
|
352
|
-
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
353
|
-
return {
|
|
354
|
-
[axis]: coords[axis] - alignmentOffset,
|
|
355
|
-
data: {
|
|
356
|
-
[axis]: offset,
|
|
357
|
-
centerOffset: center - offset
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
const sides = ['top', 'right', 'bottom', 'left'];
|
|
364
|
-
const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
|
|
365
|
-
|
|
366
|
-
const oppositeSideMap = {
|
|
367
|
-
left: 'right',
|
|
368
|
-
right: 'left',
|
|
369
|
-
bottom: 'top',
|
|
370
|
-
top: 'bottom'
|
|
371
|
-
};
|
|
372
|
-
function getOppositePlacement(placement) {
|
|
373
|
-
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
377
|
-
if (rtl === void 0) {
|
|
378
|
-
rtl = false;
|
|
379
|
-
}
|
|
380
|
-
const alignment = getAlignment(placement);
|
|
381
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
382
|
-
const length = getLengthFromAxis(mainAxis);
|
|
383
|
-
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
384
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
385
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
386
|
-
}
|
|
387
|
-
return {
|
|
388
|
-
main: mainAlignmentSide,
|
|
389
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const oppositeAlignmentMap = {
|
|
394
|
-
start: 'end',
|
|
395
|
-
end: 'start'
|
|
396
|
-
};
|
|
397
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
398
|
-
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
402
|
-
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
403
|
-
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
404
|
-
if (alignment) {
|
|
405
|
-
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Automatically chooses the `placement` which has the most space available.
|
|
412
|
-
* @see https://floating-ui.com/docs/autoPlacement
|
|
413
|
-
*/
|
|
414
|
-
const autoPlacement = function (options) {
|
|
415
|
-
if (options === void 0) {
|
|
416
|
-
options = {};
|
|
417
|
-
}
|
|
418
|
-
return {
|
|
419
|
-
name: 'autoPlacement',
|
|
420
|
-
options,
|
|
421
|
-
async fn(middlewareArguments) {
|
|
422
|
-
var _middlewareData$autoP, _middlewareData$autoP2, _placementsSortedByLe;
|
|
423
|
-
const {
|
|
424
|
-
rects,
|
|
425
|
-
middlewareData,
|
|
426
|
-
placement,
|
|
427
|
-
platform,
|
|
428
|
-
elements
|
|
429
|
-
} = middlewareArguments;
|
|
430
|
-
const {
|
|
431
|
-
alignment,
|
|
432
|
-
allowedPlacements = allPlacements,
|
|
433
|
-
autoAlignment = true,
|
|
434
|
-
...detectOverflowOptions
|
|
435
|
-
} = options;
|
|
436
|
-
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
437
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
438
|
-
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
439
|
-
const currentPlacement = placements[currentIndex];
|
|
440
|
-
if (currentPlacement == null) {
|
|
441
|
-
return {};
|
|
442
|
-
}
|
|
443
|
-
const {
|
|
444
|
-
main,
|
|
445
|
-
cross
|
|
446
|
-
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
447
|
-
|
|
448
|
-
// Make `computeCoords` start from the right place.
|
|
449
|
-
if (placement !== currentPlacement) {
|
|
450
|
-
return {
|
|
451
|
-
reset: {
|
|
452
|
-
placement: placements[0]
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
|
|
457
|
-
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
|
458
|
-
placement: currentPlacement,
|
|
459
|
-
overflows: currentOverflows
|
|
460
|
-
}];
|
|
461
|
-
const nextPlacement = placements[currentIndex + 1];
|
|
462
|
-
|
|
463
|
-
// There are more placements to check.
|
|
464
|
-
if (nextPlacement) {
|
|
465
|
-
return {
|
|
466
|
-
data: {
|
|
467
|
-
index: currentIndex + 1,
|
|
468
|
-
overflows: allOverflows
|
|
469
|
-
},
|
|
470
|
-
reset: {
|
|
471
|
-
placement: nextPlacement
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
|
|
476
|
-
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
|
|
477
|
-
let {
|
|
478
|
-
overflows
|
|
479
|
-
} = _ref;
|
|
480
|
-
return overflows.every(overflow => overflow <= 0);
|
|
481
|
-
})) == null ? void 0 : _placementsSortedByLe.placement;
|
|
482
|
-
const resetPlacement = placementThatFitsOnAllSides || placementsSortedByLeastOverflow[0].placement;
|
|
483
|
-
if (resetPlacement !== placement) {
|
|
484
|
-
return {
|
|
485
|
-
data: {
|
|
486
|
-
index: currentIndex + 1,
|
|
487
|
-
overflows: allOverflows
|
|
488
|
-
},
|
|
489
|
-
reset: {
|
|
490
|
-
placement: resetPlacement
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
return {};
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
function getExpandedPlacements(placement) {
|
|
500
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
501
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function getSideList(side, isStart, rtl) {
|
|
505
|
-
const lr = ['left', 'right'];
|
|
506
|
-
const rl = ['right', 'left'];
|
|
507
|
-
const tb = ['top', 'bottom'];
|
|
508
|
-
const bt = ['bottom', 'top'];
|
|
509
|
-
switch (side) {
|
|
510
|
-
case 'top':
|
|
511
|
-
case 'bottom':
|
|
512
|
-
if (rtl) return isStart ? rl : lr;
|
|
513
|
-
return isStart ? lr : rl;
|
|
514
|
-
case 'left':
|
|
515
|
-
case 'right':
|
|
516
|
-
return isStart ? tb : bt;
|
|
517
|
-
default:
|
|
518
|
-
return [];
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
522
|
-
const alignment = getAlignment(placement);
|
|
523
|
-
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
524
|
-
if (alignment) {
|
|
525
|
-
list = list.map(side => side + "-" + alignment);
|
|
526
|
-
if (flipAlignment) {
|
|
527
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
return list;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Changes the placement of the floating element to one that will fit if the
|
|
535
|
-
* initially specified `placement` does not.
|
|
536
|
-
* @see https://floating-ui.com/docs/flip
|
|
537
|
-
*/
|
|
538
|
-
const flip = function (options) {
|
|
539
|
-
if (options === void 0) {
|
|
540
|
-
options = {};
|
|
541
|
-
}
|
|
542
|
-
return {
|
|
543
|
-
name: 'flip',
|
|
544
|
-
options,
|
|
545
|
-
async fn(middlewareArguments) {
|
|
546
|
-
var _middlewareData$flip;
|
|
547
|
-
const {
|
|
548
|
-
placement,
|
|
549
|
-
middlewareData,
|
|
550
|
-
rects,
|
|
551
|
-
initialPlacement,
|
|
552
|
-
platform,
|
|
553
|
-
elements
|
|
554
|
-
} = middlewareArguments;
|
|
555
|
-
const {
|
|
556
|
-
mainAxis: checkMainAxis = true,
|
|
557
|
-
crossAxis: checkCrossAxis = true,
|
|
558
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
559
|
-
fallbackStrategy = 'bestFit',
|
|
560
|
-
fallbackAxisSideDirection = 'none',
|
|
561
|
-
flipAlignment = true,
|
|
562
|
-
...detectOverflowOptions
|
|
563
|
-
} = options;
|
|
564
|
-
const side = getSide(placement);
|
|
565
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
566
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
567
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
568
|
-
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
569
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
570
|
-
}
|
|
571
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
572
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
573
|
-
const overflows = [];
|
|
574
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
575
|
-
if (checkMainAxis) {
|
|
576
|
-
overflows.push(overflow[side]);
|
|
577
|
-
}
|
|
578
|
-
if (checkCrossAxis) {
|
|
579
|
-
const {
|
|
580
|
-
main,
|
|
581
|
-
cross
|
|
582
|
-
} = getAlignmentSides(placement, rects, rtl);
|
|
583
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
584
|
-
}
|
|
585
|
-
overflowsData = [...overflowsData, {
|
|
586
|
-
placement,
|
|
587
|
-
overflows
|
|
588
|
-
}];
|
|
589
|
-
|
|
590
|
-
// One or more sides is overflowing.
|
|
591
|
-
if (!overflows.every(side => side <= 0)) {
|
|
592
|
-
var _middlewareData$flip2, _overflowsData$find;
|
|
593
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
594
|
-
const nextPlacement = placements[nextIndex];
|
|
595
|
-
if (nextPlacement) {
|
|
596
|
-
// Try next placement and re-run the lifecycle.
|
|
597
|
-
return {
|
|
598
|
-
data: {
|
|
599
|
-
index: nextIndex,
|
|
600
|
-
overflows: overflowsData
|
|
601
|
-
},
|
|
602
|
-
reset: {
|
|
603
|
-
placement: nextPlacement
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// First, try to use the one that fits on mainAxis side of overflow.
|
|
609
|
-
let resetPlacement = (_overflowsData$find = overflowsData.find(d => d.overflows[0] <= 0)) == null ? void 0 : _overflowsData$find.placement;
|
|
610
|
-
|
|
611
|
-
// Otherwise fallback.
|
|
612
|
-
if (!resetPlacement) {
|
|
613
|
-
switch (fallbackStrategy) {
|
|
614
|
-
case 'bestFit':
|
|
615
|
-
{
|
|
616
|
-
var _overflowsData$map$so;
|
|
617
|
-
const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
|
|
618
|
-
if (placement) {
|
|
619
|
-
resetPlacement = placement;
|
|
620
|
-
}
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
case 'initialPlacement':
|
|
624
|
-
resetPlacement = initialPlacement;
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
if (placement !== resetPlacement) {
|
|
629
|
-
return {
|
|
630
|
-
reset: {
|
|
631
|
-
placement: resetPlacement
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
return {};
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* Provides improved positioning for inline reference elements that can span
|
|
643
|
-
* over multiple lines, such as hyperlinks or range selections.
|
|
644
|
-
* @see https://floating-ui.com/docs/inline
|
|
645
|
-
*/
|
|
646
|
-
const inline = function (options) {
|
|
647
|
-
if (options === void 0) {
|
|
648
|
-
options = {};
|
|
649
|
-
}
|
|
650
|
-
return {
|
|
651
|
-
name: 'inline',
|
|
652
|
-
options,
|
|
653
|
-
async fn(middlewareArguments) {
|
|
654
|
-
const {
|
|
655
|
-
placement,
|
|
656
|
-
elements,
|
|
657
|
-
rects,
|
|
658
|
-
platform,
|
|
659
|
-
strategy
|
|
660
|
-
} = middlewareArguments;
|
|
661
|
-
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
662
|
-
// ClientRect's bounds, despite the event listener being triggered. A
|
|
663
|
-
// padding of 2 seems to handle this issue.
|
|
664
|
-
const {
|
|
665
|
-
padding = 2,
|
|
666
|
-
x,
|
|
667
|
-
y
|
|
668
|
-
} = options;
|
|
669
|
-
const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
670
|
-
rect: rects.reference,
|
|
671
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
672
|
-
strategy
|
|
673
|
-
}) : rects.reference);
|
|
674
|
-
const clientRects = (await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || [];
|
|
675
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
676
|
-
function getBoundingClientRect() {
|
|
677
|
-
// There are two rects and they are disjoined.
|
|
678
|
-
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
679
|
-
// Find the first rect in which the point is fully inside.
|
|
680
|
-
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// There are 2 or more connected rects.
|
|
684
|
-
if (clientRects.length >= 2) {
|
|
685
|
-
if (getMainAxisFromPlacement(placement) === 'x') {
|
|
686
|
-
const firstRect = clientRects[0];
|
|
687
|
-
const lastRect = clientRects[clientRects.length - 1];
|
|
688
|
-
const isTop = getSide(placement) === 'top';
|
|
689
|
-
const top = firstRect.top;
|
|
690
|
-
const bottom = lastRect.bottom;
|
|
691
|
-
const left = isTop ? firstRect.left : lastRect.left;
|
|
692
|
-
const right = isTop ? firstRect.right : lastRect.right;
|
|
693
|
-
const width = right - left;
|
|
694
|
-
const height = bottom - top;
|
|
695
|
-
return {
|
|
696
|
-
top,
|
|
697
|
-
bottom,
|
|
698
|
-
left,
|
|
699
|
-
right,
|
|
700
|
-
width,
|
|
701
|
-
height,
|
|
702
|
-
x: left,
|
|
703
|
-
y: top
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
const isLeftSide = getSide(placement) === 'left';
|
|
707
|
-
const maxRight = max$1(...clientRects.map(rect => rect.right));
|
|
708
|
-
const minLeft = min$1(...clientRects.map(rect => rect.left));
|
|
709
|
-
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
710
|
-
const top = measureRects[0].top;
|
|
711
|
-
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
712
|
-
const left = minLeft;
|
|
713
|
-
const right = maxRight;
|
|
714
|
-
const width = right - left;
|
|
715
|
-
const height = bottom - top;
|
|
716
|
-
return {
|
|
717
|
-
top,
|
|
718
|
-
bottom,
|
|
719
|
-
left,
|
|
720
|
-
right,
|
|
721
|
-
width,
|
|
722
|
-
height,
|
|
723
|
-
x: left,
|
|
724
|
-
y: top
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
return fallback;
|
|
728
|
-
}
|
|
729
|
-
const resetRects = await platform.getElementRects({
|
|
730
|
-
reference: {
|
|
731
|
-
getBoundingClientRect
|
|
732
|
-
},
|
|
733
|
-
floating: elements.floating,
|
|
734
|
-
strategy
|
|
735
|
-
});
|
|
736
|
-
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
737
|
-
return {
|
|
738
|
-
reset: {
|
|
739
|
-
rects: resetRects
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
return {};
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
async function convertValueToCoords(middlewareArguments, value) {
|
|
749
|
-
const {
|
|
750
|
-
placement,
|
|
751
|
-
platform,
|
|
752
|
-
elements
|
|
753
|
-
} = middlewareArguments;
|
|
754
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
755
|
-
const side = getSide(placement);
|
|
756
|
-
const alignment = getAlignment(placement);
|
|
757
|
-
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
758
|
-
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
759
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
760
|
-
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
|
|
761
|
-
|
|
762
|
-
// eslint-disable-next-line prefer-const
|
|
763
|
-
let {
|
|
764
|
-
mainAxis,
|
|
765
|
-
crossAxis,
|
|
766
|
-
alignmentAxis
|
|
767
|
-
} = typeof rawValue === 'number' ? {
|
|
768
|
-
mainAxis: rawValue,
|
|
769
|
-
crossAxis: 0,
|
|
770
|
-
alignmentAxis: null
|
|
771
|
-
} : {
|
|
772
|
-
mainAxis: 0,
|
|
773
|
-
crossAxis: 0,
|
|
774
|
-
alignmentAxis: null,
|
|
775
|
-
...rawValue
|
|
776
|
-
};
|
|
777
|
-
if (alignment && typeof alignmentAxis === 'number') {
|
|
778
|
-
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
779
|
-
}
|
|
780
|
-
return isVertical ? {
|
|
781
|
-
x: crossAxis * crossAxisMulti,
|
|
782
|
-
y: mainAxis * mainAxisMulti
|
|
783
|
-
} : {
|
|
784
|
-
x: mainAxis * mainAxisMulti,
|
|
785
|
-
y: crossAxis * crossAxisMulti
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
/**
|
|
790
|
-
* Displaces the floating element from its reference element.
|
|
791
|
-
* @see https://floating-ui.com/docs/offset
|
|
792
|
-
*/
|
|
793
|
-
const offset = function (value) {
|
|
794
|
-
if (value === void 0) {
|
|
795
|
-
value = 0;
|
|
796
|
-
}
|
|
797
|
-
return {
|
|
798
|
-
name: 'offset',
|
|
799
|
-
options: value,
|
|
800
|
-
async fn(middlewareArguments) {
|
|
801
|
-
const {
|
|
802
|
-
x,
|
|
803
|
-
y
|
|
804
|
-
} = middlewareArguments;
|
|
805
|
-
const diffCoords = await convertValueToCoords(middlewareArguments, value);
|
|
806
|
-
return {
|
|
807
|
-
x: x + diffCoords.x,
|
|
808
|
-
y: y + diffCoords.y,
|
|
809
|
-
data: diffCoords
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
function getCrossAxis(axis) {
|
|
816
|
-
return axis === 'x' ? 'y' : 'x';
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* Shifts the floating element in order to keep it in view when it will overflow
|
|
821
|
-
* a clipping boundary.
|
|
822
|
-
* @see https://floating-ui.com/docs/shift
|
|
823
|
-
*/
|
|
824
|
-
const shift = function (options) {
|
|
825
|
-
if (options === void 0) {
|
|
826
|
-
options = {};
|
|
827
|
-
}
|
|
828
|
-
return {
|
|
829
|
-
name: 'shift',
|
|
830
|
-
options,
|
|
831
|
-
async fn(middlewareArguments) {
|
|
832
|
-
const {
|
|
833
|
-
x,
|
|
834
|
-
y,
|
|
835
|
-
placement
|
|
836
|
-
} = middlewareArguments;
|
|
837
|
-
const {
|
|
838
|
-
mainAxis: checkMainAxis = true,
|
|
839
|
-
crossAxis: checkCrossAxis = false,
|
|
840
|
-
limiter = {
|
|
841
|
-
fn: _ref => {
|
|
842
|
-
let {
|
|
843
|
-
x,
|
|
844
|
-
y
|
|
845
|
-
} = _ref;
|
|
846
|
-
return {
|
|
847
|
-
x,
|
|
848
|
-
y
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
},
|
|
852
|
-
...detectOverflowOptions
|
|
853
|
-
} = options;
|
|
854
|
-
const coords = {
|
|
855
|
-
x,
|
|
856
|
-
y
|
|
857
|
-
};
|
|
858
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
859
|
-
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
860
|
-
const crossAxis = getCrossAxis(mainAxis);
|
|
861
|
-
let mainAxisCoord = coords[mainAxis];
|
|
862
|
-
let crossAxisCoord = coords[crossAxis];
|
|
863
|
-
if (checkMainAxis) {
|
|
864
|
-
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
865
|
-
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
866
|
-
const min = mainAxisCoord + overflow[minSide];
|
|
867
|
-
const max = mainAxisCoord - overflow[maxSide];
|
|
868
|
-
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
869
|
-
}
|
|
870
|
-
if (checkCrossAxis) {
|
|
871
|
-
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
872
|
-
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
873
|
-
const min = crossAxisCoord + overflow[minSide];
|
|
874
|
-
const max = crossAxisCoord - overflow[maxSide];
|
|
875
|
-
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
876
|
-
}
|
|
877
|
-
const limitedCoords = limiter.fn({
|
|
878
|
-
...middlewareArguments,
|
|
879
|
-
[mainAxis]: mainAxisCoord,
|
|
880
|
-
[crossAxis]: crossAxisCoord
|
|
881
|
-
});
|
|
882
|
-
return {
|
|
883
|
-
...limitedCoords,
|
|
884
|
-
data: {
|
|
885
|
-
x: limitedCoords.x - x,
|
|
886
|
-
y: limitedCoords.y - y
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* Provides data to change the size of the floating element. For instance,
|
|
895
|
-
* prevent it from overflowing its clipping boundary or match the width of the
|
|
896
|
-
* reference element.
|
|
897
|
-
* @see https://floating-ui.com/docs/size
|
|
898
|
-
*/
|
|
899
|
-
const size = function (options) {
|
|
900
|
-
if (options === void 0) {
|
|
901
|
-
options = {};
|
|
902
|
-
}
|
|
903
|
-
return {
|
|
904
|
-
name: 'size',
|
|
905
|
-
options,
|
|
906
|
-
async fn(middlewareArguments) {
|
|
907
|
-
const {
|
|
908
|
-
placement,
|
|
909
|
-
rects,
|
|
910
|
-
platform,
|
|
911
|
-
elements
|
|
912
|
-
} = middlewareArguments;
|
|
913
|
-
const {
|
|
914
|
-
apply = () => {},
|
|
915
|
-
...detectOverflowOptions
|
|
916
|
-
} = options;
|
|
917
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
918
|
-
const side = getSide(placement);
|
|
919
|
-
const alignment = getAlignment(placement);
|
|
920
|
-
let heightSide;
|
|
921
|
-
let widthSide;
|
|
922
|
-
if (side === 'top' || side === 'bottom') {
|
|
923
|
-
heightSide = side;
|
|
924
|
-
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
925
|
-
} else {
|
|
926
|
-
widthSide = side;
|
|
927
|
-
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
928
|
-
}
|
|
929
|
-
const xMin = max$1(overflow.left, 0);
|
|
930
|
-
const xMax = max$1(overflow.right, 0);
|
|
931
|
-
const yMin = max$1(overflow.top, 0);
|
|
932
|
-
const yMax = max$1(overflow.bottom, 0);
|
|
933
|
-
const dimensions = {
|
|
934
|
-
availableHeight: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom)) : overflow[heightSide]),
|
|
935
|
-
availableWidth: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right)) : overflow[widthSide])
|
|
936
|
-
};
|
|
937
|
-
await apply({
|
|
938
|
-
...middlewareArguments,
|
|
939
|
-
...dimensions
|
|
940
|
-
});
|
|
941
|
-
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
942
|
-
if (rects.floating.width !== nextDimensions.width || rects.floating.height !== nextDimensions.height) {
|
|
943
|
-
return {
|
|
944
|
-
reset: {
|
|
945
|
-
rects: true
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
return {};
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
function getWindow(node) {
|
|
955
|
-
var _node$ownerDocument;
|
|
956
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
function getComputedStyle$1(element) {
|
|
960
|
-
return getWindow(element).getComputedStyle(element);
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
const min = Math.min;
|
|
964
|
-
const max = Math.max;
|
|
965
|
-
const round = Math.round;
|
|
966
|
-
|
|
967
|
-
function getCssDimensions(element) {
|
|
968
|
-
const css = getComputedStyle$1(element);
|
|
969
|
-
let width = parseFloat(css.width);
|
|
970
|
-
let height = parseFloat(css.height);
|
|
971
|
-
const offsetWidth = element.offsetWidth;
|
|
972
|
-
const offsetHeight = element.offsetHeight;
|
|
973
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
974
|
-
if (shouldFallback) {
|
|
975
|
-
width = offsetWidth;
|
|
976
|
-
height = offsetHeight;
|
|
977
|
-
}
|
|
978
|
-
return {
|
|
979
|
-
width,
|
|
980
|
-
height,
|
|
981
|
-
fallback: shouldFallback
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
function getNodeName(node) {
|
|
986
|
-
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
let uaString;
|
|
990
|
-
function getUAString() {
|
|
991
|
-
if (uaString) {
|
|
992
|
-
return uaString;
|
|
993
|
-
}
|
|
994
|
-
const uaData = navigator.userAgentData;
|
|
995
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
996
|
-
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
997
|
-
return uaString;
|
|
998
|
-
}
|
|
999
|
-
return navigator.userAgent;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
function isHTMLElement(value) {
|
|
1003
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
1004
|
-
}
|
|
1005
|
-
function isElement(value) {
|
|
1006
|
-
return value instanceof getWindow(value).Element;
|
|
1007
|
-
}
|
|
1008
|
-
function isNode(value) {
|
|
1009
|
-
return value instanceof getWindow(value).Node;
|
|
1010
|
-
}
|
|
1011
|
-
function isShadowRoot(node) {
|
|
1012
|
-
// Browsers without `ShadowRoot` support.
|
|
1013
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
1014
|
-
return false;
|
|
1015
|
-
}
|
|
1016
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
1017
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1018
|
-
}
|
|
1019
|
-
function isOverflowElement(element) {
|
|
1020
|
-
const {
|
|
1021
|
-
overflow,
|
|
1022
|
-
overflowX,
|
|
1023
|
-
overflowY,
|
|
1024
|
-
display
|
|
1025
|
-
} = getComputedStyle$1(element);
|
|
1026
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
1027
|
-
}
|
|
1028
|
-
function isTableElement(element) {
|
|
1029
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
1030
|
-
}
|
|
1031
|
-
function isContainingBlock(element) {
|
|
1032
|
-
// TODO: Try to use feature detection here instead.
|
|
1033
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
1034
|
-
const css = getComputedStyle$1(element);
|
|
1035
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
1036
|
-
|
|
1037
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
1038
|
-
// create a containing block.
|
|
1039
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1040
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
|
|
1041
|
-
// Add type check for old browsers.
|
|
1042
|
-
const contain = css.contain;
|
|
1043
|
-
return contain != null ? contain.includes(value) : false;
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
function isLayoutViewport() {
|
|
1047
|
-
// TODO: Try to use feature detection here instead. Feature detection for
|
|
1048
|
-
// this can fail in various ways, making the userAgent check the most:
|
|
1049
|
-
// reliable:
|
|
1050
|
-
// • Always-visible scrollbar or not
|
|
1051
|
-
// • Width of <html>
|
|
1052
|
-
|
|
1053
|
-
// Not Safari.
|
|
1054
|
-
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
1055
|
-
}
|
|
1056
|
-
function isLastTraversableNode(node) {
|
|
1057
|
-
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
function unwrapElement(element) {
|
|
1061
|
-
return !isElement(element) ? element.contextElement : element;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
const FALLBACK_SCALE = {
|
|
1065
|
-
x: 1,
|
|
1066
|
-
y: 1
|
|
1067
|
-
};
|
|
1068
|
-
function getScale(element) {
|
|
1069
|
-
const domElement = unwrapElement(element);
|
|
1070
|
-
if (!isHTMLElement(domElement)) {
|
|
1071
|
-
return FALLBACK_SCALE;
|
|
1072
|
-
}
|
|
1073
|
-
const rect = domElement.getBoundingClientRect();
|
|
1074
|
-
const {
|
|
1075
|
-
width,
|
|
1076
|
-
height,
|
|
1077
|
-
fallback
|
|
1078
|
-
} = getCssDimensions(domElement);
|
|
1079
|
-
let x = (fallback ? round(rect.width) : rect.width) / width;
|
|
1080
|
-
let y = (fallback ? round(rect.height) : rect.height) / height;
|
|
1081
|
-
|
|
1082
|
-
// 0, NaN, or Infinity should always fallback to 1.
|
|
1083
|
-
|
|
1084
|
-
if (!x || !Number.isFinite(x)) {
|
|
1085
|
-
x = 1;
|
|
1086
|
-
}
|
|
1087
|
-
if (!y || !Number.isFinite(y)) {
|
|
1088
|
-
y = 1;
|
|
1089
|
-
}
|
|
1090
|
-
return {
|
|
1091
|
-
x,
|
|
1092
|
-
y
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1097
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
1098
|
-
if (includeScale === void 0) {
|
|
1099
|
-
includeScale = false;
|
|
1100
|
-
}
|
|
1101
|
-
if (isFixedStrategy === void 0) {
|
|
1102
|
-
isFixedStrategy = false;
|
|
1103
|
-
}
|
|
1104
|
-
const clientRect = element.getBoundingClientRect();
|
|
1105
|
-
const domElement = unwrapElement(element);
|
|
1106
|
-
let scale = FALLBACK_SCALE;
|
|
1107
|
-
if (includeScale) {
|
|
1108
|
-
if (offsetParent) {
|
|
1109
|
-
if (isElement(offsetParent)) {
|
|
1110
|
-
scale = getScale(offsetParent);
|
|
1111
|
-
}
|
|
1112
|
-
} else {
|
|
1113
|
-
scale = getScale(element);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
const win = domElement ? getWindow(domElement) : window;
|
|
1117
|
-
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
1118
|
-
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
|
|
1119
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
1120
|
-
let width = clientRect.width / scale.x;
|
|
1121
|
-
let height = clientRect.height / scale.y;
|
|
1122
|
-
if (domElement) {
|
|
1123
|
-
const win = getWindow(domElement);
|
|
1124
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1125
|
-
let currentIFrame = win.frameElement;
|
|
1126
|
-
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
1127
|
-
const iframeScale = getScale(currentIFrame);
|
|
1128
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1129
|
-
const css = getComputedStyle(currentIFrame);
|
|
1130
|
-
iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1131
|
-
iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1132
|
-
x *= iframeScale.x;
|
|
1133
|
-
y *= iframeScale.y;
|
|
1134
|
-
width *= iframeScale.x;
|
|
1135
|
-
height *= iframeScale.y;
|
|
1136
|
-
x += iframeRect.x;
|
|
1137
|
-
y += iframeRect.y;
|
|
1138
|
-
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
return {
|
|
1142
|
-
width,
|
|
1143
|
-
height,
|
|
1144
|
-
top: y,
|
|
1145
|
-
right: x + width,
|
|
1146
|
-
bottom: y + height,
|
|
1147
|
-
left: x,
|
|
1148
|
-
x,
|
|
1149
|
-
y
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
function getDocumentElement(node) {
|
|
1154
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
function getNodeScroll(element) {
|
|
1158
|
-
if (isElement(element)) {
|
|
1159
|
-
return {
|
|
1160
|
-
scrollLeft: element.scrollLeft,
|
|
1161
|
-
scrollTop: element.scrollTop
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
return {
|
|
1165
|
-
scrollLeft: element.pageXOffset,
|
|
1166
|
-
scrollTop: element.pageYOffset
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1171
|
-
let {
|
|
1172
|
-
rect,
|
|
1173
|
-
offsetParent,
|
|
1174
|
-
strategy
|
|
1175
|
-
} = _ref;
|
|
1176
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1177
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1178
|
-
if (offsetParent === documentElement) {
|
|
1179
|
-
return rect;
|
|
1180
|
-
}
|
|
1181
|
-
let scroll = {
|
|
1182
|
-
scrollLeft: 0,
|
|
1183
|
-
scrollTop: 0
|
|
1184
|
-
};
|
|
1185
|
-
let scale = {
|
|
1186
|
-
x: 1,
|
|
1187
|
-
y: 1
|
|
1188
|
-
};
|
|
1189
|
-
const offsets = {
|
|
1190
|
-
x: 0,
|
|
1191
|
-
y: 0
|
|
1192
|
-
};
|
|
1193
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1194
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1195
|
-
scroll = getNodeScroll(offsetParent);
|
|
1196
|
-
}
|
|
1197
|
-
if (isHTMLElement(offsetParent)) {
|
|
1198
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1199
|
-
scale = getScale(offsetParent);
|
|
1200
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1201
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
return {
|
|
1205
|
-
width: rect.width * scale.x,
|
|
1206
|
-
height: rect.height * scale.y,
|
|
1207
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
1208
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
1209
|
-
};
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
function getWindowScrollBarX(element) {
|
|
1213
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1214
|
-
// incorrect for RTL.
|
|
1215
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
// Gets the entire size of the scrollable document area, even extending outside
|
|
1219
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1220
|
-
function getDocumentRect(element) {
|
|
1221
|
-
const html = getDocumentElement(element);
|
|
1222
|
-
const scroll = getNodeScroll(element);
|
|
1223
|
-
const body = element.ownerDocument.body;
|
|
1224
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1225
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1226
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1227
|
-
const y = -scroll.scrollTop;
|
|
1228
|
-
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
1229
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1230
|
-
}
|
|
1231
|
-
return {
|
|
1232
|
-
width,
|
|
1233
|
-
height,
|
|
1234
|
-
x,
|
|
1235
|
-
y
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
function getParentNode(node) {
|
|
1240
|
-
if (getNodeName(node) === 'html') {
|
|
1241
|
-
return node;
|
|
1242
|
-
}
|
|
1243
|
-
const result =
|
|
1244
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
1245
|
-
node.assignedSlot ||
|
|
1246
|
-
// DOM Element detected.
|
|
1247
|
-
node.parentNode ||
|
|
1248
|
-
// ShadowRoot detected.
|
|
1249
|
-
isShadowRoot(node) && node.host ||
|
|
1250
|
-
// Fallback.
|
|
1251
|
-
getDocumentElement(node);
|
|
1252
|
-
return isShadowRoot(result) ? result.host : result;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
function getNearestOverflowAncestor(node) {
|
|
1256
|
-
const parentNode = getParentNode(node);
|
|
1257
|
-
if (isLastTraversableNode(parentNode)) {
|
|
1258
|
-
// `getParentNode` will never return a `Document` due to the fallback
|
|
1259
|
-
// check, so it's either the <html> or <body> element.
|
|
1260
|
-
return parentNode.ownerDocument.body;
|
|
1261
|
-
}
|
|
1262
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1263
|
-
return parentNode;
|
|
1264
|
-
}
|
|
1265
|
-
return getNearestOverflowAncestor(parentNode);
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
function getOverflowAncestors(node, list) {
|
|
1269
|
-
var _node$ownerDocument;
|
|
1270
|
-
if (list === void 0) {
|
|
1271
|
-
list = [];
|
|
1272
|
-
}
|
|
1273
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1274
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1275
|
-
const win = getWindow(scrollableAncestor);
|
|
1276
|
-
if (isBody) {
|
|
1277
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
1278
|
-
}
|
|
1279
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
function getViewportRect(element, strategy) {
|
|
1283
|
-
const win = getWindow(element);
|
|
1284
|
-
const html = getDocumentElement(element);
|
|
1285
|
-
const visualViewport = win.visualViewport;
|
|
1286
|
-
let width = html.clientWidth;
|
|
1287
|
-
let height = html.clientHeight;
|
|
1288
|
-
let x = 0;
|
|
1289
|
-
let y = 0;
|
|
1290
|
-
if (visualViewport) {
|
|
1291
|
-
width = visualViewport.width;
|
|
1292
|
-
height = visualViewport.height;
|
|
1293
|
-
const layoutViewport = isLayoutViewport();
|
|
1294
|
-
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
1295
|
-
x = visualViewport.offsetLeft;
|
|
1296
|
-
y = visualViewport.offsetTop;
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
return {
|
|
1300
|
-
width,
|
|
1301
|
-
height,
|
|
1302
|
-
x,
|
|
1303
|
-
y
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1308
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1309
|
-
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1310
|
-
const top = clientRect.top + element.clientTop;
|
|
1311
|
-
const left = clientRect.left + element.clientLeft;
|
|
1312
|
-
const scale = isHTMLElement(element) ? getScale(element) : {
|
|
1313
|
-
x: 1,
|
|
1314
|
-
y: 1
|
|
1315
|
-
};
|
|
1316
|
-
const width = element.clientWidth * scale.x;
|
|
1317
|
-
const height = element.clientHeight * scale.y;
|
|
1318
|
-
const x = left * scale.x;
|
|
1319
|
-
const y = top * scale.y;
|
|
1320
|
-
return {
|
|
1321
|
-
width,
|
|
1322
|
-
height,
|
|
1323
|
-
x,
|
|
1324
|
-
y
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1328
|
-
if (clippingAncestor === 'viewport') {
|
|
1329
|
-
return rectToClientRect(getViewportRect(element, strategy));
|
|
1330
|
-
}
|
|
1331
|
-
if (isElement(clippingAncestor)) {
|
|
1332
|
-
return rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy));
|
|
1333
|
-
}
|
|
1334
|
-
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1338
|
-
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1339
|
-
// of the given element up the tree.
|
|
1340
|
-
function getClippingElementAncestors(element, cache) {
|
|
1341
|
-
const cachedResult = cache.get(element);
|
|
1342
|
-
if (cachedResult) {
|
|
1343
|
-
return cachedResult;
|
|
1344
|
-
}
|
|
1345
|
-
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1346
|
-
let currentContainingBlockComputedStyle = null;
|
|
1347
|
-
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
1348
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1349
|
-
|
|
1350
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1351
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1352
|
-
const computedStyle = getComputedStyle$1(currentNode);
|
|
1353
|
-
const containingBlock = isContainingBlock(currentNode);
|
|
1354
|
-
const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position);
|
|
1355
|
-
if (shouldDropCurrentNode) {
|
|
1356
|
-
// Drop non-containing blocks.
|
|
1357
|
-
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1358
|
-
} else {
|
|
1359
|
-
// Record last containing block for next iteration.
|
|
1360
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1361
|
-
}
|
|
1362
|
-
currentNode = getParentNode(currentNode);
|
|
1363
|
-
}
|
|
1364
|
-
cache.set(element, result);
|
|
1365
|
-
return result;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
// Gets the maximum area that the element is visible in due to any number of
|
|
1369
|
-
// clipping ancestors.
|
|
1370
|
-
function getClippingRect(_ref) {
|
|
1371
|
-
let {
|
|
1372
|
-
element,
|
|
1373
|
-
boundary,
|
|
1374
|
-
rootBoundary,
|
|
1375
|
-
strategy
|
|
1376
|
-
} = _ref;
|
|
1377
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1378
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1379
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1380
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1381
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1382
|
-
accRect.top = max(rect.top, accRect.top);
|
|
1383
|
-
accRect.right = min(rect.right, accRect.right);
|
|
1384
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1385
|
-
accRect.left = max(rect.left, accRect.left);
|
|
1386
|
-
return accRect;
|
|
1387
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1388
|
-
return {
|
|
1389
|
-
width: clippingRect.right - clippingRect.left,
|
|
1390
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1391
|
-
x: clippingRect.left,
|
|
1392
|
-
y: clippingRect.top
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
function getDimensions(element) {
|
|
1397
|
-
if (isHTMLElement(element)) {
|
|
1398
|
-
return getCssDimensions(element);
|
|
1399
|
-
}
|
|
1400
|
-
return element.getBoundingClientRect();
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
function getTrueOffsetParent(element) {
|
|
1404
|
-
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1405
|
-
return null;
|
|
1406
|
-
}
|
|
1407
|
-
return element.offsetParent;
|
|
1408
|
-
}
|
|
1409
|
-
function getContainingBlock(element) {
|
|
1410
|
-
let currentNode = getParentNode(element);
|
|
1411
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1412
|
-
if (isContainingBlock(currentNode)) {
|
|
1413
|
-
return currentNode;
|
|
1414
|
-
} else {
|
|
1415
|
-
currentNode = getParentNode(currentNode);
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
return null;
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1422
|
-
// such as table ancestors and cross browser bugs.
|
|
1423
|
-
function getOffsetParent(element) {
|
|
1424
|
-
const window = getWindow(element);
|
|
1425
|
-
let offsetParent = getTrueOffsetParent(element);
|
|
1426
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
|
1427
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
1428
|
-
}
|
|
1429
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
1430
|
-
return window;
|
|
1431
|
-
}
|
|
1432
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1436
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1437
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1438
|
-
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
|
|
1439
|
-
let scroll = {
|
|
1440
|
-
scrollLeft: 0,
|
|
1441
|
-
scrollTop: 0
|
|
1442
|
-
};
|
|
1443
|
-
const offsets = {
|
|
1444
|
-
x: 0,
|
|
1445
|
-
y: 0
|
|
1446
|
-
};
|
|
1447
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1448
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1449
|
-
scroll = getNodeScroll(offsetParent);
|
|
1450
|
-
}
|
|
1451
|
-
if (isHTMLElement(offsetParent)) {
|
|
1452
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1453
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1454
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1455
|
-
} else if (documentElement) {
|
|
1456
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
return {
|
|
1460
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1461
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1462
|
-
width: rect.width,
|
|
1463
|
-
height: rect.height
|
|
1464
|
-
};
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
const platform = {
|
|
1468
|
-
getClippingRect,
|
|
1469
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1470
|
-
isElement,
|
|
1471
|
-
getDimensions,
|
|
1472
|
-
getOffsetParent,
|
|
1473
|
-
getDocumentElement,
|
|
1474
|
-
getScale,
|
|
1475
|
-
async getElementRects(_ref) {
|
|
1476
|
-
let {
|
|
1477
|
-
reference,
|
|
1478
|
-
floating,
|
|
1479
|
-
strategy
|
|
1480
|
-
} = _ref;
|
|
1481
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1482
|
-
const getDimensionsFn = this.getDimensions;
|
|
1483
|
-
return {
|
|
1484
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1485
|
-
floating: {
|
|
1486
|
-
x: 0,
|
|
1487
|
-
y: 0,
|
|
1488
|
-
...(await getDimensionsFn(floating))
|
|
1489
|
-
}
|
|
1490
|
-
};
|
|
1491
|
-
},
|
|
1492
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
1493
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
1494
|
-
};
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1498
|
-
* next to a reference element when it is given a certain CSS positioning
|
|
1499
|
-
* strategy.
|
|
1500
|
-
*/
|
|
1501
|
-
const computePosition = (reference, floating, options) => {
|
|
1502
|
-
// This caches the expensive `getClippingElementAncestors` function so that
|
|
1503
|
-
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
1504
|
-
// single call. If other functions become expensive, we can add them as well.
|
|
1505
|
-
const cache = new Map();
|
|
1506
|
-
const mergedOptions = {
|
|
1507
|
-
platform,
|
|
1508
|
-
...options
|
|
1509
|
-
};
|
|
1510
|
-
const platformWithCache = {
|
|
1511
|
-
...mergedOptions.platform,
|
|
1512
|
-
_c: cache
|
|
1513
|
-
};
|
|
1514
|
-
return computePosition$1(reference, floating, {
|
|
1515
|
-
...mergedOptions,
|
|
1516
|
-
platform: platformWithCache
|
|
1517
|
-
});
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
11
|
var jsxRuntime = {exports: {}};
|
|
1521
12
|
|
|
1522
13
|
var reactJsxRuntime_development = {};
|
|
@@ -1795,832 +286,2074 @@
|
|
|
1795
286
|
}
|
|
1796
287
|
}
|
|
1797
288
|
|
|
1798
|
-
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
289
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
290
|
+
{
|
|
291
|
+
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
292
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
293
|
+
|
|
294
|
+
for (var typeSpecName in typeSpecs) {
|
|
295
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
296
|
+
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
297
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
298
|
+
// After these have been cleaned up, we'll let them throw.
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
302
|
+
// behavior as without this statement except with a better message.
|
|
303
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
304
|
+
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
305
|
+
err.name = 'Invariant Violation';
|
|
306
|
+
throw err;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
310
|
+
} catch (ex) {
|
|
311
|
+
error$1 = ex;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
315
|
+
setCurrentlyValidatingElement(element);
|
|
316
|
+
|
|
317
|
+
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
318
|
+
|
|
319
|
+
setCurrentlyValidatingElement(null);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
323
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
324
|
+
// same error.
|
|
325
|
+
loggedTypeFailures[error$1.message] = true;
|
|
326
|
+
setCurrentlyValidatingElement(element);
|
|
327
|
+
|
|
328
|
+
error('Failed %s type: %s', location, error$1.message);
|
|
329
|
+
|
|
330
|
+
setCurrentlyValidatingElement(null);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
338
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
339
|
+
var RESERVED_PROPS = {
|
|
340
|
+
key: true,
|
|
341
|
+
ref: true,
|
|
342
|
+
__self: true,
|
|
343
|
+
__source: true
|
|
344
|
+
};
|
|
345
|
+
var specialPropKeyWarningShown;
|
|
346
|
+
var specialPropRefWarningShown;
|
|
347
|
+
var didWarnAboutStringRefs;
|
|
348
|
+
|
|
349
|
+
{
|
|
350
|
+
didWarnAboutStringRefs = {};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function hasValidRef(config) {
|
|
354
|
+
{
|
|
355
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
356
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
357
|
+
|
|
358
|
+
if (getter && getter.isReactWarning) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return config.ref !== undefined;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function hasValidKey(config) {
|
|
368
|
+
{
|
|
369
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
370
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
371
|
+
|
|
372
|
+
if (getter && getter.isReactWarning) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return config.key !== undefined;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
382
|
+
{
|
|
383
|
+
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
384
|
+
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
385
|
+
|
|
386
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
387
|
+
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
|
388
|
+
|
|
389
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
396
|
+
{
|
|
397
|
+
var warnAboutAccessingKey = function () {
|
|
398
|
+
if (!specialPropKeyWarningShown) {
|
|
399
|
+
specialPropKeyWarningShown = true;
|
|
400
|
+
|
|
401
|
+
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
406
|
+
Object.defineProperty(props, 'key', {
|
|
407
|
+
get: warnAboutAccessingKey,
|
|
408
|
+
configurable: true
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
414
|
+
{
|
|
415
|
+
var warnAboutAccessingRef = function () {
|
|
416
|
+
if (!specialPropRefWarningShown) {
|
|
417
|
+
specialPropRefWarningShown = true;
|
|
418
|
+
|
|
419
|
+
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
424
|
+
Object.defineProperty(props, 'ref', {
|
|
425
|
+
get: warnAboutAccessingRef,
|
|
426
|
+
configurable: true
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
432
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
433
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
434
|
+
* if something is a React Element.
|
|
435
|
+
*
|
|
436
|
+
* @param {*} type
|
|
437
|
+
* @param {*} props
|
|
438
|
+
* @param {*} key
|
|
439
|
+
* @param {string|object} ref
|
|
440
|
+
* @param {*} owner
|
|
441
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
442
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
443
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
444
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
445
|
+
* change in behavior.
|
|
446
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
447
|
+
* indicating filename, line number, and/or other information.
|
|
448
|
+
* @internal
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
453
|
+
var element = {
|
|
454
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
455
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
456
|
+
// Built-in properties that belong on the element
|
|
457
|
+
type: type,
|
|
458
|
+
key: key,
|
|
459
|
+
ref: ref,
|
|
460
|
+
props: props,
|
|
461
|
+
// Record the component responsible for creating this element.
|
|
462
|
+
_owner: owner
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
{
|
|
466
|
+
// The validation flag is currently mutative. We put it on
|
|
467
|
+
// an external backing store so that we can freeze the whole object.
|
|
468
|
+
// This can be replaced with a WeakMap once they are implemented in
|
|
469
|
+
// commonly used development environments.
|
|
470
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
471
|
+
// the validation flag non-enumerable (where possible, which should
|
|
472
|
+
// include every environment we run tests in), so the test framework
|
|
473
|
+
// ignores it.
|
|
474
|
+
|
|
475
|
+
Object.defineProperty(element._store, 'validated', {
|
|
476
|
+
configurable: false,
|
|
477
|
+
enumerable: false,
|
|
478
|
+
writable: true,
|
|
479
|
+
value: false
|
|
480
|
+
}); // self and source are DEV only properties.
|
|
481
|
+
|
|
482
|
+
Object.defineProperty(element, '_self', {
|
|
483
|
+
configurable: false,
|
|
484
|
+
enumerable: false,
|
|
485
|
+
writable: false,
|
|
486
|
+
value: self
|
|
487
|
+
}); // Two elements created in two different places should be considered
|
|
488
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
489
|
+
|
|
490
|
+
Object.defineProperty(element, '_source', {
|
|
491
|
+
configurable: false,
|
|
492
|
+
enumerable: false,
|
|
493
|
+
writable: false,
|
|
494
|
+
value: source
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
if (Object.freeze) {
|
|
498
|
+
Object.freeze(element.props);
|
|
499
|
+
Object.freeze(element);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return element;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
507
|
+
* @param {*} type
|
|
508
|
+
* @param {object} props
|
|
509
|
+
* @param {string} key
|
|
510
|
+
*/
|
|
511
|
+
|
|
512
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
1799
513
|
{
|
|
1800
|
-
|
|
1801
|
-
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
514
|
+
var propName; // Reserved names are extracted
|
|
1802
515
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
516
|
+
var props = {};
|
|
517
|
+
var key = null;
|
|
518
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
519
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
520
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
521
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
522
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
523
|
+
// key is explicitly declared to be undefined or not.
|
|
1808
524
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
1813
|
-
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
1814
|
-
err.name = 'Invariant Violation';
|
|
1815
|
-
throw err;
|
|
1816
|
-
}
|
|
525
|
+
if (maybeKey !== undefined) {
|
|
526
|
+
key = '' + maybeKey;
|
|
527
|
+
}
|
|
1817
528
|
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
}
|
|
529
|
+
if (hasValidKey(config)) {
|
|
530
|
+
key = '' + config.key;
|
|
531
|
+
}
|
|
1822
532
|
|
|
1823
|
-
|
|
1824
|
-
|
|
533
|
+
if (hasValidRef(config)) {
|
|
534
|
+
ref = config.ref;
|
|
535
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
536
|
+
} // Remaining properties are added to a new props object
|
|
1825
537
|
|
|
1826
|
-
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
1827
538
|
|
|
1828
|
-
|
|
1829
|
-
|
|
539
|
+
for (propName in config) {
|
|
540
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
541
|
+
props[propName] = config[propName];
|
|
542
|
+
}
|
|
543
|
+
} // Resolve default props
|
|
1830
544
|
|
|
1831
|
-
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
1832
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
1833
|
-
// same error.
|
|
1834
|
-
loggedTypeFailures[error$1.message] = true;
|
|
1835
|
-
setCurrentlyValidatingElement(element);
|
|
1836
545
|
|
|
1837
|
-
|
|
546
|
+
if (type && type.defaultProps) {
|
|
547
|
+
var defaultProps = type.defaultProps;
|
|
1838
548
|
|
|
1839
|
-
|
|
549
|
+
for (propName in defaultProps) {
|
|
550
|
+
if (props[propName] === undefined) {
|
|
551
|
+
props[propName] = defaultProps[propName];
|
|
1840
552
|
}
|
|
1841
553
|
}
|
|
1842
554
|
}
|
|
555
|
+
|
|
556
|
+
if (key || ref) {
|
|
557
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
558
|
+
|
|
559
|
+
if (key) {
|
|
560
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (ref) {
|
|
564
|
+
defineRefPropWarningGetter(props, displayName);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
1843
569
|
}
|
|
1844
570
|
}
|
|
1845
571
|
|
|
1846
|
-
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
var specialPropKeyWarningShown;
|
|
1855
|
-
var specialPropRefWarningShown;
|
|
1856
|
-
var didWarnAboutStringRefs;
|
|
572
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
573
|
+
ReactSharedInternals.ReactDebugCurrentFrame;
|
|
574
|
+
|
|
575
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
576
|
+
currentlyValidatingElement = element;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
var propTypesMisspellWarningShown;
|
|
1857
580
|
|
|
1858
581
|
{
|
|
1859
|
-
|
|
582
|
+
propTypesMisspellWarningShown = false;
|
|
1860
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Verifies the object is a ReactElement.
|
|
586
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
587
|
+
* @param {?object} object
|
|
588
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
589
|
+
* @final
|
|
590
|
+
*/
|
|
1861
591
|
|
|
1862
|
-
function
|
|
592
|
+
function isValidElement(object) {
|
|
1863
593
|
{
|
|
1864
|
-
|
|
1865
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
1866
|
-
|
|
1867
|
-
if (getter && getter.isReactWarning) {
|
|
1868
|
-
return false;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
594
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1871
595
|
}
|
|
1872
|
-
|
|
1873
|
-
return config.ref !== undefined;
|
|
1874
596
|
}
|
|
1875
597
|
|
|
1876
|
-
function
|
|
598
|
+
function getDeclarationErrorAddendum() {
|
|
1877
599
|
{
|
|
1878
|
-
if (
|
|
1879
|
-
var
|
|
600
|
+
if (ReactCurrentOwner$1.current) {
|
|
601
|
+
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
|
1880
602
|
|
|
1881
|
-
if (
|
|
1882
|
-
return
|
|
603
|
+
if (name) {
|
|
604
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
|
1883
605
|
}
|
|
1884
606
|
}
|
|
607
|
+
|
|
608
|
+
return '';
|
|
1885
609
|
}
|
|
610
|
+
}
|
|
1886
611
|
|
|
1887
|
-
|
|
612
|
+
function getSourceInfoErrorAddendum(source) {
|
|
613
|
+
{
|
|
614
|
+
if (source !== undefined) {
|
|
615
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
616
|
+
var lineNumber = source.lineNumber;
|
|
617
|
+
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return '';
|
|
621
|
+
}
|
|
1888
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
625
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
626
|
+
* updates.
|
|
627
|
+
*/
|
|
1889
628
|
|
|
1890
|
-
|
|
629
|
+
|
|
630
|
+
var ownerHasKeyUseWarning = {};
|
|
631
|
+
|
|
632
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
1891
633
|
{
|
|
1892
|
-
|
|
1893
|
-
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
634
|
+
var info = getDeclarationErrorAddendum();
|
|
1894
635
|
|
|
1895
|
-
|
|
1896
|
-
|
|
636
|
+
if (!info) {
|
|
637
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1897
638
|
|
|
1898
|
-
|
|
639
|
+
if (parentName) {
|
|
640
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1899
641
|
}
|
|
1900
642
|
}
|
|
643
|
+
|
|
644
|
+
return info;
|
|
1901
645
|
}
|
|
1902
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
649
|
+
* This element is in an array. The array could grow and shrink or be
|
|
650
|
+
* reordered. All children that haven't already been validated are required to
|
|
651
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
652
|
+
* will only be shown once.
|
|
653
|
+
*
|
|
654
|
+
* @internal
|
|
655
|
+
* @param {ReactElement} element Element that requires a key.
|
|
656
|
+
* @param {*} parentType element's parent's type.
|
|
657
|
+
*/
|
|
1903
658
|
|
|
1904
|
-
|
|
659
|
+
|
|
660
|
+
function validateExplicitKey(element, parentType) {
|
|
1905
661
|
{
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
662
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
1909
665
|
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
};
|
|
666
|
+
element._store.validated = true;
|
|
667
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1913
668
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
669
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
674
|
+
// property, it may be the creator of the child that's responsible for
|
|
675
|
+
// assigning it a key.
|
|
676
|
+
|
|
677
|
+
var childOwner = '';
|
|
678
|
+
|
|
679
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
680
|
+
// Give the component that originally created this child.
|
|
681
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
setCurrentlyValidatingElement$1(element);
|
|
685
|
+
|
|
686
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
687
|
+
|
|
688
|
+
setCurrentlyValidatingElement$1(null);
|
|
1919
689
|
}
|
|
1920
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* Ensure that every element either is passed in a static location, in an
|
|
693
|
+
* array with an explicit keys property defined, or in an object literal
|
|
694
|
+
* with valid key property.
|
|
695
|
+
*
|
|
696
|
+
* @internal
|
|
697
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
698
|
+
* @param {*} parentType node's parent's type.
|
|
699
|
+
*/
|
|
1921
700
|
|
|
1922
|
-
|
|
701
|
+
|
|
702
|
+
function validateChildKeys(node, parentType) {
|
|
1923
703
|
{
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
704
|
+
if (typeof node !== 'object') {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
1927
707
|
|
|
1928
|
-
|
|
708
|
+
if (Array.isArray(node)) {
|
|
709
|
+
for (var i = 0; i < node.length; i++) {
|
|
710
|
+
var child = node[i];
|
|
711
|
+
|
|
712
|
+
if (isValidElement(child)) {
|
|
713
|
+
validateExplicitKey(child, parentType);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
} else if (isValidElement(node)) {
|
|
717
|
+
// This element was passed in a valid location.
|
|
718
|
+
if (node._store) {
|
|
719
|
+
node._store.validated = true;
|
|
720
|
+
}
|
|
721
|
+
} else if (node) {
|
|
722
|
+
var iteratorFn = getIteratorFn(node);
|
|
723
|
+
|
|
724
|
+
if (typeof iteratorFn === 'function') {
|
|
725
|
+
// Entry iterators used to provide implicit keys,
|
|
726
|
+
// but now we print a separate warning for them later.
|
|
727
|
+
if (iteratorFn !== node.entries) {
|
|
728
|
+
var iterator = iteratorFn.call(node);
|
|
729
|
+
var step;
|
|
730
|
+
|
|
731
|
+
while (!(step = iterator.next()).done) {
|
|
732
|
+
if (isValidElement(step.value)) {
|
|
733
|
+
validateExplicitKey(step.value, parentType);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
1929
737
|
}
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
warnAboutAccessingRef.isReactWarning = true;
|
|
1933
|
-
Object.defineProperty(props, 'ref', {
|
|
1934
|
-
get: warnAboutAccessingRef,
|
|
1935
|
-
configurable: true
|
|
1936
|
-
});
|
|
738
|
+
}
|
|
1937
739
|
}
|
|
1938
740
|
}
|
|
1939
741
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
1942
|
-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
1943
|
-
* if something is a React Element.
|
|
742
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
743
|
+
* provided by the type.
|
|
1944
744
|
*
|
|
1945
|
-
* @param {
|
|
1946
|
-
* @param {*} props
|
|
1947
|
-
* @param {*} key
|
|
1948
|
-
* @param {string|object} ref
|
|
1949
|
-
* @param {*} owner
|
|
1950
|
-
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
1951
|
-
* different from the `owner` when React.createElement is called, so that we
|
|
1952
|
-
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
1953
|
-
* functions, and as long as `this` and owner are the same, there will be no
|
|
1954
|
-
* change in behavior.
|
|
1955
|
-
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
1956
|
-
* indicating filename, line number, and/or other information.
|
|
1957
|
-
* @internal
|
|
745
|
+
* @param {ReactElement} element
|
|
1958
746
|
*/
|
|
1959
747
|
|
|
1960
748
|
|
|
1961
|
-
|
|
1962
|
-
var element = {
|
|
1963
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
1964
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
1965
|
-
// Built-in properties that belong on the element
|
|
1966
|
-
type: type,
|
|
1967
|
-
key: key,
|
|
1968
|
-
ref: ref,
|
|
1969
|
-
props: props,
|
|
1970
|
-
// Record the component responsible for creating this element.
|
|
1971
|
-
_owner: owner
|
|
1972
|
-
};
|
|
1973
|
-
|
|
749
|
+
function validatePropTypes(element) {
|
|
1974
750
|
{
|
|
1975
|
-
|
|
1976
|
-
// an external backing store so that we can freeze the whole object.
|
|
1977
|
-
// This can be replaced with a WeakMap once they are implemented in
|
|
1978
|
-
// commonly used development environments.
|
|
1979
|
-
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
1980
|
-
// the validation flag non-enumerable (where possible, which should
|
|
1981
|
-
// include every environment we run tests in), so the test framework
|
|
1982
|
-
// ignores it.
|
|
751
|
+
var type = element.type;
|
|
1983
752
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
writable: true,
|
|
1988
|
-
value: false
|
|
1989
|
-
}); // self and source are DEV only properties.
|
|
753
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
1990
756
|
|
|
1991
|
-
|
|
1992
|
-
configurable: false,
|
|
1993
|
-
enumerable: false,
|
|
1994
|
-
writable: false,
|
|
1995
|
-
value: self
|
|
1996
|
-
}); // Two elements created in two different places should be considered
|
|
1997
|
-
// equal for testing purposes and therefore we hide it from enumeration.
|
|
757
|
+
var propTypes;
|
|
1998
758
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
759
|
+
if (typeof type === 'function') {
|
|
760
|
+
propTypes = type.propTypes;
|
|
761
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
762
|
+
// Inner props are checked in the reconciler.
|
|
763
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
764
|
+
propTypes = type.propTypes;
|
|
765
|
+
} else {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
2005
768
|
|
|
2006
|
-
if (
|
|
2007
|
-
|
|
2008
|
-
|
|
769
|
+
if (propTypes) {
|
|
770
|
+
// Intentionally inside to avoid triggering lazy initializers:
|
|
771
|
+
var name = getComponentName(type);
|
|
772
|
+
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
773
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
774
|
+
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
775
|
+
|
|
776
|
+
var _name = getComponentName(type);
|
|
777
|
+
|
|
778
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
2009
779
|
}
|
|
2010
|
-
}
|
|
2011
780
|
|
|
2012
|
-
|
|
2013
|
-
|
|
781
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
782
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
2014
786
|
/**
|
|
2015
|
-
*
|
|
2016
|
-
* @param {
|
|
2017
|
-
* @param {object} props
|
|
2018
|
-
* @param {string} key
|
|
787
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
788
|
+
* @param {ReactElement} fragment
|
|
2019
789
|
*/
|
|
2020
790
|
|
|
2021
|
-
|
|
791
|
+
|
|
792
|
+
function validateFragmentProps(fragment) {
|
|
2022
793
|
{
|
|
2023
|
-
var
|
|
794
|
+
var keys = Object.keys(fragment.props);
|
|
2024
795
|
|
|
2025
|
-
var
|
|
2026
|
-
|
|
2027
|
-
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
2028
|
-
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
2029
|
-
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
2030
|
-
// but as an intermediary step, we will use jsxDEV for everything except
|
|
2031
|
-
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
2032
|
-
// key is explicitly declared to be undefined or not.
|
|
796
|
+
for (var i = 0; i < keys.length; i++) {
|
|
797
|
+
var key = keys[i];
|
|
2033
798
|
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
}
|
|
799
|
+
if (key !== 'children' && key !== 'key') {
|
|
800
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
2037
801
|
|
|
2038
|
-
|
|
2039
|
-
|
|
802
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
803
|
+
|
|
804
|
+
setCurrentlyValidatingElement$1(null);
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
2040
807
|
}
|
|
2041
808
|
|
|
2042
|
-
if (
|
|
2043
|
-
|
|
2044
|
-
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
2045
|
-
} // Remaining properties are added to a new props object
|
|
809
|
+
if (fragment.ref !== null) {
|
|
810
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
2046
811
|
|
|
812
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
2047
813
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
} // Resolve default props
|
|
814
|
+
setCurrentlyValidatingElement$1(null);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
2053
818
|
|
|
819
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
820
|
+
{
|
|
821
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
822
|
+
// succeed and there will likely be errors in render.
|
|
2054
823
|
|
|
2055
|
-
if (
|
|
2056
|
-
var
|
|
824
|
+
if (!validType) {
|
|
825
|
+
var info = '';
|
|
2057
826
|
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
props[propName] = defaultProps[propName];
|
|
2061
|
-
}
|
|
827
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
828
|
+
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
2062
829
|
}
|
|
2063
|
-
}
|
|
2064
830
|
|
|
2065
|
-
|
|
2066
|
-
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
831
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
2067
832
|
|
|
2068
|
-
if (
|
|
2069
|
-
|
|
833
|
+
if (sourceInfo) {
|
|
834
|
+
info += sourceInfo;
|
|
835
|
+
} else {
|
|
836
|
+
info += getDeclarationErrorAddendum();
|
|
2070
837
|
}
|
|
2071
838
|
|
|
2072
|
-
|
|
2073
|
-
|
|
839
|
+
var typeString;
|
|
840
|
+
|
|
841
|
+
if (type === null) {
|
|
842
|
+
typeString = 'null';
|
|
843
|
+
} else if (Array.isArray(type)) {
|
|
844
|
+
typeString = 'array';
|
|
845
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
846
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
847
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
848
|
+
} else {
|
|
849
|
+
typeString = typeof type;
|
|
2074
850
|
}
|
|
851
|
+
|
|
852
|
+
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
2075
853
|
}
|
|
2076
854
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
}
|
|
855
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
856
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
2080
857
|
|
|
2081
|
-
|
|
2082
|
-
|
|
858
|
+
if (element == null) {
|
|
859
|
+
return element;
|
|
860
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
861
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
862
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
863
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
864
|
+
// fixed, the key warnings will appear.)
|
|
2083
865
|
|
|
2084
|
-
function setCurrentlyValidatingElement$1(element) {
|
|
2085
|
-
currentlyValidatingElement = element;
|
|
2086
|
-
}
|
|
2087
866
|
|
|
2088
|
-
|
|
867
|
+
if (validType) {
|
|
868
|
+
var children = props.children;
|
|
2089
869
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
870
|
+
if (children !== undefined) {
|
|
871
|
+
if (isStaticChildren) {
|
|
872
|
+
if (Array.isArray(children)) {
|
|
873
|
+
for (var i = 0; i < children.length; i++) {
|
|
874
|
+
validateChildKeys(children[i], type);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (Object.freeze) {
|
|
878
|
+
Object.freeze(children);
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
882
|
+
}
|
|
883
|
+
} else {
|
|
884
|
+
validateChildKeys(children, type);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
if (type === exports.Fragment) {
|
|
890
|
+
validateFragmentProps(element);
|
|
891
|
+
} else {
|
|
892
|
+
validatePropTypes(element);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
return element;
|
|
896
|
+
}
|
|
897
|
+
} // These two functions exist to still get child warnings in dev
|
|
898
|
+
// even with the prod transform. This means that jsxDEV is purely
|
|
899
|
+
// opt-in behavior for better messages but that we won't stop
|
|
900
|
+
// giving you warnings if you use production apis.
|
|
2100
901
|
|
|
2101
|
-
function
|
|
902
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
2102
903
|
{
|
|
2103
|
-
return
|
|
904
|
+
return jsxWithValidation(type, props, key, true);
|
|
2104
905
|
}
|
|
2105
906
|
}
|
|
2106
|
-
|
|
2107
|
-
function getDeclarationErrorAddendum() {
|
|
907
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
2108
908
|
{
|
|
2109
|
-
|
|
2110
|
-
|
|
909
|
+
return jsxWithValidation(type, props, key, false);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
2111
912
|
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
913
|
+
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
|
914
|
+
// for now we can ship identical prod functions
|
|
2116
915
|
|
|
2117
|
-
|
|
2118
|
-
|
|
916
|
+
var jsxs = jsxWithValidationStatic ;
|
|
917
|
+
|
|
918
|
+
exports.jsx = jsx;
|
|
919
|
+
exports.jsxs = jsxs;
|
|
920
|
+
})();
|
|
2119
921
|
}
|
|
922
|
+
} (reactJsxRuntime_development));
|
|
2120
923
|
|
|
2121
|
-
|
|
2122
|
-
{
|
|
2123
|
-
if (source !== undefined) {
|
|
2124
|
-
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
2125
|
-
var lineNumber = source.lineNumber;
|
|
2126
|
-
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
2127
|
-
}
|
|
924
|
+
(function (module) {
|
|
2128
925
|
|
|
2129
|
-
|
|
2130
|
-
|
|
926
|
+
{
|
|
927
|
+
module.exports = reactJsxRuntime_development;
|
|
2131
928
|
}
|
|
2132
|
-
|
|
2133
|
-
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
2134
|
-
* object keys are not valid. This allows us to keep track of children between
|
|
2135
|
-
* updates.
|
|
2136
|
-
*/
|
|
929
|
+
} (jsxRuntime));
|
|
2137
930
|
|
|
931
|
+
var classnames = {exports: {}};
|
|
2138
932
|
|
|
2139
|
-
|
|
933
|
+
/*!
|
|
934
|
+
Copyright (c) 2018 Jed Watson.
|
|
935
|
+
Licensed under the MIT License (MIT), see
|
|
936
|
+
http://jedwatson.github.io/classnames
|
|
937
|
+
*/
|
|
2140
938
|
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
var info = getDeclarationErrorAddendum();
|
|
939
|
+
(function (module) {
|
|
940
|
+
/* global define */
|
|
2144
941
|
|
|
2145
|
-
|
|
2146
|
-
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
942
|
+
(function () {
|
|
2147
943
|
|
|
2148
|
-
|
|
2149
|
-
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
944
|
+
var hasOwn = {}.hasOwnProperty;
|
|
2152
945
|
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
}
|
|
2156
|
-
/**
|
|
2157
|
-
* Warn if the element doesn't have an explicit key assigned to it.
|
|
2158
|
-
* This element is in an array. The array could grow and shrink or be
|
|
2159
|
-
* reordered. All children that haven't already been validated are required to
|
|
2160
|
-
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
2161
|
-
* will only be shown once.
|
|
2162
|
-
*
|
|
2163
|
-
* @internal
|
|
2164
|
-
* @param {ReactElement} element Element that requires a key.
|
|
2165
|
-
* @param {*} parentType element's parent's type.
|
|
2166
|
-
*/
|
|
946
|
+
function classNames() {
|
|
947
|
+
var classes = [];
|
|
2167
948
|
|
|
949
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
950
|
+
var arg = arguments[i];
|
|
951
|
+
if (!arg) continue;
|
|
2168
952
|
|
|
2169
|
-
|
|
2170
|
-
{
|
|
2171
|
-
if (!element._store || element._store.validated || element.key != null) {
|
|
2172
|
-
return;
|
|
2173
|
-
}
|
|
953
|
+
var argType = typeof arg;
|
|
2174
954
|
|
|
2175
|
-
|
|
2176
|
-
|
|
955
|
+
if (argType === 'string' || argType === 'number') {
|
|
956
|
+
classes.push(arg);
|
|
957
|
+
} else if (Array.isArray(arg)) {
|
|
958
|
+
if (arg.length) {
|
|
959
|
+
var inner = classNames.apply(null, arg);
|
|
960
|
+
if (inner) {
|
|
961
|
+
classes.push(inner);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
} else if (argType === 'object') {
|
|
965
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
966
|
+
classes.push(arg.toString());
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
2177
969
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
970
|
+
for (var key in arg) {
|
|
971
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
972
|
+
classes.push(key);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
2181
977
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
// assigning it a key.
|
|
978
|
+
return classes.join(' ');
|
|
979
|
+
}
|
|
2185
980
|
|
|
2186
|
-
|
|
981
|
+
if (module.exports) {
|
|
982
|
+
classNames.default = classNames;
|
|
983
|
+
module.exports = classNames;
|
|
984
|
+
} else {
|
|
985
|
+
window.classNames = classNames;
|
|
986
|
+
}
|
|
987
|
+
}());
|
|
988
|
+
} (classnames));
|
|
2187
989
|
|
|
2188
|
-
|
|
2189
|
-
// Give the component that originally created this child.
|
|
2190
|
-
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
2191
|
-
}
|
|
990
|
+
var classNames = classnames.exports;
|
|
2192
991
|
|
|
2193
|
-
|
|
992
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
993
|
+
/**
|
|
994
|
+
* This function debounce the received function
|
|
995
|
+
* @param { function } func Function to be debounced
|
|
996
|
+
* @param { number } wait Time to wait before execut the function
|
|
997
|
+
* @param { boolean } immediate Param to define if the function will be executed immediately
|
|
998
|
+
*/
|
|
999
|
+
const debounce = (func, wait, immediate) => {
|
|
1000
|
+
let timeout = null;
|
|
1001
|
+
return function debounced(...args) {
|
|
1002
|
+
const later = () => {
|
|
1003
|
+
timeout = null;
|
|
1004
|
+
if (!immediate) {
|
|
1005
|
+
func.apply(this, args);
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
if (timeout) {
|
|
1009
|
+
clearTimeout(timeout);
|
|
1010
|
+
}
|
|
1011
|
+
timeout = setTimeout(later, wait);
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
2194
1014
|
|
|
2195
|
-
|
|
1015
|
+
const TooltipContent = ({ content }) => {
|
|
1016
|
+
return jsxRuntime.exports.jsx("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
1017
|
+
};
|
|
2196
1018
|
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
1019
|
+
const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
|
|
1020
|
+
const DEFAULT_CONTEXT_DATA = {
|
|
1021
|
+
anchorRefs: new Set(),
|
|
1022
|
+
activeAnchor: { current: null },
|
|
1023
|
+
attach: () => {
|
|
1024
|
+
/* attach anchor element */
|
|
1025
|
+
},
|
|
1026
|
+
detach: () => {
|
|
1027
|
+
/* detach anchor element */
|
|
1028
|
+
},
|
|
1029
|
+
setActiveAnchor: () => {
|
|
1030
|
+
/* set active anchor */
|
|
1031
|
+
},
|
|
1032
|
+
};
|
|
1033
|
+
const DEFAULT_CONTEXT_DATA_WRAPPER = {
|
|
1034
|
+
getTooltipData: () => DEFAULT_CONTEXT_DATA,
|
|
1035
|
+
};
|
|
1036
|
+
const TooltipContext = require$$0.createContext(DEFAULT_CONTEXT_DATA_WRAPPER);
|
|
1037
|
+
/**
|
|
1038
|
+
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
|
|
1039
|
+
* See https://react-tooltip.com/docs/getting-started
|
|
1040
|
+
*/
|
|
1041
|
+
const TooltipProvider = ({ children }) => {
|
|
1042
|
+
const [anchorRefMap, setAnchorRefMap] = require$$0.useState({
|
|
1043
|
+
[DEFAULT_TOOLTIP_ID]: new Set(),
|
|
1044
|
+
});
|
|
1045
|
+
const [activeAnchorMap, setActiveAnchorMap] = require$$0.useState({
|
|
1046
|
+
[DEFAULT_TOOLTIP_ID]: { current: null },
|
|
1047
|
+
});
|
|
1048
|
+
const attach = (tooltipId, ...refs) => {
|
|
1049
|
+
setAnchorRefMap((oldMap) => {
|
|
1050
|
+
var _a;
|
|
1051
|
+
const tooltipRefs = (_a = oldMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set();
|
|
1052
|
+
refs.forEach((ref) => tooltipRefs.add(ref));
|
|
1053
|
+
// create new object to trigger re-render
|
|
1054
|
+
return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
const detach = (tooltipId, ...refs) => {
|
|
1058
|
+
setAnchorRefMap((oldMap) => {
|
|
1059
|
+
const tooltipRefs = oldMap[tooltipId];
|
|
1060
|
+
if (!tooltipRefs) {
|
|
1061
|
+
// tooltip not found
|
|
1062
|
+
// maybe thow error?
|
|
1063
|
+
return oldMap;
|
|
1064
|
+
}
|
|
1065
|
+
refs.forEach((ref) => tooltipRefs.delete(ref));
|
|
1066
|
+
// create new object to trigger re-render
|
|
1067
|
+
return { ...oldMap };
|
|
1068
|
+
});
|
|
1069
|
+
};
|
|
1070
|
+
const setActiveAnchor = (tooltipId, ref) => {
|
|
1071
|
+
setActiveAnchorMap((oldMap) => {
|
|
1072
|
+
var _a;
|
|
1073
|
+
if (((_a = oldMap[tooltipId]) === null || _a === void 0 ? void 0 : _a.current) === ref.current) {
|
|
1074
|
+
return oldMap;
|
|
1075
|
+
}
|
|
1076
|
+
// create new object to trigger re-render
|
|
1077
|
+
return { ...oldMap, [tooltipId]: ref };
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
const getTooltipData = require$$0.useCallback((tooltipId = DEFAULT_TOOLTIP_ID) => {
|
|
1081
|
+
var _a, _b;
|
|
1082
|
+
return ({
|
|
1083
|
+
anchorRefs: (_a = anchorRefMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set(),
|
|
1084
|
+
activeAnchor: (_b = activeAnchorMap[tooltipId]) !== null && _b !== void 0 ? _b : { current: null },
|
|
1085
|
+
attach: (...refs) => attach(tooltipId, ...refs),
|
|
1086
|
+
detach: (...refs) => detach(tooltipId, ...refs),
|
|
1087
|
+
setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref),
|
|
1088
|
+
});
|
|
1089
|
+
}, [anchorRefMap, activeAnchorMap, attach, detach]);
|
|
1090
|
+
const context = require$$0.useMemo(() => {
|
|
1091
|
+
return {
|
|
1092
|
+
getTooltipData,
|
|
1093
|
+
};
|
|
1094
|
+
}, [getTooltipData]);
|
|
1095
|
+
return jsxRuntime.exports.jsx(TooltipContext.Provider, { value: context, children: children });
|
|
1096
|
+
};
|
|
1097
|
+
function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
|
|
1098
|
+
return require$$0.useContext(TooltipContext).getTooltipData(tooltipId);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
|
|
1103
|
+
* See https://react-tooltip.com/docs/getting-started
|
|
1104
|
+
*/
|
|
1105
|
+
const TooltipWrapper = ({ tooltipId, children, className, place, content, html, variant, offset, wrapper, events, positionStrategy, delayShow, delayHide, }) => {
|
|
1106
|
+
const { attach, detach } = useTooltip(tooltipId);
|
|
1107
|
+
const anchorRef = require$$0.useRef(null);
|
|
1108
|
+
require$$0.useEffect(() => {
|
|
1109
|
+
attach(anchorRef);
|
|
1110
|
+
return () => {
|
|
1111
|
+
detach(anchorRef);
|
|
1112
|
+
};
|
|
1113
|
+
}, []);
|
|
1114
|
+
return (jsxRuntime.exports.jsx("span", { ref: anchorRef, className: classNames('react-tooltip-wrapper', className), "data-tooltip-place": place, "data-tooltip-content": content, "data-tooltip-html": html, "data-tooltip-variant": variant, "data-tooltip-offset": offset, "data-tooltip-wrapper": wrapper, "data-tooltip-events": events, "data-tooltip-position-strategy": positionStrategy, "data-tooltip-delay-show": delayShow, "data-tooltip-delay-hide": delayHide, children: children }));
|
|
1115
|
+
};
|
|
2209
1116
|
|
|
1117
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? require$$0.useLayoutEffect : require$$0.useEffect;
|
|
2210
1118
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
return;
|
|
2215
|
-
}
|
|
1119
|
+
function getAlignment(placement) {
|
|
1120
|
+
return placement.split('-')[1];
|
|
1121
|
+
}
|
|
2216
1122
|
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
1123
|
+
function getLengthFromAxis(axis) {
|
|
1124
|
+
return axis === 'y' ? 'height' : 'width';
|
|
1125
|
+
}
|
|
2220
1126
|
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
}
|
|
2225
|
-
} else if (isValidElement(node)) {
|
|
2226
|
-
// This element was passed in a valid location.
|
|
2227
|
-
if (node._store) {
|
|
2228
|
-
node._store.validated = true;
|
|
2229
|
-
}
|
|
2230
|
-
} else if (node) {
|
|
2231
|
-
var iteratorFn = getIteratorFn(node);
|
|
1127
|
+
function getSide(placement) {
|
|
1128
|
+
return placement.split('-')[0];
|
|
1129
|
+
}
|
|
2232
1130
|
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
if (iteratorFn !== node.entries) {
|
|
2237
|
-
var iterator = iteratorFn.call(node);
|
|
2238
|
-
var step;
|
|
1131
|
+
function getMainAxisFromPlacement(placement) {
|
|
1132
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
1133
|
+
}
|
|
2239
1134
|
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
1135
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
1136
|
+
let {
|
|
1137
|
+
reference,
|
|
1138
|
+
floating
|
|
1139
|
+
} = _ref;
|
|
1140
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
1141
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
1142
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
1143
|
+
const length = getLengthFromAxis(mainAxis);
|
|
1144
|
+
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
1145
|
+
const side = getSide(placement);
|
|
1146
|
+
const isVertical = mainAxis === 'x';
|
|
1147
|
+
let coords;
|
|
1148
|
+
switch (side) {
|
|
1149
|
+
case 'top':
|
|
1150
|
+
coords = {
|
|
1151
|
+
x: commonX,
|
|
1152
|
+
y: reference.y - floating.height
|
|
1153
|
+
};
|
|
1154
|
+
break;
|
|
1155
|
+
case 'bottom':
|
|
1156
|
+
coords = {
|
|
1157
|
+
x: commonX,
|
|
1158
|
+
y: reference.y + reference.height
|
|
1159
|
+
};
|
|
1160
|
+
break;
|
|
1161
|
+
case 'right':
|
|
1162
|
+
coords = {
|
|
1163
|
+
x: reference.x + reference.width,
|
|
1164
|
+
y: commonY
|
|
1165
|
+
};
|
|
1166
|
+
break;
|
|
1167
|
+
case 'left':
|
|
1168
|
+
coords = {
|
|
1169
|
+
x: reference.x - floating.width,
|
|
1170
|
+
y: commonY
|
|
1171
|
+
};
|
|
1172
|
+
break;
|
|
1173
|
+
default:
|
|
1174
|
+
coords = {
|
|
1175
|
+
x: reference.x,
|
|
1176
|
+
y: reference.y
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
switch (getAlignment(placement)) {
|
|
1180
|
+
case 'start':
|
|
1181
|
+
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1182
|
+
break;
|
|
1183
|
+
case 'end':
|
|
1184
|
+
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
return coords;
|
|
1188
|
+
}
|
|
2256
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1192
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
1193
|
+
*
|
|
1194
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
1195
|
+
* write one for the platform you are using Floating UI with.
|
|
1196
|
+
*/
|
|
1197
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
1198
|
+
const {
|
|
1199
|
+
placement = 'bottom',
|
|
1200
|
+
strategy = 'absolute',
|
|
1201
|
+
middleware = [],
|
|
1202
|
+
platform
|
|
1203
|
+
} = config;
|
|
1204
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
1205
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
1206
|
+
{
|
|
1207
|
+
if (platform == null) {
|
|
1208
|
+
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
|
|
1209
|
+
}
|
|
1210
|
+
if (validMiddleware.filter(_ref => {
|
|
1211
|
+
let {
|
|
1212
|
+
name
|
|
1213
|
+
} = _ref;
|
|
1214
|
+
return name === 'autoPlacement' || name === 'flip';
|
|
1215
|
+
}).length > 1) {
|
|
1216
|
+
throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
|
|
1217
|
+
}
|
|
1218
|
+
if (!reference || !floating) {
|
|
1219
|
+
console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
let rects = await platform.getElementRects({
|
|
1223
|
+
reference,
|
|
1224
|
+
floating,
|
|
1225
|
+
strategy
|
|
1226
|
+
});
|
|
1227
|
+
let {
|
|
1228
|
+
x,
|
|
1229
|
+
y
|
|
1230
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
1231
|
+
let statefulPlacement = placement;
|
|
1232
|
+
let middlewareData = {};
|
|
1233
|
+
let resetCount = 0;
|
|
1234
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
1235
|
+
const {
|
|
1236
|
+
name,
|
|
1237
|
+
fn
|
|
1238
|
+
} = validMiddleware[i];
|
|
1239
|
+
const {
|
|
1240
|
+
x: nextX,
|
|
1241
|
+
y: nextY,
|
|
1242
|
+
data,
|
|
1243
|
+
reset
|
|
1244
|
+
} = await fn({
|
|
1245
|
+
x,
|
|
1246
|
+
y,
|
|
1247
|
+
initialPlacement: placement,
|
|
1248
|
+
placement: statefulPlacement,
|
|
1249
|
+
strategy,
|
|
1250
|
+
middlewareData,
|
|
1251
|
+
rects,
|
|
1252
|
+
platform,
|
|
1253
|
+
elements: {
|
|
1254
|
+
reference,
|
|
1255
|
+
floating
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
x = nextX != null ? nextX : x;
|
|
1259
|
+
y = nextY != null ? nextY : y;
|
|
1260
|
+
middlewareData = {
|
|
1261
|
+
...middlewareData,
|
|
1262
|
+
[name]: {
|
|
1263
|
+
...middlewareData[name],
|
|
1264
|
+
...data
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
{
|
|
1268
|
+
if (resetCount > 50) {
|
|
1269
|
+
console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
if (reset && resetCount <= 50) {
|
|
1273
|
+
resetCount++;
|
|
1274
|
+
if (typeof reset === 'object') {
|
|
1275
|
+
if (reset.placement) {
|
|
1276
|
+
statefulPlacement = reset.placement;
|
|
1277
|
+
}
|
|
1278
|
+
if (reset.rects) {
|
|
1279
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
1280
|
+
reference,
|
|
1281
|
+
floating,
|
|
1282
|
+
strategy
|
|
1283
|
+
}) : reset.rects;
|
|
1284
|
+
}
|
|
1285
|
+
({
|
|
1286
|
+
x,
|
|
1287
|
+
y
|
|
1288
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1289
|
+
}
|
|
1290
|
+
i = -1;
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
x,
|
|
1296
|
+
y,
|
|
1297
|
+
placement: statefulPlacement,
|
|
1298
|
+
strategy,
|
|
1299
|
+
middlewareData
|
|
1300
|
+
};
|
|
1301
|
+
};
|
|
2257
1302
|
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
1303
|
+
function expandPaddingObject(padding) {
|
|
1304
|
+
return {
|
|
1305
|
+
top: 0,
|
|
1306
|
+
right: 0,
|
|
1307
|
+
bottom: 0,
|
|
1308
|
+
left: 0,
|
|
1309
|
+
...padding
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
2261
1312
|
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
1313
|
+
function getSideObjectFromPadding(padding) {
|
|
1314
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
1315
|
+
top: padding,
|
|
1316
|
+
right: padding,
|
|
1317
|
+
bottom: padding,
|
|
1318
|
+
left: padding
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
2265
1321
|
|
|
2266
|
-
|
|
1322
|
+
function rectToClientRect(rect) {
|
|
1323
|
+
return {
|
|
1324
|
+
...rect,
|
|
1325
|
+
top: rect.y,
|
|
1326
|
+
left: rect.x,
|
|
1327
|
+
right: rect.x + rect.width,
|
|
1328
|
+
bottom: rect.y + rect.height
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
2267
1331
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
1334
|
+
* element is overflowing a given clipping boundary.
|
|
1335
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
1336
|
+
* - negative = how many pixels left before it will overflow
|
|
1337
|
+
* - 0 = lies flush with the boundary
|
|
1338
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
1339
|
+
*/
|
|
1340
|
+
async function detectOverflow(middlewareArguments, options) {
|
|
1341
|
+
var _await$platform$isEle;
|
|
1342
|
+
if (options === void 0) {
|
|
1343
|
+
options = {};
|
|
1344
|
+
}
|
|
1345
|
+
const {
|
|
1346
|
+
x,
|
|
1347
|
+
y,
|
|
1348
|
+
platform,
|
|
1349
|
+
rects,
|
|
1350
|
+
elements,
|
|
1351
|
+
strategy
|
|
1352
|
+
} = middlewareArguments;
|
|
1353
|
+
const {
|
|
1354
|
+
boundary = 'clippingAncestors',
|
|
1355
|
+
rootBoundary = 'viewport',
|
|
1356
|
+
elementContext = 'floating',
|
|
1357
|
+
altBoundary = false,
|
|
1358
|
+
padding = 0
|
|
1359
|
+
} = options;
|
|
1360
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
1361
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
1362
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
1363
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
1364
|
+
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))),
|
|
1365
|
+
boundary,
|
|
1366
|
+
rootBoundary,
|
|
1367
|
+
strategy
|
|
1368
|
+
}));
|
|
1369
|
+
const rect = elementContext === 'floating' ? {
|
|
1370
|
+
...rects.floating,
|
|
1371
|
+
x,
|
|
1372
|
+
y
|
|
1373
|
+
} : rects.reference;
|
|
1374
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1375
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
1376
|
+
x: 1,
|
|
1377
|
+
y: 1
|
|
1378
|
+
} : {
|
|
1379
|
+
x: 1,
|
|
1380
|
+
y: 1
|
|
1381
|
+
};
|
|
1382
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1383
|
+
rect,
|
|
1384
|
+
offsetParent,
|
|
1385
|
+
strategy
|
|
1386
|
+
}) : rect);
|
|
1387
|
+
return {
|
|
1388
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1389
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1390
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1391
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
2277
1394
|
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
var name = getComponentName(type);
|
|
2281
|
-
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
2282
|
-
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
2283
|
-
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
1395
|
+
const min$1 = Math.min;
|
|
1396
|
+
const max$1 = Math.max;
|
|
2284
1397
|
|
|
2285
|
-
|
|
1398
|
+
function within(min$1$1, value, max$1$1) {
|
|
1399
|
+
return max$1(min$1$1, min$1(value, max$1$1));
|
|
1400
|
+
}
|
|
2286
1401
|
|
|
2287
|
-
|
|
2288
|
-
|
|
1402
|
+
/**
|
|
1403
|
+
* Positions an inner element of the floating element such that it is centered
|
|
1404
|
+
* to the reference element.
|
|
1405
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1406
|
+
*/
|
|
1407
|
+
const arrow = options => ({
|
|
1408
|
+
name: 'arrow',
|
|
1409
|
+
options,
|
|
1410
|
+
async fn(middlewareArguments) {
|
|
1411
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
1412
|
+
const {
|
|
1413
|
+
element,
|
|
1414
|
+
padding = 0
|
|
1415
|
+
} = options || {};
|
|
1416
|
+
const {
|
|
1417
|
+
x,
|
|
1418
|
+
y,
|
|
1419
|
+
placement,
|
|
1420
|
+
rects,
|
|
1421
|
+
platform
|
|
1422
|
+
} = middlewareArguments;
|
|
1423
|
+
if (element == null) {
|
|
1424
|
+
{
|
|
1425
|
+
console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
|
|
1426
|
+
}
|
|
1427
|
+
return {};
|
|
1428
|
+
}
|
|
1429
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
1430
|
+
const coords = {
|
|
1431
|
+
x,
|
|
1432
|
+
y
|
|
1433
|
+
};
|
|
1434
|
+
const axis = getMainAxisFromPlacement(placement);
|
|
1435
|
+
const length = getLengthFromAxis(axis);
|
|
1436
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1437
|
+
const minProp = axis === 'y' ? 'top' : 'left';
|
|
1438
|
+
const maxProp = axis === 'y' ? 'bottom' : 'right';
|
|
1439
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1440
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1441
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1442
|
+
let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
1443
|
+
if (clientSize === 0) {
|
|
1444
|
+
clientSize = rects.floating[length];
|
|
1445
|
+
}
|
|
1446
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
2289
1447
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
* Given a fragment, validate that it can only be provided with fragment props
|
|
2297
|
-
* @param {ReactElement} fragment
|
|
2298
|
-
*/
|
|
1448
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
1449
|
+
// point is outside the floating element's bounds.
|
|
1450
|
+
const min = paddingObject[minProp];
|
|
1451
|
+
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
1452
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1453
|
+
const offset = within(min, center, max);
|
|
2299
1454
|
|
|
1455
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
1456
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1457
|
+
// floating element itself. This stops `shift()` from taking action, but can
|
|
1458
|
+
// be worked around by calling it again after the `arrow()` if desired.
|
|
1459
|
+
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
|
|
1460
|
+
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
1461
|
+
return {
|
|
1462
|
+
[axis]: coords[axis] - alignmentOffset,
|
|
1463
|
+
data: {
|
|
1464
|
+
[axis]: offset,
|
|
1465
|
+
centerOffset: center - offset
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
2300
1470
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
1471
|
+
const oppositeSideMap = {
|
|
1472
|
+
left: 'right',
|
|
1473
|
+
right: 'left',
|
|
1474
|
+
bottom: 'top',
|
|
1475
|
+
top: 'bottom'
|
|
1476
|
+
};
|
|
1477
|
+
function getOppositePlacement(placement) {
|
|
1478
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
1479
|
+
}
|
|
2304
1480
|
|
|
2305
|
-
|
|
2306
|
-
|
|
1481
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
1482
|
+
if (rtl === void 0) {
|
|
1483
|
+
rtl = false;
|
|
1484
|
+
}
|
|
1485
|
+
const alignment = getAlignment(placement);
|
|
1486
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
1487
|
+
const length = getLengthFromAxis(mainAxis);
|
|
1488
|
+
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
1489
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
1490
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
1491
|
+
}
|
|
1492
|
+
return {
|
|
1493
|
+
main: mainAlignmentSide,
|
|
1494
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
|
1495
|
+
};
|
|
1496
|
+
}
|
|
2307
1497
|
|
|
2308
|
-
|
|
2309
|
-
|
|
1498
|
+
const oppositeAlignmentMap = {
|
|
1499
|
+
start: 'end',
|
|
1500
|
+
end: 'start'
|
|
1501
|
+
};
|
|
1502
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
1503
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
1504
|
+
}
|
|
2310
1505
|
|
|
2311
|
-
|
|
1506
|
+
function getExpandedPlacements(placement) {
|
|
1507
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
1508
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
1509
|
+
}
|
|
2312
1510
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
1511
|
+
function getSideList(side, isStart, rtl) {
|
|
1512
|
+
const lr = ['left', 'right'];
|
|
1513
|
+
const rl = ['right', 'left'];
|
|
1514
|
+
const tb = ['top', 'bottom'];
|
|
1515
|
+
const bt = ['bottom', 'top'];
|
|
1516
|
+
switch (side) {
|
|
1517
|
+
case 'top':
|
|
1518
|
+
case 'bottom':
|
|
1519
|
+
if (rtl) return isStart ? rl : lr;
|
|
1520
|
+
return isStart ? lr : rl;
|
|
1521
|
+
case 'left':
|
|
1522
|
+
case 'right':
|
|
1523
|
+
return isStart ? tb : bt;
|
|
1524
|
+
default:
|
|
1525
|
+
return [];
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
1529
|
+
const alignment = getAlignment(placement);
|
|
1530
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
1531
|
+
if (alignment) {
|
|
1532
|
+
list = list.map(side => side + "-" + alignment);
|
|
1533
|
+
if (flipAlignment) {
|
|
1534
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
return list;
|
|
1538
|
+
}
|
|
2317
1539
|
|
|
2318
|
-
|
|
2319
|
-
|
|
1540
|
+
/**
|
|
1541
|
+
* Changes the placement of the floating element to one that will fit if the
|
|
1542
|
+
* initially specified `placement` does not.
|
|
1543
|
+
* @see https://floating-ui.com/docs/flip
|
|
1544
|
+
*/
|
|
1545
|
+
const flip = function (options) {
|
|
1546
|
+
if (options === void 0) {
|
|
1547
|
+
options = {};
|
|
1548
|
+
}
|
|
1549
|
+
return {
|
|
1550
|
+
name: 'flip',
|
|
1551
|
+
options,
|
|
1552
|
+
async fn(middlewareArguments) {
|
|
1553
|
+
var _middlewareData$flip;
|
|
1554
|
+
const {
|
|
1555
|
+
placement,
|
|
1556
|
+
middlewareData,
|
|
1557
|
+
rects,
|
|
1558
|
+
initialPlacement,
|
|
1559
|
+
platform,
|
|
1560
|
+
elements
|
|
1561
|
+
} = middlewareArguments;
|
|
1562
|
+
const {
|
|
1563
|
+
mainAxis: checkMainAxis = true,
|
|
1564
|
+
crossAxis: checkCrossAxis = true,
|
|
1565
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1566
|
+
fallbackStrategy = 'bestFit',
|
|
1567
|
+
fallbackAxisSideDirection = 'none',
|
|
1568
|
+
flipAlignment = true,
|
|
1569
|
+
...detectOverflowOptions
|
|
1570
|
+
} = options;
|
|
1571
|
+
const side = getSide(placement);
|
|
1572
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1573
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1574
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1575
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
1576
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1577
|
+
}
|
|
1578
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1579
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1580
|
+
const overflows = [];
|
|
1581
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1582
|
+
if (checkMainAxis) {
|
|
1583
|
+
overflows.push(overflow[side]);
|
|
1584
|
+
}
|
|
1585
|
+
if (checkCrossAxis) {
|
|
1586
|
+
const {
|
|
1587
|
+
main,
|
|
1588
|
+
cross
|
|
1589
|
+
} = getAlignmentSides(placement, rects, rtl);
|
|
1590
|
+
overflows.push(overflow[main], overflow[cross]);
|
|
1591
|
+
}
|
|
1592
|
+
overflowsData = [...overflowsData, {
|
|
1593
|
+
placement,
|
|
1594
|
+
overflows
|
|
1595
|
+
}];
|
|
2320
1596
|
|
|
2321
|
-
|
|
1597
|
+
// One or more sides is overflowing.
|
|
1598
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1599
|
+
var _middlewareData$flip2, _overflowsData$find;
|
|
1600
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1601
|
+
const nextPlacement = placements[nextIndex];
|
|
1602
|
+
if (nextPlacement) {
|
|
1603
|
+
// Try next placement and re-run the lifecycle.
|
|
1604
|
+
return {
|
|
1605
|
+
data: {
|
|
1606
|
+
index: nextIndex,
|
|
1607
|
+
overflows: overflowsData
|
|
1608
|
+
},
|
|
1609
|
+
reset: {
|
|
1610
|
+
placement: nextPlacement
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
2322
1614
|
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
1615
|
+
// First, try to use the one that fits on mainAxis side of overflow.
|
|
1616
|
+
let resetPlacement = (_overflowsData$find = overflowsData.find(d => d.overflows[0] <= 0)) == null ? void 0 : _overflowsData$find.placement;
|
|
2327
1617
|
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
1618
|
+
// Otherwise fallback.
|
|
1619
|
+
if (!resetPlacement) {
|
|
1620
|
+
switch (fallbackStrategy) {
|
|
1621
|
+
case 'bestFit':
|
|
1622
|
+
{
|
|
1623
|
+
var _overflowsData$map$so;
|
|
1624
|
+
const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
|
|
1625
|
+
if (placement) {
|
|
1626
|
+
resetPlacement = placement;
|
|
1627
|
+
}
|
|
1628
|
+
break;
|
|
1629
|
+
}
|
|
1630
|
+
case 'initialPlacement':
|
|
1631
|
+
resetPlacement = initialPlacement;
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
if (placement !== resetPlacement) {
|
|
1636
|
+
return {
|
|
1637
|
+
reset: {
|
|
1638
|
+
placement: resetPlacement
|
|
1639
|
+
}
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
return {};
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
};
|
|
2332
1647
|
|
|
2333
|
-
|
|
2334
|
-
|
|
1648
|
+
async function convertValueToCoords(middlewareArguments, value) {
|
|
1649
|
+
const {
|
|
1650
|
+
placement,
|
|
1651
|
+
platform,
|
|
1652
|
+
elements
|
|
1653
|
+
} = middlewareArguments;
|
|
1654
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1655
|
+
const side = getSide(placement);
|
|
1656
|
+
const alignment = getAlignment(placement);
|
|
1657
|
+
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
1658
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
1659
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1660
|
+
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
|
|
2335
1661
|
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
1662
|
+
// eslint-disable-next-line prefer-const
|
|
1663
|
+
let {
|
|
1664
|
+
mainAxis,
|
|
1665
|
+
crossAxis,
|
|
1666
|
+
alignmentAxis
|
|
1667
|
+
} = typeof rawValue === 'number' ? {
|
|
1668
|
+
mainAxis: rawValue,
|
|
1669
|
+
crossAxis: 0,
|
|
1670
|
+
alignmentAxis: null
|
|
1671
|
+
} : {
|
|
1672
|
+
mainAxis: 0,
|
|
1673
|
+
crossAxis: 0,
|
|
1674
|
+
alignmentAxis: null,
|
|
1675
|
+
...rawValue
|
|
1676
|
+
};
|
|
1677
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1678
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1679
|
+
}
|
|
1680
|
+
return isVertical ? {
|
|
1681
|
+
x: crossAxis * crossAxisMulti,
|
|
1682
|
+
y: mainAxis * mainAxisMulti
|
|
1683
|
+
} : {
|
|
1684
|
+
x: mainAxis * mainAxisMulti,
|
|
1685
|
+
y: crossAxis * crossAxisMulti
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
2339
1688
|
|
|
2340
|
-
|
|
1689
|
+
/**
|
|
1690
|
+
* Displaces the floating element from its reference element.
|
|
1691
|
+
* @see https://floating-ui.com/docs/offset
|
|
1692
|
+
*/
|
|
1693
|
+
const offset = function (value) {
|
|
1694
|
+
if (value === void 0) {
|
|
1695
|
+
value = 0;
|
|
1696
|
+
}
|
|
1697
|
+
return {
|
|
1698
|
+
name: 'offset',
|
|
1699
|
+
options: value,
|
|
1700
|
+
async fn(middlewareArguments) {
|
|
1701
|
+
const {
|
|
1702
|
+
x,
|
|
1703
|
+
y
|
|
1704
|
+
} = middlewareArguments;
|
|
1705
|
+
const diffCoords = await convertValueToCoords(middlewareArguments, value);
|
|
1706
|
+
return {
|
|
1707
|
+
x: x + diffCoords.x,
|
|
1708
|
+
y: y + diffCoords.y,
|
|
1709
|
+
data: diffCoords
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
};
|
|
1713
|
+
};
|
|
2341
1714
|
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
info += getDeclarationErrorAddendum();
|
|
2346
|
-
}
|
|
1715
|
+
function getCrossAxis(axis) {
|
|
1716
|
+
return axis === 'x' ? 'y' : 'x';
|
|
1717
|
+
}
|
|
2347
1718
|
|
|
2348
|
-
|
|
1719
|
+
/**
|
|
1720
|
+
* Shifts the floating element in order to keep it in view when it will overflow
|
|
1721
|
+
* a clipping boundary.
|
|
1722
|
+
* @see https://floating-ui.com/docs/shift
|
|
1723
|
+
*/
|
|
1724
|
+
const shift = function (options) {
|
|
1725
|
+
if (options === void 0) {
|
|
1726
|
+
options = {};
|
|
1727
|
+
}
|
|
1728
|
+
return {
|
|
1729
|
+
name: 'shift',
|
|
1730
|
+
options,
|
|
1731
|
+
async fn(middlewareArguments) {
|
|
1732
|
+
const {
|
|
1733
|
+
x,
|
|
1734
|
+
y,
|
|
1735
|
+
placement
|
|
1736
|
+
} = middlewareArguments;
|
|
1737
|
+
const {
|
|
1738
|
+
mainAxis: checkMainAxis = true,
|
|
1739
|
+
crossAxis: checkCrossAxis = false,
|
|
1740
|
+
limiter = {
|
|
1741
|
+
fn: _ref => {
|
|
1742
|
+
let {
|
|
1743
|
+
x,
|
|
1744
|
+
y
|
|
1745
|
+
} = _ref;
|
|
1746
|
+
return {
|
|
1747
|
+
x,
|
|
1748
|
+
y
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
},
|
|
1752
|
+
...detectOverflowOptions
|
|
1753
|
+
} = options;
|
|
1754
|
+
const coords = {
|
|
1755
|
+
x,
|
|
1756
|
+
y
|
|
1757
|
+
};
|
|
1758
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1759
|
+
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
1760
|
+
const crossAxis = getCrossAxis(mainAxis);
|
|
1761
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1762
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1763
|
+
if (checkMainAxis) {
|
|
1764
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1765
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1766
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1767
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1768
|
+
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
1769
|
+
}
|
|
1770
|
+
if (checkCrossAxis) {
|
|
1771
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1772
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1773
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1774
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1775
|
+
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
1776
|
+
}
|
|
1777
|
+
const limitedCoords = limiter.fn({
|
|
1778
|
+
...middlewareArguments,
|
|
1779
|
+
[mainAxis]: mainAxisCoord,
|
|
1780
|
+
[crossAxis]: crossAxisCoord
|
|
1781
|
+
});
|
|
1782
|
+
return {
|
|
1783
|
+
...limitedCoords,
|
|
1784
|
+
data: {
|
|
1785
|
+
x: limitedCoords.x - x,
|
|
1786
|
+
y: limitedCoords.y - y
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
};
|
|
2349
1792
|
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
2355
|
-
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
2356
|
-
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
2357
|
-
} else {
|
|
2358
|
-
typeString = typeof type;
|
|
2359
|
-
}
|
|
1793
|
+
function getWindow(node) {
|
|
1794
|
+
var _node$ownerDocument;
|
|
1795
|
+
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1796
|
+
}
|
|
2360
1797
|
|
|
2361
|
-
|
|
2362
|
-
|
|
1798
|
+
function getComputedStyle$1(element) {
|
|
1799
|
+
return getWindow(element).getComputedStyle(element);
|
|
1800
|
+
}
|
|
2363
1801
|
|
|
2364
|
-
|
|
2365
|
-
|
|
1802
|
+
const min = Math.min;
|
|
1803
|
+
const max = Math.max;
|
|
1804
|
+
const round = Math.round;
|
|
2366
1805
|
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
1806
|
+
function getCssDimensions(element) {
|
|
1807
|
+
const css = getComputedStyle$1(element);
|
|
1808
|
+
let width = parseFloat(css.width);
|
|
1809
|
+
let height = parseFloat(css.height);
|
|
1810
|
+
const offsetWidth = element.offsetWidth;
|
|
1811
|
+
const offsetHeight = element.offsetHeight;
|
|
1812
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1813
|
+
if (shouldFallback) {
|
|
1814
|
+
width = offsetWidth;
|
|
1815
|
+
height = offsetHeight;
|
|
1816
|
+
}
|
|
1817
|
+
return {
|
|
1818
|
+
width,
|
|
1819
|
+
height,
|
|
1820
|
+
fallback: shouldFallback
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
2374
1823
|
|
|
1824
|
+
function getNodeName(node) {
|
|
1825
|
+
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
1826
|
+
}
|
|
2375
1827
|
|
|
2376
|
-
|
|
2377
|
-
|
|
1828
|
+
let uaString;
|
|
1829
|
+
function getUAString() {
|
|
1830
|
+
if (uaString) {
|
|
1831
|
+
return uaString;
|
|
1832
|
+
}
|
|
1833
|
+
const uaData = navigator.userAgentData;
|
|
1834
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
1835
|
+
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
1836
|
+
return uaString;
|
|
1837
|
+
}
|
|
1838
|
+
return navigator.userAgent;
|
|
1839
|
+
}
|
|
2378
1840
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
1841
|
+
function isHTMLElement(value) {
|
|
1842
|
+
return value instanceof getWindow(value).HTMLElement;
|
|
1843
|
+
}
|
|
1844
|
+
function isElement(value) {
|
|
1845
|
+
return value instanceof getWindow(value).Element;
|
|
1846
|
+
}
|
|
1847
|
+
function isNode(value) {
|
|
1848
|
+
return value instanceof getWindow(value).Node;
|
|
1849
|
+
}
|
|
1850
|
+
function isShadowRoot(node) {
|
|
1851
|
+
// Browsers without `ShadowRoot` support.
|
|
1852
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
1853
|
+
return false;
|
|
1854
|
+
}
|
|
1855
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
|
1856
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1857
|
+
}
|
|
1858
|
+
function isOverflowElement(element) {
|
|
1859
|
+
const {
|
|
1860
|
+
overflow,
|
|
1861
|
+
overflowX,
|
|
1862
|
+
overflowY,
|
|
1863
|
+
display
|
|
1864
|
+
} = getComputedStyle$1(element);
|
|
1865
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
1866
|
+
}
|
|
1867
|
+
function isTableElement(element) {
|
|
1868
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
1869
|
+
}
|
|
1870
|
+
function isContainingBlock(element) {
|
|
1871
|
+
// TODO: Try to use feature detection here instead.
|
|
1872
|
+
const isFirefox = /firefox/i.test(getUAString());
|
|
1873
|
+
const css = getComputedStyle$1(element);
|
|
1874
|
+
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
2385
1875
|
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
1876
|
+
// This is non-exhaustive but covers the most common CSS properties that
|
|
1877
|
+
// create a containing block.
|
|
1878
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1879
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
|
|
1880
|
+
// Add type check for old browsers.
|
|
1881
|
+
const contain = css.contain;
|
|
1882
|
+
return contain != null ? contain.includes(value) : false;
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
function isLayoutViewport() {
|
|
1886
|
+
// TODO: Try to use feature detection here instead. Feature detection for
|
|
1887
|
+
// this can fail in various ways, making the userAgent check the most:
|
|
1888
|
+
// reliable:
|
|
1889
|
+
// • Always-visible scrollbar or not
|
|
1890
|
+
// • Width of <html>
|
|
2397
1891
|
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
1892
|
+
// Not Safari.
|
|
1893
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
1894
|
+
}
|
|
1895
|
+
function isLastTraversableNode(node) {
|
|
1896
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
1897
|
+
}
|
|
2403
1898
|
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
// even with the prod transform. This means that jsxDEV is purely
|
|
2408
|
-
// opt-in behavior for better messages but that we won't stop
|
|
2409
|
-
// giving you warnings if you use production apis.
|
|
1899
|
+
function unwrapElement(element) {
|
|
1900
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1901
|
+
}
|
|
2410
1902
|
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
1903
|
+
const FALLBACK_SCALE = {
|
|
1904
|
+
x: 1,
|
|
1905
|
+
y: 1
|
|
1906
|
+
};
|
|
1907
|
+
function getScale(element) {
|
|
1908
|
+
const domElement = unwrapElement(element);
|
|
1909
|
+
if (!isHTMLElement(domElement)) {
|
|
1910
|
+
return FALLBACK_SCALE;
|
|
1911
|
+
}
|
|
1912
|
+
const rect = domElement.getBoundingClientRect();
|
|
1913
|
+
const {
|
|
1914
|
+
width,
|
|
1915
|
+
height,
|
|
1916
|
+
fallback
|
|
1917
|
+
} = getCssDimensions(domElement);
|
|
1918
|
+
let x = (fallback ? round(rect.width) : rect.width) / width;
|
|
1919
|
+
let y = (fallback ? round(rect.height) : rect.height) / height;
|
|
2421
1920
|
|
|
2422
|
-
|
|
2423
|
-
// for now we can ship identical prod functions
|
|
1921
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
2424
1922
|
|
|
2425
|
-
|
|
1923
|
+
if (!x || !Number.isFinite(x)) {
|
|
1924
|
+
x = 1;
|
|
1925
|
+
}
|
|
1926
|
+
if (!y || !Number.isFinite(y)) {
|
|
1927
|
+
y = 1;
|
|
1928
|
+
}
|
|
1929
|
+
return {
|
|
1930
|
+
x,
|
|
1931
|
+
y
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
2426
1934
|
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
1935
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1936
|
+
var _win$visualViewport, _win$visualViewport2;
|
|
1937
|
+
if (includeScale === void 0) {
|
|
1938
|
+
includeScale = false;
|
|
1939
|
+
}
|
|
1940
|
+
if (isFixedStrategy === void 0) {
|
|
1941
|
+
isFixedStrategy = false;
|
|
1942
|
+
}
|
|
1943
|
+
const clientRect = element.getBoundingClientRect();
|
|
1944
|
+
const domElement = unwrapElement(element);
|
|
1945
|
+
let scale = FALLBACK_SCALE;
|
|
1946
|
+
if (includeScale) {
|
|
1947
|
+
if (offsetParent) {
|
|
1948
|
+
if (isElement(offsetParent)) {
|
|
1949
|
+
scale = getScale(offsetParent);
|
|
1950
|
+
}
|
|
1951
|
+
} else {
|
|
1952
|
+
scale = getScale(element);
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
const win = domElement ? getWindow(domElement) : window;
|
|
1956
|
+
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
1957
|
+
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
|
|
1958
|
+
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
1959
|
+
let width = clientRect.width / scale.x;
|
|
1960
|
+
let height = clientRect.height / scale.y;
|
|
1961
|
+
if (domElement) {
|
|
1962
|
+
const win = getWindow(domElement);
|
|
1963
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1964
|
+
let currentIFrame = win.frameElement;
|
|
1965
|
+
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
1966
|
+
const iframeScale = getScale(currentIFrame);
|
|
1967
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1968
|
+
const css = getComputedStyle(currentIFrame);
|
|
1969
|
+
iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1970
|
+
iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1971
|
+
x *= iframeScale.x;
|
|
1972
|
+
y *= iframeScale.y;
|
|
1973
|
+
width *= iframeScale.x;
|
|
1974
|
+
height *= iframeScale.y;
|
|
1975
|
+
x += iframeRect.x;
|
|
1976
|
+
y += iframeRect.y;
|
|
1977
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
return {
|
|
1981
|
+
width,
|
|
1982
|
+
height,
|
|
1983
|
+
top: y,
|
|
1984
|
+
right: x + width,
|
|
1985
|
+
bottom: y + height,
|
|
1986
|
+
left: x,
|
|
1987
|
+
x,
|
|
1988
|
+
y
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
2432
1991
|
|
|
2433
|
-
|
|
1992
|
+
function getDocumentElement(node) {
|
|
1993
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
1994
|
+
}
|
|
2434
1995
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
1996
|
+
function getNodeScroll(element) {
|
|
1997
|
+
if (isElement(element)) {
|
|
1998
|
+
return {
|
|
1999
|
+
scrollLeft: element.scrollLeft,
|
|
2000
|
+
scrollTop: element.scrollTop
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
2003
|
+
return {
|
|
2004
|
+
scrollLeft: element.pageXOffset,
|
|
2005
|
+
scrollTop: element.pageYOffset
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2439
2008
|
|
|
2440
|
-
|
|
2009
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2010
|
+
let {
|
|
2011
|
+
rect,
|
|
2012
|
+
offsetParent,
|
|
2013
|
+
strategy
|
|
2014
|
+
} = _ref;
|
|
2015
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2016
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2017
|
+
if (offsetParent === documentElement) {
|
|
2018
|
+
return rect;
|
|
2019
|
+
}
|
|
2020
|
+
let scroll = {
|
|
2021
|
+
scrollLeft: 0,
|
|
2022
|
+
scrollTop: 0
|
|
2023
|
+
};
|
|
2024
|
+
let scale = {
|
|
2025
|
+
x: 1,
|
|
2026
|
+
y: 1
|
|
2027
|
+
};
|
|
2028
|
+
const offsets = {
|
|
2029
|
+
x: 0,
|
|
2030
|
+
y: 0
|
|
2031
|
+
};
|
|
2032
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
2033
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2034
|
+
scroll = getNodeScroll(offsetParent);
|
|
2035
|
+
}
|
|
2036
|
+
if (isHTMLElement(offsetParent)) {
|
|
2037
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2038
|
+
scale = getScale(offsetParent);
|
|
2039
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2040
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return {
|
|
2044
|
+
width: rect.width * scale.x,
|
|
2045
|
+
height: rect.height * scale.y,
|
|
2046
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
2047
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2441
2050
|
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2051
|
+
function getWindowScrollBarX(element) {
|
|
2052
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2053
|
+
// incorrect for RTL.
|
|
2054
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
2055
|
+
}
|
|
2447
2056
|
|
|
2448
|
-
|
|
2449
|
-
|
|
2057
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
2058
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2059
|
+
function getDocumentRect(element) {
|
|
2060
|
+
const html = getDocumentElement(element);
|
|
2061
|
+
const scroll = getNodeScroll(element);
|
|
2062
|
+
const body = element.ownerDocument.body;
|
|
2063
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2064
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2065
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2066
|
+
const y = -scroll.scrollTop;
|
|
2067
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
2068
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
2069
|
+
}
|
|
2070
|
+
return {
|
|
2071
|
+
width,
|
|
2072
|
+
height,
|
|
2073
|
+
x,
|
|
2074
|
+
y
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2450
2077
|
|
|
2451
|
-
|
|
2078
|
+
function getParentNode(node) {
|
|
2079
|
+
if (getNodeName(node) === 'html') {
|
|
2080
|
+
return node;
|
|
2081
|
+
}
|
|
2082
|
+
const result =
|
|
2083
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
2084
|
+
node.assignedSlot ||
|
|
2085
|
+
// DOM Element detected.
|
|
2086
|
+
node.parentNode ||
|
|
2087
|
+
// ShadowRoot detected.
|
|
2088
|
+
isShadowRoot(node) && node.host ||
|
|
2089
|
+
// Fallback.
|
|
2090
|
+
getDocumentElement(node);
|
|
2091
|
+
return isShadowRoot(result) ? result.host : result;
|
|
2092
|
+
}
|
|
2452
2093
|
|
|
2453
|
-
|
|
2094
|
+
function getNearestOverflowAncestor(node) {
|
|
2095
|
+
const parentNode = getParentNode(node);
|
|
2096
|
+
if (isLastTraversableNode(parentNode)) {
|
|
2097
|
+
// `getParentNode` will never return a `Document` due to the fallback
|
|
2098
|
+
// check, so it's either the <html> or <body> element.
|
|
2099
|
+
return parentNode.ownerDocument.body;
|
|
2100
|
+
}
|
|
2101
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
2102
|
+
return parentNode;
|
|
2103
|
+
}
|
|
2104
|
+
return getNearestOverflowAncestor(parentNode);
|
|
2105
|
+
}
|
|
2454
2106
|
|
|
2455
|
-
|
|
2456
|
-
|
|
2107
|
+
function getOverflowAncestors(node, list) {
|
|
2108
|
+
var _node$ownerDocument;
|
|
2109
|
+
if (list === void 0) {
|
|
2110
|
+
list = [];
|
|
2111
|
+
}
|
|
2112
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
2113
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
2114
|
+
const win = getWindow(scrollableAncestor);
|
|
2115
|
+
if (isBody) {
|
|
2116
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
2117
|
+
}
|
|
2118
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
2119
|
+
}
|
|
2457
2120
|
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2121
|
+
function getViewportRect(element, strategy) {
|
|
2122
|
+
const win = getWindow(element);
|
|
2123
|
+
const html = getDocumentElement(element);
|
|
2124
|
+
const visualViewport = win.visualViewport;
|
|
2125
|
+
let width = html.clientWidth;
|
|
2126
|
+
let height = html.clientHeight;
|
|
2127
|
+
let x = 0;
|
|
2128
|
+
let y = 0;
|
|
2129
|
+
if (visualViewport) {
|
|
2130
|
+
width = visualViewport.width;
|
|
2131
|
+
height = visualViewport.height;
|
|
2132
|
+
const layoutViewport = isLayoutViewport();
|
|
2133
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
2134
|
+
x = visualViewport.offsetLeft;
|
|
2135
|
+
y = visualViewport.offsetTop;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
return {
|
|
2139
|
+
width,
|
|
2140
|
+
height,
|
|
2141
|
+
x,
|
|
2142
|
+
y
|
|
2143
|
+
};
|
|
2144
|
+
}
|
|
2461
2145
|
|
|
2462
|
-
|
|
2146
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
2147
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2148
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
2149
|
+
const top = clientRect.top + element.clientTop;
|
|
2150
|
+
const left = clientRect.left + element.clientLeft;
|
|
2151
|
+
const scale = isHTMLElement(element) ? getScale(element) : {
|
|
2152
|
+
x: 1,
|
|
2153
|
+
y: 1
|
|
2154
|
+
};
|
|
2155
|
+
const width = element.clientWidth * scale.x;
|
|
2156
|
+
const height = element.clientHeight * scale.y;
|
|
2157
|
+
const x = left * scale.x;
|
|
2158
|
+
const y = top * scale.y;
|
|
2159
|
+
return {
|
|
2160
|
+
width,
|
|
2161
|
+
height,
|
|
2162
|
+
x,
|
|
2163
|
+
y
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2167
|
+
if (clippingAncestor === 'viewport') {
|
|
2168
|
+
return rectToClientRect(getViewportRect(element, strategy));
|
|
2169
|
+
}
|
|
2170
|
+
if (isElement(clippingAncestor)) {
|
|
2171
|
+
return rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy));
|
|
2172
|
+
}
|
|
2173
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
2174
|
+
}
|
|
2463
2175
|
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
continue;
|
|
2477
|
-
}
|
|
2176
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
2177
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
2178
|
+
// of the given element up the tree.
|
|
2179
|
+
function getClippingElementAncestors(element, cache) {
|
|
2180
|
+
const cachedResult = cache.get(element);
|
|
2181
|
+
if (cachedResult) {
|
|
2182
|
+
return cachedResult;
|
|
2183
|
+
}
|
|
2184
|
+
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
2185
|
+
let currentContainingBlockComputedStyle = null;
|
|
2186
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
2187
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2478
2188
|
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2189
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2190
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2191
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
2192
|
+
const containingBlock = isContainingBlock(currentNode);
|
|
2193
|
+
const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position);
|
|
2194
|
+
if (shouldDropCurrentNode) {
|
|
2195
|
+
// Drop non-containing blocks.
|
|
2196
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
2197
|
+
} else {
|
|
2198
|
+
// Record last containing block for next iteration.
|
|
2199
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
2200
|
+
}
|
|
2201
|
+
currentNode = getParentNode(currentNode);
|
|
2202
|
+
}
|
|
2203
|
+
cache.set(element, result);
|
|
2204
|
+
return result;
|
|
2205
|
+
}
|
|
2486
2206
|
|
|
2487
|
-
|
|
2488
|
-
|
|
2207
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
2208
|
+
// clipping ancestors.
|
|
2209
|
+
function getClippingRect(_ref) {
|
|
2210
|
+
let {
|
|
2211
|
+
element,
|
|
2212
|
+
boundary,
|
|
2213
|
+
rootBoundary,
|
|
2214
|
+
strategy
|
|
2215
|
+
} = _ref;
|
|
2216
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2217
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2218
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
2219
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
2220
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
2221
|
+
accRect.top = max(rect.top, accRect.top);
|
|
2222
|
+
accRect.right = min(rect.right, accRect.right);
|
|
2223
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
2224
|
+
accRect.left = max(rect.left, accRect.left);
|
|
2225
|
+
return accRect;
|
|
2226
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
2227
|
+
return {
|
|
2228
|
+
width: clippingRect.right - clippingRect.left,
|
|
2229
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
2230
|
+
x: clippingRect.left,
|
|
2231
|
+
y: clippingRect.top
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2489
2234
|
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
}());
|
|
2497
|
-
} (classnames));
|
|
2235
|
+
function getDimensions(element) {
|
|
2236
|
+
if (isHTMLElement(element)) {
|
|
2237
|
+
return getCssDimensions(element);
|
|
2238
|
+
}
|
|
2239
|
+
return element.getBoundingClientRect();
|
|
2240
|
+
}
|
|
2498
2241
|
|
|
2499
|
-
|
|
2242
|
+
function getTrueOffsetParent(element) {
|
|
2243
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
2244
|
+
return null;
|
|
2245
|
+
}
|
|
2246
|
+
return element.offsetParent;
|
|
2247
|
+
}
|
|
2248
|
+
function getContainingBlock(element) {
|
|
2249
|
+
let currentNode = getParentNode(element);
|
|
2250
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2251
|
+
if (isContainingBlock(currentNode)) {
|
|
2252
|
+
return currentNode;
|
|
2253
|
+
} else {
|
|
2254
|
+
currentNode = getParentNode(currentNode);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return null;
|
|
2258
|
+
}
|
|
2500
2259
|
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
return
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
func.apply(this, args);
|
|
2515
|
-
}
|
|
2516
|
-
};
|
|
2517
|
-
if (timeout) {
|
|
2518
|
-
clearTimeout(timeout);
|
|
2519
|
-
}
|
|
2520
|
-
timeout = setTimeout(later, wait);
|
|
2521
|
-
};
|
|
2522
|
-
};
|
|
2260
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2261
|
+
// such as table ancestors and cross browser bugs.
|
|
2262
|
+
function getOffsetParent(element) {
|
|
2263
|
+
const window = getWindow(element);
|
|
2264
|
+
let offsetParent = getTrueOffsetParent(element);
|
|
2265
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
|
2266
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
2267
|
+
}
|
|
2268
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
2269
|
+
return window;
|
|
2270
|
+
}
|
|
2271
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
2272
|
+
}
|
|
2523
2273
|
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2274
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
2275
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2276
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2277
|
+
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
|
|
2278
|
+
let scroll = {
|
|
2279
|
+
scrollLeft: 0,
|
|
2280
|
+
scrollTop: 0
|
|
2281
|
+
};
|
|
2282
|
+
const offsets = {
|
|
2283
|
+
x: 0,
|
|
2284
|
+
y: 0
|
|
2285
|
+
};
|
|
2286
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
2287
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2288
|
+
scroll = getNodeScroll(offsetParent);
|
|
2289
|
+
}
|
|
2290
|
+
if (isHTMLElement(offsetParent)) {
|
|
2291
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
2292
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2293
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2294
|
+
} else if (documentElement) {
|
|
2295
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
2300
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
2301
|
+
width: rect.width,
|
|
2302
|
+
height: rect.height
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2527
2305
|
|
|
2528
|
-
const
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
const [anchorRefMap, setAnchorRefMap] = require$$0.useState({
|
|
2552
|
-
[DEFAULT_TOOLTIP_ID]: new Set(),
|
|
2553
|
-
});
|
|
2554
|
-
const [activeAnchorMap, setActiveAnchorMap] = require$$0.useState({
|
|
2555
|
-
[DEFAULT_TOOLTIP_ID]: { current: null },
|
|
2556
|
-
});
|
|
2557
|
-
const attach = (tooltipId, ...refs) => {
|
|
2558
|
-
setAnchorRefMap((oldMap) => {
|
|
2559
|
-
var _a;
|
|
2560
|
-
const tooltipRefs = (_a = oldMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set();
|
|
2561
|
-
refs.forEach((ref) => tooltipRefs.add(ref));
|
|
2562
|
-
// create new object to trigger re-render
|
|
2563
|
-
return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
|
|
2564
|
-
});
|
|
2565
|
-
};
|
|
2566
|
-
const detach = (tooltipId, ...refs) => {
|
|
2567
|
-
setAnchorRefMap((oldMap) => {
|
|
2568
|
-
const tooltipRefs = oldMap[tooltipId];
|
|
2569
|
-
if (!tooltipRefs) {
|
|
2570
|
-
// tooltip not found
|
|
2571
|
-
// maybe thow error?
|
|
2572
|
-
return oldMap;
|
|
2573
|
-
}
|
|
2574
|
-
refs.forEach((ref) => tooltipRefs.delete(ref));
|
|
2575
|
-
// create new object to trigger re-render
|
|
2576
|
-
return { ...oldMap };
|
|
2577
|
-
});
|
|
2578
|
-
};
|
|
2579
|
-
const setActiveAnchor = (tooltipId, ref) => {
|
|
2580
|
-
setActiveAnchorMap((oldMap) => {
|
|
2581
|
-
var _a;
|
|
2582
|
-
if (((_a = oldMap[tooltipId]) === null || _a === void 0 ? void 0 : _a.current) === ref.current) {
|
|
2583
|
-
return oldMap;
|
|
2584
|
-
}
|
|
2585
|
-
// create new object to trigger re-render
|
|
2586
|
-
return { ...oldMap, [tooltipId]: ref };
|
|
2587
|
-
});
|
|
2306
|
+
const platform = {
|
|
2307
|
+
getClippingRect,
|
|
2308
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
2309
|
+
isElement,
|
|
2310
|
+
getDimensions,
|
|
2311
|
+
getOffsetParent,
|
|
2312
|
+
getDocumentElement,
|
|
2313
|
+
getScale,
|
|
2314
|
+
async getElementRects(_ref) {
|
|
2315
|
+
let {
|
|
2316
|
+
reference,
|
|
2317
|
+
floating,
|
|
2318
|
+
strategy
|
|
2319
|
+
} = _ref;
|
|
2320
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2321
|
+
const getDimensionsFn = this.getDimensions;
|
|
2322
|
+
return {
|
|
2323
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
2324
|
+
floating: {
|
|
2325
|
+
x: 0,
|
|
2326
|
+
y: 0,
|
|
2327
|
+
...(await getDimensionsFn(floating))
|
|
2328
|
+
}
|
|
2588
2329
|
};
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
anchorRefs: (_a = anchorRefMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set(),
|
|
2593
|
-
activeAnchor: (_b = activeAnchorMap[tooltipId]) !== null && _b !== void 0 ? _b : { current: null },
|
|
2594
|
-
attach: (...refs) => attach(tooltipId, ...refs),
|
|
2595
|
-
detach: (...refs) => detach(tooltipId, ...refs),
|
|
2596
|
-
setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref),
|
|
2597
|
-
});
|
|
2598
|
-
}, [anchorRefMap, activeAnchorMap, attach, detach]);
|
|
2599
|
-
const context = require$$0.useMemo(() => {
|
|
2600
|
-
return {
|
|
2601
|
-
getTooltipData,
|
|
2602
|
-
};
|
|
2603
|
-
}, [getTooltipData]);
|
|
2604
|
-
return jsxRuntime.exports.jsx(TooltipContext.Provider, { value: context, children: children });
|
|
2330
|
+
},
|
|
2331
|
+
getClientRects: element => Array.from(element.getClientRects()),
|
|
2332
|
+
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
2605
2333
|
};
|
|
2606
|
-
function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
|
|
2607
|
-
return require$$0.useContext(TooltipContext).getTooltipData(tooltipId);
|
|
2608
|
-
}
|
|
2609
2334
|
|
|
2610
2335
|
/**
|
|
2611
|
-
*
|
|
2612
|
-
*
|
|
2336
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2337
|
+
* next to a reference element when it is given a certain CSS positioning
|
|
2338
|
+
* strategy.
|
|
2613
2339
|
*/
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2340
|
+
const computePosition = (reference, floating, options) => {
|
|
2341
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
2342
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
2343
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
2344
|
+
const cache = new Map();
|
|
2345
|
+
const mergedOptions = {
|
|
2346
|
+
platform,
|
|
2347
|
+
...options
|
|
2348
|
+
};
|
|
2349
|
+
const platformWithCache = {
|
|
2350
|
+
...mergedOptions.platform,
|
|
2351
|
+
_c: cache
|
|
2352
|
+
};
|
|
2353
|
+
return computePosition$1(reference, floating, {
|
|
2354
|
+
...mergedOptions,
|
|
2355
|
+
platform: platformWithCache
|
|
2356
|
+
});
|
|
2624
2357
|
};
|
|
2625
2358
|
|
|
2626
2359
|
const computeTooltipPosition = async ({ elementReference = null, tooltipReference = null, tooltipArrowReference = null, place = 'top', offset: offsetValue = 10, strategy = 'absolute', middlewares = [offset(Number(offsetValue)), flip(), shift({ padding: 5 })], }) => {
|
|
@@ -2699,7 +2432,7 @@
|
|
|
2699
2432
|
* but should be used carefully because of caveats
|
|
2700
2433
|
* https://beta.reactjs.org/reference/react/useLayoutEffect#caveats
|
|
2701
2434
|
*/
|
|
2702
|
-
|
|
2435
|
+
useIsomorphicLayoutEffect(() => {
|
|
2703
2436
|
mounted.current = true;
|
|
2704
2437
|
return () => {
|
|
2705
2438
|
mounted.current = false;
|
|
@@ -3298,12 +3031,6 @@
|
|
|
3298
3031
|
exports.Tooltip = TooltipController;
|
|
3299
3032
|
exports.TooltipProvider = TooltipProvider;
|
|
3300
3033
|
exports.TooltipWrapper = TooltipWrapper;
|
|
3301
|
-
exports.autoPlacement = autoPlacement;
|
|
3302
|
-
exports.flip = flip;
|
|
3303
|
-
exports.inline = inline;
|
|
3304
|
-
exports.offset = offset;
|
|
3305
|
-
exports.shift = shift;
|
|
3306
|
-
exports.size = size;
|
|
3307
3034
|
|
|
3308
3035
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3309
3036
|
|