@y14e/accordion 1.4.4 → 1.4.6

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/accordion
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import Accordion from '@y14e/accordion@1.4.4';
13
+ import Accordion from '@y14e/accordion@1.4.6';
14
14
 
15
15
  // CDNs
16
- import Accordion from 'https://esm.sh/@y14e/accordion@1.4.4';
16
+ import Accordion from 'https://esm.sh/@y14e/accordion@1.4.6';
17
17
  // or
18
- import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.4/+esm';
18
+ import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.6/+esm';
19
19
  // or
20
- import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.4';
20
+ import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.6';
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -68,15 +68,6 @@ new Accordion(root);
68
68
 
69
69
  ## 📦 APIs
70
70
 
71
- ### `open`
72
-
73
- ```ts
74
- accordion.open(trigger);
75
- // => void
76
- //
77
- // trigger: HTMLElement
78
- ```
79
-
80
71
  ### `close`
81
72
 
82
73
  ```ts
@@ -97,6 +88,15 @@ accordion.destroy(force);
97
88
  // force (optional): If true, skips waiting for animations to finish.
98
89
  ```
99
90
 
91
+ ### `open`
92
+
93
+ ```ts
94
+ accordion.open(trigger);
95
+ // => void
96
+ //
97
+ // trigger: HTMLElement
98
+ ```
99
+
100
100
  ## Demo
101
101
 
102
102
  https://y14e.github.io/accordion/
package/dist/index.cjs CHANGED
@@ -683,16 +683,6 @@ var Accordion = class _Accordion {
683
683
  });
684
684
  this.#initialize();
685
685
  }
686
- open(trigger) {
687
- if (this.#isDestroyed) {
688
- return;
689
- }
690
- if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
691
- console.warn("Invalid trigger element");
692
- return;
693
- }
694
- this.#toggle(trigger, true);
695
- }
696
686
  close(trigger) {
697
687
  if (this.#isDestroyed) {
698
688
  return;
@@ -728,6 +718,16 @@ var Accordion = class _Accordion {
728
718
  this.#contentElements.length = 0;
729
719
  this.#rootElement.removeAttribute("data-accordion-initialized");
730
720
  }
721
+ open(trigger) {
722
+ if (this.#isDestroyed) {
723
+ return;
724
+ }
725
+ if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
726
+ console.warn("Invalid trigger element");
727
+ return;
728
+ }
729
+ this.#toggle(trigger, true);
730
+ }
731
731
  #initialize() {
732
732
  saveAttributes(this.#triggerElements, [
733
733
  "aria-controls",
@@ -749,7 +749,7 @@ var Accordion = class _Accordion {
749
749
  addTokenToAttribute(trigger2, "aria-controls", content2.id);
750
750
  trigger2.setAttribute(
751
751
  "aria-expanded",
752
- trigger2.ariaExpanded === "true" ? "true" : "false"
752
+ String(trigger2.ariaExpanded === "true")
753
753
  );
754
754
  trigger2.id ||= `accordion-trigger-${id}`;
755
755
  if (!isFocusable2(trigger2)) {
@@ -840,6 +840,9 @@ var Accordion = class _Accordion {
840
840
  animation.addEventListener(
841
841
  "finish",
842
842
  () => {
843
+ if (binding?.animation !== animation) {
844
+ return;
845
+ }
843
846
  this.#onAnimationFinish(content);
844
847
  cleanup();
845
848
  },
@@ -892,7 +895,7 @@ function waitAnimationFinish(animation) {
892
895
  * Accordion
893
896
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
894
897
  *
895
- * @version 1.4.4
898
+ * @version 1.4.6
896
899
  * @author Yusuke Kamiyamane
897
900
  * @license MIT
898
901
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.4.4
5
+ * @version 1.4.6
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -22,9 +22,9 @@ declare class Accordion {
22
22
  #private;
23
23
  static defaults: AccordionOptions;
24
24
  constructor(root: HTMLElement, options?: AccordionOptions);
25
- open(trigger: HTMLElement): void;
26
25
  close(trigger: HTMLElement): void;
27
26
  destroy(force?: boolean): Promise<void>;
27
+ open(trigger: HTMLElement): void;
28
28
  }
29
29
 
30
30
  export { type AccordionOptions, Accordion as default };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.4.4
5
+ * @version 1.4.6
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -22,9 +22,9 @@ declare class Accordion {
22
22
  #private;
23
23
  static defaults: AccordionOptions;
24
24
  constructor(root: HTMLElement, options?: AccordionOptions);
25
- open(trigger: HTMLElement): void;
26
25
  close(trigger: HTMLElement): void;
27
26
  destroy(force?: boolean): Promise<void>;
27
+ open(trigger: HTMLElement): void;
28
28
  }
29
29
 
30
30
  export { type AccordionOptions, Accordion as default };
package/dist/index.js CHANGED
@@ -681,16 +681,6 @@ var Accordion = class _Accordion {
681
681
  });
682
682
  this.#initialize();
683
683
  }
684
- open(trigger) {
685
- if (this.#isDestroyed) {
686
- return;
687
- }
688
- if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
689
- console.warn("Invalid trigger element");
690
- return;
691
- }
692
- this.#toggle(trigger, true);
693
- }
694
684
  close(trigger) {
695
685
  if (this.#isDestroyed) {
696
686
  return;
@@ -726,6 +716,16 @@ var Accordion = class _Accordion {
726
716
  this.#contentElements.length = 0;
727
717
  this.#rootElement.removeAttribute("data-accordion-initialized");
728
718
  }
719
+ open(trigger) {
720
+ if (this.#isDestroyed) {
721
+ return;
722
+ }
723
+ if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
724
+ console.warn("Invalid trigger element");
725
+ return;
726
+ }
727
+ this.#toggle(trigger, true);
728
+ }
729
729
  #initialize() {
730
730
  saveAttributes(this.#triggerElements, [
731
731
  "aria-controls",
@@ -747,7 +747,7 @@ var Accordion = class _Accordion {
747
747
  addTokenToAttribute(trigger2, "aria-controls", content2.id);
748
748
  trigger2.setAttribute(
749
749
  "aria-expanded",
750
- trigger2.ariaExpanded === "true" ? "true" : "false"
750
+ String(trigger2.ariaExpanded === "true")
751
751
  );
752
752
  trigger2.id ||= `accordion-trigger-${id}`;
753
753
  if (!isFocusable2(trigger2)) {
@@ -838,6 +838,9 @@ var Accordion = class _Accordion {
838
838
  animation.addEventListener(
839
839
  "finish",
840
840
  () => {
841
+ if (binding?.animation !== animation) {
842
+ return;
843
+ }
841
844
  this.#onAnimationFinish(content);
842
845
  cleanup();
843
846
  },
@@ -890,7 +893,7 @@ function waitAnimationFinish(animation) {
890
893
  * Accordion
891
894
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
892
895
  *
893
- * @version 1.4.4
896
+ * @version 1.4.6
894
897
  * @author Yusuke Kamiyamane
895
898
  * @license MIT
896
899
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",