@jobber/components 8.23.0 → 8.23.1

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 (134) hide show
  1. package/dist/Autocomplete/index.cjs +1 -1
  2. package/dist/Autocomplete/index.mjs +1 -1
  3. package/dist/Card/index.cjs +4 -4
  4. package/dist/Card/index.mjs +4 -4
  5. package/dist/Chip/index.cjs +1 -1
  6. package/dist/Chip/index.mjs +1 -1
  7. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +1 -1
  8. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +1 -1
  9. package/dist/Chips/InternalChipDismissible/index.cjs +1 -1
  10. package/dist/Chips/InternalChipDismissible/index.mjs +1 -1
  11. package/dist/Chips/index.cjs +1 -1
  12. package/dist/Chips/index.mjs +1 -1
  13. package/dist/ComboboxChipRemove-cjs.js +668 -379
  14. package/dist/ComboboxChipRemove-es.js +508 -219
  15. package/dist/ConfirmationModal/index.cjs +1 -1
  16. package/dist/ConfirmationModal/index.mjs +1 -1
  17. package/dist/DataDump/index.cjs +4 -4
  18. package/dist/DataDump/index.mjs +4 -4
  19. package/dist/DataList/components/DataListActions/index.cjs +1 -1
  20. package/dist/DataList/components/DataListActions/index.mjs +1 -1
  21. package/dist/DataList/components/DataListBulkActions/index.cjs +1 -1
  22. package/dist/DataList/components/DataListBulkActions/index.mjs +1 -1
  23. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +1 -1
  24. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +1 -1
  25. package/dist/DataList/components/DataListFilters/index.cjs +1 -1
  26. package/dist/DataList/components/DataListFilters/index.mjs +1 -1
  27. package/dist/DataList/components/DataListHeader/index.cjs +1 -1
  28. package/dist/DataList/components/DataListHeader/index.mjs +1 -1
  29. package/dist/DataList/components/DataListItem/index.cjs +1 -1
  30. package/dist/DataList/components/DataListItem/index.mjs +1 -1
  31. package/dist/DataList/components/DataListItemActions/index.cjs +1 -1
  32. package/dist/DataList/components/DataListItemActions/index.mjs +1 -1
  33. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +1 -1
  34. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +1 -1
  35. package/dist/DataList/components/DataListItems/index.cjs +1 -1
  36. package/dist/DataList/components/DataListItems/index.mjs +1 -1
  37. package/dist/DataList/components/DataListLayout/index.cjs +1 -1
  38. package/dist/DataList/components/DataListLayout/index.mjs +1 -1
  39. package/dist/DataList/components/DataListLayoutActions/index.cjs +1 -1
  40. package/dist/DataList/components/DataListLayoutActions/index.mjs +1 -1
  41. package/dist/DataList/index.cjs +1 -1
  42. package/dist/DataList/index.mjs +1 -1
  43. package/dist/DatePicker/index.cjs +1 -1
  44. package/dist/DatePicker/index.mjs +1 -1
  45. package/dist/Dialog/index.cjs +3 -3
  46. package/dist/Dialog/index.mjs +3 -3
  47. package/dist/DrawerDescription-cjs.js +32 -33
  48. package/dist/DrawerDescription-es.js +19 -20
  49. package/dist/DrawerTitle-cjs.js +7 -5
  50. package/dist/DrawerTitle-es.js +7 -5
  51. package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +1 -1
  52. package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +1 -1
  53. package/dist/FilterPicker/components/FilterPickerContent/index.cjs +1 -1
  54. package/dist/FilterPicker/components/FilterPickerContent/index.mjs +1 -1
  55. package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +1 -1
  56. package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +1 -1
  57. package/dist/FilterPicker/index.cjs +1 -1
  58. package/dist/FilterPicker/index.mjs +1 -1
  59. package/dist/FormFieldWrapper-cjs.js +2 -2
  60. package/dist/FormFieldWrapper-es.js +2 -2
  61. package/dist/FormatFile/index.cjs +1 -1
  62. package/dist/FormatFile/index.mjs +1 -1
  63. package/dist/Gallery/index.cjs +1 -1
  64. package/dist/Gallery/index.mjs +1 -1
  65. package/dist/InputDate/index.cjs +1 -1
  66. package/dist/InputDate/index.mjs +1 -1
  67. package/dist/InputNumberExperimental-cjs.js +319 -102
  68. package/dist/InputNumberExperimental-es.js +321 -104
  69. package/dist/LightBox/index.cjs +1 -1
  70. package/dist/LightBox/index.mjs +1 -1
  71. package/dist/Menu/index.cjs +4 -4
  72. package/dist/Menu/index.mjs +4 -4
  73. package/dist/MenuSubmenuTrigger-cjs.js +545 -498
  74. package/dist/MenuSubmenuTrigger-es.js +490 -443
  75. package/dist/Modal/index.cjs +1 -1
  76. package/dist/Modal/index.mjs +1 -1
  77. package/dist/NumberFieldInput-cjs.js +609 -496
  78. package/dist/NumberFieldInput-es.js +612 -498
  79. package/dist/Page/index.cjs +4 -4
  80. package/dist/Page/index.mjs +4 -4
  81. package/dist/Popover/index.cjs +1 -1
  82. package/dist/Popover/index.mjs +1 -1
  83. package/dist/ScrollAreaViewport-cjs.js +326 -601
  84. package/dist/ScrollAreaViewport-es.js +278 -548
  85. package/dist/SelectGroupLabel-cjs.js +494 -528
  86. package/dist/SelectGroupLabel-es.js +411 -445
  87. package/dist/Separator-cjs.js +1 -0
  88. package/dist/Separator-es.js +1 -0
  89. package/dist/Tooltip/index.cjs +1 -1
  90. package/dist/Tooltip/index.mjs +1 -1
  91. package/dist/docs/InputTime/InputTime.md +8 -0
  92. package/dist/docs/SelectPrimitive/SelectPrimitive.md +38 -25
  93. package/dist/floating-ui.react-cjs.js +586 -10
  94. package/dist/floating-ui.react-dom-cjs.js +92 -92
  95. package/dist/floating-ui.react-dom-es.js +1 -1
  96. package/dist/floating-ui.react-es.js +580 -4
  97. package/dist/floating-ui.utils-cjs.js +159 -0
  98. package/dist/floating-ui.utils-es.js +136 -0
  99. package/dist/index.cjs +4 -4
  100. package/dist/index.mjs +4 -4
  101. package/dist/{ToolbarRootContext-cjs.js → isElementDisabled-cjs.js} +5 -0
  102. package/dist/{ToolbarRootContext-es.js → isElementDisabled-es.js} +5 -1
  103. package/dist/primitives/BottomSheet/index.cjs +3 -3
  104. package/dist/primitives/BottomSheet/index.mjs +3 -3
  105. package/dist/primitives/ComboboxPrimitive/index.cjs +2 -2
  106. package/dist/primitives/ComboboxPrimitive/index.mjs +2 -2
  107. package/dist/primitives/InputNumberExperimental/index.cjs +1 -1
  108. package/dist/primitives/InputNumberExperimental/index.mjs +1 -1
  109. package/dist/primitives/SelectPrimitive/index.cjs +5 -5
  110. package/dist/primitives/SelectPrimitive/index.mjs +5 -5
  111. package/dist/primitives/index.cjs +4 -4
  112. package/dist/primitives/index.mjs +4 -4
  113. package/dist/resolveAriaLabelledBy-cjs.js +5 -0
  114. package/dist/resolveAriaLabelledBy-es.js +5 -1
  115. package/dist/{CSPContext-cjs.js → scrollEdges-cjs.js} +30 -2
  116. package/dist/{CSPContext-es.js → scrollEdges-es.js} +28 -3
  117. package/dist/styles.css +9 -3
  118. package/dist/unstyledPrimitives/index.cjs +1217 -639
  119. package/dist/unstyledPrimitives/index.mjs +1163 -585
  120. package/dist/useButton-cjs.js +283 -317
  121. package/dist/useButton-es.js +277 -298
  122. package/dist/useCompositeListItem-cjs.js +328 -279
  123. package/dist/useCompositeListItem-es.js +293 -246
  124. package/dist/useLabel-cjs.js +11 -1
  125. package/dist/useLabel-es.js +11 -2
  126. package/dist/useLabelableId-cjs.js +37 -91
  127. package/dist/useLabelableId-es.js +37 -90
  128. package/dist/useRenderElement-cjs.js +81 -26
  129. package/dist/useRenderElement-es.js +81 -27
  130. package/dist/{InternalBackdrop-cjs.js → useScrollLock-cjs.js} +1286 -1220
  131. package/dist/{InternalBackdrop-es.js → useScrollLock-es.js} +1250 -1207
  132. package/package.json +3 -3
  133. package/dist/index.esm-cjs.js +0 -738
  134. package/dist/index.esm-es.js +0 -712
