@y14e/roving-tabindex 3.1.16 → 3.1.17
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 +14 -13
- package/dist/index.bundle.js +14 -13
- package/dist/index.cjs +14 -13
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -13
- package/package.json +1 -1
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.17';
|
|
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.17/+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.17';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -459,16 +459,16 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
459
459
|
if (!(active instanceof Element)) {
|
|
460
460
|
return;
|
|
461
461
|
}
|
|
462
|
-
const
|
|
462
|
+
const candidates = this.#getFocusables().filter(
|
|
463
463
|
(focusable2) => this.#focusables.has(focusable2)
|
|
464
464
|
);
|
|
465
|
-
if (!
|
|
465
|
+
if (!candidates.includes(active)) {
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
468
|
event.preventDefault();
|
|
469
|
-
const
|
|
469
|
+
const activeIndex = candidates.indexOf(active);
|
|
470
470
|
let newIndex;
|
|
471
|
-
let target =
|
|
471
|
+
let target = candidates;
|
|
472
472
|
switch (key) {
|
|
473
473
|
case "End":
|
|
474
474
|
newIndex = -1;
|
|
@@ -478,25 +478,26 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
478
478
|
break;
|
|
479
479
|
case "ArrowLeft":
|
|
480
480
|
case "ArrowUp": {
|
|
481
|
-
const rawIndex =
|
|
481
|
+
const rawIndex = activeIndex - 1;
|
|
482
482
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
483
483
|
break;
|
|
484
484
|
}
|
|
485
485
|
case "ArrowRight":
|
|
486
486
|
case "ArrowDown": {
|
|
487
|
-
const rawIndex =
|
|
488
|
-
|
|
487
|
+
const rawIndex = activeIndex + 1;
|
|
488
|
+
const length = target.length;
|
|
489
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
489
490
|
break;
|
|
490
491
|
}
|
|
491
492
|
default: {
|
|
492
493
|
const focusables = new Set(
|
|
493
494
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
494
495
|
);
|
|
495
|
-
target =
|
|
496
|
-
const
|
|
497
|
-
(focusable2) =>
|
|
496
|
+
target = candidates.filter((focusable2) => focusables.has(focusable2));
|
|
497
|
+
const afterIndex = target.findIndex(
|
|
498
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
498
499
|
);
|
|
499
|
-
newIndex =
|
|
500
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
503
|
const focusable = target.at(newIndex);
|
|
@@ -567,7 +568,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
567
568
|
}
|
|
568
569
|
#createSelectorFilter() {
|
|
569
570
|
const { selector } = this.#settings;
|
|
570
|
-
return (element) => !selector ||
|
|
571
|
+
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
571
572
|
}
|
|
572
573
|
#getFocusables() {
|
|
573
574
|
return getFocusables(this.#container, {
|
|
@@ -583,7 +584,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
583
584
|
* Lightweight roving tabindex utility with fully focus management.
|
|
584
585
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
585
586
|
*
|
|
586
|
-
* @version 3.1.
|
|
587
|
+
* @version 3.1.17
|
|
587
588
|
* @author Yusuke Kamiyamane
|
|
588
589
|
* @license MIT
|
|
589
590
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.bundle.js
CHANGED
|
@@ -457,16 +457,16 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
457
457
|
if (!(active instanceof Element)) {
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
460
|
-
const
|
|
460
|
+
const candidates = this.#getFocusables().filter(
|
|
461
461
|
(focusable2) => this.#focusables.has(focusable2)
|
|
462
462
|
);
|
|
463
|
-
if (!
|
|
463
|
+
if (!candidates.includes(active)) {
|
|
464
464
|
return;
|
|
465
465
|
}
|
|
466
466
|
event.preventDefault();
|
|
467
|
-
const
|
|
467
|
+
const activeIndex = candidates.indexOf(active);
|
|
468
468
|
let newIndex;
|
|
469
|
-
let target =
|
|
469
|
+
let target = candidates;
|
|
470
470
|
switch (key) {
|
|
471
471
|
case "End":
|
|
472
472
|
newIndex = -1;
|
|
@@ -476,25 +476,26 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
476
476
|
break;
|
|
477
477
|
case "ArrowLeft":
|
|
478
478
|
case "ArrowUp": {
|
|
479
|
-
const rawIndex =
|
|
479
|
+
const rawIndex = activeIndex - 1;
|
|
480
480
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
481
481
|
break;
|
|
482
482
|
}
|
|
483
483
|
case "ArrowRight":
|
|
484
484
|
case "ArrowDown": {
|
|
485
|
-
const rawIndex =
|
|
486
|
-
|
|
485
|
+
const rawIndex = activeIndex + 1;
|
|
486
|
+
const length = target.length;
|
|
487
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
487
488
|
break;
|
|
488
489
|
}
|
|
489
490
|
default: {
|
|
490
491
|
const focusables = new Set(
|
|
491
492
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
492
493
|
);
|
|
493
|
-
target =
|
|
494
|
-
const
|
|
495
|
-
(focusable2) =>
|
|
494
|
+
target = candidates.filter((focusable2) => focusables.has(focusable2));
|
|
495
|
+
const afterIndex = target.findIndex(
|
|
496
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
496
497
|
);
|
|
497
|
-
newIndex =
|
|
498
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
const focusable = target.at(newIndex);
|
|
@@ -565,7 +566,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
565
566
|
}
|
|
566
567
|
#createSelectorFilter() {
|
|
567
568
|
const { selector } = this.#settings;
|
|
568
|
-
return (element) => !selector ||
|
|
569
|
+
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
569
570
|
}
|
|
570
571
|
#getFocusables() {
|
|
571
572
|
return getFocusables(this.#container, {
|
|
@@ -581,7 +582,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
581
582
|
* Lightweight roving tabindex utility with fully focus management.
|
|
582
583
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
583
584
|
*
|
|
584
|
-
* @version 3.1.
|
|
585
|
+
* @version 3.1.17
|
|
585
586
|
* @author Yusuke Kamiyamane
|
|
586
587
|
* @license MIT
|
|
587
588
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -145,16 +145,16 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
145
145
|
if (!(active instanceof Element)) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const candidates = this.#getFocusables().filter(
|
|
149
149
|
(focusable2) => this.#focusables.has(focusable2)
|
|
150
150
|
);
|
|
151
|
-
if (!
|
|
151
|
+
if (!candidates.includes(active)) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
event.preventDefault();
|
|
155
|
-
const
|
|
155
|
+
const activeIndex = candidates.indexOf(active);
|
|
156
156
|
let newIndex;
|
|
157
|
-
let target =
|
|
157
|
+
let target = candidates;
|
|
158
158
|
switch (key) {
|
|
159
159
|
case "End":
|
|
160
160
|
newIndex = -1;
|
|
@@ -164,25 +164,26 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
164
164
|
break;
|
|
165
165
|
case "ArrowLeft":
|
|
166
166
|
case "ArrowUp": {
|
|
167
|
-
const rawIndex =
|
|
167
|
+
const rawIndex = activeIndex - 1;
|
|
168
168
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
171
171
|
case "ArrowRight":
|
|
172
172
|
case "ArrowDown": {
|
|
173
|
-
const rawIndex =
|
|
174
|
-
|
|
173
|
+
const rawIndex = activeIndex + 1;
|
|
174
|
+
const length = target.length;
|
|
175
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
175
176
|
break;
|
|
176
177
|
}
|
|
177
178
|
default: {
|
|
178
179
|
const focusables = new Set(
|
|
179
180
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
180
181
|
);
|
|
181
|
-
target =
|
|
182
|
-
const
|
|
183
|
-
(focusable2) =>
|
|
182
|
+
target = candidates.filter((focusable2) => focusables.has(focusable2));
|
|
183
|
+
const afterIndex = target.findIndex(
|
|
184
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
184
185
|
);
|
|
185
|
-
newIndex =
|
|
186
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
const focusable = target.at(newIndex);
|
|
@@ -253,7 +254,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
253
254
|
}
|
|
254
255
|
#createSelectorFilter() {
|
|
255
256
|
const { selector } = this.#settings;
|
|
256
|
-
return (element) => !selector ||
|
|
257
|
+
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
257
258
|
}
|
|
258
259
|
#getFocusables() {
|
|
259
260
|
return powerFocusable.getFocusables(this.#container, {
|
|
@@ -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.17
|
|
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.17
|
|
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.17
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -143,16 +143,16 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
143
143
|
if (!(active instanceof Element)) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
const
|
|
146
|
+
const candidates = this.#getFocusables().filter(
|
|
147
147
|
(focusable2) => this.#focusables.has(focusable2)
|
|
148
148
|
);
|
|
149
|
-
if (!
|
|
149
|
+
if (!candidates.includes(active)) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
event.preventDefault();
|
|
153
|
-
const
|
|
153
|
+
const activeIndex = candidates.indexOf(active);
|
|
154
154
|
let newIndex;
|
|
155
|
-
let target =
|
|
155
|
+
let target = candidates;
|
|
156
156
|
switch (key) {
|
|
157
157
|
case "End":
|
|
158
158
|
newIndex = -1;
|
|
@@ -162,25 +162,26 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
162
162
|
break;
|
|
163
163
|
case "ArrowLeft":
|
|
164
164
|
case "ArrowUp": {
|
|
165
|
-
const rawIndex =
|
|
165
|
+
const rawIndex = activeIndex - 1;
|
|
166
166
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
169
|
case "ArrowRight":
|
|
170
170
|
case "ArrowDown": {
|
|
171
|
-
const rawIndex =
|
|
172
|
-
|
|
171
|
+
const rawIndex = activeIndex + 1;
|
|
172
|
+
const length = target.length;
|
|
173
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
173
174
|
break;
|
|
174
175
|
}
|
|
175
176
|
default: {
|
|
176
177
|
const focusables = new Set(
|
|
177
178
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
178
179
|
);
|
|
179
|
-
target =
|
|
180
|
-
const
|
|
181
|
-
(focusable2) =>
|
|
180
|
+
target = candidates.filter((focusable2) => focusables.has(focusable2));
|
|
181
|
+
const afterIndex = target.findIndex(
|
|
182
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
182
183
|
);
|
|
183
|
-
newIndex =
|
|
184
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
const focusable = target.at(newIndex);
|
|
@@ -251,7 +252,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
251
252
|
}
|
|
252
253
|
#createSelectorFilter() {
|
|
253
254
|
const { selector } = this.#settings;
|
|
254
|
-
return (element) => !selector ||
|
|
255
|
+
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
255
256
|
}
|
|
256
257
|
#getFocusables() {
|
|
257
258
|
return getFocusables(this.#container, {
|
|
@@ -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.17
|
|
271
272
|
* @author Yusuke Kamiyamane
|
|
272
273
|
* @license MIT
|
|
273
274
|
* @copyright Copyright (c) Yusuke Kamiyamane
|