@y14e/accordion 2.0.10 → 2.0.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 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@2.0.10";
16
+ import { Accordion } from "https://esm.sh/@y14e/accordion@2.0.12";
17
17
  // or
18
- import { Accordion } from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.10/+esm";
18
+ import { Accordion } from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.12/+esm";
19
19
  // or
20
- import { Accordion } from "https://esm.unpkg.com/@y14e/accordion@2.0.10";
20
+ import { Accordion } from "https://esm.unpkg.com/@y14e/accordion@2.0.12";
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -661,8 +661,8 @@ var Accordion = class _Accordion {
661
661
  return;
662
662
  }
663
663
  this.#rootElement = root;
664
- this.#defaults = this.#mergeOptions(this.#defaults, _Accordion.defaults);
665
- this.#settings = this.#mergeOptions(this.#defaults, options);
664
+ this.#defaults = this.#resolveOptions(this.#defaults, _Accordion.defaults);
665
+ this.#settings = this.#resolveOptions(this.#defaults, options);
666
666
  matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
667
667
  const { trigger, content } = this.#settings.selector;
668
668
  const NOT_NESTED = `:not(:scope ${content} *)`;
@@ -886,48 +886,50 @@ var Accordion = class _Accordion {
886
886
  #isFocusable(element) {
887
887
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
888
888
  }
889
- #mergeOptions(target, source) {
889
+ #resolveOptions(target, source) {
890
890
  const merged = {
891
891
  ...target,
892
892
  ...source,
893
893
  animation: { ...target.animation, ...source.animation ?? {} },
894
894
  selector: { ...target.selector, ...source.selector ?? {} }
895
895
  };
896
- const animation = merged.animation;
897
- const duration = animation.duration;
896
+ const mergedAnimation = merged.animation;
897
+ const duration = mergedAnimation.duration;
898
+ const defaultAnimation = this.#defaults.animation;
898
899
  if (typeof duration !== "number" || Number.isNaN(duration)) {
899
- const duration2 = this.#defaults.animation.duration;
900
+ const duration2 = defaultAnimation.duration;
900
901
  console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
901
- animation.duration = duration2;
902
+ mergedAnimation.duration = duration2;
902
903
  }
903
904
  if (duration < 0) {
904
905
  console.warn("Invalid animation duration. Fallback: 0 (ms).");
905
- animation.duration = 0;
906
+ mergedAnimation.duration = 0;
906
907
  }
907
- if (!CSS.supports("animation-timing-function", animation.easing)) {
908
- const easing = this.#defaults.animation.easing;
908
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
909
+ const easing = defaultAnimation.easing;
909
910
  console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
910
- animation.easing = easing;
911
+ mergedAnimation.easing = easing;
911
912
  }
912
913
  if (typeof merged.collapsible !== "boolean") {
913
914
  const collapsible = this.#defaults.collapsible;
914
915
  console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
915
916
  merged.collapsible = collapsible;
916
917
  }
917
- const selector = merged.selector;
918
+ const mergedSelector = merged.selector;
919
+ const defaultSelector = this.#defaults.selector;
918
920
  try {
919
- document.querySelector(selector.content);
921
+ document.querySelector(mergedSelector.content);
920
922
  } catch {
921
- const content = this.#defaults.selector.content;
923
+ const content = defaultSelector.content;
922
924
  console.warn(`Invalid content selector. Fallback: '${content}'.`);
923
- selector.content = content;
925
+ mergedSelector.content = content;
924
926
  }
925
927
  try {
926
- document.querySelector(selector.trigger);
928
+ document.querySelector(mergedSelector.trigger);
927
929
  } catch {
928
- const trigger = this.#defaults.selector.trigger;
930
+ const trigger = defaultSelector.trigger;
929
931
  console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
930
- selector.trigger = trigger;
932
+ mergedSelector.trigger = trigger;
931
933
  }
932
934
  return merged;
933
935
  }
