@y14e/accordion 2.0.6 → 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.
- package/README.md +5 -5
- package/dist/index.bundle.cjs +75 -14
- package/dist/index.bundle.js +75 -14
- package/dist/index.cjs +11 -14
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -9
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@ npm i @y14e/accordion
|
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// npm
|
|
13
|
-
import Accordion from "@y14e/accordion";
|
|
13
|
+
import { Accordion } from "@y14e/accordion";
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import Accordion from "https://esm.sh/@y14e/accordion@2.0.
|
|
16
|
+
import { Accordion } from "https://esm.sh/@y14e/accordion@2.0.7";
|
|
17
17
|
// or
|
|
18
|
-
import Accordion from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.
|
|
18
|
+
import { Accordion } from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.7/+esm";
|
|
19
19
|
// or
|
|
20
|
-
import Accordion from "https://esm.unpkg.com/@y14e/accordion@2.0.
|
|
20
|
+
import { Accordion } from "https://esm.unpkg.com/@y14e/accordion@2.0.7";
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
@@ -51,7 +51,7 @@ interface AccordionOptions {
|
|
|
51
51
|
Override the global default settings applied to all accordion instances.
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
import Accordion from "@y14e/accordion";
|
|
54
|
+
import { Accordion } from "@y14e/accordion";
|
|
55
55
|
|
|
56
56
|
Accordion.defaults = {
|
|
57
57
|
animation: {
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// node_modules/@y14e/attribute-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
603
|
-
|
|
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.
|
|
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-
|
|
978
|
+
@y14e/attribute-utils/dist/index.js:
|
|
929
979
|
(**
|
|
930
|
-
* Attribute
|
|
980
|
+
* Attribute Utils
|
|
931
981
|
*
|
|
932
|
-
* @version 2.0.
|
|
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-
|
|
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.
|
|
995
|
+
* @version 4.3.26
|
|
946
996
|
* @author Yusuke Kamiyamane
|
|
947
997
|
* @license MIT
|
|
948
998
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -953,13 +1003,24 @@ power-focusable/dist/index.js:
|
|
|
953
1003
|
(**
|
|
954
1004
|
* Button
|
|
955
1005
|
*
|
|
956
|
-
* @version 1.0.
|
|
1006
|
+
* @version 1.0.8
|
|
957
1007
|
* @author Yusuke Kamiyamane
|
|
958
1008
|
* @license MIT
|
|
959
1009
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
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
|
|
@@ -974,4 +1035,4 @@ power-focusable/dist/index.js:
|
|
|
974
1035
|
*)
|
|
975
1036
|
*/
|
|
976
1037
|
|
|
977
|
-
|
|
1038
|
+
exports.Accordion = Accordion;
|
package/dist/index.bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/@y14e/attribute-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
601
|
-
|
|
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.
|
|
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-
|
|
976
|
+
@y14e/attribute-utils/dist/index.js:
|
|
927
977
|
(**
|
|
928
|
-
* Attribute
|
|
978
|
+
* Attribute Utils
|
|
929
979
|
*
|
|
930
|
-
* @version 2.0.
|
|
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-
|
|
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.
|
|
993
|
+
* @version 4.3.26
|
|
944
994
|
* @author Yusuke Kamiyamane
|
|
945
995
|
* @license MIT
|
|
946
996
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -951,13 +1001,24 @@ power-focusable/dist/index.js:
|
|
|
951
1001
|
(**
|
|
952
1002
|
* Button
|
|
953
1003
|
*
|
|
954
|
-
* @version 1.0.
|
|
1004
|
+
* @version 1.0.8
|
|
955
1005
|
* @author Yusuke Kamiyamane
|
|
956
1006
|
* @license MIT
|
|
957
1007
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
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
|
|
@@ -972,4 +1033,4 @@ power-focusable/dist/index.js:
|
|
|
972
1033
|
*)
|
|
973
1034
|
*/
|
|
974
1035
|
|
|
975
|
-
export { Accordion
|
|
1036
|
+
export { Accordion };
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var utils = require('@y14e/attribute-utils');
|
|
4
|
+
var button = require('@y14e/button');
|
|
5
5
|
var rovingTabindex = require('@y14e/roving-tabindex');
|
|
6
6
|
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
7
|
function _interopNamespace(e) {
|
|
10
8
|
if (e && e.__esModule) return e;
|
|
11
9
|
var n = Object.create(null);
|
|
@@ -24,8 +22,7 @@ function _interopNamespace(e) {
|
|
|
24
22
|
return Object.freeze(n);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
var
|
|
28
|
-
var Button__default = /*#__PURE__*/_interopDefault(Button);
|
|
25
|
+
var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
|
|
29
26
|
|
|
30
27
|
// src/index.ts
|
|
31
28
|
var Accordion = class _Accordion {
|
|
@@ -121,7 +118,7 @@ var Accordion = class _Accordion {
|
|
|
121
118
|
});
|
|
122
119
|
this.#animationController?.abort();
|
|
123
120
|
this.#animationController = null;
|
|
124
|
-
|
|
121
|
+
utils__namespace.restoreAttributes([
|
|
125
122
|
...this.#triggerElements,
|
|
126
123
|
...this.#contentElements
|
|
127
124
|
]);
|
|
@@ -140,14 +137,14 @@ var Accordion = class _Accordion {
|
|
|
140
137
|
this.#toggle(trigger, true);
|
|
141
138
|
}
|
|
142
139
|
#initialize() {
|
|
143
|
-
|
|
140
|
+
utils__namespace.saveAttributes(this.#triggerElements, [
|
|
144
141
|
"aria-controls",
|
|
145
142
|
"aria-disabled",
|
|
146
143
|
"id",
|
|
147
144
|
"style",
|
|
148
145
|
"tabindex"
|
|
149
146
|
]);
|
|
150
|
-
|
|
147
|
+
utils__namespace.saveAttributes(this.#contentElements, [
|
|
151
148
|
"aria-labelledby",
|
|
152
149
|
"id",
|
|
153
150
|
"role"
|
|
@@ -161,7 +158,7 @@ var Accordion = class _Accordion {
|
|
|
161
158
|
return;
|
|
162
159
|
}
|
|
163
160
|
content2.id ||= `accordion-content-${id}`;
|
|
164
|
-
|
|
161
|
+
utils__namespace.addAttributeToken(trigger2, "aria-controls", content2.id);
|
|
165
162
|
trigger2.setAttribute(
|
|
166
163
|
"aria-expanded",
|
|
167
164
|
String(trigger2.ariaExpanded === "true")
|
|
@@ -173,12 +170,12 @@ var Accordion = class _Accordion {
|
|
|
173
170
|
trigger2.style.setProperty("pointer-events", "none");
|
|
174
171
|
}
|
|
175
172
|
trigger2.addEventListener("click", this.#onTriggerClick, { signal });
|
|
176
|
-
|
|
173
|
+
utils__namespace.addAttributeToken(content2, "aria-labelledby", trigger2.id);
|
|
177
174
|
content2.setAttribute("role", "region");
|
|
178
175
|
content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
|
|
179
176
|
signal
|
|
180
177
|
});
|
|
181
|
-
this.#buttons.push(new
|
|
178
|
+
this.#buttons.push(new button.Button(trigger2));
|
|
182
179
|
});
|
|
183
180
|
const { trigger, content } = this.#settings.selector;
|
|
184
181
|
this.#cleanupRovingTabIndex = rovingTabindex.createRovingTabIndex(this.#rootElement, {
|
|
@@ -308,11 +305,11 @@ function waitAnimationFinish(animation) {
|
|
|
308
305
|
* Accordion
|
|
309
306
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
310
307
|
*
|
|
311
|
-
* @version 2.0.
|
|
308
|
+
* @version 2.0.8
|
|
312
309
|
* @author Yusuke Kamiyamane
|
|
313
310
|
* @license MIT
|
|
314
311
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
315
312
|
* @see {@link https://github.com/y14e/accordion}
|
|
316
313
|
*/
|
|
317
314
|
|
|
318
|
-
|
|
315
|
+
exports.Accordion = Accordion;
|
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.
|
|
5
|
+
* @version 2.0.8
|
|
6
6
|
* @author Yusuke Kamiyamane
|
|
7
7
|
* @license MIT
|
|
8
8
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -28,4 +28,4 @@ declare class Accordion {
|
|
|
28
28
|
expand(trigger: HTMLElement): void;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export { type AccordionOptions
|
|
31
|
+
export { Accordion, type AccordionOptions };
|
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.
|
|
5
|
+
* @version 2.0.8
|
|
6
6
|
* @author Yusuke Kamiyamane
|
|
7
7
|
* @license MIT
|
|
8
8
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -28,4 +28,4 @@ declare class Accordion {
|
|
|
28
28
|
expand(trigger: HTMLElement): void;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export { type AccordionOptions
|
|
31
|
+
export { Accordion, type AccordionOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import Button from '@y14e/button';
|
|
1
|
+
import * as utils from '@y14e/attribute-utils';
|
|
2
|
+
import { Button } from '@y14e/button';
|
|
3
3
|
import { createRovingTabIndex } from '@y14e/roving-tabindex';
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
@@ -96,7 +96,7 @@ var Accordion = class _Accordion {
|
|
|
96
96
|
});
|
|
97
97
|
this.#animationController?.abort();
|
|
98
98
|
this.#animationController = null;
|
|
99
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,11 +283,11 @@ function waitAnimationFinish(animation) {
|
|
|
283
283
|
* Accordion
|
|
284
284
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
285
285
|
*
|
|
286
|
-
* @version 2.0.
|
|
286
|
+
* @version 2.0.8
|
|
287
287
|
* @author Yusuke Kamiyamane
|
|
288
288
|
* @license MIT
|
|
289
289
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
290
290
|
* @see {@link https://github.com/y14e/accordion}
|
|
291
291
|
*/
|
|
292
292
|
|
|
293
|
-
export { Accordion
|
|
293
|
+
export { Accordion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/accordion",
|
|
3
|
-
"version": "2.0.
|
|
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",
|
|
@@ -50,9 +50,12 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|
|
52
52
|
},
|
|
53
|
+
"allowScripts": {
|
|
54
|
+
"esbuild": true
|
|
55
|
+
},
|
|
53
56
|
"dependencies": {
|
|
54
|
-
"@y14e/attribute-
|
|
55
|
-
"@y14e/button": "^1.0.
|
|
57
|
+
"@y14e/attribute-utils": "^2.0.5",
|
|
58
|
+
"@y14e/button": "^1.0.8",
|
|
56
59
|
"@y14e/roving-tabindex": "^3.1.22"
|
|
57
60
|
}
|
|
58
61
|
}
|