1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.contains = exports.parentAutofocusables = exports.getFocusableNodes = exports.getTabbableNodes = exports.filterAutoFocusable = exports.filterFocusable = void 0;
|
4 | var array_1 = require("./array");
|
5 | var is_1 = require("./is");
|
6 | var tabOrder_1 = require("./tabOrder");
|
7 | var tabUtils_1 = require("./tabUtils");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var filterFocusable = function (nodes, visibilityCache) {
|
14 | return (0, array_1.toArray)(nodes)
|
15 | .filter(function (node) { return (0, is_1.isVisibleCached)(visibilityCache, node); })
|
16 | .filter(function (node) { return (0, is_1.notHiddenInput)(node); });
|
17 | };
|
18 | exports.filterFocusable = filterFocusable;
|
19 | var filterAutoFocusable = function (nodes, cache) {
|
20 | if (cache === void 0) { cache = new Map(); }
|
21 | return (0, array_1.toArray)(nodes).filter(function (node) { return (0, is_1.isAutoFocusAllowedCached)(cache, node); });
|
22 | };
|
23 | exports.filterAutoFocusable = filterAutoFocusable;
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var getTabbableNodes = function (topNodes, visibilityCache, withGuards) {
|
34 | return (0, tabOrder_1.orderByTabIndex)((0, exports.filterFocusable)((0, tabUtils_1.getFocusables)(topNodes, withGuards), visibilityCache), true, withGuards);
|
35 | };
|
36 | exports.getTabbableNodes = getTabbableNodes;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | var getFocusableNodes = function (topNodes, visibilityCache) {
|
49 | return (0, tabOrder_1.orderByTabIndex)((0, exports.filterFocusable)((0, tabUtils_1.getFocusables)(topNodes), visibilityCache), false);
|
50 | };
|
51 | exports.getFocusableNodes = getFocusableNodes;
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | var parentAutofocusables = function (topNode, visibilityCache) {
|
58 | return (0, exports.filterFocusable)((0, tabUtils_1.getParentAutofocusables)(topNode), visibilityCache);
|
59 | };
|
60 | exports.parentAutofocusables = parentAutofocusables;
|
61 |
|
62 |
|
63 |
|
64 | var contains = function (scope, element) {
|
65 | if (scope.shadowRoot) {
|
66 | return (0, exports.contains)(scope.shadowRoot, element);
|
67 | }
|
68 | else {
|
69 | if (Object.getPrototypeOf(scope).contains !== undefined &&
|
70 | Object.getPrototypeOf(scope).contains.call(scope, element)) {
|
71 | return true;
|
72 | }
|
73 | return (0, array_1.toArray)(scope.children).some(function (child) {
|
74 | var _a;
|
75 | if (child instanceof HTMLIFrameElement) {
|
76 | var iframeBody = (_a = child.contentDocument) === null || _a === void 0 ? void 0 : _a.body;
|
77 | if (iframeBody) {
|
78 | return (0, exports.contains)(iframeBody, element);
|
79 | }
|
80 | return false;
|
81 | }
|
82 | return (0, exports.contains)(child, element);
|
83 | });
|
84 | }
|
85 | };
|
86 | exports.contains = contains;
|