@@ -949,7 +951,7 @@ function waitAnimationFinish(animation) {
949
951
  * Accordion
950
952
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
951
953
  *
952
- * @version 2.0.10
954
+ * @version 2.0.12
953
955
  * @author Yusuke Kamiyamane
954
956
  * @license MIT
955
957
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -659,8 +659,8 @@ var Accordion = class _Accordion {
659
659
  return;
660
660
  }
661
661
  this.#rootElement = root;
662
- this.#defaults = this.#mergeOptions(this.#defaults, _Accordion.defaults);
663
- this.#settings = this.#mergeOptions(this.#defaults, options);
662
+ this.#defaults = this.#resolveOptions(this.#defaults, _Accordion.defaults);
663
+ this.#settings = this.#resolveOptions(this.#defaults, options);
664
664
  matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
665
665
  const { trigger, content } = this.#settings.selector;
666
666
  const NOT_NESTED = `:not(:scope ${content} *)`;
@@ -884,48 +884,50 @@ var Accordion = class _Accordion {
884
884
  #isFocusable(element) {
885
885
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
886
886
  }
887
- #mergeOptions(target, source) {
887
+ #resolveOptions(target, source) {
888
888
  const merged = {
889
889
  ...target,
890
890
  ...source,
891
891
  animation: { ...target.animation, ...source.animation ?? {} },
892
892
  selector: { ...target.selector, ...source.selector ?? {} }
893
893
  };
894
- const animation = merged.animation;
895
- const duration = animation.duration;
894
+ const mergedAnimation = merged.animation;
895
+ const duration = mergedAnimation.duration;
896
+ const defaultAnimation = this.#defaults.animation;
896
897
  if (typeof duration !== "number" || Number.isNaN(duration)) {
897
- const duration2 = this.#defaults.animation.duration;
898
+ const duration2 = defaultAnimation.duration;
898
899
  console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
899
- animation.duration = duration2;
900
+ mergedAnimation.duration = duration2;
900
901
  }
901
902
  if (duration < 0) {
902
903
  console.warn("Invalid animation duration. Fallback: 0 (ms).");
903
- animation.duration = 0;
904
+ mergedAnimation.duration = 0;
904
905
  }
905
- if (!CSS.supports("animation-timing-function", animation.easing)) {
906
- const easing = this.#defaults.animation.easing;
906
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
907
+ const easing = defaultAnimation.easing;
907
908
  console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
908
- animation.easing = easing;
909
+ mergedAnimation.easing = easing;
909
910
  }
910
911
  if (typeof merged.collapsible !== "boolean") {
911
912
  const collapsible = this.#defaults.collapsible;
912
913
  console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
913
914
  merged.collapsible = collapsible;
914
915
  }
915
- const selector = merged.selector;
916
+ const mergedSelector = merged.selector;
917
+ const defaultSelector = this.#defaults.selector;
916
918
  try {
917
- document.querySelector(selector.content);
919
+ document.querySelector(mergedSelector.content);
918
920
  } catch {
919
- const content = this.#defaults.selector.content;
921
+ const content = defaultSelector.content;
920
922
  console.warn(`Invalid content selector. Fallback: '${content}'.`);
921
- selector.content = content;
923
+ mergedSelector.content = content;
922
924
  }
923
925
  try {
924
- document.querySelector(selector.trigger);
926
+ document.querySelector(mergedSelector.trigger);
925
927
  } catch {
926
- const trigger = this.#defaults.selector.trigger;
928
+ const trigger = defaultSelector.trigger;
927
929
  console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
928
- selector.trigger = trigger;
930
+ mergedSelector.trigger = trigger;
929
931
  }
930
932
  return merged;
931
933
  }
@@ -947,7 +949,7 @@ function waitAnimationFinish(animation) {
947
949
  * Accordion
948
950
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
949
951
  *
950
- * @version 2.0.10
952
+ * @version 2.0.12
951
953
  * @author Yusuke Kamiyamane
952
954
  * @license MIT
953
955
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -57,8 +57,8 @@ var Accordion = class _Accordion {
57
57
  return;
58
58
  }
59
59
  this.#rootElement = root;
60
- this.#defaults = this.#mergeOptions(this.#defaults, _Accordion.defaults);
61
- this.#settings = this.#mergeOptions(this.#defaults, options);
60
+ this.#defaults = this.#resolveOptions(this.#defaults, _Accordion.defaults);
61
+ this.#settings = this.#resolveOptions(this.#defaults, options);
62
62
  matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
63
63
  const { trigger, content } = this.#settings.selector;
64
64
  const NOT_NESTED = `:not(:scope ${content} *)`;
@@ -282,48 +282,50 @@ var Accordion = class _Accordion {
282
282
  #isFocusable(element) {
283
283
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
284
284
  }
285
- #mergeOptions(target, source) {
285
+ #resolveOptions(target, source) {
286
286
  const merged = {
287
287
  ...target,
288
288
  ...source,
289
289
  animation: { ...target.animation, ...source.animation ?? {} },
290
290
  selector: { ...target.selector, ...source.selector ?? {} }
291
291
  };
292
- const animation = merged.animation;
293
- const duration = animation.duration;
292
+ const mergedAnimation = merged.animation;
293
+ const duration = mergedAnimation.duration;
294
+ const defaultAnimation = this.#defaults.animation;
294
295
  if (typeof duration !== "number" || Number.isNaN(duration)) {
295
- const duration2 = this.#defaults.animation.duration;
296
+ const duration2 = defaultAnimation.duration;
296
297
  console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
297
- animation.duration = duration2;
298
+ mergedAnimation.duration = duration2;
298
299
  }
299
300
  if (duration < 0) {
300
301
  console.warn("Invalid animation duration. Fallback: 0 (ms).");
301
- animation.duration = 0;
302
+ mergedAnimation.duration = 0;
302
303
  }
303
- if (!CSS.supports("animation-timing-function", animation.easing)) {
304
- const easing = this.#defaults.animation.easing;
304
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
305
+ const easing = defaultAnimation.easing;
305
306
  console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
306
- animation.easing = easing;
307
+ mergedAnimation.easing = easing;
307
308
  }
308
309
  if (typeof merged.collapsible !== "boolean") {
309
310
  const collapsible = this.#defaults.collapsible;
310
311
  console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
311
312
  merged.collapsible = collapsible;
312
313
  }
313
- const selector = merged.selector;
314
+ const mergedSelector = merged.selector;
315
+ const defaultSelector = this.#defaults.selector;
314
316
  try {
315
- document.querySelector(selector.content);
317
+ document.querySelector(mergedSelector.content);
316
318
  } catch {
317
- const content = this.#defaults.selector.content;
319
+ const content = defaultSelector.content;
318
320
  console.warn(`Invalid content selector. Fallback: '${content}'.`);
319
- selector.content = content;
321
+ mergedSelector.content = content;
320
322
  }
321
323
  try {
322
- document.querySelector(selector.trigger);
324
+ document.querySelector(mergedSelector.trigger);
323
325
  } catch {
324
- const trigger = this.#defaults.selector.trigger;
326
+ const trigger = defaultSelector.trigger;
325
327
  console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
326
- selector.trigger = trigger;
328
+ mergedSelector.trigger = trigger;
327
329
  }
328
330
  return merged;
329
331
  }
