power-focusable 4.3.14 → 4.3.16
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 -15
- package/dist/index.cjs +21 -21
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -21
- 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.16';
|
|
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.16/+esm';
|
|
30
30
|
// or
|
|
31
|
-
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.
|
|
31
|
+
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.16';
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## 🪄 Options
|
|
@@ -121,9 +121,6 @@ getFocusables(container, { composed: true });
|
|
|
121
121
|
|
|
122
122
|
// Uses custom filter function
|
|
123
123
|
getFocusables(container, { filter: (element) => !element.matches('[data-skip-focus]') });
|
|
124
|
-
|
|
125
|
-
// Uses custom include function
|
|
126
|
-
getFocusables(container, { filter: (element) => element.matches('[data-force-focusable]') });
|
|
127
124
|
```
|
|
128
125
|
|
|
129
126
|
### `getNextFocusable`
|
|
@@ -145,9 +142,6 @@ getNextFocusable(container, { composed: true });
|
|
|
145
142
|
// Uses custom filter function
|
|
146
143
|
getNextFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
|
|
147
144
|
|
|
148
|
-
// Uses custom include function
|
|
149
|
-
getNextFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
|
|
150
|
-
|
|
151
145
|
// Wraps around to the first element when reaching the end
|
|
152
146
|
getNextFocusable(container, { wrap: true });
|
|
153
147
|
```
|
|
@@ -171,9 +165,6 @@ getPreviousFocusable(container, { composed: true });
|
|
|
171
165
|
// Uses custom filter function
|
|
172
166
|
getPreviousFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
|
|
173
167
|
|
|
174
|
-
// Uses custom include function
|
|
175
|
-
getPreviousFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
|
|
176
|
-
|
|
177
168
|
// Wraps around to the last element when reaching the end
|
|
178
169
|
getPreviousFocusable(container, { wrap: true });
|
|
179
170
|
|
|
@@ -194,9 +185,6 @@ hasFocusable(container, { composed: true });
|
|
|
194
185
|
|
|
195
186
|
// Uses custom filter function
|
|
196
187
|
hasFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
|
|
197
|
-
|
|
198
|
-
// Uses custom include function
|
|
199
|
-
hasFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
|
|
200
188
|
```
|
|
201
189
|
|
|
202
190
|
### `inertOutside`
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
|
|
5
|
-
var
|
|
5
|
+
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
6
6
|
/(,\s*)?\[tabindex="-1"\]/g,
|
|
7
7
|
""
|
|
8
8
|
);
|
|
@@ -118,7 +118,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
} else {
|
|
120
120
|
const candidates = container.querySelectorAll(
|
|
121
|
-
skipNegativeTabIndexCheck ?
|
|
121
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
122
122
|
);
|
|
123
123
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
124
124
|
const candidate = candidates[i];
|
|
@@ -186,7 +186,7 @@ function isFocusable(element, options = {}) {
|
|
|
186
186
|
return false;
|
|
187
187
|
}
|
|
188
188
|
if (!element.matches(
|
|
189
|
-
skipNegativeTabIndexCheck ?
|
|
189
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
190
190
|
)) {
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
@@ -323,31 +323,31 @@ function normalizeRadioGroup(elements) {
|
|
|
323
323
|
map = /* @__PURE__ */ new Map();
|
|
324
324
|
}
|
|
325
325
|
const root = element.getRootNode();
|
|
326
|
-
let
|
|
327
|
-
if (!
|
|
328
|
-
|
|
329
|
-
map.set(root,
|
|
326
|
+
let value = map.get(root);
|
|
327
|
+
if (!value) {
|
|
328
|
+
value = /* @__PURE__ */ new Map();
|
|
329
|
+
map.set(root, value);
|
|
330
330
|
}
|
|
331
|
-
let
|
|
332
|
-
if (!
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
let v = value.get(element.form);
|
|
332
|
+
if (!v) {
|
|
333
|
+
v = /* @__PURE__ */ new Map();
|
|
334
|
+
value.set(element.form, v);
|
|
335
335
|
}
|
|
336
|
-
let
|
|
337
|
-
if (!
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
let vv = v.get(element.name);
|
|
337
|
+
if (!vv) {
|
|
338
|
+
vv = [];
|
|
339
|
+
v.set(element.name, vv);
|
|
340
340
|
}
|
|
341
|
-
|
|
341
|
+
vv[vv.length] = element;
|
|
342
342
|
}
|
|
343
343
|
if (!map) {
|
|
344
344
|
return elements;
|
|
345
345
|
}
|
|
346
346
|
const placeholder = /* @__PURE__ */ new Set();
|
|
347
|
-
for (const
|
|
348
|
-
for (const
|
|
349
|
-
for (const
|
|
350
|
-
const radio =
|
|
347
|
+
for (const value of map.values()) {
|
|
348
|
+
for (const v of value.values()) {
|
|
349
|
+
for (const vv of v.values()) {
|
|
350
|
+
const radio = vv.find((element) => element.checked) ?? vv[0];
|
|
351
351
|
radio && placeholder.add(radio);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
@@ -493,7 +493,7 @@ function isUngroupedRadio(element) {
|
|
|
493
493
|
* High-precision focus management utility with full composed tree support.
|
|
494
494
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
495
495
|
*
|
|
496
|
-
* @version 4.3.
|
|
496
|
+
* @version 4.3.16
|
|
497
497
|
* @author Yusuke Kamiyamane
|
|
498
498
|
* @license MIT
|
|
499
499
|
* @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.16
|
|
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.16
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
|
|
3
|
-
var
|
|
3
|
+
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
4
4
|
/(,\s*)?\[tabindex="-1"\]/g,
|
|
5
5
|
""
|
|
6
6
|
);
|
|
@@ -116,7 +116,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
116
116
|
}
|
|
117
117
|
} else {
|
|
118
118
|
const candidates = container.querySelectorAll(
|
|
119
|
-
skipNegativeTabIndexCheck ?
|
|
119
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
120
120
|
);
|
|
121
121
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
122
122
|
const candidate = candidates[i];
|
|
@@ -184,7 +184,7 @@ function isFocusable(element, options = {}) {
|
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
186
186
|
if (!element.matches(
|
|
187
|
-
skipNegativeTabIndexCheck ?
|
|
187
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
188
188
|
)) {
|
|
189
189
|
return false;
|
|
190
190
|
}
|
|
@@ -321,31 +321,31 @@ function normalizeRadioGroup(elements) {
|
|
|
321
321
|
map = /* @__PURE__ */ new Map();
|
|
322
322
|
}
|
|
323
323
|
const root = element.getRootNode();
|
|
324
|
-
let
|
|
325
|
-
if (!
|
|
326
|
-
|
|
327
|
-
map.set(root,
|
|
324
|
+
let value = map.get(root);
|
|
325
|
+
if (!value) {
|
|
326
|
+
value = /* @__PURE__ */ new Map();
|
|
327
|
+
map.set(root, value);
|
|
328
328
|
}
|
|
329
|
-
let
|
|
330
|
-
if (!
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
let v = value.get(element.form);
|
|
330
|
+
if (!v) {
|
|
331
|
+
v = /* @__PURE__ */ new Map();
|
|
332
|
+
value.set(element.form, v);
|
|
333
333
|
}
|
|
334
|
-
let
|
|
335
|
-
if (!
|
|
336
|
-
|
|
337
|
-
|
|
334
|
+
let vv = v.get(element.name);
|
|
335
|
+
if (!vv) {
|
|
336
|
+
vv = [];
|
|
337
|
+
v.set(element.name, vv);
|
|
338
338
|
}
|
|
339
|
-
|
|
339
|
+
vv[vv.length] = element;
|
|
340
340
|
}
|
|
341
341
|
if (!map) {
|
|
342
342
|
return elements;
|
|
343
343
|
}
|
|
344
344
|
const placeholder = /* @__PURE__ */ new Set();
|
|
345
|
-
for (const
|
|
346
|
-
for (const
|
|
347
|
-
for (const
|
|
348
|
-
const radio =
|
|
345
|
+
for (const value of map.values()) {
|
|
346
|
+
for (const v of value.values()) {
|
|
347
|
+
for (const vv of v.values()) {
|
|
348
|
+
const radio = vv.find((element) => element.checked) ?? vv[0];
|
|
349
349
|
radio && placeholder.add(radio);
|
|
350
350
|
}
|
|
351
351
|
}
|
|
@@ -491,7 +491,7 @@ function isUngroupedRadio(element) {
|
|
|
491
491
|
* High-precision focus management utility with full composed tree support.
|
|
492
492
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
493
493
|
*
|
|
494
|
-
* @version 4.3.
|
|
494
|
+
* @version 4.3.16
|
|
495
495
|
* @author Yusuke Kamiyamane
|
|
496
496
|
* @license MIT
|
|
497
497
|
* @copyright Copyright (c) Yusuke Kamiyamane
|