@y14e/accordion 1.2.4 → 1.2.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 +2 -2
- package/dist/index.cjs +7 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -6
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -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 '
|
|
54
|
+
import Accordion from '@y14e/accordion';
|
|
55
55
|
|
|
56
56
|
Accordion.defaults = {
|
|
57
57
|
animation: {
|
|
@@ -99,4 +99,4 @@ accordion.destroy(force);
|
|
|
99
99
|
|
|
100
100
|
## Demo
|
|
101
101
|
|
|
102
|
-
https://y14e.github.io/accordion
|
|
102
|
+
https://y14e.github.io/accordion/
|
package/dist/index.cjs
CHANGED
|
@@ -132,25 +132,26 @@ var Accordion = class _Accordion {
|
|
|
132
132
|
}
|
|
133
133
|
#onTriggerClick = (event) => {
|
|
134
134
|
event.preventDefault();
|
|
135
|
-
event.stopPropagation();
|
|
136
135
|
const trigger = event.currentTarget;
|
|
137
136
|
if (!(trigger instanceof HTMLElement)) {
|
|
138
137
|
return;
|
|
139
138
|
}
|
|
140
|
-
this.#toggle(trigger, trigger.ariaExpanded
|
|
139
|
+
this.#toggle(trigger, trigger.ariaExpanded === "false");
|
|
141
140
|
};
|
|
142
141
|
#onTriggerKeyDown = (event) => {
|
|
143
|
-
const { key } = event;
|
|
142
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
143
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
144
146
|
if (!["Enter", " ", "End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
145
147
|
return;
|
|
146
148
|
}
|
|
147
|
-
event.preventDefault();
|
|
148
|
-
event.stopPropagation();
|
|
149
149
|
const focusables = this.#triggerElements.filter(isFocusable);
|
|
150
150
|
const active = getActiveElement();
|
|
151
151
|
if (!(active instanceof HTMLElement)) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
+
event.preventDefault();
|
|
154
155
|
const currentIndex = focusables.indexOf(active);
|
|
155
156
|
let newIndex = currentIndex;
|
|
156
157
|
switch (key) {
|
|
@@ -299,7 +300,7 @@ function waitAnimationFinish(animation) {
|
|
|
299
300
|
* Accordion
|
|
300
301
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
301
302
|
*
|
|
302
|
-
* @version 1.2.
|
|
303
|
+
* @version 1.2.6
|
|
303
304
|
* @author Yusuke Kamiyamane
|
|
304
305
|
* @license MIT
|
|
305
306
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -130,25 +130,26 @@ var Accordion = class _Accordion {
|
|
|
130
130
|
}
|
|
131
131
|
#onTriggerClick = (event) => {
|
|
132
132
|
event.preventDefault();
|
|
133
|
-
event.stopPropagation();
|
|
134
133
|
const trigger = event.currentTarget;
|
|
135
134
|
if (!(trigger instanceof HTMLElement)) {
|
|
136
135
|
return;
|
|
137
136
|
}
|
|
138
|
-
this.#toggle(trigger, trigger.ariaExpanded
|
|
137
|
+
this.#toggle(trigger, trigger.ariaExpanded === "false");
|
|
139
138
|
};
|
|
140
139
|
#onTriggerKeyDown = (event) => {
|
|
141
|
-
const { key } = event;
|
|
140
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
141
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
142
144
|
if (!["Enter", " ", "End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
143
145
|
return;
|
|
144
146
|
}
|
|
145
|
-
event.preventDefault();
|
|
146
|
-
event.stopPropagation();
|
|
147
147
|
const focusables = this.#triggerElements.filter(isFocusable);
|
|
148
148
|
const active = getActiveElement();
|
|
149
149
|
if (!(active instanceof HTMLElement)) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
|
+
event.preventDefault();
|
|
152
153
|
const currentIndex = focusables.indexOf(active);
|
|
153
154
|
let newIndex = currentIndex;
|
|
154
155
|
switch (key) {
|
|
@@ -297,7 +298,7 @@ function waitAnimationFinish(animation) {
|
|
|
297
298
|
* Accordion
|
|
298
299
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
299
300
|
*
|
|
300
|
-
* @version 1.2.
|
|
301
|
+
* @version 1.2.6
|
|
301
302
|
* @author Yusuke Kamiyamane
|
|
302
303
|
* @license MIT
|
|
303
304
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/accordion",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"bun-types": "latest",
|
|
47
47
|
"tsup": "^8.0.0",
|
|
48
|
-
"typescript": "^5.6.0"
|
|
48
|
+
"typescript": "^5.6.0",
|
|
49
|
+
"utility-types": "^3.11.0"
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">=18"
|