@@ -2,7 +2,7 @@
2
2
 
3
3
  var React = require('react');
4
4
  var floatingUi_utils_dom = require('./floating-ui.utils.dom-cjs.js');
5
- var index_esm = require('./index.esm-cjs.js');
5
+ var floatingUi_utils = require('./floating-ui.utils-cjs.js');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var ReactDOM = require('react-dom');
8
8
  var floatingUi_reactDom = require('./floating-ui.react-dom-cjs.js');
@@ -27,6 +27,582 @@ function _interopNamespaceDefault(e) {
27
27
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
28
28
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
29
29
 
30
+ /*!
31
+ * tabbable 6.4.0
32
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
33
+ */
34
+ // NOTE: separate `:not()` selectors has broader browser support than the newer
35
+ // `:not([inert], [inert] *)` (Feb 2023)
36
+ 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] *)'];
37
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
38
+ var NoElement = typeof Element === 'undefined';
39
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
40
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
41
+ var _element$getRootNode;
42
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
43
+ } : function (element) {
44
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
45
+ };
46
+
47
+ /**
48
+ * Determines if a node is inert or in an inert ancestor.
49
+ * @param {Node} [node]
50
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
51
+ * see if any of them are inert. If false, only `node` itself is considered.
52
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
53
+ * False if `node` is falsy.
54
+ */
55
+ var _isInert = function isInert(node, lookUp) {
56
+ var _node$getAttribute;
57
+ if (lookUp === void 0) {
58
+ lookUp = true;
59
+ }
60
+ // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
61
+ // JS API property; we have to check the attribute, which can either be empty or 'true';
62
+ // if it's `null` (not specified) or 'false', it's an active element
63
+ 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');
64
+ var inert = inertAtt === '' || inertAtt === 'true';
65
+
66
+ // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
67
+ // if it weren't for `matches()` not being a function on shadow roots; the following
68
+ // code works for any kind of node
69
+ var result = inert || lookUp && node && (
70
+ // closest does not exist on shadow roots, so we fall back to a manual
71
+ // lookup upward, in case it is not defined.
72
+ typeof node.closest === 'function' ? node.closest('[inert]') : _isInert(node.parentNode));
73
+ return result;
74
+ };
75
+
76
+ /**
77
+ * Determines if a node's content is editable.
78
+ * @param {Element} [node]
79
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
80
+ */
81
+ var isContentEditable = function isContentEditable(node) {
82
+ var _node$getAttribute2;
83
+ // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
84
+ // to use the attribute directly to check for this, which can either be empty or 'true';
85
+ // if it's `null` (not specified) or 'false', it's a non-editable element
86
+ 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');
87
+ return attValue === '' || attValue === 'true';
88
+ };
89
+
90
+ /**
91
+ * @param {Element} el container to check in
92
+ * @param {boolean} includeContainer add container to check
93
+ * @param {(node: Element) => boolean} filter filter candidates
94
+ * @returns {Element[]}
95
+ */
96
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
97
+ // even if `includeContainer=false`, we still have to check it for inertness because
98
+ // if it's inert (either by itself or via its parent), then all its children are inert
99
+ if (_isInert(el)) {
100
+ return [];
101
+ }
102
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
103
+ if (includeContainer && matches.call(el, candidateSelector)) {
104
+ candidates.unshift(el);
105
+ }
106
+ candidates = candidates.filter(filter);
107
+ return candidates;
108
+ };
109
+
110
+ /**
111
+ * @callback GetShadowRoot
112
+ * @param {Element} element to check for shadow root
113
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
114
+ */
115
+
116
+ /**
117
+ * @callback ShadowRootFilter
118
+ * @param {Element} shadowHostNode the element which contains shadow content
119
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
120
+ */
121
+
122
+ /**
123
+ * @typedef {Object} CandidateScope
124
+ * @property {Element} scopeParent contains inner candidates
125
+ * @property {Element[]} candidates list of candidates found in the scope parent
126
+ */
127
+
128
+ /**
129
+ * @typedef {Object} IterativeOptions
130
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
131
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
132
+ * or a boolean stating if it has an undisclosed shadow root
133
+ * @property {(node: Element) => boolean} filter filter candidates
134
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
135
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
136
+ */
137
+
138
+ /**
139
+ * @param {Element[]} elements list of element containers to match candidates from
140
+ * @param {boolean} includeContainer add container list to check
141
+ * @param {IterativeOptions} options
142
+ * @returns {Array.<Element|CandidateScope>}
143
+ */
144
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
145
+ var candidates = [];
146
+ var elementsToCheck = Array.from(elements);
147
+ while (elementsToCheck.length) {
148
+ var element = elementsToCheck.shift();
149
+ if (_isInert(element, false)) {
150
+ // no need to look up since we're drilling down
151
+ // anything inside this container will also be inert
152
+ continue;
153
+ }
154
+ if (element.tagName === 'SLOT') {
155
+ // add shadow dom slot scope (slot itself cannot be focusable)
156
+ var assigned = element.assignedElements();
157
+ var content = assigned.length ? assigned : element.children;
158
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
159
+ if (options.flatten) {
160
+ candidates.push.apply(candidates, nestedCandidates);
161
+ } else {
162
+ candidates.push({
163
+ scopeParent: element,
164
+ candidates: nestedCandidates
165
+ });
166
+ }
167
+ } else {
168
+ // check candidate element
169
+ var validCandidate = matches.call(element, candidateSelector);
170
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
171
+ candidates.push(element);
172
+ }
173
+
174
+ // iterate over shadow content if possible
175
+ var shadowRoot = element.shadowRoot ||
176
+ // check for an undisclosed shadow
177
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
178
+
179
+ // no inert look up because we're already drilling down and checking for inertness
180
+ // on the way down, so all containers to this root node should have already been
181
+ // vetted as non-inert
182
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
183
+ if (shadowRoot && validShadowRoot) {
184
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
185
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
186
+ // child candidates found because they're likely slotted elements (elements that are
187
+ // children of the web component element (which has the shadow), in the light dom, but
188
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
189
+ // _after_ we return from this recursive call
190
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
191
+ if (options.flatten) {
192
+ candidates.push.apply(candidates, _nestedCandidates);
193
+ } else {
194
+ candidates.push({
195
+ scopeParent: element,
196
+ candidates: _nestedCandidates
197
+ });
198
+ }
199
+ } else {
200
+ // there's not shadow so just dig into the element's (light dom) children
201
+ // __without__ giving the element special scope treatment
202
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
203
+ }
204
+ }
205
+ }
206
+ return candidates;
207
+ };
208
+
209
+ /**
210
+ * @private
211
+ * Determines if the node has an explicitly specified `tabindex` attribute.
212
+ * @param {HTMLElement} node
213
+ * @returns {boolean} True if so; false if not.
214
+ */
215
+ var hasTabIndex = function hasTabIndex(node) {
216
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
217
+ };
218
+
219
+ /**
220
+ * Determine the tab index of a given node.
221
+ * @param {HTMLElement} node
222
+ * @returns {number} Tab order (negative, 0, or positive number).
223
+ * @throws {Error} If `node` is falsy.
224
+ */
225
+ var getTabIndex = function getTabIndex(node) {
226
+ if (!node) {
227
+ throw new Error('No node provided');
228
+ }
229
+ if (node.tabIndex < 0) {
230
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
231
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
232
+ // yet they are still part of the regular tab order; in FF, they get a default
233
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
234
+ // order, consider their tab index to be 0.
235
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
236
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
237
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
238
+ return 0;
239
+ }
240
+ }
241
+ return node.tabIndex;
242
+ };
243
+
244
+ /**
245
+ * Determine the tab index of a given node __for sort order purposes__.
246
+ * @param {HTMLElement} node
247
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
248
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
249
+ * inserted into the correct sort position.
250
+ * @returns {number} Tab order (negative, 0, or positive number).
251
+ */
252
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
253
+ var tabIndex = getTabIndex(node);
254
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
255
+ return 0;
256
+ }
257
+ return tabIndex;
258
+ };
259
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
260
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
261
+ };
262
+ var isInput = function isInput(node) {
263
+ return node.tagName === 'INPUT';
264
+ };
265
+ var isHiddenInput = function isHiddenInput(node) {
266
+ return isInput(node) && node.type === 'hidden';
267
+ };
268
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
269
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
270
+ return child.tagName === 'SUMMARY';
271
+ });
272
+ return r;
273
+ };
274
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
275
+ for (var i = 0; i < nodes.length; i++) {
276
+ if (nodes[i].checked && nodes[i].form === form) {
277
+ return nodes[i];
278
+ }
279
+ }
280
+ };
281
+ var isTabbableRadio = function isTabbableRadio(node) {
282
+ if (!node.name) {
283
+ return true;
284
+ }
285
+ var radioScope = node.form || getRootNode(node);
286
+ var queryRadios = function queryRadios(name) {
287
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
288
+ };
289
+ var radioSet;
290
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
291
+ radioSet = queryRadios(window.CSS.escape(node.name));
292
+ } else {
293
+ try {
294
+ radioSet = queryRadios(node.name);
295
+ } catch (err) {
296
+ // eslint-disable-next-line no-console
297
+ 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);
298
+ return false;
299
+ }
300
+ }
301
+ var checked = getCheckedRadio(radioSet, node.form);
302
+ return !checked || checked === node;
303
+ };
304
+ var isRadio = function isRadio(node) {
305
+ return isInput(node) && node.type === 'radio';
306
+ };
307
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
308
+ return isRadio(node) && !isTabbableRadio(node);
309
+ };
310
+
311
+ // determines if a node is ultimately attached to the window's document
312
+ var isNodeAttached = function isNodeAttached(node) {
313
+ var _nodeRoot;
314
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
315
+ // (but NOT _the_ document; see second 'If' comment below for more).
316
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
317
+ // is attached, and the one we need to check if it's in the document or not (because the
318
+ // shadow, and all nodes it contains, is never considered in the document since shadows
319
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
320
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
321
+ // visibility, including all the nodes it contains). The host could be any normal node,
322
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
323
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
324
+ // tested).
325
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
326
+ // that is attached (or find none) because the node might be in nested shadows...
327
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
328
+ // document (per the docs) and while it's a Document-type object, that document does not
329
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
330
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
331
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
332
+ // node is actually detached.
333
+ // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
334
+ // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
335
+ // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
336
+ // `ownerDocument` will be `null`, hence the optional chaining on it.
337
+ var nodeRoot = node && getRootNode(node);
338
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
339
+
340
+ // in some cases, a detached node will return itself as the root instead of a document or
341
+ // shadow root object, in which case, we shouldn't try to look further up the host chain
342
+ var attached = false;
343
+ if (nodeRoot && nodeRoot !== node) {
344
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
345
+ 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));
346
+ while (!attached && nodeRootHost) {
347
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
348
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
349
+ // which means we need to get the host's host and check if that parent host is contained
350
+ // in (i.e. attached to) the document
351
+ nodeRoot = getRootNode(nodeRootHost);
352
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
353
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
354
+ }
355
+ }
356
+ return attached;
357
+ };
358
+ var isZeroArea = function isZeroArea(node) {
359
+ var _node$getBoundingClie = node.getBoundingClientRect(),
360
+ width = _node$getBoundingClie.width,
361
+ height = _node$getBoundingClie.height;
362
+ return width === 0 && height === 0;
363
+ };
364
+ var isHidden = function isHidden(node, _ref) {
365
+ var displayCheck = _ref.displayCheck,
366
+ getShadowRoot = _ref.getShadowRoot;
367
+ if (displayCheck === 'full-native') {
368
+ if ('checkVisibility' in node) {
369
+ // Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
370
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
371
+ var visible = node.checkVisibility({
372
+ // Checking opacity might be desirable for some use cases, but natively,
373
+ // opacity zero elements _are_ focusable and tabbable.
374
+ checkOpacity: false,
375
+ opacityProperty: false,
376
+ contentVisibilityAuto: true,
377
+ visibilityProperty: true,
378
+ // This is an alias for `visibilityProperty`. Contemporary browsers
379
+ // support both. However, this alias has wider browser support (Chrome
380
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
381
+ // we include it anyway.
382
+ checkVisibilityCSS: true
383
+ });
384
+ return !visible;
385
+ }
386
+ // Fall through to manual visibility checks
387
+ }
388
+
389
+ // NOTE: visibility will be `undefined` if node is detached from the document
390
+ // (see notes about this further down), which means we will consider it visible
391
+ // (this is legacy behavior from a very long way back)
392
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
393
+ // _visibility_ check, not a _display_ check
394
+ if (getComputedStyle(node).visibility === 'hidden') {
395
+ return true;
396
+ }
397
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
398
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
399
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
400
+ return true;
401
+ }
402
+ if (!displayCheck || displayCheck === 'full' ||
403
+ // full-native can run this branch when it falls through in case
404
+ // Element#checkVisibility is unsupported
405
+ displayCheck === 'full-native' || displayCheck === 'legacy-full') {
406
+ if (typeof getShadowRoot === 'function') {
407
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
408
+ // 'non-zero-area' fallback
409
+ var originalNode = node;
410
+ while (node) {
411
+ var parentElement = node.parentElement;
412
+ var rootNode = getRootNode(node);
413
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
414
+ ) {
415
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
416
+ // fall back to a non-zero-area test
417
+ return isZeroArea(node);
418
+ } else if (node.assignedSlot) {
419
+ // iterate up slot
420
+ node = node.assignedSlot;
421
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
422
+ // cross shadow boundary
423
+ node = rootNode.host;
424
+ } else {
425
+ // iterate up normal dom
426
+ node = parentElement;
427
+ }
428
+ }
429
+ node = originalNode;
430
+ }
431
+ // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
432
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
433
+ // it might be a falsy value, which means shadow DOM support is disabled
434
+
435
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
436
+ // now we can just test to see if it would normally be visible or not, provided it's
437
+ // attached to the main document.
438
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
439
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
440
+
441
+ if (isNodeAttached(node)) {
442
+ // this works wherever the node is: if there's at least one client rect, it's
443
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
444
+ // node itself is hidden in place of its contents; and there's no need to search
445
+ // up the hierarchy either
446
+ return !node.getClientRects().length;
447
+ }
448
+
449
+ // Else, the node isn't attached to the document, which means the `getClientRects()`
450
+ // API will __always__ return zero rects (this can happen, for example, if React
451
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
452
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
453
+ //
454
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
455
+ // because styles are only computed for nodes that are in the document.
456
+ //
457
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
458
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
459
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
460
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
461
+ // considering __everything__ to be visible because of the innability to determine styles.
462
+ //
463
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
464
+ // nodes as visible with the 'none' fallback.__
465
+ if (displayCheck !== 'legacy-full') {
466
+ return true; // hidden
467
+ }
468
+ // else, fallback to 'none' mode and consider the node visible
469
+ } else if (displayCheck === 'non-zero-area') {
470
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
471
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
472
+ // client rect, we don't special-case for whether the node is attached or not. In
473
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
474
+ // times, and that includes attached or not.
475
+ return isZeroArea(node);
476
+ }
477
+
478
+ // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
479
+ // it's visible
480
+ return false;
481
+ };
482
+
483
+ // form fields (nested) inside a disabled fieldset are not focusable/tabbable
484
+ // unless they are in the _first_ <legend> element of the top-most disabled
485
+ // fieldset
486
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
487
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
488
+ var parentNode = node.parentElement;
489
+ // check if `node` is contained in a disabled <fieldset>
490
+ while (parentNode) {
491
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
492
+ // look for the first <legend> among the children of the disabled <fieldset>
493
+ for (var i = 0; i < parentNode.children.length; i++) {
494
+ var child = parentNode.children.item(i);
495
+ // when the first <legend> (in document order) is found
496
+ if (child.tagName === 'LEGEND') {
497
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
498
+ // return whether `node` is a descendant of its first <legend>
499
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
500
+ }
501
+ }
502
+ // the disabled <fieldset> containing `node` has no <legend>
503
+ return true;
504
+ }
505
+ parentNode = parentNode.parentElement;
506
+ }
507
+ }
508
+
509
+ // else, node's tabbable/focusable state should not be affected by a fieldset's
510
+ // enabled/disabled state
511
+ return false;
512
+ };
513
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
514
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) ||
515
+ // For a details element with a summary, the summary element gets the focus
516
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
517
+ return false;
518
+ }
519
+ return true;
520
+ };
521
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
522
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
523
+ return false;
524
+ }
525
+ return true;
526
+ };
527
+ var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
528
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
529
+ if (isNaN(tabIndex) || tabIndex >= 0) {
530
+ return true;
531
+ }
532
+ // If a custom element has an explicit negative tabindex,
533
+ // browsers will not allow tab targeting said element's children.
534
+ return false;
535
+ };
536
+
537
+ /**
538
+ * @param {Array.<Element|CandidateScope>} candidates
539
+ * @returns Element[]
540
+ */
541
+ var _sortByOrder = function sortByOrder(candidates) {
542
+ var regularTabbables = [];
543
+ var orderedTabbables = [];
544
+ candidates.forEach(function (item, i) {
545
+ var isScope = !!item.scopeParent;
546
+ var element = isScope ? item.scopeParent : item;
547
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
548
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
549
+ if (candidateTabindex === 0) {
550
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
551
+ } else {
552
+ orderedTabbables.push({
553
+ documentOrder: i,
554
+ tabIndex: candidateTabindex,
555
+ item: item,
556
+ isScope: isScope,
557
+ content: elements
558
+ });
559
+ }
560
+ });
561
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
562
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
563
+ return acc;
564
+ }, []).concat(regularTabbables);
565
+ };
566
+ var tabbable = function tabbable(container, options) {
567
+ options = options || {};
568
+ var candidates;
569
+ if (options.getShadowRoot) {
570
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
571
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
572
+ flatten: false,
573
+ getShadowRoot: options.getShadowRoot,
574
+ shadowRootFilter: isShadowRootTabbable
575
+ });
576
+ } else {
577
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
578
+ }
579
+ return _sortByOrder(candidates);
580
+ };
581
+ var focusable = function focusable(container, options) {
582
+ options = options || {};
583
+ var candidates;
584
+ if (options.getShadowRoot) {
585
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
586
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
587
+ flatten: true,
588
+ getShadowRoot: options.getShadowRoot
589
+ });
590
+ } else {
591
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
592
+ }
593
+ return candidates;
594
+ };
595
+ var isTabbable = function isTabbable(node, options) {
596
+ options = options || {};
597
+ if (!node) {
598
+ throw new Error('No node provided');
599
+ }
600
+ if (matches.call(node, candidateSelector) === false) {
601
+ return false;
602
+ }
603
+ return isNodeMatchingSelectorTabbable(options, node);
604
+ };
605
+
30
606
  // Avoid Chrome DevTools blue warning.
