@jobber/components 9.6.0 → 9.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/ActivityIndicator-cjs.js +1 -0
  2. package/dist/ActivityIndicator-es.js +1 -0
  3. package/dist/Autocomplete/index.cjs +2 -0
  4. package/dist/Autocomplete/index.mjs +2 -0
  5. package/dist/Autocomplete-cjs.js +6 -4
  6. package/dist/Autocomplete-es.js +3 -1
  7. package/dist/Banner-cjs.js +1 -0
  8. package/dist/Banner-es.js +1 -0
  9. package/dist/Card/index.cjs +2 -1
  10. package/dist/Card/index.mjs +2 -1
  11. package/dist/Chip/index.cjs +2 -0
  12. package/dist/Chip/index.mjs +2 -0
  13. package/dist/Chip-cjs.js +1 -0
  14. package/dist/Chip-es.js +1 -0
  15. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -0
  16. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -0
  17. package/dist/Chips/InternalChipDismissible/index.cjs +2 -0
  18. package/dist/Chips/InternalChipDismissible/index.mjs +2 -0
  19. package/dist/Chips/index.cjs +2 -0
  20. package/dist/Chips/index.mjs +2 -0
  21. package/dist/Combobox/index.cjs +4 -2
  22. package/dist/Combobox/index.mjs +4 -2
  23. package/dist/{ComboboxSeparator-cjs.js → ComboboxChipRemove-cjs.js} +455 -501
  24. package/dist/{ComboboxSeparator-es.js → ComboboxChipRemove-es.js} +456 -500
  25. package/dist/ComboboxPrimitive-cjs.js +30 -29
  26. package/dist/ComboboxPrimitive-es.js +3 -2
  27. package/dist/ConfirmationModal/index.cjs +2 -0
  28. package/dist/ConfirmationModal/index.mjs +2 -0
  29. package/dist/ConfirmationModal-cjs.js +1 -0
  30. package/dist/ConfirmationModal-es.js +1 -0
  31. package/dist/DataDump/index.cjs +2 -1
  32. package/dist/DataDump/index.mjs +2 -1
  33. package/dist/DataDump-cjs.js +1 -0
  34. package/dist/DataDump-es.js +1 -0
  35. package/dist/DataList/components/DataListActions/index.cjs +2 -0
  36. package/dist/DataList/components/DataListActions/index.mjs +2 -0
  37. package/dist/DataList/components/DataListBulkActions/index.cjs +2 -0
  38. package/dist/DataList/components/DataListBulkActions/index.mjs +2 -0
  39. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +2 -0
  40. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +2 -0
  41. package/dist/DataList/components/DataListFilters/index.cjs +2 -0
  42. package/dist/DataList/components/DataListFilters/index.mjs +2 -0
  43. package/dist/DataList/components/DataListHeader/index.cjs +2 -0
  44. package/dist/DataList/components/DataListHeader/index.mjs +2 -0
  45. package/dist/DataList/components/DataListItem/index.cjs +2 -0
  46. package/dist/DataList/components/DataListItem/index.mjs +2 -0
  47. package/dist/DataList/components/DataListItemActions/index.cjs +2 -0
  48. package/dist/DataList/components/DataListItemActions/index.mjs +2 -0
  49. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +2 -0
  50. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +2 -0
  51. package/dist/DataList/components/DataListItems/index.cjs +2 -0
  52. package/dist/DataList/components/DataListItems/index.mjs +2 -0
  53. package/dist/DataList/components/DataListLayout/index.cjs +2 -0
  54. package/dist/DataList/components/DataListLayout/index.mjs +2 -0
  55. package/dist/DataList/components/DataListLayoutActions/index.cjs +2 -0
  56. package/dist/DataList/components/DataListLayoutActions/index.mjs +2 -0
  57. package/dist/DataList/index.cjs +2 -0
  58. package/dist/DataList/index.mjs +2 -0
  59. package/dist/DataTable-cjs.js +1 -0
  60. package/dist/DataTable-es.js +1 -0
  61. package/dist/DatePicker/index.cjs +2 -0
  62. package/dist/DatePicker/index.mjs +2 -0
  63. package/dist/DatePicker-cjs.js +8 -7
  64. package/dist/DatePicker-es.js +6 -5
  65. package/dist/Dialog/index.cjs +2 -1
  66. package/dist/Dialog/index.mjs +2 -1
  67. package/dist/DrawerDescription-cjs.js +99 -268
  68. package/dist/DrawerDescription-es.js +103 -270
  69. package/dist/DrawerGrid-cjs.js +1 -0
  70. package/dist/DrawerGrid-es.js +1 -0
  71. package/dist/DrawerTitle-cjs.js +6 -2
  72. package/dist/DrawerTitle-es.js +7 -3
  73. package/dist/FeatureSwitch-cjs.js +1 -0
  74. package/dist/FeatureSwitch-es.js +1 -0
  75. package/dist/FieldDescription-cjs.js +181 -184
  76. package/dist/FieldDescription-es.js +184 -187
  77. package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +2 -0
  78. package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +2 -0
  79. package/dist/FilterPicker/components/FilterPickerContent/index.cjs +2 -0
  80. package/dist/FilterPicker/components/FilterPickerContent/index.mjs +2 -0
  81. package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +2 -0
  82. package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +2 -0
  83. package/dist/FilterPicker/index.cjs +2 -0
  84. package/dist/FilterPicker/index.mjs +2 -0
  85. package/dist/FilterPickerContent-cjs.js +5 -4
  86. package/dist/FilterPickerContent-es.js +2 -1
  87. package/dist/FormFieldWrapper-cjs.js +1 -0
  88. package/dist/FormFieldWrapper-es.js +1 -0
  89. package/dist/FormatFile/index.cjs +2 -0
  90. package/dist/FormatFile/index.mjs +2 -0
  91. package/dist/FormatFile-cjs.js +1 -0
  92. package/dist/FormatFile-es.js +1 -0
  93. package/dist/Gallery/index.cjs +2 -0
  94. package/dist/Gallery/index.mjs +2 -0
  95. package/dist/InputAvatar-cjs.js +1 -0
  96. package/dist/InputAvatar-es.js +1 -0
  97. package/dist/InputDate/index.cjs +2 -0
  98. package/dist/InputDate/index.mjs +2 -0
  99. package/dist/InputDate-cjs.js +1 -0
  100. package/dist/InputDate-es.js +1 -0
  101. package/dist/InputNumber/index.cjs +2 -1
  102. package/dist/InputNumber/index.mjs +2 -1
  103. package/dist/InternalChipDismissible-cjs.js +1 -0
  104. package/dist/InternalChipDismissible-es.js +1 -0
  105. package/dist/LightBox/index.cjs +2 -0
  106. package/dist/LightBox/index.mjs +2 -0
  107. package/dist/LightBox-cjs.js +1 -0
  108. package/dist/LightBox-es.js +1 -0
  109. package/dist/Menu/index.cjs +2 -1
  110. package/dist/Menu/index.mjs +2 -1
  111. package/dist/Menu-cjs.js +6 -4
  112. package/dist/Menu-es.js +3 -1
  113. package/dist/MenuSubmenuTrigger-cjs.js +164 -206
  114. package/dist/MenuSubmenuTrigger-es.js +152 -194
  115. package/dist/Modal/index.cjs +3 -1
  116. package/dist/Modal/index.mjs +4 -2
  117. package/dist/NumberFieldInput-cjs.js +308 -187
  118. package/dist/NumberFieldInput-es.js +308 -187
  119. package/dist/Page/index.cjs +2 -1
  120. package/dist/Page/index.mjs +2 -1
  121. package/dist/Page-cjs.js +1 -0
  122. package/dist/Page-es.js +1 -0
  123. package/dist/Popover/index.cjs +2 -0
  124. package/dist/Popover/index.mjs +2 -0
  125. package/dist/Popover-cjs.js +9 -7
  126. package/dist/Popover-es.js +3 -1
  127. package/dist/ProgressBar-cjs.js +1 -0
  128. package/dist/ProgressBar-es.js +1 -0
  129. package/dist/ScrollAreaViewport-cjs.js +1093 -747
  130. package/dist/ScrollAreaViewport-es.js +1081 -734
  131. package/dist/Select/index.cjs +2 -1
  132. package/dist/Select/index.mjs +2 -1
  133. package/dist/SelectGroupLabel-cjs.js +306 -207
  134. package/dist/SelectGroupLabel-es.js +302 -203
  135. package/dist/SideDrawer-cjs.js +1 -0
  136. package/dist/SideDrawer-es.js +1 -0
  137. package/dist/Spinner-cjs.js +1 -0
  138. package/dist/Spinner-es.js +1 -0
  139. package/dist/Tooltip/index.cjs +2 -0
  140. package/dist/Tooltip/index.mjs +2 -0
  141. package/dist/Tooltip-cjs.js +7 -6
  142. package/dist/Tooltip-es.js +2 -1
  143. package/dist/dialogReturnFocus-cjs.js +1 -1
  144. package/dist/dialogReturnFocus-es.js +2 -2
  145. package/dist/floating-ui.react-cjs.js +192 -2564
  146. package/dist/floating-ui.react-dom-cjs.js +2103 -0
  147. package/dist/floating-ui.react-dom-es.js +2072 -0
  148. package/dist/floating-ui.react-es.js +156 -2519
  149. package/dist/floating-ui.utils-cjs.js +342 -0
  150. package/dist/floating-ui.utils-es.js +300 -0
  151. package/dist/index.cjs +4 -3
  152. package/dist/index.mjs +4 -3
  153. package/dist/primitives/BottomSheet/index.cjs +1 -1
  154. package/dist/primitives/BottomSheet/index.mjs +1 -1
  155. package/dist/primitives/ComboboxPrimitive/index.cjs +4 -2
  156. package/dist/primitives/ComboboxPrimitive/index.mjs +4 -2
  157. package/dist/primitives/SelectPrimitive/index.cjs +2 -0
  158. package/dist/primitives/SelectPrimitive/index.mjs +2 -0
  159. package/dist/primitives/index.cjs +3 -2
  160. package/dist/primitives/index.mjs +3 -2
  161. package/dist/scrollEdges-cjs.js +11 -1
  162. package/dist/scrollEdges-es.js +11 -1
  163. package/dist/sharedHelpers/i18n/index.cjs +1 -0
  164. package/dist/sharedHelpers/i18n/index.d.ts +1 -0
  165. package/dist/sharedHelpers/i18n/index.mjs +1 -1
  166. package/dist/sharedHelpers/i18n/releasedLanguages.d.ts +12 -0
  167. package/dist/sharedHelpers/i18n/useReleasedLocale.d.ts +6 -0
  168. package/dist/showToast-cjs.js +1 -1
  169. package/dist/showToast-es.js +1 -1
  170. package/dist/testUtils/releasedLanguages.d.ts +16 -0
  171. package/dist/unstyledPrimitives/index.cjs +478 -720
  172. package/dist/unstyledPrimitives/index.mjs +421 -663
  173. package/dist/useAtlantisI18n-cjs.js +44 -11
  174. package/dist/useAtlantisI18n-es.js +44 -12
  175. package/dist/useCompositeListItem-cjs.js +361 -2108
  176. package/dist/useCompositeListItem-es.js +331 -2076
  177. package/dist/useLabel-cjs.js +3 -2
  178. package/dist/useLabel-es.js +3 -2
  179. package/dist/useRenderElement-cjs.js +7 -9
  180. package/dist/useRenderElement-es.js +7 -9
  181. package/dist/useScrollLock-cjs.js +344 -819
  182. package/dist/useScrollLock-es.js +296 -732
  183. package/dist/useScrollToActive-cjs.js +5 -4
  184. package/dist/useScrollToActive-es.js +2 -1
  185. package/package.json +3 -3
  186. package/dist/scrollable-cjs.js +0 -58
  187. package/dist/scrollable-es.js +0 -54
@@ -1,306 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { useLayoutEffect } from 'react';
3
+ import { a as isShadowRoot, i as isHTMLElement, f as floor, b as isElement, c as isNode, g as getNodeName, d as isLastTraversableNode, e as getParentNode, h as getComputedStyle$1, j as getOverflowAncestors, k as isWebKit } from './floating-ui.utils-es.js';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
5
  import * as ReactDOM from 'react-dom';
