@y14e/tabs 1.3.7 → 1.3.8

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
@@ -389,6 +389,7 @@ var Tabs = class _Tabs {
389
389
  }
390
390
  addTokenToAttribute(panel, "aria-labelledby", tab.id);
391
391
  tab.addEventListener("click", this.#onTabClick, { signal });
392
+ tab.addEventListener("focusin", this.#onTabFocusIn, { signal });
392
393
  tab.addEventListener("keydown", this.#onTabKeyDown, { signal });
393
394
  });
394
395
  this.#indicatorElements.forEach((indicator) => {
@@ -417,6 +418,16 @@ var Tabs = class _Tabs {
417
418
  }
418
419
  this.activate(tab);
419
420
  };
421
+ #onTabFocusIn = (event) => {
422
+ const tab = event.currentTarget;
423
+ if (!(tab instanceof HTMLElement)) {
424
+ return;
425
+ }
426
+ if (this.#isAvoidedTab(tab)) {
427
+ const active = getActiveElement();
428
+ active && "blur" in active && typeof active.blur === "function" && active.blur();
429
+ }
430
+ };
420
431
  #onTabKeyDown = (event) => {
421
432
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
422
433
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -630,7 +641,7 @@ function isFocusable(element) {
630
641
  * Tabs
631
642
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
632
643
  *
633
- * @version 1.3.7
644
+ * @version 1.3.8
634
645
  * @author Yusuke Kamiyamane
635
646
  * @license MIT
636
647
  * @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.7
5
+ * @version 1.3.8
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.7
5
+ * @version 1.3.8
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -387,6 +387,7 @@ var Tabs = class _Tabs {
387
387
  }
388
388
  addTokenToAttribute(panel, "aria-labelledby", tab.id);
389
389
  tab.addEventListener("click", this.#onTabClick, { signal });
390
+ tab.addEventListener("focusin", this.#onTabFocusIn, { signal });
390
391
  tab.addEventListener("keydown", this.#onTabKeyDown, { signal });
391
392
  });
392
393
  this.#indicatorElements.forEach((indicator) => {
@@ -415,6 +416,16 @@ var Tabs = class _Tabs {
415
416
  }
416
417
  this.activate(tab);
417
418
  };
419
+ #onTabFocusIn = (event) => {
420
+ const tab = event.currentTarget;
421
+ if (!(tab instanceof HTMLElement)) {
422
+ return;
423
+ }
424
+ if (this.#isAvoidedTab(tab)) {
425
+ const active = getActiveElement();
426
+ active && "blur" in active && typeof active.blur === "function" && active.blur();
427
+ }
428
+ };
418
429
  #onTabKeyDown = (event) => {
419
430
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
420
431
  if (altKey || ctrlKey || metaKey || shiftKey) {
@@ -628,7 +639,7 @@ function isFocusable(element) {
628
639
  * Tabs
629
640
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
630
641
  *
631
- * @version 1.3.7
642
+ * @version 1.3.8
632
643
  * @author Yusuke Kamiyamane
633
644
  * @license MIT
634
645
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/tabs",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "WAI-ARIA compliant tabs pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",