@haiilo/catalyst 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-89a97b7b.entry.js +10 -0
- package/dist/catalyst/p-89a97b7b.entry.js.map +1 -0
- package/dist/cjs/{cat-alert_8.cjs.entry.js → cat-alert_9.cjs.entry.js} +158 -51
- package/dist/cjs/cat-alert_9.cjs.entry.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/cat-menu/cat-menu.js +3 -5
- package/dist/collection/components/cat-menu/cat-menu.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +37 -0
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +254 -0
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -0
- package/dist/collection/utils/first-tabbable.js +6 -0
- package/dist/collection/utils/first-tabbable.js.map +1 -0
- package/dist/collection/utils/is-touch-screen.js +3 -0
- package/dist/collection/utils/is-touch-screen.js.map +1 -0
- package/dist/components/cat-menu.js +11 -1519
- package/dist/components/cat-menu.js.map +1 -1
- package/dist/components/cat-tooltip.d.ts +11 -0
- package/dist/components/cat-tooltip.js +154 -0
- package/dist/components/cat-tooltip.js.map +1 -0
- package/dist/components/first-tabbable.js +1495 -0
- package/dist/components/first-tabbable.js.map +1 -0
- package/dist/esm/{cat-alert_8.entry.js → cat-alert_9.entry.js} +158 -52
- package/dist/esm/cat-alert_9.entry.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-menu/cat-menu.d.ts +0 -1
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +46 -0
- package/dist/types/components.d.ts +61 -0
- package/dist/types/utils/first-tabbable.d.ts +4 -0
- package/dist/types/utils/is-touch-screen.d.ts +2 -0
- package/package.json +7 -7
- package/dist/catalyst/p-31b500c7.entry.js +0 -10
- package/dist/catalyst/p-31b500c7.entry.js.map +0 -1
- package/dist/cjs/cat-alert_8.cjs.entry.js.map +0 -1
- package/dist/esm/cat-alert_8.entry.js.map +0 -1
|
@@ -1,1507 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
|
|
3
|
-
function getSide(placement) {
|
|
4
|
-
return placement.split('-')[0];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function getAlignment(placement) {
|
|
8
|
-
return placement.split('-')[1];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function getMainAxisFromPlacement(placement) {
|
|
12
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getLengthFromAxis(axis) {
|
|
16
|
-
return axis === 'y' ? 'height' : 'width';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
20
|
-
let {
|
|
21
|
-
reference,
|
|
22
|
-
floating
|
|
23
|
-
} = _ref;
|
|
24
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
25
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
26
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
27
|
-
const length = getLengthFromAxis(mainAxis);
|
|
28
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
29
|
-
const side = getSide(placement);
|
|
30
|
-
const isVertical = mainAxis === 'x';
|
|
31
|
-
let coords;
|
|
32
|
-
|
|
33
|
-
switch (side) {
|
|
34
|
-
case 'top':
|
|
35
|
-
coords = {
|
|
36
|
-
x: commonX,
|
|
37
|
-
y: reference.y - floating.height
|
|
38
|
-
};
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case 'bottom':
|
|
42
|
-
coords = {
|
|
43
|
-
x: commonX,
|
|
44
|
-
y: reference.y + reference.height
|
|
45
|
-
};
|
|
46
|
-
break;
|
|
47
|
-
|
|
48
|
-
case 'right':
|
|
49
|
-
coords = {
|
|
50
|
-
x: reference.x + reference.width,
|
|
51
|
-
y: commonY
|
|
52
|
-
};
|
|
53
|
-
break;
|
|
54
|
-
|
|
55
|
-
case 'left':
|
|
56
|
-
coords = {
|
|
57
|
-
x: reference.x - floating.width,
|
|
58
|
-
y: commonY
|
|
59
|
-
};
|
|
60
|
-
break;
|
|
61
|
-
|
|
62
|
-
default:
|
|
63
|
-
coords = {
|
|
64
|
-
x: reference.x,
|
|
65
|
-
y: reference.y
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
switch (getAlignment(placement)) {
|
|
70
|
-
case 'start':
|
|
71
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
72
|
-
break;
|
|
73
|
-
|
|
74
|
-
case 'end':
|
|
75
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
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
|
-
|
|
90
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
91
|
-
const {
|
|
92
|
-
placement = 'bottom',
|
|
93
|
-
strategy = 'absolute',
|
|
94
|
-
middleware = [],
|
|
95
|
-
platform
|
|
96
|
-
} = config;
|
|
97
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
98
|
-
|
|
99
|
-
let rects = await platform.getElementRects({
|
|
100
|
-
reference,
|
|
101
|
-
floating,
|
|
102
|
-
strategy
|
|
103
|
-
});
|
|
104
|
-
let {
|
|
105
|
-
x,
|
|
106
|
-
y
|
|
107
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
108
|
-
let statefulPlacement = placement;
|
|
109
|
-
let middlewareData = {};
|
|
110
|
-
|
|
111
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
112
|
-
|
|
113
|
-
const {
|
|
114
|
-
name,
|
|
115
|
-
fn
|
|
116
|
-
} = middleware[i];
|
|
117
|
-
const {
|
|
118
|
-
x: nextX,
|
|
119
|
-
y: nextY,
|
|
120
|
-
data,
|
|
121
|
-
reset
|
|
122
|
-
} = await fn({
|
|
123
|
-
x,
|
|
124
|
-
y,
|
|
125
|
-
initialPlacement: placement,
|
|
126
|
-
placement: statefulPlacement,
|
|
127
|
-
strategy,
|
|
128
|
-
middlewareData,
|
|
129
|
-
rects,
|
|
130
|
-
platform,
|
|
131
|
-
elements: {
|
|
132
|
-
reference,
|
|
133
|
-
floating
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
x = nextX != null ? nextX : x;
|
|
137
|
-
y = nextY != null ? nextY : y;
|
|
138
|
-
middlewareData = { ...middlewareData,
|
|
139
|
-
[name]: { ...middlewareData[name],
|
|
140
|
-
...data
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (reset) {
|
|
145
|
-
if (typeof reset === 'object') {
|
|
146
|
-
if (reset.placement) {
|
|
147
|
-
statefulPlacement = reset.placement;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (reset.rects) {
|
|
151
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
152
|
-
reference,
|
|
153
|
-
floating,
|
|
154
|
-
strategy
|
|
155
|
-
}) : reset.rects;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
({
|
|
159
|
-
x,
|
|
160
|
-
y
|
|
161
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
i = -1;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
x,
|
|
171
|
-
y,
|
|
172
|
-
placement: statefulPlacement,
|
|
173
|
-
strategy,
|
|
174
|
-
middlewareData
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
function expandPaddingObject(padding) {
|
|
179
|
-
return {
|
|
180
|
-
top: 0,
|
|
181
|
-
right: 0,
|
|
182
|
-
bottom: 0,
|
|
183
|
-
left: 0,
|
|
184
|
-
...padding
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function getSideObjectFromPadding(padding) {
|
|
189
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
190
|
-
top: padding,
|
|
191
|
-
right: padding,
|
|
192
|
-
bottom: padding,
|
|
193
|
-
left: padding
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function rectToClientRect(rect) {
|
|
198
|
-
return { ...rect,
|
|
199
|
-
top: rect.y,
|
|
200
|
-
left: rect.x,
|
|
201
|
-
right: rect.x + rect.width,
|
|
202
|
-
bottom: rect.y + rect.height
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
208
|
-
* element is overflowing a given clipping boundary.
|
|
209
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
210
|
-
* - negative = how many pixels left before it will overflow
|
|
211
|
-
* - 0 = lies flush with the boundary
|
|
212
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
213
|
-
*/
|
|
214
|
-
async function detectOverflow(middlewareArguments, options) {
|
|
215
|
-
var _await$platform$isEle;
|
|
216
|
-
|
|
217
|
-
if (options === void 0) {
|
|
218
|
-
options = {};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const {
|
|
222
|
-
x,
|
|
223
|
-
y,
|
|
224
|
-
platform,
|
|
225
|
-
rects,
|
|
226
|
-
elements,
|
|
227
|
-
strategy
|
|
228
|
-
} = middlewareArguments;
|
|
229
|
-
const {
|
|
230
|
-
boundary = 'clippingAncestors',
|
|
231
|
-
rootBoundary = 'viewport',
|
|
232
|
-
elementContext = 'floating',
|
|
233
|
-
altBoundary = false,
|
|
234
|
-
padding = 0
|
|
235
|
-
} = options;
|
|
236
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
237
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
238
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
239
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
240
|
-
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))),
|
|
241
|
-
boundary,
|
|
242
|
-
rootBoundary,
|
|
243
|
-
strategy
|
|
244
|
-
}));
|
|
245
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
246
|
-
rect: elementContext === 'floating' ? { ...rects.floating,
|
|
247
|
-
x,
|
|
248
|
-
y
|
|
249
|
-
} : rects.reference,
|
|
250
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
251
|
-
strategy
|
|
252
|
-
}) : rects[elementContext]); // positive = overflowing the clipping rect
|
|
253
|
-
// 0 or negative = within the clipping rect
|
|
254
|
-
|
|
255
|
-
return {
|
|
256
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
257
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
258
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
259
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const hash$1 = {
|
|
264
|
-
left: 'right',
|
|
265
|
-
right: 'left',
|
|
266
|
-
bottom: 'top',
|
|
267
|
-
top: 'bottom'
|
|
268
|
-
};
|
|
269
|
-
function getOppositePlacement(placement) {
|
|
270
|
-
return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
274
|
-
if (rtl === void 0) {
|
|
275
|
-
rtl = false;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const alignment = getAlignment(placement);
|
|
279
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
280
|
-
const length = getLengthFromAxis(mainAxis);
|
|
281
|
-
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
282
|
-
|
|
283
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
284
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return {
|
|
288
|
-
main: mainAlignmentSide,
|
|
289
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const hash = {
|
|
294
|
-
start: 'end',
|
|
295
|
-
end: 'start'
|
|
296
|
-
};
|
|
297
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
298
|
-
return placement.replace(/start|end/g, matched => hash[matched]);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function getExpandedPlacements(placement) {
|
|
302
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
303
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Changes the placement of the floating element to one that will fit if the
|
|
308
|
-
* initially specified `placement` does not.
|
|
309
|
-
* @see https://floating-ui.com/docs/flip
|
|
310
|
-
*/
|
|
311
|
-
const flip = function (options) {
|
|
312
|
-
if (options === void 0) {
|
|
313
|
-
options = {};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return {
|
|
317
|
-
name: 'flip',
|
|
318
|
-
options,
|
|
319
|
-
|
|
320
|
-
async fn(middlewareArguments) {
|
|
321
|
-
var _middlewareData$flip;
|
|
322
|
-
|
|
323
|
-
const {
|
|
324
|
-
placement,
|
|
325
|
-
middlewareData,
|
|
326
|
-
rects,
|
|
327
|
-
initialPlacement,
|
|
328
|
-
platform,
|
|
329
|
-
elements
|
|
330
|
-
} = middlewareArguments;
|
|
331
|
-
const {
|
|
332
|
-
mainAxis: checkMainAxis = true,
|
|
333
|
-
crossAxis: checkCrossAxis = true,
|
|
334
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
335
|
-
fallbackStrategy = 'bestFit',
|
|
336
|
-
flipAlignment = true,
|
|
337
|
-
...detectOverflowOptions
|
|
338
|
-
} = options;
|
|
339
|
-
const side = getSide(placement);
|
|
340
|
-
const isBasePlacement = side === initialPlacement;
|
|
341
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
342
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
343
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
344
|
-
const overflows = [];
|
|
345
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
346
|
-
|
|
347
|
-
if (checkMainAxis) {
|
|
348
|
-
overflows.push(overflow[side]);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (checkCrossAxis) {
|
|
352
|
-
const {
|
|
353
|
-
main,
|
|
354
|
-
cross
|
|
355
|
-
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
356
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
overflowsData = [...overflowsData, {
|
|
360
|
-
placement,
|
|
361
|
-
overflows
|
|
362
|
-
}]; // One or more sides is overflowing
|
|
363
|
-
|
|
364
|
-
if (!overflows.every(side => side <= 0)) {
|
|
365
|
-
var _middlewareData$flip$, _middlewareData$flip2;
|
|
366
|
-
|
|
367
|
-
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
368
|
-
const nextPlacement = placements[nextIndex];
|
|
369
|
-
|
|
370
|
-
if (nextPlacement) {
|
|
371
|
-
// Try next placement and re-run the lifecycle
|
|
372
|
-
return {
|
|
373
|
-
data: {
|
|
374
|
-
index: nextIndex,
|
|
375
|
-
overflows: overflowsData
|
|
376
|
-
},
|
|
377
|
-
reset: {
|
|
378
|
-
placement: nextPlacement
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
let resetPlacement = 'bottom';
|
|
384
|
-
|
|
385
|
-
switch (fallbackStrategy) {
|
|
386
|
-
case 'bestFit':
|
|
387
|
-
{
|
|
388
|
-
var _overflowsData$map$so;
|
|
389
|
-
|
|
390
|
-
const placement = (_overflowsData$map$so = overflowsData.map(d => [d, 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].placement;
|
|
391
|
-
|
|
392
|
-
if (placement) {
|
|
393
|
-
resetPlacement = placement;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
case 'initialPlacement':
|
|
400
|
-
resetPlacement = initialPlacement;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (placement !== resetPlacement) {
|
|
405
|
-
return {
|
|
406
|
-
reset: {
|
|
407
|
-
placement: resetPlacement
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return {};
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
};
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
function convertValueToCoords(placement, rects, value, rtl) {
|
|
420
|
-
if (rtl === void 0) {
|
|
421
|
-
rtl = false;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
const side = getSide(placement);
|
|
425
|
-
const alignment = getAlignment(placement);
|
|
426
|
-
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
427
|
-
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
428
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
429
|
-
const rawValue = typeof value === 'function' ? value({ ...rects,
|
|
430
|
-
placement
|
|
431
|
-
}) : value; // eslint-disable-next-line prefer-const
|
|
432
|
-
|
|
433
|
-
let {
|
|
434
|
-
mainAxis,
|
|
435
|
-
crossAxis,
|
|
436
|
-
alignmentAxis
|
|
437
|
-
} = typeof rawValue === 'number' ? {
|
|
438
|
-
mainAxis: rawValue,
|
|
439
|
-
crossAxis: 0,
|
|
440
|
-
alignmentAxis: null
|
|
441
|
-
} : {
|
|
442
|
-
mainAxis: 0,
|
|
443
|
-
crossAxis: 0,
|
|
444
|
-
alignmentAxis: null,
|
|
445
|
-
...rawValue
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
if (alignment && typeof alignmentAxis === 'number') {
|
|
449
|
-
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return isVertical ? {
|
|
453
|
-
x: crossAxis * crossAxisMulti,
|
|
454
|
-
y: mainAxis * mainAxisMulti
|
|
455
|
-
} : {
|
|
456
|
-
x: mainAxis * mainAxisMulti,
|
|
457
|
-
y: crossAxis * crossAxisMulti
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Displaces the floating element from its reference element.
|
|
462
|
-
* @see https://floating-ui.com/docs/offset
|
|
463
|
-
*/
|
|
464
|
-
|
|
465
|
-
const offset = function (value) {
|
|
466
|
-
if (value === void 0) {
|
|
467
|
-
value = 0;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return {
|
|
471
|
-
name: 'offset',
|
|
472
|
-
options: value,
|
|
473
|
-
|
|
474
|
-
async fn(middlewareArguments) {
|
|
475
|
-
const {
|
|
476
|
-
x,
|
|
477
|
-
y,
|
|
478
|
-
placement,
|
|
479
|
-
rects,
|
|
480
|
-
platform,
|
|
481
|
-
elements
|
|
482
|
-
} = middlewareArguments;
|
|
483
|
-
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
484
|
-
return {
|
|
485
|
-
x: x + diffCoords.x,
|
|
486
|
-
y: y + diffCoords.y,
|
|
487
|
-
data: diffCoords
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
};
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
function isWindow(value) {
|
|
495
|
-
return (value == null ? void 0 : value.toString()) === '[object Window]';
|
|
496
|
-
}
|
|
497
|
-
function getWindow(node) {
|
|
498
|
-
if (node == null) {
|
|
499
|
-
return window;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (!isWindow(node)) {
|
|
503
|
-
const ownerDocument = node.ownerDocument;
|
|
504
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
return node;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
function getComputedStyle$1(element) {
|
|
511
|
-
return getWindow(element).getComputedStyle(element);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function getNodeName(node) {
|
|
515
|
-
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function isHTMLElement(value) {
|
|
519
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
520
|
-
}
|
|
521
|
-
function isElement(value) {
|
|
522
|
-
return value instanceof getWindow(value).Element;
|
|
523
|
-
}
|
|
524
|
-
function isNode(value) {
|
|
525
|
-
return value instanceof getWindow(value).Node;
|
|
526
|
-
}
|
|
527
|
-
function isShadowRoot(node) {
|
|
528
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
529
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
530
|
-
}
|
|
531
|
-
function isOverflowElement(element) {
|
|
532
|
-
// Firefox wants us to check `-x` and `-y` variations as well
|
|
533
|
-
const {
|
|
534
|
-
overflow,
|
|
535
|
-
overflowX,
|
|
536
|
-
overflowY
|
|
537
|
-
} = getComputedStyle$1(element);
|
|
538
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
539
|
-
}
|
|
540
|
-
function isTableElement(element) {
|
|
541
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
542
|
-
}
|
|
543
|
-
function isContainingBlock(element) {
|
|
544
|
-
// TODO: Try and use feature detection here instead
|
|
545
|
-
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
|
546
|
-
const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
|
|
547
|
-
// create a containing block.
|
|
548
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
549
|
-
|
|
550
|
-
return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
|
|
551
|
-
}
|
|
552
|
-
function isLayoutViewport() {
|
|
553
|
-
// Not Safari
|
|
554
|
-
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent); // Feature detection for this fails in various ways
|
|
555
|
-
// • Always-visible scrollbar or not
|
|
556
|
-
// • Width of <html>, etc.
|
|
557
|
-
// const vV = win.visualViewport;
|
|
558
|
-
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const min = Math.min;
|
|
562
|
-
const max = Math.max;
|
|
563
|
-
const round = Math.round;
|
|
564
|
-
|
|
565
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
566
|
-
if (includeScale === void 0) {
|
|
567
|
-
includeScale = false;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (isFixedStrategy === void 0) {
|
|
571
|
-
isFixedStrategy = false;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
const clientRect = element.getBoundingClientRect();
|
|
575
|
-
let scaleX = 1;
|
|
576
|
-
let scaleY = 1;
|
|
577
|
-
|
|
578
|
-
if (includeScale && isHTMLElement(element)) {
|
|
579
|
-
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
580
|
-
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
const win = isElement(element) ? getWindow(element) : window;
|
|
584
|
-
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
585
|
-
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
586
|
-
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
587
|
-
const width = clientRect.width / scaleX;
|
|
588
|
-
const height = clientRect.height / scaleY;
|
|
589
|
-
return {
|
|
590
|
-
width,
|
|
591
|
-
height,
|
|
592
|
-
top: y,
|
|
593
|
-
right: x + width,
|
|
594
|
-
bottom: y + height,
|
|
595
|
-
left: x,
|
|
596
|
-
x,
|
|
597
|
-
y
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function getDocumentElement(node) {
|
|
602
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
function getNodeScroll(element) {
|
|
606
|
-
if (isWindow(element)) {
|
|
607
|
-
return {
|
|
608
|
-
scrollLeft: element.pageXOffset,
|
|
609
|
-
scrollTop: element.pageYOffset
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return {
|
|
614
|
-
scrollLeft: element.scrollLeft,
|
|
615
|
-
scrollTop: element.scrollTop
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
function getWindowScrollBarX(element) {
|
|
620
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
621
|
-
// incorrect for RTL.
|
|
622
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function isScaled(element) {
|
|
626
|
-
const rect = getBoundingClientRect(element);
|
|
627
|
-
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
631
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
632
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
633
|
-
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
|
634
|
-
let scroll = {
|
|
635
|
-
scrollLeft: 0,
|
|
636
|
-
scrollTop: 0
|
|
637
|
-
};
|
|
638
|
-
const offsets = {
|
|
639
|
-
x: 0,
|
|
640
|
-
y: 0
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
644
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
645
|
-
scroll = getNodeScroll(offsetParent);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if (isHTMLElement(offsetParent)) {
|
|
649
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
650
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
651
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
652
|
-
} else if (documentElement) {
|
|
653
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
return {
|
|
658
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
659
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
660
|
-
width: rect.width,
|
|
661
|
-
height: rect.height
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function getParentNode(node) {
|
|
666
|
-
if (getNodeName(node) === 'html') {
|
|
667
|
-
return node;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
671
|
-
// @ts-ignore
|
|
672
|
-
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
673
|
-
node.parentNode || ( // DOM Element detected
|
|
674
|
-
isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
|
675
|
-
getDocumentElement(node) // fallback
|
|
676
|
-
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
function getTrueOffsetParent(element) {
|
|
681
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
682
|
-
return null;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
return element.offsetParent;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
function getContainingBlock(element) {
|
|
689
|
-
let currentNode = getParentNode(element);
|
|
690
|
-
|
|
691
|
-
if (isShadowRoot(currentNode)) {
|
|
692
|
-
currentNode = currentNode.host;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
|
|
696
|
-
if (isContainingBlock(currentNode)) {
|
|
697
|
-
return currentNode;
|
|
698
|
-
} else {
|
|
699
|
-
currentNode = currentNode.parentNode;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
return null;
|
|
704
|
-
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
705
|
-
// such as table ancestors and cross browser bugs.
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
function getOffsetParent(element) {
|
|
709
|
-
const window = getWindow(element);
|
|
710
|
-
let offsetParent = getTrueOffsetParent(element);
|
|
711
|
-
|
|
712
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
713
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
717
|
-
return window;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
function getDimensions(element) {
|
|
724
|
-
if (isHTMLElement(element)) {
|
|
725
|
-
return {
|
|
726
|
-
width: element.offsetWidth,
|
|
727
|
-
height: element.offsetHeight
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
const rect = getBoundingClientRect(element);
|
|
732
|
-
return {
|
|
733
|
-
width: rect.width,
|
|
734
|
-
height: rect.height
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
739
|
-
let {
|
|
740
|
-
rect,
|
|
741
|
-
offsetParent,
|
|
742
|
-
strategy
|
|
743
|
-
} = _ref;
|
|
744
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
745
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
746
|
-
|
|
747
|
-
if (offsetParent === documentElement) {
|
|
748
|
-
return rect;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
let scroll = {
|
|
752
|
-
scrollLeft: 0,
|
|
753
|
-
scrollTop: 0
|
|
754
|
-
};
|
|
755
|
-
const offsets = {
|
|
756
|
-
x: 0,
|
|
757
|
-
y: 0
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
761
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
762
|
-
scroll = getNodeScroll(offsetParent);
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
if (isHTMLElement(offsetParent)) {
|
|
766
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
767
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
768
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
769
|
-
} // This doesn't appear to be need to be negated.
|
|
770
|
-
// else if (documentElement) {
|
|
771
|
-
// offsets.x = getWindowScrollBarX(documentElement);
|
|
772
|
-
// }
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
return { ...rect,
|
|
777
|
-
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
778
|
-
y: rect.y - scroll.scrollTop + offsets.y
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
function getViewportRect(element, strategy) {
|
|
783
|
-
const win = getWindow(element);
|
|
784
|
-
const html = getDocumentElement(element);
|
|
785
|
-
const visualViewport = win.visualViewport;
|
|
786
|
-
let width = html.clientWidth;
|
|
787
|
-
let height = html.clientHeight;
|
|
788
|
-
let x = 0;
|
|
789
|
-
let y = 0;
|
|
790
|
-
|
|
791
|
-
if (visualViewport) {
|
|
792
|
-
width = visualViewport.width;
|
|
793
|
-
height = visualViewport.height;
|
|
794
|
-
const layoutViewport = isLayoutViewport();
|
|
795
|
-
|
|
796
|
-
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
797
|
-
x = visualViewport.offsetLeft;
|
|
798
|
-
y = visualViewport.offsetTop;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
return {
|
|
803
|
-
width,
|
|
804
|
-
height,
|
|
805
|
-
x,
|
|
806
|
-
y
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
811
|
-
|
|
812
|
-
function getDocumentRect(element) {
|
|
813
|
-
var _element$ownerDocumen;
|
|
814
|
-
|
|
815
|
-
const html = getDocumentElement(element);
|
|
816
|
-
const scroll = getNodeScroll(element);
|
|
817
|
-
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
818
|
-
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
819
|
-
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
820
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
821
|
-
const y = -scroll.scrollTop;
|
|
822
|
-
|
|
823
|
-
if (getComputedStyle$1(body || html).direction === 'rtl') {
|
|
824
|
-
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
return {
|
|
828
|
-
width,
|
|
829
|
-
height,
|
|
830
|
-
x,
|
|
831
|
-
y
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
function getNearestOverflowAncestor(node) {
|
|
836
|
-
const parentNode = getParentNode(node);
|
|
837
|
-
|
|
838
|
-
if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
|
|
839
|
-
// @ts-ignore assume body is always available
|
|
840
|
-
return node.ownerDocument.body;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
844
|
-
return parentNode;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
return getNearestOverflowAncestor(parentNode);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
function getOverflowAncestors(node, list) {
|
|
851
|
-
var _node$ownerDocument;
|
|
852
|
-
|
|
853
|
-
if (list === void 0) {
|
|
854
|
-
list = [];
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
858
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
859
|
-
const win = getWindow(scrollableAncestor);
|
|
860
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
861
|
-
const updatedList = list.concat(target);
|
|
862
|
-
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
863
|
-
updatedList.concat(getOverflowAncestors(getParentNode(target)));
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
function contains(parent, child) {
|
|
867
|
-
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
|
|
868
|
-
|
|
869
|
-
if (parent.contains(child)) {
|
|
870
|
-
return true;
|
|
871
|
-
} // then fallback to custom implementation with Shadow DOM support
|
|
872
|
-
else if (rootNode && isShadowRoot(rootNode)) {
|
|
873
|
-
let next = child;
|
|
874
|
-
|
|
875
|
-
do {
|
|
876
|
-
// use `===` replace node.isSameNode()
|
|
877
|
-
if (next && parent === next) {
|
|
878
|
-
return true;
|
|
879
|
-
} // @ts-ignore: need a better way to handle this...
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
next = next.parentNode || next.host;
|
|
883
|
-
} while (next);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
return false;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
890
|
-
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
891
|
-
const top = clientRect.top + element.clientTop;
|
|
892
|
-
const left = clientRect.left + element.clientLeft;
|
|
893
|
-
return {
|
|
894
|
-
top,
|
|
895
|
-
left,
|
|
896
|
-
x: left,
|
|
897
|
-
y: top,
|
|
898
|
-
right: left + element.clientWidth,
|
|
899
|
-
bottom: top + element.clientHeight,
|
|
900
|
-
width: element.clientWidth,
|
|
901
|
-
height: element.clientHeight
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
906
|
-
if (clippingParent === 'viewport') {
|
|
907
|
-
return rectToClientRect(getViewportRect(element, strategy));
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if (isElement(clippingParent)) {
|
|
911
|
-
return getInnerBoundingClientRect(clippingParent, strategy);
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
915
|
-
} // A "clipping ancestor" is an overflowable container with the characteristic of
|
|
916
|
-
// clipping (or hiding) overflowing elements with a position different from
|
|
917
|
-
// `initial`
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
function getClippingAncestors(element) {
|
|
921
|
-
const clippingAncestors = getOverflowAncestors(element);
|
|
922
|
-
const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
|
|
923
|
-
const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
924
|
-
|
|
925
|
-
if (!isElement(clipperElement)) {
|
|
926
|
-
return [];
|
|
927
|
-
} // @ts-ignore isElement check ensures we return Array<Element>
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
|
931
|
-
} // Gets the maximum area that the element is visible in due to any number of
|
|
932
|
-
// clipping ancestors
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
function getClippingRect(_ref) {
|
|
936
|
-
let {
|
|
937
|
-
element,
|
|
938
|
-
boundary,
|
|
939
|
-
rootBoundary,
|
|
940
|
-
strategy
|
|
941
|
-
} = _ref;
|
|
942
|
-
const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
|
|
943
|
-
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
|
944
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
945
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
946
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
947
|
-
accRect.top = max(rect.top, accRect.top);
|
|
948
|
-
accRect.right = min(rect.right, accRect.right);
|
|
949
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
950
|
-
accRect.left = max(rect.left, accRect.left);
|
|
951
|
-
return accRect;
|
|
952
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
953
|
-
return {
|
|
954
|
-
width: clippingRect.right - clippingRect.left,
|
|
955
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
956
|
-
x: clippingRect.left,
|
|
957
|
-
y: clippingRect.top
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
const platform = {
|
|
962
|
-
getClippingRect,
|
|
963
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
964
|
-
isElement,
|
|
965
|
-
getDimensions,
|
|
966
|
-
getOffsetParent,
|
|
967
|
-
getDocumentElement,
|
|
968
|
-
getElementRects: _ref => {
|
|
969
|
-
let {
|
|
970
|
-
reference,
|
|
971
|
-
floating,
|
|
972
|
-
strategy
|
|
973
|
-
} = _ref;
|
|
974
|
-
return {
|
|
975
|
-
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
976
|
-
floating: { ...getDimensions(floating),
|
|
977
|
-
x: 0,
|
|
978
|
-
y: 0
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
},
|
|
982
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
983
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
984
|
-
};
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* Automatically updates the position of the floating element when necessary.
|
|
988
|
-
* @see https://floating-ui.com/docs/autoUpdate
|
|
989
|
-
*/
|
|
990
|
-
function autoUpdate(reference, floating, update, options) {
|
|
991
|
-
if (options === void 0) {
|
|
992
|
-
options = {};
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
const {
|
|
996
|
-
ancestorScroll: _ancestorScroll = true,
|
|
997
|
-
ancestorResize: _ancestorResize = true,
|
|
998
|
-
elementResize: _elementResize = true,
|
|
999
|
-
animationFrame = false
|
|
1000
|
-
} = options;
|
|
1001
|
-
let cleanedUp = false;
|
|
1002
|
-
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1003
|
-
const ancestorResize = _ancestorResize && !animationFrame;
|
|
1004
|
-
const elementResize = _elementResize && !animationFrame;
|
|
1005
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
|
|
1006
|
-
ancestors.forEach(ancestor => {
|
|
1007
|
-
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1008
|
-
passive: true
|
|
1009
|
-
});
|
|
1010
|
-
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1011
|
-
});
|
|
1012
|
-
let observer = null;
|
|
1013
|
-
|
|
1014
|
-
if (elementResize) {
|
|
1015
|
-
observer = new ResizeObserver(update);
|
|
1016
|
-
isElement(reference) && observer.observe(reference);
|
|
1017
|
-
observer.observe(floating);
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
let frameId;
|
|
1021
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1022
|
-
|
|
1023
|
-
if (animationFrame) {
|
|
1024
|
-
frameLoop();
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
function frameLoop() {
|
|
1028
|
-
if (cleanedUp) {
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1033
|
-
|
|
1034
|
-
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1035
|
-
update();
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
prevRefRect = nextRefRect;
|
|
1039
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
return () => {
|
|
1043
|
-
var _observer;
|
|
1044
|
-
|
|
1045
|
-
cleanedUp = true;
|
|
1046
|
-
ancestors.forEach(ancestor => {
|
|
1047
|
-
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1048
|
-
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1049
|
-
});
|
|
1050
|
-
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
1051
|
-
observer = null;
|
|
1052
|
-
|
|
1053
|
-
if (animationFrame) {
|
|
1054
|
-
cancelAnimationFrame(frameId);
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1061
|
-
* next to a reference element when it is given a certain CSS positioning
|
|
1062
|
-
* strategy.
|
|
1063
|
-
*/
|
|
1064
|
-
|
|
1065
|
-
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
|
1066
|
-
platform,
|
|
1067
|
-
...options
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
/*!
|
|
1071
|
-
* tabbable 5.3.0-beta.1
|
|
1072
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
1073
|
-
*/
|
|
1074
|
-
var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]:not(slot)', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])', 'details>summary:first-of-type', 'details'];
|
|
1075
|
-
var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
|
|
1076
|
-
var NoElement = typeof Element === 'undefined';
|
|
1077
|
-
var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
1078
|
-
var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
|
|
1079
|
-
return element.getRootNode();
|
|
1080
|
-
} : function (element) {
|
|
1081
|
-
return element.ownerDocument;
|
|
1082
|
-
};
|
|
1083
|
-
/**
|
|
1084
|
-
* @param {Element} el container to check in
|
|
1085
|
-
* @param {boolean} includeContainer add container to check
|
|
1086
|
-
* @param {(node: Element) => boolean} filter filter candidates
|
|
1087
|
-
* @returns {Element[]}
|
|
1088
|
-
*/
|
|
1089
|
-
|
|
1090
|
-
var getCandidates = function getCandidates(el, includeContainer, filter) {
|
|
1091
|
-
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
1092
|
-
|
|
1093
|
-
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
1094
|
-
candidates.unshift(el);
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
candidates = candidates.filter(filter);
|
|
1098
|
-
return candidates;
|
|
1099
|
-
};
|
|
1100
|
-
/**
|
|
1101
|
-
* @callback GetShadowRoot
|
|
1102
|
-
* @param {Element} element to check for shadow root
|
|
1103
|
-
* @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
|
|
1104
|
-
*/
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* @typedef {Object} CandidatesScope
|
|
1108
|
-
* @property {Element} scope contains inner candidates
|
|
1109
|
-
* @property {Element[]} candidates
|
|
1110
|
-
*/
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* @typedef {Object} IterativeOptions
|
|
1114
|
-
* @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
|
|
1115
|
-
* if a function, implies shadow support is enabled and either returns the shadow root of an element
|
|
1116
|
-
* or a boolean stating if it has an undisclosed shadow root
|
|
1117
|
-
* @property {(node: Element) => boolean} filter filter candidates
|
|
1118
|
-
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list
|
|
1119
|
-
*/
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* @param {Element[]} elements list of element containers to match candidates from
|
|
1123
|
-
* @param {boolean} includeContainer add container list to check
|
|
1124
|
-
* @param {IterativeOptions} options
|
|
1125
|
-
* @returns {Array.<Element|CandidatesScope>}
|
|
1126
|
-
*/
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
|
|
1130
|
-
var candidates = [];
|
|
1131
|
-
var elementsToCheck = Array.from(elements);
|
|
1132
|
-
|
|
1133
|
-
while (elementsToCheck.length) {
|
|
1134
|
-
var element = elementsToCheck.shift();
|
|
1135
|
-
|
|
1136
|
-
if (element.tagName === 'SLOT') {
|
|
1137
|
-
// add shadow dom slot scope (slot itself cannot be focusable)
|
|
1138
|
-
var assigned = element.assignedElements();
|
|
1139
|
-
var content = assigned.length ? assigned : element.children;
|
|
1140
|
-
var nestedCandidates = getCandidatesIteratively(content, true, options);
|
|
1141
|
-
|
|
1142
|
-
if (options.flatten) {
|
|
1143
|
-
candidates.push.apply(candidates, nestedCandidates);
|
|
1144
|
-
} else {
|
|
1145
|
-
candidates.push({
|
|
1146
|
-
scope: element,
|
|
1147
|
-
candidates: nestedCandidates
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
} else {
|
|
1151
|
-
// check candidate element
|
|
1152
|
-
var validCandidate = matches.call(element, candidateSelector);
|
|
1153
|
-
|
|
1154
|
-
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
1155
|
-
candidates.push(element);
|
|
1156
|
-
} // iterate over shadow content if possible
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
|
|
1160
|
-
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
|
|
1161
|
-
|
|
1162
|
-
if (shadowRoot) {
|
|
1163
|
-
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
|
|
1164
|
-
// shadow exists, so look at light dom children as fallback BUT create a scope for any
|
|
1165
|
-
// child candidates found because they're likely slotted elements (elements that are
|
|
1166
|
-
// children of the web component element (which has the shadow), in the light dom, but
|
|
1167
|
-
// slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
|
|
1168
|
-
// _after_ we return from this recursive call
|
|
1169
|
-
var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
1170
|
-
|
|
1171
|
-
if (options.flatten) {
|
|
1172
|
-
candidates.push.apply(candidates, _nestedCandidates);
|
|
1173
|
-
} else {
|
|
1174
|
-
candidates.push({
|
|
1175
|
-
scope: element,
|
|
1176
|
-
candidates: _nestedCandidates
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
} else {
|
|
1180
|
-
// there's not shadow so just dig into the element's (light dom) children
|
|
1181
|
-
// __without__ giving the element special scope treatment
|
|
1182
|
-
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
return candidates;
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
var isContentEditable = function isContentEditable(node) {
|
|
1191
|
-
return node.contentEditable === 'true';
|
|
1192
|
-
};
|
|
1193
|
-
|
|
1194
|
-
var getTabindex = function getTabindex(node, isScope) {
|
|
1195
|
-
var tabindexAttr = parseInt(node.getAttribute('tabindex'), 10);
|
|
1196
|
-
|
|
1197
|
-
if (!isNaN(tabindexAttr)) {
|
|
1198
|
-
return tabindexAttr;
|
|
1199
|
-
} // Browsers do not return `tabIndex` correctly for contentEditable nodes;
|
|
1200
|
-
// so if they don't have a tabindex attribute specifically set, assume it's 0.
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
if (isContentEditable(node)) {
|
|
1204
|
-
return 0;
|
|
1205
|
-
} // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
|
|
1206
|
-
// `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
|
|
1207
|
-
// yet they are still part of the regular tab order; in FF, they get a default
|
|
1208
|
-
// `tabIndex` of 0; since Chrome still puts those elements in the regular tab
|
|
1209
|
-
// order, consider their tab index to be 0.
|
|
1210
|
-
//
|
|
1211
|
-
// isScope is positive for custom element with shadow root or slot that by default
|
|
1212
|
-
// have tabIndex -1, but need to be sorted by document order in order for their
|
|
1213
|
-
// content to be inserted in the correct position
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
if ((isScope || node.nodeName === 'AUDIO' || node.nodeName === 'VIDEO' || node.nodeName === 'DETAILS') && node.getAttribute('tabindex') === null) {
|
|
1217
|
-
return 0;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
return node.tabIndex;
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
|
|
1224
|
-
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
1225
|
-
};
|
|
1226
|
-
|
|
1227
|
-
var isInput = function isInput(node) {
|
|
1228
|
-
return node.tagName === 'INPUT';
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
var isHiddenInput = function isHiddenInput(node) {
|
|
1232
|
-
return isInput(node) && node.type === 'hidden';
|
|
1233
|
-
};
|
|
1234
|
-
|
|
1235
|
-
var isDetailsWithSummary = function isDetailsWithSummary(node) {
|
|
1236
|
-
var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
|
|
1237
|
-
return child.tagName === 'SUMMARY';
|
|
1238
|
-
});
|
|
1239
|
-
return r;
|
|
1240
|
-
};
|
|
1241
|
-
|
|
1242
|
-
var getCheckedRadio = function getCheckedRadio(nodes, form) {
|
|
1243
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
1244
|
-
if (nodes[i].checked && nodes[i].form === form) {
|
|
1245
|
-
return nodes[i];
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
var isTabbableRadio = function isTabbableRadio(node) {
|
|
1251
|
-
if (!node.name) {
|
|
1252
|
-
return true;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
var radioScope = node.form || getRootNode(node);
|
|
1256
|
-
|
|
1257
|
-
var queryRadios = function queryRadios(name) {
|
|
1258
|
-
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
1259
|
-
};
|
|
1260
|
-
|
|
1261
|
-
var radioSet;
|
|
1262
|
-
|
|
1263
|
-
if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
|
|
1264
|
-
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
1265
|
-
} else {
|
|
1266
|
-
try {
|
|
1267
|
-
radioSet = queryRadios(node.name);
|
|
1268
|
-
} catch (err) {
|
|
1269
|
-
// eslint-disable-next-line no-console
|
|
1270
|
-
console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
|
|
1271
|
-
return false;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
var checked = getCheckedRadio(radioSet, node.form);
|
|
1276
|
-
return !checked || checked === node;
|
|
1277
|
-
};
|
|
1278
|
-
|
|
1279
|
-
var isRadio = function isRadio(node) {
|
|
1280
|
-
return isInput(node) && node.type === 'radio';
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
var isNonTabbableRadio = function isNonTabbableRadio(node) {
|
|
1284
|
-
return isRadio(node) && !isTabbableRadio(node);
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1287
|
-
var isZeroArea = function isZeroArea(node) {
|
|
1288
|
-
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1289
|
-
width = _node$getBoundingClie.width,
|
|
1290
|
-
height = _node$getBoundingClie.height;
|
|
1291
|
-
|
|
1292
|
-
return width === 0 && height === 0;
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
var isHidden = function isHidden(node, _ref) {
|
|
1296
|
-
var displayCheck = _ref.displayCheck,
|
|
1297
|
-
getShadowRoot = _ref.getShadowRoot;
|
|
1298
|
-
|
|
1299
|
-
if (getComputedStyle(node).visibility === 'hidden') {
|
|
1300
|
-
return true;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
|
|
1304
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
1305
|
-
|
|
1306
|
-
if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
|
|
1307
|
-
return true;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
if (!displayCheck || displayCheck === 'full') {
|
|
1311
|
-
if (typeof getShadowRoot === 'function') {
|
|
1312
|
-
// figure out if we should consider the node to be in an undisclosed shadow and use the
|
|
1313
|
-
// 'non-zero-area' fallback
|
|
1314
|
-
var originalNode = node;
|
|
1315
|
-
|
|
1316
|
-
while (node) {
|
|
1317
|
-
var parentElement = node.parentElement;
|
|
1318
|
-
var rootNode = getRootNode(node);
|
|
1319
|
-
|
|
1320
|
-
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
|
|
1321
|
-
) {
|
|
1322
|
-
// node has an undisclosed shadow which means we can only treat it as a black box, so we
|
|
1323
|
-
// fall back to a non-zero-area test
|
|
1324
|
-
return isZeroArea(node);
|
|
1325
|
-
} else if (node.assignedSlot) {
|
|
1326
|
-
// iterate up slot
|
|
1327
|
-
node = node.assignedSlot;
|
|
1328
|
-
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
1329
|
-
// cross shadow boundary
|
|
1330
|
-
node = rootNode.host;
|
|
1331
|
-
} else {
|
|
1332
|
-
// iterate up normal dom
|
|
1333
|
-
node = parentElement;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
node = originalNode;
|
|
1338
|
-
} // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
|
|
1339
|
-
// (i.e. it does not also presume that all nodes might have undisclosed shadows); or
|
|
1340
|
-
// it might be a falsy value, which means shadow DOM support is disabled
|
|
1341
|
-
// didn't find it sitting in an undisclosed shadow (or shadows are disabled) so now we
|
|
1342
|
-
// can just test to see if it would normally be visible or not
|
|
1343
|
-
// this works wherever the node is: if there's at least one client rect, it's
|
|
1344
|
-
// somehow displayed; it also covers the CSS 'display: contents' case where the
|
|
1345
|
-
// node itself is hidden in place of its contents; and there's no need to search
|
|
1346
|
-
// up the hierarchy either
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
return !node.getClientRects().length;
|
|
1350
|
-
} else if (displayCheck === 'non-zero-area') {
|
|
1351
|
-
return isZeroArea(node);
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
return false;
|
|
1355
|
-
}; // form fields (nested) inside a disabled fieldset are not focusable/tabbable
|
|
1356
|
-
// unless they are in the _first_ <legend> element of the top-most disabled
|
|
1357
|
-
// fieldset
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
|
|
1361
|
-
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
1362
|
-
var parentNode = node.parentElement; // check if `node` is contained in a disabled <fieldset>
|
|
1363
|
-
|
|
1364
|
-
while (parentNode) {
|
|
1365
|
-
if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
|
|
1366
|
-
// look for the first <legend> among the children of the disabled <fieldset>
|
|
1367
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
1368
|
-
var child = parentNode.children.item(i); // when the first <legend> (in document order) is found
|
|
1369
|
-
|
|
1370
|
-
if (child.tagName === 'LEGEND') {
|
|
1371
|
-
// if its parent <fieldset> is not nested in another disabled <fieldset>,
|
|
1372
|
-
// return whether `node` is a descendant of its first <legend>
|
|
1373
|
-
return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
|
|
1374
|
-
}
|
|
1375
|
-
} // the disabled <fieldset> containing `node` has no <legend>
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
return true;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
parentNode = parentNode.parentElement;
|
|
1382
|
-
}
|
|
1383
|
-
} // else, node's tabbable/focusable state should not be affected by a fieldset's
|
|
1384
|
-
// enabled/disabled state
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
return false;
|
|
1388
|
-
};
|
|
1389
|
-
|
|
1390
|
-
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
|
|
1391
|
-
if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
1392
|
-
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
1393
|
-
return false;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
return true;
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
|
|
1400
|
-
if (!isNodeMatchingSelectorFocusable(options, node) || isNonTabbableRadio(node) || getTabindex(node) < 0) {
|
|
1401
|
-
return false;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
return true;
|
|
1405
|
-
};
|
|
1406
|
-
/**
|
|
1407
|
-
* @param {Array.<Element|CandidatesScope>} candidates
|
|
1408
|
-
* @returns Element[]
|
|
1409
|
-
*/
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
var sortByOrder = function sortByOrder(candidates) {
|
|
1413
|
-
var regularTabbables = [];
|
|
1414
|
-
var orderedTabbables = [];
|
|
1415
|
-
candidates.forEach(function (item, i) {
|
|
1416
|
-
var isScope = !!item.scope;
|
|
1417
|
-
var element = isScope ? item.scope : item;
|
|
1418
|
-
var candidateTabindex = getTabindex(element, isScope);
|
|
1419
|
-
var elements = isScope ? sortByOrder(item.candidates) : element;
|
|
1420
|
-
|
|
1421
|
-
if (candidateTabindex === 0) {
|
|
1422
|
-
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
1423
|
-
} else {
|
|
1424
|
-
orderedTabbables.push({
|
|
1425
|
-
documentOrder: i,
|
|
1426
|
-
tabIndex: candidateTabindex,
|
|
1427
|
-
item: item,
|
|
1428
|
-
isScope: isScope,
|
|
1429
|
-
content: elements
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
});
|
|
1433
|
-
return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
|
|
1434
|
-
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
1435
|
-
return acc;
|
|
1436
|
-
}, []).concat(regularTabbables);
|
|
1437
|
-
};
|
|
1438
|
-
|
|
1439
|
-
var tabbable = function tabbable(el, options) {
|
|
1440
|
-
options = options || {};
|
|
1441
|
-
var candidates;
|
|
1442
|
-
|
|
1443
|
-
if (options.getShadowRoot) {
|
|
1444
|
-
candidates = getCandidatesIteratively([el], options.includeContainer, {
|
|
1445
|
-
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
1446
|
-
flatten: false,
|
|
1447
|
-
getShadowRoot: options.getShadowRoot
|
|
1448
|
-
});
|
|
1449
|
-
} else {
|
|
1450
|
-
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
return sortByOrder(candidates);
|
|
1454
|
-
};
|
|
1455
|
-
|
|
1456
|
-
var focusable = function focusable(el, options) {
|
|
1457
|
-
options = options || {};
|
|
1458
|
-
var candidates;
|
|
1459
|
-
|
|
1460
|
-
if (options.getShadowRoot) {
|
|
1461
|
-
candidates = getCandidatesIteratively([el], options.includeContainer, {
|
|
1462
|
-
filter: isNodeMatchingSelectorFocusable.bind(null, options),
|
|
1463
|
-
flatten: true,
|
|
1464
|
-
getShadowRoot: options.getShadowRoot
|
|
1465
|
-
});
|
|
1466
|
-
} else {
|
|
1467
|
-
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
return candidates;
|
|
1471
|
-
};
|
|
1472
|
-
|
|
1473
|
-
var isTabbable = function isTabbable(node, options) {
|
|
1474
|
-
options = options || {};
|
|
1475
|
-
|
|
1476
|
-
if (!node) {
|
|
1477
|
-
throw new Error('No node provided');
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
if (matches.call(node, candidateSelector) === false) {
|
|
1481
|
-
return false;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
return isNodeMatchingSelectorTabbable(options, node);
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
|
|
1488
|
-
|
|
1489
|
-
var isFocusable = function isFocusable(node, options) {
|
|
1490
|
-
options = options || {};
|
|
1491
|
-
|
|
1492
|
-
if (!node) {
|
|
1493
|
-
throw new Error('No node provided');
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
1497
|
-
return false;
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
return isNodeMatchingSelectorFocusable(options, node);
|
|
1501
|
-
};
|
|
2
|
+
import { t as tabbable, f as focusable, i as isTabbable, a as isFocusable, b as firstTabbable, c as autoUpdate, d as computePosition, o as offset, e as flip } from './first-tabbable.js';
|
|
1502
3
|
|
|
1503
4
|
/*!
|
|
1504
|
-
* focus-trap 6.8.
|
|
5
|
+
* focus-trap 6.8.1
|
|
1505
6
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
1506
7
|
*/
|
|
1507
8
|
|
|
@@ -1798,16 +299,10 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1798
299
|
|
|
1799
300
|
var updateTabbableNodes = function updateTabbableNodes() {
|
|
1800
301
|
state.containerGroups = state.containers.map(function (container) {
|
|
1801
|
-
var
|
|
1802
|
-
|
|
1803
|
-
var tabbableNodes = tabbable(container, {
|
|
1804
|
-
getShadowRoot: (_config$tabbableOptio = config.tabbableOptions) === null || _config$tabbableOptio === void 0 ? void 0 : _config$tabbableOptio.getShadowRoot
|
|
1805
|
-
}); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
302
|
+
var tabbableNodes = tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
1806
303
|
// are a superset of tabbable nodes
|
|
1807
304
|
|
|
1808
|
-
var focusableNodes = focusable(container,
|
|
1809
|
-
getShadowRoot: (_config$tabbableOptio2 = config.tabbableOptions) === null || _config$tabbableOptio2 === void 0 ? void 0 : _config$tabbableOptio2.getShadowRoot
|
|
1810
|
-
});
|
|
305
|
+
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
1811
306
|
return {
|
|
1812
307
|
container: container,
|
|
1813
308
|
tabbableNodes: tabbableNodes,
|
|
@@ -1845,12 +340,12 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1845
340
|
|
|
1846
341
|
if (forward) {
|
|
1847
342
|
return focusableNodes.slice(nodeIdx + 1).find(function (n) {
|
|
1848
|
-
return isTabbable(n);
|
|
343
|
+
return isTabbable(n, config.tabbableOptions);
|
|
1849
344
|
});
|
|
1850
345
|
}
|
|
1851
346
|
|
|
1852
347
|
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
|
|
1853
|
-
return isTabbable(n);
|
|
348
|
+
return isTabbable(n, config.tabbableOptions);
|
|
1854
349
|
});
|
|
1855
350
|
}
|
|
1856
351
|
};
|
|
@@ -1918,7 +413,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1918
413
|
// that was clicked, whether it's focusable or not; by setting
|
|
1919
414
|
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
1920
415
|
// on activation (or the configured `setReturnFocus` node)
|
|
1921
|
-
returnFocus: config.returnFocusOnDeactivate && !isFocusable(target)
|
|
416
|
+
returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
|
|
1922
417
|
});
|
|
1923
418
|
return;
|
|
1924
419
|
} // This is needed for mobile devices.
|
|
@@ -1985,7 +480,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1985
480
|
return target === firstTabbableNode;
|
|
1986
481
|
});
|
|
1987
482
|
|
|
1988
|
-
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target) && !isTabbable(target) && !containerGroup.nextTabbableNode(target, false))) {
|
|
483
|
+
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
1989
484
|
// an exception case where the target is either the container itself, or
|
|
1990
485
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
1991
486
|
// and user clicked on it or node was programmatically given focus)
|
|
@@ -2011,7 +506,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
2011
506
|
return target === lastTabbableNode;
|
|
2012
507
|
});
|
|
2013
508
|
|
|
2014
|
-
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target) && !isTabbable(target) && !containerGroup.nextTabbableNode(target))) {
|
|
509
|
+
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
2015
510
|
// an exception case where the target is the container itself, or
|
|
2016
511
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
2017
512
|
// and user clicked on it or node was programmatically given focus)
|
|
@@ -2273,7 +768,7 @@ const CatMenu$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
2273
768
|
}
|
|
2274
769
|
componentDidLoad() {
|
|
2275
770
|
var _a, _b, _c, _d, _e;
|
|
2276
|
-
this.trigger =
|
|
771
|
+
this.trigger = firstTabbable(this.triggerSlot);
|
|
2277
772
|
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
|
|
2278
773
|
(_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
|
|
2279
774
|
(_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
|
|
@@ -2285,7 +780,7 @@ const CatMenu$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
2285
780
|
this.keyListener = event => {
|
|
2286
781
|
if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
2287
782
|
const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
|
|
2288
|
-
const activeElement =
|
|
783
|
+
const activeElement = firstTabbable(document.activeElement);
|
|
2289
784
|
const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
|
|
2290
785
|
const activeOff = event.key === 'ArrowDown' ? 1 : -1;
|
|
2291
786
|
const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
|
|
@@ -2348,9 +843,6 @@ const CatMenu$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
2348
843
|
});
|
|
2349
844
|
}
|
|
2350
845
|
}
|
|
2351
|
-
firstTabbable(container) {
|
|
2352
|
-
return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
|
|
2353
|
-
}
|
|
2354
846
|
static get style() { return catMenuCss; }
|
|
2355
847
|
}, [1, "cat-menu", {
|
|
2356
848
|
"placement": [1]
|