5
-
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
- function isOverflowElement(element) {
51
- const {
52
- overflow,
53
- overflowX,
54
- overflowY,
55
- display
56
- } = getComputedStyle$1(element);
57
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
58
- }
59
- function isTableElement(element) {
60
- return /^(table|td|th)$/.test(getNodeName(element));
61
- }
62
- function isTopLayer(element) {
63
- try {
64
- if (element.matches(':popover-open')) {
65
- return true;
66
- }
67
- } catch (_e) {
68
- // no-op
69
- }
70
- try {
71
- return element.matches(':modal');
72
- } catch (_e) {
73
- return false;
74
- }
75
- }
76
- const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
77
- const containRe = /paint|layout|strict|content/;
78
- const isNotNone = value => !!value && value !== 'none';
79
- let isWebKitValue;
80
- function isContainingBlock(elementOrCss) {
81
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
82
-
83
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
84
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
85
- return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
86
- }
87
- function getContainingBlock(element) {
88
- let currentNode = getParentNode(element);
89
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
90
- if (isContainingBlock(currentNode)) {
91
- return currentNode;
92
- } else if (isTopLayer(currentNode)) {
93
- return null;
94
- }
95
- currentNode = getParentNode(currentNode);
96
- }
97
- return null;
98
- }
99
- function isWebKit() {
100
- if (isWebKitValue == null) {
101
- isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
102
- }
103
- return isWebKitValue;
104
- }
105
- function isLastTraversableNode(node) {
106
- return /^(html|body|#document)$/.test(getNodeName(node));
107
- }
108
- function getComputedStyle$1(element) {
109
- return getWindow(element).getComputedStyle(element);
110
- }
111
- function getNodeScroll(element) {
112
- if (isElement(element)) {
113
- return {
114
- scrollLeft: element.scrollLeft,
115
- scrollTop: element.scrollTop
116
- };
117
- }
118
- return {
119
- scrollLeft: element.scrollX,
120
- scrollTop: element.scrollY
121
- };
122
- }
123
- function getParentNode(node) {
124
- if (getNodeName(node) === 'html') {
125
- return node;
126
- }
127
- const result =
128
- // Step into the shadow DOM of the parent of a slotted node.
129
- node.assignedSlot ||
130
- // DOM Element detected.
131
- node.parentNode ||
132
- // ShadowRoot detected.
133
- isShadowRoot(node) && node.host ||
134
- // Fallback.
135
- getDocumentElement(node);
136
- return isShadowRoot(result) ? result.host : result;
137
- }
138
- function getNearestOverflowAncestor(node) {
139
- const parentNode = getParentNode(node);
140
- if (isLastTraversableNode(parentNode)) {
141
- return node.ownerDocument ? node.ownerDocument.body : node.body;
142
- }
143
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
144
- return parentNode;
145
- }
146
- return getNearestOverflowAncestor(parentNode);
147
- }
148
- function getOverflowAncestors(node, list, traverseIframes) {
149
- var _node$ownerDocument2;
150
- if (list === void 0) {
151
- list = [];
152
- }
153
- if (traverseIframes === void 0) {
154
- traverseIframes = true;
155
- }
156
- const scrollableAncestor = getNearestOverflowAncestor(node);
157
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
158
- const win = getWindow(scrollableAncestor);
159
- if (isBody) {
160
- const frameElement = getFrameElement(win);
161
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
162
- } else {
163
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
164
- }
165
- }
166
- function getFrameElement(win) {
167
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
168
- }
169
-
170
- /**
171
- * Custom positioning reference element.
172
- * @see https://floating-ui.com/docs/virtual-elements
173
- */
174
-
175
- const sides = ['top', 'right', 'bottom', 'left'];
176
- const alignments = ['start', 'end'];
177
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
178
- const min = Math.min;
179
- const max = Math.max;
180
- const round = Math.round;
181
- const floor = Math.floor;
182
- const createCoords = v => ({
183
- x: v,
184
- y: v
185
- });
186
- const oppositeSideMap = {
187
- left: 'right',
188
- right: 'left',
189
- bottom: 'top',
190
- top: 'bottom'
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
- function getSideAxis(placement) {
211
- const firstChar = placement[0];
212
- return firstChar === 't' || firstChar === 'b' ? '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.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
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
- const side = getSide(placement);
267
- return oppositeSideMap[side] + placement.slice(side.length);
268
- }
269
- function expandPaddingObject(padding) {
270
- return {
271
- top: 0,
272
- right: 0,
273
- bottom: 0,
274
- left: 0,
275
- ...padding
276
- };
277
- }
278
- function getPaddingObject(padding) {
279
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
280
- top: padding,
281
- right: padding,
282
- bottom: padding,
283
- left: padding
284
- };
285
- }
286
- function rectToClientRect(rect) {
287
- const {
288
- x,
289
- y,
290
- width,
291
- height
292
- } = rect;
293
- return {
294
- width,
295
- height,
296
- top: y,
297
- left: x,
298
- right: x + width,
299
- bottom: y + height,
300
- x,
301
- y
302
- };
303
- }
6
+ import { u as useFloating$1 } from './floating-ui.react-dom-es.js';
304
7
 
