@jobber/components 6.118.2 → 6.119.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.
Files changed (109) hide show
  1. package/dist/Autocomplete/index.cjs +11 -10
  2. package/dist/Autocomplete/index.mjs +2 -1
  3. package/dist/Card/index.cjs +3 -1
  4. package/dist/Card/index.mjs +3 -1
  5. package/dist/Chip/index.cjs +2 -1
  6. package/dist/Chip/index.mjs +2 -1
  7. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -1
  8. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -1
  9. package/dist/Chips/InternalChipDismissible/index.cjs +2 -1
  10. package/dist/Chips/InternalChipDismissible/index.mjs +2 -1
  11. package/dist/Chips/index.cjs +2 -1
  12. package/dist/Chips/index.mjs +2 -1
  13. package/dist/Combobox/components/ComboboxActivator/index.cjs +2 -1
  14. package/dist/Combobox/components/ComboboxActivator/index.mjs +2 -1
  15. package/dist/Combobox/components/ComboboxContent/index.cjs +2 -1
  16. package/dist/Combobox/components/ComboboxContent/index.mjs +2 -1
  17. package/dist/Combobox/components/ComboboxTrigger/index.cjs +2 -1
  18. package/dist/Combobox/components/ComboboxTrigger/index.mjs +2 -1
  19. package/dist/Combobox/index.cjs +2 -1
  20. package/dist/Combobox/index.mjs +2 -1
  21. package/dist/ComboboxContent-cjs.js +5 -4
  22. package/dist/ComboboxContent-es.js +2 -1
  23. package/dist/ConfirmationModal/index.cjs +1 -0
  24. package/dist/ConfirmationModal/index.mjs +1 -0
  25. package/dist/Countdown/index.cjs +1 -1
  26. package/dist/Countdown/index.mjs +1 -1
  27. package/dist/Countdown-cjs.js +1 -1
  28. package/dist/Countdown-es.js +1 -1
  29. package/dist/DataDump/index.cjs +3 -1
  30. package/dist/DataDump/index.mjs +3 -1
  31. package/dist/DataList/components/DataListActions/index.cjs +2 -1
  32. package/dist/DataList/components/DataListActions/index.mjs +2 -1
  33. package/dist/DataList/components/DataListBulkActions/index.cjs +2 -1
  34. package/dist/DataList/components/DataListBulkActions/index.mjs +2 -1
  35. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +2 -1
  36. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +2 -1
  37. package/dist/DataList/components/DataListFilters/index.cjs +2 -1
  38. package/dist/DataList/components/DataListFilters/index.mjs +2 -1
  39. package/dist/DataList/components/DataListHeader/index.cjs +2 -1
  40. package/dist/DataList/components/DataListHeader/index.mjs +2 -1
  41. package/dist/DataList/components/DataListItem/index.cjs +2 -1
  42. package/dist/DataList/components/DataListItem/index.mjs +2 -1
  43. package/dist/DataList/components/DataListItemActions/index.cjs +2 -1
  44. package/dist/DataList/components/DataListItemActions/index.mjs +2 -1
  45. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +2 -1
  46. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +2 -1
  47. package/dist/DataList/components/DataListItems/index.cjs +2 -1
  48. package/dist/DataList/components/DataListItems/index.mjs +2 -1
  49. package/dist/DataList/components/DataListLayout/index.cjs +2 -1
  50. package/dist/DataList/components/DataListLayout/index.mjs +2 -1
  51. package/dist/DataList/components/DataListLayoutActions/index.cjs +2 -1
  52. package/dist/DataList/components/DataListLayoutActions/index.mjs +2 -1
  53. package/dist/DataList/index.cjs +2 -1
  54. package/dist/DataList/index.mjs +2 -1
  55. package/dist/DatePicker/index.cjs +2 -1
  56. package/dist/DatePicker/index.mjs +2 -1
  57. package/dist/DatePicker-cjs.js +5 -4
  58. package/dist/DatePicker-es.js +2 -1
  59. package/dist/FormatFile/index.cjs +1 -0
  60. package/dist/FormatFile/index.mjs +1 -0
  61. package/dist/Gallery/index.cjs +1 -0
  62. package/dist/Gallery/index.mjs +1 -0
  63. package/dist/InputAvatar/index.cjs +1 -1
  64. package/dist/InputAvatar/index.mjs +1 -1
  65. package/dist/InputDate/index.cjs +2 -1
  66. package/dist/InputDate/index.mjs +2 -1
  67. package/dist/InputFile/index.cjs +1 -1
  68. package/dist/InputFile/index.mjs +1 -1
  69. package/dist/InputFile-cjs.js +1 -1
  70. package/dist/InputFile-es.js +1 -1
  71. package/dist/Menu/index.cjs +3 -1
  72. package/dist/Menu/index.mjs +3 -1
  73. package/dist/Menu-cjs.js +7 -194
  74. package/dist/Menu-es.js +3 -190
  75. package/dist/Modal/index.cjs +1 -0
  76. package/dist/Modal/index.mjs +2 -1
  77. package/dist/Page/index.cjs +2 -0
  78. package/dist/Page/index.mjs +2 -0
  79. package/dist/Popover/index.cjs +2 -1
  80. package/dist/Popover/index.mjs +2 -1
  81. package/dist/Popover-cjs.js +8 -7
  82. package/dist/Popover-es.js +2 -1
  83. package/dist/Tooltip/index.cjs +2 -1
  84. package/dist/Tooltip/index.mjs +2 -1
  85. package/dist/Tooltip-cjs.js +7 -6
  86. package/dist/Tooltip-es.js +2 -1
  87. package/dist/floating-ui.react-cjs.js +218 -3104
  88. package/dist/floating-ui.react-dom-cjs.js +3000 -0
  89. package/dist/floating-ui.react-dom-es.js +2946 -0
  90. package/dist/floating-ui.react-es.js +177 -3054
  91. package/dist/index-cjs.js +166 -1161
  92. package/dist/index-cjs2.js +1189 -0
  93. package/dist/index-es.js +166 -1160
  94. package/dist/index-es2.js +1186 -0
  95. package/dist/index.cjs +4 -2
  96. package/dist/index.mjs +4 -2
  97. package/dist/primitives/index.cjs +2 -0
  98. package/dist/primitives/index.d.ts +7 -0
  99. package/dist/primitives/index.mjs +1 -0
  100. package/dist/unstyledPrimitives/index.cjs +10446 -0
  101. package/dist/unstyledPrimitives/index.d.ts +18 -0
  102. package/dist/unstyledPrimitives/index.mjs +10425 -0
  103. package/dist/useScrollToActive-cjs.js +5 -4
  104. package/dist/useScrollToActive-es.js +2 -1
  105. package/package.json +13 -2
  106. package/primitives.d.ts +1 -0
  107. package/primitives.js +17 -0
  108. package/unstyledPrimitives.d.ts +1 -0
  109. package/unstyledPrimitives.js +17 -0
@@ -1,864 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { useLayoutEffect } from 'react';
3
+ import { i as isShadowRoot, a as isHTMLElement, t as tabbable, f as floor, b as isElement, g as getOverflowAncestors, u as useFloating$1, c as isNode, d as getNodeName, e as isTabbable, h as focusable, j as isLastTraversableNode, k as getParentNode, l as getComputedStyle, m as isWebKit } from './floating-ui.react-dom-es.js';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
5
  import * as ReactDOM from 'react-dom';
5
6
 
