@y14e/roving-tabindex 3.0.5 → 3.0.7
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 +60 -57
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +57 -58
- 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.7';
|
|
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.7';
|
|
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.7/+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.7';
|
|
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
|
}
|
|
@@ -381,7 +380,7 @@ var RovingTabIndex = class {
|
|
|
381
380
|
return;
|
|
382
381
|
}
|
|
383
382
|
const isFocusable2 = this.#focusables.has(target);
|
|
384
|
-
this.#
|
|
383
|
+
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
385
384
|
};
|
|
386
385
|
#onKeyDown = (event) => {
|
|
387
386
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -391,7 +390,7 @@ var RovingTabIndex = class {
|
|
|
391
390
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
392
391
|
return;
|
|
393
392
|
}
|
|
394
|
-
const { direction, typeahead, wrap } = this.#
|
|
393
|
+
const { direction, typeahead, wrap } = this.#settings;
|
|
395
394
|
const isBoth = !direction;
|
|
396
395
|
const isHorizontal = direction === "horizontal";
|
|
397
396
|
if (![
|
|
@@ -458,7 +457,7 @@ var RovingTabIndex = class {
|
|
|
458
457
|
});
|
|
459
458
|
}
|
|
460
459
|
}
|
|
461
|
-
const { navigationOnly, noStart, typeahead } = this.#
|
|
460
|
+
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
462
461
|
for (const focusable of current) {
|
|
463
462
|
if (this.#focusables.has(focusable)) {
|
|
464
463
|
continue;
|
|
@@ -502,14 +501,14 @@ var RovingTabIndex = class {
|
|
|
502
501
|
}
|
|
503
502
|
}
|
|
504
503
|
#createSelectorFilter() {
|
|
505
|
-
const { selector } = this.#
|
|
504
|
+
const { selector } = this.#settings;
|
|
506
505
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
507
506
|
}
|
|
508
507
|
#getFocusables() {
|
|
509
508
|
return getFocusables(this.#container, {
|
|
510
509
|
composed: true,
|
|
511
510
|
filter: this.#selectorFilter,
|
|
512
|
-
skipNegativeTabIndexCheck: !this.#
|
|
511
|
+
skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
|
|
513
512
|
skipVisibilityCheck: true
|
|
514
513
|
});
|
|
515
514
|
}
|
|
@@ -529,7 +528,7 @@ function getActiveElement() {
|
|
|
529
528
|
* Lightweight roving tabindex utility with fully focus management.
|
|
530
529
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
531
530
|
*
|
|
532
|
-
* @version 3.0.
|
|
531
|
+
* @version 3.0.7
|
|
533
532
|
* @author Yusuke Kamiyamane
|
|
534
533
|
* @license MIT
|
|
535
534
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -562,4 +561,8 @@ power-focusable/dist/index.js:
|
|
|
562
561
|
*)
|
|
563
562
|
*/
|
|
564
563
|
|
|
564
|
+
exports.addTokenToAttribute = addTokenToAttribute;
|
|
565
565
|
exports.createRovingTabIndex = createRovingTabIndex;
|
|
566
|
+
exports.getFocusables = getFocusables;
|
|
567
|
+
exports.restoreAttributes = restoreAttributes;
|
|
568
|
+
exports.saveAttributes = saveAttributes;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export { addTokenToAttribute, restoreAttributes, saveAttributes } from '@y14e/attributes-utils';
|
|
2
|
+
export { getFocusables } from 'power-focusable';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Roving Tabindex
|
|
3
6
|
* Lightweight roving tabindex utility with fully focus management.
|
|
4
7
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
5
8
|
*
|
|
6
|
-
* @version 3.0.
|
|
9
|
+
* @version 3.0.7
|
|
7
10
|
* @author Yusuke Kamiyamane
|
|
8
11
|
* @license MIT
|
|
9
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
10
13
|
* @see {@link https://github.com/y14e/roving-tabindex}
|
|
11
14
|
*/
|
|
15
|
+
|
|
12
16
|
interface RovingTabIndexOptions {
|
|
13
17
|
readonly direction?: 'horizontal' | 'vertical';
|
|
14
18
|
readonly navigationOnly?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export { addTokenToAttribute, restoreAttributes, saveAttributes } from '@y14e/attributes-utils';
|
|
2
|
+
export { getFocusables } from 'power-focusable';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Roving Tabindex
|
|
3
6
|
* Lightweight roving tabindex utility with fully focus management.
|
|
4
7
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
5
8
|
*
|
|
6
|
-
* @version 3.0.
|
|
9
|
+
* @version 3.0.7
|
|
7
10
|
* @author Yusuke Kamiyamane
|
|
8
11
|
* @license MIT
|
|
9
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
10
13
|
* @see {@link https://github.com/y14e/roving-tabindex}
|
|
11
14
|
*/
|
|
15
|
+
|
|
12
16
|
interface RovingTabIndexOptions {
|
|
13
17
|
readonly direction?: 'horizontal' | 'vertical';
|
|
14
18
|
readonly navigationOnly?: boolean;
|
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
|
}
|
|
@@ -379,7 +378,7 @@ var RovingTabIndex = class {
|
|
|
379
378
|
return;
|
|
380
379
|
}
|
|
381
380
|
const isFocusable2 = this.#focusables.has(target);
|
|
382
|
-
this.#
|
|
381
|
+
this.#settings.noMemory && !isFocusable2 ? this.#update(null) : isFocusable2 && this.#update(target);
|
|
383
382
|
};
|
|
384
383
|
#onKeyDown = (event) => {
|
|
385
384
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -389,7 +388,7 @@ var RovingTabIndex = class {
|
|
|
389
388
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
390
389
|
return;
|
|
391
390
|
}
|
|
392
|
-
const { direction, typeahead, wrap } = this.#
|
|
391
|
+
const { direction, typeahead, wrap } = this.#settings;
|
|
393
392
|
const isBoth = !direction;
|
|
394
393
|
const isHorizontal = direction === "horizontal";
|
|
395
394
|
if (![
|
|
@@ -456,7 +455,7 @@ var RovingTabIndex = class {
|
|
|
456
455
|
});
|
|
457
456
|
}
|
|
458
457
|
}
|
|
459
|
-
const { navigationOnly, noStart, typeahead } = this.#
|
|
458
|
+
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
460
459
|
for (const focusable of current) {
|
|
461
460
|
if (this.#focusables.has(focusable)) {
|
|
462
461
|
continue;
|
|
@@ -500,14 +499,14 @@ var RovingTabIndex = class {
|
|
|
500
499
|
}
|
|
501
500
|
}
|
|
502
501
|
#createSelectorFilter() {
|
|
503
|
-
const { selector } = this.#
|
|
502
|
+
const { selector } = this.#settings;
|
|
504
503
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
505
504
|
}
|
|
506
505
|
#getFocusables() {
|
|
507
506
|
return getFocusables(this.#container, {
|
|
508
507
|
composed: true,
|
|
509
508
|
filter: this.#selectorFilter,
|
|
510
|
-
skipNegativeTabIndexCheck: !this.#
|
|
509
|
+
skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
|
|
511
510
|
skipVisibilityCheck: true
|
|
512
511
|
});
|
|
513
512
|
}
|
|
@@ -527,7 +526,7 @@ function getActiveElement() {
|
|
|
527
526
|
* Lightweight roving tabindex utility with fully focus management.
|
|
528
527
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
529
528
|
*
|
|
530
|
-
* @version 3.0.
|
|
529
|
+
* @version 3.0.7
|
|
531
530
|
* @author Yusuke Kamiyamane
|
|
532
531
|
* @license MIT
|
|
533
532
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -560,4 +559,4 @@ power-focusable/dist/index.js:
|
|
|
560
559
|
*)
|
|
561
560
|
*/
|
|
562
561
|
|
|
563
|
-
export { createRovingTabIndex };
|
|
562
|
+
export { addTokenToAttribute, createRovingTabIndex, getFocusables, restoreAttributes, saveAttributes };
|