@zjex/git-workflow 0.2.24 → 0.3.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/.github/workflows/deploy-docs.yml +68 -0
- package/.github/workflows/test.yml +24 -4
- package/.husky/pre-commit +14 -0
- package/README.md +72 -1066
- package/dist/index.js +103 -13
- package/docs/.vitepress/cache/deps/_metadata.json +52 -0
- package/docs/.vitepress/cache/deps/chunk-2CLQ7TTZ.js +9719 -0
- package/docs/.vitepress/cache/deps/chunk-2CLQ7TTZ.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-LE5NDSFD.js +12824 -0
- package/docs/.vitepress/cache/deps/chunk-LE5NDSFD.js.map +7 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1352 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1665 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1813 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +347 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-2CLQ7TTZ.js +9719 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-2CLQ7TTZ.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-LE5NDSFD.js +12824 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-LE5NDSFD.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/package.json +3 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_integrations_useFocusTrap.js +1352 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___mark__js_src_vanilla__js.js +1665 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___minisearch.js +1813 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vue.js +347 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vue.js.map +7 -0
- package/docs/.vitepress/config.ts +167 -0
- package/docs/.vitepress/theme/custom.css +39 -0
- package/docs/.vitepress/theme/index.ts +4 -0
- package/docs/README.md +82 -0
- package/docs/commands/branch.md +468 -0
- package/docs/commands/commit.md +554 -0
- package/docs/commands/config.md +346 -0
- package/docs/commands/index.md +312 -0
- package/docs/commands/interactive.md +384 -0
- package/docs/commands/release.md +300 -0
- package/docs/commands/stash.md +309 -0
- package/docs/commands/tag.md +278 -0
- package/docs/commands/update.md +347 -0
- package/docs/config/ai-config.md +160 -0
- package/docs/config/branch-config.md +133 -0
- package/docs/config/commit-config.md +185 -0
- package/docs/config/config-file.md +776 -0
- package/docs/config/examples.md +279 -0
- package/docs/config/index.md +478 -0
- package/docs/guide/ai-commit.md +576 -0
- package/docs/guide/basic-usage.md +522 -0
- package/docs/guide/best-practices.md +426 -0
- package/docs/guide/branch-management.md +712 -0
- package/docs/guide/getting-started.md +294 -0
- package/docs/guide/index.md +168 -0
- package/docs/guide/installation.md +449 -0
- package/docs/guide/release-management.md +744 -0
- package/docs/guide/stash-management.md +608 -0
- package/docs/guide/tag-management.md +614 -0
- package/docs/index.md +205 -0
- package/docs/public/favicon.svg +21 -0
- package/docs/public/hero-logo.svg +43 -0
- package/docs/public/logo.svg +20 -0
- package/package.json +11 -2
- package/scripts/publish.js +55 -8
- package/scripts/publish.sh +20 -2
- package/scripts/release.sh +20 -2
- package/scripts/update-test-count.js +55 -0
- package/src/ai-service.ts +101 -15
- package/src/commands/init.ts +18 -0
- package/src/config.ts +1 -0
- package/tests/ai-service.test.ts +237 -2
- package/tests/help.test.ts +134 -0
- package/tests/init.test.ts +582 -0
- package/tests/release.test.ts +333 -0
- package/tests/setup.ts +21 -0
- package/tests/stash.test.ts +376 -0
- package/tests/update.test.ts +402 -0
- package/vitest.config.ts +3 -0
- package/zjex-logo.svg +22 -0
- package/zjex-optimized.svg +34 -0
- package/zjex.svg +1 -0
|
@@ -0,0 +1,1352 @@
|
|
|
1
|
+
import {
|
|
2
|
+
notNullish,
|
|
3
|
+
toArray,
|
|
4
|
+
tryOnScopeDispose,
|
|
5
|
+
unrefElement
|
|
6
|
+
} from "./chunk-2CLQ7TTZ.js";
|
|
7
|
+
import {
|
|
8
|
+
computed,
|
|
9
|
+
shallowRef,
|
|
10
|
+
toValue,
|
|
11
|
+
watch
|
|
12
|
+
} from "./chunk-LE5NDSFD.js";
|
|
13
|
+
|
|
14
|
+
// node_modules/tabbable/dist/index.esm.js
|
|
15
|
+
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] *)"];
|
|
16
|
+
var candidateSelector = candidateSelectors.join(",");
|
|
17
|
+
var NoElement = typeof Element === "undefined";
|
|
18
|
+
var matches = NoElement ? function() {
|
|
19
|
+
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
20
|
+
var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
|
|
21
|
+
var _element$getRootNode;
|
|
22
|
+
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
23
|
+
} : function(element) {
|
|
24
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
25
|
+
};
|
|
26
|
+
var _isInert = function isInert(node, lookUp) {
|
|
27
|
+
var _node$getAttribute;
|
|
28
|
+
if (lookUp === void 0) {
|
|
29
|
+
lookUp = true;
|
|
30
|
+
}
|
|
31
|
+
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");
|
|
32
|
+
var inert = inertAtt === "" || inertAtt === "true";
|
|
33
|
+
var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual
|
|
34
|
+
// lookup upward, in case it is not defined.
|
|
35
|
+
(typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
var isContentEditable = function isContentEditable2(node) {
|
|
39
|
+
var _node$getAttribute2;
|
|
40
|
+
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");
|
|
41
|
+
return attValue === "" || attValue === "true";
|
|
42
|
+
};
|
|
43
|
+
var getCandidates = function getCandidates2(el, includeContainer, filter) {
|
|
44
|
+
if (_isInert(el)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
48
|
+
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
49
|
+
candidates.unshift(el);
|
|
50
|
+
}
|
|
51
|
+
candidates = candidates.filter(filter);
|
|
52
|
+
return candidates;
|
|
53
|
+
};
|
|
54
|
+
var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
|
|
55
|
+
var candidates = [];
|
|
56
|
+
var elementsToCheck = Array.from(elements);
|
|
57
|
+
while (elementsToCheck.length) {
|
|
58
|
+
var element = elementsToCheck.shift();
|
|
59
|
+
if (_isInert(element, false)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (element.tagName === "SLOT") {
|
|
63
|
+
var assigned = element.assignedElements();
|
|
64
|
+
var content = assigned.length ? assigned : element.children;
|
|
65
|
+
var nestedCandidates = _getCandidatesIteratively(content, true, options);
|
|
66
|
+
if (options.flatten) {
|
|
67
|
+
candidates.push.apply(candidates, nestedCandidates);
|
|
68
|
+
} else {
|
|
69
|
+
candidates.push({
|
|
70
|
+
scopeParent: element,
|
|
71
|
+
candidates: nestedCandidates
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
var validCandidate = matches.call(element, candidateSelector);
|
|
76
|
+
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
77
|
+
candidates.push(element);
|
|
78
|
+
}
|
|
79
|
+
var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
|
|
80
|
+
typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
|
|
81
|
+
var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
|
|
82
|
+
if (shadowRoot && validShadowRoot) {
|
|
83
|
+
var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
84
|
+
if (options.flatten) {
|
|
85
|
+
candidates.push.apply(candidates, _nestedCandidates);
|
|
86
|
+
} else {
|
|
87
|
+
candidates.push({
|
|
88
|
+
scopeParent: element,
|
|
89
|
+
candidates: _nestedCandidates
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return candidates;
|
|
98
|
+
};
|
|
99
|
+
var hasTabIndex = function hasTabIndex2(node) {
|
|
100
|
+
return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
|
|
101
|
+
};
|
|
102
|
+
var getTabIndex = function getTabIndex2(node) {
|
|
103
|
+
if (!node) {
|
|
104
|
+
throw new Error("No node provided");
|
|
105
|
+
}
|
|
106
|
+
if (node.tabIndex < 0) {
|
|
107
|
+
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return node.tabIndex;
|
|
112
|
+
};
|
|
113
|
+
var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
|
|
114
|
+
var tabIndex = getTabIndex(node);
|
|
115
|
+
if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
return tabIndex;
|
|
119
|
+
};
|
|
120
|
+
var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
|
|
121
|
+
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
122
|
+
};
|
|
123
|
+
var isInput = function isInput2(node) {
|
|
124
|
+
return node.tagName === "INPUT";
|
|
125
|
+
};
|
|
126
|
+
var isHiddenInput = function isHiddenInput2(node) {
|
|
127
|
+
return isInput(node) && node.type === "hidden";
|
|
128
|
+
};
|
|
129
|
+
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
130
|
+
var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
131
|
+
return child.tagName === "SUMMARY";
|
|
132
|
+
});
|
|
133
|
+
return r;
|
|
134
|
+
};
|
|
135
|
+
var getCheckedRadio = function getCheckedRadio2(nodes, form) {
|
|
136
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
137
|
+
if (nodes[i].checked && nodes[i].form === form) {
|
|
138
|
+
return nodes[i];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var isTabbableRadio = function isTabbableRadio2(node) {
|
|
143
|
+
if (!node.name) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
var radioScope = node.form || getRootNode(node);
|
|
147
|
+
var queryRadios = function queryRadios2(name) {
|
|
148
|
+
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
149
|
+
};
|
|
150
|
+
var radioSet;
|
|
151
|
+
if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
|
|
152
|
+
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
153
|
+
} else {
|
|
154
|
+
try {
|
|
155
|
+
radioSet = queryRadios(node.name);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
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);
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var checked = getCheckedRadio(radioSet, node.form);
|
|
162
|
+
return !checked || checked === node;
|
|
163
|
+
};
|
|
164
|
+
var isRadio = function isRadio2(node) {
|
|
165
|
+
return isInput(node) && node.type === "radio";
|
|
166
|
+
};
|
|
167
|
+
var isNonTabbableRadio = function isNonTabbableRadio2(node) {
|
|
168
|
+
return isRadio(node) && !isTabbableRadio(node);
|
|
169
|
+
};
|
|
170
|
+
var isNodeAttached = function isNodeAttached2(node) {
|
|
171
|
+
var _nodeRoot;
|
|
172
|
+
var nodeRoot = node && getRootNode(node);
|
|
173
|
+
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
174
|
+
var attached = false;
|
|
175
|
+
if (nodeRoot && nodeRoot !== node) {
|
|
176
|
+
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
177
|
+
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));
|
|
178
|
+
while (!attached && nodeRootHost) {
|
|
179
|
+
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
180
|
+
nodeRoot = getRootNode(nodeRootHost);
|
|
181
|
+
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
182
|
+
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return attached;
|
|
186
|
+
};
|
|
187
|
+
var isZeroArea = function isZeroArea2(node) {
|
|
188
|
+
var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
|
|
189
|
+
return width === 0 && height === 0;
|
|
190
|
+
};
|
|
191
|
+
var isHidden = function isHidden2(node, _ref) {
|
|
192
|
+
var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
|
|
193
|
+
if (displayCheck === "full-native") {
|
|
194
|
+
if ("checkVisibility" in node) {
|
|
195
|
+
var visible = node.checkVisibility({
|
|
196
|
+
// Checking opacity might be desirable for some use cases, but natively,
|
|
197
|
+
// opacity zero elements _are_ focusable and tabbable.
|
|
198
|
+
checkOpacity: false,
|
|
199
|
+
opacityProperty: false,
|
|
200
|
+
contentVisibilityAuto: true,
|
|
201
|
+
visibilityProperty: true,
|
|
202
|
+
// This is an alias for `visibilityProperty`. Contemporary browsers
|
|
203
|
+
// support both. However, this alias has wider browser support (Chrome
|
|
204
|
+
// >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
|
|
205
|
+
// we include it anyway.
|
|
206
|
+
checkVisibilityCSS: true
|
|
207
|
+
});
|
|
208
|
+
return !visible;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (getComputedStyle(node).visibility === "hidden") {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
215
|
+
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
216
|
+
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
|
|
220
|
+
// Element#checkVisibility is unsupported
|
|
221
|
+
displayCheck === "full-native" || displayCheck === "legacy-full") {
|
|
222
|
+
if (typeof getShadowRoot === "function") {
|
|
223
|
+
var originalNode = node;
|
|
224
|
+
while (node) {
|
|
225
|
+
var parentElement = node.parentElement;
|
|
226
|
+
var rootNode = getRootNode(node);
|
|
227
|
+
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
|
|
228
|
+
return isZeroArea(node);
|
|
229
|
+
} else if (node.assignedSlot) {
|
|
230
|
+
node = node.assignedSlot;
|
|
231
|
+
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
232
|
+
node = rootNode.host;
|
|
233
|
+
} else {
|
|
234
|
+
node = parentElement;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
node = originalNode;
|
|
238
|
+
}
|
|
239
|
+
if (isNodeAttached(node)) {
|
|
240
|
+
return !node.getClientRects().length;
|
|
241
|
+
}
|
|
242
|
+
if (displayCheck !== "legacy-full") {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
} else if (displayCheck === "non-zero-area") {
|
|
246
|
+
return isZeroArea(node);
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
};
|
|
250
|
+
var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
|
|
251
|
+
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
252
|
+
var parentNode = node.parentElement;
|
|
253
|
+
while (parentNode) {
|
|
254
|
+
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
255
|
+
for (var i = 0; i < parentNode.children.length; i++) {
|
|
256
|
+
var child = parentNode.children.item(i);
|
|
257
|
+
if (child.tagName === "LEGEND") {
|
|
258
|
+
return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
parentNode = parentNode.parentElement;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
};
|
|
268
|
+
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
|
|
269
|
+
if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
270
|
+
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
return true;
|
|
274
|
+
};
|
|
275
|
+
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
|
|
276
|
+
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
};
|
|
281
|
+
var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
|
|
282
|
+
var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
|
|
283
|
+
if (isNaN(tabIndex) || tabIndex >= 0) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
};
|
|
288
|
+
var _sortByOrder = function sortByOrder(candidates) {
|
|
289
|
+
var regularTabbables = [];
|
|
290
|
+
var orderedTabbables = [];
|
|
291
|
+
candidates.forEach(function(item, i) {
|
|
292
|
+
var isScope = !!item.scopeParent;
|
|
293
|
+
var element = isScope ? item.scopeParent : item;
|
|
294
|
+
var candidateTabindex = getSortOrderTabIndex(element, isScope);
|
|
295
|
+
var elements = isScope ? _sortByOrder(item.candidates) : element;
|
|
296
|
+
if (candidateTabindex === 0) {
|
|
297
|
+
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
298
|
+
} else {
|
|
299
|
+
orderedTabbables.push({
|
|
300
|
+
documentOrder: i,
|
|
301
|
+
tabIndex: candidateTabindex,
|
|
302
|
+
item,
|
|
303
|
+
isScope,
|
|
304
|
+
content: elements
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
|
|
309
|
+
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
310
|
+
return acc;
|
|
311
|
+
}, []).concat(regularTabbables);
|
|
312
|
+
};
|
|
313
|
+
var tabbable = function tabbable2(container, options) {
|
|
314
|
+
options = options || {};
|
|
315
|
+
var candidates;
|
|
316
|
+
if (options.getShadowRoot) {
|
|
317
|
+
candidates = _getCandidatesIteratively([container], options.includeContainer, {
|
|
318
|
+
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
319
|
+
flatten: false,
|
|
320
|
+
getShadowRoot: options.getShadowRoot,
|
|
321
|
+
shadowRootFilter: isShadowRootTabbable
|
|
322
|
+
});
|
|
323
|
+
} else {
|
|
324
|
+
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
325
|
+
}
|
|
326
|
+
return _sortByOrder(candidates);
|
|
327
|
+
};
|
|
328
|
+
var focusable = function focusable2(container, options) {
|
|
329
|
+
options = options || {};
|
|
330
|
+
var candidates;
|
|
331
|
+
if (options.getShadowRoot) {
|
|
332
|
+
candidates = _getCandidatesIteratively([container], options.includeContainer, {
|
|
333
|
+
filter: isNodeMatchingSelectorFocusable.bind(null, options),
|
|
334
|
+
flatten: true,
|
|
335
|
+
getShadowRoot: options.getShadowRoot
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
|
|
339
|
+
}
|
|
340
|
+
return candidates;
|
|
341
|
+
};
|
|
342
|
+
var isTabbable = function isTabbable2(node, options) {
|
|
343
|
+
options = options || {};
|
|
344
|
+
if (!node) {
|
|
345
|
+
throw new Error("No node provided");
|
|
346
|
+
}
|
|
347
|
+
if (matches.call(node, candidateSelector) === false) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
return isNodeMatchingSelectorTabbable(options, node);
|
|
351
|
+
};
|
|
352
|
+
var focusableCandidateSelector = candidateSelectors.concat("iframe:not([inert]):not([inert] *)").join(",");
|
|
353
|
+
var isFocusable = function isFocusable2(node, options) {
|
|
354
|
+
options = options || {};
|
|
355
|
+
if (!node) {
|
|
356
|
+
throw new Error("No node provided");
|
|
357
|
+
}
|
|
358
|
+
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
return isNodeMatchingSelectorFocusable(options, node);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// node_modules/focus-trap/dist/focus-trap.esm.js
|
|
365
|
+
function _arrayLikeToArray(r, a) {
|
|
366
|
+
(null == a || a > r.length) && (a = r.length);
|
|
367
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
368
|
+
return n;
|
|
369
|
+
}
|
|
370
|
+
function _arrayWithoutHoles(r) {
|
|
371
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
372
|
+
}
|
|
373
|
+
function _createForOfIteratorHelper(r, e) {
|
|
374
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
375
|
+
if (!t) {
|
|
376
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
377
|
+
t && (r = t);
|
|
378
|
+
var n = 0, F = function() {
|
|
379
|
+
};
|
|
380
|
+
return {
|
|
381
|
+
s: F,
|
|
382
|
+
n: function() {
|
|
383
|
+
return n >= r.length ? {
|
|
384
|
+
done: true
|
|
385
|
+
} : {
|
|
386
|
+
done: false,
|
|
387
|
+
value: r[n++]
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
e: function(r2) {
|
|
391
|
+
throw r2;
|
|
392
|
+
},
|
|
393
|
+
f: F
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
397
|
+
}
|
|
398
|
+
var o, a = true, u = false;
|
|
399
|
+
return {
|
|
400
|
+
s: function() {
|
|
401
|
+
t = t.call(r);
|
|
402
|
+
},
|
|
403
|
+
n: function() {
|
|
404
|
+
var r2 = t.next();
|
|
405
|
+
return a = r2.done, r2;
|
|
406
|
+
},
|
|
407
|
+
e: function(r2) {
|
|
408
|
+
u = true, o = r2;
|
|
409
|
+
},
|
|
410
|
+
f: function() {
|
|
411
|
+
try {
|
|
412
|
+
a || null == t.return || t.return();
|
|
413
|
+
} finally {
|
|
414
|
+
if (u) throw o;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function _defineProperty(e, r, t) {
|
|
420
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
421
|
+
value: t,
|
|
422
|
+
enumerable: true,
|
|
423
|
+
configurable: true,
|
|
424
|
+
writable: true
|
|
425
|
+
}) : e[r] = t, e;
|
|
426
|
+
}
|
|
427
|
+
function _iterableToArray(r) {
|
|
428
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
429
|
+
}
|
|
430
|
+
function _nonIterableSpread() {
|
|
431
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
432
|
+
}
|
|
433
|
+
function ownKeys(e, r) {
|
|
434
|
+
var t = Object.keys(e);
|
|
435
|
+
if (Object.getOwnPropertySymbols) {
|
|
436
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
437
|
+
r && (o = o.filter(function(r2) {
|
|
438
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
439
|
+
})), t.push.apply(t, o);
|
|
440
|
+
}
|
|
441
|
+
return t;
|
|
442
|
+
}
|
|
443
|
+
function _objectSpread2(e) {
|
|
444
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
445
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
446
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
447
|
+
_defineProperty(e, r2, t[r2]);
|
|
448
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
449
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return e;
|
|
453
|
+
}
|
|
454
|
+
function _toConsumableArray(r) {
|
|
455
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
456
|
+
}
|
|
457
|
+
function _toPrimitive(t, r) {
|
|
458
|
+
if ("object" != typeof t || !t) return t;
|
|
459
|
+
var e = t[Symbol.toPrimitive];
|
|
460
|
+
if (void 0 !== e) {
|
|
461
|
+
var i = e.call(t, r);
|
|
462
|
+
if ("object" != typeof i) return i;
|
|
463
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
464
|
+
}
|
|
465
|
+
return ("string" === r ? String : Number)(t);
|
|
466
|
+
}
|
|
467
|
+
function _toPropertyKey(t) {
|
|
468
|
+
var i = _toPrimitive(t, "string");
|
|
469
|
+
return "symbol" == typeof i ? i : i + "";
|
|
470
|
+
}
|
|
471
|
+
function _unsupportedIterableToArray(r, a) {
|
|
472
|
+
if (r) {
|
|
473
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
474
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
475
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
var activeFocusTraps = {
|
|
479
|
+
// Returns the trap from the top of the stack.
|
|
480
|
+
getActiveTrap: function getActiveTrap(trapStack) {
|
|
481
|
+
if ((trapStack === null || trapStack === void 0 ? void 0 : trapStack.length) > 0) {
|
|
482
|
+
return trapStack[trapStack.length - 1];
|
|
483
|
+
}
|
|
484
|
+
return null;
|
|
485
|
+
},
|
|
486
|
+
// Pauses the currently active trap, then adds a new trap to the stack.
|
|
487
|
+
activateTrap: function activateTrap(trapStack, trap) {
|
|
488
|
+
var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
|
|
489
|
+
if (trap !== activeTrap) {
|
|
490
|
+
activeFocusTraps.pauseTrap(trapStack);
|
|
491
|
+
}
|
|
492
|
+
var trapIndex = trapStack.indexOf(trap);
|
|
493
|
+
if (trapIndex === -1) {
|
|
494
|
+
trapStack.push(trap);
|
|
495
|
+
} else {
|
|
496
|
+
trapStack.splice(trapIndex, 1);
|
|
497
|
+
trapStack.push(trap);
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
// Removes the trap from the top of the stack, then unpauses the next trap down.
|
|
501
|
+
deactivateTrap: function deactivateTrap(trapStack, trap) {
|
|
502
|
+
var trapIndex = trapStack.indexOf(trap);
|
|
503
|
+
if (trapIndex !== -1) {
|
|
504
|
+
trapStack.splice(trapIndex, 1);
|
|
505
|
+
}
|
|
506
|
+
activeFocusTraps.unpauseTrap(trapStack);
|
|
507
|
+
},
|
|
508
|
+
// Pauses the trap at the top of the stack.
|
|
509
|
+
pauseTrap: function pauseTrap(trapStack) {
|
|
510
|
+
var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
|
|
511
|
+
activeTrap === null || activeTrap === void 0 || activeTrap._setPausedState(true);
|
|
512
|
+
},
|
|
513
|
+
// Unpauses the trap at the top of the stack.
|
|
514
|
+
unpauseTrap: function unpauseTrap(trapStack) {
|
|
515
|
+
var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
|
|
516
|
+
if (activeTrap && !activeTrap._isManuallyPaused()) {
|
|
517
|
+
activeTrap._setPausedState(false);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
var isSelectableInput = function isSelectableInput2(node) {
|
|
522
|
+
return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
|
|
523
|
+
};
|
|
524
|
+
var isEscapeEvent = function isEscapeEvent2(e) {
|
|
525
|
+
return (e === null || e === void 0 ? void 0 : e.key) === "Escape" || (e === null || e === void 0 ? void 0 : e.key) === "Esc" || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
|
|
526
|
+
};
|
|
527
|
+
var isTabEvent = function isTabEvent2(e) {
|
|
528
|
+
return (e === null || e === void 0 ? void 0 : e.key) === "Tab" || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
|
|
529
|
+
};
|
|
530
|
+
var isKeyForward = function isKeyForward2(e) {
|
|
531
|
+
return isTabEvent(e) && !e.shiftKey;
|
|
532
|
+
};
|
|
533
|
+
var isKeyBackward = function isKeyBackward2(e) {
|
|
534
|
+
return isTabEvent(e) && e.shiftKey;
|
|
535
|
+
};
|
|
536
|
+
var delay = function delay2(fn) {
|
|
537
|
+
return setTimeout(fn, 0);
|
|
538
|
+
};
|
|
539
|
+
var valueOrHandler = function valueOrHandler2(value) {
|
|
540
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
541
|
+
params[_key - 1] = arguments[_key];
|
|
542
|
+
}
|
|
543
|
+
return typeof value === "function" ? value.apply(void 0, params) : value;
|
|
544
|
+
};
|
|
545
|
+
var getActualTarget = function getActualTarget2(event) {
|
|
546
|
+
return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
|
|
547
|
+
};
|
|
548
|
+
var internalTrapStack = [];
|
|
549
|
+
var createFocusTrap = function createFocusTrap2(elements, userOptions) {
|
|
550
|
+
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
|
|
551
|
+
var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
|
|
552
|
+
var config = _objectSpread2({
|
|
553
|
+
returnFocusOnDeactivate: true,
|
|
554
|
+
escapeDeactivates: true,
|
|
555
|
+
delayInitialFocus: true,
|
|
556
|
+
isolateSubtrees: false,
|
|
557
|
+
isKeyForward,
|
|
558
|
+
isKeyBackward
|
|
559
|
+
}, userOptions);
|
|
560
|
+
var state = {
|
|
561
|
+
// containers given to createFocusTrap()
|
|
562
|
+
/** @type {Array<HTMLElement>} */
|
|
563
|
+
containers: [],
|
|
564
|
+
// list of objects identifying tabbable nodes in `containers` in the trap
|
|
565
|
+
// NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
|
|
566
|
+
// is active, but the trap should never get to a state where there isn't at least one group
|
|
567
|
+
// with at least one tabbable node in it (that would lead to an error condition that would
|
|
568
|
+
// result in an error being thrown)
|
|
569
|
+
/** @type {Array<{
|
|
570
|
+
* container: HTMLElement,
|
|
571
|
+
* tabbableNodes: Array<HTMLElement>, // empty if none
|
|
572
|
+
* focusableNodes: Array<HTMLElement>, // empty if none
|
|
573
|
+
* posTabIndexesFound: boolean,
|
|
574
|
+
* firstTabbableNode: HTMLElement|undefined,
|
|
575
|
+
* lastTabbableNode: HTMLElement|undefined,
|
|
576
|
+
* firstDomTabbableNode: HTMLElement|undefined,
|
|
577
|
+
* lastDomTabbableNode: HTMLElement|undefined,
|
|
578
|
+
* nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
|
|
579
|
+
* }>}
|
|
580
|
+
*/
|
|
581
|
+
containerGroups: [],
|
|
582
|
+
// same order/length as `containers` list
|
|
583
|
+
// references to objects in `containerGroups`, but only those that actually have
|
|
584
|
+
// tabbable nodes in them
|
|
585
|
+
// NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
|
|
586
|
+
// the same length
|
|
587
|
+
tabbableGroups: [],
|
|
588
|
+
// references to nodes that are siblings to the ancestors of this trap's containers.
|
|
589
|
+
/** @type {Set<HTMLElement>} */
|
|
590
|
+
adjacentElements: /* @__PURE__ */ new Set(),
|
|
591
|
+
// references to nodes that were inert or aria-hidden before the trap was activated.
|
|
592
|
+
/** @type {Set<HTMLElement>} */
|
|
593
|
+
alreadySilent: /* @__PURE__ */ new Set(),
|
|
594
|
+
nodeFocusedBeforeActivation: null,
|
|
595
|
+
mostRecentlyFocusedNode: null,
|
|
596
|
+
active: false,
|
|
597
|
+
paused: false,
|
|
598
|
+
manuallyPaused: false,
|
|
599
|
+
// timer ID for when delayInitialFocus is true and initial focus in this trap
|
|
600
|
+
// has been delayed during activation
|
|
601
|
+
delayInitialFocusTimer: void 0,
|
|
602
|
+
// the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
|
|
603
|
+
recentNavEvent: void 0
|
|
604
|
+
};
|
|
605
|
+
var trap;
|
|
606
|
+
var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) {
|
|
607
|
+
return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
|
|
608
|
+
};
|
|
609
|
+
var findContainerIndex = function findContainerIndex2(element, event) {
|
|
610
|
+
var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === "function" ? event.composedPath() : void 0;
|
|
611
|
+
return state.containerGroups.findIndex(function(_ref) {
|
|
612
|
+
var container = _ref.container, tabbableNodes = _ref.tabbableNodes;
|
|
613
|
+
return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
|
|
614
|
+
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
615
|
+
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
616
|
+
// look inside web components even if open)
|
|
617
|
+
(composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function(node) {
|
|
618
|
+
return node === element;
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
var getNodeForOption = function getNodeForOption2(optionName) {
|
|
623
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref2$hasFallback = _ref2.hasFallback, hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback, _ref2$params = _ref2.params, params = _ref2$params === void 0 ? [] : _ref2$params;
|
|
624
|
+
var optionValue = config[optionName];
|
|
625
|
+
if (typeof optionValue === "function") {
|
|
626
|
+
optionValue = optionValue.apply(void 0, _toConsumableArray(params));
|
|
627
|
+
}
|
|
628
|
+
if (optionValue === true) {
|
|
629
|
+
optionValue = void 0;
|
|
630
|
+
}
|
|
631
|
+
if (!optionValue) {
|
|
632
|
+
if (optionValue === void 0 || optionValue === false) {
|
|
633
|
+
return optionValue;
|
|
634
|
+
}
|
|
635
|
+
throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
|
|
636
|
+
}
|
|
637
|
+
var node = optionValue;
|
|
638
|
+
if (typeof optionValue === "string") {
|
|
639
|
+
try {
|
|
640
|
+
node = doc.querySelector(optionValue);
|
|
641
|
+
} catch (err) {
|
|
642
|
+
throw new Error("`".concat(optionName, '` appears to be an invalid selector; error="').concat(err.message, '"'));
|
|
643
|
+
}
|
|
644
|
+
if (!node) {
|
|
645
|
+
if (!hasFallback) {
|
|
646
|
+
throw new Error("`".concat(optionName, "` as selector refers to no known node"));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return node;
|
|
651
|
+
};
|
|
652
|
+
var getInitialFocusNode = function getInitialFocusNode2() {
|
|
653
|
+
var node = getNodeForOption("initialFocus", {
|
|
654
|
+
hasFallback: true
|
|
655
|
+
});
|
|
656
|
+
if (node === false) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
if (node === void 0 || node && !isFocusable(node, config.tabbableOptions)) {
|
|
660
|
+
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
661
|
+
node = doc.activeElement;
|
|
662
|
+
} else {
|
|
663
|
+
var firstTabbableGroup = state.tabbableGroups[0];
|
|
664
|
+
var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
|
|
665
|
+
node = firstTabbableNode || getNodeForOption("fallbackFocus");
|
|
666
|
+
}
|
|
667
|
+
} else if (node === null) {
|
|
668
|
+
node = getNodeForOption("fallbackFocus");
|
|
669
|
+
}
|
|
670
|
+
if (!node) {
|
|
671
|
+
throw new Error("Your focus-trap needs to have at least one focusable element");
|
|
672
|
+
}
|
|
673
|
+
return node;
|
|
674
|
+
};
|
|
675
|
+
var updateTabbableNodes = function updateTabbableNodes2() {
|
|
676
|
+
state.containerGroups = state.containers.map(function(container) {
|
|
677
|
+
var tabbableNodes = tabbable(container, config.tabbableOptions);
|
|
678
|
+
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
679
|
+
var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : void 0;
|
|
680
|
+
var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : void 0;
|
|
681
|
+
var firstDomTabbableNode = focusableNodes.find(function(node) {
|
|
682
|
+
return isTabbable(node);
|
|
683
|
+
});
|
|
684
|
+
var lastDomTabbableNode = focusableNodes.slice().reverse().find(function(node) {
|
|
685
|
+
return isTabbable(node);
|
|
686
|
+
});
|
|
687
|
+
var posTabIndexesFound = !!tabbableNodes.find(function(node) {
|
|
688
|
+
return getTabIndex(node) > 0;
|
|
689
|
+
});
|
|
690
|
+
return {
|
|
691
|
+
container,
|
|
692
|
+
tabbableNodes,
|
|
693
|
+
focusableNodes,
|
|
694
|
+
/** True if at least one node with positive `tabindex` was found in this container. */
|
|
695
|
+
posTabIndexesFound,
|
|
696
|
+
/** First tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
697
|
+
firstTabbableNode,
|
|
698
|
+
/** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
699
|
+
lastTabbableNode,
|
|
700
|
+
// NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
|
|
701
|
+
// would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
702
|
+
// because that API doesn't work with Shadow DOM as well as it should (@see
|
|
703
|
+
// https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
|
|
704
|
+
// to address an edge case related to positive tabindex support, this seems like a much easier,
|
|
705
|
+
// "close enough most of the time" alternative for positive tabindexes which should generally
|
|
706
|
+
// be avoided anyway...
|
|
707
|
+
/** First tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
708
|
+
firstDomTabbableNode,
|
|
709
|
+
/** Last tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
710
|
+
lastDomTabbableNode,
|
|
711
|
+
/**
|
|
712
|
+
* Finds the __tabbable__ node that follows the given node in the specified direction,
|
|
713
|
+
* in this container, if any.
|
|
714
|
+
* @param {HTMLElement} node
|
|
715
|
+
* @param {boolean} [forward] True if going in forward tab order; false if going
|
|
716
|
+
* in reverse.
|
|
717
|
+
* @returns {HTMLElement|undefined} The next tabbable node, if any.
|
|
718
|
+
*/
|
|
719
|
+
nextTabbableNode: function nextTabbableNode(node) {
|
|
720
|
+
var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
721
|
+
var nodeIdx = tabbableNodes.indexOf(node);
|
|
722
|
+
if (nodeIdx < 0) {
|
|
723
|
+
if (forward) {
|
|
724
|
+
return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function(el) {
|
|
725
|
+
return isTabbable(el);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function(el) {
|
|
729
|
+
return isTabbable(el);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
});
|
|
736
|
+
state.tabbableGroups = state.containerGroups.filter(function(group) {
|
|
737
|
+
return group.tabbableNodes.length > 0;
|
|
738
|
+
});
|
|
739
|
+
if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) {
|
|
740
|
+
throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
|
|
741
|
+
}
|
|
742
|
+
if (state.containerGroups.find(function(g) {
|
|
743
|
+
return g.posTabIndexesFound;
|
|
744
|
+
}) && state.containerGroups.length > 1) {
|
|
745
|
+
throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var _getActiveElement = function getActiveElement(el) {
|
|
749
|
+
var activeElement = el.activeElement;
|
|
750
|
+
if (!activeElement) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
|
|
754
|
+
return _getActiveElement(activeElement.shadowRoot);
|
|
755
|
+
}
|
|
756
|
+
return activeElement;
|
|
757
|
+
};
|
|
758
|
+
var _tryFocus = function tryFocus(node) {
|
|
759
|
+
if (node === false) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (node === _getActiveElement(document)) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (!node || !node.focus) {
|
|
766
|
+
_tryFocus(getInitialFocusNode());
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
node.focus({
|
|
770
|
+
preventScroll: !!config.preventScroll
|
|
771
|
+
});
|
|
772
|
+
state.mostRecentlyFocusedNode = node;
|
|
773
|
+
if (isSelectableInput(node)) {
|
|
774
|
+
node.select();
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) {
|
|
778
|
+
var node = getNodeForOption("setReturnFocus", {
|
|
779
|
+
params: [previousActiveElement]
|
|
780
|
+
});
|
|
781
|
+
return node ? node : node === false ? false : previousActiveElement;
|
|
782
|
+
};
|
|
783
|
+
var findNextNavNode = function findNextNavNode2(_ref3) {
|
|
784
|
+
var target = _ref3.target, event = _ref3.event, _ref3$isBackward = _ref3.isBackward, isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
|
|
785
|
+
target = target || getActualTarget(event);
|
|
786
|
+
updateTabbableNodes();
|
|
787
|
+
var destinationNode = null;
|
|
788
|
+
if (state.tabbableGroups.length > 0) {
|
|
789
|
+
var containerIndex = findContainerIndex(target, event);
|
|
790
|
+
var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0;
|
|
791
|
+
if (containerIndex < 0) {
|
|
792
|
+
if (isBackward) {
|
|
793
|
+
destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
|
|
794
|
+
} else {
|
|
795
|
+
destinationNode = state.tabbableGroups[0].firstTabbableNode;
|
|
796
|
+
}
|
|
797
|
+
} else if (isBackward) {
|
|
798
|
+
var startOfGroupIndex = state.tabbableGroups.findIndex(function(_ref4) {
|
|
799
|
+
var firstTabbableNode = _ref4.firstTabbableNode;
|
|
800
|
+
return target === firstTabbableNode;
|
|
801
|
+
});
|
|
802
|
+
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
803
|
+
startOfGroupIndex = containerIndex;
|
|
804
|
+
}
|
|
805
|
+
if (startOfGroupIndex >= 0) {
|
|
806
|
+
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
807
|
+
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
808
|
+
destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
|
|
809
|
+
} else if (!isTabEvent(event)) {
|
|
810
|
+
destinationNode = containerGroup.nextTabbableNode(target, false);
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
var lastOfGroupIndex = state.tabbableGroups.findIndex(function(_ref5) {
|
|
814
|
+
var lastTabbableNode = _ref5.lastTabbableNode;
|
|
815
|
+
return target === lastTabbableNode;
|
|
816
|
+
});
|
|
817
|
+
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
818
|
+
lastOfGroupIndex = containerIndex;
|
|
819
|
+
}
|
|
820
|
+
if (lastOfGroupIndex >= 0) {
|
|
821
|
+
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
822
|
+
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
823
|
+
destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
|
|
824
|
+
} else if (!isTabEvent(event)) {
|
|
825
|
+
destinationNode = containerGroup.nextTabbableNode(target);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
destinationNode = getNodeForOption("fallbackFocus");
|
|
830
|
+
}
|
|
831
|
+
return destinationNode;
|
|
832
|
+
};
|
|
833
|
+
var checkPointerDown = function checkPointerDown2(e) {
|
|
834
|
+
var target = getActualTarget(e);
|
|
835
|
+
if (findContainerIndex(target, e) >= 0) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
839
|
+
trap.deactivate({
|
|
840
|
+
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
841
|
+
// which will result in the outside click setting focus to the node
|
|
842
|
+
// that was clicked (and if not focusable, to "nothing"); by setting
|
|
843
|
+
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
844
|
+
// on activation (or the configured `setReturnFocus` node), whether the
|
|
845
|
+
// outside click was on a focusable node or not
|
|
846
|
+
returnFocus: config.returnFocusOnDeactivate
|
|
847
|
+
});
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
e.preventDefault();
|
|
854
|
+
};
|
|
855
|
+
var checkFocusIn = function checkFocusIn2(event) {
|
|
856
|
+
var target = getActualTarget(event);
|
|
857
|
+
var targetContained = findContainerIndex(target, event) >= 0;
|
|
858
|
+
if (targetContained || target instanceof Document) {
|
|
859
|
+
if (targetContained) {
|
|
860
|
+
state.mostRecentlyFocusedNode = target;
|
|
861
|
+
}
|
|
862
|
+
} else {
|
|
863
|
+
event.stopImmediatePropagation();
|
|
864
|
+
var nextNode;
|
|
865
|
+
var navAcrossContainers = true;
|
|
866
|
+
if (state.mostRecentlyFocusedNode) {
|
|
867
|
+
if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
|
|
868
|
+
var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
|
|
869
|
+
var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
|
|
870
|
+
if (tabbableNodes.length > 0) {
|
|
871
|
+
var mruTabIdx = tabbableNodes.findIndex(function(node) {
|
|
872
|
+
return node === state.mostRecentlyFocusedNode;
|
|
873
|
+
});
|
|
874
|
+
if (mruTabIdx >= 0) {
|
|
875
|
+
if (config.isKeyForward(state.recentNavEvent)) {
|
|
876
|
+
if (mruTabIdx + 1 < tabbableNodes.length) {
|
|
877
|
+
nextNode = tabbableNodes[mruTabIdx + 1];
|
|
878
|
+
navAcrossContainers = false;
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
if (mruTabIdx - 1 >= 0) {
|
|
882
|
+
nextNode = tabbableNodes[mruTabIdx - 1];
|
|
883
|
+
navAcrossContainers = false;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
} else {
|
|
889
|
+
if (!state.containerGroups.some(function(g) {
|
|
890
|
+
return g.tabbableNodes.some(function(n) {
|
|
891
|
+
return getTabIndex(n) > 0;
|
|
892
|
+
});
|
|
893
|
+
})) {
|
|
894
|
+
navAcrossContainers = false;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
} else {
|
|
898
|
+
navAcrossContainers = false;
|
|
899
|
+
}
|
|
900
|
+
if (navAcrossContainers) {
|
|
901
|
+
nextNode = findNextNavNode({
|
|
902
|
+
// move FROM the MRU node, not event-related node (which will be the node that is
|
|
903
|
+
// outside the trap causing the focus escape we're trying to fix)
|
|
904
|
+
target: state.mostRecentlyFocusedNode,
|
|
905
|
+
isBackward: config.isKeyBackward(state.recentNavEvent)
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
if (nextNode) {
|
|
909
|
+
_tryFocus(nextNode);
|
|
910
|
+
} else {
|
|
911
|
+
_tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
state.recentNavEvent = void 0;
|
|
915
|
+
};
|
|
916
|
+
var checkKeyNav = function checkKeyNav2(event) {
|
|
917
|
+
var isBackward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
918
|
+
state.recentNavEvent = event;
|
|
919
|
+
var destinationNode = findNextNavNode({
|
|
920
|
+
event,
|
|
921
|
+
isBackward
|
|
922
|
+
});
|
|
923
|
+
if (destinationNode) {
|
|
924
|
+
if (isTabEvent(event)) {
|
|
925
|
+
event.preventDefault();
|
|
926
|
+
}
|
|
927
|
+
_tryFocus(destinationNode);
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
var checkTabKey = function checkTabKey2(event) {
|
|
931
|
+
if (config.isKeyForward(event) || config.isKeyBackward(event)) {
|
|
932
|
+
checkKeyNav(event, config.isKeyBackward(event));
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var checkEscapeKey = function checkEscapeKey2(event) {
|
|
936
|
+
if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
|
|
937
|
+
event.preventDefault();
|
|
938
|
+
trap.deactivate();
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
var checkClick = function checkClick2(e) {
|
|
942
|
+
var target = getActualTarget(e);
|
|
943
|
+
if (findContainerIndex(target, e) >= 0) {
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
e.preventDefault();
|
|
953
|
+
e.stopImmediatePropagation();
|
|
954
|
+
};
|
|
955
|
+
var addListeners = function addListeners2() {
|
|
956
|
+
if (!state.active) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
activeFocusTraps.activateTrap(trapStack, trap);
|
|
960
|
+
state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() {
|
|
961
|
+
_tryFocus(getInitialFocusNode());
|
|
962
|
+
}) : _tryFocus(getInitialFocusNode());
|
|
963
|
+
doc.addEventListener("focusin", checkFocusIn, true);
|
|
964
|
+
doc.addEventListener("mousedown", checkPointerDown, {
|
|
965
|
+
capture: true,
|
|
966
|
+
passive: false
|
|
967
|
+
});
|
|
968
|
+
doc.addEventListener("touchstart", checkPointerDown, {
|
|
969
|
+
capture: true,
|
|
970
|
+
passive: false
|
|
971
|
+
});
|
|
972
|
+
doc.addEventListener("click", checkClick, {
|
|
973
|
+
capture: true,
|
|
974
|
+
passive: false
|
|
975
|
+
});
|
|
976
|
+
doc.addEventListener("keydown", checkTabKey, {
|
|
977
|
+
capture: true,
|
|
978
|
+
passive: false
|
|
979
|
+
});
|
|
980
|
+
doc.addEventListener("keydown", checkEscapeKey);
|
|
981
|
+
return trap;
|
|
982
|
+
};
|
|
983
|
+
var collectAdjacentElements = function collectAdjacentElements2(containers) {
|
|
984
|
+
if (state.active && !state.paused) {
|
|
985
|
+
trap._setSubtreeIsolation(false);
|
|
986
|
+
}
|
|
987
|
+
state.adjacentElements.clear();
|
|
988
|
+
state.alreadySilent.clear();
|
|
989
|
+
var containerAncestors = /* @__PURE__ */ new Set();
|
|
990
|
+
var adjacentElements = /* @__PURE__ */ new Set();
|
|
991
|
+
var _iterator = _createForOfIteratorHelper(containers), _step;
|
|
992
|
+
try {
|
|
993
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
994
|
+
var container = _step.value;
|
|
995
|
+
containerAncestors.add(container);
|
|
996
|
+
var insideShadowRoot = typeof ShadowRoot !== "undefined" && container.getRootNode() instanceof ShadowRoot;
|
|
997
|
+
var current = container;
|
|
998
|
+
while (current) {
|
|
999
|
+
containerAncestors.add(current);
|
|
1000
|
+
var parent = current.parentElement;
|
|
1001
|
+
var siblings = [];
|
|
1002
|
+
if (parent) {
|
|
1003
|
+
siblings = parent.children;
|
|
1004
|
+
} else if (!parent && insideShadowRoot) {
|
|
1005
|
+
siblings = current.getRootNode().children;
|
|
1006
|
+
parent = current.getRootNode().host;
|
|
1007
|
+
insideShadowRoot = typeof ShadowRoot !== "undefined" && parent.getRootNode() instanceof ShadowRoot;
|
|
1008
|
+
}
|
|
1009
|
+
var _iterator2 = _createForOfIteratorHelper(siblings), _step2;
|
|
1010
|
+
try {
|
|
1011
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
1012
|
+
var child = _step2.value;
|
|
1013
|
+
adjacentElements.add(child);
|
|
1014
|
+
}
|
|
1015
|
+
} catch (err) {
|
|
1016
|
+
_iterator2.e(err);
|
|
1017
|
+
} finally {
|
|
1018
|
+
_iterator2.f();
|
|
1019
|
+
}
|
|
1020
|
+
current = parent;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
} catch (err) {
|
|
1024
|
+
_iterator.e(err);
|
|
1025
|
+
} finally {
|
|
1026
|
+
_iterator.f();
|
|
1027
|
+
}
|
|
1028
|
+
containerAncestors.forEach(function(el) {
|
|
1029
|
+
adjacentElements["delete"](el);
|
|
1030
|
+
});
|
|
1031
|
+
state.adjacentElements = adjacentElements;
|
|
1032
|
+
};
|
|
1033
|
+
var removeListeners = function removeListeners2() {
|
|
1034
|
+
if (!state.active) {
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
doc.removeEventListener("focusin", checkFocusIn, true);
|
|
1038
|
+
doc.removeEventListener("mousedown", checkPointerDown, true);
|
|
1039
|
+
doc.removeEventListener("touchstart", checkPointerDown, true);
|
|
1040
|
+
doc.removeEventListener("click", checkClick, true);
|
|
1041
|
+
doc.removeEventListener("keydown", checkTabKey, true);
|
|
1042
|
+
doc.removeEventListener("keydown", checkEscapeKey);
|
|
1043
|
+
return trap;
|
|
1044
|
+
};
|
|
1045
|
+
var checkDomRemoval = function checkDomRemoval2(mutations) {
|
|
1046
|
+
var isFocusedNodeRemoved = mutations.some(function(mutation) {
|
|
1047
|
+
var removedNodes = Array.from(mutation.removedNodes);
|
|
1048
|
+
return removedNodes.some(function(node) {
|
|
1049
|
+
return node === state.mostRecentlyFocusedNode;
|
|
1050
|
+
});
|
|
1051
|
+
});
|
|
1052
|
+
if (isFocusedNodeRemoved) {
|
|
1053
|
+
_tryFocus(getInitialFocusNode());
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
var mutationObserver = typeof window !== "undefined" && "MutationObserver" in window ? new MutationObserver(checkDomRemoval) : void 0;
|
|
1057
|
+
var updateObservedNodes = function updateObservedNodes2() {
|
|
1058
|
+
if (!mutationObserver) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
mutationObserver.disconnect();
|
|
1062
|
+
if (state.active && !state.paused) {
|
|
1063
|
+
state.containers.map(function(container) {
|
|
1064
|
+
mutationObserver.observe(container, {
|
|
1065
|
+
subtree: true,
|
|
1066
|
+
childList: true
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
trap = {
|
|
1072
|
+
get active() {
|
|
1073
|
+
return state.active;
|
|
1074
|
+
},
|
|
1075
|
+
get paused() {
|
|
1076
|
+
return state.paused;
|
|
1077
|
+
},
|
|
1078
|
+
activate: function activate(activateOptions) {
|
|
1079
|
+
if (state.active) {
|
|
1080
|
+
return this;
|
|
1081
|
+
}
|
|
1082
|
+
var onActivate = getOption(activateOptions, "onActivate");
|
|
1083
|
+
var onPostActivate = getOption(activateOptions, "onPostActivate");
|
|
1084
|
+
var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
|
|
1085
|
+
var preexistingTrap = activeFocusTraps.getActiveTrap(trapStack);
|
|
1086
|
+
var revertState = false;
|
|
1087
|
+
if (preexistingTrap && !preexistingTrap.paused) {
|
|
1088
|
+
var _preexistingTrap$_set;
|
|
1089
|
+
(_preexistingTrap$_set = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set === void 0 || _preexistingTrap$_set.call(preexistingTrap, false);
|
|
1090
|
+
revertState = true;
|
|
1091
|
+
}
|
|
1092
|
+
try {
|
|
1093
|
+
if (!checkCanFocusTrap) {
|
|
1094
|
+
updateTabbableNodes();
|
|
1095
|
+
}
|
|
1096
|
+
state.active = true;
|
|
1097
|
+
state.paused = false;
|
|
1098
|
+
state.nodeFocusedBeforeActivation = _getActiveElement(doc);
|
|
1099
|
+
onActivate === null || onActivate === void 0 || onActivate();
|
|
1100
|
+
var finishActivation = function finishActivation2() {
|
|
1101
|
+
if (checkCanFocusTrap) {
|
|
1102
|
+
updateTabbableNodes();
|
|
1103
|
+
}
|
|
1104
|
+
addListeners();
|
|
1105
|
+
updateObservedNodes();
|
|
1106
|
+
if (config.isolateSubtrees) {
|
|
1107
|
+
trap._setSubtreeIsolation(true);
|
|
1108
|
+
}
|
|
1109
|
+
onPostActivate === null || onPostActivate === void 0 || onPostActivate();
|
|
1110
|
+
};
|
|
1111
|
+
if (checkCanFocusTrap) {
|
|
1112
|
+
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
1113
|
+
return this;
|
|
1114
|
+
}
|
|
1115
|
+
finishActivation();
|
|
1116
|
+
} catch (error) {
|
|
1117
|
+
if (preexistingTrap === activeFocusTraps.getActiveTrap(trapStack) && revertState) {
|
|
1118
|
+
var _preexistingTrap$_set2;
|
|
1119
|
+
(_preexistingTrap$_set2 = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set2 === void 0 || _preexistingTrap$_set2.call(preexistingTrap, true);
|
|
1120
|
+
}
|
|
1121
|
+
throw error;
|
|
1122
|
+
}
|
|
1123
|
+
return this;
|
|
1124
|
+
},
|
|
1125
|
+
deactivate: function deactivate(deactivateOptions) {
|
|
1126
|
+
if (!state.active) {
|
|
1127
|
+
return this;
|
|
1128
|
+
}
|
|
1129
|
+
var options = _objectSpread2({
|
|
1130
|
+
onDeactivate: config.onDeactivate,
|
|
1131
|
+
onPostDeactivate: config.onPostDeactivate,
|
|
1132
|
+
checkCanReturnFocus: config.checkCanReturnFocus
|
|
1133
|
+
}, deactivateOptions);
|
|
1134
|
+
clearTimeout(state.delayInitialFocusTimer);
|
|
1135
|
+
state.delayInitialFocusTimer = void 0;
|
|
1136
|
+
if (!state.paused) {
|
|
1137
|
+
trap._setSubtreeIsolation(false);
|
|
1138
|
+
}
|
|
1139
|
+
state.alreadySilent.clear();
|
|
1140
|
+
removeListeners();
|
|
1141
|
+
state.active = false;
|
|
1142
|
+
state.paused = false;
|
|
1143
|
+
updateObservedNodes();
|
|
1144
|
+
activeFocusTraps.deactivateTrap(trapStack, trap);
|
|
1145
|
+
var onDeactivate = getOption(options, "onDeactivate");
|
|
1146
|
+
var onPostDeactivate = getOption(options, "onPostDeactivate");
|
|
1147
|
+
var checkCanReturnFocus = getOption(options, "checkCanReturnFocus");
|
|
1148
|
+
var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate");
|
|
1149
|
+
onDeactivate === null || onDeactivate === void 0 || onDeactivate();
|
|
1150
|
+
var finishDeactivation = function finishDeactivation2() {
|
|
1151
|
+
delay(function() {
|
|
1152
|
+
if (returnFocus) {
|
|
1153
|
+
_tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
1154
|
+
}
|
|
1155
|
+
onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
|
|
1156
|
+
});
|
|
1157
|
+
};
|
|
1158
|
+
if (returnFocus && checkCanReturnFocus) {
|
|
1159
|
+
checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
|
|
1160
|
+
return this;
|
|
1161
|
+
}
|
|
1162
|
+
finishDeactivation();
|
|
1163
|
+
return this;
|
|
1164
|
+
},
|
|
1165
|
+
pause: function pause(pauseOptions) {
|
|
1166
|
+
if (!state.active) {
|
|
1167
|
+
return this;
|
|
1168
|
+
}
|
|
1169
|
+
state.manuallyPaused = true;
|
|
1170
|
+
return this._setPausedState(true, pauseOptions);
|
|
1171
|
+
},
|
|
1172
|
+
unpause: function unpause(unpauseOptions) {
|
|
1173
|
+
if (!state.active) {
|
|
1174
|
+
return this;
|
|
1175
|
+
}
|
|
1176
|
+
state.manuallyPaused = false;
|
|
1177
|
+
if (trapStack[trapStack.length - 1] !== this) {
|
|
1178
|
+
return this;
|
|
1179
|
+
}
|
|
1180
|
+
return this._setPausedState(false, unpauseOptions);
|
|
1181
|
+
},
|
|
1182
|
+
updateContainerElements: function updateContainerElements(containerElements) {
|
|
1183
|
+
var elementsAsArray = [].concat(containerElements).filter(Boolean);
|
|
1184
|
+
state.containers = elementsAsArray.map(function(element) {
|
|
1185
|
+
return typeof element === "string" ? doc.querySelector(element) : element;
|
|
1186
|
+
});
|
|
1187
|
+
if (config.isolateSubtrees) {
|
|
1188
|
+
collectAdjacentElements(state.containers);
|
|
1189
|
+
}
|
|
1190
|
+
if (state.active) {
|
|
1191
|
+
updateTabbableNodes();
|
|
1192
|
+
if (config.isolateSubtrees && !state.paused) {
|
|
1193
|
+
trap._setSubtreeIsolation(true);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
updateObservedNodes();
|
|
1197
|
+
return this;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
Object.defineProperties(trap, {
|
|
1201
|
+
_isManuallyPaused: {
|
|
1202
|
+
value: function value() {
|
|
1203
|
+
return state.manuallyPaused;
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
_setPausedState: {
|
|
1207
|
+
value: function value(paused, options) {
|
|
1208
|
+
if (state.paused === paused) {
|
|
1209
|
+
return this;
|
|
1210
|
+
}
|
|
1211
|
+
state.paused = paused;
|
|
1212
|
+
if (paused) {
|
|
1213
|
+
var onPause = getOption(options, "onPause");
|
|
1214
|
+
var onPostPause = getOption(options, "onPostPause");
|
|
1215
|
+
onPause === null || onPause === void 0 || onPause();
|
|
1216
|
+
removeListeners();
|
|
1217
|
+
updateObservedNodes();
|
|
1218
|
+
trap._setSubtreeIsolation(false);
|
|
1219
|
+
onPostPause === null || onPostPause === void 0 || onPostPause();
|
|
1220
|
+
} else {
|
|
1221
|
+
var onUnpause = getOption(options, "onUnpause");
|
|
1222
|
+
var onPostUnpause = getOption(options, "onPostUnpause");
|
|
1223
|
+
onUnpause === null || onUnpause === void 0 || onUnpause();
|
|
1224
|
+
trap._setSubtreeIsolation(true);
|
|
1225
|
+
updateTabbableNodes();
|
|
1226
|
+
addListeners();
|
|
1227
|
+
updateObservedNodes();
|
|
1228
|
+
onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
|
|
1229
|
+
}
|
|
1230
|
+
return this;
|
|
1231
|
+
}
|
|
1232
|
+
},
|
|
1233
|
+
_setSubtreeIsolation: {
|
|
1234
|
+
value: function value(isEnabled) {
|
|
1235
|
+
if (config.isolateSubtrees) {
|
|
1236
|
+
state.adjacentElements.forEach(function(el) {
|
|
1237
|
+
var _el$getAttribute;
|
|
1238
|
+
if (isEnabled) {
|
|
1239
|
+
switch (config.isolateSubtrees) {
|
|
1240
|
+
case "aria-hidden":
|
|
1241
|
+
if (el.ariaHidden === "true" || ((_el$getAttribute = el.getAttribute("aria-hidden")) === null || _el$getAttribute === void 0 ? void 0 : _el$getAttribute.toLowerCase()) === "true") {
|
|
1242
|
+
state.alreadySilent.add(el);
|
|
1243
|
+
}
|
|
1244
|
+
el.setAttribute("aria-hidden", "true");
|
|
1245
|
+
break;
|
|
1246
|
+
default:
|
|
1247
|
+
if (el.inert || el.hasAttribute("inert")) {
|
|
1248
|
+
state.alreadySilent.add(el);
|
|
1249
|
+
}
|
|
1250
|
+
el.setAttribute("inert", true);
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
if (state.alreadySilent.has(el)) ;
|
|
1255
|
+
else {
|
|
1256
|
+
switch (config.isolateSubtrees) {
|
|
1257
|
+
case "aria-hidden":
|
|
1258
|
+
el.removeAttribute("aria-hidden");
|
|
1259
|
+
break;
|
|
1260
|
+
default:
|
|
1261
|
+
el.removeAttribute("inert");
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
trap.updateContainerElements(elements);
|
|
1272
|
+
return trap;
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
// node_modules/@vueuse/integrations/useFocusTrap.mjs
|
|
1276
|
+
function useFocusTrap(target, options = {}) {
|
|
1277
|
+
let trap;
|
|
1278
|
+
const { immediate, ...focusTrapOptions } = options;
|
|
1279
|
+
const hasFocus = shallowRef(false);
|
|
1280
|
+
const isPaused = shallowRef(false);
|
|
1281
|
+
const activate = (opts) => trap && trap.activate(opts);
|
|
1282
|
+
const deactivate = (opts) => trap && trap.deactivate(opts);
|
|
1283
|
+
const pause = () => {
|
|
1284
|
+
if (trap) {
|
|
1285
|
+
trap.pause();
|
|
1286
|
+
isPaused.value = true;
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
const unpause = () => {
|
|
1290
|
+
if (trap) {
|
|
1291
|
+
trap.unpause();
|
|
1292
|
+
isPaused.value = false;
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
const targets = computed(() => {
|
|
1296
|
+
const _targets = toValue(target);
|
|
1297
|
+
return toArray(_targets).map((el) => {
|
|
1298
|
+
const _el = toValue(el);
|
|
1299
|
+
return typeof _el === "string" ? _el : unrefElement(_el);
|
|
1300
|
+
}).filter(notNullish);
|
|
1301
|
+
});
|
|
1302
|
+
watch(
|
|
1303
|
+
targets,
|
|
1304
|
+
(els) => {
|
|
1305
|
+
if (!els.length)
|
|
1306
|
+
return;
|
|
1307
|
+
trap = createFocusTrap(els, {
|
|
1308
|
+
...focusTrapOptions,
|
|
1309
|
+
onActivate() {
|
|
1310
|
+
hasFocus.value = true;
|
|
1311
|
+
if (options.onActivate)
|
|
1312
|
+
options.onActivate();
|
|
1313
|
+
},
|
|
1314
|
+
onDeactivate() {
|
|
1315
|
+
hasFocus.value = false;
|
|
1316
|
+
if (options.onDeactivate)
|
|
1317
|
+
options.onDeactivate();
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
if (immediate)
|
|
1321
|
+
activate();
|
|
1322
|
+
},
|
|
1323
|
+
{ flush: "post" }
|
|
1324
|
+
);
|
|
1325
|
+
tryOnScopeDispose(() => deactivate());
|
|
1326
|
+
return {
|
|
1327
|
+
hasFocus,
|
|
1328
|
+
isPaused,
|
|
1329
|
+
activate,
|
|
1330
|
+
deactivate,
|
|
1331
|
+
pause,
|
|
1332
|
+
unpause
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
export {
|
|
1336
|
+
useFocusTrap
|
|
1337
|
+
};
|
|
1338
|
+
/*! Bundled license information:
|
|
1339
|
+
|
|
1340
|
+
tabbable/dist/index.esm.js:
|
|
1341
|
+
(*!
|
|
1342
|
+
* tabbable 6.4.0
|
|
1343
|
+
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
1344
|
+
*)
|
|
1345
|
+
|
|
1346
|
+
focus-trap/dist/focus-trap.esm.js:
|
|
1347
|
+
(*!
|
|
1348
|
+
* focus-trap 7.8.0
|
|
1349
|
+
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
1350
|
+
*)
|
|
1351
|
+
*/
|
|
1352
|
+
//# sourceMappingURL=vitepress___@vueuse_integrations_useFocusTrap.js.map
|