@jobber/components 6.122.0 → 6.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/Autocomplete/index.cjs +1 -0
  2. package/dist/Autocomplete/index.mjs +2 -1
  3. package/dist/BottomSheet-cjs.js +66 -0
  4. package/dist/BottomSheet-es.js +64 -0
  5. package/dist/Card/index.cjs +3 -2
  6. package/dist/Card/index.mjs +3 -2
  7. package/dist/Chip/index.cjs +3 -2
  8. package/dist/Chip/index.mjs +3 -2
  9. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +3 -2
  10. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +3 -2
  11. package/dist/Chips/InternalChipDismissible/index.cjs +3 -2
  12. package/dist/Chips/InternalChipDismissible/index.mjs +3 -2
  13. package/dist/Chips/index.cjs +3 -2
  14. package/dist/Chips/index.mjs +3 -2
  15. package/dist/Combobox/components/ComboboxActivator/index.cjs +3 -2
  16. package/dist/Combobox/components/ComboboxActivator/index.mjs +3 -2
  17. package/dist/Combobox/components/ComboboxContent/index.cjs +3 -2
  18. package/dist/Combobox/components/ComboboxContent/index.mjs +3 -2
  19. package/dist/Combobox/components/ComboboxTrigger/index.cjs +3 -2
  20. package/dist/Combobox/components/ComboboxTrigger/index.mjs +3 -2
  21. package/dist/Combobox/index.cjs +3 -2
  22. package/dist/Combobox/index.mjs +3 -2
  23. package/dist/ComboboxContent-es.js +1 -1
  24. package/dist/ConfirmationModal/index.cjs +2 -1
  25. package/dist/ConfirmationModal/index.mjs +2 -1
  26. package/dist/DataDump/index.cjs +3 -2
  27. package/dist/DataDump/index.mjs +3 -2
  28. package/dist/DataList/components/DataListActions/index.cjs +3 -2
  29. package/dist/DataList/components/DataListActions/index.mjs +3 -2
  30. package/dist/DataList/components/DataListBulkActions/index.cjs +3 -2
  31. package/dist/DataList/components/DataListBulkActions/index.mjs +3 -2
  32. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +3 -2
  33. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +3 -2
  34. package/dist/DataList/components/DataListFilters/index.cjs +3 -2
  35. package/dist/DataList/components/DataListFilters/index.mjs +3 -2
  36. package/dist/DataList/components/DataListHeader/index.cjs +3 -2
  37. package/dist/DataList/components/DataListHeader/index.mjs +3 -2
  38. package/dist/DataList/components/DataListItem/index.cjs +3 -2
  39. package/dist/DataList/components/DataListItem/index.mjs +3 -2
  40. package/dist/DataList/components/DataListItemActions/index.cjs +3 -2
  41. package/dist/DataList/components/DataListItemActions/index.mjs +3 -2
  42. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +3 -2
  43. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +3 -2
  44. package/dist/DataList/components/DataListItems/index.cjs +3 -2
  45. package/dist/DataList/components/DataListItems/index.mjs +3 -2
  46. package/dist/DataList/components/DataListLayout/index.cjs +3 -2
  47. package/dist/DataList/components/DataListLayout/index.mjs +3 -2
  48. package/dist/DataList/components/DataListLayoutActions/index.cjs +3 -2
  49. package/dist/DataList/components/DataListLayoutActions/index.mjs +3 -2
  50. package/dist/DataList/index.cjs +3 -2
  51. package/dist/DataList/index.mjs +3 -2
  52. package/dist/DatePicker/index.cjs +3 -2
  53. package/dist/DatePicker/index.mjs +3 -2
  54. package/dist/DatePicker-es.js +1 -1
  55. package/dist/DrawerRoot-cjs.js +6181 -0
  56. package/dist/DrawerRoot-es.js +6056 -0
  57. package/dist/FormatFile/index.cjs +2 -1
  58. package/dist/FormatFile/index.mjs +2 -1
  59. package/dist/Gallery/index.cjs +2 -1
  60. package/dist/Gallery/index.mjs +2 -1
  61. package/dist/InputDate/index.cjs +3 -2
  62. package/dist/InputDate/index.mjs +3 -2
  63. package/dist/LightBox/index.cjs +2 -1
  64. package/dist/LightBox/index.mjs +2 -1
  65. package/dist/Menu/index.cjs +3 -2
  66. package/dist/Menu/index.mjs +3 -2
  67. package/dist/Menu-es.js +1 -1
  68. package/dist/Modal/index.cjs +2 -1
  69. package/dist/Modal/index.mjs +2 -1
  70. package/dist/OverlaySeparator-cjs.js +15 -0
  71. package/dist/OverlaySeparator-es.js +13 -0
  72. package/dist/Page/index.cjs +2 -1
  73. package/dist/Page/index.mjs +2 -1
  74. package/dist/Popover/index.cjs +3 -2
  75. package/dist/Popover/index.mjs +3 -2
  76. package/dist/Popover-es.js +1 -1
  77. package/dist/Separator-cjs.js +53 -0
  78. package/dist/Separator-es.js +32 -0
  79. package/dist/Tooltip/index.cjs +3 -2
  80. package/dist/Tooltip/index.mjs +3 -2
  81. package/dist/Tooltip-es.js +1 -1
  82. package/dist/floating-ui.react-cjs.js +45 -44
  83. package/dist/floating-ui.react-dom-cjs.js +155 -1053
  84. package/dist/floating-ui.react-dom-es.js +2 -876
  85. package/dist/floating-ui.react-es.js +2 -1
  86. package/dist/index.cjs +3 -2
  87. package/dist/index.esm-cjs.js +921 -0
  88. package/dist/index.esm-es.js +876 -0
  89. package/dist/index.mjs +3 -2
  90. package/dist/primitives/BottomSheet/BottomSheet.d.ts +15 -0
  91. package/dist/primitives/BottomSheet/index.cjs +16 -0
  92. package/dist/primitives/BottomSheet/index.d.ts +1 -0
  93. package/dist/primitives/BottomSheet/index.mjs +10 -0
  94. package/dist/primitives/OverlaySeparator/OverlaySeparator.d.ts +6 -0
  95. package/dist/primitives/OverlaySeparator/index.cjs +12 -0
  96. package/dist/primitives/OverlaySeparator/index.d.ts +1 -0
  97. package/dist/primitives/OverlaySeparator/index.mjs +6 -0
  98. package/dist/primitives/index.cjs +17 -0
  99. package/dist/primitives/index.d.ts +2 -0
  100. package/dist/primitives/index.mjs +12 -1
  101. package/dist/unstyledPrimitives/index.cjs +7676 -9833
  102. package/dist/unstyledPrimitives/index.d.ts +6 -9
  103. package/dist/unstyledPrimitives/index.mjs +7551 -9711
  104. package/dist/useRenderElement-cjs.js +598 -0
  105. package/dist/useRenderElement-es.js +569 -0
  106. package/dist/useScrollToActive-es.js +1 -1
  107. package/package.json +2 -2
