@y14e/roving-tabindex 3.1.20 → 3.1.22

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.20';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.22';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.20/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.22/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.20';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.22';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- // node_modules/@y14e/attributes-utils/dist/index.js
3
+ // node_modules/@y14e/attribute-util/dist/index.js
4
4
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
5
5
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
6
- function addTokenToAttribute(element, attribute, token, options = {}) {
7
- const value = element.getAttribute(attribute)?.trim();
6
+ function addAttributeToken(element, name, token, options = {}) {
7
+ const value = element.getAttribute(name)?.trim();
8
8
  const {
9
9
  caseInsensitive = false,
10
10
  parse = DEFAULT_PARSER,
@@ -15,12 +15,12 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
15
15
  const lower = token.toLowerCase();
16
16
  if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
17
17
  tokens.push(token);
18
- element.setAttribute(attribute, serialize(tokens));
18
+ element.setAttribute(name, serialize(tokens));
19
19
  }
20
20
  } else {
21
21
  const set = new Set(tokens);
22
22
  set.add(token);
23
- element.setAttribute(attribute, serialize([...set]));
23
+ element.setAttribute(name, serialize([...set]));
24
24
  }
25
25
  }
26
26
  var snapshots = /* @__PURE__ */ new WeakMap();
@@ -30,22 +30,22 @@ function restoreAttributes(element_or_elements) {
30
30
  if (!snapshot) {
31
31
  continue;
32
32
  }
33
- for (const [attribute, value] of snapshot.entries()) {
34
- value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
33
+ for (const [name, value] of snapshot.entries()) {
34
+ value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
35
35
  }
36
36
  snapshots.delete(element);
37
37
  }
38
38
  }