@@ -345,7 +347,7 @@ function waitAnimationFinish(animation) {
345
347
  * Accordion
346
348
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
347
349
  *
348
- * @version 2.0.10
350
+ * @version 2.0.12
349
351
  * @author Yusuke Kamiyamane
350
352
  * @license MIT
351
353
  * @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 2.0.10
5
+ * @version 2.0.12
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
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 2.0.10
5
+ * @version 2.0.12
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -35,8 +35,8 @@ var Accordion = class _Accordion {
35
35
  return;
36
36
  }
37
37
  this.#rootElement = root;
38
- this.#defaults = this.#mergeOptions(this.#defaults, _Accordion.defaults);
39
- this.#settings = this.#mergeOptions(this.#defaults, options);
38
+ this.#defaults = this.#resolveOptions(this.#defaults, _Accordion.defaults);
39
+ this.#settings = this.#resolveOptions(this.#defaults, options);
40
40
  matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
41
41
  const { trigger, content } = this.#settings.selector;
42
42
  const NOT_NESTED = `:not(:scope ${content} *)`;
@@ -260,48 +260,50 @@ var Accordion = class _Accordion {
260
260
  #isFocusable(element) {
261
261
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
262
262
  }
263
- #mergeOptions(target, source) {
263
+ #resolveOptions(target, source) {
264
264
  const merged = {
265
265
  ...target,
266
266
  ...source,
267
267
  animation: { ...target.animation, ...source.animation ?? {} },
268
268
  selector: { ...target.selector, ...source.selector ?? {} }
269
269
  };
270
- const animation = merged.animation;
271
- const duration = animation.duration;
270
+ const mergedAnimation = merged.animation;
271
+ const duration = mergedAnimation.duration;
272
+ const defaultAnimation = this.#defaults.animation;
272
273
  if (typeof duration !== "number" || Number.isNaN(duration)) {
273
- const duration2 = this.#defaults.animation.duration;
274
+ const duration2 = defaultAnimation.duration;
274
275
  console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
275
- animation.duration = duration2;
276
+ mergedAnimation.duration = duration2;
276
277
  }
277
278
  if (duration < 0) {
278
279
  console.warn("Invalid animation duration. Fallback: 0 (ms).");
279
- animation.duration = 0;
280
+ mergedAnimation.duration = 0;
280
281
  }
281
- if (!CSS.supports("animation-timing-function", animation.easing)) {
282
- const easing = this.#defaults.animation.easing;
282
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
283
+ const easing = defaultAnimation.easing;
283
284
  console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
284
- animation.easing = easing;
285
+ mergedAnimation.easing = easing;
285
286
  }
286
287
  if (typeof merged.collapsible !== "boolean") {
287
288
  const collapsible = this.#defaults.collapsible;
288
289
  console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
289
290
  merged.collapsible = collapsible;
290
291
  }
291
- const selector = merged.selector;
292
+ const mergedSelector = merged.selector;
293
+ const defaultSelector = this.#defaults.selector;
292
294
  try {
293
- document.querySelector(selector.content);
295
+ document.querySelector(mergedSelector.content);
294
296
  } catch {
295
- const content = this.#defaults.selector.content;
297
+ const content = defaultSelector.content;
296
298
  console.warn(`Invalid content selector. Fallback: '${content}'.`);
297
- selector.content = content;
299
+ mergedSelector.content = content;
298
300
  }
299
301
  try {
300
- document.querySelector(selector.trigger);
302
+ document.querySelector(mergedSelector.trigger);
301
303
  } catch {
302
- const trigger = this.#defaults.selector.trigger;
304
+ const trigger = defaultSelector.trigger;
303
305
  console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
304
- selector.trigger = trigger;
306
+ mergedSelector.trigger = trigger;
305
307
  }
306
308
  return merged;
307
309
  }
@@ -323,7 +325,7 @@ function waitAnimationFinish(animation) {
323
325
  * Accordion
324
326
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
325
327
  *
326
- * @version 2.0.10
328
+ * @version 2.0.12
327
329
  * @author Yusuke Kamiyamane
328
330
  * @license MIT
329
331
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "keywords": [
6
6
  "a11y",