@@ -1,882 +1,8 @@
1
+ import { n as evaluate, o as getSide, p as getSideAxis, q as getOppositePlacement, r as getExpandedPlacements, s as getOppositeAxisPlacements, u as getAlignmentSides, v as getAlignment, w as min, x as max, y as getAlignmentAxis, z as getPaddingObject, A as rectToClientRect, B as clamp, C as getAxisLength, D as sides, E as getOppositeAxis, F as placements, G as getOppositeAlignmentPlacement, g as getOverflowAncestors, b as isElement, H as createCoords, I as getWindow, J as getFrameElement, l as getComputedStyle$1, K as getDocumentElement, a as isHTMLElement, L as round, m as isWebKit, f as floor, M as isTopLayer, d as getNodeName, N as isOverflowElement, O as getNodeScroll, k as getParentNode, j as isLastTraversableNode, P as isTableElement, Q as isContainingBlock, R as getContainingBlock } from './index.esm-es.js';
1
2
  import * as React from 'react';
2
3
  import { useLayoutEffect } from 'react';
3
4
  import * as ReactDOM from 'react-dom';
4
5
 
5
- function hasWindow() {
6
- return typeof window !== 'undefined';
7
- }
8
- function getNodeName(node) {
9
- if (isNode(node)) {
10
- return (node.nodeName || '').toLowerCase();
11
- }
12
- // Mocked nodes in testing environments may not be instances of Node. By
13
- // returning `#document` an infinite loop won't occur.
14
- // https://github.com/floating-ui/floating-ui/issues/2317
15
- return '#document';
16
- }
17
- function getWindow(node) {
18
- var _node$ownerDocument;
19
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
20
- }
21
- function getDocumentElement(node) {
22
- var _ref;
23
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
24
- }
25
- function isNode(value) {
26
- if (!hasWindow()) {
27
- return false;
28
- }
29
- return value instanceof Node || value instanceof getWindow(value).Node;
30
- }
31
- function isElement(value) {
32
- if (!hasWindow()) {
33
- return false;
34
- }
35
- return value instanceof Element || value instanceof getWindow(value).Element;
36
- }
37
- function isHTMLElement(value) {
38
- if (!hasWindow()) {
39
- return false;
40
- }
41
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
42
- }
43
- function isShadowRoot(value) {
44
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
45
- return false;
46
- }
47
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
48
- }
49
- function isOverflowElement(element) {
50
- const {
51
- overflow,
52
- overflowX,
53
- overflowY,
54
- display
55
- } = getComputedStyle$1(element);
56
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
57
- }
58
- function isTableElement(element) {
59
- return /^(table|td|th)$/.test(getNodeName(element));
60
- }
61
- function isTopLayer(element) {
62
- try {
63
- if (element.matches(':popover-open')) {
64
- return true;
65
- }
66
- } catch (_e) {
67
- // no-op
68
- }
69
- try {
70
- return element.matches(':modal');
71
- } catch (_e) {
72
- return false;
73
- }
74
- }
75
- const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
76
- const containRe = /paint|layout|strict|content/;
77
- const isNotNone = value => !!value && value !== 'none';
78
- let isWebKitValue;
79
- function isContainingBlock(elementOrCss) {
80
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
81
-
82
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
83
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
84
- 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 || '');
85
- }
86
- function getContainingBlock(element) {
87
- let currentNode = getParentNode(element);
88
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
89
- if (isContainingBlock(currentNode)) {
90
- return currentNode;
91
- } else if (isTopLayer(currentNode)) {
92
- return null;
93
- }
94
- currentNode = getParentNode(currentNode);
95
- }
96
- return null;
97
- }
98
- function isWebKit() {
99
- if (isWebKitValue == null) {
100
- isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
101
- }
102
- return isWebKitValue;
103
- }
104
- function isLastTraversableNode(node) {
105
- return /^(html|body|#document)$/.test(getNodeName(node));
106
- }
107
- function getComputedStyle$1(element) {
108
- return getWindow(element).getComputedStyle(element);
109
- }
110
- function getNodeScroll(element) {
111
- if (isElement(element)) {
112
- return {
113
- scrollLeft: element.scrollLeft,
114
- scrollTop: element.scrollTop
115
- };
116
- }
117
- return {
118
- scrollLeft: element.scrollX,
119
- scrollTop: element.scrollY
120
- };
121
- }
122
- function getParentNode(node) {
123
- if (getNodeName(node) === 'html') {
124
- return node;
125
- }
126
- const result =
127
- // Step into the shadow DOM of the parent of a slotted node.
128
- node.assignedSlot ||
129
- // DOM Element detected.
130
- node.parentNode ||
131
- // ShadowRoot detected.
132
- isShadowRoot(node) && node.host ||
133
- // Fallback.
134
- getDocumentElement(node);
135
- return isShadowRoot(result) ? result.host : result;
136
- }
137
- function getNearestOverflowAncestor(node) {
138
- const parentNode = getParentNode(node);
139
- if (isLastTraversableNode(parentNode)) {
140
- return node.ownerDocument ? node.ownerDocument.body : node.body;
141
- }
142
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
143
- return parentNode;
144
- }
145
- return getNearestOverflowAncestor(parentNode);
146
- }
147
- function getOverflowAncestors(node, list, traverseIframes) {
148
- var _node$ownerDocument2;
149
- if (list === void 0) {
150
- list = [];
151
- }
152
- if (traverseIframes === void 0) {
153
- traverseIframes = true;
154
- }
155
- const scrollableAncestor = getNearestOverflowAncestor(node);
156
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
157
- const win = getWindow(scrollableAncestor);
158
- if (isBody) {
159
- const frameElement = getFrameElement(win);
160
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
161
- } else {
162
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
163
- }
164
- }
165
- function getFrameElement(win) {
166
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
167
- }
168
-
169
- /**
170
- * Custom positioning reference element.
171
- * @see https://floating-ui.com/docs/virtual-elements
172
- */
173
-
174
- const sides = ['top', 'right', 'bottom', 'left'];
175
- const alignments = ['start', 'end'];
176
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
177
- const min = Math.min;
178
- const max = Math.max;
179
- const round = Math.round;
180
- const floor = Math.floor;
181
- const createCoords = v => ({
182
- x: v,
183
- y: v
184
- });
185
- const oppositeSideMap = {
186
- left: 'right',
187
- right: 'left',
188
- bottom: 'top',
189
- top: 'bottom'
190
- };
191
- function clamp(start, value, end) {
192
- return max(start, min(value, end));
193
- }
194
- function evaluate(value, param) {
195
- return typeof value === 'function' ? value(param) : value;
196
- }
197
- function getSide(placement) {
198
- return placement.split('-')[0];
199
- }
200
- function getAlignment(placement) {
201
- return placement.split('-')[1];
202
- }
203
- function getOppositeAxis(axis) {
204
- return axis === 'x' ? 'y' : 'x';
205
- }
206
- function getAxisLength(axis) {
207
- return axis === 'y' ? 'height' : 'width';
208
- }
209
- function getSideAxis(placement) {
210
- const firstChar = placement[0];
211
- return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
212
- }
213
- function getAlignmentAxis(placement) {
214
- return getOppositeAxis(getSideAxis(placement));
215
- }
216
- function getAlignmentSides(placement, rects, rtl) {
217
- if (rtl === void 0) {
218
- rtl = false;
219
- }
220
- const alignment = getAlignment(placement);
221
- const alignmentAxis = getAlignmentAxis(placement);
222
- const length = getAxisLength(alignmentAxis);
223
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
224
- if (rects.reference[length] > rects.floating[length]) {
225
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
226
- }
227
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
228
- }
229
- function getExpandedPlacements(placement) {
230
- const oppositePlacement = getOppositePlacement(placement);
231
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
232
- }
233
- function getOppositeAlignmentPlacement(placement) {
234
- return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
235
- }
236
- const lrPlacement = ['left', 'right'];
237
- const rlPlacement = ['right', 'left'];
238
- const tbPlacement = ['top', 'bottom'];
239
- const btPlacement = ['bottom', 'top'];
240
- function getSideList(side, isStart, rtl) {
241
- switch (side) {
242
- case 'top':
243
- case 'bottom':
244
- if (rtl) return isStart ? rlPlacement : lrPlacement;
245
- return isStart ? lrPlacement : rlPlacement;
246
- case 'left':
247
- case 'right':
248
- return isStart ? tbPlacement : btPlacement;
249
- default:
250
- return [];
251
- }
252
- }
253
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
254
- const alignment = getAlignment(placement);
255
- let list = getSideList(getSide(placement), direction === 'start', rtl);
256
- if (alignment) {
257
- list = list.map(side => side + "-" + alignment);
258
- if (flipAlignment) {
259
- list = list.concat(list.map(getOppositeAlignmentPlacement));
260
- }
261
- }
262
- return list;
263
- }
264
- function getOppositePlacement(placement) {
265
- const side = getSide(placement);
266
- return oppositeSideMap[side] + placement.slice(side.length);
267
- }
268
- function expandPaddingObject(padding) {
269
- return {
270
- top: 0,
271
- right: 0,
272
- bottom: 0,
273
- left: 0,
274
- ...padding
275
- };
276
- }
277
- function getPaddingObject(padding) {
278
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
279
- top: padding,
280
- right: padding,
281
- bottom: padding,
282
- left: padding
283
- };
284
- }
285
- function rectToClientRect(rect) {
286
- const {
287
- x,
288
- y,
289
- width,
290
- height
291
- } = rect;
292
- return {
293
- width,
294
- height,
295
- top: y,
296
- left: x,
297
- right: x + width,
298
- bottom: y + height,
299
- x,
300
- y
301
- };
302
- }
303
-
304
- /*!
305
- * tabbable 6.4.0
306
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
307
- */
308
- // NOTE: separate `:not()` selectors has broader browser support than the newer
309
- // `:not([inert], [inert] *)` (Feb 2023)
310
- var candidateSelectors = ['input:not([inert]):not([inert] *)', 'select:not([inert]):not([inert] *)', 'textarea:not([inert]):not([inert] *)', 'a[href]:not([inert]):not([inert] *)', 'button:not([inert]):not([inert] *)', '[tabindex]:not(slot):not([inert]):not([inert] *)', 'audio[controls]:not([inert]):not([inert] *)', 'video[controls]:not([inert]):not([inert] *)', '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', 'details>summary:first-of-type:not([inert]):not([inert] *)', 'details:not([inert]):not([inert] *)'];
311
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
312
- var NoElement = typeof Element === 'undefined';
313
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
314
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
315
- var _element$getRootNode;
316
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
317
- } : function (element) {
318
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
319
- };
320
-
321
- /**
322
- * Determines if a node is inert or in an inert ancestor.
323
- * @param {Node} [node]
324
- * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
325
- * see if any of them are inert. If false, only `node` itself is considered.
326
- * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
327
- * False if `node` is falsy.
328
- */
329
- var _isInert = function isInert(node, lookUp) {
330
- var _node$getAttribute;
331
- if (lookUp === void 0) {
332
- lookUp = true;
333
- }
334
- // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
335
- // JS API property; we have to check the attribute, which can either be empty or 'true';
336
- // if it's `null` (not specified) or 'false', it's an active element
337
- var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');
338
- var inert = inertAtt === '' || inertAtt === 'true';
339
-
340
- // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
341
- // if it weren't for `matches()` not being a function on shadow roots; the following
342
- // code works for any kind of node
343
- var result = inert || lookUp && node && (
344
- // closest does not exist on shadow roots, so we fall back to a manual
345
- // lookup upward, in case it is not defined.
346
- typeof node.closest === 'function' ? node.closest('[inert]') : _isInert(node.parentNode));
347
- return result;
348
- };
349
-
350
- /**
351
- * Determines if a node's content is editable.
352
- * @param {Element} [node]
353
- * @returns True if it's content-editable; false if it's not or `node` is falsy.
354
- */
355
- var isContentEditable = function isContentEditable(node) {
356
- var _node$getAttribute2;
357
- // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
358
- // to use the attribute directly to check for this, which can either be empty or 'true';
359
- // if it's `null` (not specified) or 'false', it's a non-editable element
360
- var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');
361
- return attValue === '' || attValue === 'true';
362
- };
363
-
364
- /**
365
- * @param {Element} el container to check in
366
- * @param {boolean} includeContainer add container to check
367
- * @param {(node: Element) => boolean} filter filter candidates
368
- * @returns {Element[]}
369
- */
370
- var getCandidates = function getCandidates(el, includeContainer, filter) {
371
- // even if `includeContainer=false`, we still have to check it for inertness because
372
- // if it's inert (either by itself or via its parent), then all its children are inert
373
- if (_isInert(el)) {
374
- return [];
375
- }
376
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
377
- if (includeContainer && matches.call(el, candidateSelector)) {
378
- candidates.unshift(el);
379
- }
380
- candidates = candidates.filter(filter);
381
- return candidates;
382
- };
383
-
384
- /**
385
- * @callback GetShadowRoot
386
- * @param {Element} element to check for shadow root
387
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
388
- */
389
-
390
- /**
391
- * @callback ShadowRootFilter
392
- * @param {Element} shadowHostNode the element which contains shadow content
393
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
394
- */
395
-
396
- /**
397
- * @typedef {Object} CandidateScope
398
- * @property {Element} scopeParent contains inner candidates
399
- * @property {Element[]} candidates list of candidates found in the scope parent
400
- */
401
-
402
- /**
403
- * @typedef {Object} IterativeOptions
404
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
405
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
406
- * or a boolean stating if it has an undisclosed shadow root
407
- * @property {(node: Element) => boolean} filter filter candidates
408
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
409
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
410
- */
411
-
412
- /**
413
- * @param {Element[]} elements list of element containers to match candidates from
414
- * @param {boolean} includeContainer add container list to check
415
- * @param {IterativeOptions} options
416
- * @returns {Array.<Element|CandidateScope>}
417
- */
418
- var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
419
- var candidates = [];
420
- var elementsToCheck = Array.from(elements);
421
- while (elementsToCheck.length) {
422
- var element = elementsToCheck.shift();
423
- if (_isInert(element, false)) {
424
- // no need to look up since we're drilling down
425
- // anything inside this container will also be inert
426
- continue;
427
- }
428
- if (element.tagName === 'SLOT') {
429
- // add shadow dom slot scope (slot itself cannot be focusable)
430
- var assigned = element.assignedElements();
431
- var content = assigned.length ? assigned : element.children;
432
- var nestedCandidates = _getCandidatesIteratively(content, true, options);
433
- if (options.flatten) {
434
- candidates.push.apply(candidates, nestedCandidates);
435
- } else {
436
- candidates.push({
437
- scopeParent: element,
438
- candidates: nestedCandidates
439
- });
440
- }
441
- } else {
442
- // check candidate element
443
- var validCandidate = matches.call(element, candidateSelector);
444
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
445
- candidates.push(element);
446
- }
447
-
448
- // iterate over shadow content if possible
449
- var shadowRoot = element.shadowRoot ||
450
- // check for an undisclosed shadow
451
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
452
-
453
- // no inert look up because we're already drilling down and checking for inertness
454
- // on the way down, so all containers to this root node should have already been
455
- // vetted as non-inert
456
- var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
457
- if (shadowRoot && validShadowRoot) {
458
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
459
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
460
- // child candidates found because they're likely slotted elements (elements that are
461
- // children of the web component element (which has the shadow), in the light dom, but
462
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
463
- // _after_ we return from this recursive call
464
- var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
465
- if (options.flatten) {
466
- candidates.push.apply(candidates, _nestedCandidates);
467
- } else {
468
- candidates.push({
469
- scopeParent: element,
470
- candidates: _nestedCandidates
471
- });
472
- }
473
- } else {
474
- // there's not shadow so just dig into the element's (light dom) children
475
- // __without__ giving the element special scope treatment
476
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
477
- }
478
- }
479
- }
480
- return candidates;
481
- };
482
-
483
- /**
484
- * @private
485
- * Determines if the node has an explicitly specified `tabindex` attribute.
486
- * @param {HTMLElement} node
487
- * @returns {boolean} True if so; false if not.
488
- */
489
- var hasTabIndex = function hasTabIndex(node) {
490
- return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
491
- };
492
-
493
- /**
494
- * Determine the tab index of a given node.
495
- * @param {HTMLElement} node
496
- * @returns {number} Tab order (negative, 0, or positive number).
497
- * @throws {Error} If `node` is falsy.
498
- */
499
- var getTabIndex = function getTabIndex(node) {
500
- if (!node) {
501
- throw new Error('No node provided');
502
- }
503
- if (node.tabIndex < 0) {
504
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
505
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
506
- // yet they are still part of the regular tab order; in FF, they get a default
507
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
508
- // order, consider their tab index to be 0.
509
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
510
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
511
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
512
- return 0;
513
- }
514
- }
515
- return node.tabIndex;
516
- };
517
-
518
- /**
519
- * Determine the tab index of a given node __for sort order purposes__.
520
- * @param {HTMLElement} node
521
- * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
522
- * has tabIndex -1, but needs to be sorted by document order in order for its content to be
523
- * inserted into the correct sort position.
524
- * @returns {number} Tab order (negative, 0, or positive number).
525
- */
526
- var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
527
- var tabIndex = getTabIndex(node);
528
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
529
- return 0;
530
- }
531
- return tabIndex;
532
- };
533
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
534
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
535
- };
536
- var isInput = function isInput(node) {
537
- return node.tagName === 'INPUT';
538
- };
539
- var isHiddenInput = function isHiddenInput(node) {
540
- return isInput(node) && node.type === 'hidden';
541
- };
542
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
543
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
544
- return child.tagName === 'SUMMARY';
545
- });
546
- return r;
547
- };
548
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
549
- for (var i = 0; i < nodes.length; i++) {
550
- if (nodes[i].checked && nodes[i].form === form) {
551
- return nodes[i];
552
- }
553
- }
554
- };
555
- var isTabbableRadio = function isTabbableRadio(node) {
556
- if (!node.name) {
557
- return true;
558
- }
559
- var radioScope = node.form || getRootNode(node);
560
- var queryRadios = function queryRadios(name) {
561
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
562
- };
563
- var radioSet;
564
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
565
- radioSet = queryRadios(window.CSS.escape(node.name));
566
- } else {
567
- try {
568
- radioSet = queryRadios(node.name);
569
- } catch (err) {
570
- // eslint-disable-next-line no-console
571
- console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
572
- return false;
573
- }
574
- }
575
- var checked = getCheckedRadio(radioSet, node.form);
576
- return !checked || checked === node;
577
- };
578
- var isRadio = function isRadio(node) {
579
- return isInput(node) && node.type === 'radio';
580
- };
581
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
582
- return isRadio(node) && !isTabbableRadio(node);
583
- };
584
-
585
- // determines if a node is ultimately attached to the window's document
586
- var isNodeAttached = function isNodeAttached(node) {
587
- var _nodeRoot;
588
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
589
- // (but NOT _the_ document; see second 'If' comment below for more).
590
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
591
- // is attached, and the one we need to check if it's in the document or not (because the
592
- // shadow, and all nodes it contains, is never considered in the document since shadows
593
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
594
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
595
- // visibility, including all the nodes it contains). The host could be any normal node,
596
- // or a custom element (i.e. web component). Either way, that's the one that is considered
597
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
598
- // tested).
599
- // To further complicate things, we have to look all the way up until we find a shadow HOST
600
- // that is attached (or find none) because the node might be in nested shadows...
601
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
602
- // document (per the docs) and while it's a Document-type object, that document does not
603
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
604
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
605
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
606
- // node is actually detached.
607
- // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
608
- // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
609
- // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
610
- // `ownerDocument` will be `null`, hence the optional chaining on it.
611
- var nodeRoot = node && getRootNode(node);
612
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
613
-
614
- // in some cases, a detached node will return itself as the root instead of a document or
615
- // shadow root object, in which case, we shouldn't try to look further up the host chain
616
- var attached = false;
617
- if (nodeRoot && nodeRoot !== node) {
618
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
619
- attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
620
- while (!attached && nodeRootHost) {
621
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
622
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
623
- // which means we need to get the host's host and check if that parent host is contained
624
- // in (i.e. attached to) the document
625
- nodeRoot = getRootNode(nodeRootHost);
626
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
627
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
628
- }
629
- }
630
- return attached;
631
- };
632
- var isZeroArea = function isZeroArea(node) {
633
- var _node$getBoundingClie = node.getBoundingClientRect(),
634
- width = _node$getBoundingClie.width,
635
- height = _node$getBoundingClie.height;
636
- return width === 0 && height === 0;
637
- };
638
- var isHidden = function isHidden(node, _ref) {
639
- var displayCheck = _ref.displayCheck,
640
- getShadowRoot = _ref.getShadowRoot;
641
- if (displayCheck === 'full-native') {
642
- if ('checkVisibility' in node) {
643
- // Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
644
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
645
- var visible = node.checkVisibility({
646
- // Checking opacity might be desirable for some use cases, but natively,
647
- // opacity zero elements _are_ focusable and tabbable.
648
- checkOpacity: false,
649
- opacityProperty: false,
650
- contentVisibilityAuto: true,
651
- visibilityProperty: true,
652
- // This is an alias for `visibilityProperty`. Contemporary browsers
653
- // support both. However, this alias has wider browser support (Chrome
654
- // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
655
- // we include it anyway.
656
- checkVisibilityCSS: true
657
- });
658
- return !visible;
659
- }
660
- // Fall through to manual visibility checks
661
- }
662
-
663
- // NOTE: visibility will be `undefined` if node is detached from the document
664
- // (see notes about this further down), which means we will consider it visible
665
- // (this is legacy behavior from a very long way back)
666
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
667
- // _visibility_ check, not a _display_ check
668
- if (getComputedStyle(node).visibility === 'hidden') {
669
- return true;
670
- }
671
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
672
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
673
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
674
- return true;
675
- }
676
- if (!displayCheck || displayCheck === 'full' ||
677
- // full-native can run this branch when it falls through in case
678
- // Element#checkVisibility is unsupported
679
- displayCheck === 'full-native' || displayCheck === 'legacy-full') {
680
- if (typeof getShadowRoot === 'function') {
681
- // figure out if we should consider the node to be in an undisclosed shadow and use the
682
- // 'non-zero-area' fallback
683
- var originalNode = node;
684
- while (node) {
685
- var parentElement = node.parentElement;
686
- var rootNode = getRootNode(node);
687
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
688
- ) {
689
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
690
- // fall back to a non-zero-area test
691
- return isZeroArea(node);
692
- } else if (node.assignedSlot) {
693
- // iterate up slot
694
- node = node.assignedSlot;
695
- } else if (!parentElement && rootNode !== node.ownerDocument) {
696
- // cross shadow boundary
697
- node = rootNode.host;
698
- } else {
699
- // iterate up normal dom
700
- node = parentElement;
701
- }
702
- }
703
- node = originalNode;
704
- }
705
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
706
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
707
- // it might be a falsy value, which means shadow DOM support is disabled
708
-
709
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
710
- // now we can just test to see if it would normally be visible or not, provided it's
711
- // attached to the main document.
712
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
713
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
714
-
715
- if (isNodeAttached(node)) {
716
- // this works wherever the node is: if there's at least one client rect, it's
717
- // somehow displayed; it also covers the CSS 'display: contents' case where the
718
- // node itself is hidden in place of its contents; and there's no need to search
719
- // up the hierarchy either
720
- return !node.getClientRects().length;
721
- }
722
-
723
- // Else, the node isn't attached to the document, which means the `getClientRects()`
724
- // API will __always__ return zero rects (this can happen, for example, if React
725
- // is used to render nodes onto a detached tree, as confirmed in this thread:
726
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
727
- //
728
- // It also means that even window.getComputedStyle(node).display will return `undefined`
729
- // because styles are only computed for nodes that are in the document.
730
- //
731
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
732
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
733
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
734
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
735
- // considering __everything__ to be visible because of the innability to determine styles.
736
- //
737
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
738
- // nodes as visible with the 'none' fallback.__
739
- if (displayCheck !== 'legacy-full') {
740
- return true; // hidden
741
- }
742
- // else, fallback to 'none' mode and consider the node visible
743
- } else if (displayCheck === 'non-zero-area') {
744
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
745
- // whether it's displayed, and that a detached node will __always__ have a zero-area
746
- // client rect, we don't special-case for whether the node is attached or not. In
747
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
748
- // times, and that includes attached or not.
749
- return isZeroArea(node);
750
- }
751
-
752
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
753
- // it's visible
754
- return false;
755
- };
756
-
757
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
758
- // unless they are in the _first_ <legend> element of the top-most disabled
759
- // fieldset
760
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
761
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
762
- var parentNode = node.parentElement;
763
- // check if `node` is contained in a disabled <fieldset>
764
- while (parentNode) {
765
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
766
- // look for the first <legend> among the children of the disabled <fieldset>
767
- for (var i = 0; i < parentNode.children.length; i++) {
768
- var child = parentNode.children.item(i);
769
- // when the first <legend> (in document order) is found
770
- if (child.tagName === 'LEGEND') {
771
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
772
- // return whether `node` is a descendant of its first <legend>
773
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
774
- }
775
- }
776
- // the disabled <fieldset> containing `node` has no <legend>
777
- return true;
778
- }
779
- parentNode = parentNode.parentElement;
780
- }
781
- }
782
-
783
- // else, node's tabbable/focusable state should not be affected by a fieldset's
784
- // enabled/disabled state
785
- return false;
786
- };
787
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
788
- if (node.disabled || isHiddenInput(node) || isHidden(node, options) ||
789
- // For a details element with a summary, the summary element gets the focus
790
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
791
- return false;
792
- }
793
- return true;
794
- };
795
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
796
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
797
- return false;
798
- }
799
- return true;
800
- };
801
- var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
802
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
803
- if (isNaN(tabIndex) || tabIndex >= 0) {
804
- return true;
805
- }
806
- // If a custom element has an explicit negative tabindex,
807
- // browsers will not allow tab targeting said element's children.
808
- return false;
809
- };
810
-
811
- /**
812
- * @param {Array.<Element|CandidateScope>} candidates
813
- * @returns Element[]
814
- */
815
- var _sortByOrder = function sortByOrder(candidates) {
816
- var regularTabbables = [];
817
- var orderedTabbables = [];
818
- candidates.forEach(function (item, i) {
819
- var isScope = !!item.scopeParent;
820
- var element = isScope ? item.scopeParent : item;
821
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
822
- var elements = isScope ? _sortByOrder(item.candidates) : element;
823
- if (candidateTabindex === 0) {
824
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
825
- } else {
826
- orderedTabbables.push({
827
- documentOrder: i,
828
- tabIndex: candidateTabindex,
829
- item: item,
830
- isScope: isScope,
831
- content: elements
832
- });
833
- }
834
- });
835
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
836
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
837
- return acc;
838
- }, []).concat(regularTabbables);
839
- };
840
- var tabbable = function tabbable(container, options) {
841
- options = options || {};
842
- var candidates;
843
- if (options.getShadowRoot) {
844
- candidates = _getCandidatesIteratively([container], options.includeContainer, {
845
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
846
- flatten: false,
847
- getShadowRoot: options.getShadowRoot,
848
- shadowRootFilter: isShadowRootTabbable
849
- });
850
- } else {
851
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
852
- }
853
- return _sortByOrder(candidates);
854
- };
855
- var focusable = function focusable(container, options) {
856
- options = options || {};
857
- var candidates;
858
- if (options.getShadowRoot) {
859
- candidates = _getCandidatesIteratively([container], options.includeContainer, {
860
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
861
- flatten: true,
862
- getShadowRoot: options.getShadowRoot
863
- });
864
- } else {
865
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
866
- }
867
- return candidates;
868
- };
869
- var isTabbable = function isTabbable(node, options) {
870
- options = options || {};
871
- if (!node) {
872
- throw new Error('No node provided');
873
- }
874
- if (matches.call(node, candidateSelector) === false) {
875
- return false;
876
- }
877
- return isNodeMatchingSelectorTabbable(options, node);
878
- };
879
-
880
6
  function computeCoordsFromPlacement(_ref, placement, rtl) {
881
7
  let {
882
8
  reference,
@@ -2943,4 +2069,4 @@ const arrow = (options, deps) => {
2943
2069
  };
2944
2070
  };
2945
2071
 
2946
- export { evaluate as A, getPaddingObject as B, getAlignmentAxis as C, getAlignment as D, getAxisLength as E, clamp as F, getSide as G, getSideAxis as H, isHTMLElement as a, isElement as b, isNode as c, getNodeName as d, isTabbable as e, floor as f, getOverflowAncestors as g, focusable as h, isShadowRoot as i, isLastTraversableNode as j, getParentNode as k, getComputedStyle$1 as l, isWebKit as m, flip as n, arrow as o, hide as p, autoUpdate as q, limitShift as r, shift as s, tabbable as t, useFloating as u, offset as v, autoPlacement as w, size as x, getWindow as y, isOverflowElement as z };
2072
+ export { arrow as a, autoUpdate as b, autoPlacement as c, size as d, flip as f, hide as h, limitShift as l, offset as o, shift as s, useFloating as u };