@haiilo/catalyst 0.7.2 → 0.8.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.css +2 -2
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-2ad6f8d8.js +2 -0
- package/dist/catalyst/{p-7c06183a.js.map → p-2ad6f8d8.js.map} +1 -1
- package/dist/catalyst/p-659073b5.js +3 -0
- package/dist/catalyst/p-659073b5.js.map +1 -0
- package/dist/catalyst/{p-c7f3b231.js → p-6a8a4dc0.js} +2 -2
- package/dist/catalyst/{p-c7f3b231.js.map → p-6a8a4dc0.js.map} +0 -0
- package/dist/catalyst/{p-5616e2cd.js → p-6fce43dd.js} +2 -2
- package/dist/catalyst/{p-5616e2cd.js.map → p-6fce43dd.js.map} +0 -0
- package/dist/catalyst/p-89c24fb5.entry.js +12 -0
- package/dist/catalyst/p-89c24fb5.entry.js.map +1 -0
- package/dist/catalyst/{p-4254363e.entry.js → p-c0b4200d.entry.js} +2 -2
- package/dist/catalyst/{p-4254363e.entry.js.map → p-c0b4200d.entry.js.map} +0 -0
- package/dist/catalyst/{p-12486027.js → p-decdc6f1.js} +2 -2
- package/dist/catalyst/p-decdc6f1.js.map +1 -0
- package/dist/catalyst/p-f45bcfd6.js +2 -0
- package/dist/catalyst/p-f45bcfd6.js.map +1 -0
- package/dist/catalyst/scss/_mixins.scss +1 -1
- package/dist/catalyst/scss/_variables.scss +2 -0
- package/dist/catalyst/scss/{utils → core}/_toast.scss +2 -2
- package/dist/catalyst/scss/fonts/_fonts-mixins.scss +17 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +1 -1
- package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +6 -6
- package/dist/catalyst/scss/fonts/_fonts.mixins.lato.scss +36 -36
- package/dist/catalyst/scss/index.scss +23 -20
- package/dist/cjs/{app-globals-aa29ad72.js → app-globals-79765026.js} +3 -3
- package/dist/cjs/{app-globals-aa29ad72.js.map → app-globals-79765026.js.map} +1 -1
- package/dist/cjs/cat-alert_20.cjs.entry.js +12632 -0
- package/dist/cjs/cat-alert_20.cjs.entry.js.map +1 -0
- package/dist/cjs/{cat-form-hint-93a6936b.js → cat-form-hint-25fdfed5.js} +2 -2
- package/dist/cjs/{cat-form-hint-93a6936b.js.map → cat-form-hint-25fdfed5.js.map} +1 -1
- package/dist/cjs/{cat-icon-registry-49b11b51.js → cat-icon-registry-b015a65f.js} +37 -43
- package/dist/cjs/cat-icon-registry-b015a65f.js.map +1 -0
- package/dist/cjs/{cat-notification-156f4cf5.js → cat-notification-fe237312.js} +2 -2
- package/dist/cjs/{cat-notification-156f4cf5.js.map → cat-notification-fe237312.js.map} +1 -1
- package/dist/cjs/cat-textarea.cjs.entry.js +3 -3
- package/dist/cjs/catalyst.cjs.js +6 -6
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-499bad41.js → index-936b777e.js} +10 -5
- package/dist/cjs/index-936b777e.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js +6 -6
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/{loglevel-c9b2d01f.js → loglevel-b5d158ad.js} +6 -1
- package/dist/cjs/loglevel-b5d158ad.js.map +1 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/cat-avatar/cat-avatar.js +2 -2
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +35 -41
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.js +2 -2
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-modal/cat-modal.css +65 -0
- package/dist/collection/components/cat-modal/cat-modal.js +117 -0
- package/dist/collection/components/cat-modal/cat-modal.js.map +1 -0
- package/dist/collection/components/cat-select/cat-select.css +602 -0
- package/dist/collection/components/cat-select/cat-select.js +528 -0
- package/dist/collection/components/cat-select/cat-select.js.map +1 -0
- package/dist/collection/init.js +1 -1
- package/dist/collection/init.js.map +1 -1
- package/dist/collection/scss/_mixins.scss +1 -1
- package/dist/collection/scss/_variables.scss +2 -0
- package/dist/collection/scss/{utils → core}/_toast.scss +2 -2
- package/dist/collection/scss/fonts/_fonts-mixins.scss +17 -0
- package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +1 -1
- package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +6 -6
- package/dist/collection/scss/fonts/_fonts.mixins.lato.scss +36 -36
- package/dist/collection/scss/index.scss +23 -20
- package/dist/components/cat-avatar.js +2 -2
- package/dist/components/cat-avatar.js.map +1 -1
- package/dist/components/cat-i18n-registry.js +35 -41
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-icon.js +1 -1
- package/dist/components/cat-icon2.js +56 -2
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +2 -2
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-menu.js +3 -742
- package/dist/components/cat-menu.js.map +1 -1
- package/dist/components/cat-modal.d.ts +11 -0
- package/dist/components/cat-modal.js +111 -0
- package/dist/components/cat-modal.js.map +1 -0
- package/dist/components/cat-select.d.ts +11 -0
- package/dist/components/cat-select.js +7790 -0
- package/dist/components/cat-select.js.map +1 -0
- package/dist/components/cat-toast-demo.js +549 -4
- package/dist/components/cat-toast-demo.js.map +1 -1
- package/dist/components/cat-tooltip.js +2 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/first-tabbable.js +1 -1068
- package/dist/components/first-tabbable.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +1070 -0
- package/dist/components/floating-ui.dom.esm.js.map +1 -0
- package/dist/components/focus-trap.esm.js +746 -0
- package/dist/components/focus-trap.esm.js.map +1 -0
- package/dist/components/index.d.ts +21 -5
- package/dist/components/index.js +24 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/loglevel.js +5 -1
- package/dist/components/loglevel.js.map +1 -1
- package/dist/esm/{app-globals-cf55f7f5.js → app-globals-7d163b94.js} +3 -3
- package/dist/esm/{app-globals-cf55f7f5.js.map → app-globals-7d163b94.js.map} +1 -1
- package/dist/esm/cat-alert_20.entry.js +12609 -0
- package/dist/esm/cat-alert_20.entry.js.map +1 -0
- package/dist/esm/{cat-form-hint-dc443c7c.js → cat-form-hint-790d1e46.js} +2 -2
- package/dist/esm/{cat-form-hint-dc443c7c.js.map → cat-form-hint-790d1e46.js.map} +1 -1
- package/dist/esm/{cat-icon-registry-3ea75755.js → cat-icon-registry-dc1ef79a.js} +37 -43
- package/dist/esm/cat-icon-registry-dc1ef79a.js.map +1 -0
- package/dist/{components/cat-notification.js → esm/cat-notification-a9655c00.js} +2 -2
- package/dist/esm/{cat-notification-cd98c266.js.map → cat-notification-a9655c00.js.map} +1 -1
- package/dist/esm/cat-textarea.entry.js +3 -3
- package/dist/esm/catalyst.js +6 -6
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-039e6f5f.js → index-41ceb7da.js} +10 -5
- package/dist/esm/index-41ceb7da.js.map +1 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/loader.js +6 -6
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/{loglevel-39a9e3f9.js → loglevel-c8b59c3a.js} +6 -2
- package/dist/{cjs/loglevel-c9b2d01f.js.map → esm/loglevel-c8b59c3a.js.map} +1 -1
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +9 -10
- package/dist/types/components/cat-modal/cat-modal.d.ts +20 -0
- package/dist/types/components/cat-select/cat-select.d.ts +84 -0
- package/dist/types/components.d.ts +184 -25
- package/package.json +11 -10
- package/dist/catalyst/p-12486027.js.map +0 -1
- package/dist/catalyst/p-12b96af6.js +0 -2
- package/dist/catalyst/p-12b96af6.js.map +0 -1
- package/dist/catalyst/p-2ec5c87a.js +0 -2
- package/dist/catalyst/p-2ec5c87a.js.map +0 -1
- package/dist/catalyst/p-7c06183a.js +0 -2
- package/dist/catalyst/p-dda85567.entry.js +0 -10
- package/dist/catalyst/p-dda85567.entry.js.map +0 -1
- package/dist/catalyst/scss/fonts/_fonts.mixins.scss +0 -3
- package/dist/catalyst/scss/fonts/_fonts.scss +0 -13
- package/dist/cjs/cat-alert_18.cjs.entry.js +0 -4831
- package/dist/cjs/cat-alert_18.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-icon-registry-49b11b51.js.map +0 -1
- package/dist/cjs/index-499bad41.js.map +0 -1
- package/dist/collection/scss/fonts/_fonts.mixins.scss +0 -3
- package/dist/collection/scss/fonts/_fonts.scss +0 -13
- package/dist/components/cat-icon-registry.js +0 -59
- package/dist/components/cat-icon-registry.js.map +0 -1
- package/dist/components/cat-notification.js.map +0 -1
- package/dist/esm/cat-alert_18.entry.js +0 -4810
- package/dist/esm/cat-alert_18.entry.js.map +0 -1
- package/dist/esm/cat-icon-registry-3ea75755.js.map +0 -1
- package/dist/esm/cat-notification-cd98c266.js +0 -550
- package/dist/esm/index-039e6f5f.js.map +0 -1
- package/dist/esm/loglevel-39a9e3f9.js.map +0 -1
|
@@ -1,1070 +1,3 @@
|
|
|
1
|
-
function getSide(placement) {
|
|
2
|
-
return placement.split('-')[0];
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function getAlignment(placement) {
|
|
6
|
-
return placement.split('-')[1];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function getMainAxisFromPlacement(placement) {
|
|
10
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function getLengthFromAxis(axis) {
|
|
14
|
-
return axis === 'y' ? 'height' : 'width';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
18
|
-
let {
|
|
19
|
-
reference,
|
|
20
|
-
floating
|
|
21
|
-
} = _ref;
|
|
22
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
23
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
24
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
25
|
-
const length = getLengthFromAxis(mainAxis);
|
|
26
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
27
|
-
const side = getSide(placement);
|
|
28
|
-
const isVertical = mainAxis === 'x';
|
|
29
|
-
let coords;
|
|
30
|
-
|
|
31
|
-
switch (side) {
|
|
32
|
-
case 'top':
|
|
33
|
-
coords = {
|
|
34
|
-
x: commonX,
|
|
35
|
-
y: reference.y - floating.height
|
|
36
|
-
};
|
|
37
|
-
break;
|
|
38
|
-
|
|
39
|
-
case 'bottom':
|
|
40
|
-
coords = {
|
|
41
|
-
x: commonX,
|
|
42
|
-
y: reference.y + reference.height
|
|
43
|
-
};
|
|
44
|
-
break;
|
|
45
|
-
|
|
46
|
-
case 'right':
|
|
47
|
-
coords = {
|
|
48
|
-
x: reference.x + reference.width,
|
|
49
|
-
y: commonY
|
|
50
|
-
};
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case 'left':
|
|
54
|
-
coords = {
|
|
55
|
-
x: reference.x - floating.width,
|
|
56
|
-
y: commonY
|
|
57
|
-
};
|
|
58
|
-
break;
|
|
59
|
-
|
|
60
|
-
default:
|
|
61
|
-
coords = {
|
|
62
|
-
x: reference.x,
|
|
63
|
-
y: reference.y
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
switch (getAlignment(placement)) {
|
|
68
|
-
case 'start':
|
|
69
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
case 'end':
|
|
73
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return coords;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
82
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
83
|
-
*
|
|
84
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
85
|
-
* write one for the platform you are using Floating UI with.
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
89
|
-
const {
|
|
90
|
-
placement = 'bottom',
|
|
91
|
-
strategy = 'absolute',
|
|
92
|
-
middleware = [],
|
|
93
|
-
platform
|
|
94
|
-
} = config;
|
|
95
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
96
|
-
|
|
97
|
-
let rects = await platform.getElementRects({
|
|
98
|
-
reference,
|
|
99
|
-
floating,
|
|
100
|
-
strategy
|
|
101
|
-
});
|
|
102
|
-
let {
|
|
103
|
-
x,
|
|
104
|
-
y
|
|
105
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
106
|
-
let statefulPlacement = placement;
|
|
107
|
-
let middlewareData = {};
|
|
108
|
-
|
|
109
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
110
|
-
|
|
111
|
-
const {
|
|
112
|
-
name,
|
|
113
|
-
fn
|
|
114
|
-
} = middleware[i];
|
|
115
|
-
const {
|
|
116
|
-
x: nextX,
|
|
117
|
-
y: nextY,
|
|
118
|
-
data,
|
|
119
|
-
reset
|
|
120
|
-
} = await fn({
|
|
121
|
-
x,
|
|
122
|
-
y,
|
|
123
|
-
initialPlacement: placement,
|
|
124
|
-
placement: statefulPlacement,
|
|
125
|
-
strategy,
|
|
126
|
-
middlewareData,
|
|
127
|
-
rects,
|
|
128
|
-
platform,
|
|
129
|
-
elements: {
|
|
130
|
-
reference,
|
|
131
|
-
floating
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
x = nextX != null ? nextX : x;
|
|
135
|
-
y = nextY != null ? nextY : y;
|
|
136
|
-
middlewareData = { ...middlewareData,
|
|
137
|
-
[name]: { ...middlewareData[name],
|
|
138
|
-
...data
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
if (reset) {
|
|
143
|
-
if (typeof reset === 'object') {
|
|
144
|
-
if (reset.placement) {
|
|
145
|
-
statefulPlacement = reset.placement;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (reset.rects) {
|
|
149
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
150
|
-
reference,
|
|
151
|
-
floating,
|
|
152
|
-
strategy
|
|
153
|
-
}) : reset.rects;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
({
|
|
157
|
-
x,
|
|
158
|
-
y
|
|
159
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
i = -1;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
x,
|
|
169
|
-
y,
|
|
170
|
-
placement: statefulPlacement,
|
|
171
|
-
strategy,
|
|
172
|
-
middlewareData
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
function expandPaddingObject(padding) {
|
|
177
|
-
return {
|
|
178
|
-
top: 0,
|
|
179
|
-
right: 0,
|
|
180
|
-
bottom: 0,
|
|
181
|
-
left: 0,
|
|
182
|
-
...padding
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function getSideObjectFromPadding(padding) {
|
|
187
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
188
|
-
top: padding,
|
|
189
|
-
right: padding,
|
|
190
|
-
bottom: padding,
|
|
191
|
-
left: padding
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function rectToClientRect(rect) {
|
|
196
|
-
return { ...rect,
|
|
197
|
-
top: rect.y,
|
|
198
|
-
left: rect.x,
|
|
199
|
-
right: rect.x + rect.width,
|
|
200
|
-
bottom: rect.y + rect.height
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
206
|
-
* element is overflowing a given clipping boundary.
|
|
207
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
208
|
-
* - negative = how many pixels left before it will overflow
|
|
209
|
-
* - 0 = lies flush with the boundary
|
|
210
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
211
|
-
*/
|
|
212
|
-
async function detectOverflow(middlewareArguments, options) {
|
|
213
|
-
var _await$platform$isEle;
|
|
214
|
-
|
|
215
|
-
if (options === void 0) {
|
|
216
|
-
options = {};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const {
|
|
220
|
-
x,
|
|
221
|
-
y,
|
|
222
|
-
platform,
|
|
223
|
-
rects,
|
|
224
|
-
elements,
|
|
225
|
-
strategy
|
|
226
|
-
} = middlewareArguments;
|
|
227
|
-
const {
|
|
228
|
-
boundary = 'clippingAncestors',
|
|
229
|
-
rootBoundary = 'viewport',
|
|
230
|
-
elementContext = 'floating',
|
|
231
|
-
altBoundary = false,
|
|
232
|
-
padding = 0
|
|
233
|
-
} = options;
|
|
234
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
235
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
236
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
237
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
238
|
-
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))),
|
|
239
|
-
boundary,
|
|
240
|
-
rootBoundary,
|
|
241
|
-
strategy
|
|
242
|
-
}));
|
|
243
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
244
|
-
rect: elementContext === 'floating' ? { ...rects.floating,
|
|
245
|
-
x,
|
|
246
|
-
y
|
|
247
|
-
} : rects.reference,
|
|
248
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
249
|
-
strategy
|
|
250
|
-
}) : rects[elementContext]); // positive = overflowing the clipping rect
|
|
251
|
-
// 0 or negative = within the clipping rect
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
255
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
256
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
257
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const hash$1 = {
|
|
262
|
-
left: 'right',
|
|
263
|
-
right: 'left',
|
|
264
|
-
bottom: 'top',
|
|
265
|
-
top: 'bottom'
|
|
266
|
-
};
|
|
267
|
-
function getOppositePlacement(placement) {
|
|
268
|
-
return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
272
|
-
if (rtl === void 0) {
|
|
273
|
-
rtl = false;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const alignment = getAlignment(placement);
|
|
277
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
278
|
-
const length = getLengthFromAxis(mainAxis);
|
|
279
|
-
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
280
|
-
|
|
281
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
282
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return {
|
|
286
|
-
main: mainAlignmentSide,
|
|
287
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const hash = {
|
|
292
|
-
start: 'end',
|
|
293
|
-
end: 'start'
|
|
294
|
-
};
|
|
295
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
296
|
-
return placement.replace(/start|end/g, matched => hash[matched]);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function getExpandedPlacements(placement) {
|
|
300
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
301
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Changes the placement of the floating element to one that will fit if the
|
|
306
|
-
* initially specified `placement` does not.
|
|
307
|
-
* @see https://floating-ui.com/docs/flip
|
|
308
|
-
*/
|
|
309
|
-
const flip = function (options) {
|
|
310
|
-
if (options === void 0) {
|
|
311
|
-
options = {};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
name: 'flip',
|
|
316
|
-
options,
|
|
317
|
-
|
|
318
|
-
async fn(middlewareArguments) {
|
|
319
|
-
var _middlewareData$flip;
|
|
320
|
-
|
|
321
|
-
const {
|
|
322
|
-
placement,
|
|
323
|
-
middlewareData,
|
|
324
|
-
rects,
|
|
325
|
-
initialPlacement,
|
|
326
|
-
platform,
|
|
327
|
-
elements
|
|
328
|
-
} = middlewareArguments;
|
|
329
|
-
const {
|
|
330
|
-
mainAxis: checkMainAxis = true,
|
|
331
|
-
crossAxis: checkCrossAxis = true,
|
|
332
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
333
|
-
fallbackStrategy = 'bestFit',
|
|
334
|
-
flipAlignment = true,
|
|
335
|
-
...detectOverflowOptions
|
|
336
|
-
} = options;
|
|
337
|
-
const side = getSide(placement);
|
|
338
|
-
const isBasePlacement = side === initialPlacement;
|
|
339
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
340
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
341
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
342
|
-
const overflows = [];
|
|
343
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
344
|
-
|
|
345
|
-
if (checkMainAxis) {
|
|
346
|
-
overflows.push(overflow[side]);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (checkCrossAxis) {
|
|
350
|
-
const {
|
|
351
|
-
main,
|
|
352
|
-
cross
|
|
353
|
-
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
354
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
overflowsData = [...overflowsData, {
|
|
358
|
-
placement,
|
|
359
|
-
overflows
|
|
360
|
-
}]; // One or more sides is overflowing
|
|
361
|
-
|
|
362
|
-
if (!overflows.every(side => side <= 0)) {
|
|
363
|
-
var _middlewareData$flip$, _middlewareData$flip2;
|
|
364
|
-
|
|
365
|
-
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
366
|
-
const nextPlacement = placements[nextIndex];
|
|
367
|
-
|
|
368
|
-
if (nextPlacement) {
|
|
369
|
-
// Try next placement and re-run the lifecycle
|
|
370
|
-
return {
|
|
371
|
-
data: {
|
|
372
|
-
index: nextIndex,
|
|
373
|
-
overflows: overflowsData
|
|
374
|
-
},
|
|
375
|
-
reset: {
|
|
376
|
-
placement: nextPlacement
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
let resetPlacement = 'bottom';
|
|
382
|
-
|
|
383
|
-
switch (fallbackStrategy) {
|
|
384
|
-
case 'bestFit':
|
|
385
|
-
{
|
|
386
|
-
var _overflowsData$map$so;
|
|
387
|
-
|
|
388
|
-
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;
|
|
389
|
-
|
|
390
|
-
if (placement) {
|
|
391
|
-
resetPlacement = placement;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
break;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
case 'initialPlacement':
|
|
398
|
-
resetPlacement = initialPlacement;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (placement !== resetPlacement) {
|
|
403
|
-
return {
|
|
404
|
-
reset: {
|
|
405
|
-
placement: resetPlacement
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return {};
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
};
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
function convertValueToCoords(placement, rects, value, rtl) {
|
|
418
|
-
if (rtl === void 0) {
|
|
419
|
-
rtl = false;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const side = getSide(placement);
|
|
423
|
-
const alignment = getAlignment(placement);
|
|
424
|
-
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
425
|
-
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
426
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
427
|
-
const rawValue = typeof value === 'function' ? value({ ...rects,
|
|
428
|
-
placement
|
|
429
|
-
}) : value; // eslint-disable-next-line prefer-const
|
|
430
|
-
|
|
431
|
-
let {
|
|
432
|
-
mainAxis,
|
|
433
|
-
crossAxis,
|
|
434
|
-
alignmentAxis
|
|
435
|
-
} = typeof rawValue === 'number' ? {
|
|
436
|
-
mainAxis: rawValue,
|
|
437
|
-
crossAxis: 0,
|
|
438
|
-
alignmentAxis: null
|
|
439
|
-
} : {
|
|
440
|
-
mainAxis: 0,
|
|
441
|
-
crossAxis: 0,
|
|
442
|
-
alignmentAxis: null,
|
|
443
|
-
...rawValue
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
if (alignment && typeof alignmentAxis === 'number') {
|
|
447
|
-
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return isVertical ? {
|
|
451
|
-
x: crossAxis * crossAxisMulti,
|
|
452
|
-
y: mainAxis * mainAxisMulti
|
|
453
|
-
} : {
|
|
454
|
-
x: mainAxis * mainAxisMulti,
|
|
455
|
-
y: crossAxis * crossAxisMulti
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Displaces the floating element from its reference element.
|
|
460
|
-
* @see https://floating-ui.com/docs/offset
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
const offset = function (value) {
|
|
464
|
-
if (value === void 0) {
|
|
465
|
-
value = 0;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return {
|
|
469
|
-
name: 'offset',
|
|
470
|
-
options: value,
|
|
471
|
-
|
|
472
|
-
async fn(middlewareArguments) {
|
|
473
|
-
const {
|
|
474
|
-
x,
|
|
475
|
-
y,
|
|
476
|
-
placement,
|
|
477
|
-
rects,
|
|
478
|
-
platform,
|
|
479
|
-
elements
|
|
480
|
-
} = middlewareArguments;
|
|
481
|
-
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
482
|
-
return {
|
|
483
|
-
x: x + diffCoords.x,
|
|
484
|
-
y: y + diffCoords.y,
|
|
485
|
-
data: diffCoords
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
function isWindow(value) {
|
|
493
|
-
return (value == null ? void 0 : value.toString()) === '[object Window]';
|
|
494
|
-
}
|
|
495
|
-
function getWindow(node) {
|
|
496
|
-
if (node == null) {
|
|
497
|
-
return window;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (!isWindow(node)) {
|
|
501
|
-
const ownerDocument = node.ownerDocument;
|
|
502
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
return node;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function getComputedStyle$1(element) {
|
|
509
|
-
return getWindow(element).getComputedStyle(element);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function getNodeName(node) {
|
|
513
|
-
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function isHTMLElement(value) {
|
|
517
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
518
|
-
}
|
|
519
|
-
function isElement(value) {
|
|
520
|
-
return value instanceof getWindow(value).Element;
|
|
521
|
-
}
|
|
522
|
-
function isNode(value) {
|
|
523
|
-
return value instanceof getWindow(value).Node;
|
|
524
|
-
}
|
|
525
|
-
function isShadowRoot(node) {
|
|
526
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
527
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
528
|
-
}
|
|
529
|
-
function isOverflowElement(element) {
|
|
530
|
-
// Firefox wants us to check `-x` and `-y` variations as well
|
|
531
|
-
const {
|
|
532
|
-
overflow,
|
|
533
|
-
overflowX,
|
|
534
|
-
overflowY
|
|
535
|
-
} = getComputedStyle$1(element);
|
|
536
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
537
|
-
}
|
|
538
|
-
function isTableElement(element) {
|
|
539
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
540
|
-
}
|
|
541
|
-
function isContainingBlock(element) {
|
|
542
|
-
// TODO: Try and use feature detection here instead
|
|
543
|
-
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
|
544
|
-
const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
|
|
545
|
-
// create a containing block.
|
|
546
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
547
|
-
|
|
548
|
-
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);
|
|
549
|
-
}
|
|
550
|
-
function isLayoutViewport() {
|
|
551
|
-
// Not Safari
|
|
552
|
-
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent); // Feature detection for this fails in various ways
|
|
553
|
-
// • Always-visible scrollbar or not
|
|
554
|
-
// • Width of <html>, etc.
|
|
555
|
-
// const vV = win.visualViewport;
|
|
556
|
-
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
const min = Math.min;
|
|
560
|
-
const max = Math.max;
|
|
561
|
-
const round = Math.round;
|
|
562
|
-
|
|
563
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
564
|
-
if (includeScale === void 0) {
|
|
565
|
-
includeScale = false;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (isFixedStrategy === void 0) {
|
|
569
|
-
isFixedStrategy = false;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
const clientRect = element.getBoundingClientRect();
|
|
573
|
-
let scaleX = 1;
|
|
574
|
-
let scaleY = 1;
|
|
575
|
-
|
|
576
|
-
if (includeScale && isHTMLElement(element)) {
|
|
577
|
-
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
578
|
-
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const win = isElement(element) ? getWindow(element) : window;
|
|
582
|
-
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
583
|
-
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
584
|
-
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
585
|
-
const width = clientRect.width / scaleX;
|
|
586
|
-
const height = clientRect.height / scaleY;
|
|
587
|
-
return {
|
|
588
|
-
width,
|
|
589
|
-
height,
|
|
590
|
-
top: y,
|
|
591
|
-
right: x + width,
|
|
592
|
-
bottom: y + height,
|
|
593
|
-
left: x,
|
|
594
|
-
x,
|
|
595
|
-
y
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function getDocumentElement(node) {
|
|
600
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function getNodeScroll(element) {
|
|
604
|
-
if (isWindow(element)) {
|
|
605
|
-
return {
|
|
606
|
-
scrollLeft: element.pageXOffset,
|
|
607
|
-
scrollTop: element.pageYOffset
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
return {
|
|
612
|
-
scrollLeft: element.scrollLeft,
|
|
613
|
-
scrollTop: element.scrollTop
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function getWindowScrollBarX(element) {
|
|
618
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
619
|
-
// incorrect for RTL.
|
|
620
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
function isScaled(element) {
|
|
624
|
-
const rect = getBoundingClientRect(element);
|
|
625
|
-
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
629
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
630
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
631
|
-
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
|
632
|
-
let scroll = {
|
|
633
|
-
scrollLeft: 0,
|
|
634
|
-
scrollTop: 0
|
|
635
|
-
};
|
|
636
|
-
const offsets = {
|
|
637
|
-
x: 0,
|
|
638
|
-
y: 0
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
642
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
643
|
-
scroll = getNodeScroll(offsetParent);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
if (isHTMLElement(offsetParent)) {
|
|
647
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
648
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
649
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
650
|
-
} else if (documentElement) {
|
|
651
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
return {
|
|
656
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
657
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
658
|
-
width: rect.width,
|
|
659
|
-
height: rect.height
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
function getParentNode(node) {
|
|
664
|
-
if (getNodeName(node) === 'html') {
|
|
665
|
-
return node;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
669
|
-
// @ts-ignore
|
|
670
|
-
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
671
|
-
node.parentNode || ( // DOM Element detected
|
|
672
|
-
isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
|
673
|
-
getDocumentElement(node) // fallback
|
|
674
|
-
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
function getTrueOffsetParent(element) {
|
|
679
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
680
|
-
return null;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
return element.offsetParent;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
function getContainingBlock(element) {
|
|
687
|
-
let currentNode = getParentNode(element);
|
|
688
|
-
|
|
689
|
-
if (isShadowRoot(currentNode)) {
|
|
690
|
-
currentNode = currentNode.host;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
|
|
694
|
-
if (isContainingBlock(currentNode)) {
|
|
695
|
-
return currentNode;
|
|
696
|
-
} else {
|
|
697
|
-
currentNode = currentNode.parentNode;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
return null;
|
|
702
|
-
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
703
|
-
// such as table ancestors and cross browser bugs.
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
function getOffsetParent(element) {
|
|
707
|
-
const window = getWindow(element);
|
|
708
|
-
let offsetParent = getTrueOffsetParent(element);
|
|
709
|
-
|
|
710
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
711
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
715
|
-
return window;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function getDimensions(element) {
|
|
722
|
-
if (isHTMLElement(element)) {
|
|
723
|
-
return {
|
|
724
|
-
width: element.offsetWidth,
|
|
725
|
-
height: element.offsetHeight
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
const rect = getBoundingClientRect(element);
|
|
730
|
-
return {
|
|
731
|
-
width: rect.width,
|
|
732
|
-
height: rect.height
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
737
|
-
let {
|
|
738
|
-
rect,
|
|
739
|
-
offsetParent,
|
|
740
|
-
strategy
|
|
741
|
-
} = _ref;
|
|
742
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
743
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
744
|
-
|
|
745
|
-
if (offsetParent === documentElement) {
|
|
746
|
-
return rect;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
let scroll = {
|
|
750
|
-
scrollLeft: 0,
|
|
751
|
-
scrollTop: 0
|
|
752
|
-
};
|
|
753
|
-
const offsets = {
|
|
754
|
-
x: 0,
|
|
755
|
-
y: 0
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
759
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
760
|
-
scroll = getNodeScroll(offsetParent);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (isHTMLElement(offsetParent)) {
|
|
764
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
765
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
766
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
767
|
-
} // This doesn't appear to be need to be negated.
|
|
768
|
-
// else if (documentElement) {
|
|
769
|
-
// offsets.x = getWindowScrollBarX(documentElement);
|
|
770
|
-
// }
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
return { ...rect,
|
|
775
|
-
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
776
|
-
y: rect.y - scroll.scrollTop + offsets.y
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
function getViewportRect(element, strategy) {
|
|
781
|
-
const win = getWindow(element);
|
|
782
|
-
const html = getDocumentElement(element);
|
|
783
|
-
const visualViewport = win.visualViewport;
|
|
784
|
-
let width = html.clientWidth;
|
|
785
|
-
let height = html.clientHeight;
|
|
786
|
-
let x = 0;
|
|
787
|
-
let y = 0;
|
|
788
|
-
|
|
789
|
-
if (visualViewport) {
|
|
790
|
-
width = visualViewport.width;
|
|
791
|
-
height = visualViewport.height;
|
|
792
|
-
const layoutViewport = isLayoutViewport();
|
|
793
|
-
|
|
794
|
-
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
795
|
-
x = visualViewport.offsetLeft;
|
|
796
|
-
y = visualViewport.offsetTop;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
return {
|
|
801
|
-
width,
|
|
802
|
-
height,
|
|
803
|
-
x,
|
|
804
|
-
y
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
809
|
-
|
|
810
|
-
function getDocumentRect(element) {
|
|
811
|
-
var _element$ownerDocumen;
|
|
812
|
-
|
|
813
|
-
const html = getDocumentElement(element);
|
|
814
|
-
const scroll = getNodeScroll(element);
|
|
815
|
-
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
816
|
-
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
817
|
-
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
818
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
819
|
-
const y = -scroll.scrollTop;
|
|
820
|
-
|
|
821
|
-
if (getComputedStyle$1(body || html).direction === 'rtl') {
|
|
822
|
-
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
return {
|
|
826
|
-
width,
|
|
827
|
-
height,
|
|
828
|
-
x,
|
|
829
|
-
y
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
function getNearestOverflowAncestor(node) {
|
|
834
|
-
const parentNode = getParentNode(node);
|
|
835
|
-
|
|
836
|
-
if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
|
|
837
|
-
// @ts-ignore assume body is always available
|
|
838
|
-
return node.ownerDocument.body;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
842
|
-
return parentNode;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
return getNearestOverflowAncestor(parentNode);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
function getOverflowAncestors(node, list) {
|
|
849
|
-
var _node$ownerDocument;
|
|
850
|
-
|
|
851
|
-
if (list === void 0) {
|
|
852
|
-
list = [];
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
856
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
857
|
-
const win = getWindow(scrollableAncestor);
|
|
858
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
859
|
-
const updatedList = list.concat(target);
|
|
860
|
-
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
861
|
-
updatedList.concat(getOverflowAncestors(getParentNode(target)));
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
function contains(parent, child) {
|
|
865
|
-
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
|
|
866
|
-
|
|
867
|
-
if (parent.contains(child)) {
|
|
868
|
-
return true;
|
|
869
|
-
} // then fallback to custom implementation with Shadow DOM support
|
|
870
|
-
else if (rootNode && isShadowRoot(rootNode)) {
|
|
871
|
-
let next = child;
|
|
872
|
-
|
|
873
|
-
do {
|
|
874
|
-
// use `===` replace node.isSameNode()
|
|
875
|
-
if (next && parent === next) {
|
|
876
|
-
return true;
|
|
877
|
-
} // @ts-ignore: need a better way to handle this...
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
next = next.parentNode || next.host;
|
|
881
|
-
} while (next);
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
return false;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
888
|
-
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
889
|
-
const top = clientRect.top + element.clientTop;
|
|
890
|
-
const left = clientRect.left + element.clientLeft;
|
|
891
|
-
return {
|
|
892
|
-
top,
|
|
893
|
-
left,
|
|
894
|
-
x: left,
|
|
895
|
-
y: top,
|
|
896
|
-
right: left + element.clientWidth,
|
|
897
|
-
bottom: top + element.clientHeight,
|
|
898
|
-
width: element.clientWidth,
|
|
899
|
-
height: element.clientHeight
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
904
|
-
if (clippingParent === 'viewport') {
|
|
905
|
-
return rectToClientRect(getViewportRect(element, strategy));
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
if (isElement(clippingParent)) {
|
|
909
|
-
return getInnerBoundingClientRect(clippingParent, strategy);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
913
|
-
} // A "clipping ancestor" is an overflowable container with the characteristic of
|
|
914
|
-
// clipping (or hiding) overflowing elements with a position different from
|
|
915
|
-
// `initial`
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
function getClippingAncestors(element) {
|
|
919
|
-
const clippingAncestors = getOverflowAncestors(element);
|
|
920
|
-
const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
|
|
921
|
-
const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
922
|
-
|
|
923
|
-
if (!isElement(clipperElement)) {
|
|
924
|
-
return [];
|
|
925
|
-
} // @ts-ignore isElement check ensures we return Array<Element>
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
|
929
|
-
} // Gets the maximum area that the element is visible in due to any number of
|
|
930
|
-
// clipping ancestors
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
function getClippingRect(_ref) {
|
|
934
|
-
let {
|
|
935
|
-
element,
|
|
936
|
-
boundary,
|
|
937
|
-
rootBoundary,
|
|
938
|
-
strategy
|
|
939
|
-
} = _ref;
|
|
940
|
-
const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
|
|
941
|
-
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
|
942
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
943
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
944
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
945
|
-
accRect.top = max(rect.top, accRect.top);
|
|
946
|
-
accRect.right = min(rect.right, accRect.right);
|
|
947
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
948
|
-
accRect.left = max(rect.left, accRect.left);
|
|
949
|
-
return accRect;
|
|
950
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
951
|
-
return {
|
|
952
|
-
width: clippingRect.right - clippingRect.left,
|
|
953
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
954
|
-
x: clippingRect.left,
|
|
955
|
-
y: clippingRect.top
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
const platform = {
|
|
960
|
-
getClippingRect,
|
|
961
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
962
|
-
isElement,
|
|
963
|
-
getDimensions,
|
|
964
|
-
getOffsetParent,
|
|
965
|
-
getDocumentElement,
|
|
966
|
-
getElementRects: _ref => {
|
|
967
|
-
let {
|
|
968
|
-
reference,
|
|
969
|
-
floating,
|
|
970
|
-
strategy
|
|
971
|
-
} = _ref;
|
|
972
|
-
return {
|
|
973
|
-
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
974
|
-
floating: { ...getDimensions(floating),
|
|
975
|
-
x: 0,
|
|
976
|
-
y: 0
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
},
|
|
980
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
981
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
* Automatically updates the position of the floating element when necessary.
|
|
986
|
-
* @see https://floating-ui.com/docs/autoUpdate
|
|
987
|
-
*/
|
|
988
|
-
function autoUpdate(reference, floating, update, options) {
|
|
989
|
-
if (options === void 0) {
|
|
990
|
-
options = {};
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
const {
|
|
994
|
-
ancestorScroll: _ancestorScroll = true,
|
|
995
|
-
ancestorResize: _ancestorResize = true,
|
|
996
|
-
elementResize: _elementResize = true,
|
|
997
|
-
animationFrame = false
|
|
998
|
-
} = options;
|
|
999
|
-
let cleanedUp = false;
|
|
1000
|
-
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1001
|
-
const ancestorResize = _ancestorResize && !animationFrame;
|
|
1002
|
-
const elementResize = _elementResize && !animationFrame;
|
|
1003
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
|
|
1004
|
-
ancestors.forEach(ancestor => {
|
|
1005
|
-
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1006
|
-
passive: true
|
|
1007
|
-
});
|
|
1008
|
-
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1009
|
-
});
|
|
1010
|
-
let observer = null;
|
|
1011
|
-
|
|
1012
|
-
if (elementResize) {
|
|
1013
|
-
observer = new ResizeObserver(update);
|
|
1014
|
-
isElement(reference) && observer.observe(reference);
|
|
1015
|
-
observer.observe(floating);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
let frameId;
|
|
1019
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1020
|
-
|
|
1021
|
-
if (animationFrame) {
|
|
1022
|
-
frameLoop();
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
function frameLoop() {
|
|
1026
|
-
if (cleanedUp) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1031
|
-
|
|
1032
|
-
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1033
|
-
update();
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
prevRefRect = nextRefRect;
|
|
1037
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
return () => {
|
|
1041
|
-
var _observer;
|
|
1042
|
-
|
|
1043
|
-
cleanedUp = true;
|
|
1044
|
-
ancestors.forEach(ancestor => {
|
|
1045
|
-
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1046
|
-
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1047
|
-
});
|
|
1048
|
-
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
1049
|
-
observer = null;
|
|
1050
|
-
|
|
1051
|
-
if (animationFrame) {
|
|
1052
|
-
cancelAnimationFrame(frameId);
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1059
|
-
* next to a reference element when it is given a certain CSS positioning
|
|
1060
|
-
* strategy.
|
|
1061
|
-
*/
|
|
1062
|
-
|
|
1063
|
-
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
|
1064
|
-
platform,
|
|
1065
|
-
...options
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
1
|
/*!
|
|
1069
2
|
* tabbable 5.3.1
|
|
1070
3
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
@@ -1490,6 +423,6 @@ const firstTabbable = (container) => {
|
|
|
1490
423
|
return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
|
|
1491
424
|
};
|
|
1492
425
|
|
|
1493
|
-
export {
|
|
426
|
+
export { focusable as a, isFocusable as b, firstTabbable as f, isTabbable as i, tabbable as t };
|
|
1494
427
|
|
|
1495
428
|
//# sourceMappingURL=first-tabbable.js.map
|