31
607
  function getPlatform() {
32
608
  const uaData = navigator.userAgentData;
@@ -351,7 +927,7 @@ function getGridNavigatedIndex(listRef, _ref) {
351
927
 
352
928
  // Remains on the same row/column.
353
929
  if (orientation === 'both') {
354
- const prevRow = index_esm.floor(prevIndex / cols);
930
+ const prevRow = floatingUi_utils.floor(prevIndex / cols);
355
931
  if (event.key === (rtl ? ARROW_LEFT$1 : ARROW_RIGHT$1)) {
356
932
  stop && stopEvent(event);
357
933
  if (prevIndex % cols !== cols - 1) {
@@ -401,7 +977,7 @@ function getGridNavigatedIndex(listRef, _ref) {
401
977
  nextIndex = prevIndex;
402
978
  }
403
979
  }
404
- const lastRow = index_esm.floor(maxIndex / cols) === prevRow;
980
+ const lastRow = floatingUi_utils.floor(maxIndex / cols) === prevRow;
405
981
  if (isIndexOutOfListBounds(listRef, nextIndex)) {
406
982
  if (loop && lastRow) {
407
983
  nextIndex = event.key === (rtl ? ARROW_RIGHT$1 : ARROW_LEFT$1) ? maxIndex : findNonDisabledListIndex(listRef, {
@@ -502,7 +1078,7 @@ const getTabbableOptions = () => ({
502
1078
  typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
503
1079
  });
504
1080
  function getTabbableIn(container, dir) {
505
- const list = index_esm.tabbable(container, getTabbableOptions());
1081
+ const list = tabbable(container, getTabbableOptions());
506
1082
  const len = list.length;
507
1083
  if (len === 0) return;
508
1084
  const active = activeElement(getDocument$1(container));
@@ -522,7 +1098,7 @@ function isOutsideEvent(event, container) {
522
1098
  return !relatedTarget || !contains(containerElement, relatedTarget);
523
1099
  }
524
1100
  function disableFocusInside(container) {
525
- const tabbableElements = index_esm.tabbable(container, getTabbableOptions());
1101
+ const tabbableElements = tabbable(container, getTabbableOptions());
526
1102
  tabbableElements.forEach(element => {
527
1103
  element.dataset.tabindex = element.getAttribute('tabindex') || '';
528
1104
  element.setAttribute('tabindex', '-1');
@@ -1239,10 +1815,10 @@ function getPreviouslyFocusedElement() {
1239
1815
  }
1240
1816
  function getFirstTabbableElement(container) {
1241
1817
  const tabbableOptions = getTabbableOptions();
1242
- if (index_esm.isTabbable(container, tabbableOptions)) {
1818
+ if (isTabbable(container, tabbableOptions)) {
1243
1819
  return container;
1244
1820
  }
1245
- return index_esm.tabbable(container, tabbableOptions)[0] || container;
1821
+ return tabbable(container, tabbableOptions)[0] || container;
1246
1822
  }
1247
1823
  function handleTabIndex(floatingFocusElement, orderRef) {
1248
1824
  var _floatingFocusElement;
@@ -1250,10 +1826,10 @@ function handleTabIndex(floatingFocusElement, orderRef) {
1250
1826
  return;
1251
1827
  }
1252
1828
  const options = getTabbableOptions();
1253
- const focusableElements = index_esm.focusable(floatingFocusElement, options);
1829
+ const focusableElements = focusable(floatingFocusElement, options);
1254
1830
  const tabbableContent = focusableElements.filter(element => {
1255
1831
  const dataTabIndex = element.getAttribute('data-tabindex') || '';
1256
- return index_esm.isTabbable(element, options) || element.hasAttribute('data-tabindex') && !dataTabIndex.startsWith('-');
1832
+ return isTabbable(element, options) || element.hasAttribute('data-tabindex') && !dataTabIndex.startsWith('-');
1257
1833
  });
1258
1834
  const tabIndex = floatingFocusElement.getAttribute('tabindex');
1259
1835
  if (orderRef.current.includes('floating') || tabbableContent.length === 0) {
@@ -1338,7 +1914,7 @@ function FloatingFocusManager(props) {
1338
1914
  if (container === void 0) {
1339
1915
  container = floatingFocusElement;
1340
1916
  }
1341
- return container ? index_esm.tabbable(container, getTabbableOptions()) : [];
1917
+ return container ? tabbable(container, getTabbableOptions()) : [];
1342
1918
  });
1343
1919
  const getTabbableElements = useEffectEvent(container => {
1344
1920
  const content = getTabbableContent(container);