305
8
  /*!
306
9
  * tabbable 6.4.0
@@ -1070,19 +773,19 @@ function isMouseLikePointerType(pointerType, strict) {
1070
773
  return values.includes(pointerType);
1071
774
  }
1072
775
 
1073
- var isClient$1 = typeof document !== 'undefined';
776
+ var isClient = typeof document !== 'undefined';
1074
777
 
1075
- var noop$1 = function noop() {};
1076
- var index$1 = isClient$1 ? useLayoutEffect : noop$1;
778
+ var noop = function noop() {};
779
+ var index = isClient ? useLayoutEffect : noop;
1077
780
 
1078
781
  // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
1079
782
  const SafeReact$1 = {
1080
783
  ...React
1081
784
  };
1082
785
 
1083
- function useLatestRef$1(value) {
786
+ function useLatestRef(value) {
1084
787
  const ref = React.useRef(value);
1085
- index$1(() => {
788
+ index(() => {
1086
789
  ref.current = value;
1087
790
  });
1088
791
  return ref;
@@ -1259,2204 +962,138 @@ function getGridNavigatedIndex(listRef, _ref) {
1259
962
  startingIndex: prevIndex - prevIndex % cols - 1,
1260
963
  disabledIndices
1261
964
  });
1262
- } else {
1263
- nextIndex = prevIndex;
1264
- }
1265
- }
1266
- }
1267
- return nextIndex;
1268
- }
1269
-
1270
- /** For each cell index, gets the item index that occupies that cell */
1271
- function createGridCellMap(sizes, cols, dense) {
1272
- const cellMap = [];
1273
- let startIndex = 0;
1274
- sizes.forEach((_ref2, index) => {
1275
- let {
1276
- width,
1277
- height
1278
- } = _ref2;
1279
- if (width > cols) {
1280
- if (process.env.NODE_ENV !== "production") {
1281
- throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
1282
- }
1283
- }
1284
- let itemPlaced = false;
1285
- if (dense) {
1286
- startIndex = 0;
1287
- }
1288
- while (!itemPlaced) {
1289
- const targetCells = [];
1290
- for (let i = 0; i < width; i++) {
1291
- for (let j = 0; j < height; j++) {
1292
- targetCells.push(startIndex + i + j * cols);
1293
- }
1294
- }
1295
- if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
1296
- targetCells.forEach(cell => {
1297
- cellMap[cell] = index;
1298
- });
1299
- itemPlaced = true;
1300
- } else {
1301
- startIndex++;
1302
- }
1303
- }
1304
- });
1305
-
1306
- // convert into a non-sparse array
1307
- return [...cellMap];
1308
- }
1309
-
1310
- /** Gets cell index of an item's corner or -1 when index is -1. */
1311
- function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
1312
- if (index === -1) return -1;
1313
- const firstCellIndex = cellMap.indexOf(index);
1314
- const sizeItem = sizes[index];
1315
- switch (corner) {
1316
- case 'tl':
1317
- return firstCellIndex;
1318
- case 'tr':
1319
- if (!sizeItem) {
1320
- return firstCellIndex;
1321
- }
1322
- return firstCellIndex + sizeItem.width - 1;
1323
- case 'bl':
1324
- if (!sizeItem) {
1325
- return firstCellIndex;
1326
- }
1327
- return firstCellIndex + (sizeItem.height - 1) * cols;
1328
- case 'br':
1329
- return cellMap.lastIndexOf(index);
1330
- }
1331
- }
1332
-
1333
- /** Gets all cell indices that correspond to the specified indices */
1334
- function getGridCellIndices(indices, cellMap) {
1335
- return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
1336
- }
1337
- function isListIndexDisabled(listRef, index, disabledIndices) {
1338
- if (typeof disabledIndices === 'function') {
1339
- return disabledIndices(index);
1340
- } else if (disabledIndices) {
1341
- return disabledIndices.includes(index);
1342
- }
1343
- const element = listRef.current[index];
1344
- return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
1345
- }
1346
-
1347
- const getTabbableOptions = () => ({
1348
- getShadowRoot: true,
1349
- displayCheck:
1350
- // JSDOM does not support the `tabbable` library. To solve this we can
1351
- // check if `ResizeObserver` is a real function (not polyfilled), which
1352
- // determines if the current environment is JSDOM-like.
1353
- typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
1354
- });
1355
- function getTabbableIn(container, dir) {
1356
- const list = tabbable(container, getTabbableOptions());
1357
- const len = list.length;
1358
- if (len === 0) return;
1359
- const active = activeElement(getDocument$1(container));
1360
- const index = list.indexOf(active);
1361
- const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
1362
- return list[nextIndex];
1363
- }
1364
- function getNextTabbable(referenceElement) {
1365
- return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
1366
- }
1367
- function getPreviousTabbable(referenceElement) {
1368
- return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
1369
- }
1370
- function isOutsideEvent(event, container) {
1371
- const containerElement = container || event.currentTarget;
1372
- const relatedTarget = event.relatedTarget;
1373
- return !relatedTarget || !contains(containerElement, relatedTarget);
1374
- }
1375
- function disableFocusInside(container) {
1376
- const tabbableElements = tabbable(container, getTabbableOptions());
1377
- tabbableElements.forEach(element => {
1378
- element.dataset.tabindex = element.getAttribute('tabindex') || '';
1379
- element.setAttribute('tabindex', '-1');
1380
- });
1381
- }
1382
- function enableFocusInside(container) {
1383
- const elements = container.querySelectorAll('[data-tabindex]');
1384
- elements.forEach(element => {
1385
- const tabindex = element.dataset.tabindex;
1386
- delete element.dataset.tabindex;
1387
- if (tabindex) {
1388
- element.setAttribute('tabindex', tabindex);
1389
- } else {
1390
- element.removeAttribute('tabindex');
1391
- }
1392
- });
1393
- }
1394
-
1395
- function computeCoordsFromPlacement(_ref, placement, rtl) {
1396
- let {
1397
- reference,
1398
- floating
1399
- } = _ref;
1400
- const sideAxis = getSideAxis(placement);
1401
- const alignmentAxis = getAlignmentAxis(placement);
1402
- const alignLength = getAxisLength(alignmentAxis);
1403
- const side = getSide(placement);
1404
- const isVertical = sideAxis === 'y';
1405
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
1406
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
1407
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1408
- let coords;
1409
- switch (side) {
1410
- case 'top':
1411
- coords = {
1412
- x: commonX,
1413
- y: reference.y - floating.height
1414
- };
1415
- break;
1416
- case 'bottom':
1417
- coords = {
1418
- x: commonX,
1419
- y: reference.y + reference.height
1420
- };
1421
- break;
1422
- case 'right':
1423
- coords = {
1424
- x: reference.x + reference.width,
1425
- y: commonY
1426
- };
1427
- break;
1428
- case 'left':
1429
- coords = {
1430
- x: reference.x - floating.width,
1431
- y: commonY
1432
- };
1433
- break;
1434
- default:
1435
- coords = {
1436
- x: reference.x,
1437
- y: reference.y
1438
- };
1439
- }
1440
- switch (getAlignment(placement)) {
1441
- case 'start':
1442
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1443
- break;
1444
- case 'end':
1445
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1446
- break;
1447
- }
1448
- return coords;
1449
- }
1450
-
1451
- /**
1452
- * Resolves with an object of overflow side offsets that determine how much the
1453
- * element is overflowing a given clipping boundary on each side.
1454
- * - positive = overflowing the boundary by that number of pixels
1455
- * - negative = how many pixels left before it will overflow
1456
- * - 0 = lies flush with the boundary
1457
- * @see https://floating-ui.com/docs/detectOverflow
1458
- */
1459
- async function detectOverflow(state, options) {
1460
- var _await$platform$isEle;
1461
- if (options === void 0) {
1462
- options = {};
1463
- }
1464
- const {
1465
- x,
1466
- y,
1467
- platform,
1468
- rects,
1469
- elements,
1470
- strategy
1471
- } = state;
1472
- const {
1473
- boundary = 'clippingAncestors',
1474
- rootBoundary = 'viewport',
1475
- elementContext = 'floating',
1476
- altBoundary = false,
1477
- padding = 0
1478
- } = evaluate(options, state);
1479
- const paddingObject = getPaddingObject(padding);
1480
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1481
- const element = elements[altBoundary ? altContext : elementContext];
1482
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1483
- 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))),
1484
- boundary,
1485
- rootBoundary,
1486
- strategy
1487
- }));
1488
- const rect = elementContext === 'floating' ? {
1489
- x,
1490
- y,
1491
- width: rects.floating.width,
1492
- height: rects.floating.height
1493
- } : rects.reference;
1494
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1495
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1496
- x: 1,
1497
- y: 1
1498
- } : {
1499
- x: 1,
1500
- y: 1
1501
- };
1502
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1503
- elements,
1504
- rect,
1505
- offsetParent,
1506
- strategy
1507
- }) : rect);
1508
- return {
1509
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1510
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1511
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1512
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1513
- };
1514
- }
1515
-
1516
- // Maximum number of resets that can occur before bailing to avoid infinite reset loops.
1517
- const MAX_RESET_COUNT = 50;
1518
-
1519
- /**
1520
- * Computes the `x` and `y` coordinates that will place the floating element
1521
- * next to a given reference element.
1522
- *
1523
- * This export does not have any `platform` interface logic. You will need to
1524
- * write one for the platform you are using Floating UI with.
1525
- */
1526
- const computePosition$1 = async (reference, floating, config) => {
1527
- const {
1528
- placement = 'bottom',
1529
- strategy = 'absolute',
1530
- middleware = [],
1531
- platform
1532
- } = config;
1533
- const platformWithDetectOverflow = platform.detectOverflow ? platform : {
1534
- ...platform,
1535
- detectOverflow
1536
- };
1537
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1538
- let rects = await platform.getElementRects({
1539
- reference,
1540
- floating,
1541
- strategy
1542
- });
1543
- let {
1544
- x,
1545
- y
1546
- } = computeCoordsFromPlacement(rects, placement, rtl);
1547
- let statefulPlacement = placement;
1548
- let resetCount = 0;
1549
- const middlewareData = {};
1550
- for (let i = 0; i < middleware.length; i++) {
1551
- const currentMiddleware = middleware[i];
1552
- if (!currentMiddleware) {
1553
- continue;
1554
- }
1555
- const {
1556
- name,
1557
- fn
1558
- } = currentMiddleware;
1559
- const {
1560
- x: nextX,
1561
- y: nextY,
1562
- data,
1563
- reset
1564
- } = await fn({
1565
- x,
1566
- y,
1567
- initialPlacement: placement,
1568
- placement: statefulPlacement,
1569
- strategy,
1570
- middlewareData,
1571
- rects,
1572
- platform: platformWithDetectOverflow,
1573
- elements: {
1574
- reference,
1575
- floating
1576
- }
1577
- });
1578
- x = nextX != null ? nextX : x;
1579
- y = nextY != null ? nextY : y;
1580
- middlewareData[name] = {
1581
- ...middlewareData[name],
1582
- ...data
1583
- };
1584
- if (reset && resetCount < MAX_RESET_COUNT) {
1585
- resetCount++;
1586
- if (typeof reset === 'object') {
1587
- if (reset.placement) {
1588
- statefulPlacement = reset.placement;
1589
- }
1590
- if (reset.rects) {
1591
- rects = reset.rects === true ? await platform.getElementRects({
1592
- reference,
1593
- floating,
1594
- strategy
1595
- }) : reset.rects;
1596
- }
1597
- ({
1598
- x,
1599
- y
1600
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1601
- }
1602
- i = -1;
1603
- }
1604
- }
1605
- return {
1606
- x,
1607
- y,
1608
- placement: statefulPlacement,
1609
- strategy,
1610
- middlewareData
1611
- };
1612
- };
1613
-
1614
- /**
1615
- * Provides data to position an inner element of the floating element so that it
1616
- * appears centered to the reference element.
1617
- * @see https://floating-ui.com/docs/arrow
1618
- */
1619
- const arrow$3 = options => ({
1620
- name: 'arrow',
1621
- options,
1622
- async fn(state) {
1623
- const {
1624
- x,
1625
- y,
1626
- placement,
1627
- rects,
1628
- platform,
1629
- elements,
1630
- middlewareData
1631
- } = state;
1632
- // Since `element` is required, we don't Partial<> the type.
1633
- const {
1634
- element,
1635
- padding = 0
1636
- } = evaluate(options, state) || {};
1637
- if (element == null) {
1638
- return {};
1639
- }
1640
- const paddingObject = getPaddingObject(padding);
1641
- const coords = {
1642
- x,
1643
- y
1644
- };
1645
- const axis = getAlignmentAxis(placement);
1646
- const length = getAxisLength(axis);
1647
- const arrowDimensions = await platform.getDimensions(element);
1648
- const isYAxis = axis === 'y';
1649
- const minProp = isYAxis ? 'top' : 'left';
1650
- const maxProp = isYAxis ? 'bottom' : 'right';
1651
- const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1652
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1653
- const startDiff = coords[axis] - rects.reference[axis];
1654
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1655
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1656
-
1657
- // DOM platform can return `window` as the `offsetParent`.
1658
- if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1659
- clientSize = elements.floating[clientProp] || rects.floating[length];
1660
- }
1661
- const centerToReference = endDiff / 2 - startDiff / 2;
1662
-
1663
- // If the padding is large enough that it causes the arrow to no longer be
1664
- // centered, modify the padding so that it is centered.
1665
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1666
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1667
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1668
-
1669
- // Make sure the arrow doesn't overflow the floating element if the center
1670
- // point is outside the floating element's bounds.
1671
- const min$1 = minPadding;
1672
- const max = clientSize - arrowDimensions[length] - maxPadding;
1673
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1674
- const offset = clamp(min$1, center, max);
1675
-
1676
- // If the reference is small enough that the arrow's padding causes it to
1677
- // to point to nothing for an aligned placement, adjust the offset of the
1678
- // floating element itself. To ensure `shift()` continues to take action,
1679
- // a single reset is performed when this is true.
1680
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1681
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1682
- return {
1683
- [axis]: coords[axis] + alignmentOffset,
1684
- data: {
1685
- [axis]: offset,
1686
- centerOffset: center - offset - alignmentOffset,
1687
- ...(shouldAddOffset && {
1688
- alignmentOffset
1689
- })
1690
- },
1691
- reset: shouldAddOffset
1692
- };
1693
- }
1694
- });
1695
-
1696
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1697
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1698
- return allowedPlacementsSortedByAlignment.filter(placement => {
1699
- if (alignment) {
1700
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1701
- }
1702
- return true;
1703
- });
1704
- }
1705
- /**
1706
- * Optimizes the visibility of the floating element by choosing the placement
1707
- * that has the most space available automatically, without needing to specify a
1708
- * preferred placement. Alternative to `flip`.
1709
- * @see https://floating-ui.com/docs/autoPlacement
1710
- */
1711
- const autoPlacement$2 = function (options) {
1712
- if (options === void 0) {
1713
- options = {};
1714
- }
1715
- return {
1716
- name: 'autoPlacement',
1717
- options,
1718
- async fn(state) {
1719
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1720
- const {
1721
- rects,
1722
- middlewareData,
1723
- placement,
1724
- platform,
1725
- elements
1726
- } = state;
1727
- const {
1728
- crossAxis = false,
1729
- alignment,
1730
- allowedPlacements = placements,
1731
- autoAlignment = true,
1732
- ...detectOverflowOptions
1733
- } = evaluate(options, state);
1734
- const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1735
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
1736
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1737
- const currentPlacement = placements$1[currentIndex];
1738
- if (currentPlacement == null) {
1739
- return {};
1740
- }
1741
- const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1742
-
1743
- // Make `computeCoords` start from the right place.
1744
- if (placement !== currentPlacement) {
1745
- return {
1746
- reset: {
1747
- placement: placements$1[0]
1748
- }
1749
- };
1750
- }
1751
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1752
- const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1753
- placement: currentPlacement,
1754
- overflows: currentOverflows
1755
- }];
1756
- const nextPlacement = placements$1[currentIndex + 1];
1757
-
1758
- // There are more placements to check.
1759
- if (nextPlacement) {
1760
- return {
1761
- data: {
1762
- index: currentIndex + 1,
1763
- overflows: allOverflows
1764
- },
1765
- reset: {
1766
- placement: nextPlacement
1767
- }
1768
- };
1769
- }
1770
- const placementsSortedByMostSpace = allOverflows.map(d => {
1771
- const alignment = getAlignment(d.placement);
1772
- return [d.placement, alignment && crossAxis ?
1773
- // Check along the mainAxis and main crossAxis side.
1774
- d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1775
- // Check only the mainAxis.
1776
- d.overflows[0], d.overflows];
1777
- }).sort((a, b) => a[1] - b[1]);
1778
- const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1779
- // Aligned placements should not check their opposite crossAxis
1780
- // side.
1781
- getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1782
- const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1783
- if (resetPlacement !== placement) {
1784
- return {
1785
- data: {
1786
- index: currentIndex + 1,
1787
- overflows: allOverflows
1788
- },
1789
- reset: {
1790
- placement: resetPlacement
1791
- }
1792
- };
1793
- }
1794
- return {};
1795
- }
1796
- };
1797
- };
1798
-
1799
- /**
1800
- * Optimizes the visibility of the floating element by flipping the `placement`
1801
- * in order to keep it in view when the preferred placement(s) will overflow the
1802
- * clipping boundary. Alternative to `autoPlacement`.
1803
- * @see https://floating-ui.com/docs/flip
1804
- */
1805
- const flip$2 = function (options) {
1806
- if (options === void 0) {
1807
- options = {};
1808
- }
1809
- return {
1810
- name: 'flip',
1811
- options,
1812
- async fn(state) {
1813
- var _middlewareData$arrow, _middlewareData$flip;
1814
- const {
1815
- placement,
1816
- middlewareData,
1817
- rects,
1818
- initialPlacement,
1819
- platform,
1820
- elements
1821
- } = state;
1822
- const {
1823
- mainAxis: checkMainAxis = true,
1824
- crossAxis: checkCrossAxis = true,
1825
- fallbackPlacements: specifiedFallbackPlacements,
1826
- fallbackStrategy = 'bestFit',
1827
- fallbackAxisSideDirection = 'none',
1828
- flipAlignment = true,
1829
- ...detectOverflowOptions
1830
- } = evaluate(options, state);
1831
-
1832
- // If a reset by the arrow was caused due to an alignment offset being
1833
- // added, we should skip any logic now since `flip()` has already done its
1834
- // work.
1835
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
1836
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1837
- return {};
1838
- }
1839
- const side = getSide(placement);
1840
- const initialSideAxis = getSideAxis(initialPlacement);
1841
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1842
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1843
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1844
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
1845
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1846
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1847
- }
1848
- const placements = [initialPlacement, ...fallbackPlacements];
1849
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
1850
- const overflows = [];
1851
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1852
- if (checkMainAxis) {
1853
- overflows.push(overflow[side]);
1854
- }
1855
- if (checkCrossAxis) {
1856
- const sides = getAlignmentSides(placement, rects, rtl);
1857
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
1858
- }
1859
- overflowsData = [...overflowsData, {
1860
- placement,
1861
- overflows
1862
- }];
1863
-
1864
- // One or more sides is overflowing.
1865
- if (!overflows.every(side => side <= 0)) {
1866
- var _middlewareData$flip2, _overflowsData$filter;
1867
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1868
- const nextPlacement = placements[nextIndex];
1869
- if (nextPlacement) {
1870
- const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
1871
- if (!ignoreCrossAxisOverflow ||
1872
- // We leave the current main axis only if every placement on that axis
1873
- // overflows the main axis.
1874
- overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
1875
- // Try next placement and re-run the lifecycle.
1876
- return {
1877
- data: {
1878
- index: nextIndex,
1879
- overflows: overflowsData
1880
- },
1881
- reset: {
1882
- placement: nextPlacement
1883
- }
1884
- };
1885
- }
1886
- }
1887
-
1888
- // First, find the candidates that fit on the mainAxis side of overflow,
1889
- // then find the placement that fits the best on the main crossAxis side.
1890
- 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;
1891
-
1892
- // Otherwise fallback.
1893
- if (!resetPlacement) {
1894
- switch (fallbackStrategy) {
1895
- case 'bestFit':
1896
- {
1897
- var _overflowsData$filter2;
1898
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
1899
- if (hasFallbackAxisSideDirection) {
1900
- const currentSideAxis = getSideAxis(d.placement);
1901
- return currentSideAxis === initialSideAxis ||
1902
- // Create a bias to the `y` side axis due to horizontal
1903
- // reading directions favoring greater width.
1904
- currentSideAxis === 'y';
1905
- }
1906
- return true;
1907
- }).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];
1908
- if (placement) {
1909
- resetPlacement = placement;
1910
- }
1911
- break;
1912
- }
1913
- case 'initialPlacement':
1914
- resetPlacement = initialPlacement;
1915
- break;
1916
- }
1917
- }
1918
- if (placement !== resetPlacement) {
1919
- return {
1920
- reset: {
1921
- placement: resetPlacement
1922
- }
1923
- };
1924
- }
1925
- }
1926
- return {};
1927
- }
1928
- };
1929
- };
1930
-
1931
- function getSideOffsets(overflow, rect) {
1932
- return {
1933
- top: overflow.top - rect.height,
1934
- right: overflow.right - rect.width,
1935
- bottom: overflow.bottom - rect.height,
1936
- left: overflow.left - rect.width
1937
- };
1938
- }
1939
- function isAnySideFullyClipped(overflow) {
1940
- return sides.some(side => overflow[side] >= 0);
1941
- }
1942
- /**
1943
- * Provides data to hide the floating element in applicable situations, such as
1944
- * when it is not in the same clipping context as the reference element.
1945
- * @see https://floating-ui.com/docs/hide
1946
- */
1947
- const hide$2 = function (options) {
1948
- if (options === void 0) {
1949
- options = {};
1950
- }
1951
- return {
1952
- name: 'hide',
1953
- options,
1954
- async fn(state) {
1955
- const {
1956
- rects,
1957
- platform
1958
- } = state;
1959
- const {
1960
- strategy = 'referenceHidden',
1961
- ...detectOverflowOptions
1962
- } = evaluate(options, state);
1963
- switch (strategy) {
1964
- case 'referenceHidden':
1965
- {
1966
- const overflow = await platform.detectOverflow(state, {
1967
- ...detectOverflowOptions,
1968
- elementContext: 'reference'
1969
- });
1970
- const offsets = getSideOffsets(overflow, rects.reference);
1971
- return {
1972
- data: {
1973
- referenceHiddenOffsets: offsets,
1974
- referenceHidden: isAnySideFullyClipped(offsets)
1975
- }
1976
- };
1977
- }
1978
- case 'escaped':
1979
- {
1980
- const overflow = await platform.detectOverflow(state, {
1981
- ...detectOverflowOptions,
1982
- altBoundary: true
1983
- });
1984
- const offsets = getSideOffsets(overflow, rects.floating);
1985
- return {
1986
- data: {
1987
- escapedOffsets: offsets,
1988
- escaped: isAnySideFullyClipped(offsets)
1989
- }
1990
- };
1991
- }
1992
- default:
1993
- {
1994
- return {};
1995
- }
1996
- }
1997
- }
1998
- };
1999
- };
2000
-
2001
- const originSides = /*#__PURE__*/new Set(['left', 'top']);
2002
-
2003
- // For type backwards-compatibility, the `OffsetOptions` type was also
2004
- // Derivable.
2005
-
2006
- async function convertValueToCoords(state, options) {
2007
- const {
2008
- placement,
2009
- platform,
2010
- elements
2011
- } = state;
2012
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2013
- const side = getSide(placement);
2014
- const alignment = getAlignment(placement);
2015
- const isVertical = getSideAxis(placement) === 'y';
2016
- const mainAxisMulti = originSides.has(side) ? -1 : 1;
2017
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
2018
- const rawValue = evaluate(options, state);
2019
-
2020
- // eslint-disable-next-line prefer-const
2021
- let {
2022
- mainAxis,
2023
- crossAxis,
2024
- alignmentAxis
2025
- } = typeof rawValue === 'number' ? {
2026
- mainAxis: rawValue,
2027
- crossAxis: 0,
2028
- alignmentAxis: null
2029
- } : {
2030
- mainAxis: rawValue.mainAxis || 0,
2031
- crossAxis: rawValue.crossAxis || 0,
2032
- alignmentAxis: rawValue.alignmentAxis
2033
- };
2034
- if (alignment && typeof alignmentAxis === 'number') {
2035
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2036
- }
2037
- return isVertical ? {
2038
- x: crossAxis * crossAxisMulti,
2039
- y: mainAxis * mainAxisMulti
2040
- } : {
2041
- x: mainAxis * mainAxisMulti,
2042
- y: crossAxis * crossAxisMulti
2043
- };
2044
- }
2045
-
2046
- /**
2047
- * Modifies the placement by translating the floating element along the
2048
- * specified axes.
2049
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
2050
- * object may be passed.
2051
- * @see https://floating-ui.com/docs/offset
2052
- */
2053
- const offset$2 = function (options) {
2054
- if (options === void 0) {
2055
- options = 0;
2056
- }
2057
- return {
2058
- name: 'offset',
2059
- options,
2060
- async fn(state) {
2061
- var _middlewareData$offse, _middlewareData$arrow;
2062
- const {
2063
- x,
2064
- y,
2065
- placement,
2066
- middlewareData
2067
- } = state;
2068
- const diffCoords = await convertValueToCoords(state, options);
2069
-
2070
- // If the placement is the same and the arrow caused an alignment offset
2071
- // then we don't need to change the positioning coordinates.
2072
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2073
- return {};
2074
- }
2075
- return {
2076
- x: x + diffCoords.x,
2077
- y: y + diffCoords.y,
2078
- data: {
2079
- ...diffCoords,
2080
- placement
2081
- }
2082
- };
2083
- }
2084
- };
2085
- };
2086
-
2087
- /**
2088
- * Optimizes the visibility of the floating element by shifting it in order to
2089
- * keep it in view when it will overflow the clipping boundary.
2090
- * @see https://floating-ui.com/docs/shift
2091
- */
2092
- const shift$2 = function (options) {
2093
- if (options === void 0) {
2094
- options = {};
2095
- }
2096
- return {
2097
- name: 'shift',
2098
- options,
2099
- async fn(state) {
2100
- const {
2101
- x,
2102
- y,
2103
- placement,
2104
- platform
2105
- } = state;
2106
- const {
2107
- mainAxis: checkMainAxis = true,
2108
- crossAxis: checkCrossAxis = false,
2109
- limiter = {
2110
- fn: _ref => {
2111
- let {
2112
- x,
2113
- y
2114
- } = _ref;
2115
- return {
2116
- x,
2117
- y
2118
- };
2119
- }
2120
- },
2121
- ...detectOverflowOptions
2122
- } = evaluate(options, state);
2123
- const coords = {
2124
- x,
2125
- y
2126
- };
2127
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
2128
- const crossAxis = getSideAxis(getSide(placement));
2129
- const mainAxis = getOppositeAxis(crossAxis);
2130
- let mainAxisCoord = coords[mainAxis];
2131
- let crossAxisCoord = coords[crossAxis];
2132
- if (checkMainAxis) {
2133
- const minSide = mainAxis === 'y' ? 'top' : 'left';
2134
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2135
- const min = mainAxisCoord + overflow[minSide];
2136
- const max = mainAxisCoord - overflow[maxSide];
2137
- mainAxisCoord = clamp(min, mainAxisCoord, max);
2138
- }
2139
- if (checkCrossAxis) {
2140
- const minSide = crossAxis === 'y' ? 'top' : 'left';
2141
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2142
- const min = crossAxisCoord + overflow[minSide];
2143
- const max = crossAxisCoord - overflow[maxSide];
2144
- crossAxisCoord = clamp(min, crossAxisCoord, max);
2145
- }
2146
- const limitedCoords = limiter.fn({
2147
- ...state,
2148
- [mainAxis]: mainAxisCoord,
2149
- [crossAxis]: crossAxisCoord
2150
- });
2151
- return {
2152
- ...limitedCoords,
2153
- data: {
2154
- x: limitedCoords.x - x,
2155
- y: limitedCoords.y - y,
2156
- enabled: {
2157
- [mainAxis]: checkMainAxis,
2158
- [crossAxis]: checkCrossAxis
2159
- }
2160
- }
2161
- };
2162
- }
2163
- };
2164
- };
2165
- /**
2166
- * Built-in `limiter` that will stop `shift()` at a certain point.
2167
- */
2168
- const limitShift$2 = function (options) {
2169
- if (options === void 0) {
2170
- options = {};
2171
- }
2172
- return {
2173
- options,
2174
- fn(state) {
2175
- const {
2176
- x,
2177
- y,
2178
- placement,
2179
- rects,
2180
- middlewareData
2181
- } = state;
2182
- const {
2183
- offset = 0,
2184
- mainAxis: checkMainAxis = true,
2185
- crossAxis: checkCrossAxis = true
2186
- } = evaluate(options, state);
2187
- const coords = {
2188
- x,
2189
- y
2190
- };
2191
- const crossAxis = getSideAxis(placement);
2192
- const mainAxis = getOppositeAxis(crossAxis);
2193
- let mainAxisCoord = coords[mainAxis];
2194
- let crossAxisCoord = coords[crossAxis];
2195
- const rawOffset = evaluate(offset, state);
2196
- const computedOffset = typeof rawOffset === 'number' ? {
2197
- mainAxis: rawOffset,
2198
- crossAxis: 0
2199
- } : {
2200
- mainAxis: 0,
2201
- crossAxis: 0,
2202
- ...rawOffset
2203
- };
2204
- if (checkMainAxis) {
2205
- const len = mainAxis === 'y' ? 'height' : 'width';
2206
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2207
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2208
- if (mainAxisCoord < limitMin) {
2209
- mainAxisCoord = limitMin;
2210
- } else if (mainAxisCoord > limitMax) {
2211
- mainAxisCoord = limitMax;
2212
- }
2213
- }
2214
- if (checkCrossAxis) {
2215
- var _middlewareData$offse, _middlewareData$offse2;
2216
- const len = mainAxis === 'y' ? 'width' : 'height';
2217
- const isOriginSide = originSides.has(getSide(placement));
2218
- 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);
2219
- 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);
2220
- if (crossAxisCoord < limitMin) {
2221
- crossAxisCoord = limitMin;
2222
- } else if (crossAxisCoord > limitMax) {
2223
- crossAxisCoord = limitMax;
2224
- }
2225
- }
2226
- return {
2227
- [mainAxis]: mainAxisCoord,
2228
- [crossAxis]: crossAxisCoord
2229
- };
2230
- }
2231
- };
2232
- };
2233
-
2234
- /**
2235
- * Provides data that allows you to change the size of the floating element —
2236
- * for instance, prevent it from overflowing the clipping boundary or match the
2237
- * width of the reference element.
2238
- * @see https://floating-ui.com/docs/size
2239
- */
2240
- const size$2 = function (options) {
2241
- if (options === void 0) {
2242
- options = {};
2243
- }
2244
- return {
2245
- name: 'size',
2246
- options,
2247
- async fn(state) {
2248
- var _state$middlewareData, _state$middlewareData2;
2249
- const {
2250
- placement,
2251
- rects,
2252
- platform,
2253
- elements
2254
- } = state;
2255
- const {
2256
- apply = () => {},
2257
- ...detectOverflowOptions
2258
- } = evaluate(options, state);
2259
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
2260
- const side = getSide(placement);
2261
- const alignment = getAlignment(placement);
2262
- const isYAxis = getSideAxis(placement) === 'y';
2263
- const {
2264
- width,
2265
- height
2266
- } = rects.floating;
2267
- let heightSide;
2268
- let widthSide;
2269
- if (side === 'top' || side === 'bottom') {
2270
- heightSide = side;
2271
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2272
- } else {
2273
- widthSide = side;
2274
- heightSide = alignment === 'end' ? 'top' : 'bottom';
2275
- }
2276
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
2277
- const maximumClippingWidth = width - overflow.left - overflow.right;
2278
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
2279
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
2280
- const noShift = !state.middlewareData.shift;
2281
- let availableHeight = overflowAvailableHeight;
2282
- let availableWidth = overflowAvailableWidth;
2283
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
2284
- availableWidth = maximumClippingWidth;
2285
- }
2286
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
2287
- availableHeight = maximumClippingHeight;
2288
- }
2289
- if (noShift && !alignment) {
2290
- const xMin = max(overflow.left, 0);
2291
- const xMax = max(overflow.right, 0);
2292
- const yMin = max(overflow.top, 0);
2293
- const yMax = max(overflow.bottom, 0);
2294
- if (isYAxis) {
2295
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2296
- } else {
2297
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2298
- }
2299
- }
2300
- await apply({
2301
- ...state,
2302
- availableWidth,
2303
- availableHeight
2304
- });
2305
- const nextDimensions = await platform.getDimensions(elements.floating);
2306
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
2307
- return {
2308
- reset: {
2309
- rects: true
2310
- }
2311
- };
2312
- }
2313
- return {};
2314
- }
2315
- };
2316
- };
2317
-
2318
- function getCssDimensions(element) {
2319
- const css = getComputedStyle$1(element);
2320
- // In testing environments, the `width` and `height` properties are empty
2321
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2322
- let width = parseFloat(css.width) || 0;
2323
- let height = parseFloat(css.height) || 0;
2324
- const hasOffset = isHTMLElement(element);
2325
- const offsetWidth = hasOffset ? element.offsetWidth : width;
2326
- const offsetHeight = hasOffset ? element.offsetHeight : height;
2327
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2328
- if (shouldFallback) {
2329
- width = offsetWidth;
2330
- height = offsetHeight;
2331
- }
2332
- return {
2333
- width,
2334
- height,
2335
- $: shouldFallback
2336
- };
2337
- }
2338
-
2339
- function unwrapElement(element) {
2340
- return !isElement(element) ? element.contextElement : element;
2341
- }
2342
-
2343
- function getScale(element) {
2344
- const domElement = unwrapElement(element);
2345
- if (!isHTMLElement(domElement)) {
2346
- return createCoords(1);
2347
- }
2348
- const rect = domElement.getBoundingClientRect();
2349
- const {
2350
- width,
2351
- height,
2352
- $
2353
- } = getCssDimensions(domElement);
2354
- let x = ($ ? round(rect.width) : rect.width) / width;
2355
- let y = ($ ? round(rect.height) : rect.height) / height;
2356
-
2357
- // 0, NaN, or Infinity should always fallback to 1.
2358
-
2359
- if (!x || !Number.isFinite(x)) {
2360
- x = 1;
2361
- }
2362
- if (!y || !Number.isFinite(y)) {
2363
- y = 1;
2364
- }
2365
- return {
2366
- x,
2367
- y
2368
- };
2369
- }
2370
-
2371
- const noOffsets = /*#__PURE__*/createCoords(0);
2372
- function getVisualOffsets(element) {
2373
- const win = getWindow(element);
2374
- if (!isWebKit() || !win.visualViewport) {
2375
- return noOffsets;
2376
- }
2377
- return {
2378
- x: win.visualViewport.offsetLeft,
2379
- y: win.visualViewport.offsetTop
2380
- };
2381
- }
2382
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2383
- if (isFixed === void 0) {
2384
- isFixed = false;
2385
- }
2386
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2387
- return false;
2388
- }
2389
- return isFixed;
2390
- }
2391
-
2392
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2393
- if (includeScale === void 0) {
2394
- includeScale = false;
2395
- }
2396
- if (isFixedStrategy === void 0) {
2397
- isFixedStrategy = false;
2398
- }
2399
- const clientRect = element.getBoundingClientRect();
2400
- const domElement = unwrapElement(element);
2401
- let scale = createCoords(1);
2402
- if (includeScale) {
2403
- if (offsetParent) {
2404
- if (isElement(offsetParent)) {
2405
- scale = getScale(offsetParent);
2406
- }
2407
- } else {
2408
- scale = getScale(element);
2409
- }
2410
- }
2411
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2412
- let x = (clientRect.left + visualOffsets.x) / scale.x;
2413
- let y = (clientRect.top + visualOffsets.y) / scale.y;
2414
- let width = clientRect.width / scale.x;
2415
- let height = clientRect.height / scale.y;
2416
- if (domElement) {
2417
- const win = getWindow(domElement);
2418
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2419
- let currentWin = win;
2420
- let currentIFrame = getFrameElement(currentWin);
2421
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2422
- const iframeScale = getScale(currentIFrame);
2423
- const iframeRect = currentIFrame.getBoundingClientRect();
2424
- const css = getComputedStyle$1(currentIFrame);
2425
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2426
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2427
- x *= iframeScale.x;
2428
- y *= iframeScale.y;
2429
- width *= iframeScale.x;
2430
- height *= iframeScale.y;
2431
- x += left;
2432
- y += top;
2433
- currentWin = getWindow(currentIFrame);
2434
- currentIFrame = getFrameElement(currentWin);
2435
- }
2436
- }
2437
- return rectToClientRect({
2438
- width,
2439
- height,
2440
- x,
2441
- y
2442
- });
2443
- }
2444
-
2445
- // If <html> has a CSS width greater than the viewport, then this will be
2446
- // incorrect for RTL.
2447
- function getWindowScrollBarX(element, rect) {
2448
- const leftScroll = getNodeScroll(element).scrollLeft;
2449
- if (!rect) {
2450
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2451
- }
2452
- return rect.left + leftScroll;
2453
- }
2454
-
2455
- function getHTMLOffset(documentElement, scroll) {
2456
- const htmlRect = documentElement.getBoundingClientRect();
2457
- const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
2458
- const y = htmlRect.top + scroll.scrollTop;
2459
- return {
2460
- x,
2461
- y
2462
- };
2463
- }
2464
-
2465
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2466
- let {
2467
- elements,
2468
- rect,
2469
- offsetParent,
2470
- strategy
2471
- } = _ref;
2472
- const isFixed = strategy === 'fixed';
2473
- const documentElement = getDocumentElement(offsetParent);
2474
- const topLayer = elements ? isTopLayer(elements.floating) : false;
2475
- if (offsetParent === documentElement || topLayer && isFixed) {
2476
- return rect;
2477
- }
2478
- let scroll = {
2479
- scrollLeft: 0,
2480
- scrollTop: 0
2481
- };
2482
- let scale = createCoords(1);
2483
- const offsets = createCoords(0);
2484
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2485
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2486
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2487
- scroll = getNodeScroll(offsetParent);
2488
- }
2489
- if (isOffsetParentAnElement) {
2490
- const offsetRect = getBoundingClientRect(offsetParent);
2491
- scale = getScale(offsetParent);
2492
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2493
- offsets.y = offsetRect.y + offsetParent.clientTop;
2494
- }
2495
- }
2496
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2497
- return {
2498
- width: rect.width * scale.x,
2499
- height: rect.height * scale.y,
2500
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2501
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2502
- };
2503
- }
2504
-
2505
- function getClientRects(element) {
2506
- return Array.from(element.getClientRects());
2507
- }
2508
-
2509
- // Gets the entire size of the scrollable document area, even extending outside
2510
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2511
- function getDocumentRect(element) {
2512
- const html = getDocumentElement(element);
2513
- const scroll = getNodeScroll(element);
2514
- const body = element.ownerDocument.body;
2515
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2516
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2517
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2518
- const y = -scroll.scrollTop;
2519
- if (getComputedStyle$1(body).direction === 'rtl') {
2520
- x += max(html.clientWidth, body.clientWidth) - width;
2521
- }
2522
- return {
2523
- width,
2524
- height,
2525
- x,
2526
- y
2527
- };
2528
- }
2529
-
2530
- // Safety check: ensure the scrollbar space is reasonable in case this
2531
- // calculation is affected by unusual styles.
2532
- // Most scrollbars leave 15-18px of space.
2533
- const SCROLLBAR_MAX = 25;
2534
- function getViewportRect(element, strategy) {
2535
- const win = getWindow(element);
2536
- const html = getDocumentElement(element);
2537
- const visualViewport = win.visualViewport;
2538
- let width = html.clientWidth;
2539
- let height = html.clientHeight;
2540
- let x = 0;
2541
- let y = 0;
2542
- if (visualViewport) {
2543
- width = visualViewport.width;
2544
- height = visualViewport.height;
2545
- const visualViewportBased = isWebKit();
2546
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2547
- x = visualViewport.offsetLeft;
2548
- y = visualViewport.offsetTop;
2549
- }
2550
- }
2551
- const windowScrollbarX = getWindowScrollBarX(html);
2552
- // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
2553
- // visual width of the <html> but this is not considered in the size
2554
- // of `html.clientWidth`.
2555
- if (windowScrollbarX <= 0) {
2556
- const doc = html.ownerDocument;
2557
- const body = doc.body;
2558
- const bodyStyles = getComputedStyle(body);
2559
- const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
2560
- const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
2561
- if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
2562
- width -= clippingStableScrollbarWidth;
2563
- }
2564
- } else if (windowScrollbarX <= SCROLLBAR_MAX) {
2565
- // If the <body> scrollbar is on the left, the width needs to be extended
2566
- // by the scrollbar amount so there isn't extra space on the right.
2567
- width += windowScrollbarX;
2568
- }
2569
- return {
2570
- width,
2571
- height,
2572
- x,
2573
- y
2574
- };
2575
- }
2576
-
2577
- // Returns the inner client rect, subtracting scrollbars if present.
2578
- function getInnerBoundingClientRect(element, strategy) {
2579
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2580
- const top = clientRect.top + element.clientTop;
2581
- const left = clientRect.left + element.clientLeft;
2582
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2583
- const width = element.clientWidth * scale.x;
2584
- const height = element.clientHeight * scale.y;
2585
- const x = left * scale.x;
2586
- const y = top * scale.y;
2587
- return {
2588
- width,
2589
- height,
2590
- x,
2591
- y
2592
- };
2593
- }
2594
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2595
- let rect;
2596
- if (clippingAncestor === 'viewport') {
2597
- rect = getViewportRect(element, strategy);
2598
- } else if (clippingAncestor === 'document') {
2599
- rect = getDocumentRect(getDocumentElement(element));
2600
- } else if (isElement(clippingAncestor)) {
2601
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2602
- } else {
2603
- const visualOffsets = getVisualOffsets(element);
2604
- rect = {
2605
- x: clippingAncestor.x - visualOffsets.x,
2606
- y: clippingAncestor.y - visualOffsets.y,
2607
- width: clippingAncestor.width,
2608
- height: clippingAncestor.height
2609
- };
2610
- }
2611
- return rectToClientRect(rect);
2612
- }
2613
- function hasFixedPositionAncestor(element, stopNode) {
2614
- const parentNode = getParentNode(element);
2615
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2616
- return false;
2617
- }
2618
- return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
2619
- }
2620
-
2621
- // A "clipping ancestor" is an `overflow` element with the characteristic of
2622
- // clipping (or hiding) child elements. This returns all clipping ancestors
2623
- // of the given element up the tree.
2624
- function getClippingElementAncestors(element, cache) {
2625
- const cachedResult = cache.get(element);
2626
- if (cachedResult) {
2627
- return cachedResult;
2628
- }
2629
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
2630
- let currentContainingBlockComputedStyle = null;
2631
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2632
- let currentNode = elementIsFixed ? getParentNode(element) : element;
2633
-
2634
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2635
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2636
- const computedStyle = getComputedStyle$1(currentNode);
2637
- const currentNodeIsContaining = isContainingBlock(currentNode);
2638
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
2639
- currentContainingBlockComputedStyle = null;
2640
- }
2641
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2642
- if (shouldDropCurrentNode) {
2643
- // Drop non-containing blocks.
2644
- result = result.filter(ancestor => ancestor !== currentNode);
2645
- } else {
2646
- // Record last containing block for next iteration.
2647
- currentContainingBlockComputedStyle = computedStyle;
2648
- }
2649
- currentNode = getParentNode(currentNode);
2650
- }
2651
- cache.set(element, result);
2652
- return result;
2653
- }
2654
-
2655
- // Gets the maximum area that the element is visible in due to any number of
2656
- // clipping ancestors.
2657
- function getClippingRect(_ref) {
2658
- let {
2659
- element,
2660
- boundary,
2661
- rootBoundary,
2662
- strategy
2663
- } = _ref;
2664
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2665
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2666
- const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
2667
- let top = firstRect.top;
2668
- let right = firstRect.right;
2669
- let bottom = firstRect.bottom;
2670
- let left = firstRect.left;
2671
- for (let i = 1; i < clippingAncestors.length; i++) {
2672
- const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
2673
- top = max(rect.top, top);
2674
- right = min(rect.right, right);
2675
- bottom = min(rect.bottom, bottom);
2676
- left = max(rect.left, left);
2677
- }
2678
- return {
2679
- width: right - left,
2680
- height: bottom - top,
2681
- x: left,
2682
- y: top
2683
- };
2684
- }
2685
-
2686
- function getDimensions(element) {
2687
- const {
2688
- width,
2689
- height
2690
- } = getCssDimensions(element);
2691
- return {
2692
- width,
2693
- height
2694
- };
2695
- }
2696
-
2697
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2698
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2699
- const documentElement = getDocumentElement(offsetParent);
2700
- const isFixed = strategy === 'fixed';
2701
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2702
- let scroll = {
2703
- scrollLeft: 0,
2704
- scrollTop: 0
2705
- };
2706
- const offsets = createCoords(0);
2707
-
2708
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
2709
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
2710
- function setLeftRTLScrollbarOffset() {
2711
- offsets.x = getWindowScrollBarX(documentElement);
2712
- }
2713
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2714
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2715
- scroll = getNodeScroll(offsetParent);
2716
- }
2717
- if (isOffsetParentAnElement) {
2718
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2719
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2720
- offsets.y = offsetRect.y + offsetParent.clientTop;
2721
- } else if (documentElement) {
2722
- setLeftRTLScrollbarOffset();
2723
- }
2724
- }
2725
- if (isFixed && !isOffsetParentAnElement && documentElement) {
2726
- setLeftRTLScrollbarOffset();
2727
- }
2728
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2729
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2730
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2731
- return {
2732
- x,
2733
- y,
2734
- width: rect.width,
2735
- height: rect.height
2736
- };
2737
- }
2738
-
2739
- function isStaticPositioned(element) {
2740
- return getComputedStyle$1(element).position === 'static';
2741
- }
2742
-
2743
- function getTrueOffsetParent(element, polyfill) {
2744
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2745
- return null;
2746
- }
2747
- if (polyfill) {
2748
- return polyfill(element);
2749
- }
2750
- let rawOffsetParent = element.offsetParent;
2751
-
2752
- // Firefox returns the <html> element as the offsetParent if it's non-static,
2753
- // while Chrome and Safari return the <body> element. The <body> element must
2754
- // be used to perform the correct calculations even if the <html> element is
2755
- // non-static.
2756
- if (getDocumentElement(element) === rawOffsetParent) {
2757
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
2758
- }
2759
- return rawOffsetParent;
2760
- }
2761
-
2762
- // Gets the closest ancestor positioned element. Handles some edge cases,
2763
- // such as table ancestors and cross browser bugs.
2764
- function getOffsetParent(element, polyfill) {
2765
- const win = getWindow(element);
2766
- if (isTopLayer(element)) {
2767
- return win;
2768
- }
2769
- if (!isHTMLElement(element)) {
2770
- let svgOffsetParent = getParentNode(element);
2771
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2772
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2773
- return svgOffsetParent;
2774
- }
2775
- svgOffsetParent = getParentNode(svgOffsetParent);
2776
- }
2777
- return win;
2778
- }
2779
- let offsetParent = getTrueOffsetParent(element, polyfill);
2780
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2781
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2782
- }
2783
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2784
- return win;
2785
- }
2786
- return offsetParent || getContainingBlock(element) || win;
2787
- }
2788
-
2789
- const getElementRects = async function (data) {
2790
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2791
- const getDimensionsFn = this.getDimensions;
2792
- const floatingDimensions = await getDimensionsFn(data.floating);
2793
- return {
2794
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2795
- floating: {
2796
- x: 0,
2797
- y: 0,
2798
- width: floatingDimensions.width,
2799
- height: floatingDimensions.height
2800
- }
2801
- };
2802
- };
2803
-
2804
- function isRTL(element) {
2805
- return getComputedStyle$1(element).direction === 'rtl';
2806
- }
2807
-
2808
- const platform = {
2809
- convertOffsetParentRelativeRectToViewportRelativeRect,
2810
- getDocumentElement,
2811
- getClippingRect,
2812
- getOffsetParent,
2813
- getElementRects,
2814
- getClientRects,
2815
- getDimensions,
2816
- getScale,
2817
- isElement,
2818
- isRTL
2819
- };
2820
-
2821
- function rectsAreEqual(a, b) {
2822
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
2823
- }
2824
-
2825
- // https://samthor.au/2021/observing-dom/
2826
- function observeMove(element, onMove) {
2827
- let io = null;
2828
- let timeoutId;
2829
- const root = getDocumentElement(element);
2830
- function cleanup() {
2831
- var _io;
2832
- clearTimeout(timeoutId);
2833
- (_io = io) == null || _io.disconnect();
2834
- io = null;
2835
- }
2836
- function refresh(skip, threshold) {
2837
- if (skip === void 0) {
2838
- skip = false;
2839
- }
2840
- if (threshold === void 0) {
2841
- threshold = 1;
2842
- }
2843
- cleanup();
2844
- const elementRectForRootMargin = element.getBoundingClientRect();
2845
- const {
2846
- left,
2847
- top,
2848
- width,
2849
- height
2850
- } = elementRectForRootMargin;
2851
- if (!skip) {
2852
- onMove();
2853
- }
2854
- if (!width || !height) {
2855
- return;
2856
- }
2857
- const insetTop = floor(top);
2858
- const insetRight = floor(root.clientWidth - (left + width));
2859
- const insetBottom = floor(root.clientHeight - (top + height));
2860
- const insetLeft = floor(left);
2861
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2862
- const options = {
2863
- rootMargin,
2864
- threshold: max(0, min(1, threshold)) || 1
2865
- };
2866
- let isFirstUpdate = true;
2867
- function handleObserve(entries) {
2868
- const ratio = entries[0].intersectionRatio;
2869
- if (ratio !== threshold) {
2870
- if (!isFirstUpdate) {
2871
- return refresh();
2872
- }
2873
- if (!ratio) {
2874
- // If the reference is clipped, the ratio is 0. Throttle the refresh
2875
- // to prevent an infinite loop of updates.
2876
- timeoutId = setTimeout(() => {
2877
- refresh(false, 1e-7);
2878
- }, 1000);
2879
- } else {
2880
- refresh(false, ratio);
2881
- }
2882
- }
2883
- if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
2884
- // It's possible that even though the ratio is reported as 1, the
2885
- // element is not actually fully within the IntersectionObserver's root
2886
- // area anymore. This can happen under performance constraints. This may
2887
- // be a bug in the browser's IntersectionObserver implementation. To
2888
- // work around this, we compare the element's bounding rect now with
2889
- // what it was at the time we created the IntersectionObserver. If they
2890
- // are not equal then the element moved, so we refresh.
2891
- refresh();
2892
- }
2893
- isFirstUpdate = false;
2894
- }
2895
-
2896
- // Older browsers don't support a `document` as the root and will throw an
2897
- // error.
2898
- try {
2899
- io = new IntersectionObserver(handleObserve, {
2900
- ...options,
2901
- // Handle <iframe>s
2902
- root: root.ownerDocument
2903
- });
2904
- } catch (_e) {
2905
- io = new IntersectionObserver(handleObserve, options);
2906
- }
2907
- io.observe(element);
2908
- }
2909
- refresh(true);
2910
- return cleanup;
2911
- }
2912
-
2913
- /**
2914
- * Automatically updates the position of the floating element when necessary.
2915
- * Should only be called when the floating element is mounted on the DOM or
2916
- * visible on the screen.
2917
- * @returns cleanup function that should be invoked when the floating element is
2918
- * removed from the DOM or hidden from the screen.
2919
- * @see https://floating-ui.com/docs/autoUpdate
2920
- */
2921
- function autoUpdate(reference, floating, update, options) {
2922
- if (options === void 0) {
2923
- options = {};
2924
- }
2925
- const {
2926
- ancestorScroll = true,
2927
- ancestorResize = true,
2928
- elementResize = typeof ResizeObserver === 'function',
2929
- layoutShift = typeof IntersectionObserver === 'function',
2930
- animationFrame = false
2931
- } = options;
2932
- const referenceEl = unwrapElement(reference);
2933
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
2934
- ancestors.forEach(ancestor => {
2935
- ancestorScroll && ancestor.addEventListener('scroll', update, {
2936
- passive: true
2937
- });
2938
- ancestorResize && ancestor.addEventListener('resize', update);
2939
- });
2940
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2941
- let reobserveFrame = -1;
2942
- let resizeObserver = null;
2943
- if (elementResize) {
2944
- resizeObserver = new ResizeObserver(_ref => {
2945
- let [firstEntry] = _ref;
2946
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
2947
- // Prevent update loops when using the `size` middleware.
2948
- // https://github.com/floating-ui/floating-ui/issues/1740
2949
- resizeObserver.unobserve(floating);
2950
- cancelAnimationFrame(reobserveFrame);
2951
- reobserveFrame = requestAnimationFrame(() => {
2952
- var _resizeObserver;
2953
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2954
- });
2955
- }
2956
- update();
2957
- });
2958
- if (referenceEl && !animationFrame) {
2959
- resizeObserver.observe(referenceEl);
2960
- }
2961
- if (floating) {
2962
- resizeObserver.observe(floating);
2963
- }
2964
- }
2965
- let frameId;
2966
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2967
- if (animationFrame) {
2968
- frameLoop();
2969
- }
2970
- function frameLoop() {
2971
- const nextRefRect = getBoundingClientRect(reference);
2972
- if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2973
- update();
2974
- }
2975
- prevRefRect = nextRefRect;
2976
- frameId = requestAnimationFrame(frameLoop);
2977
- }
2978
- update();
2979
- return () => {
2980
- var _resizeObserver2;
2981
- ancestors.forEach(ancestor => {
2982
- ancestorScroll && ancestor.removeEventListener('scroll', update);
2983
- ancestorResize && ancestor.removeEventListener('resize', update);
2984
- });
2985
- cleanupIo == null || cleanupIo();
2986
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2987
- resizeObserver = null;
2988
- if (animationFrame) {
2989
- cancelAnimationFrame(frameId);
2990
- }
2991
- };
2992
- }
2993
-
2994
- /**
2995
- * Modifies the placement by translating the floating element along the
2996
- * specified axes.
2997
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
2998
- * object may be passed.
2999
- * @see https://floating-ui.com/docs/offset
3000
- */
3001
- const offset$1 = offset$2;
3002
-
3003
- /**
3004
- * Optimizes the visibility of the floating element by choosing the placement
3005
- * that has the most space available automatically, without needing to specify a
3006
- * preferred placement. Alternative to `flip`.
3007
- * @see https://floating-ui.com/docs/autoPlacement
3008
- */
3009
- const autoPlacement$1 = autoPlacement$2;
3010
-
3011
- /**
3012
- * Optimizes the visibility of the floating element by shifting it in order to
3013
- * keep it in view when it will overflow the clipping boundary.
3014
- * @see https://floating-ui.com/docs/shift
3015
- */
3016
- const shift$1 = shift$2;
3017
-
3018
- /**
3019
- * Optimizes the visibility of the floating element by flipping the `placement`
3020
- * in order to keep it in view when the preferred placement(s) will overflow the
3021
- * clipping boundary. Alternative to `autoPlacement`.
3022
- * @see https://floating-ui.com/docs/flip
3023
- */
3024
- const flip$1 = flip$2;
3025
-
3026
- /**
3027
- * Provides data that allows you to change the size of the floating element —
3028
- * for instance, prevent it from overflowing the clipping boundary or match the
3029
- * width of the reference element.
3030
- * @see https://floating-ui.com/docs/size
3031
- */
3032
- const size$1 = size$2;
3033
-
3034
- /**
3035
- * Provides data to hide the floating element in applicable situations, such as
3036
- * when it is not in the same clipping context as the reference element.
3037
- * @see https://floating-ui.com/docs/hide
3038
- */
3039
- const hide$1 = hide$2;
3040
-
3041
- /**
3042
- * Provides data to position an inner element of the floating element so that it
3043
- * appears centered to the reference element.
3044
- * @see https://floating-ui.com/docs/arrow
3045
- */
3046
- const arrow$2 = arrow$3;
3047
-
3048
- /**
3049
- * Built-in `limiter` that will stop `shift()` at a certain point.
3050
- */
3051
- const limitShift$1 = limitShift$2;
3052
-
3053
- /**
3054
- * Computes the `x` and `y` coordinates that will place the floating element
3055
- * next to a given reference element.
3056
- */
3057
- const computePosition = (reference, floating, options) => {
3058
- // This caches the expensive `getClippingElementAncestors` function so that
3059
- // multiple lifecycle resets re-use the same result. It only lives for a
3060
- // single call. If other functions become expensive, we can add them as well.
3061
- const cache = new Map();
3062
- const mergedOptions = {
3063
- platform,
3064
- ...options
3065
- };
3066
- const platformWithCache = {
3067
- ...mergedOptions.platform,
3068
- _c: cache
3069
- };
3070
- return computePosition$1(reference, floating, {
3071
- ...mergedOptions,
3072
- platform: platformWithCache
3073
- });
3074
- };
3075
-
3076
- var isClient = typeof document !== 'undefined';
3077
-
3078
- var noop = function noop() {};
3079
- var index = isClient ? useLayoutEffect : noop;
3080
-
3081
- // Fork of `fast-deep-equal` that only does the comparisons we need and compares
3082
- // functions
3083
- function deepEqual(a, b) {
3084
- if (a === b) {
3085
- return true;
3086
- }
3087
- if (typeof a !== typeof b) {
3088
- return false;
3089
- }
3090
- if (typeof a === 'function' && a.toString() === b.toString()) {
3091
- return true;
965
+ } else {
966
+ nextIndex = prevIndex;
967
+ }
968
+ }
3092
969
  }
