@y14e/accordion 2.0.7 → 2.0.8

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // node_modules/@y14e/attribute-util/dist/index.js
3
+ // node_modules/@y14e/attribute-utils/dist/index.js
4
4
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
5
5
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
6
6
  function addAttributeToken(element, name, token, options = {}) {
@@ -368,6 +368,56 @@ var Button = class {
368
368
  };
369
369
  };
370
370
 
371
+ // node_modules/@y14e/attribute-util/dist/index.js
372
+ var DEFAULT_PARSER2 = (value) => value.split(/\s+/);
373
+ var DEFAULT_SERIALIZER2 = (tokens) => tokens.join(" ");
374
+ function addAttributeToken2(element, name, token, options = {}) {
375
+ const value = element.getAttribute(name)?.trim();
376
+ const {
377
+ caseInsensitive = false,
378
+ parse = DEFAULT_PARSER2,
379
+ serialize = DEFAULT_SERIALIZER2
380
+ } = options;
381
+ const tokens = value ? parse(value).filter(Boolean) : [];
382
+ if (caseInsensitive) {
383
+ const lower = token.toLowerCase();
384
+ if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
385
+ tokens.push(token);
386
+ element.setAttribute(name, serialize(tokens));
387
+ }
388
+ } else {
389
+ const set = new Set(tokens);
390
+ set.add(token);
391
+ element.setAttribute(name, serialize([...set]));
392
+ }
393
+ }
394
+ var snapshots2 = /* @__PURE__ */ new WeakMap();
395
+ function restoreAttributes2(element_or_elements) {
396
+ for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
397
+ const snapshot = snapshots2.get(element);
398
+ if (!snapshot) {
399
+ continue;
400
+ }
401
+ for (const [name, value] of snapshot.entries()) {
402
+ value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
403
+ }
404
+ snapshots2.delete(element);
405
+ }
406
+ }
407
+ function saveAttributes2(element_or_elements, name_or_names) {
408
+ const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
409
+ (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
410
+ let snapshot = snapshots2.get(element);
411
+ if (!snapshot) {
412
+ snapshot = /* @__PURE__ */ new Map();
413
+ snapshots2.set(element, snapshot);
414
+ }
415
+ names.forEach((name) => {
416
+ snapshot.set(name, element.getAttribute(name));
417
+ });
418
+ });
419
+ }
420
+
371
421
  // node_modules/@y14e/roving-tabindex/dist/index.js
