@y14e/roving-tabindex 3.1.26 → 3.1.27

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
@@ -13,11 +13,11 @@ npm i @y14e/roving-tabindex
13
13
  import { createRovingTabIndex } from '@y14e/roving-tabindex';
14
14
 
15
15
  // CDNs
16
- import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.26';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.27';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.26/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.27/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.26';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.27';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -53,8 +53,10 @@ function isValid(element, name, token) {
53
53
  console.warn("Invalid element");
54
54
  return false;
55
55
  }
56
- if (!element.hasAttribute(name)) {
57
- console.warn("Invalid attribute name");
56
+ try {
57
+ document.createElement("div").setAttribute(name, "");
58
+ } catch {
59
+ console.warn(`Invalid attribute name: '${name}'`);
58
60
  return false;
59
61
  }
60
62
  if (typeof token !== "string" || !token.trim()) {
@@ -99,37 +101,13 @@ function getFocusables(container = document.body, options = {}) {
99
101
  console.warn("Invalid container element. Fallback: <body> element.");
100
102
  container = document.body;
101
103
  }
102
- let {
103
- composed = false,
104
+ const {
105
+ composed,
104
106
  filter,
105
107
  include,
106
- skipNegativeTabIndexCheck = false,
107
- skipVisibilityCheck = false
108
- } = options;
109
- if (typeof composed !== "boolean") {
110
- console.warn("Invalid composed option. Fallback: false.");
111
- composed = false;
112
- }
113
- if (typeof filter !== "undefined" && typeof filter !== "function") {
114
- console.warn(
115
- "Invalid filter function. Fallback: no filter function (undefined)."
116
- );
117
- filter = void 0;
118
- }
119
- if (typeof include !== "undefined" && typeof include !== "function") {
120
- console.warn(
121
- "Invalid include function. Fallback: no include function (undefined)."
122
- );
123
- include = void 0;
124
- }
125
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
126
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
127
- skipNegativeTabIndexCheck = false;
128
- }
129
- if (typeof skipVisibilityCheck !== "boolean") {
130
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
131
- skipVisibilityCheck = false;
132
- }
108
+ skipNegativeTabIndexCheck,
109
+ skipVisibilityCheck
110
+ } = resolveOptions2(options);
133
111
  const candidates = [];
134
112
  if (composed || include) {
135
113
  let traverse2 = function(node) {
@@ -173,15 +151,7 @@ function isFocusable(element, options = {}) {
173
151
  console.warn("Invalid element");
174
152
  return false;
175
153
  }
176
- let { skipNegativeTabIndexCheck = false, skipVisibilityCheck = false } = options;
177
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
178
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
179
- skipNegativeTabIndexCheck = false;
180
- }
181
- if (typeof skipVisibilityCheck !== "boolean") {
182
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
183
- skipVisibilityCheck = false;
184
- }
154
+ const { skipNegativeTabIndexCheck, skipVisibilityCheck } = resolveOptions2(options);
185
155
  if (element.hasAttribute("hidden") || isInert(element)) {
186
156
  return false;
187
157
  }
@@ -356,6 +326,61 @@ function isInert(element) {
356
326
  function isUngroupedRadio(element) {
357
327
  return element.type === "radio" && !!element.name;
358
328
  }
329
+ function resolveOptions2(options) {
330
+ let {
331
+ anchor = getActiveElement(),
332
+ composed = false,
333
+ filter,
334
+ include,
335
+ skipNegativeTabIndexCheck = false,
336
+ skipVisibilityCheck = false,
337
+ wrap = false
338
+ } = options;
339
+ if (!(anchor instanceof Element)) {
340
+ const active = getActiveElement();
341
+ if (active instanceof Element) {
342
+ console.warn("Invalid anchor element. Fallback: active element.");
343
+ anchor = active;
344
+ }
345
+ }
346
+ if (typeof composed !== "boolean") {
347
+ console.warn("Invalid composed option. Fallback: false.");
348
+ composed = false;
349
+ }
350
+ if (filter !== void 0 && typeof filter !== "function") {
351
+ console.warn(
352
+ "Invalid filter function. Fallback: no filter function (undefined)."
353
+ );
354
+ filter = void 0;
355
+ }
356
+ if (include !== void 0 && typeof include !== "function") {
357
+ console.warn(
358
+ "Invalid include function. Fallback: no include function (undefined)."
359
+ );
360
+ include = void 0;
361
+ }
362
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
363
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
364
+ skipNegativeTabIndexCheck = false;
365
+ }
366
+ if (typeof skipVisibilityCheck !== "boolean") {
367
+ console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
368
+ skipVisibilityCheck = false;
369
+ }
370
+ if (typeof wrap !== "boolean") {
371
+ console.warn("Invalid wrap option. Fallback: false.");
372
+ wrap = false;
373
+ }
374
+ return {
375
+ anchor,
376
+ composed,
377
+ filter,
378
+ include,
379
+ skipNegativeTabIndexCheck,
380
+ skipVisibilityCheck,
381
+ wrap
382
+ };
383
+ }
359
384
 
360
385
  // src/index.ts
361
386
  function createRovingTabIndex(container, options = {}) {
@@ -624,7 +649,7 @@ var RovingTabIndex = class _RovingTabIndex {
624
649
  * Lightweight roving tabindex utility with fully focus management.
625
650
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
626
651
  *
627
- * @version 3.1.26
652
+ * @version 3.1.27
628
653
  * @author Yusuke Kamiyamane
629
654
  * @license MIT
630
655
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -636,7 +661,7 @@ var RovingTabIndex = class _RovingTabIndex {
636
661
  (**
637
662
  * Attribute Utils
638
663
  *
639
- * @version 2.0.6
664
+ * @version 2.0.8
640
665
  * @author Yusuke Kamiyamane
641
666
  * @license MIT
642
667
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -649,7 +674,7 @@ power-focusable/dist/index.js:
649
674
  * High-precision focus management utility with full composed tree support.
650
675
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
651
676
  *
652
- * @version 4.3.28
677
+ * @version 4.3.29
653
678
  * @author Yusuke Kamiyamane
654
679
  * @license MIT
655
680
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -51,8 +51,10 @@ function isValid(element, name, token) {
51
51
  console.warn("Invalid element");
52
52
  return false;
53
53
  }
54
- if (!element.hasAttribute(name)) {
55
- console.warn("Invalid attribute name");
54
+ try {
55
+ document.createElement("div").setAttribute(name, "");
56
+ } catch {
57
+ console.warn(`Invalid attribute name: '${name}'`);
56
58
  return false;
57
59
  }
58
60
  if (typeof token !== "string" || !token.trim()) {
@@ -97,37 +99,13 @@ function getFocusables(container = document.body, options = {}) {
97
99
  console.warn("Invalid container element. Fallback: <body> element.");
98
100
  container = document.body;
99
101
  }
100
- let {
101
- composed = false,
102
+ const {
103
+ composed,
102
104
  filter,
103
105
  include,
104
- skipNegativeTabIndexCheck = false,
105
- skipVisibilityCheck = false
106
- } = options;
107
- if (typeof composed !== "boolean") {
108
- console.warn("Invalid composed option. Fallback: false.");
109
- composed = false;
110
- }
111
- if (typeof filter !== "undefined" && typeof filter !== "function") {
112
- console.warn(
113
- "Invalid filter function. Fallback: no filter function (undefined)."
114
- );
115
- filter = void 0;
116
- }
117
- if (typeof include !== "undefined" && typeof include !== "function") {
118
- console.warn(
119
- "Invalid include function. Fallback: no include function (undefined)."
120
- );
121
- include = void 0;
122
- }
123
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
124
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
125
- skipNegativeTabIndexCheck = false;
126
- }
127
- if (typeof skipVisibilityCheck !== "boolean") {
128
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
129
- skipVisibilityCheck = false;
130
- }
106
+ skipNegativeTabIndexCheck,
107
+ skipVisibilityCheck
108
+ } = resolveOptions2(options);
131
109
  const candidates = [];
132
110
  if (composed || include) {
133
111
  let traverse2 = function(node) {
@@ -171,15 +149,7 @@ function isFocusable(element, options = {}) {
171
149
  console.warn("Invalid element");
172
150
  return false;
173
151
  }
174
- let { skipNegativeTabIndexCheck = false, skipVisibilityCheck = false } = options;
175
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
176
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
177
- skipNegativeTabIndexCheck = false;
178
- }
179
- if (typeof skipVisibilityCheck !== "boolean") {
180
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
181
- skipVisibilityCheck = false;
182
- }
152
+ const { skipNegativeTabIndexCheck, skipVisibilityCheck } = resolveOptions2(options);
183
153
  if (element.hasAttribute("hidden") || isInert(element)) {
184
154
  return false;
185
155
  }
@@ -354,6 +324,61 @@ function isInert(element) {
354
324
  function isUngroupedRadio(element) {
355
325
  return element.type === "radio" && !!element.name;
356
326
  }
327
+ function resolveOptions2(options) {
328
+ let {
329
+ anchor = getActiveElement(),
330
+ composed = false,
331
+ filter,
332
+ include,
333
+ skipNegativeTabIndexCheck = false,
334
+ skipVisibilityCheck = false,
335
+ wrap = false
336
+ } = options;
337
+ if (!(anchor instanceof Element)) {
338
+ const active = getActiveElement();
339
+ if (active instanceof Element) {
340
+ console.warn("Invalid anchor element. Fallback: active element.");
341
+ anchor = active;
342
+ }
343
+ }
344
+ if (typeof composed !== "boolean") {
345
+ console.warn("Invalid composed option. Fallback: false.");
346
+ composed = false;
347
+ }
348
+ if (filter !== void 0 && typeof filter !== "function") {
349
+ console.warn(
350
+ "Invalid filter function. Fallback: no filter function (undefined)."
351
+ );
352
+ filter = void 0;
353
+ }
354
+ if (include !== void 0 && typeof include !== "function") {
355
+ console.warn(
356
+ "Invalid include function. Fallback: no include function (undefined)."
357
+ );
358
+ include = void 0;
359
+ }
360
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
361
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
362
+ skipNegativeTabIndexCheck = false;
363
+ }
364
+ if (typeof skipVisibilityCheck !== "boolean") {
365
+ console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
366
+ skipVisibilityCheck = false;
367
+ }
368
+ if (typeof wrap !== "boolean") {
369
+ console.warn("Invalid wrap option. Fallback: false.");
370
+ wrap = false;
371
+ }
372
+ return {
373
+ anchor,
374
+ composed,
375
+ filter,
376
+ include,
377
+ skipNegativeTabIndexCheck,
378
+ skipVisibilityCheck,
379
+ wrap
380
+ };
381
+ }
357
382
 
358
383
  // src/index.ts
359
384
  function createRovingTabIndex(container, options = {}) {
@@ -622,7 +647,7 @@ var RovingTabIndex = class _RovingTabIndex {
622
647
  * Lightweight roving tabindex utility with fully focus management.
623
648
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
624
649
  *
625
- * @version 3.1.26
650
+ * @version 3.1.27
626
651
  * @author Yusuke Kamiyamane
627
652
  * @license MIT
628
653
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -634,7 +659,7 @@ var RovingTabIndex = class _RovingTabIndex {
634
659
  (**
635
660
  * Attribute Utils
636
661
  *
637
- * @version 2.0.6
662
+ * @version 2.0.8
638
663
  * @author Yusuke Kamiyamane
639
664
  * @license MIT
640
665
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -647,7 +672,7 @@ power-focusable/dist/index.js:
647
672
  * High-precision focus management utility with full composed tree support.
648
673
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
649
674
  *
650
- * @version 4.3.28
675
+ * @version 4.3.29
651
676
  * @author Yusuke Kamiyamane
652
677
  * @license MIT
653
678
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -291,7 +291,7 @@ var RovingTabIndex = class _RovingTabIndex {
291
291
  * Lightweight roving tabindex utility with fully focus management.
292
292
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
293
293
  *
294
- * @version 3.1.26
294
+ * @version 3.1.27
295
295
  * @author Yusuke Kamiyamane
296
296
  * @license MIT
297
297
  * @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.26
6
+ * @version 3.1.27
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.26
6
+ * @version 3.1.27
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -268,7 +268,7 @@ var RovingTabIndex = class _RovingTabIndex {
268
268
  * Lightweight roving tabindex utility with fully focus management.
269
269
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
270
270
  *
271
- * @version 3.1.26
271
+ * @version 3.1.27
272
272
  * @author Yusuke Kamiyamane
273
273
  * @license MIT
274
274
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,28 +1,7 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "3.1.26",
3
+ "version": "3.1.27",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
14
- }
15
- },
16
- "files": [
17
- "dist",
18
- "LICENSE",
19
- "README.md"
20
- ],
21
- "scripts": {
22
- "build": "tsup",
23
- "prepublishOnly": "npm run build",
24
- "lint": "tsc --noEmit"
25
- },
26
5
  "keywords": [
27
6
  "a11y",
28
7
  "accessibility",
@@ -37,16 +16,41 @@
37
16
  "typescript",
38
17
  "utility"
39
18
  ],
40
- "author": "Yusuke Kamiyamane",
41
- "license": "MIT",
19
+ "homepage": "https://github.com/y14e/roving-tabindex#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/y14e/roving-tabindex/issues"
22
+ },
42
23
  "repository": {
43
24
  "type": "git",
44
25
  "url": "git+https://github.com/y14e/roving-tabindex.git"
45
26
  },
46
- "bugs": {
47
- "url": "https://github.com/y14e/roving-tabindex/issues"
27
+ "license": "MIT",
28
+ "author": "Yusuke Kamiyamane",
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ }
36
+ },
37
+ "main": "./dist/index.cjs",
38
+ "module": "./dist/index.js",
39
+ "types": "./dist/index.d.ts",
40
+ "files": [
41
+ "dist",
42
+ "LICENSE",
43
+ "README.md"
44
+ ],
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "lint": "tsc --noEmit",
48
+ "prepublishOnly": "npm run build"
49
+ },
50
+ "dependencies": {
51
+ "@y14e/attribute-utils": "^2.0.8",
52
+ "power-focusable": "^4.3.29"
48
53
  },
49
- "homepage": "https://github.com/y14e/roving-tabindex#readme",
50
54
  "devDependencies": {
51
55
  "bun-types": "latest",
52
56
  "tsup": "^8.0.0",
@@ -57,9 +61,5 @@
57
61
  },
58
62
  "allowScripts": {
59
63
  "esbuild": true
60
- },
61
- "dependencies": {
62
- "@y14e/attribute-utils": "^2.0.6",
63
- "power-focusable": "^4.3.28"
64
64
  }
65
65
  }