@y14e/accordion 1.4.18 → 2.0.1

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
@@ -13,11 +13,11 @@ npm i @y14e/accordion
13
13
  import Accordion from '@y14e/accordion';
14
14
 
15
15
  // CDNs
16
- import Accordion from 'https://esm.sh/@y14e/accordion@1.4.18';
16
+ import Accordion from 'https://esm.sh/@y14e/accordion@2.0.1';
17
17
  // or
18
- import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.18/+esm';
18
+ import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.1/+esm';
19
19
  // or
20
- import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.18';
20
+ import Accordion from 'https://esm.unpkg.com/@y14e/accordion@2.0.1';
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -40,7 +40,7 @@ interface AccordionOptions {
40
40
  easing?: string; // <easing-function> (default: 'ease')
41
41
  };
42
42
  selector?: {
43
- content?: string; // default: ':has(> [data-accordion-trigger]) + *'
43
+ content?: string; // default: '[data-accordion-content]'
44
44
  trigger?: string; // default: '[data-accordion-trigger]'
45
45
  };
46
46
  }
@@ -68,10 +68,10 @@ new Accordion(root);
68
68
 
69
69
  ## 📦 APIs
70
70
 
71
- ### `close`
71
+ ### `collapse`
72
72
 
73
73
  ```ts
74
- accordion.close(trigger);
74
+ accordion.collapse(trigger);
75
75
  // => void
76
76
  //
77
77
  // trigger: HTMLElement
@@ -88,10 +88,10 @@ accordion.destroy(force);
88
88
  // force (optional): If true, skips waiting for animations to finish.
89
89
  ```
90
90
 
91
- ### `open`
91
+ ### `expand`
92
92
 
