@y14e/disclosure 1.3.20 → 2.0.0

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/disclosure
13
13
  import Disclosure from '@y14e/disclosure';
14
14
 
15
15
  // CDNs
16
- import Disclosure from 'https://esm.sh/@y14e/disclosure@1.3.20';
16
+ import Disclosure from 'https://esm.sh/@y14e/disclosure@2.0.0';
17
17
  // or
18
- import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@1.3.20/+esm';
18
+ import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@2.0.0/+esm';
19
19
  // or
20
- import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@1.3.20';
20
+ import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@2.0.0';
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -60,10 +60,10 @@ new Disclosure(root);
60
60
 
61
61
  ## 📦 APIs
62
62
 
63
- ### `close`
63
+ ### `collapse`
64
64
 
65
65
  ```ts
66
- disclosure.close(details);
66
+ disclosure.collapse(details);
67
67
  // => void
68
68
  //
69
69
  // details: HTMLDetailsElement
@@ -80,10 +80,10 @@ disclosure.destroy(force);
80
80
  // force (optional): If true, skips waiting for animations to finish.
81
81
  ```
82
82
 
83
- ### `open`
83
+ ### `expand`
84
84
 
85
85
  ```ts
86
- disclosure.open(details);
86
+ disclosure.expand(details);
87
87
  // => void
88
88
  //
89
89
  // details: HTMLDetailsElement
@@ -605,7 +605,7 @@ var Disclosure = class _Disclosure {
605
605
  });
606
606
  this.#initialize();
607
607
  }
608
- close(details) {
608
+ collapse(details) {
609
609
  if (this.#isDestroyed) {
610
610
  return;
611
611
  }
@@ -646,7 +646,7 @@ var Disclosure = class _Disclosure {
646
646
  this.#contentElements.length = 0;
647
647
  this.#rootElement.removeAttribute("data-disclosure-initialized");
648
648
  }
649
- open(details) {
649
+ expand(details) {
650
650
  if (this.#isDestroyed) {
651
651
  return;
652
652
  }
@@ -723,17 +723,17 @@ var Disclosure = class _Disclosure {
723
723
  content.style.removeProperty(name2);
724
724
  });
725
725
  }
726
- #toggle(details, isOpen) {
727
- if (details.hasAttribute("data-disclosure-open") === isOpen) {
726
+ #toggle(details, isExpand) {
727
+ if (details.hasAttribute("data-disclosure-open") === isExpand) {
728
728
  return;
729
729
  }
730
730
  const name = details.getAttribute("data-disclosure-name");
731
- if (name && isOpen) {
731
+ if (name && isExpand) {
732
732
  details.removeAttribute("name");
733
- const open = this.#detailsElements.find(
733
+ const expanded = this.#detailsElements.find(
734
734
  (d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
735
735
  );
736
- open && this.close(open);
736
+ expanded && this.#toggle(expanded, false);
737
737
  }
738
738
  const binding = this.#bindings.get(details);
739
739
  if (!binding) {
@@ -742,12 +742,12 @@ var Disclosure = class _Disclosure {
742
742
  const { content } = binding;
743
743
  const startSize = details.open ? content.offsetHeight : 0;
744
744
  binding.animation?.cancel();
745
- if (isOpen) {
745
+ if (isExpand) {
746
746
  details.open = true;
747
747
  }
748
- const endSize = isOpen ? content.scrollHeight : 0;
748
+ const endSize = isExpand ? content.scrollHeight : 0;
749
749
  binding.animation?.cancel();
750
- details.toggleAttribute("data-disclosure-open", isOpen);
750
+ details.toggleAttribute("data-disclosure-open", isExpand);
751
751
  content.style.setProperty("overflow", "clip");
752
752
  const { duration, easing } = this.#settings.animation;
753
753
  const animation = content.animate(
@@ -804,7 +804,7 @@ function waitAnimationFinish(animation) {
804
804
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
805
805
  * Using the <details> and <summary> element.
806
806
  *
807
- * @version 1.3.20
807
+ * @version 2.0.0
808
808
  * @author Yusuke Kamiyamane
809
809
  * @license MIT
810
810
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -603,7 +603,7 @@ var Disclosure = class _Disclosure {
603
603
  });
604
604
  this.#initialize();
605
605
  }
606
- close(details) {
606
+ collapse(details) {
607
607
  if (this.#isDestroyed) {
608
608
  return;
609
609
  }
@@ -644,7 +644,7 @@ var Disclosure = class _Disclosure {
644
644
  this.#contentElements.length = 0;
645
645
  this.#rootElement.removeAttribute("data-disclosure-initialized");
646
646
  }
647
- open(details) {
647
+ expand(details) {
648
648
  if (this.#isDestroyed) {
649
649
  return;
650
650
  }
@@ -721,17 +721,17 @@ var Disclosure = class _Disclosure {
721
721
  content.style.removeProperty(name2);
722
722
  });
723
723
  }
724
- #toggle(details, isOpen) {
725
- if (details.hasAttribute("data-disclosure-open") === isOpen) {
724
+ #toggle(details, isExpand) {
725
+ if (details.hasAttribute("data-disclosure-open") === isExpand) {
726
726
  return;
727
727
  }
728
728
  const name = details.getAttribute("data-disclosure-name");
729
- if (name && isOpen) {
729
+ if (name && isExpand) {
730
730
  details.removeAttribute("name");
731
- const open = this.#detailsElements.find(
731
+ const expanded = this.#detailsElements.find(
732
732
  (d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
733
733
  );
734
- open && this.close(open);
734
+ expanded && this.#toggle(expanded, false);
735
735
  }
736
736
  const binding = this.#bindings.get(details);
737
737
  if (!binding) {
@@ -740,12 +740,12 @@ var Disclosure = class _Disclosure {
740
740
  const { content } = binding;
741
741
  const startSize = details.open ? content.offsetHeight : 0;
742
742
  binding.animation?.cancel();
743
- if (isOpen) {
743
+ if (isExpand) {
744
744
  details.open = true;
745
745
  }
746
- const endSize = isOpen ? content.scrollHeight : 0;
746
+ const endSize = isExpand ? content.scrollHeight : 0;
747
747
  binding.animation?.cancel();
748
- details.toggleAttribute("data-disclosure-open", isOpen);
748
+ details.toggleAttribute("data-disclosure-open", isExpand);
749
749
  content.style.setProperty("overflow", "clip");
750
750
  const { duration, easing } = this.#settings.animation;
751
751
  const animation = content.animate(
@@ -802,7 +802,7 @@ function waitAnimationFinish(animation) {
802
802
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
803
803
  * Using the <details> and <summary> element.
804
804
  *
805
- * @version 1.3.20
805
+ * @version 2.0.0
806
806
  * @author Yusuke Kamiyamane
807
807
  * @license MIT
808
808
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -75,7 +75,7 @@ var Disclosure = class _Disclosure {
75
75
  });
76
76
  this.#initialize();
77
77
  }
78
- close(details) {
78
+ collapse(details) {
79
79
  if (this.#isDestroyed) {
80
80
  return;
81
81
  }
@@ -116,7 +116,7 @@ var Disclosure = class _Disclosure {
116
116
  this.#contentElements.length = 0;
117
117
  this.#rootElement.removeAttribute("data-disclosure-initialized");
118
118
  }
119
- open(details) {
119
+ expand(details) {
120
120
  if (this.#isDestroyed) {
121
121
  return;
122
122
  }
@@ -193,17 +193,17 @@ var Disclosure = class _Disclosure {
193
193
  content.style.removeProperty(name2);
194
194
  });
195
195
  }
196
- #toggle(details, isOpen) {
197
- if (details.hasAttribute("data-disclosure-open") === isOpen) {
196
+ #toggle(details, isExpand) {
197
+ if (details.hasAttribute("data-disclosure-open") === isExpand) {
198
198
  return;
199
199
  }
200
200
  const name = details.getAttribute("data-disclosure-name");
201
- if (name && isOpen) {
201
+ if (name && isExpand) {
202
202
  details.removeAttribute("name");
203
- const open = this.#detailsElements.find(
203
+ const expanded = this.#detailsElements.find(
204
204
  (d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
205
205
  );
206
- open && this.close(open);
206
+ expanded && this.#toggle(expanded, false);
207
207
  }
208
208
  const binding = this.#bindings.get(details);
209
209
  if (!binding) {
@@ -212,12 +212,12 @@ var Disclosure = class _Disclosure {
212
212
  const { content } = binding;
213
213
  const startSize = details.open ? content.offsetHeight : 0;
214
214
  binding.animation?.cancel();
215
- if (isOpen) {
215
+ if (isExpand) {
216
216
  details.open = true;
217
217
  }
218
- const endSize = isOpen ? content.scrollHeight : 0;
218
+ const endSize = isExpand ? content.scrollHeight : 0;
219
219
  binding.animation?.cancel();
220
- details.toggleAttribute("data-disclosure-open", isOpen);
220
+ details.toggleAttribute("data-disclosure-open", isExpand);
221
221
  content.style.setProperty("overflow", "clip");
222
222
  const { duration, easing } = this.#settings.animation;
223
223
  const animation = content.animate(
@@ -274,7 +274,7 @@ function waitAnimationFinish(animation) {
274
274
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
275
275
  * Using the <details> and <summary> element.
276
276
  *
277
- * @version 1.3.20
277
+ * @version 2.0.0
278
278
  * @author Yusuke Kamiyamane
279
279
  * @license MIT
280
280
  * @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.20
6
+ * @version 2.0.0
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -19,9 +19,9 @@ declare class Disclosure {
19
19
  #private;
20
20
  static defaults: DisclosureOptions;
21
21
  constructor(root: HTMLElement, options?: DisclosureOptions);
22
- close(details: HTMLDetailsElement): void;
22
+ collapse(details: HTMLDetailsElement): void;
23
23
  destroy(force?: boolean): Promise<void>;
24
- open(details: HTMLDetailsElement): void;
24
+ expand(details: HTMLDetailsElement): void;
25
25
  }
26
26
 
27
27
  export { type DisclosureOptions, Disclosure as default };
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.20
6
+ * @version 2.0.0
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -19,9 +19,9 @@ declare class Disclosure {
19
19
  #private;
20
20
  static defaults: DisclosureOptions;
21
21
  constructor(root: HTMLElement, options?: DisclosureOptions);
22
- close(details: HTMLDetailsElement): void;
22
+ collapse(details: HTMLDetailsElement): void;
23
23
  destroy(force?: boolean): Promise<void>;
24
- open(details: HTMLDetailsElement): void;
24
+ expand(details: HTMLDetailsElement): void;
25
25
  }
26
26
 
27
27
  export { type DisclosureOptions, Disclosure as default };
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ var Disclosure = class _Disclosure {
73
73
  });
74
74
  this.#initialize();
75
75
  }
76
- close(details) {
76
+ collapse(details) {
77
77
  if (this.#isDestroyed) {
78
78
  return;
79
79
  }
@@ -114,7 +114,7 @@ var Disclosure = class _Disclosure {
114
114
  this.#contentElements.length = 0;
115
115
  this.#rootElement.removeAttribute("data-disclosure-initialized");
116
116
  }
117
- open(details) {
117
+ expand(details) {
118
118
  if (this.#isDestroyed) {
119
119
  return;
120
120
  }
@@ -191,17 +191,17 @@ var Disclosure = class _Disclosure {
191
191
  content.style.removeProperty(name2);
192
192
  });
193
193
  }
194
- #toggle(details, isOpen) {
195
- if (details.hasAttribute("data-disclosure-open") === isOpen) {
194
+ #toggle(details, isExpand) {
195
+ if (details.hasAttribute("data-disclosure-open") === isExpand) {
196
196
  return;
197
197
  }
198
198
  const name = details.getAttribute("data-disclosure-name");
199
- if (name && isOpen) {
199
+ if (name && isExpand) {
200
200
  details.removeAttribute("name");
201
- const open = this.#detailsElements.find(
201
+ const expanded = this.#detailsElements.find(
202
202
  (d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
203
203
  );
204
- open && this.close(open);
204
+ expanded && this.#toggle(expanded, false);
205
205
  }
206
206
  const binding = this.#bindings.get(details);
207
207
  if (!binding) {
@@ -210,12 +210,12 @@ var Disclosure = class _Disclosure {
210
210
  const { content } = binding;
211
211
  const startSize = details.open ? content.offsetHeight : 0;
212
212
  binding.animation?.cancel();
213
- if (isOpen) {
213
+ if (isExpand) {
214
214
  details.open = true;
215
215
  }
216
- const endSize = isOpen ? content.scrollHeight : 0;
216
+ const endSize = isExpand ? content.scrollHeight : 0;
217
217
  binding.animation?.cancel();
218
- details.toggleAttribute("data-disclosure-open", isOpen);
218
+ details.toggleAttribute("data-disclosure-open", isExpand);
219
219
  content.style.setProperty("overflow", "clip");
220
220
  const { duration, easing } = this.#settings.animation;
221
221
  const animation = content.animate(
@@ -272,7 +272,7 @@ function waitAnimationFinish(animation) {
272
272
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
273
273
  * Using the <details> and <summary> element.
274
274
  *
275
- * @version 1.3.20
275
+ * @version 2.0.0
276
276
  * @author Yusuke Kamiyamane
277
277
  * @license MIT
278
278
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/disclosure",
3
- "version": "1.3.20",
3
+ "version": "2.0.0",
4
4
  "description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",