@y14e/roving-tabindex 3.1.14 → 3.1.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 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.14';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.16';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.14/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.16/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.14';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.16';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -459,16 +459,16 @@ var RovingTabIndex = class _RovingTabIndex {
459
459
  if (!(active instanceof Element)) {
460
460
  return;
461
461
  }
462
- const candidates = this.#getFocusables().filter(
462
+ const current = this.#getFocusables().filter(
463
463
  (focusable2) => this.#focusables.has(focusable2)
464
464
  );
465
- if (!candidates.includes(active)) {
465
+ if (!current.includes(active)) {
466
466
  return;
467
467
  }
468
468
  event.preventDefault();
469
- const activeIndex = candidates.indexOf(active);
469
+ const currentIndex = current.indexOf(active);
470
470
  let newIndex;
471
- let target = candidates;
471
+ let target = current;
472
472
  switch (key) {
473
473
  case "End":
474
474
  newIndex = -1;
@@ -478,48 +478,48 @@ var RovingTabIndex = class _RovingTabIndex {
478
478
  break;
479
479
  case "ArrowLeft":
480
480
  case "ArrowUp": {
481
- const rawIndex = activeIndex - 1;
481
+ const rawIndex = currentIndex - 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 = activeIndex + 1;
488
- newIndex = wrap ? rawIndex % candidates.length : Math.min(rawIndex, candidates.length - 1);
487
+ const rawIndex = currentIndex + 1;
488
+ newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
489
489
  break;
490
490
  }
491
491
  default: {
492
492
  const focusables = new Set(
493
493
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
494
494
  );
495
- target = candidates.filter((focusable2) => focusables.has(focusable2));
496
- const afterIndex = target.findIndex(
497
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
495
+ target = current.filter((focusable2) => focusables.has(focusable2));
496
+ const foundIndex = target.findIndex(
497
+ (focusable2) => current.indexOf(focusable2) > currentIndex
498
498
  );
499
- newIndex = afterIndex >= 0 ? afterIndex : 0;
499
+ newIndex = foundIndex >= 0 ? foundIndex : 0;
500
500
  }
501
501
  }
502
502
  const focusable = target.at(newIndex);
503
503
  focusable && focusElement(focusable);
504
504
  };
505
505
  #update(active) {
506
- const focusables = new Set(this.#getFocusables());
506
+ const current = new Set(this.#getFocusables());
507
507
  for (const focusable of this.#focusables) {
508
- if (!focusables.has(focusable)) {
508
+ if (!current.has(focusable)) {
509
509
  _RovingTabIndex.#initialized.delete(focusable);
510
510
  restoreAttributes([focusable]);
511
511
  this.#focusables.delete(focusable);
512
- for (const [key, focusables2] of this.#focusablesByFirstChar) {
513
- const index = focusables2.indexOf(focusable);
512
+ for (const [key, focusables] of this.#focusablesByFirstChar) {
513
+ const index = focusables.indexOf(focusable);
514
514
  if (index >= 0) {
515
- focusables2.splice(index, 1);
516
- !focusables2.length && this.#focusablesByFirstChar.delete(key);
515
+ focusables.splice(index, 1);
516
+ !focusables.length && this.#focusablesByFirstChar.delete(key);
517
517
  }
518
518
  }
519
519
  }
520
520
  }
521
521
  const { navigationOnly, noStart, typeahead } = this.#settings;
522
- for (const focusable of focusables) {
522
+ for (const focusable of current) {
523
523
  if (this.#focusables.has(focusable)) {
524
524
  continue;
525
525
  }
@@ -548,9 +548,9 @@ var RovingTabIndex = class _RovingTabIndex {
548
548
  });
549
549
  }
550
550
  keys.forEach((key) => {
551
- const focusables2 = this.#focusablesByFirstChar.get(key) ?? [];
552
- focusables2.push(focusable);
553
- this.#focusablesByFirstChar.set(key, focusables2);
551
+ const focusables = this.#focusablesByFirstChar.get(key) ?? [];
552
+ focusables.push(focusable);
553
+ this.#focusablesByFirstChar.set(key, focusables);
554
554
  });
555
555
  }
556
556
  if (!navigationOnly) {
@@ -583,7 +583,7 @@ var RovingTabIndex = class _RovingTabIndex {
583
583
  * Lightweight roving tabindex utility with fully focus management.
584
584
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
585
585
  *
586
- * @version 3.1.14
586
+ * @version 3.1.16
587
587
  * @author Yusuke Kamiyamane
588
588
  * @license MIT
589
589
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -608,7 +608,7 @@ power-focusable/dist/index.js:
608
608
  * High-precision focus management utility with full composed tree support.
609
609
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
610
610
  *
611
- * @version 4.3.18
611
+ * @version 4.3.20
612
612
  * @author Yusuke Kamiyamane
613
613
  * @license MIT
614
614
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -457,16 +457,16 @@ var RovingTabIndex = class _RovingTabIndex {
457
457
  if (!(active instanceof Element)) {
458
458
  return;
459
459
  }
460
- const candidates = this.#getFocusables().filter(
460
+ const current = this.#getFocusables().filter(
461
461
  (focusable2) => this.#focusables.has(focusable2)
462
462
  );
463
- if (!candidates.includes(active)) {
463
+ if (!current.includes(active)) {
464
464
  return;
465
465
  }
466
466
  event.preventDefault();
467
- const activeIndex = candidates.indexOf(active);
467
+ const currentIndex = current.indexOf(active);
468
468
  let newIndex;
469
- let target = candidates;
469
+ let target = current;
470
470
  switch (key) {
471
471
  case "End":
472
472
  newIndex = -1;
@@ -476,48 +476,48 @@ var RovingTabIndex = class _RovingTabIndex {
476
476
  break;
477
477
  case "ArrowLeft":
478
478
  case "ArrowUp": {
479
- const rawIndex = activeIndex - 1;
479
+ const rawIndex = currentIndex - 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 = activeIndex + 1;
486
- newIndex = wrap ? rawIndex % candidates.length : Math.min(rawIndex, candidates.length - 1);
485
+ const rawIndex = currentIndex + 1;
486
+ newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
487
487
  break;
488
488
  }
489
489
  default: {
490
490
  const focusables = new Set(
491
491
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
492
492
  );
493
- target = candidates.filter((focusable2) => focusables.has(focusable2));
494
- const afterIndex = target.findIndex(
495
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
493
+ target = current.filter((focusable2) => focusables.has(focusable2));
494
+ const foundIndex = target.findIndex(
495
+ (focusable2) => current.indexOf(focusable2) > currentIndex
496
496
  );
497
- newIndex = afterIndex >= 0 ? afterIndex : 0;
497
+ newIndex = foundIndex >= 0 ? foundIndex : 0;
498
498
  }
499
499
  }
500
500
  const focusable = target.at(newIndex);
501
501
  focusable && focusElement(focusable);
502
502
  };
503
503
  #update(active) {
504
- const focusables = new Set(this.#getFocusables());
504
+ const current = new Set(this.#getFocusables());
505
505
  for (const focusable of this.#focusables) {
506
- if (!focusables.has(focusable)) {
506
+ if (!current.has(focusable)) {
507
507
  _RovingTabIndex.#initialized.delete(focusable);
508
508
  restoreAttributes([focusable]);
509
509
  this.#focusables.delete(focusable);
510
- for (const [key, focusables2] of this.#focusablesByFirstChar) {
511
- const index = focusables2.indexOf(focusable);
510
+ for (const [key, focusables] of this.#focusablesByFirstChar) {
511
+ const index = focusables.indexOf(focusable);
512
512
  if (index >= 0) {
513
- focusables2.splice(index, 1);
514
- !focusables2.length && this.#focusablesByFirstChar.delete(key);
513
+ focusables.splice(index, 1);
514
+ !focusables.length && this.#focusablesByFirstChar.delete(key);
515
515
  }
516
516
  }
517
517
  }
518
518
  }
519
519
  const { navigationOnly, noStart, typeahead } = this.#settings;
520
- for (const focusable of focusables) {
520
+ for (const focusable of current) {
521
521
  if (this.#focusables.has(focusable)) {
522
522
  continue;
523
523
  }
@@ -546,9 +546,9 @@ var RovingTabIndex = class _RovingTabIndex {
546
546
  });
547
547
  }
548
548
  keys.forEach((key) => {
549
- const focusables2 = this.#focusablesByFirstChar.get(key) ?? [];
550
- focusables2.push(focusable);
551
- this.#focusablesByFirstChar.set(key, focusables2);
549
+ const focusables = this.#focusablesByFirstChar.get(key) ?? [];
550
+ focusables.push(focusable);
551
+ this.#focusablesByFirstChar.set(key, focusables);
552
552
  });
553
553
  }
554
554
  if (!navigationOnly) {
@@ -581,7 +581,7 @@ var RovingTabIndex = class _RovingTabIndex {
581
581
  * Lightweight roving tabindex utility with fully focus management.
582
582
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
583
583
  *
584
- * @version 3.1.14
584
+ * @version 3.1.16
585
585
  * @author Yusuke Kamiyamane
586
586
  * @license MIT
587
587
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -606,7 +606,7 @@ power-focusable/dist/index.js:
606
606
  * High-precision focus management utility with full composed tree support.
607
607
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
608
608
  *
609
- * @version 4.3.18
609
+ * @version 4.3.20
610
610
  * @author Yusuke Kamiyamane
611
611
  * @license MIT
612
612
  * @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 candidates = this.#getFocusables().filter(
148
+ const current = this.#getFocusables().filter(
149
149
  (focusable2) => this.#focusables.has(focusable2)
150
150
  );
151
- if (!candidates.includes(active)) {
151
+ if (!current.includes(active)) {
152
152
  return;
153
153
  }
154
154
  event.preventDefault();
155
- const activeIndex = candidates.indexOf(active);
155
+ const currentIndex = current.indexOf(active);
156
156
  let newIndex;
157
- let target = candidates;
157
+ let target = current;
158
158
  switch (key) {
159
159
  case "End":
160
160
  newIndex = -1;
@@ -164,48 +164,48 @@ var RovingTabIndex = class _RovingTabIndex {
164
164
  break;
165
165
  case "ArrowLeft":
166
166
  case "ArrowUp": {
167
- const rawIndex = activeIndex - 1;
167
+ const rawIndex = currentIndex - 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 = activeIndex + 1;
174
- newIndex = wrap ? rawIndex % candidates.length : Math.min(rawIndex, candidates.length - 1);
173
+ const rawIndex = currentIndex + 1;
174
+ newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
175
175
  break;
176
176
  }
177
177
  default: {
178
178
  const focusables = new Set(
179
179
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
180
180
  );
181
- target = candidates.filter((focusable2) => focusables.has(focusable2));
182
- const afterIndex = target.findIndex(
183
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
181
+ target = current.filter((focusable2) => focusables.has(focusable2));
182
+ const foundIndex = target.findIndex(
183
+ (focusable2) => current.indexOf(focusable2) > currentIndex
184
184
  );
185
- newIndex = afterIndex >= 0 ? afterIndex : 0;
185
+ newIndex = foundIndex >= 0 ? foundIndex : 0;
186
186
  }
187
187
  }
188
188
  const focusable = target.at(newIndex);
189
189
  focusable && powerFocusable.focusElement(focusable);
190
190
  };
191
191
  #update(active) {
192
- const focusables = new Set(this.#getFocusables());
192
+ const current = new Set(this.#getFocusables());
193
193
  for (const focusable of this.#focusables) {
194
- if (!focusables.has(focusable)) {
194
+ if (!current.has(focusable)) {
195
195
  _RovingTabIndex.#initialized.delete(focusable);
196
196
  attributesUtils.restoreAttributes([focusable]);
197
197
  this.#focusables.delete(focusable);
198
- for (const [key, focusables2] of this.#focusablesByFirstChar) {
199
- const index = focusables2.indexOf(focusable);
198
+ for (const [key, focusables] of this.#focusablesByFirstChar) {
199
+ const index = focusables.indexOf(focusable);
200
200
  if (index >= 0) {
201
- focusables2.splice(index, 1);
202
- !focusables2.length && this.#focusablesByFirstChar.delete(key);
201
+ focusables.splice(index, 1);
202
+ !focusables.length && this.#focusablesByFirstChar.delete(key);
203
203
  }
204
204
  }
205
205
  }
206
206
  }
207
207
  const { navigationOnly, noStart, typeahead } = this.#settings;
208
- for (const focusable of focusables) {
208
+ for (const focusable of current) {
209
209
  if (this.#focusables.has(focusable)) {
210
210
  continue;
211
211
  }
@@ -234,9 +234,9 @@ var RovingTabIndex = class _RovingTabIndex {
234
234
  });
235
235
  }
236
236
  keys.forEach((key) => {
237
- const focusables2 = this.#focusablesByFirstChar.get(key) ?? [];
238
- focusables2.push(focusable);
239
- this.#focusablesByFirstChar.set(key, focusables2);
237
+ const focusables = this.#focusablesByFirstChar.get(key) ?? [];
238
+ focusables.push(focusable);
239
+ this.#focusablesByFirstChar.set(key, focusables);
240
240
  });
241
241
  }
242
242
  if (!navigationOnly) {
@@ -269,7 +269,7 @@ var RovingTabIndex = class _RovingTabIndex {
269
269
  * Lightweight roving tabindex utility with fully focus management.
270
270
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
271
271
  *
272
- * @version 3.1.14
272
+ * @version 3.1.16
273
273
  * @author Yusuke Kamiyamane
274
274
  * @license MIT
275
275
  * @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.14
6
+ * @version 3.1.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
  * 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.14
6
+ * @version 3.1.16
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 candidates = this.#getFocusables().filter(
146
+ const current = this.#getFocusables().filter(
147
147
  (focusable2) => this.#focusables.has(focusable2)
148
148
  );
149
- if (!candidates.includes(active)) {
149
+ if (!current.includes(active)) {
150
150
  return;
151
151
  }
152
152
  event.preventDefault();
153
- const activeIndex = candidates.indexOf(active);
153
+ const currentIndex = current.indexOf(active);
154
154
  let newIndex;
155
- let target = candidates;
155
+ let target = current;
156
156
  switch (key) {
157
157
  case "End":
158
158
  newIndex = -1;
@@ -162,48 +162,48 @@ var RovingTabIndex = class _RovingTabIndex {
162
162
  break;
163
163
  case "ArrowLeft":
164
164
  case "ArrowUp": {
165
- const rawIndex = activeIndex - 1;
165
+ const rawIndex = currentIndex - 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 = activeIndex + 1;
172
- newIndex = wrap ? rawIndex % candidates.length : Math.min(rawIndex, candidates.length - 1);
171
+ const rawIndex = currentIndex + 1;
172
+ newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
173
173
  break;
174
174
  }
175
175
  default: {
176
176
  const focusables = new Set(
177
177
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
178
178
  );
179
- target = candidates.filter((focusable2) => focusables.has(focusable2));
180
- const afterIndex = target.findIndex(
181
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
179
+ target = current.filter((focusable2) => focusables.has(focusable2));
180
+ const foundIndex = target.findIndex(
181
+ (focusable2) => current.indexOf(focusable2) > currentIndex
182
182
  );
183
- newIndex = afterIndex >= 0 ? afterIndex : 0;
183
+ newIndex = foundIndex >= 0 ? foundIndex : 0;
184
184
  }
185
185
  }
186
186
  const focusable = target.at(newIndex);
187
187
  focusable && focusElement(focusable);
188
188
  };
189
189
  #update(active) {
190
- const focusables = new Set(this.#getFocusables());
190
+ const current = new Set(this.#getFocusables());
191
191
  for (const focusable of this.#focusables) {
192
- if (!focusables.has(focusable)) {
192
+ if (!current.has(focusable)) {
193
193
  _RovingTabIndex.#initialized.delete(focusable);
194
194
  restoreAttributes([focusable]);
195
195
  this.#focusables.delete(focusable);
196
- for (const [key, focusables2] of this.#focusablesByFirstChar) {
197
- const index = focusables2.indexOf(focusable);
196
+ for (const [key, focusables] of this.#focusablesByFirstChar) {
197
+ const index = focusables.indexOf(focusable);
198
198
  if (index >= 0) {
199
- focusables2.splice(index, 1);
200
- !focusables2.length && this.#focusablesByFirstChar.delete(key);
199
+ focusables.splice(index, 1);
200
+ !focusables.length && this.#focusablesByFirstChar.delete(key);
201
201
  }
202
202
  }
203
203
  }
204
204
  }
205
205
  const { navigationOnly, noStart, typeahead } = this.#settings;
206
- for (const focusable of focusables) {
206
+ for (const focusable of current) {
207
207
  if (this.#focusables.has(focusable)) {
208
208
  continue;
209
209
  }
@@ -232,9 +232,9 @@ var RovingTabIndex = class _RovingTabIndex {
232
232
  });
233
233
  }
234
234
  keys.forEach((key) => {
235
- const focusables2 = this.#focusablesByFirstChar.get(key) ?? [];
236
- focusables2.push(focusable);
237
- this.#focusablesByFirstChar.set(key, focusables2);
235
+ const focusables = this.#focusablesByFirstChar.get(key) ?? [];
236
+ focusables.push(focusable);
237
+ this.#focusablesByFirstChar.set(key, focusables);
238
238
  });
239
239
  }
240
240
  if (!navigationOnly) {
@@ -267,7 +267,7 @@ var RovingTabIndex = class _RovingTabIndex {
267
267
  * Lightweight roving tabindex utility with fully focus management.
268
268
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
269
269
  *
270
- * @version 3.1.14
270
+ * @version 3.1.16
271
271
  * @author Yusuke Kamiyamane
272
272
  * @license MIT
273
273
  * @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.14",
3
+ "version": "3.1.16",
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.18"
60
+ "power-focusable": "^4.3.20"
61
61
  }
62
62
  }