@y14e/roving-tabindex 3.0.4 → 3.0.6
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 +59 -59
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +59 -59
- 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.6';
|
|
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.6';
|
|
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.6/+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.6';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.cjs
CHANGED
|
@@ -284,60 +284,12 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
284
284
|
return () => {
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
|
|
288
|
-
direction,
|
|
289
|
-
navigationOnly = false,
|
|
290
|
-
noMemory = false,
|
|
291
|
-
noStart = false,
|
|
292
|
-
selector,
|
|
293
|
-
typeahead = false,
|
|
294
|
-
wrap = false
|
|
295
|
-
} = options;
|
|
296
|
-
if (typeof direction !== "undefined" && !["horizontal", "vertical"].includes(direction)) {
|
|
297
|
-
console.warn("Invalid direction option. Fallback: both (undefined).");
|
|
298
|
-
direction = void 0;
|
|
299
|
-
}
|
|
300
|
-
if (typeof navigationOnly !== "boolean") {
|
|
301
|
-
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
302
|
-
navigationOnly = false;
|
|
303
|
-
}
|
|
304
|
-
if (typeof noMemory !== "boolean") {
|
|
305
|
-
console.warn("Invalid noMemory option. Fallback: false.");
|
|
306
|
-
noMemory = false;
|
|
307
|
-
}
|
|
308
|
-
if (typeof noStart !== "boolean") {
|
|
309
|
-
console.warn("Invalid noStart option. Fallback: false.");
|
|
310
|
-
noStart = false;
|
|
311
|
-
}
|
|
312
|
-
if (typeof selector !== "undefined" && (typeof selector !== "string" || !selector.trim())) {
|
|
313
|
-
console.warn(
|
|
314
|
-
"Invalid selector. Fallback: all focusable elements (undefined)."
|
|
315
|
-
);
|
|
316
|
-
selector = void 0;
|
|
317
|
-
}
|
|
318
|
-
if (typeof typeahead !== "boolean") {
|
|
319
|
-
console.warn("Invalid typeahead option. Fallback: false.");
|
|
320
|
-
typeahead = false;
|
|
321
|
-
}
|
|
322
|
-
if (typeof wrap !== "boolean") {
|
|
323
|
-
console.warn("Invalid wrap option. Fallback: false.");
|
|
324
|
-
wrap = false;
|
|
325
|
-
}
|
|
326
|
-
const settings = {
|
|
327
|
-
navigationOnly,
|
|
328
|
-
noMemory,
|
|
329
|
-
noStart,
|
|
330
|
-
typeahead,
|
|
331
|
-
wrap
|
|
332
|
-
};
|
|
333
|
-
direction && Object.assign(settings, { direction });
|
|
334
|
-
selector && Object.assign(settings, { selector });
|
|
335
|
-
const roving = new RovingTabIndex(container, settings);
|
|
287
|
+
const roving = new RovingTabIndex(container, options);
|
|
336
288
|
return () => roving.destroy();
|
|
337
289
|
}
|
|
338
290
|
var RovingTabIndex = class {
|
|
339
291
|
#container;
|
|
340
|
-
#
|
|
292
|
+
#settings;
|
|
341
293
|
#focusables = /* @__PURE__ */ new Set();
|
|
342
294
|
#focusablesByFirstChar = /* @__PURE__ */ new Map();
|
|
343
295
|
#selectorFilter;
|
|
@@ -345,7 +297,54 @@ var RovingTabIndex = class {
|
|
|
345
297
|
#isDestroyed = false;
|
|
346
298
|
constructor(container, options = {}) {
|
|
347
299
|
this.#container = container;
|
|
348
|
-
|
|
300
|
+
let {
|
|
301
|
+
direction,
|
|
302
|
+
navigationOnly = false,
|
|
303
|
+
noMemory = false,
|
|
304
|
+
noStart = false,
|
|
305
|
+
selector,
|
|
306
|
+
typeahead = false,
|
|
307
|
+
wrap = false
|
|
308
|
+
} = options;
|
|
309
|
+
if (typeof direction !== "undefined" && !["horizontal", "vertical"].includes(direction)) {
|
|
310
|
+
console.warn("Invalid direction option. Fallback: both (undefined).");
|
|
311
|
+
direction = void 0;
|
|
312
|
+
}
|
|
313
|
+
if (typeof navigationOnly !== "boolean") {
|
|
314
|
+
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
315
|
+
navigationOnly = false;
|
|
316
|
+
}
|
|
317
|
+
if (typeof noMemory !== "boolean") {
|
|
318
|
+
console.warn("Invalid noMemory option. Fallback: false.");
|
|
319
|
+
noMemory = false;
|
|
320
|
+
}
|
|
321
|
+
if (typeof noStart !== "boolean") {
|
|
322
|
+
console.warn("Invalid noStart option. Fallback: false.");
|
|
323
|
+
noStart = false;
|
|
324
|
+
}
|
|
325
|
+
if (typeof selector !== "undefined" && (typeof selector !== "string" || !selector.trim())) {
|
|
326
|
+
console.warn(
|
|
327
|
+
"Invalid selector. Fallback: all focusable elements (undefined)."
|
|
328
|
+
);
|
|
329
|
+
selector = void 0;
|
|
330
|
+
}
|
|
331
|
+
if (typeof typeahead !== "boolean") {
|
|
332
|
+
console.warn("Invalid typeahead option. Fallback: false.");
|
|
333
|
+
typeahead = false;
|
|
334
|
+
}
|
|
335
|
+
if (typeof wrap !== "boolean") {
|
|
336
|
+
console.warn("Invalid wrap option. Fallback: false.");
|
|
337
|
+
wrap = false;
|
|
338
|
+
}
|
|
339
|
+
this.#settings = {
|
|
340
|
+
navigationOnly,
|
|
341
|
+
noMemory,
|
|
342
|
+
noStart,
|
|
343
|
+
typeahead,
|
|
344
|
+
wrap
|
|
345
|
+
};
|
|
346
|
+
direction && Object.assign(this.#settings, { direction });
|
|
347
|
+
selector && Object.assign(this.#settings, { selector });
|
|
349
348
|
this.#selectorFilter = this.#createSelectorFilter();
|
|
350
349
|
this.#initialize();
|
|
351
350
|
}
|
|
@@ -377,10 +376,11 @@ var RovingTabIndex = class {
|
|
|
377
376
|
}
|
|
378
377
|
#onFocusIn = (event) => {
|
|
379
378
|
const { target } = event;
|
|
380
|
-
if (target instanceof Element) {
|
|
381
|
-
|
|
382
|
-
this.#options.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
379
|
+
if (!(target instanceof Element)) {
|
|
380
|
+
return;
|
|
383
381
|
}
|
|
382
|
+
const isFocusable2 = this.#focusables.has(target);
|
|
383
|
+
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
384
384
|
};
|
|
385
385
|
#onKeyDown = (event) => {
|
|
386
386
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -390,7 +390,7 @@ var RovingTabIndex = class {
|
|
|
390
390
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
391
391
|
return;
|
|
392
392
|
}
|
|
393
|
-
const { direction, typeahead, wrap } = this.#
|
|
393
|
+
const { direction, typeahead, wrap } = this.#settings;
|
|
394
394
|
const isBoth = !direction;
|
|
395
395
|
const isHorizontal = direction === "horizontal";
|
|
396
396
|
if (![
|
|
@@ -457,7 +457,7 @@ var RovingTabIndex = class {
|
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
const { navigationOnly, noStart, typeahead } = this.#
|
|
460
|
+
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
461
461
|
for (const focusable of current) {
|
|
462
462
|
if (this.#focusables.has(focusable)) {
|
|
463
463
|
continue;
|
|
@@ -501,14 +501,14 @@ var RovingTabIndex = class {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
#createSelectorFilter() {
|
|
504
|
-
const { selector } = this.#
|
|
504
|
+
const { selector } = this.#settings;
|
|
505
505
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
506
506
|
}
|
|
507
507
|
#getFocusables() {
|
|
508
508
|
return getFocusables(this.#container, {
|
|
509
509
|
composed: true,
|
|
510
510
|
filter: this.#selectorFilter,
|
|
511
|
-
skipNegativeTabIndexCheck: !this.#
|
|
511
|
+
skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
|
|
512
512
|
skipVisibilityCheck: true
|
|
513
513
|
});
|
|
514
514
|
}
|
|
@@ -528,7 +528,7 @@ function getActiveElement() {
|
|
|
528
528
|
* Lightweight roving tabindex utility with fully focus management.
|
|
529
529
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
530
530
|
*
|
|
531
|
-
* @version 3.0.
|
|
531
|
+
* @version 3.0.6
|
|
532
532
|
* @author Yusuke Kamiyamane
|
|
533
533
|
* @license MIT
|
|
534
534
|
* @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.
|
|
6
|
+
* @version 3.0.6
|
|
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.
|
|
6
|
+
* @version 3.0.6
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -282,60 +282,12 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
282
282
|
return () => {
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
-
|
|
286
|
-
direction,
|
|
287
|
-
navigationOnly = false,
|
|
288
|
-
noMemory = false,
|
|
289
|
-
noStart = false,
|
|
290
|
-
selector,
|
|
291
|
-
typeahead = false,
|
|
292
|
-
wrap = false
|
|
293
|
-
} = options;
|
|
294
|
-
if (typeof direction !== "undefined" && !["horizontal", "vertical"].includes(direction)) {
|
|
295
|
-
console.warn("Invalid direction option. Fallback: both (undefined).");
|
|
296
|
-
direction = void 0;
|
|
297
|
-
}
|
|
298
|
-
if (typeof navigationOnly !== "boolean") {
|
|
299
|
-
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
300
|
-
navigationOnly = false;
|
|
301
|
-
}
|
|
302
|
-
if (typeof noMemory !== "boolean") {
|
|
303
|
-
console.warn("Invalid noMemory option. Fallback: false.");
|
|
304
|
-
noMemory = false;
|
|
305
|
-
}
|
|
306
|
-
if (typeof noStart !== "boolean") {
|
|
307
|
-
console.warn("Invalid noStart option. Fallback: false.");
|
|
308
|
-
noStart = false;
|
|
309
|
-
}
|
|
310
|
-
if (typeof selector !== "undefined" && (typeof selector !== "string" || !selector.trim())) {
|
|
311
|
-
console.warn(
|
|
312
|
-
"Invalid selector. Fallback: all focusable elements (undefined)."
|
|
313
|
-
);
|
|
314
|
-
selector = void 0;
|
|
315
|
-
}
|
|
316
|
-
if (typeof typeahead !== "boolean") {
|
|
317
|
-
console.warn("Invalid typeahead option. Fallback: false.");
|
|
318
|
-
typeahead = false;
|
|
319
|
-
}
|
|
320
|
-
if (typeof wrap !== "boolean") {
|
|
321
|
-
console.warn("Invalid wrap option. Fallback: false.");
|
|
322
|
-
wrap = false;
|
|
323
|
-
}
|
|
324
|
-
const settings = {
|
|
325
|
-
navigationOnly,
|
|
326
|
-
noMemory,
|
|
327
|
-
noStart,
|
|
328
|
-
typeahead,
|
|
329
|
-
wrap
|
|
330
|
-
};
|
|
331
|
-
direction && Object.assign(settings, { direction });
|
|
332
|
-
selector && Object.assign(settings, { selector });
|
|
333
|
-
const roving = new RovingTabIndex(container, settings);
|
|
285
|
+
const roving = new RovingTabIndex(container, options);
|
|
334
286
|
return () => roving.destroy();
|
|
335
287
|
}
|
|
336
288
|
var RovingTabIndex = class {
|
|
337
289
|
#container;
|
|
338
|
-
#
|
|
290
|
+
#settings;
|
|
339
291
|
#focusables = /* @__PURE__ */ new Set();
|
|
340
292
|
#focusablesByFirstChar = /* @__PURE__ */ new Map();
|
|
341
293
|
#selectorFilter;
|
|
@@ -343,7 +295,54 @@ var RovingTabIndex = class {
|
|
|
343
295
|
#isDestroyed = false;
|
|
344
296
|
constructor(container, options = {}) {
|
|
345
297
|
this.#container = container;
|
|
346
|
-
|
|
298
|
+
let {
|
|
299
|
+
direction,
|
|
300
|
+
navigationOnly = false,
|
|
301
|
+
noMemory = false,
|
|
302
|
+
noStart = false,
|
|
303
|
+
selector,
|
|
304
|
+
typeahead = false,
|
|
305
|
+
wrap = false
|
|
306
|
+
} = options;
|
|
307
|
+
if (typeof direction !== "undefined" && !["horizontal", "vertical"].includes(direction)) {
|
|
308
|
+
console.warn("Invalid direction option. Fallback: both (undefined).");
|
|
309
|
+
direction = void 0;
|
|
310
|
+
}
|
|
311
|
+
if (typeof navigationOnly !== "boolean") {
|
|
312
|
+
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
313
|
+
navigationOnly = false;
|
|
314
|
+
}
|
|
315
|
+
if (typeof noMemory !== "boolean") {
|
|
316
|
+
console.warn("Invalid noMemory option. Fallback: false.");
|
|
317
|
+
noMemory = false;
|
|
318
|
+
}
|
|
319
|
+
if (typeof noStart !== "boolean") {
|
|
320
|
+
console.warn("Invalid noStart option. Fallback: false.");
|
|
321
|
+
noStart = false;
|
|
322
|
+
}
|
|
323
|
+
if (typeof selector !== "undefined" && (typeof selector !== "string" || !selector.trim())) {
|
|
324
|
+
console.warn(
|
|
325
|
+
"Invalid selector. Fallback: all focusable elements (undefined)."
|
|
326
|
+
);
|
|
327
|
+
selector = void 0;
|
|
328
|
+
}
|
|
329
|
+
if (typeof typeahead !== "boolean") {
|
|
330
|
+
console.warn("Invalid typeahead option. Fallback: false.");
|
|
331
|
+
typeahead = false;
|
|
332
|
+
}
|
|
333
|
+
if (typeof wrap !== "boolean") {
|
|
334
|
+
console.warn("Invalid wrap option. Fallback: false.");
|
|
335
|
+
wrap = false;
|
|
336
|
+
}
|
|
337
|
+
this.#settings = {
|
|
338
|
+
navigationOnly,
|
|
339
|
+
noMemory,
|
|
340
|
+
noStart,
|
|
341
|
+
typeahead,
|
|
342
|
+
wrap
|
|
343
|
+
};
|
|
344
|
+
direction && Object.assign(this.#settings, { direction });
|
|
345
|
+
selector && Object.assign(this.#settings, { selector });
|
|
347
346
|
this.#selectorFilter = this.#createSelectorFilter();
|
|
348
347
|
this.#initialize();
|
|
349
348
|
}
|
|
@@ -375,10 +374,11 @@ var RovingTabIndex = class {
|
|
|
375
374
|
}
|
|
376
375
|
#onFocusIn = (event) => {
|
|
377
376
|
const { target } = event;
|
|
378
|
-
if (target instanceof Element) {
|
|
379
|
-
|
|
380
|
-
this.#options.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
377
|
+
if (!(target instanceof Element)) {
|
|
378
|
+
return;
|
|
381
379
|
}
|
|
380
|
+
const isFocusable2 = this.#focusables.has(target);
|
|
381
|
+
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
382
382
|
};
|
|
383
383
|
#onKeyDown = (event) => {
|
|
384
384
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -388,7 +388,7 @@ var RovingTabIndex = class {
|
|
|
388
388
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
|
-
const { direction, typeahead, wrap } = this.#
|
|
391
|
+
const { direction, typeahead, wrap } = this.#settings;
|
|
392
392
|
const isBoth = !direction;
|
|
393
393
|
const isHorizontal = direction === "horizontal";
|
|
394
394
|
if (![
|
|
@@ -455,7 +455,7 @@ var RovingTabIndex = class {
|
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
const { navigationOnly, noStart, typeahead } = this.#
|
|
458
|
+
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
459
459
|
for (const focusable of current) {
|
|
460
460
|
if (this.#focusables.has(focusable)) {
|
|
461
461
|
continue;
|
|
@@ -499,14 +499,14 @@ var RovingTabIndex = class {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
#createSelectorFilter() {
|
|
502
|
-
const { selector } = this.#
|
|
502
|
+
const { selector } = this.#settings;
|
|
503
503
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
504
504
|
}
|
|
505
505
|
#getFocusables() {
|
|
506
506
|
return getFocusables(this.#container, {
|
|
507
507
|
composed: true,
|
|
508
508
|
filter: this.#selectorFilter,
|
|
509
|
-
skipNegativeTabIndexCheck: !this.#
|
|
509
|
+
skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
|
|
510
510
|
skipVisibilityCheck: true
|
|
511
511
|
});
|
|
512
512
|
}
|
|
@@ -526,7 +526,7 @@ function getActiveElement() {
|
|
|
526
526
|
* Lightweight roving tabindex utility with fully focus management.
|
|
527
527
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
528
528
|
*
|
|
529
|
-
* @version 3.0.
|
|
529
|
+
* @version 3.0.6
|
|
530
530
|
* @author Yusuke Kamiyamane
|
|
531
531
|
* @license MIT
|
|
532
532
|
* @copyright Copyright (c) Yusuke Kamiyamane
|