@y14e/tabs 1.3.8 → 1.3.10

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
@@ -327,6 +327,7 @@ var Tabs = class _Tabs {
327
327
  restoreAttributes([
328
328
  ...this.#listElements,
329
329
  ...this.#tabElements,
330
+ ...this.#indicatorElements,
330
331
  ...this.#panelElements
331
332
  ]);
332
333
  this.#listElements.length = 0;
@@ -341,7 +342,8 @@ var Tabs = class _Tabs {
341
342
  saveAttributes(this.#listElements, [
342
343
  "aria-hidden",
343
344
  "aria-orientation",
344
- "role"
345
+ "role",
346
+ "style"
345
347
  ]);
346
348
  this.#listElements.forEach((list, i) => {
347
349
  if (this.#settings.avoidDuplicates && i) {
@@ -354,8 +356,10 @@ var Tabs = class _Tabs {
354
356
  });
355
357
  saveAttributes(this.#tabElements, [
356
358
  "aria-controls",
359
+ "aria-selected",
357
360
  "id",
358
361
  "role",
362
+ "style",
359
363
  "tabindex"
360
364
  ]);
361
365
  this.#tabElements.forEach((tab, i) => {
@@ -389,9 +393,10 @@ var Tabs = class _Tabs {
389
393
  }
390
394
  addTokenToAttribute(panel, "aria-labelledby", tab.id);
391
395
  tab.addEventListener("click", this.#onTabClick, { signal });
392
- tab.addEventListener("focusin", this.#onTabFocusIn, { signal });
396
+ tab.addEventListener("focus", this.#onTabFocus, { signal });
393
397
  tab.addEventListener("keydown", this.#onTabKeyDown, { signal });
394
398
  });
399
+ saveAttributes(this.#indicatorElements, ["style"]);
395
400
  this.#indicatorElements.forEach((indicator) => {
396
401
  indicator.closest(this.#settings.selector.list)?.style.setProperty("position", "relative");
397
402
  const { style } = indicator;
@@ -418,15 +423,12 @@ var Tabs = class _Tabs {
418
423
  }
419
424
  this.activate(tab);
420
425
  };
421
- #onTabFocusIn = (event) => {
426
+ #onTabFocus = (event) => {
422
427
  const tab = event.currentTarget;
423
428
  if (!(tab instanceof HTMLElement)) {
424
429
  return;
425
430
  }
426
- if (this.#isAvoidedTab(tab)) {
427
- const active = getActiveElement();
428
- active && "blur" in active && typeof active.blur === "function" && active.blur();
429
- }
431
+ this.#isAvoidedTab(tab) && tab.blur();
430
432
  };
431
433
  #onTabKeyDown = (event) => {
432
434
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -641,7 +643,7 @@ function isFocusable(element) {
641
643
  * Tabs
642
644
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
643
645
  *
644
- * @version 1.3.8
646
+ * @version 1.3.10
645
647
  * @author Yusuke Kamiyamane
646
648
  * @license MIT
647
649
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Tabs
3
3
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.3.8
5
+ * @version 1.3.10
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Tabs
3
3
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.3.8
5
+ * @version 1.3.10
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -325,6 +325,7 @@ var Tabs = class _Tabs {
325
325
  restoreAttributes([
326
326
  ...this.#listElements,
327
327
  ...this.#tabElements,
328
+ ...this.#indicatorElements,
328
329
  ...this.#panelElements
329
330
  ]);
330
331
  this.#listElements.length = 0;
@@ -339,7 +340,8 @@ var Tabs = class _Tabs {
339
340
  saveAttributes(this.#listElements, [
340
341
  "aria-hidden",
341
342
  "aria-orientation",
342
- "role"
343
+ "role",
344
+ "style"
343
345
  ]);
344
346
  this.#listElements.forEach((list, i) => {
345
347
  if (this.#settings.avoidDuplicates && i) {
@@ -352,8 +354,10 @@ var Tabs = class _Tabs {
352
354
  });
353
355
  saveAttributes(this.#tabElements, [
354
356
  "aria-controls",
357
+ "aria-selected",
355
358
  "id",
356
359
  "role",
360
+ "style",
357
361
  "tabindex"
358
362
  ]);
359
363
  this.#tabElements.forEach((tab, i) => {
@@ -387,9 +391,10 @@ var Tabs = class _Tabs {
387
391
  }
388
392
  addTokenToAttribute(panel, "aria-labelledby", tab.id);
389
393
  tab.addEventListener("click", this.#onTabClick, { signal });
390
- tab.addEventListener("focusin", this.#onTabFocusIn, { signal });
394
+ tab.addEventListener("focus", this.#onTabFocus, { signal });
391
395
  tab.addEventListener("keydown", this.#onTabKeyDown, { signal });
392
396
  });
397
+ saveAttributes(this.#indicatorElements, ["style"]);
393
398
  this.#indicatorElements.forEach((indicator) => {
394
399
  indicator.closest(this.#settings.selector.list)?.style.setProperty("position", "relative");
395
400
  const { style } = indicator;
@@ -416,15 +421,12 @@ var Tabs = class _Tabs {
416
421
  }
417
422
  this.activate(tab);
418
423
  };
419
- #onTabFocusIn = (event) => {
424
+ #onTabFocus = (event) => {
420
425
  const tab = event.currentTarget;
421
426
  if (!(tab instanceof HTMLElement)) {
422
427
  return;
423
428
  }
424
- if (this.#isAvoidedTab(tab)) {
425
- const active = getActiveElement();
426
- active && "blur" in active && typeof active.blur === "function" && active.blur();
427
- }
429
+ this.#isAvoidedTab(tab) && tab.blur();
428
430
  };
429
431
  #onTabKeyDown = (event) => {
430
432
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -639,7 +641,7 @@ function isFocusable(element) {
639
641
  * Tabs
640
642
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
641
643
  *
642
- * @version 1.3.8
644
+ * @version 1.3.10
643
645
  * @author Yusuke Kamiyamane
644
646
  * @license MIT
645
647
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/tabs",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "WAI-ARIA compliant tabs pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",