power-focusable 4.3.21 → 4.3.23
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 +4 -4
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- 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.23';
|
|
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.23/+esm';
|
|
30
30
|
// or
|
|
31
|
-
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.
|
|
31
|
+
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.23';
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## 🪄 Options
|
|
@@ -103,7 +103,7 @@ Creates a keyboard focus trap within the container. Automatically focuses the co
|
|
|
103
103
|
const cleanup = createFocusTrap(container);
|
|
104
104
|
// => () => void
|
|
105
105
|
//
|
|
106
|
-
// container: Element
|
|
106
|
+
// container (optional): Element (default: <body>)
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### `getFocusables`
|
package/dist/index.cjs
CHANGED
|
@@ -8,9 +8,8 @@ var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
|
8
8
|
);
|
|
9
9
|
function createFocusTrap(container = document.body) {
|
|
10
10
|
if (!(container instanceof Element)) {
|
|
11
|
-
console.warn("Invalid container element");
|
|
12
|
-
|
|
13
|
-
};
|
|
11
|
+
console.warn("Invalid container element. Fallback: <body> element.");
|
|
12
|
+
container = document.body;
|
|
14
13
|
}
|
|
15
14
|
const trap = new FocusTrap(container);
|
|
16
15
|
return () => trap.destroy();
|
|
@@ -149,21 +148,22 @@ function inertOutside(element) {
|
|
|
149
148
|
return () => {
|
|
150
149
|
};
|
|
151
150
|
}
|
|
152
|
-
function traverse(node,
|
|
151
|
+
function traverse(node, fn) {
|
|
153
152
|
const parent = getComposedParent(node);
|
|
154
153
|
if (parent) {
|
|
155
154
|
for (const sibling of getComposedSiblings(node)) {
|
|
156
|
-
|
|
155
|
+
fn(sibling);
|
|
157
156
|
}
|
|
158
|
-
traverse(parent,
|
|
157
|
+
traverse(parent, fn);
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
const elements = [];
|
|
162
161
|
traverse(element, (node) => node && applyInert(node) && elements.push(node));
|
|
163
162
|
return () => {
|
|
164
|
-
elements.
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
164
|
+
const element2 = elements[i];
|
|
165
|
+
element2 && restoreInert(element2);
|
|
166
|
+
}
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
function isFocusable(element, options = {}) {
|
|
@@ -438,7 +438,7 @@ function applyInert(element) {
|
|
|
438
438
|
if (!isInert(element) || inertRefCounts.has(element)) {
|
|
439
439
|
const count = inertRefCounts.get(element) ?? 0;
|
|
440
440
|
inertRefCounts.set(element, count + 1);
|
|
441
|
-
count
|
|
441
|
+
!count && element.setAttribute("inert", "");
|
|
442
442
|
return true;
|
|
443
443
|
} else {
|
|
444
444
|
return false;
|
|
@@ -494,7 +494,7 @@ function isUngroupedRadio(element) {
|
|
|
494
494
|
* High-precision focus management utility with full composed tree support.
|
|
495
495
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
496
496
|
*
|
|
497
|
-
* @version 4.3.
|
|
497
|
+
* @version 4.3.23
|
|
498
498
|
* @author Yusuke Kamiyamane
|
|
499
499
|
* @license MIT
|
|
500
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.23
|
|
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.23
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,8 @@ var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
|
6
6
|
);
|
|
7
7
|
function createFocusTrap(container = document.body) {
|
|
8
8
|
if (!(container instanceof Element)) {
|
|
9
|
-
console.warn("Invalid container element");
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
console.warn("Invalid container element. Fallback: <body> element.");
|
|
10
|
+
container = document.body;
|
|
12
11
|
}
|
|
13
12
|
const trap = new FocusTrap(container);
|
|
14
13
|
return () => trap.destroy();
|
|
@@ -147,21 +146,22 @@ function inertOutside(element) {
|
|
|
147
146
|
return () => {
|
|
148
147
|
};
|
|
149
148
|
}
|
|
150
|
-
function traverse(node,
|
|
149
|
+
function traverse(node, fn) {
|
|
151
150
|
const parent = getComposedParent(node);
|
|
152
151
|
if (parent) {
|
|
153
152
|
for (const sibling of getComposedSiblings(node)) {
|
|
154
|
-
|
|
153
|
+
fn(sibling);
|
|
155
154
|
}
|
|
156
|
-
traverse(parent,
|
|
155
|
+
traverse(parent, fn);
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
const elements = [];
|
|
160
159
|
traverse(element, (node) => node && applyInert(node) && elements.push(node));
|
|
161
160
|
return () => {
|
|
162
|
-
elements.
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
162
|
+
const element2 = elements[i];
|
|
163
|
+
element2 && restoreInert(element2);
|
|
164
|
+
}
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
function isFocusable(element, options = {}) {
|
|
@@ -436,7 +436,7 @@ function applyInert(element) {
|
|
|
436
436
|
if (!isInert(element) || inertRefCounts.has(element)) {
|
|
437
437
|
const count = inertRefCounts.get(element) ?? 0;
|
|
438
438
|
inertRefCounts.set(element, count + 1);
|
|
439
|
-
count
|
|
439
|
+
!count && element.setAttribute("inert", "");
|
|
440
440
|
return true;
|
|
441
441
|
} else {
|
|
442
442
|
return false;
|
|
@@ -492,7 +492,7 @@ function isUngroupedRadio(element) {
|
|
|
492
492
|
* High-precision focus management utility with full composed tree support.
|
|
493
493
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
494
494
|
*
|
|
495
|
-
* @version 4.3.
|
|
495
|
+
* @version 4.3.23
|
|
496
496
|
* @author Yusuke Kamiyamane
|
|
497
497
|
* @license MIT
|
|
498
498
|
* @copyright Copyright (c) Yusuke Kamiyamane
|