@y14e/accordion 2.0.9 → 2.0.11

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.9";
16
+ import { Accordion } from "https://esm.sh/@y14e/accordion@2.0.11";
17
17
  // or
18
- import { Accordion } from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.9/+esm";
18
+ import { Accordion } from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.11/+esm";
19
19
  // or
20
- import { Accordion } from "https://esm.unpkg.com/@y14e/accordion@2.0.9";
20
+ import { Accordion } from "https://esm.unpkg.com/@y14e/accordion@2.0.11";
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -415,17 +415,9 @@ var RovingTabIndex = class _RovingTabIndex {
415
415
  noStart = false;
416
416
  }
417
417
  if (selector !== "") {
418
- let hasError = false;
419
- if (typeof selector !== "string" || !selector.trim()) {
420
- hasError = true;
421
- } else {
422
- try {
423
- this.#container.querySelector(selector);
424
- } catch {
425
- hasError = true;
426
- }
427
- }
428
- if (hasError) {
418
+ try {
419
+ document.querySelector(selector);
420
+ } catch {
429
421
  console.warn("Invalid selector. Fallback: no selector string.");
430
422
  selector = "";
431
423
  }
@@ -641,7 +633,10 @@ var Accordion = class _Accordion {
641
633
  static defaults = {};
642
634
  #rootElement;
643
635
  #defaults = {
644
- animation: { duration: 300, easing: "ease" },
636
+ animation: {
637
+ duration: 300,
638
+ easing: "ease"
639
+ },
645
640
  collapsible: true,
646
641
  selector: {
647
642
  content: "[data-accordion-content]",
@@ -892,12 +887,51 @@ var Accordion = class _Accordion {
892
887
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
893
888
  }
894
889
  #mergeOptions(target, source) {
895
- return {
890
+ const merged = {
896
891
  ...target,
897
892
  ...source,
898
893
  animation: { ...target.animation, ...source.animation ?? {} },
899
894
  selector: { ...target.selector, ...source.selector ?? {} }
900
895
  };
896
+ const mergedAnimation = merged.animation;
897
+ const duration = mergedAnimation.duration;
898
+ const defaultAnimation = this.#defaults.animation;
899
+ if (typeof duration !== "number" || Number.isNaN(duration)) {
900
+ const duration2 = defaultAnimation.duration;
901
+ console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
902
+ mergedAnimation.duration = duration2;
903
+ }
904
+ if (duration < 0) {
905
+ console.warn("Invalid animation duration. Fallback: 0 (ms).");
906
+ mergedAnimation.duration = 0;
907
+ }
908
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
909
+ const easing = defaultAnimation.easing;
910
+ console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
911
+ mergedAnimation.easing = easing;
912
+ }
913
+ if (typeof merged.collapsible !== "boolean") {
914
+ const collapsible = this.#defaults.collapsible;
915
+ console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
916
+ merged.collapsible = collapsible;
917
+ }
918
+ const mergedSelector = merged.selector;
919
+ const defaultSelector = this.#defaults.selector;
920
+ try {
921
+ document.querySelector(mergedSelector.content);
922
+ } catch {
923
+ const content = defaultSelector.content;
924
+ console.warn(`Invalid content selector. Fallback: '${content}'.`);
925
+ mergedSelector.content = content;
926
+ }
927
+ try {
928
+ document.querySelector(mergedSelector.trigger);
929
+ } catch {
930
+ const trigger = defaultSelector.trigger;
931
+ console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
932
+ mergedSelector.trigger = trigger;
933
+ }
934
+ return merged;
901
935
  }
902
936
  async #waitAnimationsFinish() {
903
937
  const promises = [];
@@ -917,7 +951,7 @@ function waitAnimationFinish(animation) {
917
951
  * Accordion
918
952
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
919
953
  *
920
- * @version 2.0.9
954
+ * @version 2.0.11
921
955
  * @author Yusuke Kamiyamane
922
956
  * @license MIT
923
957
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -942,7 +976,7 @@ power-focusable/dist/index.js:
942
976
  * High-precision focus management utility with full composed tree support.
943
977
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
944
978
  *
945
- * @version 4.3.26
979
+ * @version 4.3.28
946
980
  * @author Yusuke Kamiyamane
947
981
  * @license MIT
948
982
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -966,7 +1000,7 @@ power-focusable/dist/index.js:
966
1000
  * Lightweight roving tabindex utility with fully focus management.
967
1001
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
968
1002
  *
969
- * @version 3.1.23
1003
+ * @version 3.1.25
970
1004
  * @author Yusuke Kamiyamane
971
1005
  * @license MIT
972
1006
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -413,17 +413,9 @@ var RovingTabIndex = class _RovingTabIndex {
413
413
  noStart = false;
414
414
  }
415
415
  if (selector !== "") {
416
- let hasError = false;
417
- if (typeof selector !== "string" || !selector.trim()) {
418
- hasError = true;
419
- } else {
420
- try {
421
- this.#container.querySelector(selector);
422
- } catch {
423
- hasError = true;
424
- }
425
- }
426
- if (hasError) {
416
+ try {
417
+ document.querySelector(selector);
418
+ } catch {
427
419
  console.warn("Invalid selector. Fallback: no selector string.");
428
420
  selector = "";
429
421
  }
@@ -639,7 +631,10 @@ var Accordion = class _Accordion {
639
631
  static defaults = {};
640
632
  #rootElement;
641
633
  #defaults = {
642
- animation: { duration: 300, easing: "ease" },
634
+ animation: {
635
+ duration: 300,
636
+ easing: "ease"
637
+ },
643
638
  collapsible: true,
644
639
  selector: {
645
640
  content: "[data-accordion-content]",
@@ -890,12 +885,51 @@ var Accordion = class _Accordion {
890
885
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
891
886
  }
892
887
  #mergeOptions(target, source) {
893
- return {
888
+ const merged = {
894
889
  ...target,
895
890
  ...source,
896
891
  animation: { ...target.animation, ...source.animation ?? {} },
897
892
  selector: { ...target.selector, ...source.selector ?? {} }
898
893
  };
894
+ const mergedAnimation = merged.animation;
895
+ const duration = mergedAnimation.duration;
896
+ const defaultAnimation = this.#defaults.animation;
897
+ if (typeof duration !== "number" || Number.isNaN(duration)) {
898
+ const duration2 = defaultAnimation.duration;
899
+ console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
900
+ mergedAnimation.duration = duration2;
901
+ }
902
+ if (duration < 0) {
903
+ console.warn("Invalid animation duration. Fallback: 0 (ms).");
904
+ mergedAnimation.duration = 0;
905
+ }
906
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
907
+ const easing = defaultAnimation.easing;
908
+ console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
909
+ mergedAnimation.easing = easing;
910
+ }
911
+ if (typeof merged.collapsible !== "boolean") {
912
+ const collapsible = this.#defaults.collapsible;
913
+ console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
914
+ merged.collapsible = collapsible;
915
+ }
916
+ const mergedSelector = merged.selector;
917
+ const defaultSelector = this.#defaults.selector;
918
+ try {
919
+ document.querySelector(mergedSelector.content);
920
+ } catch {
921
+ const content = defaultSelector.content;
922
+ console.warn(`Invalid content selector. Fallback: '${content}'.`);
923
+ mergedSelector.content = content;
924
+ }
925
+ try {
926
+ document.querySelector(mergedSelector.trigger);
927
+ } catch {
928
+ const trigger = defaultSelector.trigger;
929
+ console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
930
+ mergedSelector.trigger = trigger;
931
+ }
932
+ return merged;
899
933
  }
900
934
  async #waitAnimationsFinish() {
901
935
  const promises = [];
@@ -915,7 +949,7 @@ function waitAnimationFinish(animation) {
915
949
  * Accordion
916
950
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
917
951
  *
918
- * @version 2.0.9
952
+ * @version 2.0.11
919
953
  * @author Yusuke Kamiyamane
920
954
  * @license MIT
921
955
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -940,7 +974,7 @@ power-focusable/dist/index.js:
940
974
  * High-precision focus management utility with full composed tree support.
941
975
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
942
976
  *
943
- * @version 4.3.26
977
+ * @version 4.3.28
944
978
  * @author Yusuke Kamiyamane
945
979
  * @license MIT
946
980
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -964,7 +998,7 @@ power-focusable/dist/index.js:
964
998
  * Lightweight roving tabindex utility with fully focus management.
965
999
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
966
1000
  *
967
- * @version 3.1.23
1001
+ * @version 3.1.25
968
1002
  * @author Yusuke Kamiyamane
969
1003
  * @license MIT
970
1004
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -29,7 +29,10 @@ var Accordion = class _Accordion {
29
29
  static defaults = {};
30
30
  #rootElement;
31
31
  #defaults = {
32
- animation: { duration: 300, easing: "ease" },
32
+ animation: {
33
+ duration: 300,
34
+ easing: "ease"
35
+ },
33
36
  collapsible: true,
34
37
  selector: {
35
38
  content: "[data-accordion-content]",
@@ -280,12 +283,51 @@ var Accordion = class _Accordion {
280
283
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
281
284
  }
282
285
  #mergeOptions(target, source) {
283
- return {
286
+ const merged = {
284
287
  ...target,
285
288
  ...source,
286
289
  animation: { ...target.animation, ...source.animation ?? {} },
287
290
  selector: { ...target.selector, ...source.selector ?? {} }
288
291
  };
292
+ const mergedAnimation = merged.animation;
293
+ const duration = mergedAnimation.duration;
294
+ const defaultAnimation = this.#defaults.animation;
295
+ if (typeof duration !== "number" || Number.isNaN(duration)) {
296
+ const duration2 = defaultAnimation.duration;
297
+ console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
298
+ mergedAnimation.duration = duration2;
299
+ }
300
+ if (duration < 0) {
301
+ console.warn("Invalid animation duration. Fallback: 0 (ms).");
302
+ mergedAnimation.duration = 0;
303
+ }
304
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
305
+ const easing = defaultAnimation.easing;
306
+ console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
307
+ mergedAnimation.easing = easing;
308
+ }
309
+ if (typeof merged.collapsible !== "boolean") {
310
+ const collapsible = this.#defaults.collapsible;
311
+ console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
312
+ merged.collapsible = collapsible;
313
+ }
314
+ const mergedSelector = merged.selector;
315
+ const defaultSelector = this.#defaults.selector;
316
+ try {
317
+ document.querySelector(mergedSelector.content);
318
+ } catch {
319
+ const content = defaultSelector.content;
320
+ console.warn(`Invalid content selector. Fallback: '${content}'.`);
321
+ mergedSelector.content = content;
322
+ }
323
+ try {
324
+ document.querySelector(mergedSelector.trigger);
325
+ } catch {
326
+ const trigger = defaultSelector.trigger;
327
+ console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
328
+ mergedSelector.trigger = trigger;
329
+ }
330
+ return merged;
289
331
  }
290
332
  async #waitAnimationsFinish() {
291
333
  const promises = [];
@@ -305,7 +347,7 @@ function waitAnimationFinish(animation) {
305
347
  * Accordion
306
348
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
307
349
  *
308
- * @version 2.0.9
350
+ * @version 2.0.11
309
351
  * @author Yusuke Kamiyamane
310
352
  * @license MIT
311
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.9
5
+ * @version 2.0.11
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.9
5
+ * @version 2.0.11
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -7,7 +7,10 @@ var Accordion = class _Accordion {
7
7
  static defaults = {};
8
8
  #rootElement;
9
9
  #defaults = {
10
- animation: { duration: 300, easing: "ease" },
10
+ animation: {
11
+ duration: 300,
12
+ easing: "ease"
13
+ },
11
14
  collapsible: true,
12
15
  selector: {
13
16
  content: "[data-accordion-content]",
@@ -258,12 +261,51 @@ var Accordion = class _Accordion {
258
261
  return !element.hasAttribute("disabled") && element.tabIndex >= 0;
259
262
  }
260
263
  #mergeOptions(target, source) {
261
- return {
264
+ const merged = {
262
265
  ...target,
263
266
  ...source,
264
267
  animation: { ...target.animation, ...source.animation ?? {} },
265
268
  selector: { ...target.selector, ...source.selector ?? {} }
266
269
  };
270
+ const mergedAnimation = merged.animation;
271
+ const duration = mergedAnimation.duration;
272
+ const defaultAnimation = this.#defaults.animation;
273
+ if (typeof duration !== "number" || Number.isNaN(duration)) {
274
+ const duration2 = defaultAnimation.duration;
275
+ console.warn(`Invalid animation duration. Fallback: ${duration2} (ms).`);
276
+ mergedAnimation.duration = duration2;
277
+ }
278
+ if (duration < 0) {
279
+ console.warn("Invalid animation duration. Fallback: 0 (ms).");
280
+ mergedAnimation.duration = 0;
281
+ }
282
+ if (!CSS.supports("animation-timing-function", mergedAnimation.easing)) {
283
+ const easing = defaultAnimation.easing;
284
+ console.warn(`Invalid animation easing. Fallback: '${easing}'.`);
285
+ mergedAnimation.easing = easing;
286
+ }
287
+ if (typeof merged.collapsible !== "boolean") {
288
+ const collapsible = this.#defaults.collapsible;
289
+ console.warn(`Invalid collapsible option. Fallback: ${collapsible}.`);
290
+ merged.collapsible = collapsible;
291
+ }
292
+ const mergedSelector = merged.selector;
293
+ const defaultSelector = this.#defaults.selector;
294
+ try {
295
+ document.querySelector(mergedSelector.content);
296
+ } catch {
297
+ const content = defaultSelector.content;
298
+ console.warn(`Invalid content selector. Fallback: '${content}'.`);
299
+ mergedSelector.content = content;
300
+ }
301
+ try {
302
+ document.querySelector(mergedSelector.trigger);
303
+ } catch {
304
+ const trigger = defaultSelector.trigger;
305
+ console.warn(`Invalid trigger selector. Fallback: '${trigger}'.`);
306
+ mergedSelector.trigger = trigger;
307
+ }
308
+ return merged;
267
309
  }
268
310
  async #waitAnimationsFinish() {
269
311
  const promises = [];
@@ -283,7 +325,7 @@ function waitAnimationFinish(animation) {
283
325
  * Accordion
284
326
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
285
327
  *
286
- * @version 2.0.9
328
+ * @version 2.0.11
287
329
  * @author Yusuke Kamiyamane
288
330
  * @license MIT
289
331
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,11 +1,27 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
+ "keywords": [
6
+ "a11y",
7
+ "accessibility",
8
+ "accordion",
9
+ "collapsible",
10
+ "component",
11
+ "typescript",
12
+ "utility"
13
+ ],
14
+ "homepage": "https://github.com/y14e/accordion#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/y14e/accordion/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/y14e/accordion.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
- "accordion",
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/accordion.git"
42
+ "lint": "tsc --noEmit",
43
+ "prepublishOnly": "npm run build"
40
44
  },
41
- "bugs": {
42
- "url": "https://github.com/y14e/accordion/issues"
43
- },
44
- "homepage": "https://github.com/y14e/accordion#readme",
45
45
  "devDependencies": {
46
46
  "bun-types": "latest",
47
47
  "tsup": "^8.0.0",
@@ -56,6 +56,6 @@
56
56
  "dependencies": {
57
57
  "@y14e/attribute-utils": "^2.0.5",
58
58
  "@y14e/button": "^1.0.8",
59
- "@y14e/roving-tabindex": "^3.1.23"
59
+ "@y14e/roving-tabindex": "^3.1.25"
60
60
  }
61
61
  }