@y14e/disclosure 2.0.4 → 2.0.6

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/disclosure
13
13
  import Disclosure from "@y14e/disclosure";
14
14
 
15
15
  // CDNs
16
- import Disclosure from "https://esm.sh/@y14e/disclosure@2.0.4";
16
+ import Disclosure from "https://esm.sh/@y14e/disclosure@2.0.6";
17
17
  // or
18
- import Disclosure from "https://cdn.jsdelivr.net/npm/@y14e/disclosure@2.0.4/+esm";
18
+ import Disclosure from "https://cdn.jsdelivr.net/npm/@y14e/disclosure@2.0.6/+esm";
19
19
  // or
20
- import Disclosure from "https://esm.unpkg.com/@y14e/disclosure@2.0.4";
20
+ import Disclosure from "https://esm.unpkg.com/@y14e/disclosure@2.0.6";
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -35,8 +35,8 @@ new Disclosure(root, options);
35
35
  ```ts
36
36
  interface DisclosureOptions {
37
37
  animation: {
38
- duration: number; // ms (default: 300)
39
- easing: string; // <easing-function> (default: 'ease')
38
+ duration: number; // ms (default: 300)
39
+ easing: string; // <easing-function> (default: 'ease')
40
40
  };
41
41
  collapsible: boolean; // default: true
42
42
  }
@@ -1,37 +1,9 @@
1
1
  'use strict';
2
2
 
3
- // node_modules/@y14e/attributes-utils/dist/index.js
4
- var snapshots = /* @__PURE__ */ new WeakMap();
5
- function restoreAttributes(element_or_elements) {
6
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
7
- const snapshot = snapshots.get(element);
8
- if (!snapshot) {
9
- continue;
10
- }
11
- for (const [name, value] of snapshot.entries()) {
12
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
13
- }
14
- snapshots.delete(element);
15
- }
16
- }
17
- function saveAttributes(element_or_elements, name_or_names) {
18
- const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
19
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
20
- let snapshot = snapshots.get(element);
21
- if (!snapshot) {
22
- snapshot = /* @__PURE__ */ new Map();
23
- snapshots.set(element, snapshot);
24
- }
25
- names.forEach((name) => {
26
- snapshot.set(name, element.getAttribute(name));
27
- });
28
- });
29
- }
30
-
31
- // node_modules/@y14e/roving-tabindex/node_modules/@y14e/attributes-utils/dist/index.js
3
+ // node_modules/@y14e/attribute-util/dist/index.js
32
4
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
33
5
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
34
- function addTokenToAttribute(element, name, token, options = {}) {
6
+ function addAttributeToken(element, name, token, options = {}) {
35
7
  const value = element.getAttribute(name)?.trim();
36
8
  const {
37
9
  caseInsensitive = false,
@@ -51,26 +23,26 @@ function addTokenToAttribute(element, name, token, options = {}) {
51
23
  element.setAttribute(name, serialize([...set]));
52
24
  }
53
25
  }
54
- var snapshots2 = /* @__PURE__ */ new WeakMap();
55
- function restoreAttributes2(element_or_elements) {
26
+ var snapshots = /* @__PURE__ */ new WeakMap();
27
+ function restoreAttributes(element_or_elements) {
56
28
  for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
57
- const snapshot = snapshots2.get(element);
29
+ const snapshot = snapshots.get(element);
58
30
  if (!snapshot) {
59
31
  continue;
60
32
  }
61
33
  for (const [name, value] of snapshot.entries()) {
62
34
  value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
63
35
  }
64
- snapshots2.delete(element);
36
+ snapshots.delete(element);
65
37
  }
66
38
  }
67
- function saveAttributes2(element_or_elements, name_or_names) {
39
+ function saveAttributes(element_or_elements, name_or_names) {
68
40
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
69
41
  (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
70
- let snapshot = snapshots2.get(element);
42
+ let snapshot = snapshots.get(element);
71
43
  if (!snapshot) {
72
44
  snapshot = /* @__PURE__ */ new Map();
73
- snapshots2.set(element, snapshot);
45
+ snapshots.set(element, snapshot);
74
46
  }
75
47
  names.forEach((name) => {
76
48
  snapshot.set(name, element.getAttribute(name));
@@ -438,7 +410,7 @@ var RovingTabIndex = class _RovingTabIndex {
438
410
  this.#controller = null;
439
411
  this.#focusables.forEach((focusable) => {
440
412
  _RovingTabIndex.#initialized.delete(focusable);
441
- restoreAttributes2(focusable);
413
+ restoreAttributes(focusable);
442
414
  });
443
415
  this.#focusables.clear();
444
416
  this.#focusablesByFirstChar.clear();
@@ -543,7 +515,7 @@ var RovingTabIndex = class _RovingTabIndex {
543
515
  for (const focusable of this.#focusables) {
544
516
  if (!current.has(focusable)) {
545
517
  _RovingTabIndex.#initialized.delete(focusable);
546
- restoreAttributes2(focusable);
518
+ restoreAttributes(focusable);
547
519
  this.#focusables.delete(focusable);
548
520
  for (const [key, focusables] of this.#focusablesByFirstChar) {
549
521
  const index = focusables.indexOf(focusable);
@@ -565,7 +537,7 @@ var RovingTabIndex = class _RovingTabIndex {
565
537
  this.#focusables.add(focusable);
566
538
  _RovingTabIndex.#initialized.add(focusable);
567
539
  if (!navigationOnly) {
568
- saveAttributes2(focusable, "tabindex");
540
+ saveAttributes(focusable, "tabindex");
569
541
  focusable.setAttribute("tabindex", "-1");
570
542
  }
571
543
  if (!typeahead) {
@@ -578,8 +550,8 @@ var RovingTabIndex = class _RovingTabIndex {
578
550
  );
579
551
  if (char) {
580
552
  keys.add(char);
581
- saveAttributes2(focusable, "aria-keyshortcuts");
582
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
553
+ saveAttributes(focusable, "aria-keyshortcuts");
554
+ addAttributeToken(focusable, "aria-keyshortcuts", char, {
583
555
  caseInsensitive: true
584
556
  });
585
557
  }
@@ -895,7 +867,7 @@ function waitAnimationFinish(animation) {
895
867
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
896
868
  * Using the <details> and <summary> element.
897
869
  *
898
- * @version 2.0.4
870
+ * @version 2.0.6
899
871
  * @author Yusuke Kamiyamane
900
872
  * @license MIT
901
873
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -903,26 +875,15 @@ function waitAnimationFinish(animation) {
903
875
  */
904
876
  /*! Bundled license information:
905
877
 
906
- @y14e/attributes-utils/dist/index.js:
907
- (**
908
- * Attributes Utils
909
- *
910
- * @version 2.0.0
911
- * @author Yusuke Kamiyamane
912
- * @license MIT
913
- * @copyright Copyright (c) Yusuke Kamiyamane
914
- * @see {@link https://github.com/y14e/attributes-utils}
915
- *)
916
-
917
- @y14e/attributes-utils/dist/index.js:
878
+ @y14e/attribute-util/dist/index.js:
918
879
  (**
919
- * Attributes Utils
880
+ * Attribute Util
920
881
  *
921
- * @version 1.1.7
882
+ * @version 2.0.1
922
883
  * @author Yusuke Kamiyamane
923
884
  * @license MIT
924
885
  * @copyright Copyright (c) Yusuke Kamiyamane
925
- * @see {@link https://github.com/y14e/attributes-utils}
886
+ * @see {@link https://github.com/y14e/attribute-util}
926
887
  *)
927
888
 
928
889
  power-focusable/dist/index.js:
@@ -931,7 +892,7 @@ power-focusable/dist/index.js:
931
892
  * High-precision focus management utility with full composed tree support.
932
893
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
933
894
  *
934
- * @version 4.3.23
895
+ * @version 4.3.25
935
896
  * @author Yusuke Kamiyamane
936
897
  * @license MIT
937
898
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -944,7 +905,7 @@ power-focusable/dist/index.js:
944
905
  * Lightweight roving tabindex utility with fully focus management.
945
906
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
946
907
  *
947
- * @version 3.1.20
908
+ * @version 3.1.22
948
909
  * @author Yusuke Kamiyamane
949
910
  * @license MIT
950
911
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1,35 +1,7 @@
1
- // node_modules/@y14e/attributes-utils/dist/index.js
2
- var snapshots = /* @__PURE__ */ new WeakMap();
3
- function restoreAttributes(element_or_elements) {
4
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
5
- const snapshot = snapshots.get(element);
6
- if (!snapshot) {
7
- continue;
8
- }
9
- for (const [name, value] of snapshot.entries()) {
10
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
11
- }
12
- snapshots.delete(element);
13
- }
14
- }
15
- function saveAttributes(element_or_elements, name_or_names) {
16
- const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
17
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
18
- let snapshot = snapshots.get(element);
19
- if (!snapshot) {
20
- snapshot = /* @__PURE__ */ new Map();
21
- snapshots.set(element, snapshot);
22
- }
23
- names.forEach((name) => {
24
- snapshot.set(name, element.getAttribute(name));
25
- });
26
- });
27
- }
28
-
29
- // node_modules/@y14e/roving-tabindex/node_modules/@y14e/attributes-utils/dist/index.js
1
+ // node_modules/@y14e/attribute-util/dist/index.js
30
2
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
31
3
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
32
- function addTokenToAttribute(element, name, token, options = {}) {
4
+ function addAttributeToken(element, name, token, options = {}) {
33
5
  const value = element.getAttribute(name)?.trim();
34
6
  const {
35
7
  caseInsensitive = false,
@@ -49,26 +21,26 @@ function addTokenToAttribute(element, name, token, options = {}) {
49
21
  element.setAttribute(name, serialize([...set]));
50
22
  }
51
23
  }
52
- var snapshots2 = /* @__PURE__ */ new WeakMap();
53
- function restoreAttributes2(element_or_elements) {
24
+ var snapshots = /* @__PURE__ */ new WeakMap();
25
+ function restoreAttributes(element_or_elements) {
54
26
  for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
55
- const snapshot = snapshots2.get(element);
27
+ const snapshot = snapshots.get(element);
56
28
  if (!snapshot) {
57
29
  continue;
58
30
  }
59
31
  for (const [name, value] of snapshot.entries()) {
60
32
  value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
61
33
  }
62
- snapshots2.delete(element);
34
+ snapshots.delete(element);
63
35
  }
64
36
  }
65
- function saveAttributes2(element_or_elements, name_or_names) {
37
+ function saveAttributes(element_or_elements, name_or_names) {
66
38
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
67
39
  (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
68
- let snapshot = snapshots2.get(element);
40
+ let snapshot = snapshots.get(element);
69
41
  if (!snapshot) {
70
42
  snapshot = /* @__PURE__ */ new Map();
71
- snapshots2.set(element, snapshot);
43
+ snapshots.set(element, snapshot);
72
44
  }
73
45
  names.forEach((name) => {
74
46
  snapshot.set(name, element.getAttribute(name));
@@ -436,7 +408,7 @@ var RovingTabIndex = class _RovingTabIndex {
436
408
  this.#controller = null;
437
409
  this.#focusables.forEach((focusable) => {
438
410
  _RovingTabIndex.#initialized.delete(focusable);
439
- restoreAttributes2(focusable);
411
+ restoreAttributes(focusable);
440
412
  });
441
413
  this.#focusables.clear();
442
414
  this.#focusablesByFirstChar.clear();
@@ -541,7 +513,7 @@ var RovingTabIndex = class _RovingTabIndex {
541
513
  for (const focusable of this.#focusables) {
542
514
  if (!current.has(focusable)) {
543
515
  _RovingTabIndex.#initialized.delete(focusable);
544
- restoreAttributes2(focusable);
516
+ restoreAttributes(focusable);
545
517
  this.#focusables.delete(focusable);
546
518
  for (const [key, focusables] of this.#focusablesByFirstChar) {
547
519
  const index = focusables.indexOf(focusable);
@@ -563,7 +535,7 @@ var RovingTabIndex = class _RovingTabIndex {
563
535
  this.#focusables.add(focusable);
564
536
  _RovingTabIndex.#initialized.add(focusable);
565
537
  if (!navigationOnly) {
566
- saveAttributes2(focusable, "tabindex");
538
+ saveAttributes(focusable, "tabindex");
567
539
  focusable.setAttribute("tabindex", "-1");
568
540
  }
569
541
  if (!typeahead) {
@@ -576,8 +548,8 @@ var RovingTabIndex = class _RovingTabIndex {
576
548
  );
577
549
  if (char) {
578
550
  keys.add(char);
579
- saveAttributes2(focusable, "aria-keyshortcuts");
580
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
551
+ saveAttributes(focusable, "aria-keyshortcuts");
552
+ addAttributeToken(focusable, "aria-keyshortcuts", char, {
581
553
  caseInsensitive: true
582
554
  });
583
555
  }
@@ -893,7 +865,7 @@ function waitAnimationFinish(animation) {
893
865
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
894
866
  * Using the <details> and <summary> element.
895
867
  *
896
- * @version 2.0.4
868
+ * @version 2.0.6
897
869
  * @author Yusuke Kamiyamane
898
870
  * @license MIT
899
871
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -901,26 +873,15 @@ function waitAnimationFinish(animation) {
901
873
  */
902
874
  /*! Bundled license information:
903
875
 
904
- @y14e/attributes-utils/dist/index.js:
905
- (**
906
- * Attributes Utils
907
- *
908
- * @version 2.0.0
909
- * @author Yusuke Kamiyamane
910
- * @license MIT
911
- * @copyright Copyright (c) Yusuke Kamiyamane
912
- * @see {@link https://github.com/y14e/attributes-utils}
913
- *)
914
-
915
- @y14e/attributes-utils/dist/index.js:
876
+ @y14e/attribute-util/dist/index.js:
916
877
  (**
917
- * Attributes Utils
878
+ * Attribute Util
918
879
  *
919
- * @version 1.1.7
880
+ * @version 2.0.1
920
881
  * @author Yusuke Kamiyamane
921
882
  * @license MIT
922
883
  * @copyright Copyright (c) Yusuke Kamiyamane
923
- * @see {@link https://github.com/y14e/attributes-utils}
884
+ * @see {@link https://github.com/y14e/attribute-util}
924
885
  *)
925
886
 
926
887
  power-focusable/dist/index.js:
@@ -929,7 +890,7 @@ power-focusable/dist/index.js:
929
890
  * High-precision focus management utility with full composed tree support.
930
891
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
931
892
  *
932
- * @version 4.3.23
893
+ * @version 4.3.25
933
894
  * @author Yusuke Kamiyamane
934
895
  * @license MIT
935
896
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -942,7 +903,7 @@ power-focusable/dist/index.js:
942
903
  * Lightweight roving tabindex utility with fully focus management.
943
904
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
944
905
  *
945
- * @version 3.1.20
906
+ * @version 3.1.22
946
907
  * @author Yusuke Kamiyamane
947
908
  * @license MIT
948
909
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -1,8 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var attributesUtils = require('@y14e/attributes-utils');
3
+ var util = require('@y14e/attribute-util');
4
4
  var rovingTabindex = require('@y14e/roving-tabindex');
5
5
 
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var util__namespace = /*#__PURE__*/_interopNamespace(util);
25
+
6
26
  // src/index.ts
7
27
  var Disclosure = class _Disclosure {
8
28
  static defaults = {};
@@ -113,7 +133,7 @@ var Disclosure = class _Disclosure {
113
133
  });
114
134
  });
115
135
  this.#detailsElements.length = 0;
116
- attributesUtils.restoreAttributes(this.#summaryElements);
136
+ util__namespace.restoreAttributes(this.#summaryElements);
117
137
  this.#summaryElements.length = 0;
118
138
  this.#contentElements.length = 0;
119
139
  this.#rootElement.removeAttribute("data-disclosure-initialized");
@@ -129,7 +149,7 @@ var Disclosure = class _Disclosure {
129
149
  this.#toggle(details, true);
130
150
  }
131
151
  #initialize() {
132
- attributesUtils.saveAttributes(this.#summaryElements, [
152
+ util__namespace.saveAttributes(this.#summaryElements, [
133
153
  "aria-disabled",
134
154
  "style",
135
155
  "tabindex"
@@ -283,7 +303,7 @@ function waitAnimationFinish(animation) {
283
303
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
284
304
  * Using the <details> and <summary> element.
285
305
  *
286
- * @version 2.0.4
306
+ * @version 2.0.6
287
307
  * @author Yusuke Kamiyamane
288
308
  * @license MIT
289
309
  * @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.4
6
+ * @version 2.0.6
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.4
6
+ * @version 2.0.6
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { restoreAttributes, saveAttributes } from '@y14e/attributes-utils';
1
+ import * as util from '@y14e/attribute-util';
2
2
  import { createRovingTabIndex } from '@y14e/roving-tabindex';
3
3
 
4
4
  // src/index.ts
@@ -111,7 +111,7 @@ var Disclosure = class _Disclosure {
111
111
  });
112
112
  });
113
113
  this.#detailsElements.length = 0;
114
- restoreAttributes(this.#summaryElements);
114
+ util.restoreAttributes(this.#summaryElements);
115
115
  this.#summaryElements.length = 0;
116
116
  this.#contentElements.length = 0;
117
117
  this.#rootElement.removeAttribute("data-disclosure-initialized");
@@ -127,7 +127,7 @@ var Disclosure = class _Disclosure {
127
127
  this.#toggle(details, true);
128
128
  }
129
129
  #initialize() {
130
- saveAttributes(this.#summaryElements, [
130
+ util.saveAttributes(this.#summaryElements, [
131
131
  "aria-disabled",
132
132
  "style",
133
133
  "tabindex"
@@ -281,7 +281,7 @@ function waitAnimationFinish(animation) {
281
281
  * WAI-ARIA compliant disclosure pattern implementation in TypeScript.
282
282
  * Using the <details> and <summary> element.
283
283
  *
284
- * @version 2.0.4
284
+ * @version 2.0.6
285
285
  * @author Yusuke Kamiyamane
286
286
  * @license MIT
287
287
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/disclosure",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -51,7 +51,7 @@
51
51
  "node": ">=18"
52
52
  },
53
53
  "dependencies": {
54
- "@y14e/attributes-utils": "^2.0.0",
55
- "@y14e/roving-tabindex": "^3.1.20"
54
+ "@y14e/attribute-util": "^2.0.1",
55
+ "@y14e/roving-tabindex": "^3.1.22"
56
56
  }
57
57
  }