@y14e/disclosure 1.2.5 → 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/dist/index.cjs +5 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -7
- 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;
|
|
@@ -164,13 +163,12 @@ var Disclosure = class _Disclosure {
|
|
|
164
163
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
165
164
|
return;
|
|
166
165
|
}
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
event.stopPropagation();
|
|
169
166
|
const focusables = this.#summaryElements.filter(isFocusable);
|
|
170
167
|
const active = getActiveElement();
|
|
171
168
|
if (!(active instanceof HTMLElement)) {
|
|
172
169
|
return;
|
|
173
170
|
}
|
|
171
|
+
event.preventDefault();
|
|
174
172
|
const currentIndex = focusables.indexOf(active);
|
|
175
173
|
let newIndex = currentIndex;
|
|
176
174
|
switch (key) {
|
|
@@ -301,7 +299,7 @@ function waitAnimationFinish(animation) {
|
|
|
301
299
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
302
300
|
* Using the <details> and <summary> element.
|
|
303
301
|
*
|
|
304
|
-
* @version 1.2.
|
|
302
|
+
* @version 1.2.6
|
|
305
303
|
* @author Yusuke Kamiyamane
|
|
306
304
|
* @license MIT
|
|
307
305
|
* @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;
|
|
@@ -162,13 +161,12 @@ var Disclosure = class _Disclosure {
|
|
|
162
161
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
163
162
|
return;
|
|
164
163
|
}
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
event.stopPropagation();
|
|
167
164
|
const focusables = this.#summaryElements.filter(isFocusable);
|
|
168
165
|
const active = getActiveElement();
|
|
169
166
|
if (!(active instanceof HTMLElement)) {
|
|
170
167
|
return;
|
|
171
168
|
}
|
|
169
|
+
event.preventDefault();
|
|
172
170
|
const currentIndex = focusables.indexOf(active);
|
|
173
171
|
let newIndex = currentIndex;
|
|
174
172
|
switch (key) {
|
|
@@ -299,7 +297,7 @@ function waitAnimationFinish(animation) {
|
|
|
299
297
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
300
298
|
* Using the <details> and <summary> element.
|
|
301
299
|
*
|
|
302
|
-
* @version 1.2.
|
|
300
|
+
* @version 1.2.6
|
|
303
301
|
* @author Yusuke Kamiyamane
|
|
304
302
|
* @license MIT
|
|
305
303
|
* @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.6",
|
|
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"
|