@y14e/disclosure 1.3.11 → 1.3.13

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
@@ -10,14 +10,14 @@ npm i @y14e/disclosure
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import Disclosure from '@y14e/disclosure@1.3.11';
13
+ import Disclosure from '@y14e/disclosure@1.3.13';
14
14
 
15
15
  // CDNs
16
- import Disclosure from 'https://esm.sh/@y14e/disclosure@1.3.11';
16
+ import Disclosure from 'https://esm.sh/@y14e/disclosure@1.3.13';
17
17
  // or
18
- import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@1.3.11/+esm';
18
+ import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@1.3.13/+esm';
19
19
  // or
20
- import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@1.3.11';
20
+ import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@1.3.13';
21
21
  ```
22
22
 
23
23
  ## Usage
package/dist/index.cjs CHANGED
@@ -494,11 +494,11 @@ var RovingTabIndex = class {
494
494
  if (!typeahead) {
495
495
  continue;
496
496
  }
497
+ const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
497
498
  const value = focusable.ariaKeyShortcuts?.trim();
498
499
  const keys = new Set(
499
500
  value ? value.split(/\s+/).filter((key) => /^\S$/i.test(key)).map((key) => key.toUpperCase()) : []
500
501
  );
501
- const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
502
502
  if (char) {
503
503
  keys.add(char);
504
504
  saveAttributes2([focusable], ["aria-keyshortcuts"]);
@@ -611,13 +611,12 @@ var Disclosure = class _Disclosure {
611
611
  this.#detailsElements.forEach((details, i) => {
612
612
  const summary = this.#summaryElements[i];
613
613
  const content = this.#contentElements[i];
614
- if (!summary || !content) {
615
- return;
614
+ if (summary && content) {
615
+ const binding = createBinding(details, summary, content);
616
+ this.#bindings.set(details, binding);
617
+ this.#bindings.set(summary, binding);
618
+ this.#bindings.set(content, binding);
616
619
  }
617
- const binding = createBinding(details, summary, content);
618
- this.#bindings.set(details, binding);
619
- this.#bindings.set(summary, binding);
620
- this.#bindings.set(content, binding);
621
620
  });
622
621
  this.#initialize();
623
622
  }
@@ -625,11 +624,11 @@ var Disclosure = class _Disclosure {
625
624
  if (this.#isDestroyed) {
626
625
  return;
627
626
  }
628
- if (!(details instanceof HTMLDetailsElement) || !this.#bindings.has(details)) {
627
+ if (!(details instanceof HTMLDetailsElement)) {
629
628
  console.warn("Invalid <details> element");
630
629
  return;
631
630
  }
632
- this.#toggle(details, false);
631
+ this.#bindings.has(details) && this.#toggle(details, false);
633
632
  }
634
633
  async destroy(force = false) {
635
634
  if (this.#isDestroyed) {
@@ -666,11 +665,11 @@ var Disclosure = class _Disclosure {
666
665
  if (this.#isDestroyed) {
667
666
  return;
668
667
  }
669
- if (!(details instanceof HTMLDetailsElement) || !this.#bindings.has(details)) {
668
+ if (!(details instanceof HTMLDetailsElement)) {
670
669
  console.warn("Invalid <details> element");
671
670
  return;
672
671
  }
673
- this.#toggle(details, true);
672
+ this.#bindings.has(details) && this.#toggle(details, true);
674
673
  }
675
674
  #initialize() {
676
675
  saveAttributes(this.#summaryElements, [
@@ -817,17 +816,18 @@ function isFocusable2(element) {
817
816
  function waitAnimationFinish(animation) {
818
817
  if (["idle", "finished"].includes(animation.playState)) {
819
818
  return Promise.resolve();
819
+ } else {
820
+ return new Promise(
821
+ (resolve) => animation.addEventListener("finish", () => resolve(), { once: true })
822
+ );
820
823
  }
821
- return new Promise(
822
- (resolve) => animation.addEventListener("finish", () => resolve(), { once: true })
823
- );
824
824
  }
825
825
  /**
826
826
  * Disclosure
827
827
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
828
828
  * Using the <details> and <summary> element.
829
829
  *
830
- * @version 1.3.11
830
+ * @version 1.3.13
831
831
  * @author Yusuke Kamiyamane
832
832
  * @license MIT
833
833
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -852,7 +852,7 @@ function waitAnimationFinish(animation) {
852
852
  * Lightweight roving tabindex utility with fully focus management.
853
853
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
854
854
  *
855
- * @version 3.0.2
855
+ * @version 3.0.5
856
856
  * @author Yusuke Kamiyamane
857
857
  * @license MIT
858
858
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
4
4
  * Using the <details> and <summary> element.
5
5
  *
6
- * @version 1.3.11
6
+ * @version 1.3.13
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
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
4
4
  * Using the <details> and <summary> element.
5
5
  *
6
- * @version 1.3.11
6
+ * @version 1.3.13
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -492,11 +492,11 @@ var RovingTabIndex = class {
492
492
  if (!typeahead) {
493
493
  continue;
494
494
  }
495
+ const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
495
496
  const value = focusable.ariaKeyShortcuts?.trim();
496
497
  const keys = new Set(
497
498
  value ? value.split(/\s+/).filter((key) => /^\S$/i.test(key)).map((key) => key.toUpperCase()) : []
498
499
  );
499
- const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
500
500
  if (char) {
501
501
  keys.add(char);
502
502
  saveAttributes2([focusable], ["aria-keyshortcuts"]);
@@ -609,13 +609,12 @@ var Disclosure = class _Disclosure {
609
609
  this.#detailsElements.forEach((details, i) => {
610
610
  const summary = this.#summaryElements[i];
611
611
  const content = this.#contentElements[i];
612
- if (!summary || !content) {
613
- return;
612
+ if (summary && content) {
613
+ const binding = createBinding(details, summary, content);
614
+ this.#bindings.set(details, binding);
615
+ this.#bindings.set(summary, binding);
616
+ this.#bindings.set(content, binding);
614
617
  }
615
- const binding = createBinding(details, summary, content);
616
- this.#bindings.set(details, binding);
617
- this.#bindings.set(summary, binding);
618
- this.#bindings.set(content, binding);
619
618
  });
620
619
  this.#initialize();
621
620
  }
@@ -623,11 +622,11 @@ var Disclosure = class _Disclosure {
623
622
  if (this.#isDestroyed) {
624
623
  return;
625
624
  }
626
- if (!(details instanceof HTMLDetailsElement) || !this.#bindings.has(details)) {
625
+ if (!(details instanceof HTMLDetailsElement)) {
627
626
  console.warn("Invalid <details> element");
628
627
  return;
629
628
  }
630
- this.#toggle(details, false);
629
+ this.#bindings.has(details) && this.#toggle(details, false);
631
630
  }
632
631
  async destroy(force = false) {
633
632
  if (this.#isDestroyed) {
@@ -664,11 +663,11 @@ var Disclosure = class _Disclosure {
664
663
  if (this.#isDestroyed) {
665
664
  return;
666
665
  }
667
- if (!(details instanceof HTMLDetailsElement) || !this.#bindings.has(details)) {
666
+ if (!(details instanceof HTMLDetailsElement)) {
668
667
  console.warn("Invalid <details> element");
669
668
  return;
670
669
  }
671
- this.#toggle(details, true);
670
+ this.#bindings.has(details) && this.#toggle(details, true);
672
671
  }
673
672
  #initialize() {
674
673
  saveAttributes(this.#summaryElements, [
@@ -815,17 +814,18 @@ function isFocusable2(element) {
815
814
  function waitAnimationFinish(animation) {
816
815
  if (["idle", "finished"].includes(animation.playState)) {
817
816
  return Promise.resolve();
817
+ } else {
818
+ return new Promise(
819
+ (resolve) => animation.addEventListener("finish", () => resolve(), { once: true })
820
+ );
818
821
  }
819
- return new Promise(
820
- (resolve) => animation.addEventListener("finish", () => resolve(), { once: true })
821
- );
822
822
  }
823
823
  /**
824
824
  * Disclosure
825
825
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
826
826
  * Using the <details> and <summary> element.
827
827
  *
828
- * @version 1.3.11
828
+ * @version 1.3.13
829
829
  * @author Yusuke Kamiyamane
830
830
  * @license MIT
831
831
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -850,7 +850,7 @@ function waitAnimationFinish(animation) {
850
850
  * Lightweight roving tabindex utility with fully focus management.
851
851
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
852
852
  *
853
- * @version 3.0.2
853
+ * @version 3.0.5
854
854
  * @author Yusuke Kamiyamane
855
855
  * @license MIT
856
856
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/disclosure",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "homepage": "https://github.com/y14e/disclosure#readme",
45
45
  "devDependencies": {
46
46
  "@y14e/attributes-utils": "^1.1.2",
47
- "@y14e/roving-tabindex": "^3.0.2",
47
+ "@y14e/roving-tabindex": "^3.0.5",
48
48
  "bun-types": "latest",
49
49
  "tsup": "^8.0.0",
50
50
  "typescript": "^5.6.0",