6
- function hasWindow() {
7
- return typeof window !== 'undefined';
8
- }
9
- function getNodeName(node) {
10
- if (isNode(node)) {
11
- return (node.nodeName || '').toLowerCase();
12
- }
13
- // Mocked nodes in testing environments may not be instances of Node. By
14
- // returning `#document` an infinite loop won't occur.
15
- // https://github.com/floating-ui/floating-ui/issues/2317
16
- return '#document';
17
- }
18
- function getWindow(node) {
19
- var _node$ownerDocument;
20
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
21
- }
22
- function getDocumentElement(node) {
23
- var _ref;
24
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
25
- }
26
- function isNode(value) {
27
- if (!hasWindow()) {
28
- return false;
29
- }
30
- return value instanceof Node || value instanceof getWindow(value).Node;
31
- }
32
- function isElement(value) {
33
- if (!hasWindow()) {
34
- return false;
35
- }
36
- return value instanceof Element || value instanceof getWindow(value).Element;
37
- }
38
- function isHTMLElement(value) {
39
- if (!hasWindow()) {
40
- return false;
41
- }
42
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
43
- }
44
- function isShadowRoot(value) {
45
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
46
- return false;
47
- }
48
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
49
- }
50
- const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
51
- function isOverflowElement(element) {
52
- const {
53
- overflow,
54
- overflowX,
55
- overflowY,
56
- display
57
- } = getComputedStyle$1(element);
58
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
59
- }
60
- const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
61
- function isTableElement(element) {
62
- return tableElements.has(getNodeName(element));
63
- }
64
- const topLayerSelectors = [':popover-open', ':modal'];
65
- function isTopLayer(element) {
66
- return topLayerSelectors.some(selector => {
67
- try {
68
- return element.matches(selector);
69
- } catch (_e) {
70
- return false;
71
- }
72
- });
73
- }
74
- const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
75
- const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
76
- const containValues = ['paint', 'layout', 'strict', 'content'];
77
- function isContainingBlock(elementOrCss) {
78
- const webkit = isWebKit();
79
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
80
-
81
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
82
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
83
- return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
84
- }
85
- function getContainingBlock(element) {
86
- let currentNode = getParentNode(element);
87
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
88
- if (isContainingBlock(currentNode)) {
89
- return currentNode;
90
- } else if (isTopLayer(currentNode)) {
91
- return null;
92
- }
93
- currentNode = getParentNode(currentNode);
94
- }
95
- return null;
96
- }
97
- function isWebKit() {
98
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
99
- return CSS.supports('-webkit-backdrop-filter', 'none');
100
- }
101
- const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
102
- function isLastTraversableNode(node) {
103
- return lastTraversableNodeNames.has(getNodeName(node));
104
- }
105
- function getComputedStyle$1(element) {
106
- return getWindow(element).getComputedStyle(element);
107
- }
108
- function getNodeScroll(element) {
109
- if (isElement(element)) {
110
- return {
111
- scrollLeft: element.scrollLeft,
112
- scrollTop: element.scrollTop
113
- };
114
- }
115
- return {
116
- scrollLeft: element.scrollX,
117
- scrollTop: element.scrollY
118
- };
119
- }
120
- function getParentNode(node) {
121
- if (getNodeName(node) === 'html') {
122
- return node;
123
- }
124
- const result =
125
- // Step into the shadow DOM of the parent of a slotted node.
126
- node.assignedSlot ||
127
- // DOM Element detected.
128
- node.parentNode ||
129
- // ShadowRoot detected.
130
- isShadowRoot(node) && node.host ||
131
- // Fallback.
132
- getDocumentElement(node);
133
- return isShadowRoot(result) ? result.host : result;
134
- }
135
- function getNearestOverflowAncestor(node) {
136
- const parentNode = getParentNode(node);
137
- if (isLastTraversableNode(parentNode)) {
138
- return node.ownerDocument ? node.ownerDocument.body : node.body;
139
- }
140
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
141
- return parentNode;
142
- }
143
- return getNearestOverflowAncestor(parentNode);
144
- }
145
- function getOverflowAncestors(node, list, traverseIframes) {
146
- var _node$ownerDocument2;
147
- if (list === void 0) {
148
- list = [];
149
- }
150
- if (traverseIframes === void 0) {
151
- traverseIframes = true;
152
- }
153
- const scrollableAncestor = getNearestOverflowAncestor(node);
154
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
155
- const win = getWindow(scrollableAncestor);
156
- if (isBody) {
157
- const frameElement = getFrameElement(win);
158
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
159
- }
160
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
161
- }
162
- function getFrameElement(win) {
163
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
164
- }
165
-
166
- /**
167
- * Custom positioning reference element.
168
- * @see https://floating-ui.com/docs/virtual-elements
169
- */
170
-
171
- const sides = ['top', 'right', 'bottom', 'left'];
172
- const alignments = ['start', 'end'];
173
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
174
- const min = Math.min;
175
- const max = Math.max;
176
- const round = Math.round;
177
- const floor = Math.floor;
178
- const createCoords = v => ({
179
- x: v,
180
- y: v
181
- });
182
- const oppositeSideMap = {
183
- left: 'right',
184
- right: 'left',
185
- bottom: 'top',
186
- top: 'bottom'
187
- };
188
- const oppositeAlignmentMap = {
189
- start: 'end',
190
- end: 'start'
191
- };
192
- function clamp(start, value, end) {
193
- return max(start, min(value, end));
194
- }
195
- function evaluate(value, param) {
196
- return typeof value === 'function' ? value(param) : value;
197
- }
198
- function getSide(placement) {
199
- return placement.split('-')[0];
200
- }
201
- function getAlignment(placement) {
202
- return placement.split('-')[1];
203
- }
204
- function getOppositeAxis(axis) {
205
- return axis === 'x' ? 'y' : 'x';
206
- }
207
- function getAxisLength(axis) {
208
- return axis === 'y' ? 'height' : 'width';
209
- }
210
- const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
211
- function getSideAxis(placement) {
212
- return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
213
- }
214
- function getAlignmentAxis(placement) {
215
- return getOppositeAxis(getSideAxis(placement));
216
- }
217
- function getAlignmentSides(placement, rects, rtl) {
218
- if (rtl === void 0) {
219
- rtl = false;
220
- }
221
- const alignment = getAlignment(placement);
222
- const alignmentAxis = getAlignmentAxis(placement);
223
- const length = getAxisLength(alignmentAxis);
224
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
225
- if (rects.reference[length] > rects.floating[length]) {
226
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
227
- }
228
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
229
- }
230
- function getExpandedPlacements(placement) {
231
- const oppositePlacement = getOppositePlacement(placement);
232
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
233
- }
234
- function getOppositeAlignmentPlacement(placement) {
235
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
236
- }
237
- const lrPlacement = ['left', 'right'];
238
- const rlPlacement = ['right', 'left'];
239
- const tbPlacement = ['top', 'bottom'];
240
- const btPlacement = ['bottom', 'top'];
241
- function getSideList(side, isStart, rtl) {
242
- switch (side) {
243
- case 'top':
244
- case 'bottom':
245
- if (rtl) return isStart ? rlPlacement : lrPlacement;
246
- return isStart ? lrPlacement : rlPlacement;
247
- case 'left':
248
- case 'right':
249
- return isStart ? tbPlacement : btPlacement;
250
- default:
251
- return [];
252
- }
253
- }
254
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
255
- const alignment = getAlignment(placement);
256
- let list = getSideList(getSide(placement), direction === 'start', rtl);
257
- if (alignment) {
258
- list = list.map(side => side + "-" + alignment);
259
- if (flipAlignment) {
260
- list = list.concat(list.map(getOppositeAlignmentPlacement));
261
- }
262
- }
263
- return list;
264
- }
265
- function getOppositePlacement(placement) {
266
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
267
- }
268
- function expandPaddingObject(padding) {
269
- return {
270
- top: 0,
271
- right: 0,
272
- bottom: 0,
273
- left: 0,
274
- ...padding
275
- };
276
- }
277
- function getPaddingObject(padding) {
278
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
279
- top: padding,
280
- right: padding,
281
- bottom: padding,
282
- left: padding
283
- };
284
- }
285
- function rectToClientRect(rect) {
286
- const {
287
- x,
288
- y,
289
- width,
290
- height
291
- } = rect;
292
- return {
293
- width,
294
- height,
295
- top: y,
296
- left: x,
297
- right: x + width,
298
- bottom: y + height,
299
- x,
300
- y
301
- };
302
- }
303
-
304
- /*!
305
- * tabbable 6.2.0
306
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
307
- */
308
- // NOTE: separate `:not()` selectors has broader browser support than the newer
309
- // `:not([inert], [inert] *)` (Feb 2023)
310
- // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
311
- // the entire query to fail, resulting in no nodes found, which will break a lot
312
- // of things... so we have to rely on JS to identify nodes inside an inert container
313
- var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
314
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
315
- var NoElement = typeof Element === 'undefined';
316
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
317
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
318
- var _element$getRootNode;
319
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
320
- } : function (element) {
321
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
322
- };
323
-
324
- /**
325
- * Determines if a node is inert or in an inert ancestor.
326
- * @param {Element} [node]
327
- * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
328
- * see if any of them are inert. If false, only `node` itself is considered.
329
- * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
330
- * False if `node` is falsy.
331
- */
332
- var isInert = function isInert(node, lookUp) {
333
- var _node$getAttribute;
334
- if (lookUp === void 0) {
335
- lookUp = true;
336
- }
337
- // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
338
- // JS API property; we have to check the attribute, which can either be empty or 'true';
339
- // if it's `null` (not specified) or 'false', it's an active element
340
- var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');
341
- var inert = inertAtt === '' || inertAtt === 'true';
342
-
343
- // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
344
- // if it weren't for `matches()` not being a function on shadow roots; the following
345
- // code works for any kind of node
346
- // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
347
- // so it likely would not support `:is([inert] *)` either...
348
- var result = inert || lookUp && node && isInert(node.parentNode); // recursive
349
-
350
- return result;
351
- };
352
-
353
- /**
354
- * Determines if a node's content is editable.
355
- * @param {Element} [node]
356
- * @returns True if it's content-editable; false if it's not or `node` is falsy.
357
- */
358
- var isContentEditable = function isContentEditable(node) {
359
- var _node$getAttribute2;
360
- // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
361
- // to use the attribute directly to check for this, which can either be empty or 'true';
362
- // if it's `null` (not specified) or 'false', it's a non-editable element
363
- var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');
364
- return attValue === '' || attValue === 'true';
365
- };
366
-
367
- /**
368
- * @param {Element} el container to check in
369
- * @param {boolean} includeContainer add container to check
370
- * @param {(node: Element) => boolean} filter filter candidates
371
- * @returns {Element[]}
372
- */
373
- var getCandidates = function getCandidates(el, includeContainer, filter) {
374
- // even if `includeContainer=false`, we still have to check it for inertness because
375
- // if it's inert, all its children are inert
376
- if (isInert(el)) {
377
- return [];
378
- }
379
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
380
- if (includeContainer && matches.call(el, candidateSelector)) {
381
- candidates.unshift(el);
382
- }
383
- candidates = candidates.filter(filter);
384
- return candidates;
385
- };
386
-
387
- /**
388
- * @callback GetShadowRoot
389
- * @param {Element} element to check for shadow root
390
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
391
- */
392
-
393
- /**
394
- * @callback ShadowRootFilter
395
- * @param {Element} shadowHostNode the element which contains shadow content
396
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
397
- */
398
-
399
- /**
400
- * @typedef {Object} CandidateScope
401
- * @property {Element} scopeParent contains inner candidates
402
- * @property {Element[]} candidates list of candidates found in the scope parent
403
- */
404
-
405
- /**
406
- * @typedef {Object} IterativeOptions
407
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
408
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
409
- * or a boolean stating if it has an undisclosed shadow root
410
- * @property {(node: Element) => boolean} filter filter candidates
411
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
412
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
413
- */
414
-
415
- /**
416
- * @param {Element[]} elements list of element containers to match candidates from
417
- * @param {boolean} includeContainer add container list to check
418
- * @param {IterativeOptions} options
419
- * @returns {Array.<Element|CandidateScope>}
420
- */
421
- var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
422
- var candidates = [];
423
- var elementsToCheck = Array.from(elements);
424
- while (elementsToCheck.length) {
425
- var element = elementsToCheck.shift();
426
- if (isInert(element, false)) {
427
- // no need to look up since we're drilling down
428
- // anything inside this container will also be inert
429
- continue;
430
- }
431
- if (element.tagName === 'SLOT') {
432
- // add shadow dom slot scope (slot itself cannot be focusable)
433
- var assigned = element.assignedElements();
434
- var content = assigned.length ? assigned : element.children;
435
- var nestedCandidates = getCandidatesIteratively(content, true, options);
436
- if (options.flatten) {
437
- candidates.push.apply(candidates, nestedCandidates);
438
- } else {
439
- candidates.push({
440
- scopeParent: element,
441
- candidates: nestedCandidates
442
- });
443
- }
444
- } else {
445
- // check candidate element
446
- var validCandidate = matches.call(element, candidateSelector);
447
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
448
- candidates.push(element);
449
- }
450
-
451
- // iterate over shadow content if possible
452
- var shadowRoot = element.shadowRoot ||
453
- // check for an undisclosed shadow
454
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
455
-
456
- // no inert look up because we're already drilling down and checking for inertness
457
- // on the way down, so all containers to this root node should have already been
458
- // vetted as non-inert
459
- var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
460
- if (shadowRoot && validShadowRoot) {
461
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
462
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
463
- // child candidates found because they're likely slotted elements (elements that are
464
- // children of the web component element (which has the shadow), in the light dom, but
465
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
466
- // _after_ we return from this recursive call
467
- var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
468
- if (options.flatten) {
469
- candidates.push.apply(candidates, _nestedCandidates);
470
- } else {
471
- candidates.push({
472
- scopeParent: element,
473
- candidates: _nestedCandidates
474
- });
475
- }
476
- } else {
477
- // there's not shadow so just dig into the element's (light dom) children
478
- // __without__ giving the element special scope treatment
479
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
480
- }
481
- }
482
- }
483
- return candidates;
484
- };
485
-
486
- /**
487
- * @private
488
- * Determines if the node has an explicitly specified `tabindex` attribute.
489
- * @param {HTMLElement} node
490
- * @returns {boolean} True if so; false if not.
491
- */
492
- var hasTabIndex = function hasTabIndex(node) {
493
- return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
494
- };
495
-
496
- /**
497
- * Determine the tab index of a given node.
498
- * @param {HTMLElement} node
499
- * @returns {number} Tab order (negative, 0, or positive number).
500
- * @throws {Error} If `node` is falsy.
501
- */
502
- var getTabIndex = function getTabIndex(node) {
503
- if (!node) {
504
- throw new Error('No node provided');
505
- }
506
- if (node.tabIndex < 0) {
507
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
508
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
509
- // yet they are still part of the regular tab order; in FF, they get a default
510
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
511
- // order, consider their tab index to be 0.
512
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
513
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
514
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
515
- return 0;
516
- }
517
- }
518
- return node.tabIndex;
519
- };
520
-
521
- /**
522
- * Determine the tab index of a given node __for sort order purposes__.
523
- * @param {HTMLElement} node
524
- * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
525
- * has tabIndex -1, but needs to be sorted by document order in order for its content to be
526
- * inserted into the correct sort position.
527
- * @returns {number} Tab order (negative, 0, or positive number).
528
- */
529
- var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
530
- var tabIndex = getTabIndex(node);
531
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
532
- return 0;
533
- }
534
- return tabIndex;
535
- };
536
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
537
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
538
- };
539
- var isInput = function isInput(node) {
540
- return node.tagName === 'INPUT';
541
- };
542
- var isHiddenInput = function isHiddenInput(node) {
543
- return isInput(node) && node.type === 'hidden';
544
- };
545
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
546
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
547
- return child.tagName === 'SUMMARY';
548
- });
549
- return r;
550
- };
551
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
552
- for (var i = 0; i < nodes.length; i++) {
553
- if (nodes[i].checked && nodes[i].form === form) {
554
- return nodes[i];
555
- }
556
- }
557
- };
558
- var isTabbableRadio = function isTabbableRadio(node) {
559
- if (!node.name) {
560
- return true;
561
- }
562
- var radioScope = node.form || getRootNode(node);
563
- var queryRadios = function queryRadios(name) {
564
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
565
- };
566
- var radioSet;
567
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
568
- radioSet = queryRadios(window.CSS.escape(node.name));
569
- } else {
570
- try {
571
- radioSet = queryRadios(node.name);
572
- } catch (err) {
573
- // eslint-disable-next-line no-console
574
- 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);
575
- return false;
576
- }
577
- }
578
- var checked = getCheckedRadio(radioSet, node.form);
579
- return !checked || checked === node;
580
- };
581
- var isRadio = function isRadio(node) {
582
- return isInput(node) && node.type === 'radio';
583
- };
584
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
585
- return isRadio(node) && !isTabbableRadio(node);
586
- };
587
-
588
- // determines if a node is ultimately attached to the window's document
589
- var isNodeAttached = function isNodeAttached(node) {
590
- var _nodeRoot;
591
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
592
- // (but NOT _the_ document; see second 'If' comment below for more).
593
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
594
- // is attached, and the one we need to check if it's in the document or not (because the
595
- // shadow, and all nodes it contains, is never considered in the document since shadows
596
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
597
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
598
- // visibility, including all the nodes it contains). The host could be any normal node,
599
- // or a custom element (i.e. web component). Either way, that's the one that is considered
600
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
601
- // tested).
602
- // To further complicate things, we have to look all the way up until we find a shadow HOST
603
- // that is attached (or find none) because the node might be in nested shadows...
604
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
605
- // document (per the docs) and while it's a Document-type object, that document does not
606
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
607
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
608
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
609
- // node is actually detached.
610
- // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
611
- // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
612
- // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
613
- // `ownerDocument` will be `null`, hence the optional chaining on it.
614
- var nodeRoot = node && getRootNode(node);
615
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
616
-
617
- // in some cases, a detached node will return itself as the root instead of a document or
618
- // shadow root object, in which case, we shouldn't try to look further up the host chain
619
- var attached = false;
620
- if (nodeRoot && nodeRoot !== node) {
621
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
622
- attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
623
- while (!attached && nodeRootHost) {
624
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
625
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
626
- // which means we need to get the host's host and check if that parent host is contained
627
- // in (i.e. attached to) the document
628
- nodeRoot = getRootNode(nodeRootHost);
629
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
630
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
631
- }
632
- }
633
- return attached;
634
- };
635
- var isZeroArea = function isZeroArea(node) {
636
- var _node$getBoundingClie = node.getBoundingClientRect(),
637
- width = _node$getBoundingClie.width,
638
- height = _node$getBoundingClie.height;
639
- return width === 0 && height === 0;
640
- };
641
- var isHidden = function isHidden(node, _ref) {
642
- var displayCheck = _ref.displayCheck,
643
- getShadowRoot = _ref.getShadowRoot;
644
- // NOTE: visibility will be `undefined` if node is detached from the document
645
- // (see notes about this further down), which means we will consider it visible
646
- // (this is legacy behavior from a very long way back)
647
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
648
- // _visibility_ check, not a _display_ check
649
- if (getComputedStyle(node).visibility === 'hidden') {
650
- return true;
651
- }
652
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
653
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
654
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
655
- return true;
656
- }
657
- if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
658
- if (typeof getShadowRoot === 'function') {
659
- // figure out if we should consider the node to be in an undisclosed shadow and use the
660
- // 'non-zero-area' fallback
661
- var originalNode = node;
662
- while (node) {
663
- var parentElement = node.parentElement;
664
- var rootNode = getRootNode(node);
665
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
666
- ) {
667
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
668
- // fall back to a non-zero-area test
669
- return isZeroArea(node);
670
- } else if (node.assignedSlot) {
671
- // iterate up slot
672
- node = node.assignedSlot;
673
- } else if (!parentElement && rootNode !== node.ownerDocument) {
674
- // cross shadow boundary
675
- node = rootNode.host;
676
- } else {
677
- // iterate up normal dom
678
- node = parentElement;
679
- }
680
- }
681
- node = originalNode;
682
- }
683
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
684
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
685
- // it might be a falsy value, which means shadow DOM support is disabled
686
-
687
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
688
- // now we can just test to see if it would normally be visible or not, provided it's
689
- // attached to the main document.
690
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
691
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
692
-
693
- if (isNodeAttached(node)) {
694
- // this works wherever the node is: if there's at least one client rect, it's
695
- // somehow displayed; it also covers the CSS 'display: contents' case where the
696
- // node itself is hidden in place of its contents; and there's no need to search
697
- // up the hierarchy either
698
- return !node.getClientRects().length;
699
- }
700
-
701
- // Else, the node isn't attached to the document, which means the `getClientRects()`
702
- // API will __always__ return zero rects (this can happen, for example, if React
703
- // is used to render nodes onto a detached tree, as confirmed in this thread:
704
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
705
- //
706
- // It also means that even window.getComputedStyle(node).display will return `undefined`
707
- // because styles are only computed for nodes that are in the document.
708
- //
709
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
710
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
711
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
712
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
713
- // considering __everything__ to be visible because of the innability to determine styles.
714
- //
715
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
716
- // nodes as visible with the 'none' fallback.__
717
- if (displayCheck !== 'legacy-full') {
718
- return true; // hidden
719
- }
720
- // else, fallback to 'none' mode and consider the node visible
721
- } else if (displayCheck === 'non-zero-area') {
722
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
723
- // whether it's displayed, and that a detached node will __always__ have a zero-area
724
- // client rect, we don't special-case for whether the node is attached or not. In
725
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
726
- // times, and that includes attached or not.
727
- return isZeroArea(node);
728
- }
729
-
730
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
731
- // it's visible
732
- return false;
733
- };
734
-
735
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
736
- // unless they are in the _first_ <legend> element of the top-most disabled
737
- // fieldset
738
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
739
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
740
- var parentNode = node.parentElement;
741
- // check if `node` is contained in a disabled <fieldset>
742
- while (parentNode) {
743
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
744
- // look for the first <legend> among the children of the disabled <fieldset>
745
- for (var i = 0; i < parentNode.children.length; i++) {
746
- var child = parentNode.children.item(i);
747
- // when the first <legend> (in document order) is found
748
- if (child.tagName === 'LEGEND') {
749
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
750
- // return whether `node` is a descendant of its first <legend>
751
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
752
- }
753
- }
754
- // the disabled <fieldset> containing `node` has no <legend>
755
- return true;
756
- }
757
- parentNode = parentNode.parentElement;
758
- }
759
- }
760
-
761
- // else, node's tabbable/focusable state should not be affected by a fieldset's
762
- // enabled/disabled state
763
- return false;
764
- };
765
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
766
- if (node.disabled ||
767
- // we must do an inert look up to filter out any elements inside an inert ancestor
768
- // because we're limited in the type of selectors we can use in JSDom (see related
769
- // note related to `candidateSelectors`)
770
- isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
771
- // For a details element with a summary, the summary element gets the focus
772
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
773
- return false;
774
- }
775
- return true;
776
- };
777
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
778
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
779
- return false;
780
- }
781
- return true;
782
- };
783
- var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
784
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
785
- if (isNaN(tabIndex) || tabIndex >= 0) {
786
- return true;
787
- }
788
- // If a custom element has an explicit negative tabindex,
789
- // browsers will not allow tab targeting said element's children.
790
- return false;
791
- };
792
-
793
- /**
794
- * @param {Array.<Element|CandidateScope>} candidates
795
- * @returns Element[]
796
- */
797
- var sortByOrder = function sortByOrder(candidates) {
798
- var regularTabbables = [];
799
- var orderedTabbables = [];
800
- candidates.forEach(function (item, i) {
801
- var isScope = !!item.scopeParent;
802
- var element = isScope ? item.scopeParent : item;
803
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
804
- var elements = isScope ? sortByOrder(item.candidates) : element;
805
- if (candidateTabindex === 0) {
806
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
807
- } else {
808
- orderedTabbables.push({
809
- documentOrder: i,
810
- tabIndex: candidateTabindex,
811
- item: item,
812
- isScope: isScope,
813
- content: elements
814
- });
815
- }
816
- });
817
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
818
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
819
- return acc;
820
- }, []).concat(regularTabbables);
821
- };
822
- var tabbable = function tabbable(container, options) {
823
- options = options || {};
824
- var candidates;
825
- if (options.getShadowRoot) {
826
- candidates = getCandidatesIteratively([container], options.includeContainer, {
827
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
828
- flatten: false,
829
- getShadowRoot: options.getShadowRoot,
830
- shadowRootFilter: isValidShadowRootTabbable
831
- });
832
- } else {
833
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
834
- }
835
- return sortByOrder(candidates);
836
- };
837
- var focusable = function focusable(container, options) {
838
- options = options || {};
839
- var candidates;
840
- if (options.getShadowRoot) {
841
- candidates = getCandidatesIteratively([container], options.includeContainer, {
842
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
843
- flatten: true,
844
- getShadowRoot: options.getShadowRoot
845
- });
846
- } else {
847
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
848
- }
849
- return candidates;
850
- };
851
- var isTabbable = function isTabbable(node, options) {
852
- options = options || {};
853
- if (!node) {
854
- throw new Error('No node provided');
855
- }
856
- if (matches.call(node, candidateSelector) === false) {
857
- return false;
858
- }
859
- return isNodeMatchingSelectorTabbable(options, node);
860
- };
861
-
862
7
  // Avoid Chrome DevTools blue warning.
