@y14e/accordion 1.4.11 → 1.4.12
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 +4 -4
- package/dist/index.cjs +18 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -11
- package/package.json +1 -1
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.
|
|
13
|
+
import Accordion from '@y14e/accordion@1.4.12';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import Accordion from 'https://esm.sh/@y14e/accordion@1.4.
|
|
16
|
+
import Accordion from 'https://esm.sh/@y14e/accordion@1.4.12';
|
|
17
17
|
// or
|
|
18
|
-
import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.
|
|
18
|
+
import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.12/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.
|
|
20
|
+
import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.12';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -680,11 +680,12 @@ var Accordion = class _Accordion {
|
|
|
680
680
|
}
|
|
681
681
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
682
682
|
const content2 = this.#contentElements[i];
|
|
683
|
-
if (content2) {
|
|
684
|
-
|
|
685
|
-
this.#bindings.set(trigger2, binding);
|
|
686
|
-
this.#bindings.set(content2, binding);
|
|
683
|
+
if (!content2) {
|
|
684
|
+
return;
|
|
687
685
|
}
|
|
686
|
+
const binding = createBinding(trigger2, content2);
|
|
687
|
+
this.#bindings.set(trigger2, binding);
|
|
688
|
+
this.#bindings.set(content2, binding);
|
|
688
689
|
});
|
|
689
690
|
this.#initialize();
|
|
690
691
|
}
|
|
@@ -692,11 +693,11 @@ var Accordion = class _Accordion {
|
|
|
692
693
|
if (this.#isDestroyed) {
|
|
693
694
|
return;
|
|
694
695
|
}
|
|
695
|
-
if (!(trigger instanceof HTMLElement)) {
|
|
696
|
+
if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
|
|
696
697
|
console.warn("Invalid trigger element");
|
|
697
698
|
return;
|
|
698
699
|
}
|
|
699
|
-
this.#
|
|
700
|
+
this.#toggle(trigger, false);
|
|
700
701
|
}
|
|
701
702
|
async destroy(force = false) {
|
|
702
703
|
if (this.#isDestroyed) {
|
|
@@ -727,11 +728,11 @@ var Accordion = class _Accordion {
|
|
|
727
728
|
if (this.#isDestroyed) {
|
|
728
729
|
return;
|
|
729
730
|
}
|
|
730
|
-
if (!(trigger instanceof HTMLElement)) {
|
|
731
|
+
if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
|
|
731
732
|
console.warn("Invalid trigger element");
|
|
732
733
|
return;
|
|
733
734
|
}
|
|
734
|
-
this.#
|
|
735
|
+
this.#toggle(trigger, true);
|
|
735
736
|
}
|
|
736
737
|
#initialize() {
|
|
737
738
|
saveAttributes(this.#triggerElements, [
|
|
@@ -793,7 +794,10 @@ var Accordion = class _Accordion {
|
|
|
793
794
|
return;
|
|
794
795
|
}
|
|
795
796
|
const binding = this.#bindings.get(content);
|
|
796
|
-
|
|
797
|
+
if (!binding) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
|
|
797
801
|
};
|
|
798
802
|
#toggle(trigger, isOpen, isMatch = false) {
|
|
799
803
|
if (trigger.ariaExpanded === String(isOpen)) {
|
|
@@ -858,7 +862,10 @@ var Accordion = class _Accordion {
|
|
|
858
862
|
}
|
|
859
863
|
#onAnimationFinish(content) {
|
|
860
864
|
const trigger = this.#bindings.get(content)?.trigger;
|
|
861
|
-
if (trigger
|
|
865
|
+
if (!trigger) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (trigger.ariaExpanded === "false") {
|
|
862
869
|
content.setAttribute("hidden", "until-found");
|
|
863
870
|
}
|
|
864
871
|
["block-size", "overflow"].forEach((name) => {
|
|
@@ -893,7 +900,7 @@ function waitAnimationFinish(animation) {
|
|
|
893
900
|
* Accordion
|
|
894
901
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
895
902
|
*
|
|
896
|
-
* @version 1.4.
|
|
903
|
+
* @version 1.4.12
|
|
897
904
|
* @author Yusuke Kamiyamane
|
|
898
905
|
* @license MIT
|
|
899
906
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -678,11 +678,12 @@ var Accordion = class _Accordion {
|
|
|
678
678
|
}
|
|
679
679
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
680
680
|
const content2 = this.#contentElements[i];
|
|
681
|
-
if (content2) {
|
|
682
|
-
|
|
683
|
-
this.#bindings.set(trigger2, binding);
|
|
684
|
-
this.#bindings.set(content2, binding);
|
|
681
|
+
if (!content2) {
|
|
682
|
+
return;
|
|
685
683
|
}
|
|
684
|
+
const binding = createBinding(trigger2, content2);
|
|
685
|
+
this.#bindings.set(trigger2, binding);
|
|
686
|
+
this.#bindings.set(content2, binding);
|
|
686
687
|
});
|
|
687
688
|
this.#initialize();
|
|
688
689
|
}
|
|
@@ -690,11 +691,11 @@ var Accordion = class _Accordion {
|
|
|
690
691
|
if (this.#isDestroyed) {
|
|
691
692
|
return;
|
|
692
693
|
}
|
|
693
|
-
if (!(trigger instanceof HTMLElement)) {
|
|
694
|
+
if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
|
|
694
695
|
console.warn("Invalid trigger element");
|
|
695
696
|
return;
|
|
696
697
|
}
|
|
697
|
-
this.#
|
|
698
|
+
this.#toggle(trigger, false);
|
|
698
699
|
}
|
|
699
700
|
async destroy(force = false) {
|
|
700
701
|
if (this.#isDestroyed) {
|
|
@@ -725,11 +726,11 @@ var Accordion = class _Accordion {
|
|
|
725
726
|
if (this.#isDestroyed) {
|
|
726
727
|
return;
|
|
727
728
|
}
|
|
728
|
-
if (!(trigger instanceof HTMLElement)) {
|
|
729
|
+
if (!(trigger instanceof HTMLElement) || !this.#bindings.has(trigger)) {
|
|
729
730
|
console.warn("Invalid trigger element");
|
|
730
731
|
return;
|
|
731
732
|
}
|
|
732
|
-
this.#
|
|
733
|
+
this.#toggle(trigger, true);
|
|
733
734
|
}
|
|
734
735
|
#initialize() {
|
|
735
736
|
saveAttributes(this.#triggerElements, [
|
|
@@ -791,7 +792,10 @@ var Accordion = class _Accordion {
|
|
|
791
792
|
return;
|
|
792
793
|
}
|
|
793
794
|
const binding = this.#bindings.get(content);
|
|
794
|
-
|
|
795
|
+
if (!binding) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
|
|
795
799
|
};
|
|
796
800
|
#toggle(trigger, isOpen, isMatch = false) {
|
|
797
801
|
if (trigger.ariaExpanded === String(isOpen)) {
|
|
@@ -856,7 +860,10 @@ var Accordion = class _Accordion {
|
|
|
856
860
|
}
|
|
857
861
|
#onAnimationFinish(content) {
|
|
858
862
|
const trigger = this.#bindings.get(content)?.trigger;
|
|
859
|
-
if (trigger
|
|
863
|
+
if (!trigger) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
if (trigger.ariaExpanded === "false") {
|
|
860
867
|
content.setAttribute("hidden", "until-found");
|
|
861
868
|
}
|
|
862
869
|
["block-size", "overflow"].forEach((name) => {
|
|
@@ -891,7 +898,7 @@ function waitAnimationFinish(animation) {
|
|
|
891
898
|
* Accordion
|
|
892
899
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
893
900
|
*
|
|
894
|
-
* @version 1.4.
|
|
901
|
+
* @version 1.4.12
|
|
895
902
|
* @author Yusuke Kamiyamane
|
|
896
903
|
* @license MIT
|
|
897
904
|
* @copyright Copyright (c) Yusuke Kamiyamane
|