@y14e/roving-tabindex 3.0.13 → 3.0.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 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.0.13';
13
+ import { createRovingTabIndex } from '@y14e/roving-tabindex@3.0.15';
14
14
 
15
15
  // CDNs
16
- import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.0.13';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.0.15';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.0.13/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.0.15/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.0.13';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.0.15';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -383,7 +383,11 @@ var RovingTabIndex = class _RovingTabIndex {
383
383
  }
384
384
  this.#controller = new AbortController();
385
385
  const { signal } = this.#controller;
386
- this.#container.addEventListener("focusin", this.#onFocusIn, {
386
+ document.addEventListener("focusin", this.#onFocusIn, {
387
+ capture: true,
388
+ signal
389
+ });
390
+ document.addEventListener("focusout", this.#onFocusOut, {
387
391
  capture: true,
388
392
  signal
389
393
  });
@@ -400,6 +404,11 @@ var RovingTabIndex = class _RovingTabIndex {
400
404
  const isFocusable2 = this.#focusables.has(target);
401
405
  this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
402
406
  };
407
+ #onFocusOut = (event) => {
408
+ if (!event.relatedTarget) {
409
+ this.#update(null);
410
+ }
411
+ };
403
412
  #onKeyDown = (event) => {
404
413
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
405
414
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -537,7 +546,7 @@ var RovingTabIndex = class _RovingTabIndex {
537
546
  * Lightweight roving tabindex utility with fully focus management.
538
547
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
539
548
  *
540
- * @version 3.0.13
549
+ * @version 3.0.15
541
550
  * @author Yusuke Kamiyamane
542
551
  * @license MIT
543
552
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -381,7 +381,11 @@ var RovingTabIndex = class _RovingTabIndex {
381
381
  }
382
382
  this.#controller = new AbortController();
383
383
  const { signal } = this.#controller;
384
- this.#container.addEventListener("focusin", this.#onFocusIn, {
384
+ document.addEventListener("focusin", this.#onFocusIn, {
385
+ capture: true,
386
+ signal
387
+ });
388
+ document.addEventListener("focusout", this.#onFocusOut, {
385
389
  capture: true,
386
390
  signal
387
391
  });
@@ -398,6 +402,11 @@ var RovingTabIndex = class _RovingTabIndex {
398
402
  const isFocusable2 = this.#focusables.has(target);
399
403
  this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
400
404
  };
405
+ #onFocusOut = (event) => {
406
+ if (!event.relatedTarget) {
407
+ this.#update(null);
408
+ }
409
+ };
401
410
  #onKeyDown = (event) => {
402
411
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
403
412
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -535,7 +544,7 @@ var RovingTabIndex = class _RovingTabIndex {
535
544
  * Lightweight roving tabindex utility with fully focus management.
536
545
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
537
546
  *
538
- * @version 3.0.13
547
+ * @version 3.0.15
539
548
  * @author Yusuke Kamiyamane
540
549
  * @license MIT
541
550
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -99,7 +99,11 @@ var RovingTabIndex = class _RovingTabIndex {
99
99
  }
100
100
  this.#controller = new AbortController();
101
101
  const { signal } = this.#controller;
102
- this.#container.addEventListener("focusin", this.#onFocusIn, {
102
+ document.addEventListener("focusin", this.#onFocusIn, {
103
+ capture: true,
104
+ signal
105
+ });
106
+ document.addEventListener("focusout", this.#onFocusOut, {
103
107
  capture: true,
104
108
  signal
105
109
  });
@@ -116,6 +120,11 @@ var RovingTabIndex = class _RovingTabIndex {
116
120
  const isFocusable = this.#focusables.has(target);
117
121
  this.#settings.noMemory && !isFocusable ? this.#update(null) : isFocusable && this.#update(target);
118
122
  };
123
+ #onFocusOut = (event) => {
124
+ if (!event.relatedTarget) {
125
+ this.#update(null);
126
+ }
127
+ };
119
128
  #onKeyDown = (event) => {
120
129
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
121
130
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -253,7 +262,7 @@ var RovingTabIndex = class _RovingTabIndex {
253
262
  * Lightweight roving tabindex utility with fully focus management.
254
263
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
255
264
  *
256
- * @version 3.0.13
265
+ * @version 3.0.15
257
266
  * @author Yusuke Kamiyamane
258
267
  * @license MIT
259
268
  * @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.0.13
6
+ * @version 3.0.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.0.13
6
+ * @version 3.0.15
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -97,7 +97,11 @@ var RovingTabIndex = class _RovingTabIndex {
97
97
  }
98
98
  this.#controller = new AbortController();
99
99
  const { signal } = this.#controller;
100
- this.#container.addEventListener("focusin", this.#onFocusIn, {
100
+ document.addEventListener("focusin", this.#onFocusIn, {
101
+ capture: true,
102
+ signal
103
+ });
104
+ document.addEventListener("focusout", this.#onFocusOut, {
101
105
  capture: true,
102
106
  signal
103
107
  });
@@ -114,6 +118,11 @@ var RovingTabIndex = class _RovingTabIndex {
114
118
  const isFocusable = this.#focusables.has(target);
115
119
  this.#settings.noMemory && !isFocusable ? this.#update(null) : isFocusable && this.#update(target);
116
120
  };
121
+ #onFocusOut = (event) => {
122
+ if (!event.relatedTarget) {
123
+ this.#update(null);
124
+ }
125
+ };
117
126
  #onKeyDown = (event) => {
118
127
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
119
128
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -251,7 +260,7 @@ var RovingTabIndex = class _RovingTabIndex {
251
260
  * Lightweight roving tabindex utility with fully focus management.
252
261
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
253
262
  *
254
- * @version 3.0.13
263
+ * @version 3.0.15
255
264
  * @author Yusuke Kamiyamane
256
265
  * @license MIT
257
266
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",