863
8
  function getPlatform() {
864
9
  const uaData = navigator.userAgentData;
@@ -1051,19 +196,19 @@ function isMouseLikePointerType(pointerType, strict) {
1051
196
  return values.includes(pointerType);
1052
197
  }
1053
198
 
1054
- var isClient$1 = typeof document !== 'undefined';
199
+ var isClient = typeof document !== 'undefined';
1055
200
 
1056
- var noop$1 = function noop() {};
1057
- var index$1 = isClient$1 ? useLayoutEffect : noop$1;
201
+ var noop = function noop() {};
202
+ var index = isClient ? useLayoutEffect : noop;
1058
203
 
1059
204
  // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
1060
205
  const SafeReact$1 = {
1061
206
  ...React
1062
207
  };
1063
208
 
1064
- function useLatestRef$1(value) {
209
+ function useLatestRef(value) {
1065
210
  const ref = React.useRef(value);
1066
- index$1(() => {
211
+ index(() => {
1067
212
  ref.current = value;
1068
213
  });
1069
214
  return ref;
@@ -1218,2182 +363,160 @@ function getGridNavigatedIndex(listRef, _ref) {
1218
363
  if (loop && isDifferentGridRow(nextIndex, cols, prevRow)) {
1219
364
  nextIndex = findNonDisabledListIndex(listRef, {
1220
365
  startingIndex: prevIndex + (cols - prevIndex % cols),
1221
- decrement: true,
1222
- disabledIndices
1223
- });
1224
- }
1225
- } else if (loop) {
1226
- nextIndex = findNonDisabledListIndex(listRef, {
1227
- startingIndex: prevIndex + (cols - prevIndex % cols),
1228
- decrement: true,
1229
- disabledIndices
1230
- });
1231
- }
1232
- if (isDifferentGridRow(nextIndex, cols, prevRow)) {
1233
- nextIndex = prevIndex;
1234
- }
1235
- }
1236
- const lastRow = floor(maxIndex / cols) === prevRow;
1237
- if (isIndexOutOfListBounds(listRef, nextIndex)) {
1238
- if (loop && lastRow) {
1239
- nextIndex = event.key === (rtl ? ARROW_RIGHT$1 : ARROW_LEFT$1) ? maxIndex : findNonDisabledListIndex(listRef, {
1240
- startingIndex: prevIndex - prevIndex % cols - 1,
1241
- disabledIndices
1242
- });
1243
- } else {
1244
- nextIndex = prevIndex;
1245
- }
1246
- }
1247
- }
1248
- return nextIndex;
1249
- }
1250
-
1251
- /** For each cell index, gets the item index that occupies that cell */
1252
- function createGridCellMap(sizes, cols, dense) {
1253
- const cellMap = [];
1254
- let startIndex = 0;
1255
- sizes.forEach((_ref2, index) => {
1256
- let {
1257
- width,
1258
- height
1259
- } = _ref2;
1260
- if (width > cols) {
1261
- if (process.env.NODE_ENV !== "production") {
1262
- throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
1263
- }
1264
- }
1265
- let itemPlaced = false;
1266
- if (dense) {
1267
- startIndex = 0;
1268
- }
1269
- while (!itemPlaced) {
1270
- const targetCells = [];
1271
- for (let i = 0; i < width; i++) {
1272
- for (let j = 0; j < height; j++) {
1273
- targetCells.push(startIndex + i + j * cols);
1274
- }
1275
- }
1276
- if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
1277
- targetCells.forEach(cell => {
1278
- cellMap[cell] = index;
1279
- });
1280
- itemPlaced = true;
1281
- } else {
1282
- startIndex++;
1283
- }
1284
- }
1285
- });
1286
-
1287
- // convert into a non-sparse array
1288
- return [...cellMap];
1289
- }
1290
-
1291
- /** Gets cell index of an item's corner or -1 when index is -1. */
1292
- function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
1293
- if (index === -1) return -1;
1294
- const firstCellIndex = cellMap.indexOf(index);
1295
- const sizeItem = sizes[index];
1296
- switch (corner) {
1297
- case 'tl':
1298
- return firstCellIndex;
1299
- case 'tr':
1300
- if (!sizeItem) {
1301
- return firstCellIndex;
1302
- }
1303
- return firstCellIndex + sizeItem.width - 1;
1304
- case 'bl':
1305
- if (!sizeItem) {
1306
- return firstCellIndex;
1307
- }
1308
- return firstCellIndex + (sizeItem.height - 1) * cols;
1309
- case 'br':
1310
- return cellMap.lastIndexOf(index);
1311
- }
1312
- }
1313
-
1314
- /** Gets all cell indices that correspond to the specified indices */
1315
- function getGridCellIndices(indices, cellMap) {
1316
- return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
1317
- }
1318
- function isListIndexDisabled(listRef, index, disabledIndices) {
1319
- if (typeof disabledIndices === 'function') {
1320
- return disabledIndices(index);
1321
- } else if (disabledIndices) {
1322
- return disabledIndices.includes(index);
1323
- }
1324
- const element = listRef.current[index];
1325
- return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
1326
- }
1327
-
1328
- const getTabbableOptions = () => ({
1329
- getShadowRoot: true,
1330
- displayCheck:
1331
- // JSDOM does not support the `tabbable` library. To solve this we can
1332
- // check if `ResizeObserver` is a real function (not polyfilled), which
1333
- // determines if the current environment is JSDOM-like.
1334
- typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
1335
- });
1336
- function getTabbableIn(container, dir) {
1337
- const list = tabbable(container, getTabbableOptions());
1338
- const len = list.length;
1339
- if (len === 0) return;
1340
- const active = activeElement(getDocument$1(container));
1341
- const index = list.indexOf(active);
1342
- const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
1343
- return list[nextIndex];
1344
- }
1345
- function getNextTabbable(referenceElement) {
1346
- return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
1347
- }
1348
- function getPreviousTabbable(referenceElement) {
1349
- return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
1350
- }
1351
- function isOutsideEvent(event, container) {
1352
- const containerElement = container || event.currentTarget;
1353
- const relatedTarget = event.relatedTarget;
1354
- return !relatedTarget || !contains(containerElement, relatedTarget);
1355
- }
1356
- function disableFocusInside(container) {
1357
- const tabbableElements = tabbable(container, getTabbableOptions());
1358
- tabbableElements.forEach(element => {
1359
- element.dataset.tabindex = element.getAttribute('tabindex') || '';
1360
- element.setAttribute('tabindex', '-1');
1361
- });
1362
- }
1363
- function enableFocusInside(container) {
1364
- const elements = container.querySelectorAll('[data-tabindex]');
1365
- elements.forEach(element => {
1366
- const tabindex = element.dataset.tabindex;
1367
- delete element.dataset.tabindex;
1368
- if (tabindex) {
1369
- element.setAttribute('tabindex', tabindex);
1370
- } else {
1371
- element.removeAttribute('tabindex');
1372
- }
1373
- });
1374
- }
1375
-
1376
- function computeCoordsFromPlacement(_ref, placement, rtl) {
1377
- let {
1378
- reference,
1379
- floating
1380
- } = _ref;
1381
- const sideAxis = getSideAxis(placement);
1382
- const alignmentAxis = getAlignmentAxis(placement);
1383
- const alignLength = getAxisLength(alignmentAxis);
1384
- const side = getSide(placement);
1385
- const isVertical = sideAxis === 'y';
1386
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
1387
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
1388
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1389
- let coords;
1390
- switch (side) {
1391
- case 'top':
1392
- coords = {
1393
- x: commonX,
1394
- y: reference.y - floating.height
1395
- };
1396
- break;
1397
- case 'bottom':
1398
- coords = {
1399
- x: commonX,
1400
- y: reference.y + reference.height
1401
- };
1402
- break;
1403
- case 'right':
1404
- coords = {
1405
- x: reference.x + reference.width,
1406
- y: commonY
1407
- };
1408
- break;
1409
- case 'left':
1410
- coords = {
1411
- x: reference.x - floating.width,
1412
- y: commonY
1413
- };
1414
- break;
1415
- default:
1416
- coords = {
1417
- x: reference.x,
1418
- y: reference.y
1419
- };
1420
- }
1421
- switch (getAlignment(placement)) {
1422
- case 'start':
1423
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1424
- break;
1425
- case 'end':
1426
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1427
- break;
1428
- }
1429
- return coords;
1430
- }
1431
-
1432
- /**
1433
- * Computes the `x` and `y` coordinates that will place the floating element
1434
- * next to a given reference element.
1435
- *
1436
- * This export does not have any `platform` interface logic. You will need to
1437
- * write one for the platform you are using Floating UI with.
1438
- */
1439
- const computePosition$1 = async (reference, floating, config) => {
1440
- const {
1441
- placement = 'bottom',
1442
- strategy = 'absolute',
1443
- middleware = [],
1444
- platform
1445
- } = config;
1446
- const validMiddleware = middleware.filter(Boolean);
1447
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1448
- let rects = await platform.getElementRects({
1449
- reference,
1450
- floating,
1451
- strategy
1452
- });
1453
- let {
1454
- x,
1455
- y
1456
- } = computeCoordsFromPlacement(rects, placement, rtl);
1457
- let statefulPlacement = placement;
1458
- let middlewareData = {};
1459
- let resetCount = 0;
1460
- for (let i = 0; i < validMiddleware.length; i++) {
1461
- const {
1462
- name,
1463
- fn
1464
- } = validMiddleware[i];
1465
- const {
1466
- x: nextX,
1467
- y: nextY,
1468
- data,
1469
- reset
1470
- } = await fn({
1471
- x,
1472
- y,
1473
- initialPlacement: placement,
1474
- placement: statefulPlacement,
1475
- strategy,
1476
- middlewareData,
1477
- rects,
1478
- platform,
1479
- elements: {
1480
- reference,
1481
- floating
1482
- }
1483
- });
1484
- x = nextX != null ? nextX : x;
1485
- y = nextY != null ? nextY : y;
1486
- middlewareData = {
1487
- ...middlewareData,
1488
- [name]: {
1489
- ...middlewareData[name],
1490
- ...data
1491
- }
1492
- };
1493
- if (reset && resetCount <= 50) {
1494
- resetCount++;
1495
- if (typeof reset === 'object') {
1496
- if (reset.placement) {
1497
- statefulPlacement = reset.placement;
1498
- }
1499
- if (reset.rects) {
1500
- rects = reset.rects === true ? await platform.getElementRects({
1501
- reference,
1502
- floating,
1503
- strategy
1504
- }) : reset.rects;
1505
- }
1506
- ({
1507
- x,
1508
- y
1509
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1510
- }
1511
- i = -1;
1512
- }
1513
- }
1514
- return {
1515
- x,
1516
- y,
1517
- placement: statefulPlacement,
1518
- strategy,
1519
- middlewareData
1520
- };
1521
- };
1522
-
1523
- /**
1524
- * Resolves with an object of overflow side offsets that determine how much the
1525
- * element is overflowing a given clipping boundary on each side.
1526
- * - positive = overflowing the boundary by that number of pixels
1527
- * - negative = how many pixels left before it will overflow
1528
- * - 0 = lies flush with the boundary
1529
- * @see https://floating-ui.com/docs/detectOverflow
1530
- */
1531
- async function detectOverflow(state, options) {
1532
- var _await$platform$isEle;
1533
- if (options === void 0) {
1534
- options = {};
1535
- }
1536
- const {
1537
- x,
1538
- y,
1539
- platform,
1540
- rects,
1541
- elements,
1542
- strategy
1543
- } = state;
1544
- const {
1545
- boundary = 'clippingAncestors',
1546
- rootBoundary = 'viewport',
1547
- elementContext = 'floating',
1548
- altBoundary = false,
1549
- padding = 0
1550
- } = evaluate(options, state);
1551
- const paddingObject = getPaddingObject(padding);
1552
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1553
- const element = elements[altBoundary ? altContext : elementContext];
1554
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1555
- 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))),
1556
- boundary,
1557
- rootBoundary,
1558
- strategy
1559
- }));
1560
- const rect = elementContext === 'floating' ? {
1561
- x,
1562
- y,
1563
- width: rects.floating.width,
1564
- height: rects.floating.height
1565
- } : rects.reference;
1566
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1567
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1568
- x: 1,
1569
- y: 1
1570
- } : {
1571
- x: 1,
1572
- y: 1
1573
- };
1574
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1575
- elements,
1576
- rect,
1577
- offsetParent,
1578
- strategy
1579
- }) : rect);
1580
- return {
1581
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1582
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1583
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1584
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1585
- };
1586
- }
1587
-
1588
- /**
1589
- * Provides data to position an inner element of the floating element so that it
1590
- * appears centered to the reference element.
1591
- * @see https://floating-ui.com/docs/arrow
1592
- */
1593
- const arrow$3 = options => ({
1594
- name: 'arrow',
1595
- options,
1596
- async fn(state) {
1597
- const {
1598
- x,
1599
- y,
1600
- placement,
1601
- rects,
1602
- platform,
1603
- elements,
1604
- middlewareData
1605
- } = state;
1606
- // Since `element` is required, we don't Partial<> the type.
1607
- const {
1608
- element,
1609
- padding = 0
1610
- } = evaluate(options, state) || {};
1611
- if (element == null) {
1612
- return {};
1613
- }
1614
- const paddingObject = getPaddingObject(padding);
1615
- const coords = {
1616
- x,
1617
- y
1618
- };
1619
- const axis = getAlignmentAxis(placement);
1620
- const length = getAxisLength(axis);
1621
- const arrowDimensions = await platform.getDimensions(element);
1622
- const isYAxis = axis === 'y';
1623
- const minProp = isYAxis ? 'top' : 'left';
1624
- const maxProp = isYAxis ? 'bottom' : 'right';
1625
- const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1626
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1627
- const startDiff = coords[axis] - rects.reference[axis];
1628
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1629
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1630
-
1631
- // DOM platform can return `window` as the `offsetParent`.
1632
- if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1633
- clientSize = elements.floating[clientProp] || rects.floating[length];
1634
- }
1635
- const centerToReference = endDiff / 2 - startDiff / 2;
1636
-
1637
- // If the padding is large enough that it causes the arrow to no longer be
1638
- // centered, modify the padding so that it is centered.
1639
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1640
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1641
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1642
-
1643
- // Make sure the arrow doesn't overflow the floating element if the center
1644
- // point is outside the floating element's bounds.
1645
- const min$1 = minPadding;
1646
- const max = clientSize - arrowDimensions[length] - maxPadding;
1647
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1648
- const offset = clamp(min$1, center, max);
1649
-
1650
- // If the reference is small enough that the arrow's padding causes it to
1651
- // to point to nothing for an aligned placement, adjust the offset of the
1652
- // floating element itself. To ensure `shift()` continues to take action,
1653
- // a single reset is performed when this is true.
1654
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1655
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1656
- return {
1657
- [axis]: coords[axis] + alignmentOffset,
1658
- data: {
1659
- [axis]: offset,
1660
- centerOffset: center - offset - alignmentOffset,
1661
- ...(shouldAddOffset && {
1662
- alignmentOffset
1663
- })
1664
- },
1665
- reset: shouldAddOffset
1666
- };
1667
- }
1668
- });
1669
-
1670
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1671
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1672
- return allowedPlacementsSortedByAlignment.filter(placement => {
1673
- if (alignment) {
1674
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1675
- }
1676
- return true;
1677
- });
1678
- }
1679
- /**
1680
- * Optimizes the visibility of the floating element by choosing the placement
1681
- * that has the most space available automatically, without needing to specify a
1682
- * preferred placement. Alternative to `flip`.
1683
- * @see https://floating-ui.com/docs/autoPlacement
1684
- */
1685
- const autoPlacement$2 = function (options) {
1686
- if (options === void 0) {
1687
- options = {};
1688
- }
1689
- return {
1690
- name: 'autoPlacement',
1691
- options,
1692
- async fn(state) {
1693
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1694
- const {
1695
- rects,
1696
- middlewareData,
1697
- placement,
1698
- platform,
1699
- elements
1700
- } = state;
1701
- const {
1702
- crossAxis = false,
1703
- alignment,
1704
- allowedPlacements = placements,
1705
- autoAlignment = true,
1706
- ...detectOverflowOptions
1707
- } = evaluate(options, state);
1708
- const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1709
- const overflow = await detectOverflow(state, detectOverflowOptions);
1710
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1711
- const currentPlacement = placements$1[currentIndex];
1712
- if (currentPlacement == null) {
1713
- return {};
1714
- }
1715
- const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1716
-
1717
- // Make `computeCoords` start from the right place.
1718
- if (placement !== currentPlacement) {
1719
- return {
1720
- reset: {
1721
- placement: placements$1[0]
1722
- }
1723
- };
1724
- }
1725
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1726
- const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1727
- placement: currentPlacement,
1728
- overflows: currentOverflows
1729
- }];
1730
- const nextPlacement = placements$1[currentIndex + 1];
1731
-
1732
- // There are more placements to check.
1733
- if (nextPlacement) {
1734
- return {
1735
- data: {
1736
- index: currentIndex + 1,
1737
- overflows: allOverflows
1738
- },
1739
- reset: {
1740
- placement: nextPlacement
1741
- }
1742
- };
1743
- }
1744
- const placementsSortedByMostSpace = allOverflows.map(d => {
1745
- const alignment = getAlignment(d.placement);
1746
- return [d.placement, alignment && crossAxis ?
1747
- // Check along the mainAxis and main crossAxis side.
1748
- d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1749
- // Check only the mainAxis.
1750
- d.overflows[0], d.overflows];
1751
- }).sort((a, b) => a[1] - b[1]);
1752
- const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1753
- // Aligned placements should not check their opposite crossAxis
1754
- // side.
1755
- getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1756
- const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1757
- if (resetPlacement !== placement) {
1758
- return {
1759
- data: {
1760
- index: currentIndex + 1,
1761
- overflows: allOverflows
1762
- },
1763
- reset: {
1764
- placement: resetPlacement
1765
- }
1766
- };
1767
- }
1768
- return {};
1769
- }
1770
- };
1771
- };
1772
-
1773
- /**
1774
- * Optimizes the visibility of the floating element by flipping the `placement`
1775
- * in order to keep it in view when the preferred placement(s) will overflow the
1776
- * clipping boundary. Alternative to `autoPlacement`.
1777
- * @see https://floating-ui.com/docs/flip
1778
- */
1779
- const flip$2 = function (options) {
1780
- if (options === void 0) {
1781
- options = {};
1782
- }
1783
- return {
1784
- name: 'flip',
1785
- options,
1786
- async fn(state) {
1787
- var _middlewareData$arrow, _middlewareData$flip;
1788
- const {
1789
- placement,
1790
- middlewareData,
1791
- rects,
1792
- initialPlacement,
1793
- platform,
1794
- elements
1795
- } = state;
1796
- const {
1797
- mainAxis: checkMainAxis = true,
1798
- crossAxis: checkCrossAxis = true,
1799
- fallbackPlacements: specifiedFallbackPlacements,
1800
- fallbackStrategy = 'bestFit',
1801
- fallbackAxisSideDirection = 'none',
1802
- flipAlignment = true,
1803
- ...detectOverflowOptions
1804
- } = evaluate(options, state);
1805
-
1806
- // If a reset by the arrow was caused due to an alignment offset being
1807
- // added, we should skip any logic now since `flip()` has already done its
1808
- // work.
1809
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
1810
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1811
- return {};
1812
- }
1813
- const side = getSide(placement);
1814
- const initialSideAxis = getSideAxis(initialPlacement);
1815
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1816
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1817
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1818
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
1819
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1820
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1821
- }
1822
- const placements = [initialPlacement, ...fallbackPlacements];
1823
- const overflow = await detectOverflow(state, detectOverflowOptions);
1824
- const overflows = [];
1825
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1826
- if (checkMainAxis) {
1827
- overflows.push(overflow[side]);
1828
- }
1829
- if (checkCrossAxis) {
1830
- const sides = getAlignmentSides(placement, rects, rtl);
1831
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
1832
- }
1833
- overflowsData = [...overflowsData, {
1834
- placement,
1835
- overflows
1836
- }];
1837
-
1838
- // One or more sides is overflowing.
1839
- if (!overflows.every(side => side <= 0)) {
1840
- var _middlewareData$flip2, _overflowsData$filter;
1841
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1842
- const nextPlacement = placements[nextIndex];
1843
- if (nextPlacement) {
1844
- const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
1845
- if (!ignoreCrossAxisOverflow ||
1846
- // We leave the current main axis only if every placement on that axis
1847
- // overflows the main axis.
1848
- overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
1849
- // Try next placement and re-run the lifecycle.
1850
- return {
1851
- data: {
1852
- index: nextIndex,
1853
- overflows: overflowsData
1854
- },
1855
- reset: {
1856
- placement: nextPlacement
1857
- }
1858
- };
1859
- }
1860
- }
1861
-
1862
- // First, find the candidates that fit on the mainAxis side of overflow,
1863
- // then find the placement that fits the best on the main crossAxis side.
1864
- let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1865
-
1866
- // Otherwise fallback.
1867
- if (!resetPlacement) {
1868
- switch (fallbackStrategy) {
1869
- case 'bestFit':
1870
- {
1871
- var _overflowsData$filter2;
1872
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
1873
- if (hasFallbackAxisSideDirection) {
1874
- const currentSideAxis = getSideAxis(d.placement);
1875
- return currentSideAxis === initialSideAxis ||
1876
- // Create a bias to the `y` side axis due to horizontal
1877
- // reading directions favoring greater width.
1878
- currentSideAxis === 'y';
1879
- }
1880
- return true;
1881
- }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1882
- if (placement) {
1883
- resetPlacement = placement;
1884
- }
1885
- break;
1886
- }
1887
- case 'initialPlacement':
1888
- resetPlacement = initialPlacement;
1889
- break;
1890
- }
1891
- }
1892
- if (placement !== resetPlacement) {
1893
- return {
1894
- reset: {
1895
- placement: resetPlacement
1896
- }
1897
- };
1898
- }
1899
- }
1900
- return {};
1901
- }
1902
- };
1903
- };
1904
-
1905
- function getSideOffsets(overflow, rect) {
1906
- return {
1907
- top: overflow.top - rect.height,
1908
- right: overflow.right - rect.width,
1909
- bottom: overflow.bottom - rect.height,
1910
- left: overflow.left - rect.width
1911
- };
1912
- }
1913
- function isAnySideFullyClipped(overflow) {
1914
- return sides.some(side => overflow[side] >= 0);
1915
- }
1916
- /**
1917
- * Provides data to hide the floating element in applicable situations, such as
1918
- * when it is not in the same clipping context as the reference element.
1919
- * @see https://floating-ui.com/docs/hide
1920
- */
1921
- const hide$2 = function (options) {
1922
- if (options === void 0) {
1923
- options = {};
1924
- }
1925
- return {
1926
- name: 'hide',
1927
- options,
1928
- async fn(state) {
1929
- const {
1930
- rects
1931
- } = state;
1932
- const {
1933
- strategy = 'referenceHidden',
1934
- ...detectOverflowOptions
1935
- } = evaluate(options, state);
1936
- switch (strategy) {
1937
- case 'referenceHidden':
1938
- {
1939
- const overflow = await detectOverflow(state, {
1940
- ...detectOverflowOptions,
1941
- elementContext: 'reference'
1942
- });
1943
- const offsets = getSideOffsets(overflow, rects.reference);
1944
- return {
1945
- data: {
1946
- referenceHiddenOffsets: offsets,
1947
- referenceHidden: isAnySideFullyClipped(offsets)
1948
- }
1949
- };
1950
- }
1951
- case 'escaped':
1952
- {
1953
- const overflow = await detectOverflow(state, {
1954
- ...detectOverflowOptions,
1955
- altBoundary: true
1956
- });
1957
- const offsets = getSideOffsets(overflow, rects.floating);
1958
- return {
1959
- data: {
1960
- escapedOffsets: offsets,
1961
- escaped: isAnySideFullyClipped(offsets)
1962
- }
1963
- };
1964
- }
1965
- default:
1966
- {
1967
- return {};
1968
- }
1969
- }
1970
- }
1971
- };
1972
- };
1973
-
1974
- const originSides = /*#__PURE__*/new Set(['left', 'top']);
1975
-
1976
- // For type backwards-compatibility, the `OffsetOptions` type was also
1977
- // Derivable.
1978
-
1979
- async function convertValueToCoords(state, options) {
1980
- const {
1981
- placement,
1982
- platform,
1983
- elements
1984
- } = state;
1985
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1986
- const side = getSide(placement);
1987
- const alignment = getAlignment(placement);
1988
- const isVertical = getSideAxis(placement) === 'y';
1989
- const mainAxisMulti = originSides.has(side) ? -1 : 1;
1990
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1991
- const rawValue = evaluate(options, state);
1992
-
1993
- // eslint-disable-next-line prefer-const
1994
- let {
1995
- mainAxis,
1996
- crossAxis,
1997
- alignmentAxis
1998
- } = typeof rawValue === 'number' ? {
1999
- mainAxis: rawValue,
2000
- crossAxis: 0,
2001
- alignmentAxis: null
2002
- } : {
2003
- mainAxis: rawValue.mainAxis || 0,
2004
- crossAxis: rawValue.crossAxis || 0,
2005
- alignmentAxis: rawValue.alignmentAxis
2006
- };
2007
- if (alignment && typeof alignmentAxis === 'number') {
2008
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2009
- }
2010
- return isVertical ? {
2011
- x: crossAxis * crossAxisMulti,
2012
- y: mainAxis * mainAxisMulti
2013
- } : {
2014
- x: mainAxis * mainAxisMulti,
2015
- y: crossAxis * crossAxisMulti
2016
- };
2017
- }
2018
-
2019
- /**
2020
- * Modifies the placement by translating the floating element along the
2021
- * specified axes.
2022
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
2023
- * object may be passed.
2024
- * @see https://floating-ui.com/docs/offset
2025
- */
2026
- const offset$2 = function (options) {
2027
- if (options === void 0) {
2028
- options = 0;
2029
- }
2030
- return {
2031
- name: 'offset',
2032
- options,
2033
- async fn(state) {
2034
- var _middlewareData$offse, _middlewareData$arrow;
2035
- const {
2036
- x,
2037
- y,
2038
- placement,
2039
- middlewareData
2040
- } = state;
2041
- const diffCoords = await convertValueToCoords(state, options);
2042
-
2043
- // If the placement is the same and the arrow caused an alignment offset
2044
- // then we don't need to change the positioning coordinates.
2045
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2046
- return {};
2047
- }
2048
- return {
2049
- x: x + diffCoords.x,
2050
- y: y + diffCoords.y,
2051
- data: {
2052
- ...diffCoords,
2053
- placement
2054
- }
2055
- };
2056
- }
2057
- };
2058
- };
2059
-
2060
- /**
2061
- * Optimizes the visibility of the floating element by shifting it in order to
2062
- * keep it in view when it will overflow the clipping boundary.
2063
- * @see https://floating-ui.com/docs/shift
2064
- */
2065
- const shift$2 = function (options) {
2066
- if (options === void 0) {
2067
- options = {};
2068
- }
2069
- return {
2070
- name: 'shift',
2071
- options,
2072
- async fn(state) {
2073
- const {
2074
- x,
2075
- y,
2076
- placement
2077
- } = state;
2078
- const {
2079
- mainAxis: checkMainAxis = true,
2080
- crossAxis: checkCrossAxis = false,
2081
- limiter = {
2082
- fn: _ref => {
2083
- let {
2084
- x,
2085
- y
2086
- } = _ref;
2087
- return {
2088
- x,
2089
- y
2090
- };
2091
- }
2092
- },
2093
- ...detectOverflowOptions
2094
- } = evaluate(options, state);
2095
- const coords = {
2096
- x,
2097
- y
2098
- };
2099
- const overflow = await detectOverflow(state, detectOverflowOptions);
2100
- const crossAxis = getSideAxis(getSide(placement));
2101
- const mainAxis = getOppositeAxis(crossAxis);
2102
- let mainAxisCoord = coords[mainAxis];
2103
- let crossAxisCoord = coords[crossAxis];
2104
- if (checkMainAxis) {
2105
- const minSide = mainAxis === 'y' ? 'top' : 'left';
2106
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2107
- const min = mainAxisCoord + overflow[minSide];
2108
- const max = mainAxisCoord - overflow[maxSide];
2109
- mainAxisCoord = clamp(min, mainAxisCoord, max);
2110
- }
2111
- if (checkCrossAxis) {
2112
- const minSide = crossAxis === 'y' ? 'top' : 'left';
2113
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2114
- const min = crossAxisCoord + overflow[minSide];
2115
- const max = crossAxisCoord - overflow[maxSide];
2116
- crossAxisCoord = clamp(min, crossAxisCoord, max);
2117
- }
2118
- const limitedCoords = limiter.fn({
2119
- ...state,
2120
- [mainAxis]: mainAxisCoord,
2121
- [crossAxis]: crossAxisCoord
2122
- });
2123
- return {
2124
- ...limitedCoords,
2125
- data: {
2126
- x: limitedCoords.x - x,
2127
- y: limitedCoords.y - y,
2128
- enabled: {
2129
- [mainAxis]: checkMainAxis,
2130
- [crossAxis]: checkCrossAxis
2131
- }
2132
- }
2133
- };
2134
- }
2135
- };
2136
- };
2137
- /**
2138
- * Built-in `limiter` that will stop `shift()` at a certain point.
2139
- */
2140
- const limitShift$2 = function (options) {
2141
- if (options === void 0) {
2142
- options = {};
2143
- }
2144
- return {
2145
- options,
2146
- fn(state) {
2147
- const {
2148
- x,
2149
- y,
2150
- placement,
2151
- rects,
2152
- middlewareData
2153
- } = state;
2154
- const {
2155
- offset = 0,
2156
- mainAxis: checkMainAxis = true,
2157
- crossAxis: checkCrossAxis = true
2158
- } = evaluate(options, state);
2159
- const coords = {
2160
- x,
2161
- y
2162
- };
2163
- const crossAxis = getSideAxis(placement);
2164
- const mainAxis = getOppositeAxis(crossAxis);
2165
- let mainAxisCoord = coords[mainAxis];
2166
- let crossAxisCoord = coords[crossAxis];
2167
- const rawOffset = evaluate(offset, state);
2168
- const computedOffset = typeof rawOffset === 'number' ? {
2169
- mainAxis: rawOffset,
2170
- crossAxis: 0
2171
- } : {
2172
- mainAxis: 0,
2173
- crossAxis: 0,
2174
- ...rawOffset
2175
- };
2176
- if (checkMainAxis) {
2177
- const len = mainAxis === 'y' ? 'height' : 'width';
2178
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2179
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2180
- if (mainAxisCoord < limitMin) {
2181
- mainAxisCoord = limitMin;
2182
- } else if (mainAxisCoord > limitMax) {
2183
- mainAxisCoord = limitMax;
2184
- }
2185
- }
2186
- if (checkCrossAxis) {
2187
- var _middlewareData$offse, _middlewareData$offse2;
2188
- const len = mainAxis === 'y' ? 'width' : 'height';
2189
- const isOriginSide = originSides.has(getSide(placement));
2190
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
2191
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
2192
- if (crossAxisCoord < limitMin) {
2193
- crossAxisCoord = limitMin;
2194
- } else if (crossAxisCoord > limitMax) {
2195
- crossAxisCoord = limitMax;
2196
- }
2197
- }
2198
- return {
2199
- [mainAxis]: mainAxisCoord,
2200
- [crossAxis]: crossAxisCoord
2201
- };
2202
- }
2203
- };
2204
- };
2205
-
2206
- /**
2207
- * Provides data that allows you to change the size of the floating element —
2208
- * for instance, prevent it from overflowing the clipping boundary or match the
2209
- * width of the reference element.
2210
- * @see https://floating-ui.com/docs/size
2211
- */
2212
- const size$2 = function (options) {
2213
- if (options === void 0) {
2214
- options = {};
2215
- }
2216
- return {
2217
- name: 'size',
2218
- options,
2219
- async fn(state) {
2220
- var _state$middlewareData, _state$middlewareData2;
2221
- const {
2222
- placement,
2223
- rects,
2224
- platform,
2225
- elements
2226
- } = state;
2227
- const {
2228
- apply = () => {},
2229
- ...detectOverflowOptions
2230
- } = evaluate(options, state);
2231
- const overflow = await detectOverflow(state, detectOverflowOptions);
2232
- const side = getSide(placement);
2233
- const alignment = getAlignment(placement);
2234
- const isYAxis = getSideAxis(placement) === 'y';
2235
- const {
2236
- width,
2237
- height
2238
- } = rects.floating;
2239
- let heightSide;
2240
- let widthSide;
2241
- if (side === 'top' || side === 'bottom') {
2242
- heightSide = side;
2243
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2244
- } else {
2245
- widthSide = side;
2246
- heightSide = alignment === 'end' ? 'top' : 'bottom';
2247
- }
2248
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
2249
- const maximumClippingWidth = width - overflow.left - overflow.right;
2250
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
2251
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
2252
- const noShift = !state.middlewareData.shift;
2253
- let availableHeight = overflowAvailableHeight;
2254
- let availableWidth = overflowAvailableWidth;
2255
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
2256
- availableWidth = maximumClippingWidth;
2257
- }
2258
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
2259
- availableHeight = maximumClippingHeight;
2260
- }
2261
- if (noShift && !alignment) {
2262
- const xMin = max(overflow.left, 0);
2263
- const xMax = max(overflow.right, 0);
2264
- const yMin = max(overflow.top, 0);
2265
- const yMax = max(overflow.bottom, 0);
2266
- if (isYAxis) {
2267
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2268
- } else {
2269
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2270
- }
2271
- }
2272
- await apply({
2273
- ...state,
2274
- availableWidth,
2275
- availableHeight
2276
- });
2277
- const nextDimensions = await platform.getDimensions(elements.floating);
2278
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
2279
- return {
2280
- reset: {
2281
- rects: true
2282
- }
2283
- };
2284
- }
2285
- return {};
2286
- }
2287
- };
2288
- };
2289
-
2290
- function getCssDimensions(element) {
2291
- const css = getComputedStyle$1(element);
2292
- // In testing environments, the `width` and `height` properties are empty
2293
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2294
- let width = parseFloat(css.width) || 0;
2295
- let height = parseFloat(css.height) || 0;
2296
- const hasOffset = isHTMLElement(element);
2297
- const offsetWidth = hasOffset ? element.offsetWidth : width;
2298
- const offsetHeight = hasOffset ? element.offsetHeight : height;
2299
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2300
- if (shouldFallback) {
2301
- width = offsetWidth;
2302
- height = offsetHeight;
2303
- }
2304
- return {
2305
- width,
2306
- height,
2307
- $: shouldFallback
2308
- };
2309
- }
2310
-
2311
- function unwrapElement(element) {
2312
- return !isElement(element) ? element.contextElement : element;
2313
- }
2314
-
2315
- function getScale(element) {
2316
- const domElement = unwrapElement(element);
2317
- if (!isHTMLElement(domElement)) {
2318
- return createCoords(1);
2319
- }
2320
- const rect = domElement.getBoundingClientRect();
2321
- const {
2322
- width,
2323
- height,
2324
- $
2325
- } = getCssDimensions(domElement);
2326
- let x = ($ ? round(rect.width) : rect.width) / width;
2327
- let y = ($ ? round(rect.height) : rect.height) / height;
2328
-
2329
- // 0, NaN, or Infinity should always fallback to 1.
2330
-
2331
- if (!x || !Number.isFinite(x)) {
2332
- x = 1;
2333
- }
2334
- if (!y || !Number.isFinite(y)) {
2335
- y = 1;
2336
- }
2337
- return {
2338
- x,
2339
- y
2340
- };
2341
- }
2342
-
2343
- const noOffsets = /*#__PURE__*/createCoords(0);
2344
- function getVisualOffsets(element) {
2345
- const win = getWindow(element);
2346
- if (!isWebKit() || !win.visualViewport) {
2347
- return noOffsets;
2348
- }
2349
- return {
2350
- x: win.visualViewport.offsetLeft,
2351
- y: win.visualViewport.offsetTop
2352
- };
2353
- }
2354
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2355
- if (isFixed === void 0) {
2356
- isFixed = false;
2357
- }
2358
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2359
- return false;
2360
- }
2361
- return isFixed;
2362
- }
2363
-
2364
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2365
- if (includeScale === void 0) {
2366
- includeScale = false;
2367
- }
2368
- if (isFixedStrategy === void 0) {
2369
- isFixedStrategy = false;
2370
- }
2371
- const clientRect = element.getBoundingClientRect();
2372
- const domElement = unwrapElement(element);
2373
- let scale = createCoords(1);
2374
- if (includeScale) {
2375
- if (offsetParent) {
2376
- if (isElement(offsetParent)) {
2377
- scale = getScale(offsetParent);
2378
- }
2379
- } else {
2380
- scale = getScale(element);
2381
- }
2382
- }
2383
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2384
- let x = (clientRect.left + visualOffsets.x) / scale.x;
2385
- let y = (clientRect.top + visualOffsets.y) / scale.y;
2386
- let width = clientRect.width / scale.x;
2387
- let height = clientRect.height / scale.y;
2388
- if (domElement) {
2389
- const win = getWindow(domElement);
2390
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2391
- let currentWin = win;
2392
- let currentIFrame = getFrameElement(currentWin);
2393
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2394
- const iframeScale = getScale(currentIFrame);
2395
- const iframeRect = currentIFrame.getBoundingClientRect();
2396
- const css = getComputedStyle$1(currentIFrame);
2397
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2398
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2399
- x *= iframeScale.x;
2400
- y *= iframeScale.y;
2401
- width *= iframeScale.x;
2402
- height *= iframeScale.y;
2403
- x += left;
2404
- y += top;
2405
- currentWin = getWindow(currentIFrame);
2406
- currentIFrame = getFrameElement(currentWin);
2407
- }
2408
- }
2409
- return rectToClientRect({
2410
- width,
2411
- height,
2412
- x,
2413
- y
2414
- });
2415
- }
2416
-
2417
- // If <html> has a CSS width greater than the viewport, then this will be
2418
- // incorrect for RTL.
2419
- function getWindowScrollBarX(element, rect) {
2420
- const leftScroll = getNodeScroll(element).scrollLeft;
2421
- if (!rect) {
2422
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2423
- }
2424
- return rect.left + leftScroll;
2425
- }
2426
-
2427
- function getHTMLOffset(documentElement, scroll) {
2428
- const htmlRect = documentElement.getBoundingClientRect();
2429
- const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
2430
- const y = htmlRect.top + scroll.scrollTop;
2431
- return {
2432
- x,
2433
- y
2434
- };
2435
- }
2436
-
2437
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2438
- let {
2439
- elements,
2440
- rect,
2441
- offsetParent,
2442
- strategy
2443
- } = _ref;
2444
- const isFixed = strategy === 'fixed';
2445
- const documentElement = getDocumentElement(offsetParent);
2446
- const topLayer = elements ? isTopLayer(elements.floating) : false;
2447
- if (offsetParent === documentElement || topLayer && isFixed) {
2448
- return rect;
2449
- }
2450
- let scroll = {
2451
- scrollLeft: 0,
2452
- scrollTop: 0
2453
- };
2454
- let scale = createCoords(1);
2455
- const offsets = createCoords(0);
2456
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2457
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2458
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2459
- scroll = getNodeScroll(offsetParent);
2460
- }
2461
- if (isHTMLElement(offsetParent)) {
2462
- const offsetRect = getBoundingClientRect(offsetParent);
2463
- scale = getScale(offsetParent);
2464
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2465
- offsets.y = offsetRect.y + offsetParent.clientTop;
2466
- }
2467
- }
2468
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2469
- return {
2470
- width: rect.width * scale.x,
2471
- height: rect.height * scale.y,
2472
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2473
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2474
- };
2475
- }
2476
-
2477
- function getClientRects(element) {
2478
- return Array.from(element.getClientRects());
2479
- }
2480
-
2481
- // Gets the entire size of the scrollable document area, even extending outside
2482
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2483
- function getDocumentRect(element) {
2484
- const html = getDocumentElement(element);
2485
- const scroll = getNodeScroll(element);
2486
- const body = element.ownerDocument.body;
2487
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2488
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2489
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2490
- const y = -scroll.scrollTop;
2491
- if (getComputedStyle$1(body).direction === 'rtl') {
2492
- x += max(html.clientWidth, body.clientWidth) - width;
2493
- }
2494
- return {
2495
- width,
2496
- height,
2497
- x,
2498
- y
2499
- };
2500
- }
2501
-
2502
- // Safety check: ensure the scrollbar space is reasonable in case this
2503
- // calculation is affected by unusual styles.
2504
- // Most scrollbars leave 15-18px of space.
2505
- const SCROLLBAR_MAX = 25;
2506
- function getViewportRect(element, strategy) {
2507
- const win = getWindow(element);
2508
- const html = getDocumentElement(element);
2509
- const visualViewport = win.visualViewport;
2510
- let width = html.clientWidth;
2511
- let height = html.clientHeight;
2512
- let x = 0;
2513
- let y = 0;
2514
- if (visualViewport) {
2515
- width = visualViewport.width;
2516
- height = visualViewport.height;
2517
- const visualViewportBased = isWebKit();
2518
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2519
- x = visualViewport.offsetLeft;
2520
- y = visualViewport.offsetTop;
2521
- }
2522
- }
2523
- const windowScrollbarX = getWindowScrollBarX(html);
2524
- // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
2525
- // visual width of the <html> but this is not considered in the size
2526
- // of `html.clientWidth`.
2527
- if (windowScrollbarX <= 0) {
2528
- const doc = html.ownerDocument;
2529
- const body = doc.body;
2530
- const bodyStyles = getComputedStyle(body);
2531
- const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
2532
- const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
2533
- if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
2534
- width -= clippingStableScrollbarWidth;
2535
- }
2536
- } else if (windowScrollbarX <= SCROLLBAR_MAX) {
2537
- // If the <body> scrollbar is on the left, the width needs to be extended
2538
- // by the scrollbar amount so there isn't extra space on the right.
2539
- width += windowScrollbarX;
2540
- }
2541
- return {
2542
- width,
2543
- height,
2544
- x,
2545
- y
2546
- };
2547
- }
2548
-
2549
- const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
2550
- // Returns the inner client rect, subtracting scrollbars if present.
2551
- function getInnerBoundingClientRect(element, strategy) {
2552
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2553
- const top = clientRect.top + element.clientTop;
2554
- const left = clientRect.left + element.clientLeft;
2555
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2556
- const width = element.clientWidth * scale.x;
2557
- const height = element.clientHeight * scale.y;
2558
- const x = left * scale.x;
2559
- const y = top * scale.y;
2560
- return {
2561
- width,
2562
- height,
2563
- x,
2564
- y
2565
- };
2566
- }
2567
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2568
- let rect;
2569
- if (clippingAncestor === 'viewport') {
2570
- rect = getViewportRect(element, strategy);
2571
- } else if (clippingAncestor === 'document') {
2572
- rect = getDocumentRect(getDocumentElement(element));
2573
- } else if (isElement(clippingAncestor)) {
2574
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2575
- } else {
2576
- const visualOffsets = getVisualOffsets(element);
2577
- rect = {
2578
- x: clippingAncestor.x - visualOffsets.x,
2579
- y: clippingAncestor.y - visualOffsets.y,
2580
- width: clippingAncestor.width,
2581
- height: clippingAncestor.height
2582
- };
2583
- }
2584
- return rectToClientRect(rect);
2585
- }
2586
- function hasFixedPositionAncestor(element, stopNode) {
2587
- const parentNode = getParentNode(element);
2588
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2589
- return false;
2590
- }
2591
- return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
2592
- }
2593
-
2594
- // A "clipping ancestor" is an `overflow` element with the characteristic of
2595
- // clipping (or hiding) child elements. This returns all clipping ancestors
2596
- // of the given element up the tree.
2597
- function getClippingElementAncestors(element, cache) {
2598
- const cachedResult = cache.get(element);
2599
- if (cachedResult) {
2600
- return cachedResult;
2601
- }
2602
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
2603
- let currentContainingBlockComputedStyle = null;
2604
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2605
- let currentNode = elementIsFixed ? getParentNode(element) : element;
2606
-
2607
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2608
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2609
- const computedStyle = getComputedStyle$1(currentNode);
2610
- const currentNodeIsContaining = isContainingBlock(currentNode);
2611
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
2612
- currentContainingBlockComputedStyle = null;
2613
- }
2614
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2615
- if (shouldDropCurrentNode) {
2616
- // Drop non-containing blocks.
2617
- result = result.filter(ancestor => ancestor !== currentNode);
2618
- } else {
2619
- // Record last containing block for next iteration.
2620
- currentContainingBlockComputedStyle = computedStyle;
2621
- }
2622
- currentNode = getParentNode(currentNode);
2623
- }
2624
- cache.set(element, result);
2625
- return result;
2626
- }
2627
-
2628
- // Gets the maximum area that the element is visible in due to any number of
2629
- // clipping ancestors.
2630
- function getClippingRect(_ref) {
2631
- let {
2632
- element,
2633
- boundary,
2634
- rootBoundary,
2635
- strategy
2636
- } = _ref;
2637
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2638
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2639
- const firstClippingAncestor = clippingAncestors[0];
2640
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2641
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2642
- accRect.top = max(rect.top, accRect.top);
2643
- accRect.right = min(rect.right, accRect.right);
2644
- accRect.bottom = min(rect.bottom, accRect.bottom);
2645
- accRect.left = max(rect.left, accRect.left);
2646
- return accRect;
2647
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2648
- return {
2649
- width: clippingRect.right - clippingRect.left,
2650
- height: clippingRect.bottom - clippingRect.top,
2651
- x: clippingRect.left,
2652
- y: clippingRect.top
2653
- };
2654
- }
2655
-
2656
- function getDimensions(element) {
2657
- const {
2658
- width,
2659
- height
2660
- } = getCssDimensions(element);
2661
- return {
2662
- width,
2663
- height
2664
- };
2665
- }
2666
-
2667
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2668
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2669
- const documentElement = getDocumentElement(offsetParent);
2670
- const isFixed = strategy === 'fixed';
2671
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2672
- let scroll = {
2673
- scrollLeft: 0,
2674
- scrollTop: 0
2675
- };
2676
- const offsets = createCoords(0);
2677
-
2678
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
2679
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
2680
- function setLeftRTLScrollbarOffset() {
2681
- offsets.x = getWindowScrollBarX(documentElement);
2682
- }
2683
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2684
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2685
- scroll = getNodeScroll(offsetParent);
2686
- }
2687
- if (isOffsetParentAnElement) {
2688
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2689
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2690
- offsets.y = offsetRect.y + offsetParent.clientTop;
2691
- } else if (documentElement) {
2692
- setLeftRTLScrollbarOffset();
2693
- }
2694
- }
2695
- if (isFixed && !isOffsetParentAnElement && documentElement) {
2696
- setLeftRTLScrollbarOffset();
2697
- }
2698
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2699
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2700
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2701
- return {
2702
- x,
2703
- y,
2704
- width: rect.width,
2705
- height: rect.height
2706
- };
2707
- }
2708
-
2709
- function isStaticPositioned(element) {
2710
- return getComputedStyle$1(element).position === 'static';
2711
- }
2712
-
2713
- function getTrueOffsetParent(element, polyfill) {
2714
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2715
- return null;
2716
- }
2717
- if (polyfill) {
2718
- return polyfill(element);
2719
- }
2720
- let rawOffsetParent = element.offsetParent;
2721
-
2722
- // Firefox returns the <html> element as the offsetParent if it's non-static,
2723
- // while Chrome and Safari return the <body> element. The <body> element must
2724
- // be used to perform the correct calculations even if the <html> element is
2725
- // non-static.
2726
- if (getDocumentElement(element) === rawOffsetParent) {
2727
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
2728
- }
2729
- return rawOffsetParent;
2730
- }
2731
-
2732
- // Gets the closest ancestor positioned element. Handles some edge cases,
2733
- // such as table ancestors and cross browser bugs.
2734
- function getOffsetParent(element, polyfill) {
2735
- const win = getWindow(element);
2736
- if (isTopLayer(element)) {
2737
- return win;
2738
- }
2739
- if (!isHTMLElement(element)) {
2740
- let svgOffsetParent = getParentNode(element);
2741
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2742
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2743
- return svgOffsetParent;
2744
- }
2745
- svgOffsetParent = getParentNode(svgOffsetParent);
2746
- }
2747
- return win;
2748
- }
2749
- let offsetParent = getTrueOffsetParent(element, polyfill);
2750
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2751
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2752
- }
2753
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2754
- return win;
2755
- }
2756
- return offsetParent || getContainingBlock(element) || win;
2757
- }
2758
-
2759
- const getElementRects = async function (data) {
2760
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2761
- const getDimensionsFn = this.getDimensions;
2762
- const floatingDimensions = await getDimensionsFn(data.floating);
2763
- return {
2764
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2765
- floating: {
2766
- x: 0,
2767
- y: 0,
2768
- width: floatingDimensions.width,
2769
- height: floatingDimensions.height
2770
- }
2771
- };
2772
- };
2773
-
2774
- function isRTL(element) {
2775
- return getComputedStyle$1(element).direction === 'rtl';
2776
- }
2777
-
2778
- const platform = {
2779
- convertOffsetParentRelativeRectToViewportRelativeRect,
2780
- getDocumentElement,
2781
- getClippingRect,
2782
- getOffsetParent,
2783
- getElementRects,
2784
- getClientRects,
2785
- getDimensions,
2786
- getScale,
2787
- isElement,
2788
- isRTL
2789
- };
2790
-
2791
- function rectsAreEqual(a, b) {
2792
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
2793
- }
2794
-
2795
- // https://samthor.au/2021/observing-dom/
2796
- function observeMove(element, onMove) {
2797
- let io = null;
2798
- let timeoutId;
2799
- const root = getDocumentElement(element);
2800
- function cleanup() {
2801
- var _io;
2802
- clearTimeout(timeoutId);
2803
- (_io = io) == null || _io.disconnect();
2804
- io = null;
2805
- }
2806
- function refresh(skip, threshold) {
2807
- if (skip === void 0) {
2808
- skip = false;
2809
- }
2810
- if (threshold === void 0) {
2811
- threshold = 1;
2812
- }
2813
- cleanup();
2814
- const elementRectForRootMargin = element.getBoundingClientRect();
2815
- const {
2816
- left,
2817
- top,
2818
- width,
2819
- height
2820
- } = elementRectForRootMargin;
2821
- if (!skip) {
2822
- onMove();
2823
- }
2824
- if (!width || !height) {
2825
- return;
2826
- }
2827
- const insetTop = floor(top);
2828
- const insetRight = floor(root.clientWidth - (left + width));
2829
- const insetBottom = floor(root.clientHeight - (top + height));
2830
- const insetLeft = floor(left);
2831
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2832
- const options = {
2833
- rootMargin,
2834
- threshold: max(0, min(1, threshold)) || 1
2835
- };
2836
- let isFirstUpdate = true;
2837
- function handleObserve(entries) {
2838
- const ratio = entries[0].intersectionRatio;
2839
- if (ratio !== threshold) {
2840
- if (!isFirstUpdate) {
2841
- return refresh();
2842
- }
2843
- if (!ratio) {
2844
- // If the reference is clipped, the ratio is 0. Throttle the refresh
2845
- // to prevent an infinite loop of updates.
2846
- timeoutId = setTimeout(() => {
2847
- refresh(false, 1e-7);
2848
- }, 1000);
2849
- } else {
2850
- refresh(false, ratio);
2851
- }
2852
- }
2853
- if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
2854
- // It's possible that even though the ratio is reported as 1, the
2855
- // element is not actually fully within the IntersectionObserver's root
2856
- // area anymore. This can happen under performance constraints. This may
2857
- // be a bug in the browser's IntersectionObserver implementation. To
2858
- // work around this, we compare the element's bounding rect now with
2859
- // what it was at the time we created the IntersectionObserver. If they
2860
- // are not equal then the element moved, so we refresh.
2861
- refresh();
2862
- }
2863
- isFirstUpdate = false;
2864
- }
2865
-
2866
- // Older browsers don't support a `document` as the root and will throw an
2867
- // error.
2868
- try {
2869
- io = new IntersectionObserver(handleObserve, {
2870
- ...options,
2871
- // Handle <iframe>s
2872
- root: root.ownerDocument
2873
- });
2874
- } catch (_e) {
2875
- io = new IntersectionObserver(handleObserve, options);
2876
- }
2877
- io.observe(element);
2878
- }
2879
- refresh(true);
2880
- return cleanup;
2881
- }
2882
-
2883
- /**
2884
- * Automatically updates the position of the floating element when necessary.
2885
- * Should only be called when the floating element is mounted on the DOM or
2886
- * visible on the screen.
2887
- * @returns cleanup function that should be invoked when the floating element is
2888
- * removed from the DOM or hidden from the screen.
2889
- * @see https://floating-ui.com/docs/autoUpdate
2890
- */
2891
- function autoUpdate(reference, floating, update, options) {
2892
- if (options === void 0) {
2893
- options = {};
2894
- }
2895
- const {
2896
- ancestorScroll = true,
2897
- ancestorResize = true,
2898
- elementResize = typeof ResizeObserver === 'function',
2899
- layoutShift = typeof IntersectionObserver === 'function',
2900
- animationFrame = false
2901
- } = options;
2902
- const referenceEl = unwrapElement(reference);
2903
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2904
- ancestors.forEach(ancestor => {
2905
- ancestorScroll && ancestor.addEventListener('scroll', update, {
2906
- passive: true
2907
- });
2908
- ancestorResize && ancestor.addEventListener('resize', update);
2909
- });
2910
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2911
- let reobserveFrame = -1;
2912
- let resizeObserver = null;
2913
- if (elementResize) {
2914
- resizeObserver = new ResizeObserver(_ref => {
2915
- let [firstEntry] = _ref;
2916
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2917
- // Prevent update loops when using the `size` middleware.
2918
- // https://github.com/floating-ui/floating-ui/issues/1740
2919
- resizeObserver.unobserve(floating);
2920
- cancelAnimationFrame(reobserveFrame);
2921
- reobserveFrame = requestAnimationFrame(() => {
2922
- var _resizeObserver;
2923
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2924
- });
2925
- }
2926
- update();
2927
- });
2928
- if (referenceEl && !animationFrame) {
2929
- resizeObserver.observe(referenceEl);
2930
- }
2931
- resizeObserver.observe(floating);
2932
- }
2933
- let frameId;
2934
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2935
- if (animationFrame) {
2936
- frameLoop();
2937
- }
2938
- function frameLoop() {
2939
- const nextRefRect = getBoundingClientRect(reference);
2940
- if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2941
- update();
2942
- }
2943
- prevRefRect = nextRefRect;
2944
- frameId = requestAnimationFrame(frameLoop);
2945
- }
2946
- update();
2947
- return () => {
2948
- var _resizeObserver2;
2949
- ancestors.forEach(ancestor => {
2950
- ancestorScroll && ancestor.removeEventListener('scroll', update);
2951
- ancestorResize && ancestor.removeEventListener('resize', update);
2952
- });
2953
- cleanupIo == null || cleanupIo();
2954
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2955
- resizeObserver = null;
2956
- if (animationFrame) {
2957
- cancelAnimationFrame(frameId);
2958
- }
2959
- };
2960
- }
2961
-
2962
- /**
2963
- * Modifies the placement by translating the floating element along the
2964
- * specified axes.
2965
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
2966
- * object may be passed.
2967
- * @see https://floating-ui.com/docs/offset
2968
- */
2969
- const offset$1 = offset$2;
2970
-
2971
- /**
2972
- * Optimizes the visibility of the floating element by choosing the placement
2973
- * that has the most space available automatically, without needing to specify a
2974
- * preferred placement. Alternative to `flip`.
2975
- * @see https://floating-ui.com/docs/autoPlacement
2976
- */
2977
- const autoPlacement$1 = autoPlacement$2;
2978
-
2979
- /**
2980
- * Optimizes the visibility of the floating element by shifting it in order to
2981
- * keep it in view when it will overflow the clipping boundary.
2982
- * @see https://floating-ui.com/docs/shift
2983
- */
2984
- const shift$1 = shift$2;
2985
-
2986
- /**
2987
- * Optimizes the visibility of the floating element by flipping the `placement`
2988
- * in order to keep it in view when the preferred placement(s) will overflow the
2989
- * clipping boundary. Alternative to `autoPlacement`.
2990
- * @see https://floating-ui.com/docs/flip
2991
- */
2992
- const flip$1 = flip$2;
2993
-
2994
- /**
2995
- * Provides data that allows you to change the size of the floating element —
2996
- * for instance, prevent it from overflowing the clipping boundary or match the
2997
- * width of the reference element.
2998
- * @see https://floating-ui.com/docs/size
2999
- */
3000
- const size$1 = size$2;
3001
-
3002
- /**
3003
- * Provides data to hide the floating element in applicable situations, such as
3004
- * when it is not in the same clipping context as the reference element.
3005
- * @see https://floating-ui.com/docs/hide
3006
- */
3007
- const hide$1 = hide$2;
3008
-
3009
- /**
3010
- * Provides data to position an inner element of the floating element so that it
3011
- * appears centered to the reference element.
3012
- * @see https://floating-ui.com/docs/arrow
3013
- */
3014
- const arrow$2 = arrow$3;
3015
-
3016
- /**
3017
- * Built-in `limiter` that will stop `shift()` at a certain point.
3018
- */
3019
- const limitShift$1 = limitShift$2;
3020
-
3021
- /**
3022
- * Computes the `x` and `y` coordinates that will place the floating element
3023
- * next to a given reference element.
3024
- */
3025
- const computePosition = (reference, floating, options) => {
3026
- // This caches the expensive `getClippingElementAncestors` function so that
3027
- // multiple lifecycle resets re-use the same result. It only lives for a
3028
- // single call. If other functions become expensive, we can add them as well.
3029
- const cache = new Map();
3030
- const mergedOptions = {
3031
- platform,
3032
- ...options
3033
- };
3034
- const platformWithCache = {
3035
- ...mergedOptions.platform,
3036
- _c: cache
3037
- };
3038
- return computePosition$1(reference, floating, {
3039
- ...mergedOptions,
3040
- platform: platformWithCache
3041
- });
3042
- };
3043
-
3044
- var isClient = typeof document !== 'undefined';
3045
-
3046
- var noop = function noop() {};
3047
- var index = isClient ? useLayoutEffect : noop;
3048
-
3049
- // Fork of `fast-deep-equal` that only does the comparisons we need and compares
3050
- // functions
3051
- function deepEqual(a, b) {
3052
- if (a === b) {
3053
- return true;
3054
- }
3055
- if (typeof a !== typeof b) {
3056
- return false;
3057
- }
3058
- if (typeof a === 'function' && a.toString() === b.toString()) {
3059
- return true;
3060
- }
3061
- let length;
3062
- let i;
3063
- let keys;
3064
- if (a && b && typeof a === 'object') {
3065
- if (Array.isArray(a)) {
3066
- length = a.length;
3067
- if (length !== b.length) return false;
3068
- for (i = length; i-- !== 0;) {
3069
- if (!deepEqual(a[i], b[i])) {
3070
- return false;
366
+ decrement: true,
367
+ disabledIndices
368
+ });
3071
369
  }
370
+ } else if (loop) {
371
+ nextIndex = findNonDisabledListIndex(listRef, {
372
+ startingIndex: prevIndex + (cols - prevIndex % cols),
373
+ decrement: true,
374
+ disabledIndices
375
+ });
3072
376
  }
3073
- return true;
3074
- }
3075
- keys = Object.keys(a);
3076
- length = keys.length;
3077
- if (length !== Object.keys(b).length) {
3078
- return false;
3079
- }
3080
- for (i = length; i-- !== 0;) {
3081
- if (!{}.hasOwnProperty.call(b, keys[i])) {
3082
- return false;
377
+ if (isDifferentGridRow(nextIndex, cols, prevRow)) {
378
+ nextIndex = prevIndex;
3083
379
  }
3084
380
  }
3085
- for (i = length; i-- !== 0;) {
3086
- const key = keys[i];
3087
- if (key === '_owner' && a.$$typeof) {
3088
- continue;
3089
- }
3090
- if (!deepEqual(a[key], b[key])) {
3091
- return false;
381
+ const lastRow = floor(maxIndex / cols) === prevRow;
382
+ if (isIndexOutOfListBounds(listRef, nextIndex)) {
383
+ if (loop && lastRow) {
384
+ nextIndex = event.key === (rtl ? ARROW_RIGHT$1 : ARROW_LEFT$1) ? maxIndex : findNonDisabledListIndex(listRef, {
385
+ startingIndex: prevIndex - prevIndex % cols - 1,
386
+ disabledIndices
387
+ });
388
+ } else {
389
+ nextIndex = prevIndex;
3092
390
  }
3093
391
  }
3094
- return true;
3095
392
  }
3096
- return a !== a && b !== b;
3097
- }
3098
-
3099
- function getDPR(element) {
3100
- if (typeof window === 'undefined') {
3101
- return 1;
3102
- }
3103
- const win = element.ownerDocument.defaultView || window;
3104
- return win.devicePixelRatio || 1;
3105
- }
3106
-
3107
- function roundByDPR(element, value) {
3108
- const dpr = getDPR(element);
3109
- return Math.round(value * dpr) / dpr;
3110
- }
3111
-
3112
- function useLatestRef(value) {
3113
- const ref = React.useRef(value);
3114
- index(() => {
3115
- ref.current = value;
3116
- });
3117
- return ref;
393
+ return nextIndex;
3118
394
  }
3119
395
 
3120
- /**
3121
- * Provides data to position a floating element.
3122
- * @see https://floating-ui.com/docs/useFloating
3123
- */
3124
- function useFloating$1(options) {
3125
- if (options === void 0) {
3126
- options = {};
3127
- }
3128
- const {
3129
- placement = 'bottom',
3130
- strategy = 'absolute',
3131
- middleware = [],
3132
- platform,
3133
- elements: {
3134
- reference: externalReference,
3135
- floating: externalFloating
3136
- } = {},
3137
- transform = true,
3138
- whileElementsMounted,
3139
- open
3140
- } = options;
3141
- const [data, setData] = React.useState({
3142
- x: 0,
3143
- y: 0,
3144
- strategy,
3145
- placement,
3146
- middlewareData: {},
3147
- isPositioned: false
3148
- });
3149
- const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
3150
- if (!deepEqual(latestMiddleware, middleware)) {
3151
- setLatestMiddleware(middleware);
3152
- }
3153
- const [_reference, _setReference] = React.useState(null);
3154
- const [_floating, _setFloating] = React.useState(null);
3155
- const setReference = React.useCallback(node => {
3156
- if (node !== referenceRef.current) {
3157
- referenceRef.current = node;
3158
- _setReference(node);
3159
- }
3160
- }, []);
3161
- const setFloating = React.useCallback(node => {
3162
- if (node !== floatingRef.current) {
3163
- floatingRef.current = node;
3164
- _setFloating(node);
3165
- }
3166
- }, []);
3167
- const referenceEl = externalReference || _reference;
3168
- const floatingEl = externalFloating || _floating;
3169
- const referenceRef = React.useRef(null);
3170
- const floatingRef = React.useRef(null);
3171
- const dataRef = React.useRef(data);
3172
- const hasWhileElementsMounted = whileElementsMounted != null;
3173
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
3174
- const platformRef = useLatestRef(platform);
3175
- const openRef = useLatestRef(open);
3176
- const update = React.useCallback(() => {
3177
- if (!referenceRef.current || !floatingRef.current) {
3178
- return;
3179
- }
3180
- const config = {
3181
- placement,
3182
- strategy,
3183
- middleware: latestMiddleware
3184
- };
3185
- if (platformRef.current) {
3186
- config.platform = platformRef.current;
3187
- }
3188
- computePosition(referenceRef.current, floatingRef.current, config).then(data => {
3189
- const fullData = {
3190
- ...data,
3191
- // The floating element's position may be recomputed while it's closed
3192
- // but still mounted (such as when transitioning out). To ensure
3193
- // `isPositioned` will be `false` initially on the next open, avoid
3194
- // setting it to `true` when `open === false` (must be specified).
3195
- isPositioned: openRef.current !== false
3196
- };
3197
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
3198
- dataRef.current = fullData;
3199
- ReactDOM.flushSync(() => {
3200
- setData(fullData);
3201
- });
3202
- }
3203
- });
3204
- }, [latestMiddleware, placement, strategy, platformRef, openRef]);
3205
- index(() => {
3206
- if (open === false && dataRef.current.isPositioned) {
3207
- dataRef.current.isPositioned = false;
3208
- setData(data => ({
3209
- ...data,
3210
- isPositioned: false
3211
- }));
3212
- }
3213
- }, [open]);
3214
- const isMountedRef = React.useRef(false);
3215
- index(() => {
3216
- isMountedRef.current = true;
3217
- return () => {
3218
- isMountedRef.current = false;
3219
- };
3220
- }, []);
3221
- index(() => {
3222
- if (referenceEl) referenceRef.current = referenceEl;
3223
- if (floatingEl) floatingRef.current = floatingEl;
3224
- if (referenceEl && floatingEl) {
3225
- if (whileElementsMountedRef.current) {
3226
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
396
+ /** For each cell index, gets the item index that occupies that cell */
397
+ function createGridCellMap(sizes, cols, dense) {
398
+ const cellMap = [];
399
+ let startIndex = 0;
400
+ sizes.forEach((_ref2, index) => {
401
+ let {
402
+ width,
403
+ height
404
+ } = _ref2;
405
+ if (width > cols) {
406
+ if (process.env.NODE_ENV !== "production") {
407
+ throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
3227
408
  }
3228
- update();
3229
- }
3230
- }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
3231
- const refs = React.useMemo(() => ({
3232
- reference: referenceRef,
3233
- floating: floatingRef,
3234
- setReference,
3235
- setFloating
3236
- }), [setReference, setFloating]);
3237
- const elements = React.useMemo(() => ({
3238
- reference: referenceEl,
3239
- floating: floatingEl
3240
- }), [referenceEl, floatingEl]);
3241
- const floatingStyles = React.useMemo(() => {
3242
- const initialStyles = {
3243
- position: strategy,
3244
- left: 0,
3245
- top: 0
3246
- };
3247
- if (!elements.floating) {
3248
- return initialStyles;
3249
409
  }
3250
- const x = roundByDPR(elements.floating, data.x);
3251
- const y = roundByDPR(elements.floating, data.y);
3252
- if (transform) {
3253
- return {
3254
- ...initialStyles,
3255
- transform: "translate(" + x + "px, " + y + "px)",
3256
- ...(getDPR(elements.floating) >= 1.5 && {
3257
- willChange: 'transform'
3258
- })
3259
- };
410
+ let itemPlaced = false;
411
+ if (dense) {
412
+ startIndex = 0;
3260
413
  }
3261
- return {
3262
- position: strategy,
3263
- left: x,
3264
- top: y
3265
- };
3266
- }, [strategy, transform, elements.floating, data.x, data.y]);
3267
- return React.useMemo(() => ({
3268
- ...data,
3269
- update,
3270
- refs,
3271
- elements,
3272
- floatingStyles
3273
- }), [data, update, refs, elements, floatingStyles]);
3274
- }
3275
-
3276
- /**
3277
- * Provides data to position an inner element of the floating element so that it
3278
- * appears centered to the reference element.
3279
- * This wraps the core `arrow` middleware to allow React refs as the element.
3280
- * @see https://floating-ui.com/docs/arrow
3281
- */
3282
- const arrow$1 = options => {
3283
- function isRef(value) {
3284
- return {}.hasOwnProperty.call(value, 'current');
3285
- }
3286
- return {
3287
- name: 'arrow',
3288
- options,
3289
- fn(state) {
3290
- const {
3291
- element,
3292
- padding
3293
- } = typeof options === 'function' ? options(state) : options;
3294
- if (element && isRef(element)) {
3295
- if (element.current != null) {
3296
- return arrow$2({
3297
- element: element.current,
3298
- padding
3299
- }).fn(state);
414
+ while (!itemPlaced) {
415
+ const targetCells = [];
416
+ for (let i = 0; i < width; i++) {
417
+ for (let j = 0; j < height; j++) {
418
+ targetCells.push(startIndex + i + j * cols);
3300
419
  }
3301
- return {};
3302
420
  }
3303
- if (element) {
3304
- return arrow$2({
3305
- element,
3306
- padding
3307
- }).fn(state);
421
+ if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
422
+ targetCells.forEach(cell => {
423
+ cellMap[cell] = index;
424
+ });
425
+ itemPlaced = true;
426
+ } else {
427
+ startIndex++;
3308
428
  }
3309
- return {};
3310
429
  }
3311
- };
3312
- };
3313
-
3314
- /**
3315
- * Modifies the placement by translating the floating element along the
3316
- * specified axes.
3317
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
3318
- * object may be passed.
3319
- * @see https://floating-ui.com/docs/offset
3320
- */
3321
- const offset = (options, deps) => ({
3322
- ...offset$1(options),
3323
- options: [options, deps]
3324
- });
3325
-
3326
- /**
3327
- * Optimizes the visibility of the floating element by shifting it in order to
3328
- * keep it in view when it will overflow the clipping boundary.
3329
- * @see https://floating-ui.com/docs/shift
3330
- */
3331
- const shift = (options, deps) => ({
3332
- ...shift$1(options),
3333
- options: [options, deps]
3334
- });
3335
-
3336
- /**
3337
- * Built-in `limiter` that will stop `shift()` at a certain point.
3338
- */
3339
- const limitShift = (options, deps) => ({
3340
- ...limitShift$1(options),
3341
- options: [options, deps]
3342
- });
3343
-
3344
- /**
3345
- * Optimizes the visibility of the floating element by flipping the `placement`
3346
- * in order to keep it in view when the preferred placement(s) will overflow the
3347
- * clipping boundary. Alternative to `autoPlacement`.
3348
- * @see https://floating-ui.com/docs/flip
3349
- */
3350
- const flip = (options, deps) => ({
3351
- ...flip$1(options),
3352
- options: [options, deps]
3353
- });
430
+ });
3354
431
 
3355
- /**
3356
- * Provides data that allows you to change the size of the floating element —
3357
- * for instance, prevent it from overflowing the clipping boundary or match the
3358
- * width of the reference element.
3359
- * @see https://floating-ui.com/docs/size
3360
- */
3361
- const size = (options, deps) => ({
3362
- ...size$1(options),
3363
- options: [options, deps]
3364
- });
432
+ // convert into a non-sparse array
433
+ return [...cellMap];
434
+ }
3365
435
 
3366
- /**
3367
- * Optimizes the visibility of the floating element by choosing the placement
3368
- * that has the most space available automatically, without needing to specify a
3369
- * preferred placement. Alternative to `flip`.
3370
- * @see https://floating-ui.com/docs/autoPlacement
3371
- */
3372
- const autoPlacement = (options, deps) => ({
3373
- ...autoPlacement$1(options),
3374
- options: [options, deps]
3375
- });
436
+ /** Gets cell index of an item's corner or -1 when index is -1. */
437
+ function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
438
+ if (index === -1) return -1;
439
+ const firstCellIndex = cellMap.indexOf(index);
440
+ const sizeItem = sizes[index];
441
+ switch (corner) {
442
+ case 'tl':
443
+ return firstCellIndex;
444
+ case 'tr':
445
+ if (!sizeItem) {
446
+ return firstCellIndex;
447
+ }
448
+ return firstCellIndex + sizeItem.width - 1;
449
+ case 'bl':
450
+ if (!sizeItem) {
451
+ return firstCellIndex;
452
+ }
453
+ return firstCellIndex + (sizeItem.height - 1) * cols;
454
+ case 'br':
455
+ return cellMap.lastIndexOf(index);
456
+ }
457
+ }
3376
458
 
3377
- /**
3378
- * Provides data to hide the floating element in applicable situations, such as
3379
- * when it is not in the same clipping context as the reference element.
3380
- * @see https://floating-ui.com/docs/hide
3381
- */
3382
- const hide = (options, deps) => ({
3383
- ...hide$1(options),
3384
- options: [options, deps]
3385
- });
459
+ /** Gets all cell indices that correspond to the specified indices */
460
+ function getGridCellIndices(indices, cellMap) {
461
+ return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
462
+ }
463
+ function isListIndexDisabled(listRef, index, disabledIndices) {
464
+ if (typeof disabledIndices === 'function') {
465
+ return disabledIndices(index);
466
+ } else if (disabledIndices) {
467
+ return disabledIndices.includes(index);
468
+ }
469
+ const element = listRef.current[index];
470
+ return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
471
+ }
3386
472
 
3387
- /**
3388
- * Provides data to position an inner element of the floating element so that it
3389
- * appears centered to the reference element.
3390
- * This wraps the core `arrow` middleware to allow React refs as the element.
3391
- * @see https://floating-ui.com/docs/arrow
3392
- */
3393
- const arrow = (options, deps) => ({
3394
- ...arrow$1(options),
3395
- options: [options, deps]
473
+ const getTabbableOptions = () => ({
474
+ getShadowRoot: true,
475
+ displayCheck:
476
+ // JSDOM does not support the `tabbable` library. To solve this we can
477
+ // check if `ResizeObserver` is a real function (not polyfilled), which
478
+ // determines if the current environment is JSDOM-like.
479
+ typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
3396
480
  });
481
+ function getTabbableIn(container, dir) {
482
+ const list = tabbable(container, getTabbableOptions());
483
+ const len = list.length;
484
+ if (len === 0) return;
485
+ const active = activeElement(getDocument$1(container));
486
+ const index = list.indexOf(active);
487
+ const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
488
+ return list[nextIndex];
489
+ }
490
+ function getNextTabbable(referenceElement) {
491
+ return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
492
+ }
493
+ function getPreviousTabbable(referenceElement) {
494
+ return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
495
+ }
496
+ function isOutsideEvent(event, container) {
497
+ const containerElement = container || event.currentTarget;
498
+ const relatedTarget = event.relatedTarget;
499
+ return !relatedTarget || !contains(containerElement, relatedTarget);
500
+ }
501
+ function disableFocusInside(container) {
502
+ const tabbableElements = tabbable(container, getTabbableOptions());
503
+ tabbableElements.forEach(element => {
504
+ element.dataset.tabindex = element.getAttribute('tabindex') || '';
505
+ element.setAttribute('tabindex', '-1');
506
+ });
507
+ }
508
+ function enableFocusInside(container) {
509
+ const elements = container.querySelectorAll('[data-tabindex]');
510
+ elements.forEach(element => {
511
+ const tabindex = element.dataset.tabindex;
512
+ delete element.dataset.tabindex;
513
+ if (tabindex) {
514
+ element.setAttribute('tabindex', tabindex);
515
+ } else {
516
+ element.removeAttribute('tabindex');
517
+ }
518
+ });
519
+ }
3397
520
 
3398
521
  const FOCUSABLE_ATTRIBUTE = 'data-floating-ui-focusable';
3399
522
  const ACTIVE_KEY = 'active';
@@ -3415,7 +538,7 @@ const genId = () => // Ensure the id is unique with multiple independent version
3415
538
  "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
3416
539
  function useFloatingId() {
3417
540
  const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : undefined);
3418
- index$1(() => {
541
+ index(() => {
3419
542
  if (id == null) {
3420
543
  setId(genId());
3421
544
  }
@@ -3503,9 +626,9 @@ const FloatingArrow = /*#__PURE__*/React.forwardRef(function FloatingArrow(props
3503
626
  const [isRTL, setIsRTL] = React.useState(false);
3504
627
 
3505
628
  // https://github.com/floating-ui/floating-ui/issues/2932
3506
- index$1(() => {
629
+ index(() => {
3507
630
  if (!floating) return;
3508
- const isRTL = getComputedStyle$1(floating).direction === 'rtl';
631
+ const isRTL = getComputedStyle(floating).direction === 'rtl';
3509
632
  if (isRTL) {
3510
633
  setIsRTL(true);
3511
634
  }
@@ -3626,7 +749,7 @@ function useFloatingNodeId(customParentId) {
3626
749
  const tree = useFloatingTree();
3627
750
  const reactParentId = useFloatingParentNodeId();
3628
751
  const parentId = reactParentId;
3629
- index$1(() => {
752
+ index(() => {
3630
753
  if (!id) return;
3631
754
  const node = {
3632
755
  id,
@@ -3857,7 +980,7 @@ const HIDDEN_STYLES = {
3857
980
  };
3858
981
  const FocusGuard = /*#__PURE__*/React.forwardRef(function FocusGuard(props, ref) {
3859
982
  const [role, setRole] = React.useState();
3860
- index$1(() => {
983
+ index(() => {
3861
984
  if (isSafari()) {
3862
985
  // Unlike other screen readers such as NVDA and JAWS, the virtual cursor
3863
986
  // on VoiceOver does trigger the onFocus event, so we can use the focus
@@ -3899,7 +1022,7 @@ function useFloatingPortalNode(props) {
3899
1022
  const portalContext = usePortalContext();
3900
1023
  const [portalNode, setPortalNode] = React.useState(null);
3901
1024
  const portalNodeRef = React.useRef(null);
3902
- index$1(() => {
1025
+ index(() => {
3903
1026
  return () => {
3904
1027
  portalNode == null || portalNode.remove();
3905
1028
  // Allow the subsequent layout effects to create a new node on updates.
@@ -3910,7 +1033,7 @@ function useFloatingPortalNode(props) {
3910
1033
  });
3911
1034
  };
3912
1035
  }, [portalNode]);
3913
- index$1(() => {
1036
+ index(() => {
3914
1037
  // Wait for the uniqueId to be generated before creating the portal node in
3915
1038
  // React <18 (using `useFloatingId` instead of the native `useId`).
3916
1039
  // https://github.com/floating-ui/floating-ui/issues/2778
@@ -3925,7 +1048,7 @@ function useFloatingPortalNode(props) {
3925
1048
  portalNodeRef.current = subRoot;
3926
1049
  setPortalNode(subRoot);
3927
1050
  }, [id, uniqueId]);
3928
- index$1(() => {
1051
+ index(() => {
3929
1052
  // Wait for the root to exist before creating the portal node. The root must
3930
1053
  // be stored in state, not a ref, for this to work reactively.
3931
1054
  if (root === null) return;
@@ -4175,9 +1298,9 @@ function FloatingFocusManager(props) {
4175
1298
  const inertSupported = supportsInert();
4176
1299
  const guards = inertSupported ? _guards : true;
4177
1300
  const useInert = !guards || inertSupported && outsideElementsInert;
4178
- const orderRef = useLatestRef$1(order);
4179
- const initialFocusRef = useLatestRef$1(initialFocus);
4180
- const returnFocusRef = useLatestRef$1(returnFocus);
1301
+ const orderRef = useLatestRef(order);
1302
+ const initialFocusRef = useLatestRef(initialFocus);
1303
+ const returnFocusRef = useLatestRef(returnFocus);
4181
1304
  const tree = useFloatingTree();
4182
1305
  const portalContext = usePortalContext();
4183
1306
  const startDismissButtonRef = React.useRef(null);
@@ -4360,7 +1483,7 @@ function FloatingFocusManager(props) {
4360
1483
  cleanup();
4361
1484
  };
4362
1485
  }, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards, useInert, tree, getNodeId, getInsideElements]);
4363
- index$1(() => {
1486
+ index(() => {
4364
1487
  if (disabled || !isHTMLElement(floatingFocusElement)) return;
4365
1488
  const doc = getDocument$1(floatingFocusElement);
4366
1489
  const previouslyFocusedElement = activeElement(doc);
@@ -4378,7 +1501,7 @@ function FloatingFocusManager(props) {
4378
1501
  }
4379
1502
  });
4380
1503
  }, [disabled, open, floatingFocusElement, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
4381
- index$1(() => {
1504
+ index(() => {
4382
1505
  if (disabled || !floatingFocusElement) return;
4383
1506
  const doc = getDocument$1(floatingFocusElement);
4384
1507
  const previouslyFocusedElement = activeElement(doc);
@@ -4469,7 +1592,7 @@ function FloatingFocusManager(props) {
4469
1592
 
4470
1593
  // Synchronize the `context` & `modal` value to the FloatingPortal context.
4471
1594
  // It will decide whether or not it needs to render its own guards.
4472
- index$1(() => {
1595
+ index(() => {
4473
1596
  if (disabled) return;
4474
1597
  if (!portalContext) return;
4475
1598
  portalContext.setFocusManagerState({
@@ -4483,7 +1606,7 @@ function FloatingFocusManager(props) {
4483
1606
  portalContext.setFocusManagerState(null);
4484
1607
  };
4485
1608
  }, [disabled, portalContext, modal, open, onOpenChange, closeOnFocusOut, domReference]);
4486
- index$1(() => {
1609
+ index(() => {
4487
1610
  if (disabled) return;
4488
1611
  if (!floatingFocusElement) return;
4489
1612
  handleTabIndex(floatingFocusElement, orderRef);
@@ -4605,7 +1728,7 @@ const FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(p
4605
1728
  lockScroll = false,
4606
1729
  ...rest
4607
1730
  } = props;
4608
- index$1(() => {
1731
+ index(() => {
4609
1732
  if (!lockScroll) return;
4610
1733
  lockCount++;
4611
1734
  if (lockCount === 1) {
@@ -4885,7 +2008,7 @@ function useDismiss(context, props) {
4885
2008
  // Check if the click occurred on the scrollbar
4886
2009
  if (isHTMLElement(target) && floating) {
4887
2010
  const lastTraversableNode = isLastTraversableNode(target);
4888
- const style = getComputedStyle$1(target);
2011
+ const style = getComputedStyle(target);
4889
2012
  const scrollRe = /auto|scroll/;
4890
2013
  const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4891
2014
  const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
@@ -5112,7 +2235,7 @@ function useFloating(options) {
5112
2235
  const domReference = optionDomReference || _domReference;
5113
2236
  const domReferenceRef = React.useRef(null);
5114
2237
  const tree = useFloatingTree();
5115
- index$1(() => {
2238
+ index(() => {
5116
2239
  if (domReference) {
5117
2240
  domReferenceRef.current = domReference;
5118
2241
  }
@@ -5170,7 +2293,7 @@ function useFloating(options) {
5170
2293
  elements,
5171
2294
  nodeId
5172
2295
  }), [position, refs, elements, nodeId, rootContext]);
5173
- index$1(() => {
2296
+ index(() => {
5174
2297
  rootContext.dataRef.current.floatingContext = context;
5175
2298
  const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
5176
2299
  if (node) {
@@ -5353,10 +2476,10 @@ function useListNavigation(context, props) {
5353
2476
  }
5354
2477
  }
5355
2478
  const floatingFocusElement = getFloatingFocusElement(elements.floating);
5356
- const floatingFocusElementRef = useLatestRef$1(floatingFocusElement);
2479
+ const floatingFocusElementRef = useLatestRef(floatingFocusElement);
5357
2480
  const parentId = useFloatingParentNodeId();
5358
2481
  const tree = useFloatingTree();
5359
- index$1(() => {
2482
+ index(() => {
5360
2483
  context.dataRef.current.orientation = orientation;
5361
2484
  }, [context, orientation]);
5362
2485
  const onNavigate = useEffectEvent(() => {
@@ -5372,10 +2495,10 @@ function useListNavigation(context, props) {
5372
2495
  const previousOpenRef = React.useRef(open);
5373
2496
  const forceSyncFocusRef = React.useRef(false);
5374
2497
  const forceScrollIntoViewRef = React.useRef(false);
5375
- const disabledIndicesRef = useLatestRef$1(disabledIndices);
5376
- const latestOpenRef = useLatestRef$1(open);
5377
- const scrollItemIntoViewRef = useLatestRef$1(scrollItemIntoView);
5378
- const selectedIndexRef = useLatestRef$1(selectedIndex);
2498
+ const disabledIndicesRef = useLatestRef(disabledIndices);
2499
+ const latestOpenRef = useLatestRef(open);
2500
+ const scrollItemIntoViewRef = useLatestRef(scrollItemIntoView);
2501
+ const selectedIndexRef = useLatestRef(selectedIndex);
5379
2502
  const [activeId, setActiveId] = React.useState();
5380
2503
  const [virtualId, setVirtualId] = React.useState();
5381
2504
  const focusItem = useEffectEvent(() => {
@@ -5424,7 +2547,7 @@ function useListNavigation(context, props) {
5424
2547
 
5425
2548
  // Sync `selectedIndex` to be the `activeIndex` upon opening the floating
5426
2549
  // element. Also, reset `activeIndex` upon closing the floating element.
5427
- index$1(() => {
2550
+ index(() => {
5428
2551
  if (!enabled) return;
5429
2552
  if (open && elements.floating) {
5430
2553
  if (focusItemOnOpenRef.current && selectedIndex != null) {
@@ -5445,7 +2568,7 @@ function useListNavigation(context, props) {
5445
2568
 
5446
2569
  // Sync `activeIndex` to be the focused item while the floating element is
5447
2570
  // open.
5448
- index$1(() => {
2571
+ index(() => {
5449
2572
  if (!enabled) return;
5450
2573
  if (!open) return;
5451
2574
  if (!elements.floating) return;
@@ -5491,7 +2614,7 @@ function useListNavigation(context, props) {
5491
2614
 
5492
2615
  // Ensure the parent floating element has focus when a nested child closes
5493
2616
  // to allow arrow key navigation to work after the pointer leaves the child.
5494
- index$1(() => {
2617
+ index(() => {
5495
2618
  var _nodes$find;
5496
2619
  if (!enabled || elements.floating || !tree || virtual || !previousMountedRef.current) {
5497
2620
  return;
@@ -5506,7 +2629,7 @@ function useListNavigation(context, props) {
5506
2629
  });
5507
2630
  }
5508
2631
  }, [enabled, elements.floating, tree, parentId, virtual]);
5509
- index$1(() => {
2632
+ index(() => {
5510
2633
  if (!enabled) return;
5511
2634
  if (!tree) return;
5512
2635
  if (!virtual) return;
@@ -5522,12 +2645,12 @@ function useListNavigation(context, props) {
5522
2645
  tree.events.off('virtualfocus', handleVirtualFocus);
5523
2646
  };
5524
2647
  }, [enabled, tree, virtual, parentId, virtualItemRef]);
5525
- index$1(() => {
2648
+ index(() => {
5526
2649
  previousOnNavigateRef.current = onNavigate;
5527
2650
  previousOpenRef.current = open;
5528
2651
  previousMountedRef.current = !!elements.floating;
5529
2652
  });
5530
- index$1(() => {
2653
+ index(() => {
5531
2654
  if (!open) {
5532
2655
  keyRef.current = null;
5533
2656
  focusItemOnOpenRef.current = focusItemOnOpen;
@@ -6005,7 +3128,7 @@ function useTransitionStatus(context, props) {
6005
3128
  if (!isMounted && status === 'close') {
6006
3129
  setStatus('unmounted');
6007
3130
  }
6008
- index$1(() => {
3131
+ index(() => {
6009
3132
  if (!floating) return;
6010
3133
  if (open) {
6011
3134
  setStatus('initial');
@@ -6065,11 +3188,11 @@ function useTransitionStyles(context, props) {
6065
3188
  } = useTransitionStatus(context, {
6066
3189
  duration
6067
3190
  });
6068
- const initialRef = useLatestRef$1(unstable_initial);
6069
- const openRef = useLatestRef$1(unstable_open);
6070
- const closeRef = useLatestRef$1(unstable_close);
6071
- const commonRef = useLatestRef$1(unstable_common);
6072
- index$1(() => {
3191
+ const initialRef = useLatestRef(unstable_initial);
3192
+ const openRef = useLatestRef(unstable_open);
3193
+ const closeRef = useLatestRef(unstable_close);
3194
+ const commonRef = useLatestRef(unstable_common);
3195
+ index(() => {
6073
3196
  const initialStyles = execWithArgsOrReturn(initialRef.current, fnArgs);
6074
3197
  const closeStyles = execWithArgsOrReturn(closeRef.current, fnArgs);
6075
3198
  const commonStyles = execWithArgsOrReturn(commonRef.current, fnArgs);
@@ -6108,4 +3231,4 @@ function useTransitionStyles(context, props) {
6108
3231
  };
6109
3232
  }
6110
3233
 
6111
- export { FloatingPortal as F, arrow as a, autoUpdate as b, useFloatingParentNodeId as c, useFloatingNodeId as d, useDismiss as e, flip as f, useInteractions as g, hide as h, FloatingTree as i, FloatingNode as j, autoPlacement as k, limitShift as l, useRole as m, FloatingFocusManager as n, offset as o, FloatingOverlay as p, size as q, useClick as r, shift as s, useListNavigation as t, useFloating as u, useTransitionStyles as v, FloatingArrow as w };
3234
+ export { FloatingPortal as F, useFloatingParentNodeId as a, useFloatingNodeId as b, useDismiss as c, useInteractions as d, FloatingTree as e, FloatingNode as f, useRole as g, FloatingFocusManager as h, FloatingOverlay as i, useClick as j, useListNavigation as k, useTransitionStyles as l, FloatingArrow as m, useFloating as u };