372
422
  function createRovingTabIndex(container, options = {}) {
373
423
  if (!(container instanceof Element)) {
@@ -459,7 +509,7 @@ var RovingTabIndex = class _RovingTabIndex {
459
509
  this.#controller = null;
460
510
  this.#focusables.forEach((focusable) => {
461
511
  _RovingTabIndex.#initialized.delete(focusable);
462
- restoreAttributes(focusable);
512
+ restoreAttributes2(focusable);
463
513
  });
464
514
  this.#focusables.clear();
465
515
  this.#focusablesByFirstChar.clear();
@@ -564,7 +614,7 @@ var RovingTabIndex = class _RovingTabIndex {
564
614
  for (const focusable of this.#focusables) {
565
615
  if (!current.has(focusable)) {
566
616
  _RovingTabIndex.#initialized.delete(focusable);
567
- restoreAttributes(focusable);
617
+ restoreAttributes2(focusable);
568
618
  this.#focusables.delete(focusable);
569
619
  for (const [key, focusables] of this.#focusablesByFirstChar) {
570
620
  const index = focusables.indexOf(focusable);
@@ -586,7 +636,7 @@ var RovingTabIndex = class _RovingTabIndex {
586
636
  this.#focusables.add(focusable);
587
637
  _RovingTabIndex.#initialized.add(focusable);
588
638
  if (!navigationOnly) {
589
- saveAttributes(focusable, "tabindex");
639
+ saveAttributes2(focusable, "tabindex");
590
640
  focusable.setAttribute("tabindex", "-1");
591
641
  }
592
642
  if (!typeahead) {
@@ -599,8 +649,8 @@ var RovingTabIndex = class _RovingTabIndex {
599
649
  );
600
650
  if (char) {
601
651
  keys.add(char);
602
- saveAttributes(focusable, "aria-keyshortcuts");
603
- addAttributeToken(focusable, "aria-keyshortcuts", char, {
652
+ saveAttributes2(focusable, "aria-keyshortcuts");
653
+ addAttributeToken2(focusable, "aria-keyshortcuts", char, {
604
654
  caseInsensitive: true
605
655
  });
606
656
  }
@@ -917,7 +967,7 @@ function waitAnimationFinish(animation) {
917
967
  * Accordion
918
968
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
919
969
  *
920
- * @version 2.0.7
970
+ * @version 2.0.8
921
971
  * @author Yusuke Kamiyamane
922
972
  * @license MIT
923
973
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -925,15 +975,15 @@ function waitAnimationFinish(animation) {
925
975
  */
926
976
  /*! Bundled license information:
927
977
 
928
- @y14e/attribute-util/dist/index.js:
978
+ @y14e/attribute-utils/dist/index.js:
929
979
  (**
930
- * Attribute Util
980
+ * Attribute Utils
931
981
  *
932
- * @version 2.0.2
982
+ * @version 2.0.5
933
983
  * @author Yusuke Kamiyamane
934
984
  * @license MIT
935
985
  * @copyright Copyright (c) Yusuke Kamiyamane
936
- * @see {@link https://github.com/y14e/attribute-util}
986
+ * @see {@link https://github.com/y14e/attribute-utils}
937
987
  *)
938
988
 
939
989
  power-focusable/dist/index.js:
@@ -942,7 +992,7 @@ power-focusable/dist/index.js:
942
992
  * High-precision focus management utility with full composed tree support.
943
993
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
944
994
  *
945
- * @version 4.3.25
995
+ * @version 4.3.26
946
996
  * @author Yusuke Kamiyamane
947
997
  * @license MIT
948
998
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -960,6 +1010,17 @@ power-focusable/dist/index.js:
960
1010
  * @see {@link https://github.com/y14e/button}
961
1011
  *)
962
1012
 
1013
+ @y14e/attribute-util/dist/index.js:
1014
+ (**
1015
+ * Attribute Util
1016
+ *
1017
+ * @version 2.0.3
1018
+ * @author Yusuke Kamiyamane
1019
+ * @license MIT
1020
+ * @copyright Copyright (c) Yusuke Kamiyamane
1021
+ * @see {@link https://github.com/y14e/attribute-util}
1022
+ *)
1023
+
963
1024
  @y14e/roving-tabindex/dist/index.js:
964
1025
  (**
965
1026
  * Roving Tabindex
@@ -1,4 +1,4 @@
1
- // node_modules/@y14e/attribute-util/dist/index.js
1
+ // node_modules/@y14e/attribute-utils/dist/index.js
2
2
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
3
3
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
4
4
  function addAttributeToken(element, name, token, options = {}) {
@@ -366,6 +366,56 @@ var Button = class {
366
366
  };
367
367
  };
368
368
 
369
+ // node_modules/@y14e/attribute-util/dist/index.js
370
+ var DEFAULT_PARSER2 = (value) => value.split(/\s+/);
371
+ var DEFAULT_SERIALIZER2 = (tokens) => tokens.join(" ");
372
+ function addAttributeToken2(element, name, token, options = {}) {
373
+ const value = element.getAttribute(name)?.trim();
374
+ const {
375
+ caseInsensitive = false,
376
+ parse = DEFAULT_PARSER2,
377
+ serialize = DEFAULT_SERIALIZER2
378
+ } = options;
379
+ const tokens = value ? parse(value).filter(Boolean) : [];
380
+ if (caseInsensitive) {
381
+ const lower = token.toLowerCase();
382
+ if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
383
+ tokens.push(token);
384
+ element.setAttribute(name, serialize(tokens));
385
+ }
386
+ } else {
387
+ const set = new Set(tokens);
388
+ set.add(token);
389
+ element.setAttribute(name, serialize([...set]));
390
+ }
391
+ }
392
+ var snapshots2 = /* @__PURE__ */ new WeakMap();
393
+ function restoreAttributes2(element_or_elements) {
394
+ for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
395
+ const snapshot = snapshots2.get(element);
396
+ if (!snapshot) {
397
+ continue;
398
+ }
399
+ for (const [name, value] of snapshot.entries()) {
400
+ value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
401
+ }
402
+ snapshots2.delete(element);
403
+ }
404
+ }
405
+ function saveAttributes2(element_or_elements, name_or_names) {
406
+ const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
407
+ (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
408
+ let snapshot = snapshots2.get(element);
409
+ if (!snapshot) {
410
+ snapshot = /* @__PURE__ */ new Map();
411
+ snapshots2.set(element, snapshot);
412
+ }
413
+ names.forEach((name) => {
414
+ snapshot.set(name, element.getAttribute(name));
415
+ });
416
+ });
417
+ }
418
+
369
419
  // node_modules/@y14e/roving-tabindex/dist/index.js
370
420
  function createRovingTabIndex(container, options = {}) {
371
421
  if (!(container instanceof Element)) {
@@ -457,7 +507,7 @@ var RovingTabIndex = class _RovingTabIndex {
457
507
  this.#controller = null;
458
508
  this.#focusables.forEach((focusable) => {
459
509
  _RovingTabIndex.#initialized.delete(focusable);
460
- restoreAttributes(focusable);
510
+ restoreAttributes2(focusable);
461
511
  });
462
512
  this.#focusables.clear();
463
513
  this.#focusablesByFirstChar.clear();
@@ -562,7 +612,7 @@ var RovingTabIndex = class _RovingTabIndex {
562
612
  for (const focusable of this.#focusables) {
563
613
  if (!current.has(focusable)) {
564
614
  _RovingTabIndex.#initialized.delete(focusable);
565
- restoreAttributes(focusable);
615
+ restoreAttributes2(focusable);
566
616
  this.#focusables.delete(focusable);
567
617
  for (const [key, focusables] of this.#focusablesByFirstChar) {
568
618
  const index = focusables.indexOf(focusable);
@@ -584,7 +634,7 @@ var RovingTabIndex = class _RovingTabIndex {
584
634
  this.#focusables.add(focusable);
585
635
  _RovingTabIndex.#initialized.add(focusable);
586
636
  if (!navigationOnly) {
587
- saveAttributes(focusable, "tabindex");
637
+ saveAttributes2(focusable, "tabindex");
588
638
  focusable.setAttribute("tabindex", "-1");
589
639
  }
590
640
  if (!typeahead) {
@@ -597,8 +647,8 @@ var RovingTabIndex = class _RovingTabIndex {
597
647
  );
598
648
  if (char) {
599
649
  keys.add(char);
600
- saveAttributes(focusable, "aria-keyshortcuts");
601
- addAttributeToken(focusable, "aria-keyshortcuts", char, {
650
+ saveAttributes2(focusable, "aria-keyshortcuts");
651
+ addAttributeToken2(focusable, "aria-keyshortcuts", char, {
602
652
  caseInsensitive: true
603
653
  });
604
654
  }
@@ -915,7 +965,7 @@ function waitAnimationFinish(animation) {
915
965
  * Accordion
916
966
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
917
967
  *
918
- * @version 2.0.7
968
+ * @version 2.0.8
919
969
  * @author Yusuke Kamiyamane
920
970
  * @license MIT
921
971
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -923,15 +973,15 @@ function waitAnimationFinish(animation) {
923
973
  */
924
974
  /*! Bundled license information:
925
975
 
926
- @y14e/attribute-util/dist/index.js:
976
+ @y14e/attribute-utils/dist/index.js:
927
977
  (**
928
- * Attribute Util
978
+ * Attribute Utils
929
979
  *
930
- * @version 2.0.2
980
+ * @version 2.0.5
931
981
  * @author Yusuke Kamiyamane
932
982
  * @license MIT
933
983
  * @copyright Copyright (c) Yusuke Kamiyamane
934
- * @see {@link https://github.com/y14e/attribute-util}
984
+ * @see {@link https://github.com/y14e/attribute-utils}
935
985
  *)
936
986
 
937
987
  power-focusable/dist/index.js:
@@ -940,7 +990,7 @@ power-focusable/dist/index.js:
940
990
  * High-precision focus management utility with full composed tree support.
941
991
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
942
992
  *
943
- * @version 4.3.25
993
+ * @version 4.3.26
944
994
  * @author Yusuke Kamiyamane
945
995
  * @license MIT
946
996
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -958,6 +1008,17 @@ power-focusable/dist/index.js:
958
1008
  * @see {@link https://github.com/y14e/button}
959
1009
  *)
960
1010
 
1011
+ @y14e/attribute-util/dist/index.js:
1012
+ (**
1013
+ * Attribute Util
1014
+ *
1015
+ * @version 2.0.3
1016
+ * @author Yusuke Kamiyamane
1017
+ * @license MIT
1018
+ * @copyright Copyright (c) Yusuke Kamiyamane
1019
+ * @see {@link https://github.com/y14e/attribute-util}
1020
+ *)
1021
+
961
1022
  @y14e/roving-tabindex/dist/index.js:
962
1023
  (**
963
1024
  * Roving Tabindex
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var util = require('@y14e/attribute-util');
3
+ var utils = require('@y14e/attribute-utils');
4
4
  var button = require('@y14e/button');
5
5
  var rovingTabindex = require('@y14e/roving-tabindex');
6
6
 
@@ -22,7 +22,7 @@ function _interopNamespace(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
 
25
- var util__namespace = /*#__PURE__*/_interopNamespace(util);
25
+ var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
26
26
 
27
27
  // src/index.ts
28
28
  var Accordion = class _Accordion {
@@ -118,7 +118,7 @@ var Accordion = class _Accordion {
118
118
  });
119
119
  this.#animationController?.abort();
120
120
  this.#animationController = null;
121
- util__namespace.restoreAttributes([
121
+ utils__namespace.restoreAttributes([
122
122
  ...this.#triggerElements,
123
123
  ...this.#contentElements
124
124
  ]);
@@ -137,14 +137,14 @@ var Accordion = class _Accordion {
137
137
  this.#toggle(trigger, true);
138
138
  }
139
139
  #initialize() {
140
- util__namespace.saveAttributes(this.#triggerElements, [
140
+ utils__namespace.saveAttributes(this.#triggerElements, [
141
141
  "aria-controls",
142
142
  "aria-disabled",
143
143
  "id",
144
144
  "style",
145
145
  "tabindex"
146
146
  ]);
147
- util__namespace.saveAttributes(this.#contentElements, [
147
+ utils__namespace.saveAttributes(this.#contentElements, [
148
148
  "aria-labelledby",
149
149
  "id",
150
150
  "role"
@@ -158,7 +158,7 @@ var Accordion = class _Accordion {
158
158
  return;
159
159
  }
160
160
  content2.id ||= `accordion-content-${id}`;
161
- util__namespace.addAttributeToken(trigger2, "aria-controls", content2.id);
161
+ utils__namespace.addAttributeToken(trigger2, "aria-controls", content2.id);
162
162
  trigger2.setAttribute(
163
163
  "aria-expanded",
164
164
  String(trigger2.ariaExpanded === "true")
@@ -170,7 +170,7 @@ var Accordion = class _Accordion {
170
170
  trigger2.style.setProperty("pointer-events", "none");
171
171
  }
172
172
  trigger2.addEventListener("click", this.#onTriggerClick, { signal });
173
- util__namespace.addAttributeToken(content2, "aria-labelledby", trigger2.id);
173
+ utils__namespace.addAttributeToken(content2, "aria-labelledby", trigger2.id);
174
174
  content2.setAttribute("role", "region");
175
175
  content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
176
176
  signal
@@ -305,7 +305,7 @@ function waitAnimationFinish(animation) {
305
305
  * Accordion
306
306
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
307
307
  *
308
- * @version 2.0.7
308
+ * @version 2.0.8
309
309
  * @author Yusuke Kamiyamane
310
310
  * @license MIT
311
311
  * @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.7
5
+ * @version 2.0.8
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.7
5
+ * @version 2.0.8
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as util from '@y14e/attribute-util';
1
+ import * as utils from '@y14e/attribute-utils';
2
2
  import { Button } from '@y14e/button';
3
3
  import { createRovingTabIndex } from '@y14e/roving-tabindex';
4
4
 
@@ -96,7 +96,7 @@ var Accordion = class _Accordion {
96
96
  });
97
97
  this.#animationController?.abort();
98
98
  this.#animationController = null;
99
- util.restoreAttributes([
99
+ utils.restoreAttributes([
100
100
  ...this.#triggerElements,
101
101
  ...this.#contentElements
102
102
  ]);
@@ -115,14 +115,14 @@ var Accordion = class _Accordion {
115
115
  this.#toggle(trigger, true);
116
116
  }
117
117
  #initialize() {
118
- util.saveAttributes(this.#triggerElements, [
118
+ utils.saveAttributes(this.#triggerElements, [
119
119
  "aria-controls",
120
120
  "aria-disabled",
121
121
  "id",
122
122
  "style",
123
123
  "tabindex"
124
124
  ]);
125
- util.saveAttributes(this.#contentElements, [
125
+ utils.saveAttributes(this.#contentElements, [
126
126
  "aria-labelledby",
127
127
  "id",
128
128
  "role"
@@ -136,7 +136,7 @@ var Accordion = class _Accordion {
136
136
  return;
137
137
  }
138
138
  content2.id ||= `accordion-content-${id}`;
139
- util.addAttributeToken(trigger2, "aria-controls", content2.id);
139
+ utils.addAttributeToken(trigger2, "aria-controls", content2.id);
140
140
  trigger2.setAttribute(
141
141
  "aria-expanded",
142
142
  String(trigger2.ariaExpanded === "true")
@@ -148,7 +148,7 @@ var Accordion = class _Accordion {
148
148
  trigger2.style.setProperty("pointer-events", "none");
149
149
  }
150
150
  trigger2.addEventListener("click", this.#onTriggerClick, { signal });
151
- util.addAttributeToken(content2, "aria-labelledby", trigger2.id);
151
+ utils.addAttributeToken(content2, "aria-labelledby", trigger2.id);
152
152
  content2.setAttribute("role", "region");
153
153
  content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
154
154
  signal
@@ -283,7 +283,7 @@ function waitAnimationFinish(animation) {
283
283
  * Accordion
284
284
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
285
285
  *
286
- * @version 2.0.7
286
+ * @version 2.0.8
287
287
  * @author Yusuke Kamiyamane
288
288
  * @license MIT
289
289
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -54,7 +54,7 @@
54
54
  "esbuild": true
55
55
  },
56
56
  "dependencies": {
57
- "@y14e/attribute-util": "^2.0.2",
57
+ "@y14e/attribute-utils": "^2.0.5",
58
58
  "@y14e/button": "^1.0.8",
59
59
  "@y14e/roving-tabindex": "^3.1.22"
60
60
  }