@y14e/roving-tabindex 1.0.0 → 1.0.1

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/dist/index.cjs CHANGED
@@ -207,6 +207,19 @@ function createRovingTabIndex(container, options = {}) {
207
207
  if (!(container instanceof Element)) {
208
208
  throw new Error("Invalid container element");
209
209
  }
210
+ const { direction, selector, wrap = false } = options;
211
+ if (direction && !["horizontal", "vertical"].includes(direction)) {
212
+ console.warn("Invalid direction. Fallback: both (undefined).");
213
+ Object.assign(options, { direction: void 0 });
214
+ }
215
+ if (typeof selector !== "string") {
216
+ console.warn("Invalid selector. Fallback: all focusable elements.");
217
+ Object.assign(options, { selector: void 0 });
218
+ }
219
+ if (typeof wrap !== "boolean") {
220
+ console.warn("Invalid wrap. Fallback: false.");
221
+ Object.assign(options, { wrap: false });
222
+ }
210
223
  const roving = new RovingTabIndex(container, options);
211
224
  return () => roving.destroy();
212
225
  }
@@ -221,19 +234,6 @@ var RovingTabIndex = class {
221
234
  constructor(container, options = {}) {
222
235
  this.#container = container;
223
236
  this.#options = options;
224
- const { direction, selector, wrap = false } = this.#options;
225
- if (direction && !["horizontal", "vertical"].includes(direction)) {
226
- console.warn("Invalid direction. Fallback: both (undefined).");
227
- Object.assign(this.#options, { direction: void 0 });
228
- }
229
- if (typeof selector !== "string") {
230
- console.warn("Invalid selector. Fallback: all focusable elements.");
231
- Object.assign(this.#options, { selector: void 0 });
232
- }
233
- if (typeof wrap !== "boolean") {
234
- console.warn("Invalid wrap. Fallback: false.");
235
- Object.assign(this.#options, { wrap: false });
236
- }
237
237
  this.#selectorFilter = this.#createSelectorFilter();
238
238
  this.#initialize();
239
239
  }
@@ -366,7 +366,7 @@ var RovingTabIndex = class {
366
366
  }
367
367
  #createSelectorFilter() {
368
368
  const { selector } = this.#options;
369
- return (element) => !selector || element.matches(selector);
369
+ return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
370
370
  }
371
371
  #getFocusables() {
372
372
  return getFocusables(this.#container, {
@@ -391,7 +391,7 @@ function getActiveElement() {
391
391
  * Lightweight roving tabindex utility with fully focus management.
392
392
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
393
393
  *
394
- * @version 1.0.0
394
+ * @version 1.0.1
395
395
  * @author Yusuke Kamiyamane
396
396
  * @license MIT
397
397
  * @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 1.0.0
6
+ * @version 1.0.1
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 1.0.0
6
+ * @version 1.0.1
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -205,6 +205,19 @@ function createRovingTabIndex(container, options = {}) {
205
205
  if (!(container instanceof Element)) {
206
206
  throw new Error("Invalid container element");
207
207
  }
208
+ const { direction, selector, wrap = false } = options;
209
+ if (direction && !["horizontal", "vertical"].includes(direction)) {
210
+ console.warn("Invalid direction. Fallback: both (undefined).");
211
+ Object.assign(options, { direction: void 0 });
212
+ }
213
+ if (typeof selector !== "string") {
214
+ console.warn("Invalid selector. Fallback: all focusable elements.");
215
+ Object.assign(options, { selector: void 0 });
216
+ }
217
+ if (typeof wrap !== "boolean") {
218
+ console.warn("Invalid wrap. Fallback: false.");
219
+ Object.assign(options, { wrap: false });
220
+ }
208
221
  const roving = new RovingTabIndex(container, options);
209
222
  return () => roving.destroy();
210
223
  }
@@ -219,19 +232,6 @@ var RovingTabIndex = class {
219
232
  constructor(container, options = {}) {
220
233
  this.#container = container;
221
234
  this.#options = options;
222
- const { direction, selector, wrap = false } = this.#options;
223
- if (direction && !["horizontal", "vertical"].includes(direction)) {
224
- console.warn("Invalid direction. Fallback: both (undefined).");
225
- Object.assign(this.#options, { direction: void 0 });
226
- }
227
- if (typeof selector !== "string") {
228
- console.warn("Invalid selector. Fallback: all focusable elements.");
229
- Object.assign(this.#options, { selector: void 0 });
230
- }
231
- if (typeof wrap !== "boolean") {
232
- console.warn("Invalid wrap. Fallback: false.");
233
- Object.assign(this.#options, { wrap: false });
234
- }
235
235
  this.#selectorFilter = this.#createSelectorFilter();
236
236
  this.#initialize();
237
237
  }
@@ -364,7 +364,7 @@ var RovingTabIndex = class {
364
364
  }
365
365
  #createSelectorFilter() {
366
366
  const { selector } = this.#options;
367
- return (element) => !selector || element.matches(selector);
367
+ return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
368
368
  }
369
369
  #getFocusables() {
370
370
  return getFocusables(this.#container, {
@@ -389,7 +389,7 @@ function getActiveElement() {
389
389
  * Lightweight roving tabindex utility with fully focus management.
390
390
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
391
391
  *
392
- * @version 1.0.0
392
+ * @version 1.0.1
393
393
  * @author Yusuke Kamiyamane
394
394
  * @license MIT
395
395
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",