3093
- let length;
3094
- let i;
3095
- let keys;
3096
- if (a && b && typeof a === 'object') {
3097
- if (Array.isArray(a)) {
3098
- length = a.length;
3099
- if (length !== b.length) return false;
3100
- for (i = length; i-- !== 0;) {
3101
- if (!deepEqual(a[i], b[i])) {
3102
- return false;
3103
- }
970
+ return nextIndex;
971
+ }
972
+
973
+ /** For each cell index, gets the item index that occupies that cell */
974
+ function createGridCellMap(sizes, cols, dense) {
975
+ const cellMap = [];
976
+ let startIndex = 0;
977
+ sizes.forEach((_ref2, index) => {
978
+ let {
979
+ width,
980
+ height
981
+ } = _ref2;
982
+ if (width > cols) {
983
+ if (process.env.NODE_ENV !== "production") {
984
+ throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
3104
985
  }
3105
- return true;
3106
986
  }
3107
- keys = Object.keys(a);
3108
- length = keys.length;
3109
- if (length !== Object.keys(b).length) {
3110
- return false;
987
+ let itemPlaced = false;
988
+ if (dense) {
989
+ startIndex = 0;
3111
990
  }
3112
- for (i = length; i-- !== 0;) {
3113
- if (!{}.hasOwnProperty.call(b, keys[i])) {
3114
- return false;
991
+ while (!itemPlaced) {
992
+ const targetCells = [];
993
+ for (let i = 0; i < width; i++) {
994
+ for (let j = 0; j < height; j++) {
995
+ targetCells.push(startIndex + i + j * cols);
996
+ }
997
+ }
998
+ if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
999
+ targetCells.forEach(cell => {
1000
+ cellMap[cell] = index;
1001
+ });
1002
+ itemPlaced = true;
1003
+ } else {
1004
+ startIndex++;
3115
1005
  }
3116
1006
  }
3117
- for (i = length; i-- !== 0;) {
3118
- const key = keys[i];
3119
- if (key === '_owner' && a.$$typeof) {
3120
- continue;
1007
+ });
1008
+
1009
+ // convert into a non-sparse array
1010
+ return [...cellMap];
1011
+ }
1012
+
1013
+ /** Gets cell index of an item's corner or -1 when index is -1. */
1014
+ function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
1015
+ if (index === -1) return -1;
1016
+ const firstCellIndex = cellMap.indexOf(index);
1017
+ const sizeItem = sizes[index];
1018
+ switch (corner) {
1019
+ case 'tl':
1020
+ return firstCellIndex;
1021
+ case 'tr':
1022
+ if (!sizeItem) {
1023
+ return firstCellIndex;
3121
1024
  }
3122
- if (!deepEqual(a[key], b[key])) {
3123
- return false;
1025
+ return firstCellIndex + sizeItem.width - 1;
1026
+ case 'bl':
1027
+ if (!sizeItem) {
1028
+ return firstCellIndex;
3124
1029
  }
3125
- }
3126
- return true;
1030
+ return firstCellIndex + (sizeItem.height - 1) * cols;
1031
+ case 'br':
1032
+ return cellMap.lastIndexOf(index);
3127
1033
  }
3128
- return a !== a && b !== b;
3129
1034
  }
3130
1035
 
3131
- function getDPR(element) {
3132
- if (typeof window === 'undefined') {
3133
- return 1;
1036
+ /** Gets all cell indices that correspond to the specified indices */
1037
+ function getGridCellIndices(indices, cellMap) {
1038
+ return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
1039
+ }
1040
+ function isListIndexDisabled(listRef, index, disabledIndices) {
1041
+ if (typeof disabledIndices === 'function') {
1042
+ return disabledIndices(index);
1043
+ } else if (disabledIndices) {
1044
+ return disabledIndices.includes(index);
3134
1045
  }
3135
- const win = element.ownerDocument.defaultView || window;
3136
- return win.devicePixelRatio || 1;
1046
+ const element = listRef.current[index];
1047
+ return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
3137
1048
  }
3138
1049
 
3139
- function roundByDPR(element, value) {
3140
- const dpr = getDPR(element);
3141
- return Math.round(value * dpr) / dpr;
1050
+ const getTabbableOptions = () => ({
1051
+ getShadowRoot: true,
1052
+ displayCheck:
1053
+ // JSDOM does not support the `tabbable` library. To solve this we can
1054
+ // check if `ResizeObserver` is a real function (not polyfilled), which
1055
+ // determines if the current environment is JSDOM-like.
1056
+ typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
1057
+ });
1058
+ function getTabbableIn(container, dir) {
1059
+ const list = tabbable(container, getTabbableOptions());
1060
+ const len = list.length;
1061
+ if (len === 0) return;
1062
+ const active = activeElement(getDocument$1(container));
1063
+ const index = list.indexOf(active);
1064
+ const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
1065
+ return list[nextIndex];
3142
1066
  }
3143
-
3144
- function useLatestRef(value) {
3145
- const ref = React.useRef(value);
3146
- index(() => {
3147
- ref.current = value;
3148
- });
3149
- return ref;
1067
+ function getNextTabbable(referenceElement) {
1068
+ return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
3150
1069
  }
3151
-
3152
- /**
3153
- * Provides data to position a floating element.
3154
- * @see https://floating-ui.com/docs/useFloating
3155
- */
3156
- function useFloating$1(options) {
3157
- if (options === void 0) {
3158
- options = {};
3159
- }
3160
- const {
3161
- placement = 'bottom',
3162
- strategy = 'absolute',
3163
- middleware = [],
3164
- platform,
3165
- elements: {
3166
- reference: externalReference,
3167
- floating: externalFloating
3168
- } = {},
3169
- transform = true,
3170
- whileElementsMounted,
3171
- open
3172
- } = options;
3173
- const [data, setData] = React.useState({
3174
- x: 0,
3175
- y: 0,
3176
- strategy,
3177
- placement,
3178
- middlewareData: {},
3179
- isPositioned: false
1070
+ function getPreviousTabbable(referenceElement) {
1071
+ return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
1072
+ }
1073
+ function isOutsideEvent(event, container) {
1074
+ const containerElement = container || event.currentTarget;
1075
+ const relatedTarget = event.relatedTarget;
1076
+ return !relatedTarget || !contains(containerElement, relatedTarget);
1077
+ }
1078
+ function disableFocusInside(container) {
1079
+ const tabbableElements = tabbable(container, getTabbableOptions());
1080
+ tabbableElements.forEach(element => {
1081
+ element.dataset.tabindex = element.getAttribute('tabindex') || '';
1082
+ element.setAttribute('tabindex', '-1');
3180
1083
  });
3181
- const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
3182
- if (!deepEqual(latestMiddleware, middleware)) {
3183
- setLatestMiddleware(middleware);
3184
- }
3185
- const [_reference, _setReference] = React.useState(null);
3186
- const [_floating, _setFloating] = React.useState(null);
3187
- const setReference = React.useCallback(node => {
3188
- if (node !== referenceRef.current) {
3189
- referenceRef.current = node;
3190
- _setReference(node);
3191
- }
3192
- }, []);
3193
- const setFloating = React.useCallback(node => {
3194
- if (node !== floatingRef.current) {
3195
- floatingRef.current = node;
3196
- _setFloating(node);
3197
- }
3198
- }, []);
3199
- const referenceEl = externalReference || _reference;
3200
- const floatingEl = externalFloating || _floating;
3201
- const referenceRef = React.useRef(null);
3202
- const floatingRef = React.useRef(null);
3203
- const dataRef = React.useRef(data);
3204
- const hasWhileElementsMounted = whileElementsMounted != null;
3205
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
3206
- const platformRef = useLatestRef(platform);
3207
- const openRef = useLatestRef(open);
3208
- const update = React.useCallback(() => {
3209
- if (!referenceRef.current || !floatingRef.current) {
3210
- return;
3211
- }
3212
- const config = {
3213
- placement,
3214
- strategy,
3215
- middleware: latestMiddleware
3216
- };
3217
- if (platformRef.current) {
3218
- config.platform = platformRef.current;
3219
- }
3220
- computePosition(referenceRef.current, floatingRef.current, config).then(data => {
3221
- const fullData = {
3222
- ...data,
3223
- // The floating element's position may be recomputed while it's closed
3224
- // but still mounted (such as when transitioning out). To ensure
3225
- // `isPositioned` will be `false` initially on the next open, avoid
3226
- // setting it to `true` when `open === false` (must be specified).
3227
- isPositioned: openRef.current !== false
3228
- };
3229
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
3230
- dataRef.current = fullData;
3231
- ReactDOM.flushSync(() => {
3232
- setData(fullData);
3233
- });
3234
- }
3235
- });
3236
- }, [latestMiddleware, placement, strategy, platformRef, openRef]);
3237
- index(() => {
3238
- if (open === false && dataRef.current.isPositioned) {
3239
- dataRef.current.isPositioned = false;
3240
- setData(data => ({
3241
- ...data,
3242
- isPositioned: false
3243
- }));
3244
- }
3245
- }, [open]);
3246
- const isMountedRef = React.useRef(false);
3247
- index(() => {
3248
- isMountedRef.current = true;
3249
- return () => {
3250
- isMountedRef.current = false;
3251
- };
3252
- }, []);
3253
- index(() => {
3254
- if (referenceEl) referenceRef.current = referenceEl;
3255
- if (floatingEl) floatingRef.current = floatingEl;
3256
- if (referenceEl && floatingEl) {
3257
- if (whileElementsMountedRef.current) {
3258
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
3259
- }
3260
- update();
3261
- }
3262
- }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
3263
- const refs = React.useMemo(() => ({
3264
- reference: referenceRef,
3265
- floating: floatingRef,
3266
- setReference,
3267
- setFloating
3268
- }), [setReference, setFloating]);
3269
- const elements = React.useMemo(() => ({
3270
- reference: referenceEl,
3271
- floating: floatingEl
3272
- }), [referenceEl, floatingEl]);
3273
- const floatingStyles = React.useMemo(() => {
3274
- const initialStyles = {
3275
- position: strategy,
3276
- left: 0,
3277
- top: 0
3278
- };
3279
- if (!elements.floating) {
3280
- return initialStyles;
3281
- }
3282
- const x = roundByDPR(elements.floating, data.x);
3283
- const y = roundByDPR(elements.floating, data.y);
3284
- if (transform) {
3285
- return {
3286
- ...initialStyles,
3287
- transform: "translate(" + x + "px, " + y + "px)",
3288
- ...(getDPR(elements.floating) >= 1.5 && {
3289
- willChange: 'transform'
3290
- })
3291
- };
3292
- }
3293
- return {
3294
- position: strategy,
3295
- left: x,
3296
- top: y
3297
- };
3298
- }, [strategy, transform, elements.floating, data.x, data.y]);
3299
- return React.useMemo(() => ({
3300
- ...data,
3301
- update,
3302
- refs,
3303
- elements,
3304
- floatingStyles
3305
- }), [data, update, refs, elements, floatingStyles]);
3306
1084
  }
3307
-
3308
- /**
3309
- * Provides data to position an inner element of the floating element so that it
3310
- * appears centered to the reference element.
3311
- * This wraps the core `arrow` middleware to allow React refs as the element.
3312
- * @see https://floating-ui.com/docs/arrow
3313
- */
3314
- const arrow$1 = options => {
3315
- function isRef(value) {
3316
- return {}.hasOwnProperty.call(value, 'current');
3317
- }
3318
- return {
3319
- name: 'arrow',
3320
- options,
3321
- fn(state) {
3322
- const {
3323
- element,
3324
- padding
3325
- } = typeof options === 'function' ? options(state) : options;
3326
- if (element && isRef(element)) {
3327
- if (element.current != null) {
3328
- return arrow$2({
3329
- element: element.current,
3330
- padding
3331
- }).fn(state);
3332
- }
3333
- return {};
3334
- }
3335
- if (element) {
3336
- return arrow$2({
3337
- element,
3338
- padding
3339
- }).fn(state);
3340
- }
3341
- return {};
1085
+ function enableFocusInside(container) {
1086
+ const elements = container.querySelectorAll('[data-tabindex]');
1087
+ elements.forEach(element => {
1088
+ const tabindex = element.dataset.tabindex;
1089
+ delete element.dataset.tabindex;
1090
+ if (tabindex) {
1091
+ element.setAttribute('tabindex', tabindex);
1092
+ } else {
1093
+ element.removeAttribute('tabindex');
3342
1094
  }
3343
- };
3344
- };
3345
-
3346
- /**
3347
- * Modifies the placement by translating the floating element along the
3348
- * specified axes.
3349
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
3350
- * object may be passed.
3351
- * @see https://floating-ui.com/docs/offset
3352
- */
3353
- const offset = (options, deps) => {
3354
- const result = offset$1(options);
3355
- return {
3356
- name: result.name,
3357
- fn: result.fn,
3358
- options: [options, deps]
3359
- };
3360
- };
3361
-
3362
- /**
3363
- * Optimizes the visibility of the floating element by shifting it in order to
3364
- * keep it in view when it will overflow the clipping boundary.
3365
- * @see https://floating-ui.com/docs/shift
3366
- */
3367
- const shift = (options, deps) => {
3368
- const result = shift$1(options);
3369
- return {
3370
- name: result.name,
3371
- fn: result.fn,
3372
- options: [options, deps]
3373
- };
3374
- };
3375
-
3376
- /**
3377
- * Built-in `limiter` that will stop `shift()` at a certain point.
3378
- */
3379
- const limitShift = (options, deps) => {
3380
- const result = limitShift$1(options);
3381
- return {
3382
- fn: result.fn,
3383
- options: [options, deps]
3384
- };
3385
- };
3386
-
3387
- /**
3388
- * Optimizes the visibility of the floating element by flipping the `placement`
3389
- * in order to keep it in view when the preferred placement(s) will overflow the
3390
- * clipping boundary. Alternative to `autoPlacement`.
3391
- * @see https://floating-ui.com/docs/flip
3392
- */
3393
- const flip = (options, deps) => {
3394
- const result = flip$1(options);
3395
- return {
3396
- name: result.name,
3397
- fn: result.fn,
3398
- options: [options, deps]
3399
- };
3400
- };
3401
-
3402
- /**
3403
- * Provides data that allows you to change the size of the floating element —
3404
- * for instance, prevent it from overflowing the clipping boundary or match the
3405
- * width of the reference element.
3406
- * @see https://floating-ui.com/docs/size
3407
- */
3408
- const size = (options, deps) => {
3409
- const result = size$1(options);
3410
- return {
3411
- name: result.name,
3412
- fn: result.fn,
3413
- options: [options, deps]
3414
- };
3415
- };
3416
-
3417
- /**
3418
- * Optimizes the visibility of the floating element by choosing the placement
3419
- * that has the most space available automatically, without needing to specify a
3420
- * preferred placement. Alternative to `flip`.
3421
- * @see https://floating-ui.com/docs/autoPlacement
3422
- */
3423
- const autoPlacement = (options, deps) => {
3424
- const result = autoPlacement$1(options);
3425
- return {
3426
- name: result.name,
3427
- fn: result.fn,
3428
- options: [options, deps]
3429
- };
3430
- };
3431
-
3432
- /**
3433
- * Provides data to hide the floating element in applicable situations, such as
3434
- * when it is not in the same clipping context as the reference element.
3435
- * @see https://floating-ui.com/docs/hide
3436
- */
3437
- const hide = (options, deps) => {
3438
- const result = hide$1(options);
3439
- return {
3440
- name: result.name,
3441
- fn: result.fn,
3442
- options: [options, deps]
3443
- };
3444
- };
3445
-
3446
- /**
3447
- * Provides data to position an inner element of the floating element so that it
3448
- * appears centered to the reference element.
3449
- * This wraps the core `arrow` middleware to allow React refs as the element.
3450
- * @see https://floating-ui.com/docs/arrow
3451
- */
3452
- const arrow = (options, deps) => {
3453
- const result = arrow$1(options);
3454
- return {
3455
- name: result.name,
3456
- fn: result.fn,
3457
- options: [options, deps]
3458
- };
3459
- };
1095
+ });
1096
+ }
3460
1097
 
3461
1098
  const FOCUSABLE_ATTRIBUTE = 'data-floating-ui-focusable';
3462
1099
  const ACTIVE_KEY = 'active';
@@ -3478,7 +1115,7 @@ const genId = () => // Ensure the id is unique with multiple independent version
3478
1115
  "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
3479
1116
  function useFloatingId() {
3480
1117
  const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : undefined);
3481
- index$1(() => {
1118
+ index(() => {
3482
1119
  if (id == null) {
3483
1120
  setId(genId());
3484
1121
  }
@@ -3566,7 +1203,7 @@ const FloatingArrow = /*#__PURE__*/React.forwardRef(function FloatingArrow(props
3566
1203
  const [isRTL, setIsRTL] = React.useState(false);
3567
1204
 
3568
1205
  // https://github.com/floating-ui/floating-ui/issues/2932
3569
- index$1(() => {
1206
+ index(() => {
3570
1207
  if (!floating) return;
3571
1208
  const isRTL = getComputedStyle$1(floating).direction === 'rtl';
3572
1209
  if (isRTL) {
@@ -3689,7 +1326,7 @@ function useFloatingNodeId(customParentId) {
3689
1326
  const tree = useFloatingTree();
3690
1327
  const reactParentId = useFloatingParentNodeId();
3691
1328
  const parentId = reactParentId;
3692
- index$1(() => {
1329
+ index(() => {
3693
1330
  if (!id) return;
3694
1331
  const node = {
3695
1332
  id,
@@ -3920,7 +1557,7 @@ const HIDDEN_STYLES = {
3920
1557
  };
3921
1558
  const FocusGuard = /*#__PURE__*/React.forwardRef(function FocusGuard(props, ref) {
3922
1559
  const [role, setRole] = React.useState();
3923
- index$1(() => {
1560
+ index(() => {
3924
1561
  if (isSafari()) {
3925
1562
  // Unlike other screen readers such as NVDA and JAWS, the virtual cursor
3926
1563
  // on VoiceOver does trigger the onFocus event, so we can use the focus
@@ -3962,7 +1599,7 @@ function useFloatingPortalNode(props) {
3962
1599
  const portalContext = usePortalContext();
3963
1600
  const [portalNode, setPortalNode] = React.useState(null);
3964
1601
  const portalNodeRef = React.useRef(null);
3965
- index$1(() => {
1602
+ index(() => {
3966
1603
  return () => {
3967
1604
  portalNode == null || portalNode.remove();
3968
1605
  // Allow the subsequent layout effects to create a new node on updates.
@@ -3973,7 +1610,7 @@ function useFloatingPortalNode(props) {
3973
1610
  });
3974
1611
  };
3975
1612
  }, [portalNode]);
3976
- index$1(() => {
1613
+ index(() => {
3977
1614
  // Wait for the uniqueId to be generated before creating the portal node in
3978
1615
  // React <18 (using `useFloatingId` instead of the native `useId`).
3979
1616
  // https://github.com/floating-ui/floating-ui/issues/2778
@@ -3988,7 +1625,7 @@ function useFloatingPortalNode(props) {
3988
1625
  portalNodeRef.current = subRoot;
3989
1626
  setPortalNode(subRoot);
3990
1627
  }, [id, uniqueId]);
3991
- index$1(() => {
1628
+ index(() => {
3992
1629
  // Wait for the root to exist before creating the portal node. The root must
3993
1630
  // be stored in state, not a ref, for this to work reactively.
3994
1631
  if (root === null) return;
@@ -4238,9 +1875,9 @@ function FloatingFocusManager(props) {
4238
1875
  const inertSupported = supportsInert();
4239
1876
  const guards = inertSupported ? _guards : true;
4240
1877
  const useInert = !guards || inertSupported && outsideElementsInert;
4241
- const orderRef = useLatestRef$1(order);
4242
- const initialFocusRef = useLatestRef$1(initialFocus);
4243
- const returnFocusRef = useLatestRef$1(returnFocus);
1878
+ const orderRef = useLatestRef(order);
1879
+ const initialFocusRef = useLatestRef(initialFocus);
1880
+ const returnFocusRef = useLatestRef(returnFocus);
4244
1881
  const tree = useFloatingTree();
4245
1882
  const portalContext = usePortalContext();
4246
1883
  const startDismissButtonRef = React.useRef(null);
@@ -4423,7 +2060,7 @@ function FloatingFocusManager(props) {
4423
2060
  cleanup();
4424
2061
  };
4425
2062
  }, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards, useInert, tree, getNodeId, getInsideElements]);
4426
- index$1(() => {
2063
+ index(() => {
4427
2064
  if (disabled || !isHTMLElement(floatingFocusElement)) return;
4428
2065
  const doc = getDocument$1(floatingFocusElement);
4429
2066
  const previouslyFocusedElement = activeElement(doc);
@@ -4441,7 +2078,7 @@ function FloatingFocusManager(props) {
4441
2078
  }
4442
2079
  });
4443
2080
  }, [disabled, open, floatingFocusElement, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
4444
- index$1(() => {
2081
+ index(() => {
4445
2082
  if (disabled || !floatingFocusElement) return;
4446
2083
  const doc = getDocument$1(floatingFocusElement);
4447
2084
  const previouslyFocusedElement = activeElement(doc);
@@ -4532,7 +2169,7 @@ function FloatingFocusManager(props) {
4532
2169
 
4533
2170
  // Synchronize the `context` & `modal` value to the FloatingPortal context.
4534
2171
  // It will decide whether or not it needs to render its own guards.
4535
- index$1(() => {
2172
+ index(() => {
4536
2173
  if (disabled) return;
4537
2174
  if (!portalContext) return;
4538
2175
  portalContext.setFocusManagerState({
@@ -4546,7 +2183,7 @@ function FloatingFocusManager(props) {
4546
2183
  portalContext.setFocusManagerState(null);
4547
2184
  };
4548
2185
  }, [disabled, portalContext, modal, open, onOpenChange, closeOnFocusOut, domReference]);
4549
- index$1(() => {
2186
+ index(() => {
4550
2187
  if (disabled) return;
4551
2188
  if (!floatingFocusElement) return;
4552
2189
  handleTabIndex(floatingFocusElement, orderRef);
@@ -4668,7 +2305,7 @@ const FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(p
4668
2305
  lockScroll = false,
4669
2306
  ...rest
4670
2307
  } = props;
4671
- index$1(() => {
2308
+ index(() => {
4672
2309
  if (!lockScroll) return;
4673
2310
  lockCount++;
4674
2311
  if (lockCount === 1) {
@@ -5175,7 +2812,7 @@ function useFloating(options) {
5175
2812
  const domReference = optionDomReference || _domReference;
5176
2813
  const domReferenceRef = React.useRef(null);
5177
2814
  const tree = useFloatingTree();
5178
- index$1(() => {
2815
+ index(() => {
5179
2816
  if (domReference) {
5180
2817
  domReferenceRef.current = domReference;
5181
2818
  }
@@ -5233,7 +2870,7 @@ function useFloating(options) {
5233
2870
  elements,
5234
2871
  nodeId
5235
2872
  }), [position, refs, elements, nodeId, rootContext]);
5236
- index$1(() => {
2873
+ index(() => {
5237
2874
  rootContext.dataRef.current.floatingContext = context;
5238
2875
  const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
5239
2876
  if (node) {
@@ -5416,10 +3053,10 @@ function useListNavigation(context, props) {
5416
3053
  }
5417
3054
  }
5418
3055
  const floatingFocusElement = getFloatingFocusElement(elements.floating);
5419
- const floatingFocusElementRef = useLatestRef$1(floatingFocusElement);
3056
+ const floatingFocusElementRef = useLatestRef(floatingFocusElement);
5420
3057
  const parentId = useFloatingParentNodeId();
5421
3058
  const tree = useFloatingTree();
5422
- index$1(() => {
3059
+ index(() => {
5423
3060
  context.dataRef.current.orientation = orientation;
5424
3061
  }, [context, orientation]);
5425
3062
  const onNavigate = useEffectEvent(() => {
@@ -5435,10 +3072,10 @@ function useListNavigation(context, props) {
5435
3072
  const previousOpenRef = React.useRef(open);
5436
3073
  const forceSyncFocusRef = React.useRef(false);
5437
3074
  const forceScrollIntoViewRef = React.useRef(false);
5438
- const disabledIndicesRef = useLatestRef$1(disabledIndices);
5439
- const latestOpenRef = useLatestRef$1(open);
5440
- const scrollItemIntoViewRef = useLatestRef$1(scrollItemIntoView);
5441
- const selectedIndexRef = useLatestRef$1(selectedIndex);
3075
+ const disabledIndicesRef = useLatestRef(disabledIndices);
3076
+ const latestOpenRef = useLatestRef(open);
3077
+ const scrollItemIntoViewRef = useLatestRef(scrollItemIntoView);
3078
+ const selectedIndexRef = useLatestRef(selectedIndex);
5442
3079
  const [activeId, setActiveId] = React.useState();
5443
3080
  const [virtualId, setVirtualId] = React.useState();
5444
3081
  const focusItem = useEffectEvent(() => {
@@ -5487,7 +3124,7 @@ function useListNavigation(context, props) {
5487
3124
 
5488
3125
  // Sync `selectedIndex` to be the `activeIndex` upon opening the floating
5489
3126
  // element. Also, reset `activeIndex` upon closing the floating element.
5490
- index$1(() => {
3127
+ index(() => {
5491
3128
  if (!enabled) return;
5492
3129
  if (open && elements.floating) {
5493
3130
  if (focusItemOnOpenRef.current && selectedIndex != null) {
@@ -5508,7 +3145,7 @@ function useListNavigation(context, props) {
5508
3145
 
5509
3146
  // Sync `activeIndex` to be the focused item while the floating element is
5510
3147
  // open.
5511
- index$1(() => {
3148
+ index(() => {
5512
3149
  if (!enabled) return;
5513
3150
  if (!open) return;
5514
3151
  if (!elements.floating) return;
@@ -5554,7 +3191,7 @@ function useListNavigation(context, props) {
5554
3191
 
5555
3192
  // Ensure the parent floating element has focus when a nested child closes
5556
3193
  // to allow arrow key navigation to work after the pointer leaves the child.
5557
- index$1(() => {
3194
+ index(() => {
5558
3195
  var _nodes$find;
5559
3196
  if (!enabled || elements.floating || !tree || virtual || !previousMountedRef.current) {
5560
3197
  return;
@@ -5569,7 +3206,7 @@ function useListNavigation(context, props) {
5569
3206
  });
5570
3207
  }
5571
3208
  }, [enabled, elements.floating, tree, parentId, virtual]);
5572
- index$1(() => {
3209
+ index(() => {
5573
3210
  if (!enabled) return;
5574
3211
  if (!tree) return;
5575
3212
  if (!virtual) return;
@@ -5585,12 +3222,12 @@ function useListNavigation(context, props) {
5585
3222
  tree.events.off('virtualfocus', handleVirtualFocus);
5586
3223
  };
5587
3224
  }, [enabled, tree, virtual, parentId, virtualItemRef]);
5588
- index$1(() => {
3225
+ index(() => {
5589
3226
  previousOnNavigateRef.current = onNavigate;
5590
3227
  previousOpenRef.current = open;
5591
3228
  previousMountedRef.current = !!elements.floating;
5592
3229
  });
5593
- index$1(() => {
3230
+ index(() => {
5594
3231
  if (!open) {
5595
3232
  keyRef.current = null;
5596
3233
  focusItemOnOpenRef.current = focusItemOnOpen;
@@ -6068,7 +3705,7 @@ function useTransitionStatus(context, props) {
6068
3705
  if (!isMounted && status === 'close') {
6069
3706
  setStatus('unmounted');
6070
3707
  }
6071
- index$1(() => {
3708
+ index(() => {
6072
3709
  if (!floating) return;
6073
3710
  if (open) {
6074
3711
  setStatus('initial');
@@ -6128,11 +3765,11 @@ function useTransitionStyles(context, props) {
6128
3765
  } = useTransitionStatus(context, {
6129
3766
  duration
6130
3767
  });
6131
- const initialRef = useLatestRef$1(unstable_initial);
6132
- const openRef = useLatestRef$1(unstable_open);
6133
- const closeRef = useLatestRef$1(unstable_close);
6134
- const commonRef = useLatestRef$1(unstable_common);
6135
- index$1(() => {
3768
+ const initialRef = useLatestRef(unstable_initial);
3769
+ const openRef = useLatestRef(unstable_open);
3770
+ const closeRef = useLatestRef(unstable_close);
3771
+ const commonRef = useLatestRef(unstable_common);
3772
+ index(() => {
6136
3773
  const initialStyles = execWithArgsOrReturn(initialRef.current, fnArgs);
6137
3774
  const closeStyles = execWithArgsOrReturn(closeRef.current, fnArgs);
6138
3775
  const commonStyles = execWithArgsOrReturn(commonRef.current, fnArgs);
@@ -6171,4 +3808,4 @@ function useTransitionStyles(context, props) {
6171
3808
  };
6172
3809
  }
6173
3810
 
6174
- 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, size as m, useListNavigation as n, offset as o, useRole as p, FloatingFocusManager as q, FloatingOverlay as r, shift as s, useClick as t, useFloating as u, useTransitionStyles as v, FloatingArrow as w };
3811
+ export { FloatingPortal as F, useFloatingParentNodeId as a, useFloatingNodeId as b, useDismiss as c, useInteractions as d, FloatingTree as e, FloatingNode as f, useListNavigation as g, useRole as h, FloatingFocusManager as i, FloatingOverlay as j, useClick as k, useTransitionStyles as l, FloatingArrow as m, useFloating as u };