@y14e/roving-tabindex 3.0.8 → 3.0.10
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 +4 -4
- package/dist/index.cjs +12 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -9
- package/package.json +1 -1
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
|
+
import { createRovingTabIndex } from '@y14e/roving-tabindex@3.0.10';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.0.
|
|
16
|
+
import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.0.10';
|
|
17
17
|
// or
|
|
18
|
-
import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.0.
|
|
18
|
+
import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.0.10/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.0.
|
|
20
|
+
import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.0.10';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.cjs
CHANGED
|
@@ -297,7 +297,8 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
297
297
|
const roving = new RovingTabIndex(container, options);
|
|
298
298
|
return () => roving.destroy();
|
|
299
299
|
}
|
|
300
|
-
var RovingTabIndex = class {
|
|
300
|
+
var RovingTabIndex = class _RovingTabIndex {
|
|
301
|
+
static #initialized = /* @__PURE__ */ new Set();
|
|
301
302
|
#container;
|
|
302
303
|
#settings;
|
|
303
304
|
#focusables = /* @__PURE__ */ new Set();
|
|
@@ -368,21 +369,22 @@ var RovingTabIndex = class {
|
|
|
368
369
|
restoreAttributes([...this.#focusables]);
|
|
369
370
|
this.#focusables.clear();
|
|
370
371
|
this.#focusablesByFirstChar.clear();
|
|
371
|
-
this.#container.removeAttribute("data-roving-tabindex-initialized");
|
|
372
372
|
}
|
|
373
373
|
#initialize() {
|
|
374
374
|
this.#update(document.activeElement);
|
|
375
|
+
if (!(this.#container instanceof HTMLElement)) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
375
378
|
this.#controller = new AbortController();
|
|
376
379
|
const { signal } = this.#controller;
|
|
377
|
-
|
|
380
|
+
this.#container.addEventListener("focusin", this.#onFocusIn, {
|
|
378
381
|
capture: true,
|
|
379
382
|
signal
|
|
380
383
|
});
|
|
381
|
-
|
|
384
|
+
this.#container.addEventListener("keydown", this.#onKeyDown, {
|
|
382
385
|
capture: true,
|
|
383
386
|
signal
|
|
384
387
|
});
|
|
385
|
-
this.#container.setAttribute("data-roving-tabindex-initialized", "");
|
|
386
388
|
}
|
|
387
389
|
#onFocusIn = (event) => {
|
|
388
390
|
const { target } = event;
|
|
@@ -393,9 +395,6 @@ var RovingTabIndex = class {
|
|
|
393
395
|
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
394
396
|
};
|
|
395
397
|
#onKeyDown = (event) => {
|
|
396
|
-
if (!event.composedPath().includes(this.#container)) {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
398
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
400
399
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
401
400
|
return;
|
|
@@ -472,7 +471,11 @@ var RovingTabIndex = class {
|
|
|
472
471
|
if (this.#focusables.has(focusable)) {
|
|
473
472
|
continue;
|
|
474
473
|
}
|
|
474
|
+
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
475
|
+
throw new TypeError("Already initialized");
|
|
476
|
+
}
|
|
475
477
|
this.#focusables.add(focusable);
|
|
478
|
+
_RovingTabIndex.#initialized.add(focusable);
|
|
476
479
|
if (!navigationOnly) {
|
|
477
480
|
saveAttributes([focusable], ["tabindex"]);
|
|
478
481
|
focusable.setAttribute("tabindex", "-1");
|
|
@@ -528,7 +531,7 @@ var RovingTabIndex = class {
|
|
|
528
531
|
* Lightweight roving tabindex utility with fully focus management.
|
|
529
532
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
530
533
|
*
|
|
531
|
-
* @version 3.0.
|
|
534
|
+
* @version 3.0.10
|
|
532
535
|
* @author Yusuke Kamiyamane
|
|
533
536
|
* @license MIT
|
|
534
537
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ export { focusElement, getActiveElement, getFocusables } from 'power-focusable';
|
|
|
6
6
|
* Lightweight roving tabindex utility with fully focus management.
|
|
7
7
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
8
8
|
*
|
|
9
|
-
* @version 3.0.
|
|
9
|
+
* @version 3.0.10
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { focusElement, getActiveElement, getFocusables } from 'power-focusable';
|
|
|
6
6
|
* Lightweight roving tabindex utility with fully focus management.
|
|
7
7
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
8
8
|
*
|
|
9
|
-
* @version 3.0.
|
|
9
|
+
* @version 3.0.10
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -295,7 +295,8 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
295
295
|
const roving = new RovingTabIndex(container, options);
|
|
296
296
|
return () => roving.destroy();
|
|
297
297
|
}
|
|
298
|
-
var RovingTabIndex = class {
|
|
298
|
+
var RovingTabIndex = class _RovingTabIndex {
|
|
299
|
+
static #initialized = /* @__PURE__ */ new Set();
|
|
299
300
|
#container;
|
|
300
301
|
#settings;
|
|
301
302
|
#focusables = /* @__PURE__ */ new Set();
|
|
@@ -366,21 +367,22 @@ var RovingTabIndex = class {
|
|
|
366
367
|
restoreAttributes([...this.#focusables]);
|
|
367
368
|
this.#focusables.clear();
|
|
368
369
|
this.#focusablesByFirstChar.clear();
|
|
369
|
-
this.#container.removeAttribute("data-roving-tabindex-initialized");
|
|
370
370
|
}
|
|
371
371
|
#initialize() {
|
|
372
372
|
this.#update(document.activeElement);
|
|
373
|
+
if (!(this.#container instanceof HTMLElement)) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
373
376
|
this.#controller = new AbortController();
|
|
374
377
|
const { signal } = this.#controller;
|
|
375
|
-
|
|
378
|
+
this.#container.addEventListener("focusin", this.#onFocusIn, {
|
|
376
379
|
capture: true,
|
|
377
380
|
signal
|
|
378
381
|
});
|
|
379
|
-
|
|
382
|
+
this.#container.addEventListener("keydown", this.#onKeyDown, {
|
|
380
383
|
capture: true,
|
|
381
384
|
signal
|
|
382
385
|
});
|
|
383
|
-
this.#container.setAttribute("data-roving-tabindex-initialized", "");
|
|
384
386
|
}
|
|
385
387
|
#onFocusIn = (event) => {
|
|
386
388
|
const { target } = event;
|
|
@@ -391,9 +393,6 @@ var RovingTabIndex = class {
|
|
|
391
393
|
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
392
394
|
};
|
|
393
395
|
#onKeyDown = (event) => {
|
|
394
|
-
if (!event.composedPath().includes(this.#container)) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
396
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
398
397
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
399
398
|
return;
|
|
@@ -470,7 +469,11 @@ var RovingTabIndex = class {
|
|
|
470
469
|
if (this.#focusables.has(focusable)) {
|
|
471
470
|
continue;
|
|
472
471
|
}
|
|
472
|
+
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
473
|
+
throw new TypeError("Already initialized");
|
|
474
|
+
}
|
|
473
475
|
this.#focusables.add(focusable);
|
|
476
|
+
_RovingTabIndex.#initialized.add(focusable);
|
|
474
477
|
if (!navigationOnly) {
|
|
475
478
|
saveAttributes([focusable], ["tabindex"]);
|
|
476
479
|
focusable.setAttribute("tabindex", "-1");
|
|
@@ -526,7 +529,7 @@ var RovingTabIndex = class {
|
|
|
526
529
|
* Lightweight roving tabindex utility with fully focus management.
|
|
527
530
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
528
531
|
*
|
|
529
|
-
* @version 3.0.
|
|
532
|
+
* @version 3.0.10
|
|
530
533
|
* @author Yusuke Kamiyamane
|
|
531
534
|
* @license MIT
|
|
532
535
|
* @copyright Copyright (c) Yusuke Kamiyamane
|