@y14e/accordion 2.0.3 → 2.0.5
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 +7 -8
- package/dist/index.bundle.cjs +220 -95
- package/dist/index.bundle.js +220 -95
- package/dist/index.cjs +34 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -8
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as util from '@y14e/attribute-util';
|
|
2
2
|
import Button from '@y14e/button';
|
|
3
3
|
import { createRovingTabIndex } from '@y14e/roving-tabindex';
|
|
4
4
|
|
|
@@ -96,7 +96,10 @@ var Accordion = class _Accordion {
|
|
|
96
96
|
});
|
|
97
97
|
this.#animationController?.abort();
|
|
98
98
|
this.#animationController = null;
|
|
99
|
-
restoreAttributes([
|
|
99
|
+
util.restoreAttributes([
|
|
100
|
+
...this.#triggerElements,
|
|
101
|
+
...this.#contentElements
|
|
102
|
+
]);
|
|
100
103
|
this.#triggerElements.length = 0;
|
|
101
104
|
this.#contentElements.length = 0;
|
|
102
105
|
this.#rootElement.removeAttribute("data-accordion-initialized");
|
|
@@ -112,14 +115,18 @@ var Accordion = class _Accordion {
|
|
|
112
115
|
this.#toggle(trigger, true);
|
|
113
116
|
}
|
|
114
117
|
#initialize() {
|
|
115
|
-
saveAttributes(this.#triggerElements, [
|
|
118
|
+
util.saveAttributes(this.#triggerElements, [
|
|
116
119
|
"aria-controls",
|
|
117
120
|
"aria-disabled",
|
|
118
121
|
"id",
|
|
119
122
|
"style",
|
|
120
123
|
"tabindex"
|
|
121
124
|
]);
|
|
122
|
-
saveAttributes(this.#contentElements, [
|
|
125
|
+
util.saveAttributes(this.#contentElements, [
|
|
126
|
+
"aria-labelledby",
|
|
127
|
+
"id",
|
|
128
|
+
"role"
|
|
129
|
+
]);
|
|
123
130
|
this.#eventController = new AbortController();
|
|
124
131
|
const { signal } = this.#eventController;
|
|
125
132
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
@@ -129,7 +136,7 @@ var Accordion = class _Accordion {
|
|
|
129
136
|
return;
|
|
130
137
|
}
|
|
131
138
|
content2.id ||= `accordion-content-${id}`;
|
|
132
|
-
|
|
139
|
+
util.addAttributeToken(trigger2, "aria-controls", content2.id);
|
|
133
140
|
trigger2.setAttribute(
|
|
134
141
|
"aria-expanded",
|
|
135
142
|
String(trigger2.ariaExpanded === "true")
|
|
@@ -141,7 +148,7 @@ var Accordion = class _Accordion {
|
|
|
141
148
|
trigger2.style.setProperty("pointer-events", "none");
|
|
142
149
|
}
|
|
143
150
|
trigger2.addEventListener("click", this.#onTriggerClick, { signal });
|
|
144
|
-
|
|
151
|
+
util.addAttributeToken(content2, "aria-labelledby", trigger2.id);
|
|
145
152
|
content2.setAttribute("role", "region");
|
|
146
153
|
content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
|
|
147
154
|
signal
|
|
@@ -245,7 +252,7 @@ var Accordion = class _Accordion {
|
|
|
245
252
|
);
|
|
246
253
|
}
|
|
247
254
|
#createBinding(trigger, content) {
|
|
248
|
-
return {
|
|
255
|
+
return { animation: null, content, trigger };
|
|
249
256
|
}
|
|
250
257
|
#isFocusable(element) {
|
|
251
258
|
return !element.hasAttribute("disabled") && element.tabIndex >= 0;
|
|
@@ -276,7 +283,7 @@ function waitAnimationFinish(animation) {
|
|
|
276
283
|
* Accordion
|
|
277
284
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
278
285
|
*
|
|
279
|
-
* @version 2.0.
|
|
286
|
+
* @version 2.0.5
|
|
280
287
|
* @author Yusuke Kamiyamane
|
|
281
288
|
* @license MIT
|
|
282
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.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"node": ">=18"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@y14e/
|
|
54
|
+
"@y14e/attribute-util": "^2.0.0",
|
|
55
55
|
"@y14e/button": "^1.0.6",
|
|
56
|
-
"@y14e/roving-tabindex": "^3.1.
|
|
56
|
+
"@y14e/roving-tabindex": "^3.1.20"
|
|
57
57
|
}
|
|
58
58
|
}
|