@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
@@ -1,738 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Custom positioning reference element.
5
- * @see https://floating-ui.com/docs/virtual-elements
6
- */
7
-
8
- const sides = ['top', 'right', 'bottom', 'left'];
9
- const alignments = ['start', 'end'];
10
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
11
- const min = Math.min;
12
- const max = Math.max;
13
- const round = Math.round;
14
- const floor = Math.floor;
15
- const createCoords = v => ({
16
- x: v,
17
- y: v
18
- });
19
- const oppositeSideMap = {
20
- left: 'right',
21
- right: 'left',
22
- bottom: 'top',
23
- top: 'bottom'
24
- };
25
- function clamp(start, value, end) {
26
- return max(start, min(value, end));
27
- }
28
- function evaluate(value, param) {
29
- return typeof value === 'function' ? value(param) : value;
30
- }
31
- function getSide(placement) {
32
- return placement.split('-')[0];
33
- }
34
- function getAlignment(placement) {
35
- return placement.split('-')[1];
36
- }
37
- function getOppositeAxis(axis) {
38
- return axis === 'x' ? 'y' : 'x';
39
- }
40
- function getAxisLength(axis) {
41
- return axis === 'y' ? 'height' : 'width';
42
- }
43
- function getSideAxis(placement) {
44
- const firstChar = placement[0];
45
- return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
46
- }
47
- function getAlignmentAxis(placement) {
48
- return getOppositeAxis(getSideAxis(placement));
49
- }
50
- function getAlignmentSides(placement, rects, rtl) {
51
- if (rtl === void 0) {
52
- rtl = false;
53
- }
54
- const alignment = getAlignment(placement);
55
- const alignmentAxis = getAlignmentAxis(placement);
56
- const length = getAxisLength(alignmentAxis);
57
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
58
- if (rects.reference[length] > rects.floating[length]) {
59
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
60
- }
61
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
62
- }
63
- function getExpandedPlacements(placement) {
64
- const oppositePlacement = getOppositePlacement(placement);
65
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
66
- }
67
- function getOppositeAlignmentPlacement(placement) {
68
- return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
69
- }
70
- const lrPlacement = ['left', 'right'];
71
- const rlPlacement = ['right', 'left'];
72
- const tbPlacement = ['top', 'bottom'];
73
- const btPlacement = ['bottom', 'top'];
74
- function getSideList(side, isStart, rtl) {
75
- switch (side) {
76
- case 'top':
77
- case 'bottom':
78
- if (rtl) return isStart ? rlPlacement : lrPlacement;
79
- return isStart ? lrPlacement : rlPlacement;
80
- case 'left':
81
- case 'right':
82
- return isStart ? tbPlacement : btPlacement;
83
- default:
84
- return [];
85
- }
86
- }
87
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
88
- const alignment = getAlignment(placement);
89
- let list = getSideList(getSide(placement), direction === 'start', rtl);
90
- if (alignment) {
91
- list = list.map(side => side + "-" + alignment);
92
- if (flipAlignment) {
93
- list = list.concat(list.map(getOppositeAlignmentPlacement));
94
- }
95
- }
96
- return list;
97
- }
98
- function getOppositePlacement(placement) {
99
- const side = getSide(placement);
100
- return oppositeSideMap[side] + placement.slice(side.length);
101
- }
102
- function expandPaddingObject(padding) {
103
- return {
104
- top: 0,
105
- right: 0,
106
- bottom: 0,
107
- left: 0,
108
- ...padding
109
- };
110
- }
111
- function getPaddingObject(padding) {
112
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
113
- top: padding,
114
- right: padding,
115
- bottom: padding,
116
- left: padding
117
- };
118
- }
119
- function rectToClientRect(rect) {
120
- const {
121
- x,
122
- y,
123
- width,
124
- height
125
- } = rect;
126
- return {
127
- width,
128
- height,
129
- top: y,
130
- left: x,
131
- right: x + width,
132
- bottom: y + height,
133
- x,
134
- y
135
- };
136
- }
137
-
138
- /*!
139
- * tabbable 6.4.0
140
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
141
- */
142
- // NOTE: separate `:not()` selectors has broader browser support than the newer
143
- // `:not([inert], [inert] *)` (Feb 2023)
144
- 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] *)'];
145
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
146
- var NoElement = typeof Element === 'undefined';
147
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
148
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
149
- var _element$getRootNode;
150
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
151
- } : function (element) {
152
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
153
- };
154
-
155
- /**
156
- * Determines if a node is inert or in an inert ancestor.
157
- * @param {Node} [node]
158
- * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
159
- * see if any of them are inert. If false, only `node` itself is considered.
160
- * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
161
- * False if `node` is falsy.
162
- */
163
- var _isInert = function isInert(node, lookUp) {
164
- var _node$getAttribute;
165
- if (lookUp === void 0) {
166
- lookUp = true;
167
- }
168
- // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
169
- // JS API property; we have to check the attribute, which can either be empty or 'true';
170
- // if it's `null` (not specified) or 'false', it's an active element
171
- 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');
172
- var inert = inertAtt === '' || inertAtt === 'true';
173
-
174
- // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
175
- // if it weren't for `matches()` not being a function on shadow roots; the following
176
- // code works for any kind of node
177
- var result = inert || lookUp && node && (
178
- // closest does not exist on shadow roots, so we fall back to a manual
179
- // lookup upward, in case it is not defined.
180
- typeof node.closest === 'function' ? node.closest('[inert]') : _isInert(node.parentNode));
181
- return result;
182
- };
183
-
184
- /**
185
- * Determines if a node's content is editable.
186
- * @param {Element} [node]
187
- * @returns True if it's content-editable; false if it's not or `node` is falsy.
188
- */
189
- var isContentEditable = function isContentEditable(node) {
190
- var _node$getAttribute2;
191
- // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
192
- // to use the attribute directly to check for this, which can either be empty or 'true';
193
- // if it's `null` (not specified) or 'false', it's a non-editable element
194
- 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');
195
- return attValue === '' || attValue === 'true';
196
- };
197
-
198
- /**
199
- * @param {Element} el container to check in
200
- * @param {boolean} includeContainer add container to check
201
- * @param {(node: Element) => boolean} filter filter candidates
202
- * @returns {Element[]}
203
- */
204
- var getCandidates = function getCandidates(el, includeContainer, filter) {
205
- // even if `includeContainer=false`, we still have to check it for inertness because
206
- // if it's inert (either by itself or via its parent), then all its children are inert
207
- if (_isInert(el)) {
208
- return [];
209
- }
210
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
211
- if (includeContainer && matches.call(el, candidateSelector)) {
212
- candidates.unshift(el);
213
- }
214
- candidates = candidates.filter(filter);
215
- return candidates;
216
- };
217
-
218
- /**
219
- * @callback GetShadowRoot
220
- * @param {Element} element to check for shadow root
221
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
222
- */
223
-
224
- /**
225
- * @callback ShadowRootFilter
226
- * @param {Element} shadowHostNode the element which contains shadow content
227
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
228
- */
229
-
230
- /**
231
- * @typedef {Object} CandidateScope
232
- * @property {Element} scopeParent contains inner candidates
233
- * @property {Element[]} candidates list of candidates found in the scope parent
234
- */
235
-
236
- /**
237
- * @typedef {Object} IterativeOptions
238
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
239
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
240
- * or a boolean stating if it has an undisclosed shadow root
241
- * @property {(node: Element) => boolean} filter filter candidates
242
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
243
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
244
- */
245
-
246
- /**
247
- * @param {Element[]} elements list of element containers to match candidates from
248
- * @param {boolean} includeContainer add container list to check
249
- * @param {IterativeOptions} options
250
- * @returns {Array.<Element|CandidateScope>}
251
- */
252
- var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
253
- var candidates = [];
254
- var elementsToCheck = Array.from(elements);
255
- while (elementsToCheck.length) {
256
- var element = elementsToCheck.shift();
257
- if (_isInert(element, false)) {
258
- // no need to look up since we're drilling down
259
- // anything inside this container will also be inert
260
- continue;
261
- }
262
- if (element.tagName === 'SLOT') {
263
- // add shadow dom slot scope (slot itself cannot be focusable)
264
- var assigned = element.assignedElements();
265
- var content = assigned.length ? assigned : element.children;
266
- var nestedCandidates = _getCandidatesIteratively(content, true, options);
267
- if (options.flatten) {
268
- candidates.push.apply(candidates, nestedCandidates);
269
- } else {
270
- candidates.push({
271
- scopeParent: element,
272
- candidates: nestedCandidates
273
- });
274
- }
275
- } else {
276
- // check candidate element
277
- var validCandidate = matches.call(element, candidateSelector);
278
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
279
- candidates.push(element);
280
- }
281
-
282
- // iterate over shadow content if possible
283
- var shadowRoot = element.shadowRoot ||
284
- // check for an undisclosed shadow
285
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
286
-
287
- // no inert look up because we're already drilling down and checking for inertness
288
- // on the way down, so all containers to this root node should have already been
289
- // vetted as non-inert
290
- var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
291
- if (shadowRoot && validShadowRoot) {
292
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
293
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
294
- // child candidates found because they're likely slotted elements (elements that are
295
- // children of the web component element (which has the shadow), in the light dom, but
296
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
297
- // _after_ we return from this recursive call
298
- var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
299
- if (options.flatten) {
300
- candidates.push.apply(candidates, _nestedCandidates);
301
- } else {
302
- candidates.push({
303
- scopeParent: element,
304
- candidates: _nestedCandidates
305
- });
306
- }
307
- } else {
308
- // there's not shadow so just dig into the element's (light dom) children
309
- // __without__ giving the element special scope treatment
310
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
311
- }
312
- }
313
- }
314
- return candidates;
315
- };
316
-
317
- /**
318
- * @private
319
- * Determines if the node has an explicitly specified `tabindex` attribute.
320
- * @param {HTMLElement} node
321
- * @returns {boolean} True if so; false if not.
322
- */
323
- var hasTabIndex = function hasTabIndex(node) {
324
- return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
325
- };
326
-
327
- /**
328
- * Determine the tab index of a given node.
329
- * @param {HTMLElement} node
330
- * @returns {number} Tab order (negative, 0, or positive number).
331
- * @throws {Error} If `node` is falsy.
332
- */
333
- var getTabIndex = function getTabIndex(node) {
334
- if (!node) {
335
- throw new Error('No node provided');
336
- }
337
- if (node.tabIndex < 0) {
338
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
339
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
340
- // yet they are still part of the regular tab order; in FF, they get a default
341
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
342
- // order, consider their tab index to be 0.
343
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
344
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
345
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
346
- return 0;
347
- }
348
- }
349
- return node.tabIndex;
350
- };
351
-
352
- /**
353
- * Determine the tab index of a given node __for sort order purposes__.
354
- * @param {HTMLElement} node
355
- * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
356
- * has tabIndex -1, but needs to be sorted by document order in order for its content to be
357
- * inserted into the correct sort position.
358
- * @returns {number} Tab order (negative, 0, or positive number).
359
- */
360
- var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
361
- var tabIndex = getTabIndex(node);
362
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
363
- return 0;
364
- }
365
- return tabIndex;
366
- };
367
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
368
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
369
- };
370
- var isInput = function isInput(node) {
371
- return node.tagName === 'INPUT';
372
- };
373
- var isHiddenInput = function isHiddenInput(node) {
374
- return isInput(node) && node.type === 'hidden';
375
- };
376
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
377
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
378
- return child.tagName === 'SUMMARY';
379
- });
380
- return r;
381
- };
382
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
383
- for (var i = 0; i < nodes.length; i++) {
384
- if (nodes[i].checked && nodes[i].form === form) {
385
- return nodes[i];
386
- }
387
- }
388
- };
389
- var isTabbableRadio = function isTabbableRadio(node) {
390
- if (!node.name) {
391
- return true;
392
- }
393
- var radioScope = node.form || getRootNode(node);
394
- var queryRadios = function queryRadios(name) {
395
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
396
- };
397
- var radioSet;
398
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
399
- radioSet = queryRadios(window.CSS.escape(node.name));
400
- } else {
401
- try {
402
- radioSet = queryRadios(node.name);
403
- } catch (err) {
404
- // eslint-disable-next-line no-console
405
- 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);
406
- return false;
407
- }
408
- }
409
- var checked = getCheckedRadio(radioSet, node.form);
410
- return !checked || checked === node;
411
- };
412
- var isRadio = function isRadio(node) {
413
- return isInput(node) && node.type === 'radio';
414
- };
415
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
416
- return isRadio(node) && !isTabbableRadio(node);
417
- };
418
-
419
- // determines if a node is ultimately attached to the window's document
420
- var isNodeAttached = function isNodeAttached(node) {
421
- var _nodeRoot;
422
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
423
- // (but NOT _the_ document; see second 'If' comment below for more).
424
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
425
- // is attached, and the one we need to check if it's in the document or not (because the
426
- // shadow, and all nodes it contains, is never considered in the document since shadows
427
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
428
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
429
- // visibility, including all the nodes it contains). The host could be any normal node,
430
- // or a custom element (i.e. web component). Either way, that's the one that is considered
431
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
432
- // tested).
433
- // To further complicate things, we have to look all the way up until we find a shadow HOST
434
- // that is attached (or find none) because the node might be in nested shadows...
435
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
436
- // document (per the docs) and while it's a Document-type object, that document does not
437
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
438
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
439
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
440
- // node is actually detached.
441
- // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
442
- // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
443
- // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
444
- // `ownerDocument` will be `null`, hence the optional chaining on it.
445
- var nodeRoot = node && getRootNode(node);
446
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
447
-
448
- // in some cases, a detached node will return itself as the root instead of a document or
449
- // shadow root object, in which case, we shouldn't try to look further up the host chain
450
- var attached = false;
451
- if (nodeRoot && nodeRoot !== node) {
452
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
453
- 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));
454
- while (!attached && nodeRootHost) {
455
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
456
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
457
- // which means we need to get the host's host and check if that parent host is contained
458
- // in (i.e. attached to) the document
459
- nodeRoot = getRootNode(nodeRootHost);
460
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
461
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
462
- }
463
- }
464
- return attached;
465
- };
466
- var isZeroArea = function isZeroArea(node) {
467
- var _node$getBoundingClie = node.getBoundingClientRect(),
468
- width = _node$getBoundingClie.width,
469
- height = _node$getBoundingClie.height;
470
- return width === 0 && height === 0;
471
- };
472
- var isHidden = function isHidden(node, _ref) {
473
- var displayCheck = _ref.displayCheck,
474
- getShadowRoot = _ref.getShadowRoot;
475
- if (displayCheck === 'full-native') {
476
- if ('checkVisibility' in node) {
477
- // Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
478
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
479
- var visible = node.checkVisibility({
480
- // Checking opacity might be desirable for some use cases, but natively,
481
- // opacity zero elements _are_ focusable and tabbable.
482
- checkOpacity: false,
483
- opacityProperty: false,
484
- contentVisibilityAuto: true,
485
- visibilityProperty: true,
486
- // This is an alias for `visibilityProperty`. Contemporary browsers
487
- // support both. However, this alias has wider browser support (Chrome
488
- // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
489
- // we include it anyway.
490
- checkVisibilityCSS: true
491
- });
492
- return !visible;
493
- }
494
- // Fall through to manual visibility checks
495
- }
496
-
497
- // NOTE: visibility will be `undefined` if node is detached from the document
498
- // (see notes about this further down), which means we will consider it visible
499
- // (this is legacy behavior from a very long way back)
500
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
501
- // _visibility_ check, not a _display_ check
502
- if (getComputedStyle(node).visibility === 'hidden') {
503
- return true;
504
- }
505
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
506
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
507
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
508
- return true;
509
- }
510
- if (!displayCheck || displayCheck === 'full' ||
511
- // full-native can run this branch when it falls through in case
512
- // Element#checkVisibility is unsupported
513
- displayCheck === 'full-native' || displayCheck === 'legacy-full') {
514
- if (typeof getShadowRoot === 'function') {
515
- // figure out if we should consider the node to be in an undisclosed shadow and use the
516
- // 'non-zero-area' fallback
517
- var originalNode = node;
518
- while (node) {
519
- var parentElement = node.parentElement;
520
- var rootNode = getRootNode(node);
521
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
522
- ) {
523
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
524
- // fall back to a non-zero-area test
525
- return isZeroArea(node);
526
- } else if (node.assignedSlot) {
527
- // iterate up slot
528
- node = node.assignedSlot;
529
- } else if (!parentElement && rootNode !== node.ownerDocument) {
530
- // cross shadow boundary
531
- node = rootNode.host;
532
- } else {
533
- // iterate up normal dom
534
- node = parentElement;
535
- }
536
- }
537
- node = originalNode;
538
- }
539
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
540
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
541
- // it might be a falsy value, which means shadow DOM support is disabled
542
-
543
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
544
- // now we can just test to see if it would normally be visible or not, provided it's
545
- // attached to the main document.
546
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
547
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
548
-
549
- if (isNodeAttached(node)) {
550
- // this works wherever the node is: if there's at least one client rect, it's
551
- // somehow displayed; it also covers the CSS 'display: contents' case where the
552
- // node itself is hidden in place of its contents; and there's no need to search
553
- // up the hierarchy either
554
- return !node.getClientRects().length;
555
- }
556
-
557
- // Else, the node isn't attached to the document, which means the `getClientRects()`
558
- // API will __always__ return zero rects (this can happen, for example, if React
559
- // is used to render nodes onto a detached tree, as confirmed in this thread:
560
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
561
- //
562
- // It also means that even window.getComputedStyle(node).display will return `undefined`
563
- // because styles are only computed for nodes that are in the document.
564
- //
565
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
566
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
567
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
568
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
569
- // considering __everything__ to be visible because of the innability to determine styles.
570
- //
571
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
572
- // nodes as visible with the 'none' fallback.__
573
- if (displayCheck !== 'legacy-full') {
574
- return true; // hidden
575
- }
576
- // else, fallback to 'none' mode and consider the node visible
577
- } else if (displayCheck === 'non-zero-area') {
578
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
579
- // whether it's displayed, and that a detached node will __always__ have a zero-area
580
- // client rect, we don't special-case for whether the node is attached or not. In
581
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
582
- // times, and that includes attached or not.
583
- return isZeroArea(node);
584
- }
585
-
586
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
587
- // it's visible
588
- return false;
589
- };
590
-
591
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
592
- // unless they are in the _first_ <legend> element of the top-most disabled
593
- // fieldset
594
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
595
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
596
- var parentNode = node.parentElement;
597
- // check if `node` is contained in a disabled <fieldset>
598
- while (parentNode) {
599
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
600
- // look for the first <legend> among the children of the disabled <fieldset>
601
- for (var i = 0; i < parentNode.children.length; i++) {
602
- var child = parentNode.children.item(i);
603
- // when the first <legend> (in document order) is found
604
- if (child.tagName === 'LEGEND') {
605
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
606
- // return whether `node` is a descendant of its first <legend>
607
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
608
- }
609
- }
610
- // the disabled <fieldset> containing `node` has no <legend>
611
- return true;
612
- }
613
- parentNode = parentNode.parentElement;
614
- }
615
- }
616
-
617
- // else, node's tabbable/focusable state should not be affected by a fieldset's
618
- // enabled/disabled state
619
- return false;
620
- };
621
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
622
- if (node.disabled || isHiddenInput(node) || isHidden(node, options) ||
623
- // For a details element with a summary, the summary element gets the focus
624
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
625
- return false;
626
- }
627
- return true;
628
- };
629
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
630
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
631
- return false;
632
- }
633
- return true;
634
- };
635
- var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
636
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
637
- if (isNaN(tabIndex) || tabIndex >= 0) {
638
- return true;
639
- }
640
- // If a custom element has an explicit negative tabindex,
641
- // browsers will not allow tab targeting said element's children.
642
- return false;
643
- };
644
-
645
- /**
646
- * @param {Array.<Element|CandidateScope>} candidates
647
- * @returns Element[]
648
- */
649
- var _sortByOrder = function sortByOrder(candidates) {
650
- var regularTabbables = [];
651
- var orderedTabbables = [];
652
- candidates.forEach(function (item, i) {
653
- var isScope = !!item.scopeParent;
654
- var element = isScope ? item.scopeParent : item;
655
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
656
- var elements = isScope ? _sortByOrder(item.candidates) : element;
657
- if (candidateTabindex === 0) {
658
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
659
- } else {
660
- orderedTabbables.push({
661
- documentOrder: i,
662
- tabIndex: candidateTabindex,
663
- item: item,
664
- isScope: isScope,
665
- content: elements
666
- });
667
- }
668
- });
669
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
670
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
671
- return acc;
672
- }, []).concat(regularTabbables);
673
- };
674
- var tabbable = function tabbable(container, options) {
675
- options = options || {};
676
- var candidates;
677
- if (options.getShadowRoot) {
678
- candidates = _getCandidatesIteratively([container], options.includeContainer, {
679
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
680
- flatten: false,
681
- getShadowRoot: options.getShadowRoot,
682
- shadowRootFilter: isShadowRootTabbable
683
- });
684
- } else {
685
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
686
- }
687
- return _sortByOrder(candidates);
688
- };
689
- var focusable = function focusable(container, options) {
690
- options = options || {};
691
- var candidates;
692
- if (options.getShadowRoot) {
693
- candidates = _getCandidatesIteratively([container], options.includeContainer, {
694
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
695
- flatten: true,
696
- getShadowRoot: options.getShadowRoot
697
- });
698
- } else {
699
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
700
- }
701
- return candidates;
702
- };
703
- var isTabbable = function isTabbable(node, options) {
704
- options = options || {};
705
- if (!node) {
706
- throw new Error('No node provided');
707
- }
708
- if (matches.call(node, candidateSelector) === false) {
709
- return false;
710
- }
711
- return isNodeMatchingSelectorTabbable(options, node);
712
- };
713
-
714
- exports.clamp = clamp;
715
- exports.createCoords = createCoords;
716
- exports.evaluate = evaluate;
717
- exports.floor = floor;
718
- exports.focusable = focusable;
719
- exports.getAlignment = getAlignment;
720
- exports.getAlignmentAxis = getAlignmentAxis;
721
- exports.getAlignmentSides = getAlignmentSides;
722
- exports.getAxisLength = getAxisLength;
723
- exports.getExpandedPlacements = getExpandedPlacements;
724
- exports.getOppositeAlignmentPlacement = getOppositeAlignmentPlacement;
725
- exports.getOppositeAxis = getOppositeAxis;
726
- exports.getOppositeAxisPlacements = getOppositeAxisPlacements;
727
- exports.getOppositePlacement = getOppositePlacement;
728
- exports.getPaddingObject = getPaddingObject;
729
- exports.getSide = getSide;
730
- exports.getSideAxis = getSideAxis;
731
- exports.isTabbable = isTabbable;
732
- exports.max = max;
733
- exports.min = min;
734
- exports.placements = placements;
735
- exports.rectToClientRect = rectToClientRect;
736
- exports.round = round;
737
- exports.sides = sides;
738
- exports.tabbable = tabbable;