@y14e/roving-tabindex 3.1.14 → 3.1.15
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.bundle.cjs +24 -22
- package/dist/index.bundle.js +24 -22
- package/dist/index.cjs +13 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm i @y14e/roving-tabindex
|
|
|
13
13
|
import { createRovingTabIndex } from '@y14e/roving-tabindex';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.
|
|
16
|
+
import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.15';
|
|
17
17
|
// or
|
|
18
|
-
import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.
|
|
18
|
+
import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.15/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.
|
|
20
|
+
import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.15';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -91,14 +91,14 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
91
91
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
92
92
|
skipVisibilityCheck = false;
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const candidates = [];
|
|
95
95
|
if (composed || include) {
|
|
96
96
|
let traverse2 = function(node) {
|
|
97
97
|
if (isFocusable(node, {
|
|
98
98
|
skipNegativeTabIndexCheck,
|
|
99
99
|
skipVisibilityCheck
|
|
100
100
|
}) || include?.(node)) {
|
|
101
|
-
|
|
101
|
+
candidates[candidates.length] = node;
|
|
102
102
|
}
|
|
103
103
|
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
104
104
|
for (let i = 0, l = children2.length; i < l; i++) {
|
|
@@ -112,21 +112,22 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
112
112
|
child && traverse2(child);
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
|
-
const
|
|
115
|
+
const matches = container.querySelectorAll(
|
|
116
116
|
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
117
117
|
);
|
|
118
|
-
for (let i = 0, l =
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
118
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
119
|
+
const matched = matches[i];
|
|
120
|
+
if (matched && isFocusable(matched, {
|
|
121
121
|
skipNegativeTabIndexCheck,
|
|
122
122
|
skipVisibilityCheck
|
|
123
123
|
})) {
|
|
124
|
-
|
|
124
|
+
candidates[candidates.length] = matched;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
return normalizeRadioGroup(
|
|
129
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
130
|
+
);
|
|
130
131
|
}
|
|
131
132
|
function isFocusable(element, options = {}) {
|
|
132
133
|
if (!(element instanceof Element)) {
|
|
@@ -485,7 +486,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
485
486
|
case "ArrowRight":
|
|
486
487
|
case "ArrowDown": {
|
|
487
488
|
const rawIndex = activeIndex + 1;
|
|
488
|
-
|
|
489
|
+
const length = target.length;
|
|
490
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
489
491
|
break;
|
|
490
492
|
}
|
|
491
493
|
default: {
|
|
@@ -503,23 +505,23 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
503
505
|
focusable && focusElement(focusable);
|
|
504
506
|
};
|
|
505
507
|
#update(active) {
|
|
506
|
-
const
|
|
508
|
+
const current = new Set(this.#getFocusables());
|
|
507
509
|
for (const focusable of this.#focusables) {
|
|
508
|
-
if (!
|
|
510
|
+
if (!current.has(focusable)) {
|
|
509
511
|
_RovingTabIndex.#initialized.delete(focusable);
|
|
510
512
|
restoreAttributes([focusable]);
|
|
511
513
|
this.#focusables.delete(focusable);
|
|
512
|
-
for (const [key,
|
|
513
|
-
const index =
|
|
514
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
515
|
+
const index = focusables.indexOf(focusable);
|
|
514
516
|
if (index >= 0) {
|
|
515
|
-
|
|
516
|
-
!
|
|
517
|
+
focusables.splice(index, 1);
|
|
518
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
517
519
|
}
|
|
518
520
|
}
|
|
519
521
|
}
|
|
520
522
|
}
|
|
521
523
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
522
|
-
for (const focusable of
|
|
524
|
+
for (const focusable of current) {
|
|
523
525
|
if (this.#focusables.has(focusable)) {
|
|
524
526
|
continue;
|
|
525
527
|
}
|
|
@@ -548,9 +550,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
548
550
|
});
|
|
549
551
|
}
|
|
550
552
|
keys.forEach((key) => {
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
this.#focusablesByFirstChar.set(key,
|
|
553
|
+
const focusables = this.#focusablesByFirstChar.get(key) ?? [];
|
|
554
|
+
focusables.push(focusable);
|
|
555
|
+
this.#focusablesByFirstChar.set(key, focusables);
|
|
554
556
|
});
|
|
555
557
|
}
|
|
556
558
|
if (!navigationOnly) {
|
|
@@ -583,7 +585,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
583
585
|
* Lightweight roving tabindex utility with fully focus management.
|
|
584
586
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
585
587
|
*
|
|
586
|
-
* @version 3.1.
|
|
588
|
+
* @version 3.1.15
|
|
587
589
|
* @author Yusuke Kamiyamane
|
|
588
590
|
* @license MIT
|
|
589
591
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -608,7 +610,7 @@ power-focusable/dist/index.js:
|
|
|
608
610
|
* High-precision focus management utility with full composed tree support.
|
|
609
611
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
610
612
|
*
|
|
611
|
-
* @version 4.3.
|
|
613
|
+
* @version 4.3.19
|
|
612
614
|
* @author Yusuke Kamiyamane
|
|
613
615
|
* @license MIT
|
|
614
616
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.bundle.js
CHANGED
|
@@ -89,14 +89,14 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
89
89
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
90
90
|
skipVisibilityCheck = false;
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const candidates = [];
|
|
93
93
|
if (composed || include) {
|
|
94
94
|
let traverse2 = function(node) {
|
|
95
95
|
if (isFocusable(node, {
|
|
96
96
|
skipNegativeTabIndexCheck,
|
|
97
97
|
skipVisibilityCheck
|
|
98
98
|
}) || include?.(node)) {
|
|
99
|
-
|
|
99
|
+
candidates[candidates.length] = node;
|
|
100
100
|
}
|
|
101
101
|
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
102
102
|
for (let i = 0, l = children2.length; i < l; i++) {
|
|
@@ -110,21 +110,22 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
110
110
|
child && traverse2(child);
|
|
111
111
|
}
|
|
112
112
|
} else {
|
|
113
|
-
const
|
|
113
|
+
const matches = container.querySelectorAll(
|
|
114
114
|
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
115
115
|
);
|
|
116
|
-
for (let i = 0, l =
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
116
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
117
|
+
const matched = matches[i];
|
|
118
|
+
if (matched && isFocusable(matched, {
|
|
119
119
|
skipNegativeTabIndexCheck,
|
|
120
120
|
skipVisibilityCheck
|
|
121
121
|
})) {
|
|
122
|
-
|
|
122
|
+
candidates[candidates.length] = matched;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
return normalizeRadioGroup(
|
|
127
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
128
|
+
);
|
|
128
129
|
}
|
|
129
130
|
function isFocusable(element, options = {}) {
|
|
130
131
|
if (!(element instanceof Element)) {
|
|
@@ -483,7 +484,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
483
484
|
case "ArrowRight":
|
|
484
485
|
case "ArrowDown": {
|
|
485
486
|
const rawIndex = activeIndex + 1;
|
|
486
|
-
|
|
487
|
+
const length = target.length;
|
|
488
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
487
489
|
break;
|
|
488
490
|
}
|
|
489
491
|
default: {
|
|
@@ -501,23 +503,23 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
501
503
|
focusable && focusElement(focusable);
|
|
502
504
|
};
|
|
503
505
|
#update(active) {
|
|
504
|
-
const
|
|
506
|
+
const current = new Set(this.#getFocusables());
|
|
505
507
|
for (const focusable of this.#focusables) {
|
|
506
|
-
if (!
|
|
508
|
+
if (!current.has(focusable)) {
|
|
507
509
|
_RovingTabIndex.#initialized.delete(focusable);
|
|
508
510
|
restoreAttributes([focusable]);
|
|
509
511
|
this.#focusables.delete(focusable);
|
|
510
|
-
for (const [key,
|
|
511
|
-
const index =
|
|
512
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
513
|
+
const index = focusables.indexOf(focusable);
|
|
512
514
|
if (index >= 0) {
|
|
513
|
-
|
|
514
|
-
!
|
|
515
|
+
focusables.splice(index, 1);
|
|
516
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
519
|
}
|
|
518
520
|
}
|
|
519
521
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
520
|
-
for (const focusable of
|
|
522
|
+
for (const focusable of current) {
|
|
521
523
|
if (this.#focusables.has(focusable)) {
|
|
522
524
|
continue;
|
|
523
525
|
}
|
|
@@ -546,9 +548,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
546
548
|
});
|
|
547
549
|
}
|
|
548
550
|
keys.forEach((key) => {
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
this.#focusablesByFirstChar.set(key,
|
|
551
|
+
const focusables = this.#focusablesByFirstChar.get(key) ?? [];
|
|
552
|
+
focusables.push(focusable);
|
|
553
|
+
this.#focusablesByFirstChar.set(key, focusables);
|
|
552
554
|
});
|
|
553
555
|
}
|
|
554
556
|
if (!navigationOnly) {
|
|
@@ -581,7 +583,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
581
583
|
* Lightweight roving tabindex utility with fully focus management.
|
|
582
584
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
583
585
|
*
|
|
584
|
-
* @version 3.1.
|
|
586
|
+
* @version 3.1.15
|
|
585
587
|
* @author Yusuke Kamiyamane
|
|
586
588
|
* @license MIT
|
|
587
589
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -606,7 +608,7 @@ power-focusable/dist/index.js:
|
|
|
606
608
|
* High-precision focus management utility with full composed tree support.
|
|
607
609
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
608
610
|
*
|
|
609
|
-
* @version 4.3.
|
|
611
|
+
* @version 4.3.19
|
|
610
612
|
* @author Yusuke Kamiyamane
|
|
611
613
|
* @license MIT
|
|
612
614
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -171,7 +171,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
171
171
|
case "ArrowRight":
|
|
172
172
|
case "ArrowDown": {
|
|
173
173
|
const rawIndex = activeIndex + 1;
|
|
174
|
-
|
|
174
|
+
const length = target.length;
|
|
175
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
175
176
|
break;
|
|
176
177
|
}
|
|
177
178
|
default: {
|
|
@@ -189,23 +190,23 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
189
190
|
focusable && powerFocusable.focusElement(focusable);
|
|
190
191
|
};
|
|
191
192
|
#update(active) {
|
|
192
|
-
const
|
|
193
|
+
const current = new Set(this.#getFocusables());
|
|
193
194
|
for (const focusable of this.#focusables) {
|
|
194
|
-
if (!
|
|
195
|
+
if (!current.has(focusable)) {
|
|
195
196
|
_RovingTabIndex.#initialized.delete(focusable);
|
|
196
197
|
attributesUtils.restoreAttributes([focusable]);
|
|
197
198
|
this.#focusables.delete(focusable);
|
|
198
|
-
for (const [key,
|
|
199
|
-
const index =
|
|
199
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
200
|
+
const index = focusables.indexOf(focusable);
|
|
200
201
|
if (index >= 0) {
|
|
201
|
-
|
|
202
|
-
!
|
|
202
|
+
focusables.splice(index, 1);
|
|
203
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
208
|
-
for (const focusable of
|
|
209
|
+
for (const focusable of current) {
|
|
209
210
|
if (this.#focusables.has(focusable)) {
|
|
210
211
|
continue;
|
|
211
212
|
}
|
|
@@ -234,9 +235,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
237
|
keys.forEach((key) => {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
this.#focusablesByFirstChar.set(key,
|
|
238
|
+
const focusables = this.#focusablesByFirstChar.get(key) ?? [];
|
|
239
|
+
focusables.push(focusable);
|
|
240
|
+
this.#focusablesByFirstChar.set(key, focusables);
|
|
240
241
|
});
|
|
241
242
|
}
|
|
242
243
|
if (!navigationOnly) {
|
|
@@ -269,7 +270,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
269
270
|
* Lightweight roving tabindex utility with fully focus management.
|
|
270
271
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
271
272
|
*
|
|
272
|
-
* @version 3.1.
|
|
273
|
+
* @version 3.1.15
|
|
273
274
|
* @author Yusuke Kamiyamane
|
|
274
275
|
* @license MIT
|
|
275
276
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Lightweight roving tabindex utility with fully focus management.
|
|
4
4
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
5
5
|
*
|
|
6
|
-
* @version 3.1.
|
|
6
|
+
* @version 3.1.15
|
|
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
|
* Lightweight roving tabindex utility with fully focus management.
|
|
4
4
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
5
5
|
*
|
|
6
|
-
* @version 3.1.
|
|
6
|
+
* @version 3.1.15
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -169,7 +169,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
169
169
|
case "ArrowRight":
|
|
170
170
|
case "ArrowDown": {
|
|
171
171
|
const rawIndex = activeIndex + 1;
|
|
172
|
-
|
|
172
|
+
const length = target.length;
|
|
173
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
173
174
|
break;
|
|
174
175
|
}
|
|
175
176
|
default: {
|
|
@@ -187,23 +188,23 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
187
188
|
focusable && focusElement(focusable);
|
|
188
189
|
};
|
|
189
190
|
#update(active) {
|
|
190
|
-
const
|
|
191
|
+
const current = new Set(this.#getFocusables());
|
|
191
192
|
for (const focusable of this.#focusables) {
|
|
192
|
-
if (!
|
|
193
|
+
if (!current.has(focusable)) {
|
|
193
194
|
_RovingTabIndex.#initialized.delete(focusable);
|
|
194
195
|
restoreAttributes([focusable]);
|
|
195
196
|
this.#focusables.delete(focusable);
|
|
196
|
-
for (const [key,
|
|
197
|
-
const index =
|
|
197
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
198
|
+
const index = focusables.indexOf(focusable);
|
|
198
199
|
if (index >= 0) {
|
|
199
|
-
|
|
200
|
-
!
|
|
200
|
+
focusables.splice(index, 1);
|
|
201
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
206
|
-
for (const focusable of
|
|
207
|
+
for (const focusable of current) {
|
|
207
208
|
if (this.#focusables.has(focusable)) {
|
|
208
209
|
continue;
|
|
209
210
|
}
|
|
@@ -232,9 +233,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
keys.forEach((key) => {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
this.#focusablesByFirstChar.set(key,
|
|
236
|
+
const focusables = this.#focusablesByFirstChar.get(key) ?? [];
|
|
237
|
+
focusables.push(focusable);
|
|
238
|
+
this.#focusablesByFirstChar.set(key, focusables);
|
|
238
239
|
});
|
|
239
240
|
}
|
|
240
241
|
if (!navigationOnly) {
|
|
@@ -267,7 +268,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
267
268
|
* Lightweight roving tabindex utility with fully focus management.
|
|
268
269
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
269
270
|
*
|
|
270
|
-
* @version 3.1.
|
|
271
|
+
* @version 3.1.15
|
|
271
272
|
* @author Yusuke Kamiyamane
|
|
272
273
|
* @license MIT
|
|
273
274
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/roving-tabindex",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.15",
|
|
4
4
|
"description": "Lightweight roving tabindex utility with fully focus management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@y14e/attributes-utils": "^1.1.3",
|
|
60
|
-
"power-focusable": "^4.3.
|
|
60
|
+
"power-focusable": "^4.3.19"
|
|
61
61
|
}
|
|
62
62
|
}
|