@y14e/roving-tabindex 3.1.2 → 3.1.4

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
@@ -10,14 +10,14 @@ npm i @y14e/roving-tabindex
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import { createRovingTabIndex } from '@y14e/roving-tabindex@3.1.2';
13
+ import { createRovingTabIndex } from '@y14e/roving-tabindex';
14
14
 
15
15
  // CDNs
16
- import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.2';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.4';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.2/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.4/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.2';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.4';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -353,13 +353,7 @@ var RovingTabIndex = class _RovingTabIndex {
353
353
  console.warn("Invalid wrap option. Fallback: false.");
354
354
  wrap = false;
355
355
  }
356
- this.#settings = {
357
- navigationOnly,
358
- noMemory,
359
- noStart,
360
- typeahead,
361
- wrap
362
- };
356
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
363
357
  direction && Object.assign(this.#settings, { direction });
364
358
  selector && Object.assign(this.#settings, { selector });
365
359
  this.#selectorFilter = this.#createSelectorFilter();
@@ -383,22 +377,17 @@ var RovingTabIndex = class _RovingTabIndex {
383
377
  }
384
378
  this.#controller = new AbortController();
385
379
  const { signal } = this.#controller;
386
- document.addEventListener("focusin", this.#onFocusIn, { signal });
387
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
380
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
381
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
388
382
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
389
383
  }
390
384
  #onFocusIn = (event) => {
391
385
  const { target } = event;
392
- if (!(target instanceof Element)) {
393
- return;
394
- }
395
- const isFocusable2 = this.#focusables.has(target);
396
- this.#settings.noMemory && !isFocusable2 ? this.#update() : isFocusable2 && this.#update(target);
386
+ target instanceof Element && this.#update(target);
397
387
  };
398
388
  #onFocusOut = (event) => {
399
- if (!event.relatedTarget) {
400
- this.#update();
401
- }
389
+ const target = event.relatedTarget;
390
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
402
391
  };
403
392
  #onKeyDown = (event) => {
404
393
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -537,7 +526,7 @@ var RovingTabIndex = class _RovingTabIndex {
537
526
  * Lightweight roving tabindex utility with fully focus management.
538
527
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
539
528
  *
540
- * @version 3.1.2
529
+ * @version 3.1.4
541
530
  * @author Yusuke Kamiyamane
542
531
  * @license MIT
543
532
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -562,7 +551,7 @@ power-focusable/dist/index.js:
562
551
  * High-precision focus management utility with full composed tree support.
563
552
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
564
553
  *
565
- * @version 4.3.3
554
+ * @version 4.3.6
566
555
  * @author Yusuke Kamiyamane
567
556
  * @license MIT
568
557
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -351,13 +351,7 @@ var RovingTabIndex = class _RovingTabIndex {
351
351
  console.warn("Invalid wrap option. Fallback: false.");
352
352
  wrap = false;
353
353
  }
354
- this.#settings = {
355
- navigationOnly,
356
- noMemory,
357
- noStart,
358
- typeahead,
359
- wrap
360
- };
354
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
361
355
  direction && Object.assign(this.#settings, { direction });
362
356
  selector && Object.assign(this.#settings, { selector });
363
357
  this.#selectorFilter = this.#createSelectorFilter();
@@ -381,22 +375,17 @@ var RovingTabIndex = class _RovingTabIndex {
381
375
  }
382
376
  this.#controller = new AbortController();
383
377
  const { signal } = this.#controller;
384
- document.addEventListener("focusin", this.#onFocusIn, { signal });
385
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
378
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
379
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
386
380
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
387
381
  }
388
382
  #onFocusIn = (event) => {
389
383
  const { target } = event;
390
- if (!(target instanceof Element)) {
391
- return;
392
- }
393
- const isFocusable2 = this.#focusables.has(target);
394
- this.#settings.noMemory && !isFocusable2 ? this.#update() : isFocusable2 && this.#update(target);
384
+ target instanceof Element && this.#update(target);
395
385
  };
396
386
  #onFocusOut = (event) => {
397
- if (!event.relatedTarget) {
398
- this.#update();
399
- }
387
+ const target = event.relatedTarget;
388
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
400
389
  };
401
390
  #onKeyDown = (event) => {