39
- function saveAttributes(element_or_elements, attribute_or_attributes) {
40
- const attributes = Array.isArray(attribute_or_attributes) ? attribute_or_attributes : [attribute_or_attributes];
39
+ function saveAttributes(element_or_elements, name_or_names) {
40
+ const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
41
41
  (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
42
42
  let snapshot = snapshots.get(element);
43
43
  if (!snapshot) {
44
44
  snapshot = /* @__PURE__ */ new Map();
45
45
  snapshots.set(element, snapshot);
46
46
  }
47
- attributes.forEach((attribute) => {
48
- snapshot.set(attribute, element.getAttribute(attribute));
47
+ names.forEach((name) => {
48
+ snapshot.set(name, element.getAttribute(name));
49
49
  });
50
50
  });
51
51
  }
@@ -551,7 +551,7 @@ var RovingTabIndex = class _RovingTabIndex {
551
551
  if (char) {
552
552
  keys.add(char);
553
553
  saveAttributes(focusable, "aria-keyshortcuts");
554
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
554
+ addAttributeToken(focusable, "aria-keyshortcuts", char, {
555
555
  caseInsensitive: true
556
556
  });
557
557
  }
@@ -591,7 +591,7 @@ var RovingTabIndex = class _RovingTabIndex {
591
591
  * Lightweight roving tabindex utility with fully focus management.
592
592
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
593
593
  *
594
- * @version 3.1.20
594
+ * @version 3.1.22
595
595
  * @author Yusuke Kamiyamane
596
596
  * @license MIT
597
597
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -599,15 +599,15 @@ var RovingTabIndex = class _RovingTabIndex {
599
599
  */
600
600
  /*! Bundled license information:
601
601
 
602
- @y14e/attributes-utils/dist/index.js:
602
+ @y14e/attribute-util/dist/index.js:
603
603
  (**
604
- * Attributes Utils
604
+ * Attribute Util
605
605
  *
606
- * @version 1.1.4
606
+ * @version 2.0.1
607
607
  * @author Yusuke Kamiyamane
608
608
  * @license MIT
609
609
  * @copyright Copyright (c) Yusuke Kamiyamane
610
- * @see {@link https://github.com/y14e/attributes-utils}
610
+ * @see {@link https://github.com/y14e/attribute-util}
611
611
  *)
612
612
 
613
613
  power-focusable/dist/index.js:
@@ -616,7 +616,7 @@ power-focusable/dist/index.js:
616
616
  * High-precision focus management utility with full composed tree support.
617
617
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
618
618
  *
619
- * @version 4.3.21
619
+ * @version 4.3.25
620
620
  * @author Yusuke Kamiyamane
621
621
  * @license MIT
622
622
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1,8 +1,8 @@
1
- // node_modules/@y14e/attributes-utils/dist/index.js
1
+ // node_modules/@y14e/attribute-util/dist/index.js
2
2
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
3
3
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
4
- function addTokenToAttribute(element, attribute, token, options = {}) {
5
- const value = element.getAttribute(attribute)?.trim();
4
+ function addAttributeToken(element, name, token, options = {}) {
5
+ const value = element.getAttribute(name)?.trim();
6
6
  const {
7
7
  caseInsensitive = false,
8
8
  parse = DEFAULT_PARSER,
@@ -13,12 +13,12 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
13
13
  const lower = token.toLowerCase();
14
14
  if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
15
15
  tokens.push(token);
16
- element.setAttribute(attribute, serialize(tokens));
16
+ element.setAttribute(name, serialize(tokens));
17
17
  }
18
18
  } else {
19
19
  const set = new Set(tokens);
20
20
  set.add(token);
21
- element.setAttribute(attribute, serialize([...set]));
21
+ element.setAttribute(name, serialize([...set]));
22
22
  }
23
23
  }
24
24
  var snapshots = /* @__PURE__ */ new WeakMap();
@@ -28,22 +28,22 @@ function restoreAttributes(element_or_elements) {
28
28
  if (!snapshot) {
29
29
  continue;
30
30
  }
31
- for (const [attribute, value] of snapshot.entries()) {
32
- value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
31
+ for (const [name, value] of snapshot.entries()) {
32
+ value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
33
33
  }
34
34
  snapshots.delete(element);
35
35
  }
36
36
  }
37
- function saveAttributes(element_or_elements, attribute_or_attributes) {
38
- const attributes = Array.isArray(attribute_or_attributes) ? attribute_or_attributes : [attribute_or_attributes];
37
+ function saveAttributes(element_or_elements, name_or_names) {
38
+ const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
39
39
  (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
40
40
  let snapshot = snapshots.get(element);
41
41
  if (!snapshot) {
42
42
  snapshot = /* @__PURE__ */ new Map();
43
43
  snapshots.set(element, snapshot);
44
44
  }
45
- attributes.forEach((attribute) => {
46
- snapshot.set(attribute, element.getAttribute(attribute));
45
+ names.forEach((name) => {
46
+ snapshot.set(name, element.getAttribute(name));
47
47
  });
48
48
  });
49
49
  }
@@ -549,7 +549,7 @@ var RovingTabIndex = class _RovingTabIndex {
549
549
  if (char) {
550
550
  keys.add(char);
551
551
  saveAttributes(focusable, "aria-keyshortcuts");
552
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
552
+ addAttributeToken(focusable, "aria-keyshortcuts", char, {
553
553
  caseInsensitive: true
554
554
  });
555
555
  }
@@ -589,7 +589,7 @@ var RovingTabIndex = class _RovingTabIndex {
589
589
  * Lightweight roving tabindex utility with fully focus management.
590
590
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
591
591
  *
592
- * @version 3.1.20
592
+ * @version 3.1.22
593
593
  * @author Yusuke Kamiyamane
594
594
  * @license MIT
595
595
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -597,15 +597,15 @@ var RovingTabIndex = class _RovingTabIndex {
597
597
  */
598
598
  /*! Bundled license information:
599
599
 
600
- @y14e/attributes-utils/dist/index.js:
600
+ @y14e/attribute-util/dist/index.js:
601
601
  (**
602
- * Attributes Utils
602
+ * Attribute Util
603
603
  *
604
- * @version 1.1.4
604
+ * @version 2.0.1
605
605
  * @author Yusuke Kamiyamane
606
606
  * @license MIT
607
607
  * @copyright Copyright (c) Yusuke Kamiyamane
608
- * @see {@link https://github.com/y14e/attributes-utils}
608
+ * @see {@link https://github.com/y14e/attribute-util}
609
609
  *)
610
610
 
611
611
  power-focusable/dist/index.js:
@@ -614,7 +614,7 @@ power-focusable/dist/index.js:
614
614
  * High-precision focus management utility with full composed tree support.
615
615
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
616
616
  *
617
- * @version 4.3.21
617
+ * @version 4.3.25
618
618
  * @author Yusuke Kamiyamane
619
619
  * @license MIT
620
620
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -1,7 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var attributesUtils = require('@y14e/attributes-utils');
4
- var powerFocusable = require('power-focusable');
3
+ var util = require('@y14e/attribute-util');
4
+ var pf = require('power-focusable');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var util__namespace = /*#__PURE__*/_interopNamespace(util);
25
+ var pf__namespace = /*#__PURE__*/_interopNamespace(pf);
5
26
 
6
27
  // src/index.ts
7
28
  function createRovingTabIndex(container, options = {}) {
@@ -94,13 +115,13 @@ var RovingTabIndex = class _RovingTabIndex {
94
115
  this.#controller = null;
95
116
  this.#focusables.forEach((focusable) => {
96
117
  _RovingTabIndex.#initialized.delete(focusable);
97
- attributesUtils.restoreAttributes(focusable);
118
+ util__namespace.restoreAttributes(focusable);
98
119
  });
99
120
  this.#focusables.clear();
100
121
  this.#focusablesByFirstChar.clear();
101
122
  }
102
123
  #initialize() {
103
- this.#update(powerFocusable.getActiveElement());
124
+ this.#update(pf__namespace.getActiveElement());
104
125
  this.#controller = new AbortController();
105
126
  const { signal } = this.#controller;
106
127
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
@@ -147,7 +168,7 @@ var RovingTabIndex = class _RovingTabIndex {
147
168
  const candidates = this.#getFocusables().filter(
148
169
  (focusable2) => this.#focusables.has(focusable2)
149
170
  );
150
- const active = powerFocusable.getActiveElement();
171
+ const active = pf__namespace.getActiveElement();
151
172
  if (!(active instanceof Element)) {
152
173
  return;
153
174
  }
@@ -192,14 +213,14 @@ var RovingTabIndex = class _RovingTabIndex {
192
213
  }
193
214
  }
194
215
  const focusable = focusables.at(newIndex);
195
- focusable && powerFocusable.focusElement(focusable);
216
+ focusable && pf__namespace.focusElement(focusable);
196
217
  };
197
218
  #update(active) {
198
219
  const current = new Set(this.#getFocusables());
199
220
  for (const focusable of this.#focusables) {
200
221
  if (!current.has(focusable)) {
201
222
  _RovingTabIndex.#initialized.delete(focusable);
202
- attributesUtils.restoreAttributes(focusable);
223
+ util__namespace.restoreAttributes(focusable);
203
224
  this.#focusables.delete(focusable);
204
225
  for (const [key, focusables] of this.#focusablesByFirstChar) {
205
226
  const index = focusables.indexOf(focusable);
@@ -221,7 +242,7 @@ var RovingTabIndex = class _RovingTabIndex {
221
242
  this.#focusables.add(focusable);
222
243
  _RovingTabIndex.#initialized.add(focusable);
223
244
  if (!navigationOnly) {
224
- attributesUtils.saveAttributes(focusable, "tabindex");
245
+ util__namespace.saveAttributes(focusable, "tabindex");
225
246
  focusable.setAttribute("tabindex", "-1");
226
247
  }
227
248
  if (!typeahead) {
@@ -234,8 +255,8 @@ var RovingTabIndex = class _RovingTabIndex {
234
255
  );
235
256
  if (char) {
236
257
  keys.add(char);
237
- attributesUtils.saveAttributes(focusable, "aria-keyshortcuts");
238
- attributesUtils.addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
258
+ util__namespace.saveAttributes(focusable, "aria-keyshortcuts");
259
+ util__namespace.addAttributeToken(focusable, "aria-keyshortcuts", char, {
239
260
  caseInsensitive: true
240
261
  });
241
262
  }
@@ -262,7 +283,7 @@ var RovingTabIndex = class _RovingTabIndex {
262
283
  return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
263
284
  }
264
285
  #getFocusables() {
265
- return powerFocusable.getFocusables(this.#container, {
286
+ return pf__namespace.getFocusables(this.#container, {
266
287
  composed: true,
267
288
  filter: this.#selectorFilter,
268
289
  skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
@@ -275,7 +296,7 @@ var RovingTabIndex = class _RovingTabIndex {
275
296
  * Lightweight roving tabindex utility with fully focus management.
276
297
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
277
298
  *
278
- * @version 3.1.20
299
+ * @version 3.1.22
279
300
  * @author Yusuke Kamiyamane
280
301
  * @license MIT
281
302
  * @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.20
6
+ * @version 3.1.22
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.20
6
+ * @version 3.1.22
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { restoreAttributes, saveAttributes, addTokenToAttribute } from '@y14e/attributes-utils';
2
- import { getActiveElement, focusElement, getFocusables } from 'power-focusable';
1
+ import * as util from '@y14e/attribute-util';
2
+ import * as pf from 'power-focusable';
3
3
 
4
4
  // src/index.ts
5
5
  function createRovingTabIndex(container, options = {}) {
@@ -92,13 +92,13 @@ var RovingTabIndex = class _RovingTabIndex {
92
92
  this.#controller = null;
93
93
  this.#focusables.forEach((focusable) => {
94
94
  _RovingTabIndex.#initialized.delete(focusable);
95
- restoreAttributes(focusable);
95
+ util.restoreAttributes(focusable);
96
96
  });
97
97
  this.#focusables.clear();
98
98
  this.#focusablesByFirstChar.clear();
99
99
  }
100
100
  #initialize() {
101
- this.#update(getActiveElement());
101
+ this.#update(pf.getActiveElement());
102
102
  this.#controller = new AbortController();
103
103
  const { signal } = this.#controller;
104
104
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
@@ -145,7 +145,7 @@ var RovingTabIndex = class _RovingTabIndex {
145
145
  const candidates = this.#getFocusables().filter(
146
146
  (focusable2) => this.#focusables.has(focusable2)
147
147
  );
148
- const active = getActiveElement();
148
+ const active = pf.getActiveElement();
149
149
  if (!(active instanceof Element)) {
150
150
  return;
151
151
  }
@@ -190,14 +190,14 @@ var RovingTabIndex = class _RovingTabIndex {
190
190
  }
191
191
  }
192
192
  const focusable = focusables.at(newIndex);
193
- focusable && focusElement(focusable);
193
+ focusable && pf.focusElement(focusable);
194
194
  };
195
195
  #update(active) {
196
196
  const current = new Set(this.#getFocusables());
197
197
  for (const focusable of this.#focusables) {
198
198
  if (!current.has(focusable)) {
199
199
  _RovingTabIndex.#initialized.delete(focusable);
200
- restoreAttributes(focusable);
200
+ util.restoreAttributes(focusable);
201
201
  this.#focusables.delete(focusable);
202
202
  for (const [key, focusables] of this.#focusablesByFirstChar) {
203
203
  const index = focusables.indexOf(focusable);
@@ -219,7 +219,7 @@ var RovingTabIndex = class _RovingTabIndex {
219
219
  this.#focusables.add(focusable);
220
220
  _RovingTabIndex.#initialized.add(focusable);
221
221
  if (!navigationOnly) {
222
- saveAttributes(focusable, "tabindex");
222
+ util.saveAttributes(focusable, "tabindex");
223
223
  focusable.setAttribute("tabindex", "-1");
224
224
  }
225
225
  if (!typeahead) {
@@ -232,8 +232,8 @@ var RovingTabIndex = class _RovingTabIndex {
232
232
  );
233
233
  if (char) {
234
234
  keys.add(char);
235
- saveAttributes(focusable, "aria-keyshortcuts");
236
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
235
+ util.saveAttributes(focusable, "aria-keyshortcuts");
236
+ util.addAttributeToken(focusable, "aria-keyshortcuts", char, {
237
237
  caseInsensitive: true
238
238
  });
239
239
  }
@@ -260,7 +260,7 @@ var RovingTabIndex = class _RovingTabIndex {
260
260
  return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
261
261
  }
262
262
  #getFocusables() {
263
- return getFocusables(this.#container, {
263
+ return pf.getFocusables(this.#container, {
264
264
  composed: true,
265
265
  filter: this.#selectorFilter,
266
266
  skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
@@ -273,7 +273,7 @@ var RovingTabIndex = class _RovingTabIndex {
273
273
  * Lightweight roving tabindex utility with fully focus management.
274
274
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
275
275
  *
276
- * @version 3.1.20
276
+ * @version 3.1.22
277
277
  * @author Yusuke Kamiyamane
278
278
  * @license MIT
279
279
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "3.1.20",
3
+ "version": "3.1.22",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -56,7 +56,7 @@
56
56
  "node": ">=18"
57
57
  },
58
58
  "dependencies": {
59
- "@y14e/attributes-utils": "^1.1.4",
60
- "power-focusable": "^4.3.21"
59
+ "@y14e/attribute-util": "^2.0.1",
60
+ "power-focusable": "^4.3.25"
61
61
  }
62
62
  }