@dso-toolkit/core 62.10.0 → 62.12.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.
- package/dist/cjs/dso-accordion-section.cjs.entry.js +1 -1
- package/dist/cjs/dso-accordion-section.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-action-list-item.cjs.entry.js +1 -1
- package/dist/cjs/dso-action-list-item.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-action-list.cjs.entry.js +1 -1
- package/dist/cjs/dso-action-list.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-alert_7.cjs.entry.js +6 -7
- package/dist/cjs/dso-alert_7.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-annotation-output_3.cjs.entry.js +2 -2
- package/dist/cjs/dso-annotation-output_3.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-card.cjs.entry.js +5 -2
- package/dist/cjs/dso-card.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-dropdown-menu.cjs.entry.js +36 -10
- package/dist/cjs/dso-dropdown-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-header.cjs.entry.js +1 -1
- package/dist/cjs/dso-header.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +1 -2
- package/dist/cjs/dso-helpcenter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-highlight-box.cjs.entry.js +2 -10
- package/dist/cjs/dso-highlight-box.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-icon.cjs.entry.js +1 -1
- package/dist/cjs/dso-info_2.cjs.entry.js +1 -1
- package/dist/cjs/dso-info_2.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-list-button.cjs.entry.js +2 -3
- package/dist/cjs/dso-list-button.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-modal.cjs.entry.js +1 -1
- package/dist/cjs/dso-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-toolkit.cjs.js +1 -1
- package/dist/cjs/dso-viewer-grid.cjs.entry.js +1 -1
- package/dist/cjs/dso-viewer-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/{focus-trap.esm-6cff35a7.js → focus-trap.esm-1633a28f.js} +584 -16
- package/dist/cjs/focus-trap.esm-1633a28f.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/accordion/components/accordion-section.css +1 -1
- package/dist/collection/components/action-list/action-list.css +18 -1
- package/dist/collection/components/action-list/components/action-list-item.css +0 -12
- package/dist/collection/components/alert/alert.css +0 -20
- package/dist/collection/components/annotation-output/annotation-output.css +17 -0
- package/dist/collection/components/badge/badge.css +8 -5
- package/dist/collection/components/card/card.css +22 -9
- package/dist/collection/components/card/card.js +21 -1
- package/dist/collection/components/card/card.js.map +1 -1
- package/dist/collection/components/document-component/document-component.css +41 -9
- package/dist/collection/components/dropdown-menu/dropdown-menu.js +34 -7
- package/dist/collection/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/collection/components/header/header.css +1 -1
- package/dist/collection/components/highlight-box/highlight-box.css +20 -56
- package/dist/collection/components/highlight-box/highlight-box.js +7 -15
- package/dist/collection/components/highlight-box/highlight-box.js.map +1 -1
- package/dist/collection/components/info/info.css +0 -2
- package/dist/collection/components/label/label.css +15 -4
- package/dist/collection/components/list-button/list-button.css +4 -0
- package/dist/collection/components/modal/modal.css +2 -2
- package/dist/collection/components/ozon-content/ozon-content.css +83 -19
- package/dist/collection/components/table/table.css +2 -2
- package/dist/collection/components/viewer-grid/viewer-grid.css +4 -4
- package/dist/components/alert.js +1 -1
- package/dist/components/alert.js.map +1 -1
- package/dist/components/annotation-output.js +1 -1
- package/dist/components/annotation-output.js.map +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/document-component.js +1 -1
- package/dist/components/document-component.js.map +1 -1
- package/dist/components/dropdown-menu.js +34 -8
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dso-accordion-section.js +1 -1
- package/dist/components/dso-accordion-section.js.map +1 -1
- package/dist/components/dso-action-list-item.js +1 -1
- package/dist/components/dso-action-list-item.js.map +1 -1
- package/dist/components/dso-action-list.js +1 -1
- package/dist/components/dso-action-list.js.map +1 -1
- package/dist/components/dso-card.js +7 -3
- package/dist/components/dso-card.js.map +1 -1
- package/dist/components/dso-header.js +1 -1
- package/dist/components/dso-header.js.map +1 -1
- package/dist/components/dso-highlight-box.js +8 -16
- package/dist/components/dso-highlight-box.js.map +1 -1
- package/dist/components/dso-list-button.js +1 -1
- package/dist/components/dso-list-button.js.map +1 -1
- package/dist/components/dso-modal.js +1 -1
- package/dist/components/dso-modal.js.map +1 -1
- package/dist/components/dso-viewer-grid.js +1 -1
- package/dist/components/dso-viewer-grid.js.map +1 -1
- package/dist/components/focus-trap.esm.js +569 -2
- package/dist/components/focus-trap.esm.js.map +1 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/info.js +1 -1
- package/dist/components/info.js.map +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/ozon-content.js +1 -1
- package/dist/components/ozon-content.js.map +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
- package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
- package/dist/dso-toolkit/p-1faa1497.entry.js +2 -0
- package/dist/dso-toolkit/{p-eb7275e9.entry.js.map → p-1faa1497.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-2862c19a.entry.js +2 -0
- package/dist/dso-toolkit/{p-35dae23f.entry.js.map → p-2862c19a.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-31825ec2.entry.js +2 -0
- package/dist/dso-toolkit/{p-336aefb5.entry.js.map → p-31825ec2.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-4e5a6107.entry.js +2 -0
- package/dist/dso-toolkit/p-4e5a6107.entry.js.map +1 -0
- package/dist/dso-toolkit/p-5595d073.entry.js +2 -0
- package/dist/dso-toolkit/{p-638ad5e5.entry.js.map → p-5595d073.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-5def1d28.entry.js +2 -0
- package/dist/dso-toolkit/p-5def1d28.entry.js.map +1 -0
- package/dist/dso-toolkit/p-67461818.entry.js +2 -0
- package/dist/dso-toolkit/{p-977dde7f.entry.js.map → p-67461818.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-7bcce109.entry.js +2 -0
- package/dist/dso-toolkit/{p-193b7e46.entry.js.map → p-7bcce109.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-92fd9516.entry.js +2 -0
- package/dist/dso-toolkit/p-92fd9516.entry.js.map +1 -0
- package/dist/dso-toolkit/p-9bf33855.entry.js +2 -0
- package/dist/dso-toolkit/{p-a3f28ef2.entry.js.map → p-9bf33855.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-9c0f67c8.js +10 -0
- package/dist/dso-toolkit/p-9c0f67c8.js.map +1 -0
- package/dist/dso-toolkit/{p-bf04808f.entry.js → p-aa6d1e42.entry.js} +2 -2
- package/dist/dso-toolkit/{p-bf04808f.entry.js.map → p-aa6d1e42.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-c9fbf040.entry.js +2 -0
- package/dist/dso-toolkit/p-c9fbf040.entry.js.map +1 -0
- package/dist/dso-toolkit/p-e5ecc82f.entry.js +2 -0
- package/dist/dso-toolkit/p-e5ecc82f.entry.js.map +1 -0
- package/dist/dso-toolkit/p-eeacda43.entry.js +2 -0
- package/dist/dso-toolkit/{p-e348d48b.entry.js.map → p-eeacda43.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-f4cb0d36.entry.js +2 -0
- package/dist/dso-toolkit/{p-b36ab83a.entry.js.map → p-f4cb0d36.entry.js.map} +1 -1
- package/dist/esm/dso-accordion-section.entry.js +1 -1
- package/dist/esm/dso-accordion-section.entry.js.map +1 -1
- package/dist/esm/dso-action-list-item.entry.js +1 -1
- package/dist/esm/dso-action-list-item.entry.js.map +1 -1
- package/dist/esm/dso-action-list.entry.js +1 -1
- package/dist/esm/dso-action-list.entry.js.map +1 -1
- package/dist/esm/dso-alert_7.entry.js +6 -7
- package/dist/esm/dso-alert_7.entry.js.map +1 -1
- package/dist/esm/dso-annotation-output_3.entry.js +2 -2
- package/dist/esm/dso-annotation-output_3.entry.js.map +1 -1
- package/dist/esm/dso-card.entry.js +5 -2
- package/dist/esm/dso-card.entry.js.map +1 -1
- package/dist/esm/dso-dropdown-menu.entry.js +34 -8
- package/dist/esm/dso-dropdown-menu.entry.js.map +1 -1
- package/dist/esm/dso-header.entry.js +1 -1
- package/dist/esm/dso-header.entry.js.map +1 -1
- package/dist/esm/dso-helpcenter-panel.entry.js +1 -2
- package/dist/esm/dso-helpcenter-panel.entry.js.map +1 -1
- package/dist/esm/dso-highlight-box.entry.js +3 -11
- package/dist/esm/dso-highlight-box.entry.js.map +1 -1
- package/dist/esm/dso-icon.entry.js +1 -1
- package/dist/esm/dso-info_2.entry.js +1 -1
- package/dist/esm/dso-info_2.entry.js.map +1 -1
- package/dist/esm/dso-list-button.entry.js +2 -3
- package/dist/esm/dso-list-button.entry.js.map +1 -1
- package/dist/esm/dso-modal.entry.js +1 -1
- package/dist/esm/dso-modal.entry.js.map +1 -1
- package/dist/esm/dso-toolkit.js +1 -1
- package/dist/esm/dso-viewer-grid.entry.js +1 -1
- package/dist/esm/dso-viewer-grid.entry.js.map +1 -1
- package/dist/esm/{focus-trap.esm-d8deb1f0.js → focus-trap.esm-22fb5633.js} +570 -3
- package/dist/esm/focus-trap.esm-22fb5633.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/card/card.d.ts +6 -0
- package/dist/types/components/dropdown-menu/dropdown-menu.d.ts +2 -1
- package/dist/types/components.d.ts +8 -0
- package/package.json +2 -2
- package/dist/cjs/focus-trap.esm-6cff35a7.js.map +0 -1
- package/dist/cjs/index.esm-970bc106.js +0 -578
- package/dist/cjs/index.esm-970bc106.js.map +0 -1
- package/dist/components/index.esm.js +0 -572
- package/dist/components/index.esm.js.map +0 -1
- package/dist/dso-toolkit/p-09e0f1a6.entry.js +0 -2
- package/dist/dso-toolkit/p-09e0f1a6.entry.js.map +0 -1
- package/dist/dso-toolkit/p-193b7e46.entry.js +0 -2
- package/dist/dso-toolkit/p-33416b1d.entry.js +0 -2
- package/dist/dso-toolkit/p-33416b1d.entry.js.map +0 -1
- package/dist/dso-toolkit/p-336aefb5.entry.js +0 -2
- package/dist/dso-toolkit/p-35dae23f.entry.js +0 -2
- package/dist/dso-toolkit/p-39962ce8.entry.js +0 -2
- package/dist/dso-toolkit/p-39962ce8.entry.js.map +0 -1
- package/dist/dso-toolkit/p-482c8ebd.entry.js +0 -2
- package/dist/dso-toolkit/p-482c8ebd.entry.js.map +0 -1
- package/dist/dso-toolkit/p-638ad5e5.entry.js +0 -2
- package/dist/dso-toolkit/p-86133aa5.js +0 -6
- package/dist/dso-toolkit/p-86133aa5.js.map +0 -1
- package/dist/dso-toolkit/p-977dde7f.entry.js +0 -2
- package/dist/dso-toolkit/p-9c34ee39.entry.js +0 -2
- package/dist/dso-toolkit/p-9c34ee39.entry.js.map +0 -1
- package/dist/dso-toolkit/p-a3f28ef2.entry.js +0 -2
- package/dist/dso-toolkit/p-b36ab83a.entry.js +0 -2
- package/dist/dso-toolkit/p-e348d48b.entry.js +0 -2
- package/dist/dso-toolkit/p-eb7275e9.entry.js +0 -2
- package/dist/dso-toolkit/p-fbb226aa.js +0 -6
- package/dist/dso-toolkit/p-fbb226aa.js.map +0 -1
- package/dist/esm/focus-trap.esm-d8deb1f0.js.map +0 -1
- package/dist/esm/index.esm-7e16e884.js +0 -572
- package/dist/esm/index.esm-7e16e884.js.map +0 -1
|
@@ -1,6 +1,573 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/*!
|
|
4
|
+
* tabbable 6.2.0
|
|
5
|
+
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
6
|
+
*/
|
|
7
|
+
// NOTE: separate `:not()` selectors has broader browser support than the newer
|
|
8
|
+
// `:not([inert], [inert] *)` (Feb 2023)
|
|
9
|
+
// CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
|
|
10
|
+
// the entire query to fail, resulting in no nodes found, which will break a lot
|
|
11
|
+
// of things... so we have to rely on JS to identify nodes inside an inert container
|
|
12
|
+
var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
|
|
13
|
+
var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
|
|
14
|
+
var NoElement = typeof Element === 'undefined';
|
|
15
|
+
var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
16
|
+
var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
|
|
17
|
+
var _element$getRootNode;
|
|
18
|
+
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
19
|
+
} : function (element) {
|
|
20
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Determines if a node is inert or in an inert ancestor.
|
|
25
|
+
* @param {Element} [node]
|
|
26
|
+
* @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
|
|
27
|
+
* see if any of them are inert. If false, only `node` itself is considered.
|
|
28
|
+
* @returns {boolean} True if inert itself or by way of being in an inert ancestor.
|
|
29
|
+
* False if `node` is falsy.
|
|
30
|
+
*/
|
|
31
|
+
var isInert = function isInert(node, lookUp) {
|
|
32
|
+
var _node$getAttribute;
|
|
33
|
+
if (lookUp === void 0) {
|
|
34
|
+
lookUp = true;
|
|
35
|
+
}
|
|
36
|
+
// CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
|
|
37
|
+
// JS API property; we have to check the attribute, which can either be empty or 'true';
|
|
38
|
+
// if it's `null` (not specified) or 'false', it's an active element
|
|
39
|
+
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');
|
|
40
|
+
var inert = inertAtt === '' || inertAtt === 'true';
|
|
41
|
+
|
|
42
|
+
// NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
|
|
43
|
+
// if it weren't for `matches()` not being a function on shadow roots; the following
|
|
44
|
+
// code works for any kind of node
|
|
45
|
+
// CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
|
|
46
|
+
// so it likely would not support `:is([inert] *)` either...
|
|
47
|
+
var result = inert || lookUp && node && isInert(node.parentNode); // recursive
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Determines if a node's content is editable.
|
|
54
|
+
* @param {Element} [node]
|
|
55
|
+
* @returns True if it's content-editable; false if it's not or `node` is falsy.
|
|
56
|
+
*/
|
|
57
|
+
var isContentEditable = function isContentEditable(node) {
|
|
58
|
+
var _node$getAttribute2;
|
|
59
|
+
// CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
|
|
60
|
+
// to use the attribute directly to check for this, which can either be empty or 'true';
|
|
61
|
+
// if it's `null` (not specified) or 'false', it's a non-editable element
|
|
62
|
+
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');
|
|
63
|
+
return attValue === '' || attValue === 'true';
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {Element} el container to check in
|
|
68
|
+
* @param {boolean} includeContainer add container to check
|
|
69
|
+
* @param {(node: Element) => boolean} filter filter candidates
|
|
70
|
+
* @returns {Element[]}
|
|
71
|
+
*/
|
|
72
|
+
var getCandidates = function getCandidates(el, includeContainer, filter) {
|
|
73
|
+
// even if `includeContainer=false`, we still have to check it for inertness because
|
|
74
|
+
// if it's inert, all its children are inert
|
|
75
|
+
if (isInert(el)) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
79
|
+
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
80
|
+
candidates.unshift(el);
|
|
81
|
+
}
|
|
82
|
+
candidates = candidates.filter(filter);
|
|
83
|
+
return candidates;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @callback GetShadowRoot
|
|
88
|
+
* @param {Element} element to check for shadow root
|
|
89
|
+
* @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @callback ShadowRootFilter
|
|
94
|
+
* @param {Element} shadowHostNode the element which contains shadow content
|
|
95
|
+
* @returns {boolean} true if a shadow root could potentially contain valid candidates.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} CandidateScope
|
|
100
|
+
* @property {Element} scopeParent contains inner candidates
|
|
101
|
+
* @property {Element[]} candidates list of candidates found in the scope parent
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {Object} IterativeOptions
|
|
106
|
+
* @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
|
|
107
|
+
* if a function, implies shadow support is enabled and either returns the shadow root of an element
|
|
108
|
+
* or a boolean stating if it has an undisclosed shadow root
|
|
109
|
+
* @property {(node: Element) => boolean} filter filter candidates
|
|
110
|
+
* @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
|
|
111
|
+
* @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {Element[]} elements list of element containers to match candidates from
|
|
116
|
+
* @param {boolean} includeContainer add container list to check
|
|
117
|
+
* @param {IterativeOptions} options
|
|
118
|
+
* @returns {Array.<Element|CandidateScope>}
|
|
119
|
+
*/
|
|
120
|
+
var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
|
|
121
|
+
var candidates = [];
|
|
122
|
+
var elementsToCheck = Array.from(elements);
|
|
123
|
+
while (elementsToCheck.length) {
|
|
124
|
+
var element = elementsToCheck.shift();
|
|
125
|
+
if (isInert(element, false)) {
|
|
126
|
+
// no need to look up since we're drilling down
|
|
127
|
+
// anything inside this container will also be inert
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (element.tagName === 'SLOT') {
|
|
131
|
+
// add shadow dom slot scope (slot itself cannot be focusable)
|
|
132
|
+
var assigned = element.assignedElements();
|
|
133
|
+
var content = assigned.length ? assigned : element.children;
|
|
134
|
+
var nestedCandidates = getCandidatesIteratively(content, true, options);
|
|
135
|
+
if (options.flatten) {
|
|
136
|
+
candidates.push.apply(candidates, nestedCandidates);
|
|
137
|
+
} else {
|
|
138
|
+
candidates.push({
|
|
139
|
+
scopeParent: element,
|
|
140
|
+
candidates: nestedCandidates
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
// check candidate element
|
|
145
|
+
var validCandidate = matches.call(element, candidateSelector);
|
|
146
|
+
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
147
|
+
candidates.push(element);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// iterate over shadow content if possible
|
|
151
|
+
var shadowRoot = element.shadowRoot ||
|
|
152
|
+
// check for an undisclosed shadow
|
|
153
|
+
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
|
|
154
|
+
|
|
155
|
+
// no inert look up because we're already drilling down and checking for inertness
|
|
156
|
+
// on the way down, so all containers to this root node should have already been
|
|
157
|
+
// vetted as non-inert
|
|
158
|
+
var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
|
|
159
|
+
if (shadowRoot && validShadowRoot) {
|
|
160
|
+
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
|
|
161
|
+
// shadow exists, so look at light dom children as fallback BUT create a scope for any
|
|
162
|
+
// child candidates found because they're likely slotted elements (elements that are
|
|
163
|
+
// children of the web component element (which has the shadow), in the light dom, but
|
|
164
|
+
// slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
|
|
165
|
+
// _after_ we return from this recursive call
|
|
166
|
+
var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
167
|
+
if (options.flatten) {
|
|
168
|
+
candidates.push.apply(candidates, _nestedCandidates);
|
|
169
|
+
} else {
|
|
170
|
+
candidates.push({
|
|
171
|
+
scopeParent: element,
|
|
172
|
+
candidates: _nestedCandidates
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
// there's not shadow so just dig into the element's (light dom) children
|
|
177
|
+
// __without__ giving the element special scope treatment
|
|
178
|
+
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return candidates;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @private
|
|
187
|
+
* Determines if the node has an explicitly specified `tabindex` attribute.
|
|
188
|
+
* @param {HTMLElement} node
|
|
189
|
+
* @returns {boolean} True if so; false if not.
|
|
190
|
+
*/
|
|
191
|
+
var hasTabIndex = function hasTabIndex(node) {
|
|
192
|
+
return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Determine the tab index of a given node.
|
|
197
|
+
* @param {HTMLElement} node
|
|
198
|
+
* @returns {number} Tab order (negative, 0, or positive number).
|
|
199
|
+
* @throws {Error} If `node` is falsy.
|
|
200
|
+
*/
|
|
201
|
+
var getTabIndex = function getTabIndex(node) {
|
|
202
|
+
if (!node) {
|
|
203
|
+
throw new Error('No node provided');
|
|
204
|
+
}
|
|
205
|
+
if (node.tabIndex < 0) {
|
|
206
|
+
// in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
|
|
207
|
+
// `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
|
|
208
|
+
// yet they are still part of the regular tab order; in FF, they get a default
|
|
209
|
+
// `tabIndex` of 0; since Chrome still puts those elements in the regular tab
|
|
210
|
+
// order, consider their tab index to be 0.
|
|
211
|
+
// Also browsers do not return `tabIndex` correctly for contentEditable nodes;
|
|
212
|
+
// so if they don't have a tabindex attribute specifically set, assume it's 0.
|
|
213
|
+
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return node.tabIndex;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Determine the tab index of a given node __for sort order purposes__.
|
|
222
|
+
* @param {HTMLElement} node
|
|
223
|
+
* @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
|
|
224
|
+
* has tabIndex -1, but needs to be sorted by document order in order for its content to be
|
|
225
|
+
* inserted into the correct sort position.
|
|
226
|
+
* @returns {number} Tab order (negative, 0, or positive number).
|
|
227
|
+
*/
|
|
228
|
+
var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
|
|
229
|
+
var tabIndex = getTabIndex(node);
|
|
230
|
+
if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
return tabIndex;
|
|
234
|
+
};
|
|
235
|
+
var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
|
|
236
|
+
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
237
|
+
};
|
|
238
|
+
var isInput = function isInput(node) {
|
|
239
|
+
return node.tagName === 'INPUT';
|
|
240
|
+
};
|
|
241
|
+
var isHiddenInput = function isHiddenInput(node) {
|
|
242
|
+
return isInput(node) && node.type === 'hidden';
|
|
243
|
+
};
|
|
244
|
+
var isDetailsWithSummary = function isDetailsWithSummary(node) {
|
|
245
|
+
var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
|
|
246
|
+
return child.tagName === 'SUMMARY';
|
|
247
|
+
});
|
|
248
|
+
return r;
|
|
249
|
+
};
|
|
250
|
+
var getCheckedRadio = function getCheckedRadio(nodes, form) {
|
|
251
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
252
|
+
if (nodes[i].checked && nodes[i].form === form) {
|
|
253
|
+
return nodes[i];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var isTabbableRadio = function isTabbableRadio(node) {
|
|
258
|
+
if (!node.name) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
var radioScope = node.form || getRootNode(node);
|
|
262
|
+
var queryRadios = function queryRadios(name) {
|
|
263
|
+
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
264
|
+
};
|
|
265
|
+
var radioSet;
|
|
266
|
+
if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
|
|
267
|
+
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
268
|
+
} else {
|
|
269
|
+
try {
|
|
270
|
+
radioSet = queryRadios(node.name);
|
|
271
|
+
} catch (err) {
|
|
272
|
+
// eslint-disable-next-line no-console
|
|
273
|
+
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);
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var checked = getCheckedRadio(radioSet, node.form);
|
|
278
|
+
return !checked || checked === node;
|
|
279
|
+
};
|
|
280
|
+
var isRadio = function isRadio(node) {
|
|
281
|
+
return isInput(node) && node.type === 'radio';
|
|
282
|
+
};
|
|
283
|
+
var isNonTabbableRadio = function isNonTabbableRadio(node) {
|
|
284
|
+
return isRadio(node) && !isTabbableRadio(node);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// determines if a node is ultimately attached to the window's document
|
|
288
|
+
var isNodeAttached = function isNodeAttached(node) {
|
|
289
|
+
var _nodeRoot;
|
|
290
|
+
// The root node is the shadow root if the node is in a shadow DOM; some document otherwise
|
|
291
|
+
// (but NOT _the_ document; see second 'If' comment below for more).
|
|
292
|
+
// If rootNode is shadow root, it'll have a host, which is the element to which the shadow
|
|
293
|
+
// is attached, and the one we need to check if it's in the document or not (because the
|
|
294
|
+
// shadow, and all nodes it contains, is never considered in the document since shadows
|
|
295
|
+
// behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
|
|
296
|
+
// is hidden, or is not in the document itself but is detached, it will affect the shadow's
|
|
297
|
+
// visibility, including all the nodes it contains). The host could be any normal node,
|
|
298
|
+
// or a custom element (i.e. web component). Either way, that's the one that is considered
|
|
299
|
+
// part of the document, not the shadow root, nor any of its children (i.e. the node being
|
|
300
|
+
// tested).
|
|
301
|
+
// To further complicate things, we have to look all the way up until we find a shadow HOST
|
|
302
|
+
// that is attached (or find none) because the node might be in nested shadows...
|
|
303
|
+
// If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
|
|
304
|
+
// document (per the docs) and while it's a Document-type object, that document does not
|
|
305
|
+
// appear to be the same as the node's `ownerDocument` for some reason, so it's safer
|
|
306
|
+
// to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
|
|
307
|
+
// using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
|
|
308
|
+
// node is actually detached.
|
|
309
|
+
// NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
|
|
310
|
+
// if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
|
|
311
|
+
// from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
|
|
312
|
+
// `ownerDocument` will be `null`, hence the optional chaining on it.
|
|
313
|
+
var nodeRoot = node && getRootNode(node);
|
|
314
|
+
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
315
|
+
|
|
316
|
+
// in some cases, a detached node will return itself as the root instead of a document or
|
|
317
|
+
// shadow root object, in which case, we shouldn't try to look further up the host chain
|
|
318
|
+
var attached = false;
|
|
319
|
+
if (nodeRoot && nodeRoot !== node) {
|
|
320
|
+
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
321
|
+
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));
|
|
322
|
+
while (!attached && nodeRootHost) {
|
|
323
|
+
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
324
|
+
// since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
|
|
325
|
+
// which means we need to get the host's host and check if that parent host is contained
|
|
326
|
+
// in (i.e. attached to) the document
|
|
327
|
+
nodeRoot = getRootNode(nodeRootHost);
|
|
328
|
+
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
329
|
+
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return attached;
|
|
333
|
+
};
|
|
334
|
+
var isZeroArea = function isZeroArea(node) {
|
|
335
|
+
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
336
|
+
width = _node$getBoundingClie.width,
|
|
337
|
+
height = _node$getBoundingClie.height;
|
|
338
|
+
return width === 0 && height === 0;
|
|
339
|
+
};
|
|
340
|
+
var isHidden = function isHidden(node, _ref) {
|
|
341
|
+
var displayCheck = _ref.displayCheck,
|
|
342
|
+
getShadowRoot = _ref.getShadowRoot;
|
|
343
|
+
// NOTE: visibility will be `undefined` if node is detached from the document
|
|
344
|
+
// (see notes about this further down), which means we will consider it visible
|
|
345
|
+
// (this is legacy behavior from a very long way back)
|
|
346
|
+
// NOTE: we check this regardless of `displayCheck="none"` because this is a
|
|
347
|
+
// _visibility_ check, not a _display_ check
|
|
348
|
+
if (getComputedStyle(node).visibility === 'hidden') {
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
|
|
352
|
+
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
353
|
+
if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
|
|
357
|
+
if (typeof getShadowRoot === 'function') {
|
|
358
|
+
// figure out if we should consider the node to be in an undisclosed shadow and use the
|
|
359
|
+
// 'non-zero-area' fallback
|
|
360
|
+
var originalNode = node;
|
|
361
|
+
while (node) {
|
|
362
|
+
var parentElement = node.parentElement;
|
|
363
|
+
var rootNode = getRootNode(node);
|
|
364
|
+
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
|
|
365
|
+
) {
|
|
366
|
+
// node has an undisclosed shadow which means we can only treat it as a black box, so we
|
|
367
|
+
// fall back to a non-zero-area test
|
|
368
|
+
return isZeroArea(node);
|
|
369
|
+
} else if (node.assignedSlot) {
|
|
370
|
+
// iterate up slot
|
|
371
|
+
node = node.assignedSlot;
|
|
372
|
+
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
373
|
+
// cross shadow boundary
|
|
374
|
+
node = rootNode.host;
|
|
375
|
+
} else {
|
|
376
|
+
// iterate up normal dom
|
|
377
|
+
node = parentElement;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
node = originalNode;
|
|
381
|
+
}
|
|
382
|
+
// else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
|
|
383
|
+
// (i.e. it does not also presume that all nodes might have undisclosed shadows); or
|
|
384
|
+
// it might be a falsy value, which means shadow DOM support is disabled
|
|
385
|
+
|
|
386
|
+
// Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
|
|
387
|
+
// now we can just test to see if it would normally be visible or not, provided it's
|
|
388
|
+
// attached to the main document.
|
|
389
|
+
// NOTE: We must consider case where node is inside a shadow DOM and given directly to
|
|
390
|
+
// `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
|
|
391
|
+
|
|
392
|
+
if (isNodeAttached(node)) {
|
|
393
|
+
// this works wherever the node is: if there's at least one client rect, it's
|
|
394
|
+
// somehow displayed; it also covers the CSS 'display: contents' case where the
|
|
395
|
+
// node itself is hidden in place of its contents; and there's no need to search
|
|
396
|
+
// up the hierarchy either
|
|
397
|
+
return !node.getClientRects().length;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Else, the node isn't attached to the document, which means the `getClientRects()`
|
|
401
|
+
// API will __always__ return zero rects (this can happen, for example, if React
|
|
402
|
+
// is used to render nodes onto a detached tree, as confirmed in this thread:
|
|
403
|
+
// https://github.com/facebook/react/issues/9117#issuecomment-284228870)
|
|
404
|
+
//
|
|
405
|
+
// It also means that even window.getComputedStyle(node).display will return `undefined`
|
|
406
|
+
// because styles are only computed for nodes that are in the document.
|
|
407
|
+
//
|
|
408
|
+
// NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
|
|
409
|
+
// somehow. Though it was never stated officially, anyone who has ever used tabbable
|
|
410
|
+
// APIs on nodes in detached containers has actually implicitly used tabbable in what
|
|
411
|
+
// was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
|
|
412
|
+
// considering __everything__ to be visible because of the innability to determine styles.
|
|
413
|
+
//
|
|
414
|
+
// v6.0.0: As of this major release, the default 'full' option __no longer treats detached
|
|
415
|
+
// nodes as visible with the 'none' fallback.__
|
|
416
|
+
if (displayCheck !== 'legacy-full') {
|
|
417
|
+
return true; // hidden
|
|
418
|
+
}
|
|
419
|
+
// else, fallback to 'none' mode and consider the node visible
|
|
420
|
+
} else if (displayCheck === 'non-zero-area') {
|
|
421
|
+
// NOTE: Even though this tests that the node's client rect is non-zero to determine
|
|
422
|
+
// whether it's displayed, and that a detached node will __always__ have a zero-area
|
|
423
|
+
// client rect, we don't special-case for whether the node is attached or not. In
|
|
424
|
+
// this mode, we do want to consider nodes that have a zero area to be hidden at all
|
|
425
|
+
// times, and that includes attached or not.
|
|
426
|
+
return isZeroArea(node);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
|
|
430
|
+
// it's visible
|
|
431
|
+
return false;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// form fields (nested) inside a disabled fieldset are not focusable/tabbable
|
|
435
|
+
// unless they are in the _first_ <legend> element of the top-most disabled
|
|
436
|
+
// fieldset
|
|
437
|
+
var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
|
|
438
|
+
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
439
|
+
var parentNode = node.parentElement;
|
|
440
|
+
// check if `node` is contained in a disabled <fieldset>
|
|
441
|
+
while (parentNode) {
|
|
442
|
+
if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
|
|
443
|
+
// look for the first <legend> among the children of the disabled <fieldset>
|
|
444
|
+
for (var i = 0; i < parentNode.children.length; i++) {
|
|
445
|
+
var child = parentNode.children.item(i);
|
|
446
|
+
// when the first <legend> (in document order) is found
|
|
447
|
+
if (child.tagName === 'LEGEND') {
|
|
448
|
+
// if its parent <fieldset> is not nested in another disabled <fieldset>,
|
|
449
|
+
// return whether `node` is a descendant of its first <legend>
|
|
450
|
+
return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// the disabled <fieldset> containing `node` has no <legend>
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
parentNode = parentNode.parentElement;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// else, node's tabbable/focusable state should not be affected by a fieldset's
|
|
461
|
+
// enabled/disabled state
|
|
462
|
+
return false;
|
|
463
|
+
};
|
|
464
|
+
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
|
|
465
|
+
if (node.disabled ||
|
|
466
|
+
// we must do an inert look up to filter out any elements inside an inert ancestor
|
|
467
|
+
// because we're limited in the type of selectors we can use in JSDom (see related
|
|
468
|
+
// note related to `candidateSelectors`)
|
|
469
|
+
isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
|
|
470
|
+
// For a details element with a summary, the summary element gets the focus
|
|
471
|
+
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
return true;
|
|
475
|
+
};
|
|
476
|
+
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
|
|
477
|
+
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
return true;
|
|
481
|
+
};
|
|
482
|
+
var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
|
|
483
|
+
var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
|
|
484
|
+
if (isNaN(tabIndex) || tabIndex >= 0) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
// If a custom element has an explicit negative tabindex,
|
|
488
|
+
// browsers will not allow tab targeting said element's children.
|
|
489
|
+
return false;
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @param {Array.<Element|CandidateScope>} candidates
|
|
494
|
+
* @returns Element[]
|
|
495
|
+
*/
|
|
496
|
+
var sortByOrder = function sortByOrder(candidates) {
|
|
497
|
+
var regularTabbables = [];
|
|
498
|
+
var orderedTabbables = [];
|
|
499
|
+
candidates.forEach(function (item, i) {
|
|
500
|
+
var isScope = !!item.scopeParent;
|
|
501
|
+
var element = isScope ? item.scopeParent : item;
|
|
502
|
+
var candidateTabindex = getSortOrderTabIndex(element, isScope);
|
|
503
|
+
var elements = isScope ? sortByOrder(item.candidates) : element;
|
|
504
|
+
if (candidateTabindex === 0) {
|
|
505
|
+
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
506
|
+
} else {
|
|
507
|
+
orderedTabbables.push({
|
|
508
|
+
documentOrder: i,
|
|
509
|
+
tabIndex: candidateTabindex,
|
|
510
|
+
item: item,
|
|
511
|
+
isScope: isScope,
|
|
512
|
+
content: elements
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
|
|
517
|
+
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
518
|
+
return acc;
|
|
519
|
+
}, []).concat(regularTabbables);
|
|
520
|
+
};
|
|
521
|
+
var tabbable = function tabbable(container, options) {
|
|
522
|
+
options = options || {};
|
|
523
|
+
var candidates;
|
|
524
|
+
if (options.getShadowRoot) {
|
|
525
|
+
candidates = getCandidatesIteratively([container], options.includeContainer, {
|
|
526
|
+
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
527
|
+
flatten: false,
|
|
528
|
+
getShadowRoot: options.getShadowRoot,
|
|
529
|
+
shadowRootFilter: isValidShadowRootTabbable
|
|
530
|
+
});
|
|
531
|
+
} else {
|
|
532
|
+
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
533
|
+
}
|
|
534
|
+
return sortByOrder(candidates);
|
|
535
|
+
};
|
|
536
|
+
var focusable = function focusable(container, options) {
|
|
537
|
+
options = options || {};
|
|
538
|
+
var candidates;
|
|
539
|
+
if (options.getShadowRoot) {
|
|
540
|
+
candidates = getCandidatesIteratively([container], options.includeContainer, {
|
|
541
|
+
filter: isNodeMatchingSelectorFocusable.bind(null, options),
|
|
542
|
+
flatten: true,
|
|
543
|
+
getShadowRoot: options.getShadowRoot
|
|
544
|
+
});
|
|
545
|
+
} else {
|
|
546
|
+
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
|
|
547
|
+
}
|
|
548
|
+
return candidates;
|
|
549
|
+
};
|
|
550
|
+
var isTabbable = function isTabbable(node, options) {
|
|
551
|
+
options = options || {};
|
|
552
|
+
if (!node) {
|
|
553
|
+
throw new Error('No node provided');
|
|
554
|
+
}
|
|
555
|
+
if (matches.call(node, candidateSelector) === false) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
return isNodeMatchingSelectorTabbable(options, node);
|
|
559
|
+
};
|
|
560
|
+
var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
|
|
561
|
+
var isFocusable = function isFocusable(node, options) {
|
|
562
|
+
options = options || {};
|
|
563
|
+
if (!node) {
|
|
564
|
+
throw new Error('No node provided');
|
|
565
|
+
}
|
|
566
|
+
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
return isNodeMatchingSelectorFocusable(options, node);
|
|
570
|
+
};
|
|
4
571
|
|
|
5
572
|
/*!
|
|
6
573
|
* focus-trap 7.5.4
|
|
@@ -292,7 +859,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
292
859
|
if (node === false) {
|
|
293
860
|
return false;
|
|
294
861
|
}
|
|
295
|
-
if (node === undefined || !
|
|
862
|
+
if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
|
|
296
863
|
// option not specified nor focusable: use fallback options
|
|
297
864
|
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
298
865
|
node = doc.activeElement;
|
|
@@ -311,22 +878,22 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
311
878
|
};
|
|
312
879
|
var updateTabbableNodes = function updateTabbableNodes() {
|
|
313
880
|
state.containerGroups = state.containers.map(function (container) {
|
|
314
|
-
var tabbableNodes =
|
|
881
|
+
var tabbableNodes = tabbable(container, config.tabbableOptions);
|
|
315
882
|
|
|
316
883
|
// NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
317
884
|
// are a superset of tabbable nodes since nodes with negative `tabindex` attributes
|
|
318
885
|
// are focusable but not tabbable
|
|
319
|
-
var focusableNodes =
|
|
886
|
+
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
320
887
|
var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
|
|
321
888
|
var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
|
|
322
889
|
var firstDomTabbableNode = focusableNodes.find(function (node) {
|
|
323
|
-
return
|
|
890
|
+
return isTabbable(node);
|
|
324
891
|
});
|
|
325
892
|
var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
|
|
326
|
-
return
|
|
893
|
+
return isTabbable(node);
|
|
327
894
|
});
|
|
328
895
|
var posTabIndexesFound = !!tabbableNodes.find(function (node) {
|
|
329
|
-
return
|
|
896
|
+
return getTabIndex(node) > 0;
|
|
330
897
|
});
|
|
331
898
|
return {
|
|
332
899
|
container: container,
|
|
@@ -369,11 +936,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
369
936
|
// basic DOM order
|
|
370
937
|
if (forward) {
|
|
371
938
|
return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
|
|
372
|
-
return
|
|
939
|
+
return isTabbable(el);
|
|
373
940
|
});
|
|
374
941
|
}
|
|
375
942
|
return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
|
|
376
|
-
return
|
|
943
|
+
return isTabbable(el);
|
|
377
944
|
});
|
|
378
945
|
}
|
|
379
946
|
return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
|
|
@@ -490,7 +1057,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
490
1057
|
var firstTabbableNode = _ref3.firstTabbableNode;
|
|
491
1058
|
return target === firstTabbableNode;
|
|
492
1059
|
});
|
|
493
|
-
if (startOfGroupIndex < 0 && (containerGroup.container === target ||
|
|
1060
|
+
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
494
1061
|
// an exception case where the target is either the container itself, or
|
|
495
1062
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
496
1063
|
// and user clicked on it or node was programmatically given focus)
|
|
@@ -505,7 +1072,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
505
1072
|
// the LAST group if it's the first tabbable node of the FIRST group)
|
|
506
1073
|
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
507
1074
|
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
508
|
-
destinationNode =
|
|
1075
|
+
destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
|
|
509
1076
|
} else if (!isTabEvent(event)) {
|
|
510
1077
|
// user must have customized the nav keys so we have to move focus manually _within_
|
|
511
1078
|
// the active group: do this based on the order determined by tabbable()
|
|
@@ -519,7 +1086,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
519
1086
|
var lastTabbableNode = _ref4.lastTabbableNode;
|
|
520
1087
|
return target === lastTabbableNode;
|
|
521
1088
|
});
|
|
522
|
-
if (lastOfGroupIndex < 0 && (containerGroup.container === target ||
|
|
1089
|
+
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
523
1090
|
// an exception case where the target is the container itself, or
|
|
524
1091
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
525
1092
|
// and user clicked on it or node was programmatically given focus)
|
|
@@ -534,7 +1101,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
534
1101
|
// group if it's the last tabbable node of the LAST group)
|
|
535
1102
|
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
536
1103
|
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
537
|
-
destinationNode =
|
|
1104
|
+
destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
|
|
538
1105
|
} else if (!isTabEvent(event)) {
|
|
539
1106
|
// user must have customized the nav keys so we have to move focus manually _within_
|
|
540
1107
|
// the active group: do this based on the order determined by tabbable()
|
|
@@ -606,7 +1173,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
606
1173
|
var nextNode; // next node to focus, if we find one
|
|
607
1174
|
var navAcrossContainers = true;
|
|
608
1175
|
if (state.mostRecentlyFocusedNode) {
|
|
609
|
-
if (
|
|
1176
|
+
if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
|
|
610
1177
|
// MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
|
|
611
1178
|
var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
|
|
612
1179
|
// there MAY not be any tabbable nodes in the container if there are at least 2 containers
|
|
@@ -649,7 +1216,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
649
1216
|
// the greatest positive tab index like it should)
|
|
650
1217
|
if (!state.containerGroups.some(function (g) {
|
|
651
1218
|
return g.tabbableNodes.some(function (n) {
|
|
652
|
-
return
|
|
1219
|
+
return getTabIndex(n) > 0;
|
|
653
1220
|
});
|
|
654
1221
|
})) {
|
|
655
1222
|
// no containers with tabbable nodes with positive tab indexes which means the focus
|
|
@@ -938,5 +1505,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
938
1505
|
};
|
|
939
1506
|
|
|
940
1507
|
exports.createFocusTrap = createFocusTrap;
|
|
1508
|
+
exports.tabbable = tabbable;
|
|
941
1509
|
|
|
942
|
-
//# sourceMappingURL=focus-trap.esm-
|
|
1510
|
+
//# sourceMappingURL=focus-trap.esm-1633a28f.js.map
|