402
391
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -535,7 +524,7 @@ var RovingTabIndex = class _RovingTabIndex {
535
524
  * Lightweight roving tabindex utility with fully focus management.
536
525
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
537
526
  *
538
- * @version 3.1.2
527
+ * @version 3.1.4
539
528
  * @author Yusuke Kamiyamane
540
529
  * @license MIT
541
530
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -560,7 +549,7 @@ power-focusable/dist/index.js:
560
549
  * High-precision focus management utility with full composed tree support.
561
550
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
562
551
  *
563
- * @version 4.3.3
552
+ * @version 4.3.6
564
553
  * @author Yusuke Kamiyamane
565
554
  * @license MIT
566
555
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -69,13 +69,7 @@ var RovingTabIndex = class _RovingTabIndex {
69
69
  console.warn("Invalid wrap option. Fallback: false.");
70
70
  wrap = false;
71
71
  }
72
- this.#settings = {
73
- navigationOnly,
74
- noMemory,
75
- noStart,
76
- typeahead,
77
- wrap
78
- };
72
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
79
73
  direction && Object.assign(this.#settings, { direction });
80
74
  selector && Object.assign(this.#settings, { selector });
81
75
  this.#selectorFilter = this.#createSelectorFilter();
@@ -99,22 +93,17 @@ var RovingTabIndex = class _RovingTabIndex {
99
93
  }
100
94
  this.#controller = new AbortController();
101
95
  const { signal } = this.#controller;
102
- document.addEventListener("focusin", this.#onFocusIn, { signal });
103
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
96
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
97
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
104
98
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
105
99
  }
106
100
  #onFocusIn = (event) => {
107
101
  const { target } = event;
108
- if (!(target instanceof Element)) {
109
- return;
110
- }
111
- const isFocusable = this.#focusables.has(target);
112
- this.#settings.noMemory && !isFocusable ? this.#update() : isFocusable && this.#update(target);
102
+ target instanceof Element && this.#update(target);
113
103
  };
114
104
  #onFocusOut = (event) => {
115
- if (!event.relatedTarget) {
116
- this.#update();
117
- }
105
+ const target = event.relatedTarget;
106
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
118
107
  };
119
108
  #onKeyDown = (event) => {
120
109
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -253,7 +242,7 @@ var RovingTabIndex = class _RovingTabIndex {
253
242
  * Lightweight roving tabindex utility with fully focus management.
254
243
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
255
244
  *
256
- * @version 3.1.2
245
+ * @version 3.1.4
257
246
  * @author Yusuke Kamiyamane
258
247
  * @license MIT
259
248
  * @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.2
6
+ * @version 3.1.4
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.2
6
+ * @version 3.1.4
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -67,13 +67,7 @@ var RovingTabIndex = class _RovingTabIndex {
67
67
  console.warn("Invalid wrap option. Fallback: false.");
68
68
  wrap = false;
69
69
  }
70
- this.#settings = {
71
- navigationOnly,
72
- noMemory,
73
- noStart,
74
- typeahead,
75
- wrap
76
- };
70
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
77
71
  direction && Object.assign(this.#settings, { direction });
78
72
  selector && Object.assign(this.#settings, { selector });
79
73
  this.#selectorFilter = this.#createSelectorFilter();
@@ -97,22 +91,17 @@ var RovingTabIndex = class _RovingTabIndex {
97
91
  }
98
92
  this.#controller = new AbortController();
99
93
  const { signal } = this.#controller;
100
- document.addEventListener("focusin", this.#onFocusIn, { signal });
101
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
94
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
95
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
102
96
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
103
97
  }
104
98
  #onFocusIn = (event) => {
105
99
  const { target } = event;
106
- if (!(target instanceof Element)) {
107
- return;
108
- }
109
- const isFocusable = this.#focusables.has(target);
110
- this.#settings.noMemory && !isFocusable ? this.#update() : isFocusable && this.#update(target);
100
+ target instanceof Element && this.#update(target);
111
101
  };
112
102
  #onFocusOut = (event) => {
113
- if (!event.relatedTarget) {
114
- this.#update();
115
- }
103
+ const target = event.relatedTarget;
104
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
116
105
  };
117
106
  #onKeyDown = (event) => {
118
107
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -251,7 +240,7 @@ var RovingTabIndex = class _RovingTabIndex {
251
240
  * Lightweight roving tabindex utility with fully focus management.
252
241
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
253
242
  *
254
- * @version 3.1.2
243
+ * @version 3.1.4
255
244
  * @author Yusuke Kamiyamane
256
245
  * @license MIT
257
246
  * @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.2",
3
+ "version": "3.1.4",
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.2",
60
- "power-focusable": "^4.3.4"
60
+ "power-focusable": "^4.3.6"
61
61
  }
62
62
  }