93
93
  ```ts
94
- accordion.open(trigger);
94
+ accordion.expand(trigger);
95
95
  // => void
96
96
  //
97
97
  // trigger: HTMLElement
@@ -402,13 +402,7 @@ var RovingTabIndex = class _RovingTabIndex {
402
402
  console.warn("Invalid wrap option. Fallback: false.");
403
403
  wrap = false;
404
404
  }
405
- this.#settings = {
406
- navigationOnly,
407
- noMemory,
408
- noStart,
409
- typeahead,
410
- wrap
411
- };
405
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
412
406
  direction && Object.assign(this.#settings, { direction });
413
407
  selector && Object.assign(this.#settings, { selector });
414
408
  this.#selectorFilter = this.#createSelectorFilter();
@@ -589,7 +583,7 @@ var Accordion = class _Accordion {
589
583
  #defaults = {
590
584
  animation: { duration: 300, easing: "ease" },
591
585
  selector: {
592
- content: ":has(> [data-accordion-trigger]) + *",
586
+ content: "[data-accordion-content]",
593
587
  trigger: "[data-accordion-trigger]"
594
588
  }
595
589
  };
@@ -645,7 +639,7 @@ var Accordion = class _Accordion {
645
639
  });
646
640
  this.#initialize();
647
641
  }
648
- close(trigger) {
642
+ collapse(trigger) {
649
643
  if (this.#isDestroyed) {
650
644
  return;
651
645
  }
@@ -680,7 +674,7 @@ var Accordion = class _Accordion {
680
674
  this.#contentElements.length = 0;
681
675
  this.#rootElement.removeAttribute("data-accordion-initialized");
682
676
  }
683
- open(trigger) {
677
+ expand(trigger) {
684
678
  if (this.#isDestroyed) {
685
679
  return;
686
680
  }
@@ -765,21 +759,21 @@ var Accordion = class _Accordion {
765
759
  }
766
760
  binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
767
761
  };
768
- #toggle(trigger, isOpen, isMatch = false) {
769
- if (trigger.ariaExpanded === String(isOpen)) {
762
+ #toggle(trigger, isExpand, isMatch = false) {
763
+ if (trigger.ariaExpanded === String(isExpand)) {
770
764
  return;
771
765
  }
772
766
  const name = trigger.getAttribute("data-accordion-name");
773
- if (name && isOpen) {
774
- const open = this.#triggerElements.find(
767
+ if (name && isExpand) {
768
+ const expanded = this.#triggerElements.find(
775
769
  (t) => t !== trigger && t.getAttribute("data-accordion-name") === name && t.ariaExpanded === "true"
776
770
  );
777
- open && this.#toggle(open, false, isMatch);
771
+ expanded && this.#toggle(expanded, false, isMatch);
778
772
  }
779
773
  trigger.setAttribute(
780
774
  "aria-label",
781
775
  trigger.getAttribute(
782
- `data-accordion-${isOpen ? "expanded" : "collapsed"}-label`
776
+ `data-accordion-${isExpand ? "expanded" : "collapsed"}-label`
783
777
  ) ?? trigger.ariaLabel ?? ""
784
778
  );
785
779
  const binding = this.#bindings.get(trigger);
@@ -791,7 +785,7 @@ var Accordion = class _Accordion {
791
785
  if (content.hidden) {
792
786
  content.hidden = false;
793
787
  }
794
- const endSize = isOpen ? content.scrollHeight : 0;
788
+ const endSize = isExpand ? content.scrollHeight : 0;
795
789
  binding.animation?.cancel();
796
790
  content.style.setProperty("overflow", "clip");
797
791
  const { duration, easing } = this.#settings.animation;
@@ -800,7 +794,7 @@ var Accordion = class _Accordion {
800
794
  { duration: isMatch ? 0 : duration, easing }
801
795
  );
802
796
  binding.animation = animation;
803
- trigger.setAttribute("aria-expanded", String(isOpen));
797
+ trigger.setAttribute("aria-expanded", String(isExpand));
804
798
  function cleanup() {
805
799
  if (binding?.animation === animation) {
806
800
  binding.animation = null;
@@ -850,7 +844,7 @@ function waitAnimationFinish(animation) {
850
844
  * Accordion
851
845
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
852
846
  *
853
- * @version 1.4.18
847
+ * @version 2.0.1
854
848
  * @author Yusuke Kamiyamane
855
849
  * @license MIT
856
850
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -875,7 +869,7 @@ power-focusable/dist/index.js:
875
869
  * High-precision focus management utility with full composed tree support.
876
870
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
877
871
  *
878
- * @version 4.3.5
872
+ * @version 4.3.6
879
873
  * @author Yusuke Kamiyamane
880
874
  * @license MIT
881
875
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -899,7 +893,7 @@ power-focusable/dist/index.js:
899
893
  * Lightweight roving tabindex utility with fully focus management.
900
894
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
901
895
  *
902
- * @version 3.1.2
896
+ * @version 3.1.3
903
897
  * @author Yusuke Kamiyamane
904
898
  * @license MIT
905
899
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -400,13 +400,7 @@ var RovingTabIndex = class _RovingTabIndex {
400
400
  console.warn("Invalid wrap option. Fallback: false.");
401
401
  wrap = false;
402
402
  }
403
- this.#settings = {
404
- navigationOnly,
405
- noMemory,
406
- noStart,
407
- typeahead,
408
- wrap
409
- };
403
+ this.#settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
410
404
  direction && Object.assign(this.#settings, { direction });
411
405
  selector && Object.assign(this.#settings, { selector });
412
406
  this.#selectorFilter = this.#createSelectorFilter();
@@ -587,7 +581,7 @@ var Accordion = class _Accordion {
587
581
  #defaults = {
588
582
  animation: { duration: 300, easing: "ease" },
589
583
  selector: {
590
- content: ":has(> [data-accordion-trigger]) + *",
584
+ content: "[data-accordion-content]",
591
585
  trigger: "[data-accordion-trigger]"
592
586
  }
593
587
  };
@@ -643,7 +637,7 @@ var Accordion = class _Accordion {
643
637
  });
644
638
  this.#initialize();
645
639
  }
646
- close(trigger) {
640
+ collapse(trigger) {
647
641
  if (this.#isDestroyed) {
648
642
  return;
649
643
  }
@@ -678,7 +672,7 @@ var Accordion = class _Accordion {
678
672
  this.#contentElements.length = 0;
679
673
  this.#rootElement.removeAttribute("data-accordion-initialized");
680
674
  }
681
- open(trigger) {
675
+ expand(trigger) {
682
676
  if (this.#isDestroyed) {
683
677
  return;
684
678
  }
@@ -763,21 +757,21 @@ var Accordion = class _Accordion {
763
757
  }
764
758
  binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
765
759
  };
766
- #toggle(trigger, isOpen, isMatch = false) {
767
- if (trigger.ariaExpanded === String(isOpen)) {
760
+ #toggle(trigger, isExpand, isMatch = false) {
761
+ if (trigger.ariaExpanded === String(isExpand)) {
768
762
  return;
769
763
  }
770
764
  const name = trigger.getAttribute("data-accordion-name");
771
- if (name && isOpen) {
772
- const open = this.#triggerElements.find(
765
+ if (name && isExpand) {
766
+ const expanded = this.#triggerElements.find(
773
767
  (t) => t !== trigger && t.getAttribute("data-accordion-name") === name && t.ariaExpanded === "true"
774
768
  );
775
- open && this.#toggle(open, false, isMatch);
769
+ expanded && this.#toggle(expanded, false, isMatch);
776
770
  }
777
771
  trigger.setAttribute(
778
772
  "aria-label",
779
773
  trigger.getAttribute(
780
- `data-accordion-${isOpen ? "expanded" : "collapsed"}-label`
774
+ `data-accordion-${isExpand ? "expanded" : "collapsed"}-label`
781
775
  ) ?? trigger.ariaLabel ?? ""
782
776
  );
783
777
  const binding = this.#bindings.get(trigger);
@@ -789,7 +783,7 @@ var Accordion = class _Accordion {
789
783
  if (content.hidden) {
790
784
  content.hidden = false;
791
785
  }
792
- const endSize = isOpen ? content.scrollHeight : 0;
786
+ const endSize = isExpand ? content.scrollHeight : 0;
793
787
  binding.animation?.cancel();
794
788
  content.style.setProperty("overflow", "clip");
795
789
  const { duration, easing } = this.#settings.animation;
@@ -798,7 +792,7 @@ var Accordion = class _Accordion {
798
792
  { duration: isMatch ? 0 : duration, easing }
799
793
  );
800
794
  binding.animation = animation;
801
- trigger.setAttribute("aria-expanded", String(isOpen));
795
+ trigger.setAttribute("aria-expanded", String(isExpand));
802
796
  function cleanup() {
803
797
  if (binding?.animation === animation) {
804
798
  binding.animation = null;
@@ -848,7 +842,7 @@ function waitAnimationFinish(animation) {
848
842
  * Accordion
849
843
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
850
844
  *
851
- * @version 1.4.18
845
+ * @version 2.0.1
852
846
  * @author Yusuke Kamiyamane
853
847
  * @license MIT
854
848
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -873,7 +867,7 @@ power-focusable/dist/index.js:
873
867
  * High-precision focus management utility with full composed tree support.
874
868
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
875
869
  *
876
- * @version 4.3.5
870
+ * @version 4.3.6
877
871
  * @author Yusuke Kamiyamane
878
872
  * @license MIT
879
873
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -897,7 +891,7 @@ power-focusable/dist/index.js:
897
891
  * Lightweight roving tabindex utility with fully focus management.
898
892
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
899
893
  *
900
- * @version 3.1.2
894
+ * @version 3.1.3
901
895
  * @author Yusuke Kamiyamane
902
896
  * @license MIT
903
897
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -15,7 +15,7 @@ var Accordion = class _Accordion {
15
15
  #defaults = {
16
16
  animation: { duration: 300, easing: "ease" },
17
17
  selector: {
18
- content: ":has(> [data-accordion-trigger]) + *",
18
+ content: "[data-accordion-content]",
19
19
  trigger: "[data-accordion-trigger]"
20
20
  }
21
21
  };
@@ -71,7 +71,7 @@ var Accordion = class _Accordion {
71
71
  });
72
72
  this.#initialize();
73
73
  }
74
- close(trigger) {
74
+ collapse(trigger) {
75
75
  if (this.#isDestroyed) {
76
76
  return;
77
77
  }
@@ -106,7 +106,7 @@ var Accordion = class _Accordion {
106
106
  this.#contentElements.length = 0;
107
107
  this.#rootElement.removeAttribute("data-accordion-initialized");
108
108
  }
109
- open(trigger) {
109
+ expand(trigger) {
110
110
  if (this.#isDestroyed) {
111
111
  return;
112
112
  }
@@ -191,21 +191,21 @@ var Accordion = class _Accordion {
191
191
  }
192
192
  binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
193
193
  };
194
- #toggle(trigger, isOpen, isMatch = false) {
195
- if (trigger.ariaExpanded === String(isOpen)) {
194
+ #toggle(trigger, isExpand, isMatch = false) {
195
+ if (trigger.ariaExpanded === String(isExpand)) {
196
196
  return;
197
197
  }
198
198
  const name = trigger.getAttribute("data-accordion-name");
199
- if (name && isOpen) {
200
- const open = this.#triggerElements.find(
199
+ if (name && isExpand) {
200
+ const expanded = this.#triggerElements.find(
201
201
  (t) => t !== trigger && t.getAttribute("data-accordion-name") === name && t.ariaExpanded === "true"
202
202
  );
203
- open && this.#toggle(open, false, isMatch);
203
+ expanded && this.#toggle(expanded, false, isMatch);
204
204
  }
205
205
  trigger.setAttribute(
206
206
  "aria-label",
207
207
  trigger.getAttribute(
208
- `data-accordion-${isOpen ? "expanded" : "collapsed"}-label`
208
+ `data-accordion-${isExpand ? "expanded" : "collapsed"}-label`
209
209
  ) ?? trigger.ariaLabel ?? ""
210
210
  );
211
211
  const binding = this.#bindings.get(trigger);
@@ -217,7 +217,7 @@ var Accordion = class _Accordion {
217
217
  if (content.hidden) {
218
218
  content.hidden = false;
219
219
  }
220
- const endSize = isOpen ? content.scrollHeight : 0;
220
+ const endSize = isExpand ? content.scrollHeight : 0;
221
221
  binding.animation?.cancel();
222
222
  content.style.setProperty("overflow", "clip");
223
223
  const { duration, easing } = this.#settings.animation;
@@ -226,7 +226,7 @@ var Accordion = class _Accordion {
226
226
  { duration: isMatch ? 0 : duration, easing }
227
227
  );
228
228
  binding.animation = animation;
229
- trigger.setAttribute("aria-expanded", String(isOpen));
229
+ trigger.setAttribute("aria-expanded", String(isExpand));
230
230
  function cleanup() {
231
231
  if (binding?.animation === animation) {
232
232
  binding.animation = null;
@@ -276,7 +276,7 @@ function waitAnimationFinish(animation) {
276
276
  * Accordion
277
277
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
278
278
  *
279
- * @version 1.4.18
279
+ * @version 2.0.1
280
280
  * @author Yusuke Kamiyamane
281
281
  * @license MIT
282
282
  * @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.18
5
+ * @version 2.0.1
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
- close(trigger: HTMLElement): void;
25
+ collapse(trigger: HTMLElement): void;
26
26
  destroy(force?: boolean): Promise<void>;
27
- open(trigger: HTMLElement): void;
27
+ expand(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.18
5
+ * @version 2.0.1
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
- close(trigger: HTMLElement): void;
25
+ collapse(trigger: HTMLElement): void;
26
26
  destroy(force?: boolean): Promise<void>;
27
- open(trigger: HTMLElement): void;
27
+ expand(trigger: HTMLElement): void;
28
28
  }
29
29
 
30
30
  export { type AccordionOptions, Accordion as default };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var Accordion = class _Accordion {
9
9
  #defaults = {
10
10
  animation: { duration: 300, easing: "ease" },
11
11
  selector: {
12
- content: ":has(> [data-accordion-trigger]) + *",
12
+ content: "[data-accordion-content]",
13
13
  trigger: "[data-accordion-trigger]"
14
14
  }
15
15
  };
@@ -65,7 +65,7 @@ var Accordion = class _Accordion {
65
65
  });
66
66
  this.#initialize();
67
67
  }
68
- close(trigger) {
68
+ collapse(trigger) {
69
69
  if (this.#isDestroyed) {
70
70
  return;
71
71
  }
@@ -100,7 +100,7 @@ var Accordion = class _Accordion {
100
100
  this.#contentElements.length = 0;
101
101
  this.#rootElement.removeAttribute("data-accordion-initialized");
102
102
  }
103
- open(trigger) {
103
+ expand(trigger) {
104
104
  if (this.#isDestroyed) {
105
105
  return;
106
106
  }
@@ -185,21 +185,21 @@ var Accordion = class _Accordion {
185
185
  }
186
186
  binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
187
187
  };
188
- #toggle(trigger, isOpen, isMatch = false) {
189
- if (trigger.ariaExpanded === String(isOpen)) {
188
+ #toggle(trigger, isExpand, isMatch = false) {
189
+ if (trigger.ariaExpanded === String(isExpand)) {
190
190
  return;
191
191
  }
192
192
  const name = trigger.getAttribute("data-accordion-name");
193
- if (name && isOpen) {
194
- const open = this.#triggerElements.find(
193
+ if (name && isExpand) {
194
+ const expanded = this.#triggerElements.find(
195
195
  (t) => t !== trigger && t.getAttribute("data-accordion-name") === name && t.ariaExpanded === "true"
196
196
  );
197
- open && this.#toggle(open, false, isMatch);
197
+ expanded && this.#toggle(expanded, false, isMatch);
198
198
  }
199
199
  trigger.setAttribute(
200
200
  "aria-label",
201
201
  trigger.getAttribute(
202
- `data-accordion-${isOpen ? "expanded" : "collapsed"}-label`
202
+ `data-accordion-${isExpand ? "expanded" : "collapsed"}-label`
203
203
  ) ?? trigger.ariaLabel ?? ""
204
204
  );
205
205
  const binding = this.#bindings.get(trigger);
@@ -211,7 +211,7 @@ var Accordion = class _Accordion {
211
211
  if (content.hidden) {
212
212
  content.hidden = false;
213
213
  }
214
- const endSize = isOpen ? content.scrollHeight : 0;
214
+ const endSize = isExpand ? content.scrollHeight : 0;
215
215
  binding.animation?.cancel();
216
216
  content.style.setProperty("overflow", "clip");
217
217
  const { duration, easing } = this.#settings.animation;
@@ -220,7 +220,7 @@ var Accordion = class _Accordion {
220
220
  { duration: isMatch ? 0 : duration, easing }
221
221
  );
222
222
  binding.animation = animation;
223
- trigger.setAttribute("aria-expanded", String(isOpen));
223
+ trigger.setAttribute("aria-expanded", String(isExpand));
224
224
  function cleanup() {
225
225
  if (binding?.animation === animation) {
226
226
  binding.animation = null;
@@ -270,7 +270,7 @@ function waitAnimationFinish(animation) {
270
270
  * Accordion
271
271
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
272
272
  *
273
- * @version 1.4.18
273
+ * @version 2.0.1
274
274
  * @author Yusuke Kamiyamane
275
275
  * @license MIT
276
276
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "1.4.18",
3
+ "version": "2.0.1",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -54,6 +54,6 @@
54
54
  "dependencies": {
55
55
  "@y14e/attributes-utils": "^1.1.2",
56
56
  "@y14e/button": "^1.0.6",
57
- "@y14e/roving-tabindex": "^3.1.2"
57
+ "@y14e/roving-tabindex": "^3.1.3"
58
58
  }
59
59
  }