@y14e/disclosure 1.2.5 → 1.2.7
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/dist/index.cjs +9 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -8
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -124,13 +124,13 @@ var Disclosure = class _Disclosure {
|
|
|
124
124
|
const { signal } = this.#eventController;
|
|
125
125
|
this.#detailsElements.forEach((details, i) => {
|
|
126
126
|
details.name && details.setAttribute("data-disclosure-name", details.name);
|
|
127
|
-
function
|
|
127
|
+
function onMutate() {
|
|
128
128
|
details.toggleAttribute("data-disclosure-open", details.open);
|
|
129
129
|
}
|
|
130
|
-
const observer = new MutationObserver(
|
|
130
|
+
const observer = new MutationObserver(onMutate);
|
|
131
131
|
observer.observe(details, { attributeFilter: ["open"] });
|
|
132
132
|
this.#observers.push(observer);
|
|
133
|
-
|
|
133
|
+
onMutate();
|
|
134
134
|
const summary = this.#summaryElements[i];
|
|
135
135
|
if (!summary) {
|
|
136
136
|
return;
|
|
@@ -147,7 +147,6 @@ var Disclosure = class _Disclosure {
|
|
|
147
147
|
}
|
|
148
148
|
#onSummaryClick = (event) => {
|
|
149
149
|
event.preventDefault();
|
|
150
|
-
event.stopPropagation();
|
|
151
150
|
const summary = event.currentTarget;
|
|
152
151
|
if (!(summary instanceof HTMLElement)) {
|
|
153
152
|
return;
|
|
@@ -160,17 +159,19 @@ var Disclosure = class _Disclosure {
|
|
|
160
159
|
this.#toggle(details, !details.hasAttribute("data-disclosure-open"));
|
|
161
160
|
};
|
|
162
161
|
#onSummaryKeyDown = (event) => {
|
|
163
|
-
const { key } = event;
|
|
162
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
163
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
164
166
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
165
167
|
return;
|
|
166
168
|
}
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
event.stopPropagation();
|
|
169
169
|
const focusables = this.#summaryElements.filter(isFocusable);
|
|
170
170
|
const active = getActiveElement();
|
|
171
171
|
if (!(active instanceof HTMLElement)) {
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
+
event.preventDefault();
|
|
174
175
|
const currentIndex = focusables.indexOf(active);
|
|
175
176
|
let newIndex = currentIndex;
|
|
176
177
|
switch (key) {
|
|
@@ -301,7 +302,7 @@ function waitAnimationFinish(animation) {
|
|
|
301
302
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
302
303
|
* Using the <details> and <summary> element.
|
|
303
304
|
*
|
|
304
|
-
* @version 1.2.
|
|
305
|
+
* @version 1.2.7
|
|
305
306
|
* @author Yusuke Kamiyamane
|
|
306
307
|
* @license MIT
|
|
307
308
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -122,13 +122,13 @@ var Disclosure = class _Disclosure {
|
|
|
122
122
|
const { signal } = this.#eventController;
|
|
123
123
|
this.#detailsElements.forEach((details, i) => {
|
|
124
124
|
details.name && details.setAttribute("data-disclosure-name", details.name);
|
|
125
|
-
function
|
|
125
|
+
function onMutate() {
|
|
126
126
|
details.toggleAttribute("data-disclosure-open", details.open);
|
|
127
127
|
}
|
|
128
|
-
const observer = new MutationObserver(
|
|
128
|
+
const observer = new MutationObserver(onMutate);
|
|
129
129
|
observer.observe(details, { attributeFilter: ["open"] });
|
|
130
130
|
this.#observers.push(observer);
|
|
131
|
-
|
|
131
|
+
onMutate();
|
|
132
132
|
const summary = this.#summaryElements[i];
|
|
133
133
|
if (!summary) {
|
|
134
134
|
return;
|
|
@@ -145,7 +145,6 @@ var Disclosure = class _Disclosure {
|
|
|
145
145
|
}
|
|
146
146
|
#onSummaryClick = (event) => {
|
|
147
147
|
event.preventDefault();
|
|
148
|
-
event.stopPropagation();
|
|
149
148
|
const summary = event.currentTarget;
|
|
150
149
|
if (!(summary instanceof HTMLElement)) {
|
|
151
150
|
return;
|
|
@@ -158,17 +157,19 @@ var Disclosure = class _Disclosure {
|
|
|
158
157
|
this.#toggle(details, !details.hasAttribute("data-disclosure-open"));
|
|
159
158
|
};
|
|
160
159
|
#onSummaryKeyDown = (event) => {
|
|
161
|
-
const { key } = event;
|
|
160
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
161
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
162
164
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
163
165
|
return;
|
|
164
166
|
}
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
event.stopPropagation();
|
|
167
167
|
const focusables = this.#summaryElements.filter(isFocusable);
|
|
168
168
|
const active = getActiveElement();
|
|
169
169
|
if (!(active instanceof HTMLElement)) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
+
event.preventDefault();
|
|
172
173
|
const currentIndex = focusables.indexOf(active);
|
|
173
174
|
let newIndex = currentIndex;
|
|
174
175
|
switch (key) {
|
|
@@ -299,7 +300,7 @@ function waitAnimationFinish(animation) {
|
|
|
299
300
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
300
301
|
* Using the <details> and <summary> element.
|
|
301
302
|
*
|
|
302
|
-
* @version 1.2.
|
|
303
|
+
* @version 1.2.7
|
|
303
304
|
* @author Yusuke Kamiyamane
|
|
304
305
|
* @license MIT
|
|
305
306
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "WAI-ARIA compliant disclosure 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"
|