@y14e/accordion 2.0.15 → 2.0.16

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.15';
16
+ import { Accordion } from 'https://esm.sh/@y14e/accordion@2.0.16';
17
17
  // or
18
- import { Accordion } from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.15/+esm';
18
+ import { Accordion } from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.16/+esm';
19
19
  // or
20
- import { Accordion } from 'https://esm.unpkg.com/@y14e/accordion@2.0.15';
20
+ import { Accordion } from 'https://esm.unpkg.com/@y14e/accordion@2.0.16';
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  // node_modules/@y14e/attribute-utils/dist/index.js
4
- var DEFAULT_PARSER = (value) => value.split(/\s+/);
5
- var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
4
+ var DEFAULT_PARSER = (v) => v.split(/\s+/);
5
+ var DEFAULT_SERIALIZER = (t) => t.join(" ");
6
6
  function addAttributeToken(element, name, token, options = {}) {
7
7
  if (!isValid(element, name, token)) {
8
8
  return;
@@ -12,7 +12,7 @@ function addAttributeToken(element, name, token, options = {}) {
12
12
  const tokens = value ? parse(value).filter(Boolean) : [];
13
13
  if (caseInsensitive) {
14
14
  const lower = token.toLowerCase();
15
- if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
15
+ if (tokens.every((t) => t.toLowerCase() !== lower)) {
16
16
  tokens.push(token);
17
17
  element.setAttribute(name, serialize(tokens));
18
18
  }
@@ -115,11 +115,11 @@ function getFocusables(container = document.body, options = {}) {
115
115
  skipNegativeTabIndexCheck,
116
116
  skipVisibilityCheck
117
117
  }) || include?.(node)) {
118
- candidates[candidates.length] = node;
118
+ candidates.push(node);
119
119
  }
120
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
120
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
121
121
  };
122
- (composed ? getComposedChildren(container) : getChildren(container)).map(
122
+ (composed ? getComposedChildren(container) : [...container.children]).map(
123
123
  traverse2
124
124
  );
125
125
  } else {
@@ -207,31 +207,31 @@ function normalizeRadioGroup(elements) {
207
207
  map = /* @__PURE__ */ new Map();
208
208
  }
209
209
  const root = element.getRootNode();
210
- let value = map.get(root);
211
- if (!value) {
212
- value = /* @__PURE__ */ new Map();
213
- map.set(root, value);
214
- }
215
- let v = value.get(element.form);
216
- if (!v) {
217
- v = /* @__PURE__ */ new Map();
218
- value.set(element.form, v);
219
- }
220
- let vv = v.get(element.name);
221
- if (!vv) {
222
- vv = [];
223
- v.set(element.name, vv);
224
- }
225
- vv[vv.length] = element;
210
+ let groups = map.get(root);
211
+ if (!groups) {
212
+ groups = /* @__PURE__ */ new Map();
213
+ map.set(root, groups);
214
+ }
215
+ let group = groups.get(element.form);
216
+ if (!group) {
217
+ group = /* @__PURE__ */ new Map();
218
+ groups.set(element.form, group);
219
+ }
220
+ let radios = group.get(element.name);
221
+ if (!radios) {
222
+ radios = [];
223
+ group.set(element.name, radios);
224
+ }
225
+ radios.push(element);
226
226
  }
227
227
  if (!map) {
228
228
  return elements;
229
229
  }
230
230
  const placeholder = /* @__PURE__ */ new Set();
231
- for (const value of map.values()) {
232
- for (const v of value.values()) {
233
- for (const vv of v.values()) {
234
- const radio = vv.find((element) => element.checked) ?? vv[0];
231
+ for (const groups of map.values()) {
232
+ for (const group of groups.values()) {
233
+ for (const radios of group.values()) {
234
+ const radio = radios.find((r) => r.checked) ?? radios[0];
235
235
  radio && placeholder.add(radio);
236
236
  }
237
237
  }
@@ -253,7 +253,7 @@ function sortByTabIndex(elements) {
253
253
  }
254
254
  function getComposedChildren(node) {
255
255
  if (node instanceof ShadowRoot) {
256
- return getChildren(node);
256
+ return [...node.children];
257
257
  }
258
258
  if (!(node instanceof Element)) {
259
259
  return [];
@@ -265,9 +265,9 @@ function getComposedChildren(node) {
265
265
  }
266
266
  }
267
267
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
268
- return getChildren(node.shadowRoot);
268
+ return [...node.shadowRoot.children];
269
269
  }
270
- return getChildren(node);
270
+ return [...node.children];
271
271
  }
272
272
  function focusElement(element) {
273
273
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -279,13 +279,6 @@ function getActiveElement() {
279
279
  }
280
280
  return current;
281
281
  }
282
- function getChildren(node) {
283
- const elements = [];
284
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
285
- elements[elements.length] = child;
286
- }
287
- return elements;
288
- }
289
282
  function getTabIndex(element) {
290
283
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
291
284
  }
@@ -492,7 +485,7 @@ var RovingTabIndex = class _RovingTabIndex {
492
485
  }
493
486
  }
494
487
  const candidates = this.#getFocusables().filter(
495
- (focusable2) => this.#focusables.has(focusable2)
488
+ (f) => this.#focusables.has(f)
496
489
  );
497
490
  const active = getActiveElement();
498
491
  if (!(active instanceof Element)) {
@@ -529,11 +522,9 @@ var RovingTabIndex = class _RovingTabIndex {
529
522
  const focusablesByFirstChar = new Set(
530
523
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
531
524
  );
532
- focusables = candidates.filter(
533
- (candidate) => focusablesByFirstChar.has(candidate)
534
- );
525
+ focusables = candidates.filter((c) => focusablesByFirstChar.has(c));
535
526
  const afterIndex = focusables.findIndex(
536
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
527
+ (f) => candidates.indexOf(f) > activeIndex
537
528
  );
538
529
  newIndex = afterIndex >= 0 ? afterIndex : 0;
539
530
  }
@@ -577,7 +568,7 @@ var RovingTabIndex = class _RovingTabIndex {
577
568
  const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
578
569
  const value = focusable.ariaKeyShortcuts?.trim();
579
570
  const keys = new Set(
580
- value ? value.split(/\s+/).filter((key) => /^\S$/i.test(key)).map((key) => key.toUpperCase()) : []
571
+ value ? value.split(/\s+/).filter((k) => /^\S$/i.test(k)).map((k) => k.toUpperCase()) : []
581
572
  );
582
573
  if (char) {
583
574
  keys.add(char);
@@ -869,7 +860,7 @@ var Accordion = class _Accordion {
869
860
  if (trigger.ariaExpanded === String(isExpand)) {
870
861
  return;
871
862
  }
872
- if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((trigger2) => trigger2.ariaExpanded === "true").length <= 1) {
863
+ if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((t) => t.ariaExpanded === "true").length <= 1) {
873
864
  return;
874
865
  }
875
866
  const name = trigger.getAttribute("data-accordion-name");
@@ -995,7 +986,7 @@ function waitAnimationFinish(animation) {
995
986
  * Accordion
996
987
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
997
988
  *
998
- * @version 2.0.15
989
+ * @version 2.0.16
999
990
  * @author Yusuke Kamiyamane
1000
991
  * @license MIT
1001
992
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1007,7 +998,7 @@ function waitAnimationFinish(animation) {
1007
998
  (**
1008
999
  * Attribute Utils
1009
1000
  *
1010
- * @version 2.0.10
1001
+ * @version 2.0.12
1011
1002
  * @author Yusuke Kamiyamane
1012
1003
  * @license MIT
1013
1004
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1020,7 +1011,7 @@ power-focusable/dist/index.js:
1020
1011
  * High-precision focus management utility with full composed tree support.
1021
1012
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
1022
1013
  *
1023
- * @version 4.3.30
1014
+ * @version 4.3.33
1024
1015
  * @author Yusuke Kamiyamane
1025
1016
  * @license MIT
1026
1017
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1044,7 +1035,7 @@ power-focusable/dist/index.js:
1044
1035
  * Lightweight roving tabindex utility with fully focus management.
1045
1036
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
1046
1037
  *
1047
- * @version 3.1.28
1038
+ * @version 3.1.31
1048
1039
  * @author Yusuke Kamiyamane
1049
1040
  * @license MIT
1050
1041
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1,6 +1,6 @@
1
1
  // node_modules/@y14e/attribute-utils/dist/index.js
2
- var DEFAULT_PARSER = (value) => value.split(/\s+/);
3
- var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
2
+ var DEFAULT_PARSER = (v) => v.split(/\s+/);
3
+ var DEFAULT_SERIALIZER = (t) => t.join(" ");
4
4
  function addAttributeToken(element, name, token, options = {}) {
5
5
  if (!isValid(element, name, token)) {
6
6
  return;
@@ -10,7 +10,7 @@ function addAttributeToken(element, name, token, options = {}) {
10
10
  const tokens = value ? parse(value).filter(Boolean) : [];
11
11
  if (caseInsensitive) {
12
12
  const lower = token.toLowerCase();
13
- if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
13
+ if (tokens.every((t) => t.toLowerCase() !== lower)) {
14
14
  tokens.push(token);
15
15
  element.setAttribute(name, serialize(tokens));
16
16
  }
@@ -113,11 +113,11 @@ function getFocusables(container = document.body, options = {}) {
113
113
  skipNegativeTabIndexCheck,
114
114
  skipVisibilityCheck
115
115
  }) || include?.(node)) {
116
- candidates[candidates.length] = node;
116
+ candidates.push(node);
117
117
  }
118
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
118
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
119
119
  };
120
- (composed ? getComposedChildren(container) : getChildren(container)).map(
120
+ (composed ? getComposedChildren(container) : [...container.children]).map(
121
121
  traverse2
122
122
  );
123
123
  } else {
@@ -205,31 +205,31 @@ function normalizeRadioGroup(elements) {
205
205
  map = /* @__PURE__ */ new Map();
206
206
  }
207
207
  const root = element.getRootNode();
208
- let value = map.get(root);
209
- if (!value) {
210
- value = /* @__PURE__ */ new Map();
211
- map.set(root, value);
212
- }
213
- let v = value.get(element.form);
214
- if (!v) {
215
- v = /* @__PURE__ */ new Map();
216
- value.set(element.form, v);
217
- }
218
- let vv = v.get(element.name);
219
- if (!vv) {
220
- vv = [];
221
- v.set(element.name, vv);
222
- }
223
- vv[vv.length] = element;
208
+ let groups = map.get(root);
209
+ if (!groups) {
210
+ groups = /* @__PURE__ */ new Map();
211
+ map.set(root, groups);
212
+ }
213
+ let group = groups.get(element.form);
214
+ if (!group) {
215
+ group = /* @__PURE__ */ new Map();
216
+ groups.set(element.form, group);
217
+ }
218
+ let radios = group.get(element.name);
219
+ if (!radios) {
220
+ radios = [];
221
+ group.set(element.name, radios);
222
+ }
223
+ radios.push(element);
224
224
  }
225
225
  if (!map) {
226
226
  return elements;
227
227
  }
228
228
  const placeholder = /* @__PURE__ */ new Set();
229
- for (const value of map.values()) {
230
- for (const v of value.values()) {
231
- for (const vv of v.values()) {
232
- const radio = vv.find((element) => element.checked) ?? vv[0];
229
+ for (const groups of map.values()) {
230
+ for (const group of groups.values()) {
231
+ for (const radios of group.values()) {
232
+ const radio = radios.find((r) => r.checked) ?? radios[0];
233
233
  radio && placeholder.add(radio);
234
234
  }
235
235
  }
@@ -251,7 +251,7 @@ function sortByTabIndex(elements) {
251
251
  }
252
252
  function getComposedChildren(node) {
253
253
  if (node instanceof ShadowRoot) {
254
- return getChildren(node);
254
+ return [...node.children];
255
255
  }
256
256
  if (!(node instanceof Element)) {
257
257
  return [];
@@ -263,9 +263,9 @@ function getComposedChildren(node) {
263
263
  }
264
264
  }
265
265
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
266
- return getChildren(node.shadowRoot);
266
+ return [...node.shadowRoot.children];
267
267
  }
268
- return getChildren(node);
268
+ return [...node.children];
269
269
  }
270
270
  function focusElement(element) {
271
271
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -277,13 +277,6 @@ function getActiveElement() {
277
277
  }
278
278
  return current;
279
279
  }
280
- function getChildren(node) {
281
- const elements = [];
282
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
283
- elements[elements.length] = child;
284
- }
285
- return elements;
286
- }
287
280
  function getTabIndex(element) {
288
281
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
289
282
  }
@@ -490,7 +483,7 @@ var RovingTabIndex = class _RovingTabIndex {
490
483
  }
491
484
  }
492
485
  const candidates = this.#getFocusables().filter(
493
- (focusable2) => this.#focusables.has(focusable2)
486
+ (f) => this.#focusables.has(f)
494
487
  );
495
488
  const active = getActiveElement();
496
489
  if (!(active instanceof Element)) {
@@ -527,11 +520,9 @@ var RovingTabIndex = class _RovingTabIndex {
527
520
  const focusablesByFirstChar = new Set(
528
521
  this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
529
522
  );
530
- focusables = candidates.filter(
531
- (candidate) => focusablesByFirstChar.has(candidate)
532
- );
523
+ focusables = candidates.filter((c) => focusablesByFirstChar.has(c));
533
524
  const afterIndex = focusables.findIndex(
534
- (focusable2) => candidates.indexOf(focusable2) > activeIndex
525
+ (f) => candidates.indexOf(f) > activeIndex
535
526
  );
536
527
  newIndex = afterIndex >= 0 ? afterIndex : 0;
537
528
  }
@@ -575,7 +566,7 @@ var RovingTabIndex = class _RovingTabIndex {
575
566
  const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
576
567
  const value = focusable.ariaKeyShortcuts?.trim();
577
568
  const keys = new Set(
578
- value ? value.split(/\s+/).filter((key) => /^\S$/i.test(key)).map((key) => key.toUpperCase()) : []
569
+ value ? value.split(/\s+/).filter((k) => /^\S$/i.test(k)).map((k) => k.toUpperCase()) : []
579
570
  );
580
571
  if (char) {
581
572
  keys.add(char);
@@ -867,7 +858,7 @@ var Accordion = class _Accordion {
867
858
  if (trigger.ariaExpanded === String(isExpand)) {
868
859
  return;
869
860
  }
870
- if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((trigger2) => trigger2.ariaExpanded === "true").length <= 1) {
861
+ if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((t) => t.ariaExpanded === "true").length <= 1) {
871
862
  return;
872
863
  }
873
864
  const name = trigger.getAttribute("data-accordion-name");
@@ -993,7 +984,7 @@ function waitAnimationFinish(animation) {
993
984
  * Accordion
994
985
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
995
986
  *
996
- * @version 2.0.15
987
+ * @version 2.0.16
997
988
  * @author Yusuke Kamiyamane
998
989
  * @license MIT
999
990
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1005,7 +996,7 @@ function waitAnimationFinish(animation) {
1005
996
  (**
1006
997
  * Attribute Utils
1007
998
  *
1008
- * @version 2.0.10
999
+ * @version 2.0.12
1009
1000
  * @author Yusuke Kamiyamane
1010
1001
  * @license MIT
1011
1002
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1018,7 +1009,7 @@ power-focusable/dist/index.js:
1018
1009
  * High-precision focus management utility with full composed tree support.
1019
1010
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
1020
1011
  *
1021
- * @version 4.3.30
1012
+ * @version 4.3.33
1022
1013
  * @author Yusuke Kamiyamane
1023
1014
  * @license MIT
1024
1015
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1042,7 +1033,7 @@ power-focusable/dist/index.js:
1042
1033
  * Lightweight roving tabindex utility with fully focus management.
1043
1034
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
1044
1035
  *
1045
- * @version 3.1.28
1036
+ * @version 3.1.31
1046
1037
  * @author Yusuke Kamiyamane
1047
1038
  * @license MIT
1048
1039
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -222,7 +222,7 @@ var Accordion = class _Accordion {
222
222
  if (trigger.ariaExpanded === String(isExpand)) {
223
223
  return;
224
224
  }
225
- if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((trigger2) => trigger2.ariaExpanded === "true").length <= 1) {
225
+ if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((t) => t.ariaExpanded === "true").length <= 1) {
226
226
  return;
227
227
  }
228
228
  const name = trigger.getAttribute("data-accordion-name");
@@ -348,7 +348,7 @@ function waitAnimationFinish(animation) {
348
348
  * Accordion
349
349
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
350
350
  *
351
- * @version 2.0.15
351
+ * @version 2.0.16
352
352
  * @author Yusuke Kamiyamane
353
353
  * @license MIT
354
354
  * @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.15
5
+ * @version 2.0.16
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.15
5
+ * @version 2.0.16
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -200,7 +200,7 @@ var Accordion = class _Accordion {
200
200
  if (trigger.ariaExpanded === String(isExpand)) {
201
201
  return;
202
202
  }
203
- if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((trigger2) => trigger2.ariaExpanded === "true").length <= 1) {
203
+ if (!isExpand && !isProgrammatic && !this.#settings.collapsible && this.#triggerElements.filter((t) => t.ariaExpanded === "true").length <= 1) {
204
204
  return;
205
205
  }
206
206
  const name = trigger.getAttribute("data-accordion-name");
@@ -326,7 +326,7 @@ function waitAnimationFinish(animation) {
326
326
  * Accordion
327
327
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
328
328
  *
329
- * @version 2.0.15
329
+ * @version 2.0.16
330
330
  * @author Yusuke Kamiyamane
331
331
  * @license MIT
332
332
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "keywords": [
6
6
  "a11y",
@@ -54,8 +54,8 @@
54
54
  "esbuild": true
55
55
  },
56
56
  "dependencies": {
57
- "@y14e/attribute-utils": "^2.0.10",
57
+ "@y14e/attribute-utils": "^2.0.12",
58
58
  "@y14e/button": "^1.0.8",
59
- "@y14e/roving-tabindex": "^3.1.28"
59
+ "@y14e/roving-tabindex": "^3.1.31"
60
60
  }
61
61
  }