@y14e/tabs 1.5.1 → 1.5.2

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
@@ -165,6 +165,7 @@ function getFocusables(container = document.body, options = {}) {
165
165
  composed = false,
166
166
  filter,
167
167
  include,
168
+ skipNegativeTabIndexCheck = false,
168
169
  skipVisibilityCheck = false
169
170
  } = options;
170
171
  if (typeof composed !== "boolean") {
@@ -183,6 +184,10 @@ function getFocusables(container = document.body, options = {}) {
183
184
  );
184
185
  include = void 0;
185
186
  }
187
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
188
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
189
+ skipNegativeTabIndexCheck = false;
190
+ }
186
191
  if (typeof skipVisibilityCheck !== "boolean") {
187
192
  console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
188
193
  skipVisibilityCheck = false;
@@ -191,7 +196,10 @@ function getFocusables(container = document.body, options = {}) {
191
196
  if (composed || include) {
192
197
  let traverse2 = function(node) {
193
198
  if (node instanceof Element) {
194
- if (isFocusable(node, { skipVisibilityCheck }) || include?.(node)) {
199
+ if (isFocusable(node, {
200
+ skipNegativeTabIndexCheck,
201
+ skipVisibilityCheck
202
+ }) || include?.(node)) {
195
203
  elements[elements.length] = node;
196
204
  }
197
205
  }
@@ -212,7 +220,10 @@ function getFocusables(container = document.body, options = {}) {
212
220
  if (!(candidate instanceof Element)) {
213
221
  continue;
214
222
  }
215
- if (isFocusable(candidate, { skipVisibilityCheck })) {
223
+ if (isFocusable(candidate, {
224
+ skipNegativeTabIndexCheck,
225
+ skipVisibilityCheck
226
+ })) {
216
227
  elements[elements.length] = candidate;
217
228
  }
218
229
  }
@@ -225,7 +236,11 @@ function isFocusable(element, options = {}) {
225
236
  console.warn("Invalid element");
226
237
  return false;
227
238
  }
228
- let { skipVisibilityCheck = false } = options;
239
+ let { skipNegativeTabIndexCheck = false, skipVisibilityCheck = false } = options;
240
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
241
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
242
+ skipNegativeTabIndexCheck = false;
243
+ }
229
244
  if (typeof skipVisibilityCheck !== "boolean") {
230
245
  console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
231
246
  skipVisibilityCheck = false;
@@ -233,10 +248,12 @@ function isFocusable(element, options = {}) {
233
248
  if (element.hasAttribute("hidden") || isInert(element)) {
234
249
  return false;
235
250
  }
236
- if (getTabIndex(element) < 0) {
251
+ if (!skipNegativeTabIndexCheck && getTabIndex(element) < 0) {
237
252
  return false;
238
253
  }
239
- if (!element.matches(FOCUSABLE_SELECTOR)) {
254
+ if (!element.matches(
255
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR.replace(/(,\s*)?\[tabindex="-1"\]/g, "") : FOCUSABLE_SELECTOR
256
+ )) {
240
257
  return false;
241
258
  }
242
259
  if (isDisabledDeep(element)) {
@@ -386,7 +403,6 @@ function createRovingTabIndex(container, options = {}) {
386
403
  direction,
387
404
  navigationOnly = false,
388
405
  selector,
389
- skipVisibilityCheck = false,
390
406
  typeahead = false,
391
407
  wrap = false
392
408
  } = options;
@@ -404,10 +420,6 @@ function createRovingTabIndex(container, options = {}) {
404
420
  );
405
421
  selector = void 0;
406
422
  }
407
- if (typeof skipVisibilityCheck !== "boolean") {
408
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
409
- skipVisibilityCheck = false;
410
- }
411
423
  if (typeof typeahead !== "boolean") {
412
424
  console.warn("Invalid typeahead option. Fallback: false.");
413
425
  typeahead = false;
@@ -420,7 +432,6 @@ function createRovingTabIndex(container, options = {}) {
420
432
  direction,
421
433
  navigationOnly,
422
434
  selector,
423
- skipVisibilityCheck,
424
435
  typeahead,
425
436
  wrap
426
437
  });
@@ -534,7 +545,7 @@ var RovingTabIndex = class {
534
545
  ...getFocusables(this.#container, {
535
546
  composed: true,
536
547
  filter: this.#selectorFilter,
537
- skipVisibilityCheck: !!this.#options.skipVisibilityCheck
548
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly
538
549
  })
539
550
  ]);
540
551
  for (const focusable of this.#focusables) {
@@ -600,8 +611,7 @@ var RovingTabIndex = class {
600
611
  return getFocusables(this.#container, {
601
612
  composed: true,
602
613
  filter: this.#selectorFilter,
603
- include: (element) => this.#focusables.has(element),
604
- skipVisibilityCheck: !!this.#options.skipVisibilityCheck
614
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly
605
615
  });
606
616
  }
607
617
  };
@@ -969,7 +979,6 @@ var Tabs = class _Tabs {
969
979
  createRovingTabIndex(list, {
970
980
  direction: list.ariaOrientation === "undefined" ? void 0 : this.#settings.vertical ? "vertical" : "horizontal",
971
981
  selector: this.#settings.selector.tab,
972
- skipVisibilityCheck: true,
973
982
  wrap: true
974
983
  })
975
984
  );
@@ -1176,7 +1185,7 @@ function isFocusable2(element) {
1176
1185
  * Lightweight roving tabindex utility with fully focus management.
1177
1186
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
1178
1187
  *
1179
- * @version 1.3.2
1188
+ * @version 2.0.0
1180
1189
  * @author Yusuke Kamiyamane
1181
1190
  * @license MIT
1182
1191
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1201,7 +1210,7 @@ function isFocusable2(element) {
1201
1210
  * High-precision focus management utility with full composed tree support.
1202
1211
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
1203
1212
  *
1204
- * @version 4.2.1
1213
+ * @version 4.3.0
1205
1214
  * @author Yusuke Kamiyamane
1206
1215
  * @license MIT
1207
1216
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -163,6 +163,7 @@ function getFocusables(container = document.body, options = {}) {
163
163
  composed = false,
164
164
  filter,
165
165
  include,
166
+ skipNegativeTabIndexCheck = false,
166
167
  skipVisibilityCheck = false
167
168
  } = options;
168
169
  if (typeof composed !== "boolean") {
@@ -181,6 +182,10 @@ function getFocusables(container = document.body, options = {}) {
181
182
  );
182
183
  include = void 0;
183
184
  }
185
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
186
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
187
+ skipNegativeTabIndexCheck = false;
188
+ }
184
189
  if (typeof skipVisibilityCheck !== "boolean") {
185
190
  console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
186
191
  skipVisibilityCheck = false;
@@ -189,7 +194,10 @@ function getFocusables(container = document.body, options = {}) {
189
194
  if (composed || include) {
190
195
  let traverse2 = function(node) {
191
196
  if (node instanceof Element) {
192
- if (isFocusable(node, { skipVisibilityCheck }) || include?.(node)) {
197
+ if (isFocusable(node, {
198
+ skipNegativeTabIndexCheck,
199
+ skipVisibilityCheck
200
+ }) || include?.(node)) {
193
201
  elements[elements.length] = node;
194
202
  }
195
203
  }
@@ -210,7 +218,10 @@ function getFocusables(container = document.body, options = {}) {
210
218
  if (!(candidate instanceof Element)) {
211
219
  continue;
212
220
  }
213
- if (isFocusable(candidate, { skipVisibilityCheck })) {
221
+ if (isFocusable(candidate, {
222
+ skipNegativeTabIndexCheck,
223
+ skipVisibilityCheck
224
+ })) {
214
225
  elements[elements.length] = candidate;
215
226
  }
216
227
  }
@@ -223,7 +234,11 @@ function isFocusable(element, options = {}) {
223
234
  console.warn("Invalid element");
224
235
  return false;
225
236
  }
226
- let { skipVisibilityCheck = false } = options;
237
+ let { skipNegativeTabIndexCheck = false, skipVisibilityCheck = false } = options;
238
+ if (typeof skipNegativeTabIndexCheck !== "boolean") {
239
+ console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
240
+ skipNegativeTabIndexCheck = false;
241
+ }
227
242
  if (typeof skipVisibilityCheck !== "boolean") {
228
243
  console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
229
244
  skipVisibilityCheck = false;
@@ -231,10 +246,12 @@ function isFocusable(element, options = {}) {
231
246
  if (element.hasAttribute("hidden") || isInert(element)) {
232
247
  return false;
233
248
  }
234
- if (getTabIndex(element) < 0) {
249
+ if (!skipNegativeTabIndexCheck && getTabIndex(element) < 0) {
235
250
  return false;
236
251
  }
237
- if (!element.matches(FOCUSABLE_SELECTOR)) {
252
+ if (!element.matches(
253
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR.replace(/(,\s*)?\[tabindex="-1"\]/g, "") : FOCUSABLE_SELECTOR
254
+ )) {
238
255
  return false;
239
256
  }
240
257
  if (isDisabledDeep(element)) {
@@ -384,7 +401,6 @@ function createRovingTabIndex(container, options = {}) {
384
401
  direction,
385
402
  navigationOnly = false,
386
403
  selector,
387
- skipVisibilityCheck = false,
388
404
  typeahead = false,
389
405
  wrap = false
390
406
  } = options;
@@ -402,10 +418,6 @@ function createRovingTabIndex(container, options = {}) {
402
418
  );
403
419
  selector = void 0;
404
420
  }
405
- if (typeof skipVisibilityCheck !== "boolean") {
406
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
407
- skipVisibilityCheck = false;
408
- }
409
421
  if (typeof typeahead !== "boolean") {
410
422
  console.warn("Invalid typeahead option. Fallback: false.");
411
423
  typeahead = false;
@@ -418,7 +430,6 @@ function createRovingTabIndex(container, options = {}) {
418
430
  direction,
419
431
  navigationOnly,
420
432
  selector,
421
- skipVisibilityCheck,
422
433
  typeahead,
423
434
  wrap
424
435
  });
@@ -532,7 +543,7 @@ var RovingTabIndex = class {
532
543
  ...getFocusables(this.#container, {
533
544
  composed: true,
534
545
  filter: this.#selectorFilter,
535
- skipVisibilityCheck: !!this.#options.skipVisibilityCheck
546
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly
536
547
  })
537
548
  ]);
538
549
  for (const focusable of this.#focusables) {
@@ -598,8 +609,7 @@ var RovingTabIndex = class {
598
609
  return getFocusables(this.#container, {
599
610
  composed: true,
600
611
  filter: this.#selectorFilter,
601
- include: (element) => this.#focusables.has(element),
602
- skipVisibilityCheck: !!this.#options.skipVisibilityCheck
612
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly
603
613
  });
604
614
  }
605
615
  };
@@ -967,7 +977,6 @@ var Tabs = class _Tabs {
967
977
  createRovingTabIndex(list, {
968
978
  direction: list.ariaOrientation === "undefined" ? void 0 : this.#settings.vertical ? "vertical" : "horizontal",
969
979
  selector: this.#settings.selector.tab,
970
- skipVisibilityCheck: true,
971
980
  wrap: true
972
981
  })
973
982
  );
@@ -1174,7 +1183,7 @@ function isFocusable2(element) {
1174
1183
  * Lightweight roving tabindex utility with fully focus management.
1175
1184
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
1176
1185
  *
1177
- * @version 1.3.2
1186
+ * @version 2.0.0
1178
1187
  * @author Yusuke Kamiyamane
1179
1188
  * @license MIT
1180
1189
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1199,7 +1208,7 @@ function isFocusable2(element) {
1199
1208
  * High-precision focus management utility with full composed tree support.
1200
1209
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
1201
1210
  *
1202
- * @version 4.2.1
1211
+ * @version 4.3.0
1203
1212
  * @author Yusuke Kamiyamane
1204
1213
  * @license MIT
1205
1214
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/tabs",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "WAI-ARIA compliant tabs pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "devDependencies": {
45
45
  "@y14e/attributes-utils": "^1.0.5",
46
46
  "@y14e/button": "^1.0.0",
47
- "@y14e/roving-tabindex": "^1.3.2",
47
+ "@y14e/roving-tabindex": "^2.0.0",
48
48
  "bun-types": "latest",
49
49
  "tsup": "^8.0.0",
50
50
  "typescript": "^5.6.0",