power-focusable 4.3.18 → 4.3.19
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/README.md +3 -3
- package/dist/index.cjs +15 -14
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,11 @@ import {
|
|
|
24
24
|
} from 'power-focusable';
|
|
25
25
|
|
|
26
26
|
// CDNs
|
|
27
|
-
import { ... } 'https://esm.sh/power-focusable@4.3.
|
|
27
|
+
import { ... } 'https://esm.sh/power-focusable@4.3.19';
|
|
28
28
|
// or
|
|
29
|
-
import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.
|
|
29
|
+
import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.19/+esm';
|
|
30
30
|
// or
|
|
31
|
-
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.
|
|
31
|
+
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.19';
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## 🪄 Options
|
package/dist/index.cjs
CHANGED
|
@@ -96,14 +96,14 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
96
96
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
97
97
|
skipVisibilityCheck = false;
|
|
98
98
|
}
|
|
99
|
-
const
|
|
99
|
+
const candidates = [];
|
|
100
100
|
if (composed || include) {
|
|
101
101
|
let traverse2 = function(node) {
|
|
102
102
|
if (isFocusable(node, {
|
|
103
103
|
skipNegativeTabIndexCheck,
|
|
104
104
|
skipVisibilityCheck
|
|
105
105
|
}) || include?.(node)) {
|
|
106
|
-
|
|
106
|
+
candidates[candidates.length] = node;
|
|
107
107
|
}
|
|
108
108
|
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
109
109
|
for (let i = 0, l = children2.length; i < l; i++) {
|
|
@@ -117,21 +117,22 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
117
117
|
child && traverse2(child);
|
|
118
118
|
}
|
|
119
119
|
} else {
|
|
120
|
-
const
|
|
120
|
+
const matches = container.querySelectorAll(
|
|
121
121
|
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
122
122
|
);
|
|
123
|
-
for (let i = 0, l =
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
123
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
124
|
+
const matched = matches[i];
|
|
125
|
+
if (matched && isFocusable(matched, {
|
|
126
126
|
skipNegativeTabIndexCheck,
|
|
127
127
|
skipVisibilityCheck
|
|
128
128
|
})) {
|
|
129
|
-
|
|
129
|
+
candidates[candidates.length] = matched;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
return normalizeRadioGroup(
|
|
134
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
135
|
+
);
|
|
135
136
|
}
|
|
136
137
|
function getNextFocusable(container = document.body, options = {}) {
|
|
137
138
|
return getRelativeFocusable(container, 1, options);
|
|
@@ -265,12 +266,12 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
265
266
|
skipNegativeTabIndexCheck,
|
|
266
267
|
skipVisibilityCheck
|
|
267
268
|
};
|
|
268
|
-
const
|
|
269
|
-
const { length } =
|
|
269
|
+
const focusables = getFocusables(container, settings);
|
|
270
|
+
const { length } = focusables;
|
|
270
271
|
if (!length) {
|
|
271
272
|
return null;
|
|
272
273
|
}
|
|
273
|
-
const anchorIndex =
|
|
274
|
+
const anchorIndex = focusables.indexOf(anchor);
|
|
274
275
|
if (anchorIndex === -1) {
|
|
275
276
|
return null;
|
|
276
277
|
}
|
|
@@ -278,7 +279,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
278
279
|
if ((offsetIndex < 0 || offsetIndex >= length) && !wrap) {
|
|
279
280
|
return null;
|
|
280
281
|
}
|
|
281
|
-
return
|
|
282
|
+
return focusables[(offsetIndex + length) % length] ?? null;
|
|
282
283
|
}
|
|
283
284
|
function isDisabledDeep(element) {
|
|
284
285
|
let current = element;
|
|
@@ -493,7 +494,7 @@ function isUngroupedRadio(element) {
|
|
|
493
494
|
* High-precision focus management utility with full composed tree support.
|
|
494
495
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
495
496
|
*
|
|
496
|
-
* @version 4.3.
|
|
497
|
+
* @version 4.3.19
|
|
497
498
|
* @author Yusuke Kamiyamane
|
|
498
499
|
* @license MIT
|
|
499
500
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-precision focus management utility with full composed tree support.
|
|
4
4
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
5
5
|
*
|
|
6
|
-
* @version 4.3.
|
|
6
|
+
* @version 4.3.19
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-precision focus management utility with full composed tree support.
|
|
4
4
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
5
5
|
*
|
|
6
|
-
* @version 4.3.
|
|
6
|
+
* @version 4.3.19
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -94,14 +94,14 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
94
94
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
95
95
|
skipVisibilityCheck = false;
|
|
96
96
|
}
|
|
97
|
-
const
|
|
97
|
+
const candidates = [];
|
|
98
98
|
if (composed || include) {
|
|
99
99
|
let traverse2 = function(node) {
|
|
100
100
|
if (isFocusable(node, {
|
|
101
101
|
skipNegativeTabIndexCheck,
|
|
102
102
|
skipVisibilityCheck
|
|
103
103
|
}) || include?.(node)) {
|
|
104
|
-
|
|
104
|
+
candidates[candidates.length] = node;
|
|
105
105
|
}
|
|
106
106
|
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
107
107
|
for (let i = 0, l = children2.length; i < l; i++) {
|
|
@@ -115,21 +115,22 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
115
115
|
child && traverse2(child);
|
|
116
116
|
}
|
|
117
117
|
} else {
|
|
118
|
-
const
|
|
118
|
+
const matches = container.querySelectorAll(
|
|
119
119
|
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
120
120
|
);
|
|
121
|
-
for (let i = 0, l =
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
121
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
122
|
+
const matched = matches[i];
|
|
123
|
+
if (matched && isFocusable(matched, {
|
|
124
124
|
skipNegativeTabIndexCheck,
|
|
125
125
|
skipVisibilityCheck
|
|
126
126
|
})) {
|
|
127
|
-
|
|
127
|
+
candidates[candidates.length] = matched;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
return normalizeRadioGroup(
|
|
132
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
133
|
+
);
|
|
133
134
|
}
|
|
134
135
|
function getNextFocusable(container = document.body, options = {}) {
|
|
135
136
|
return getRelativeFocusable(container, 1, options);
|
|
@@ -263,12 +264,12 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
263
264
|
skipNegativeTabIndexCheck,
|
|
264
265
|
skipVisibilityCheck
|
|
265
266
|
};
|
|
266
|
-
const
|
|
267
|
-
const { length } =
|
|
267
|
+
const focusables = getFocusables(container, settings);
|
|
268
|
+
const { length } = focusables;
|
|
268
269
|
if (!length) {
|
|
269
270
|
return null;
|
|
270
271
|
}
|
|
271
|
-
const anchorIndex =
|
|
272
|
+
const anchorIndex = focusables.indexOf(anchor);
|
|
272
273
|
if (anchorIndex === -1) {
|
|
273
274
|
return null;
|
|
274
275
|
}
|
|
@@ -276,7 +277,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
276
277
|
if ((offsetIndex < 0 || offsetIndex >= length) && !wrap) {
|
|
277
278
|
return null;
|
|
278
279
|
}
|
|
279
|
-
return
|
|
280
|
+
return focusables[(offsetIndex + length) % length] ?? null;
|
|
280
281
|
}
|
|
281
282
|
function isDisabledDeep(element) {
|
|
282
283
|
let current = element;
|
|
@@ -491,7 +492,7 @@ function isUngroupedRadio(element) {
|
|
|
491
492
|
* High-precision focus management utility with full composed tree support.
|
|
492
493
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
493
494
|
*
|
|
494
|
-
* @version 4.3.
|
|
495
|
+
* @version 4.3.19
|
|
495
496
|
* @author Yusuke Kamiyamane
|
|
496
497
|
* @license MIT
|
|
497
498
|
* @copyright Copyright (c) Yusuke Kamiyamane
|