@y14e/disclosure 2.0.14 → 2.0.15

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";
13
+ import { Disclosure } from '@y14e/disclosure';
14
14
 
15
15
  // CDNs
16
- import { Disclosure } from "https://esm.sh/@y14e/disclosure@2.0.14";
16
+ import { Disclosure } from 'https://esm.sh/@y14e/disclosure@2.0.15';
17
17
  // or
18
- import { Disclosure } from "https://cdn.jsdelivr.net/npm/@y14e/disclosure@2.0.14/+esm";
18
+ import { Disclosure } from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@2.0.15/+esm';
19
19
  // or
20
- import { Disclosure } from "https://esm.unpkg.com/@y14e/disclosure@2.0.14";
20
+ import { Disclosure } from 'https://esm.unpkg.com/@y14e/disclosure@2.0.15';
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -47,7 +47,7 @@ interface DisclosureOptions {
47
47
  Override the global default settings applied to all disclosure instances.
48
48
 
49
49
  ```ts
50
- import { Disclosure } from "@y14e/disclosure";
50
+ import { Disclosure } from '@y14e/disclosure';
51
51
 
52
52
  Disclosure.defaults = {
53
53
  animation: {
@@ -37,16 +37,16 @@ function restoreAttributes(element_or_elements) {
37
37
  }
38
38
  function saveAttributes(element_or_elements, name_or_names) {
39
39
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
40
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
40
+ for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
41
41
  let snapshot = snapshots.get(element);
42
42
  if (!snapshot) {
43
43
  snapshot = /* @__PURE__ */ new Map();
44
44
  snapshots.set(element, snapshot);
45
45
  }
46
- names.forEach((name) => {
46
+ for (const name of names) {
47
47
  snapshot.set(name, element.getAttribute(name));
48
- });
49
- });
48
+ }
49
+ }
50
50
  }
51
51
  function isValid(element, name, token) {
52
52
  if (!(element instanceof Element)) {
@@ -91,7 +91,7 @@ function resolveOptions(options) {
91
91
  }
92
92
 
93
93
  // node_modules/power-focusable/dist/index.js
94
- var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
94
+ var FOCUSABLE_SELECTOR = ':is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])';
95
95
  var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
96
96
  /(,\s*)?\[tabindex="-1"\]/g,
97
97
  ""
@@ -117,29 +117,19 @@ function getFocusables(container = document.body, options = {}) {
117
117
  }) || include?.(node)) {
118
118
  candidates[candidates.length] = node;
119
119
  }
120
- const children2 = composed ? getComposedChildren(node) : getChildren(node);
121
- for (let i = 0, l = children2.length; i < l; i++) {
122
- const child = children2[i];
123
- child && traverse2(child);
124
- }
120
+ (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
125
121
  };
126
- const children = composed ? getComposedChildren(container) : getChildren(container);
127
- for (let i = 0, l = children.length; i < l; i++) {
128
- const child = children[i];
129
- child && traverse2(child);
130
- }
122
+ (composed ? getComposedChildren(container) : getChildren(container)).map(
123
+ traverse2
124
+ );
131
125
  } else {
132
- const matches = container.querySelectorAll(
126
+ for (const match of container.querySelectorAll(
133
127
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
134
- );
135
- for (let i = 0, l = matches.length; i < l; i++) {
136
- const matched = matches[i];
137
- if (matched && isFocusable(matched, {
128
+ )) {
129
+ match && isFocusable(match, {
138
130
  skipNegativeTabIndexCheck,
139
131
  skipVisibilityCheck
140
- })) {
141
- candidates[candidates.length] = matched;
142
- }
132
+ }) && candidates.push(match);
143
133
  }
144
134
  }
145
135
  return normalizeRadioGroup(
@@ -206,8 +196,7 @@ function isDisabledDeep(element) {
206
196
  }
207
197
  function normalizeRadioGroup(elements) {
208
198
  let map = null;
209
- for (let i = 0, l = elements.length; i < l; i++) {
210
- const element = elements[i];
199
+ for (const element of elements) {
211
200
  if (!(element instanceof HTMLInputElement)) {
212
201
  continue;
213
202
  }
@@ -257,23 +246,10 @@ function normalizeRadioGroup(elements) {
257
246
  function sortByTabIndex(elements) {
258
247
  const ordered = [];
259
248
  const natural = [];
260
- for (let i = 0, l = elements.length; i < l; i++) {
261
- const element = elements[i];
262
- if (element) {
263
- const target = getTabIndex(element) > 0 ? ordered : natural;
264
- target[target.length] = element;
265
- }
266
- }
267
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
268
- let count = 0;
269
- const sorted = new Array(ordered.length + natural.length);
270
- for (let i = 0, l = ordered.length; i < l; i++) {
271
- sorted[count++] = ordered[i];
249
+ for (const element of elements) {
250
+ (getTabIndex(element) > 0 ? ordered : natural).push(element);
272
251
  }
273
- for (let i = 0, l = natural.length; i < l; i++) {
274
- sorted[count++] = natural[i];
275
- }
276
- return sorted;
252
+ return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
277
253
  }
278
254
  function getComposedChildren(node) {
279
255
  if (node instanceof ShadowRoot) {
@@ -414,10 +390,10 @@ var RovingTabIndex = class _RovingTabIndex {
414
390
  this.#isDestroyed = true;
415
391
  this.#controller?.abort();
416
392
  this.#controller = null;
417
- this.#focusables.forEach((focusable) => {
393
+ for (const focusable of this.#focusables) {
418
394
  _RovingTabIndex.#initialized.delete(focusable);
419
395
  restoreAttributes(focusable);
420
- });
396
+ }
421
397
  this.#focusables.clear();
422
398
  this.#focusablesByFirstChar.clear();
423
399
  }
@@ -561,17 +537,17 @@ var RovingTabIndex = class _RovingTabIndex {
561
537
  caseInsensitive: true
562
538
  });
563
539
  }
564
- keys.forEach((key) => {
540
+ for (const key of keys) {
565
541
  const focusables = this.#focusablesByFirstChar.get(key) ?? [];
566
542
  focusables.push(focusable);
567
543
  this.#focusablesByFirstChar.set(key, focusables);
568
- });
544
+ }
569
545
  }
570
546
  if (!navigationOnly) {
571
547
  if (active && this.#focusables.has(active)) {
572
- this.#focusables.forEach((focusable) => {
548
+ for (const focusable of this.#focusables) {
573
549
  focusable.setAttribute("tabindex", focusable === active ? "0" : "-1");
574
- });
550
+ }
575
551
  } else {
576
552
  [...this.#focusables].forEach((focusable, i) => {
577
553
  focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
@@ -601,6 +577,7 @@ var RovingTabIndex = class _RovingTabIndex {
601
577
  typeahead = false,
602
578
  wrap = false
603
579
  } = options;
580
+ direction = direction.toLowerCase();
604
581
  if (!["both", "horizontal", "vertical"].includes(direction)) {
605
582
  console.warn("Invalid direction option. Fallback: 'both'.");
606
583
  direction = "both";
@@ -736,24 +713,24 @@ var Disclosure = class _Disclosure {
736
713
  this.#isDestroyed = true;
737
714
  this.#eventController?.abort();
738
715
  this.#eventController = null;
739
- this.#observers.forEach((observer) => {
716
+ for (const observer of this.#observers) {
740
717
  observer.disconnect();
741
- });
718
+ }
742
719
  this.#observers.length = 0;
743
720
  this.#cleanupRovingTabIndex?.();
744
721
  this.#cleanupRovingTabIndex = null;
745
722
  !force && await this.#waitAnimationsFinish();
746
- this.#contentElements.forEach((content) => {
723
+ for (const content of this.#contentElements) {
747
724
  force && this.#bindings.get(content)?.animation?.finish();
748
725
  this.#onContentAnimationFinish(content);
749
- });
726
+ }
750
727
  this.#animationController?.abort();
751
728
  this.#animationController = null;
752
- this.#detailsElements.forEach((details) => {
753
- ["name", "open"].forEach((name) => {
729
+ for (const details of this.#detailsElements) {
730
+ for (const name of ["name", "open"]) {
754
731
  details.removeAttribute(`data-disclosure-${name}`);
755
- });
756
- });
732
+ }
733
+ }
757
734
  this.#detailsElements.length = 0;
758
735
  restoreAttributes(this.#summaryElements);
759
736
  this.#summaryElements.length = 0;
@@ -833,9 +810,9 @@ var Disclosure = class _Disclosure {
833
810
  if (!details.hasAttribute("data-disclosure-open")) {
834
811
  details.open = false;
835
812
  }
836
- ["block-size", "overflow"].forEach((name2) => {
813
+ for (const name2 of ["block-size", "overflow"]) {
837
814
  content.style.removeProperty(name2);
838
- });
815
+ }
839
816
  }
840
817
  #toggle(details, isExpand, isProgrammatic = false) {
841
818
  if (details.hasAttribute("data-disclosure-open") === isExpand) {
@@ -932,10 +909,10 @@ var Disclosure = class _Disclosure {
932
909
  }
933
910
  async #waitAnimationsFinish() {
934
911
  const promises = [];
935
- this.#contentElements.forEach((content) => {
912
+ for (const content of this.#contentElements) {
936
913
  const animation = this.#bindings.get(content)?.animation;
937
914
  animation && promises.push(waitAnimationFinish(animation));
938
- });
915
+ }
939
916
  await Promise.allSettled(promises);
940
917
  }
941
918
  };
@@ -949,7 +926,7 @@ function waitAnimationFinish(animation) {
949
926
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
950
927
  * Using the <details> and <summary> element.
951
928
  *
952
- * @version 2.0.14
929
+ * @version 2.0.15
953
930
  * @author Yusuke Kamiyamane
954
931
  * @license MIT
955
932
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -961,7 +938,7 @@ function waitAnimationFinish(animation) {
961
938
  (**
962
939
  * Attribute Utils
963
940
  *
964
- * @version 2.0.8
941
+ * @version 2.0.10
965
942
  * @author Yusuke Kamiyamane
966
943
  * @license MIT
967
944
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -974,7 +951,7 @@ power-focusable/dist/index.js:
974
951
  * High-precision focus management utility with full composed tree support.
975
952
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
976
953
  *
977
- * @version 4.3.29
954
+ * @version 4.3.30
978
955
  * @author Yusuke Kamiyamane
979
956
  * @license MIT
980
957
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -987,7 +964,7 @@ power-focusable/dist/index.js:
987
964
  * Lightweight roving tabindex utility with fully focus management.
988
965
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
989
966
  *
990
- * @version 3.1.27
967
+ * @version 3.1.28
991
968
  * @author Yusuke Kamiyamane
992
969
  * @license MIT
993
970
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -35,16 +35,16 @@ function restoreAttributes(element_or_elements) {
35
35
  }
36
36
  function saveAttributes(element_or_elements, name_or_names) {
37
37
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
38
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
38
+ for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
39
39
  let snapshot = snapshots.get(element);
40
40
  if (!snapshot) {
41
41
  snapshot = /* @__PURE__ */ new Map();
42
42
  snapshots.set(element, snapshot);
43
43
  }
44
- names.forEach((name) => {
44
+ for (const name of names) {
45
45
  snapshot.set(name, element.getAttribute(name));
46
- });
47
- });
46
+ }
47
+ }
48
48
  }
49
49
  function isValid(element, name, token) {
50
50
  if (!(element instanceof Element)) {
@@ -89,7 +89,7 @@ function resolveOptions(options) {
89
89
  }
90
90
 
91
91
  // node_modules/power-focusable/dist/index.js
92
- var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
92
+ var FOCUSABLE_SELECTOR = ':is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])';
93
93
  var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
94
94
  /(,\s*)?\[tabindex="-1"\]/g,
95
95
  ""
@@ -115,29 +115,19 @@ function getFocusables(container = document.body, options = {}) {
115
115
  }) || include?.(node)) {
116
116
  candidates[candidates.length] = node;
117
117
  }
118
- const children2 = composed ? getComposedChildren(node) : getChildren(node);
119
- for (let i = 0, l = children2.length; i < l; i++) {
120
- const child = children2[i];
121
- child && traverse2(child);
122
- }
118
+ (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
123
119
  };
124
- const children = composed ? getComposedChildren(container) : getChildren(container);
125
- for (let i = 0, l = children.length; i < l; i++) {
126
- const child = children[i];
127
- child && traverse2(child);
128
- }
120
+ (composed ? getComposedChildren(container) : getChildren(container)).map(
121
+ traverse2
122
+ );
129
123
  } else {
130
- const matches = container.querySelectorAll(
124
+ for (const match of container.querySelectorAll(
131
125
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
132
- );
133
- for (let i = 0, l = matches.length; i < l; i++) {
134
- const matched = matches[i];
135
- if (matched && isFocusable(matched, {
126
+ )) {
127
+ match && isFocusable(match, {
136
128
  skipNegativeTabIndexCheck,
137
129
  skipVisibilityCheck
138
- })) {
139
- candidates[candidates.length] = matched;
140
- }
130
+ }) && candidates.push(match);
141
131
  }
142
132
  }
143
133
  return normalizeRadioGroup(
@@ -204,8 +194,7 @@ function isDisabledDeep(element) {
204
194
  }
205
195
  function normalizeRadioGroup(elements) {
206
196
  let map = null;
207
- for (let i = 0, l = elements.length; i < l; i++) {
208
- const element = elements[i];
197
+ for (const element of elements) {
209
198
  if (!(element instanceof HTMLInputElement)) {
210
199
  continue;
211
200
  }
@@ -255,23 +244,10 @@ function normalizeRadioGroup(elements) {
255
244
  function sortByTabIndex(elements) {
256
245
  const ordered = [];
257
246
  const natural = [];
258
- for (let i = 0, l = elements.length; i < l; i++) {
259
- const element = elements[i];
260
- if (element) {
261
- const target = getTabIndex(element) > 0 ? ordered : natural;
262
- target[target.length] = element;
263
- }
264
- }
265
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
266
- let count = 0;
267
- const sorted = new Array(ordered.length + natural.length);
268
- for (let i = 0, l = ordered.length; i < l; i++) {
269
- sorted[count++] = ordered[i];
247
+ for (const element of elements) {
248
+ (getTabIndex(element) > 0 ? ordered : natural).push(element);
270
249
  }
271
- for (let i = 0, l = natural.length; i < l; i++) {
272
- sorted[count++] = natural[i];
273
- }
274
- return sorted;
250
+ return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
275
251
  }
276
252
  function getComposedChildren(node) {
277
253
  if (node instanceof ShadowRoot) {
@@ -412,10 +388,10 @@ var RovingTabIndex = class _RovingTabIndex {
412
388
  this.#isDestroyed = true;
413
389
  this.#controller?.abort();
414
390
  this.#controller = null;
415
- this.#focusables.forEach((focusable) => {
391
+ for (const focusable of this.#focusables) {
416
392
  _RovingTabIndex.#initialized.delete(focusable);
417
393
  restoreAttributes(focusable);
418
- });
394
+ }
419
395
  this.#focusables.clear();
420
396
  this.#focusablesByFirstChar.clear();
421
397
  }
@@ -559,17 +535,17 @@ var RovingTabIndex = class _RovingTabIndex {
559
535
  caseInsensitive: true
560
536
  });
561
537
  }
562
- keys.forEach((key) => {
538
+ for (const key of keys) {
563
539
  const focusables = this.#focusablesByFirstChar.get(key) ?? [];
564
540
  focusables.push(focusable);
565
541
  this.#focusablesByFirstChar.set(key, focusables);
566
- });
542
+ }
567
543
  }
568
544
  if (!navigationOnly) {
569
545
  if (active && this.#focusables.has(active)) {
570
- this.#focusables.forEach((focusable) => {
546
+ for (const focusable of this.#focusables) {
571
547
  focusable.setAttribute("tabindex", focusable === active ? "0" : "-1");
572
- });
548
+ }
573
549
  } else {
574
550
  [...this.#focusables].forEach((focusable, i) => {
575
551
  focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
@@ -599,6 +575,7 @@ var RovingTabIndex = class _RovingTabIndex {
599
575
  typeahead = false,
600
576
  wrap = false
601
577
  } = options;
578
+ direction = direction.toLowerCase();
602
579
  if (!["both", "horizontal", "vertical"].includes(direction)) {
603
580
  console.warn("Invalid direction option. Fallback: 'both'.");
604
581
  direction = "both";
@@ -734,24 +711,24 @@ var Disclosure = class _Disclosure {
734
711
  this.#isDestroyed = true;
735
712
  this.#eventController?.abort();
736
713
  this.#eventController = null;
737
- this.#observers.forEach((observer) => {
714
+ for (const observer of this.#observers) {
738
715
  observer.disconnect();
739
- });
716
+ }
740
717
  this.#observers.length = 0;
741
718
  this.#cleanupRovingTabIndex?.();
742
719
  this.#cleanupRovingTabIndex = null;
743
720
  !force && await this.#waitAnimationsFinish();
744
- this.#contentElements.forEach((content) => {
721
+ for (const content of this.#contentElements) {
745
722
  force && this.#bindings.get(content)?.animation?.finish();
746
723
  this.#onContentAnimationFinish(content);
747
- });
724
+ }
748
725
  this.#animationController?.abort();
749
726
  this.#animationController = null;
750
- this.#detailsElements.forEach((details) => {
751
- ["name", "open"].forEach((name) => {
727
+ for (const details of this.#detailsElements) {
728
+ for (const name of ["name", "open"]) {
752
729
  details.removeAttribute(`data-disclosure-${name}`);
753
- });
754
- });
730
+ }
731
+ }
755
732
  this.#detailsElements.length = 0;
756
733
  restoreAttributes(this.#summaryElements);
757
734
  this.#summaryElements.length = 0;
@@ -831,9 +808,9 @@ var Disclosure = class _Disclosure {
831
808
  if (!details.hasAttribute("data-disclosure-open")) {
832
809
  details.open = false;
833
810
  }
834
- ["block-size", "overflow"].forEach((name2) => {
811
+ for (const name2 of ["block-size", "overflow"]) {
835
812
  content.style.removeProperty(name2);
836
- });
813
+ }
837
814
  }
838
815
  #toggle(details, isExpand, isProgrammatic = false) {
839
816
  if (details.hasAttribute("data-disclosure-open") === isExpand) {
@@ -930,10 +907,10 @@ var Disclosure = class _Disclosure {
930
907
  }
931
908
  async #waitAnimationsFinish() {
932
909
  const promises = [];
933
- this.#contentElements.forEach((content) => {
910
+ for (const content of this.#contentElements) {
934
911
  const animation = this.#bindings.get(content)?.animation;
935
912
  animation && promises.push(waitAnimationFinish(animation));
936
- });
913
+ }
937
914
  await Promise.allSettled(promises);
938
915
  }
939
916
  };
@@ -947,7 +924,7 @@ function waitAnimationFinish(animation) {
947
924
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
948
925
  * Using the <details> and <summary> element.
949
926
  *
950
- * @version 2.0.14
927
+ * @version 2.0.15
951
928
  * @author Yusuke Kamiyamane
952
929
  * @license MIT
953
930
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -959,7 +936,7 @@ function waitAnimationFinish(animation) {
959
936
  (**
960
937
  * Attribute Utils
961
938
  *
962
- * @version 2.0.8
939
+ * @version 2.0.10
963
940
  * @author Yusuke Kamiyamane
964
941
  * @license MIT
965
942
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -972,7 +949,7 @@ power-focusable/dist/index.js:
972
949
  * High-precision focus management utility with full composed tree support.
973
950
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
974
951
  *
975
- * @version 4.3.29
952
+ * @version 4.3.30
976
953
  * @author Yusuke Kamiyamane
977
954
  * @license MIT
978
955
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -985,7 +962,7 @@ power-focusable/dist/index.js:
985
962
  * Lightweight roving tabindex utility with fully focus management.
986
963
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
987
964
  *
988
- * @version 3.1.27
965
+ * @version 3.1.28
989
966
  * @author Yusuke Kamiyamane
990
967
  * @license MIT
991
968
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -114,24 +114,24 @@ var Disclosure = class _Disclosure {
114
114
  this.#isDestroyed = true;
115
115
  this.#eventController?.abort();
116
116
  this.#eventController = null;
117
- this.#observers.forEach((observer) => {
117
+ for (const observer of this.#observers) {
118
118
  observer.disconnect();
119
- });
119
+ }
120
120
  this.#observers.length = 0;
121
121
  this.#cleanupRovingTabIndex?.();
122
122
  this.#cleanupRovingTabIndex = null;
123
123
  !force && await this.#waitAnimationsFinish();
124
- this.#contentElements.forEach((content) => {
124
+ for (const content of this.#contentElements) {
125
125
  force && this.#bindings.get(content)?.animation?.finish();
126
126
  this.#onContentAnimationFinish(content);
127
- });
127
+ }
128
128
  this.#animationController?.abort();
129
129
  this.#animationController = null;
130
- this.#detailsElements.forEach((details) => {
131
- ["name", "open"].forEach((name) => {
130
+ for (const details of this.#detailsElements) {
131
+ for (const name of ["name", "open"]) {
132
132
  details.removeAttribute(`data-disclosure-${name}`);
133
- });
134
- });
133
+ }
134
+ }
135
135
  this.#detailsElements.length = 0;
136
136
  utils__namespace.restoreAttributes(this.#summaryElements);
137
137
  this.#summaryElements.length = 0;
@@ -211,9 +211,9 @@ var Disclosure = class _Disclosure {
211
211
  if (!details.hasAttribute("data-disclosure-open")) {
212
212
  details.open = false;
213
213
  }
214
- ["block-size", "overflow"].forEach((name2) => {
214
+ for (const name2 of ["block-size", "overflow"]) {
215
215
  content.style.removeProperty(name2);
216
- });
216
+ }
217
217
  }
218
218
  #toggle(details, isExpand, isProgrammatic = false) {
219
219
  if (details.hasAttribute("data-disclosure-open") === isExpand) {
@@ -310,10 +310,10 @@ var Disclosure = class _Disclosure {
310
310
  }
311
311
  async #waitAnimationsFinish() {
312
312
  const promises = [];
313
- this.#contentElements.forEach((content) => {
313
+ for (const content of this.#contentElements) {
314
314
  const animation = this.#bindings.get(content)?.animation;
315
315
  animation && promises.push(waitAnimationFinish(animation));
316
- });
316
+ }
317
317
  await Promise.allSettled(promises);
318
318
  }
319
319
  };
@@ -327,7 +327,7 @@ function waitAnimationFinish(animation) {
327
327
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
328
328
  * Using the <details> and <summary> element.
329
329
  *
330
- * @version 2.0.14
330
+ * @version 2.0.15
331
331
  * @author Yusuke Kamiyamane
332
332
  * @license MIT
333
333
  * @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 2.0.14
6
+ * @version 2.0.15
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 2.0.14
6
+ * @version 2.0.15
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -92,24 +92,24 @@ var Disclosure = class _Disclosure {
92
92
  this.#isDestroyed = true;
93
93
  this.#eventController?.abort();
94
94
  this.#eventController = null;
95
- this.#observers.forEach((observer) => {
95
+ for (const observer of this.#observers) {
96
96
  observer.disconnect();
97
- });
97
+ }
98
98
  this.#observers.length = 0;
99
99
  this.#cleanupRovingTabIndex?.();
100
100
  this.#cleanupRovingTabIndex = null;
101
101
  !force && await this.#waitAnimationsFinish();
102
- this.#contentElements.forEach((content) => {
102
+ for (const content of this.#contentElements) {
103
103
  force && this.#bindings.get(content)?.animation?.finish();
104
104
  this.#onContentAnimationFinish(content);
105
- });
105
+ }
106
106
  this.#animationController?.abort();
107
107
  this.#animationController = null;
108
- this.#detailsElements.forEach((details) => {
109
- ["name", "open"].forEach((name) => {
108
+ for (const details of this.#detailsElements) {
109
+ for (const name of ["name", "open"]) {
110
110
  details.removeAttribute(`data-disclosure-${name}`);
111
- });
112
- });
111
+ }
112
+ }
113
113
  this.#detailsElements.length = 0;
114
114
  utils.restoreAttributes(this.#summaryElements);
115
115
  this.#summaryElements.length = 0;
@@ -189,9 +189,9 @@ var Disclosure = class _Disclosure {
189
189
  if (!details.hasAttribute("data-disclosure-open")) {
190
190
  details.open = false;
191
191
  }
192
- ["block-size", "overflow"].forEach((name2) => {
192
+ for (const name2 of ["block-size", "overflow"]) {
193
193
  content.style.removeProperty(name2);
194
- });
194
+ }
195
195
  }
196
196
  #toggle(details, isExpand, isProgrammatic = false) {
197
197
  if (details.hasAttribute("data-disclosure-open") === isExpand) {
@@ -288,10 +288,10 @@ var Disclosure = class _Disclosure {
288
288
  }
289
289
  async #waitAnimationsFinish() {
290
290
  const promises = [];
291
- this.#contentElements.forEach((content) => {
291
+ for (const content of this.#contentElements) {
292
292
  const animation = this.#bindings.get(content)?.animation;
293
293
  animation && promises.push(waitAnimationFinish(animation));
294
- });
294
+ }
295
295
  await Promise.allSettled(promises);
296
296
  }
297
297
  };
@@ -305,7 +305,7 @@ function waitAnimationFinish(animation) {
305
305
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
306
306
  * Using the <details> and <summary> element.
307
307
  *
308
- * @version 2.0.14
308
+ * @version 2.0.15
309
309
  * @author Yusuke Kamiyamane
310
310
  * @license MIT
311
311
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,11 +1,27 @@
1
1
  {
2
2
  "name": "@y14e/disclosure",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
5
+ "keywords": [
6
+ "a11y",
7
+ "accessibility",
8
+ "disclosure",
9
+ "collapsible",
10
+ "component",
11
+ "typescript",
12
+ "utility"
13
+ ],
14
+ "homepage": "https://github.com/y14e/disclosure#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/y14e/disclosure/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/y14e/disclosure.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Yusuke Kamiyamane",
5
24
  "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
25
  "exports": {
10
26
  ".": {
11
27
  "types": "./dist/index.d.ts",
@@ -13,6 +29,9 @@
13
29
  "require": "./dist/index.cjs"
14
30
  }
15
31
  },
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
16
35
  "files": [
17
36
  "dist",
18
37
  "LICENSE",
@@ -20,28 +39,9 @@
20
39
  ],
21
40
  "scripts": {
22
41
  "build": "tsup",
23
- "prepublishOnly": "npm run build",
24
- "lint": "tsc --noEmit"
25
- },
26
- "keywords": [
27
- "a11y",
28
- "accessibility",
29
- "disclosure",
30
- "collapsible",
31
- "component",
32
- "typescript",
33
- "utility"
34
- ],
35
- "author": "Yusuke Kamiyamane",
36
- "license": "MIT",
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/y14e/disclosure.git"
42
+ "lint": "tsc --noEmit",
43
+ "prepublishOnly": "npm run build"
40
44
  },
41
- "bugs": {
42
- "url": "https://github.com/y14e/disclosure/issues"
43
- },
44
- "homepage": "https://github.com/y14e/disclosure#readme",
45
45
  "devDependencies": {
46
46
  "bun-types": "latest",
47
47
  "tsup": "^8.0.0",
@@ -54,7 +54,7 @@
54
54
  "esbuild": true
55
55
  },
56
56
  "dependencies": {
57
- "@y14e/attribute-utils": "^2.0.8",
58
- "@y14e/roving-tabindex": "^3.1.27"
57
+ "@y14e/attribute-utils": "^2.0.10",
58
+ "@y14e/roving-tabindex": "^3.1.28"
59
59
  }
60
60
  }