@y14e/disclosure 1.2.6 → 1.2.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/dist/index.cjs +47 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
4
|
+
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function restoreAttributes(elements) {
|
|
6
|
+
for (const element of elements) {
|
|
7
|
+
const snapshot = snapshots.get(element);
|
|
8
|
+
if (!snapshot) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
for (const [attribute, value] of snapshot.entries()) {
|
|
12
|
+
value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
|
|
13
|
+
}
|
|
14
|
+
snapshots.delete(element);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function saveAttributes(elements, attributes) {
|
|
18
|
+
elements.forEach((element) => {
|
|
19
|
+
let snapshot = snapshots.get(element);
|
|
20
|
+
if (!snapshot) {
|
|
21
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
22
|
+
snapshots.set(element, snapshot);
|
|
23
|
+
}
|
|
24
|
+
attributes.forEach((attribute) => {
|
|
25
|
+
snapshot.set(attribute, element.getAttribute(attribute));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
3
30
|
// src/index.ts
|
|
4
31
|
var Disclosure = class _Disclosure {
|
|
5
32
|
static defaults = {};
|
|
@@ -115,6 +142,7 @@ var Disclosure = class _Disclosure {
|
|
|
115
142
|
details.removeAttribute("data-disclosure-open");
|
|
116
143
|
});
|
|
117
144
|
this.#detailsElements.length = 0;
|
|
145
|
+
restoreAttributes(this.#summaryElements);
|
|
118
146
|
this.#summaryElements.length = 0;
|
|
119
147
|
this.#contentElements.length = 0;
|
|
120
148
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
@@ -136,6 +164,7 @@ var Disclosure = class _Disclosure {
|
|
|
136
164
|
return;
|
|
137
165
|
}
|
|
138
166
|
if (!isFocusable(summary)) {
|
|
167
|
+
saveAttributes([summary], ["aria-disabled", "style", "tabindex"]);
|
|
139
168
|
summary.setAttribute("aria-disabled", "true");
|
|
140
169
|
summary.setAttribute("tabindex", "-1");
|
|
141
170
|
summary.style.setProperty("pointer-events", "none");
|
|
@@ -159,7 +188,10 @@ var Disclosure = class _Disclosure {
|
|
|
159
188
|
this.#toggle(details, !details.hasAttribute("data-disclosure-open"));
|
|
160
189
|
};
|
|
161
190
|
#onSummaryKeyDown = (event) => {
|
|
162
|
-
const { key } = event;
|
|
191
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
192
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
163
195
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
164
196
|
return;
|
|
165
197
|
}
|
|
@@ -299,11 +331,24 @@ function waitAnimationFinish(animation) {
|
|
|
299
331
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
300
332
|
* Using the <details> and <summary> element.
|
|
301
333
|
*
|
|
302
|
-
* @version 1.2.
|
|
334
|
+
* @version 1.2.8
|
|
303
335
|
* @author Yusuke Kamiyamane
|
|
304
336
|
* @license MIT
|
|
305
337
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
306
338
|
* @see {@link https://github.com/y14e/disclosure}
|
|
307
339
|
*/
|
|
340
|
+
/*! Bundled license information:
|
|
341
|
+
|
|
342
|
+
@y14e/attributes-utils/dist/index.js:
|
|
343
|
+
(**
|
|
344
|
+
* Attributes Utils
|
|
345
|
+
*
|
|
346
|
+
* @version 1.0.5
|
|
347
|
+
* @author Yusuke Kamiyamane
|
|
348
|
+
* @license MIT
|
|
349
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
350
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
351
|
+
*)
|
|
352
|
+
*/
|
|
308
353
|
|
|
309
354
|
module.exports = Disclosure;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
2
|
+
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function restoreAttributes(elements) {
|
|
4
|
+
for (const element of elements) {
|
|
5
|
+
const snapshot = snapshots.get(element);
|
|
6
|
+
if (!snapshot) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
for (const [attribute, value] of snapshot.entries()) {
|
|
10
|
+
value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
|
|
11
|
+
}
|
|
12
|
+
snapshots.delete(element);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function saveAttributes(elements, attributes) {
|
|
16
|
+
elements.forEach((element) => {
|
|
17
|
+
let snapshot = snapshots.get(element);
|
|
18
|
+
if (!snapshot) {
|
|
19
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
20
|
+
snapshots.set(element, snapshot);
|
|
21
|
+
}
|
|
22
|
+
attributes.forEach((attribute) => {
|
|
23
|
+
snapshot.set(attribute, element.getAttribute(attribute));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
// src/index.ts
|
|
2
29
|
var Disclosure = class _Disclosure {
|
|
3
30
|
static defaults = {};
|
|
@@ -113,6 +140,7 @@ var Disclosure = class _Disclosure {
|
|
|
113
140
|
details.removeAttribute("data-disclosure-open");
|
|
114
141
|
});
|
|
115
142
|
this.#detailsElements.length = 0;
|
|
143
|
+
restoreAttributes(this.#summaryElements);
|
|
116
144
|
this.#summaryElements.length = 0;
|
|
117
145
|
this.#contentElements.length = 0;
|
|
118
146
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
@@ -134,6 +162,7 @@ var Disclosure = class _Disclosure {
|
|
|
134
162
|
return;
|
|
135
163
|
}
|
|
136
164
|
if (!isFocusable(summary)) {
|
|
165
|
+
saveAttributes([summary], ["aria-disabled", "style", "tabindex"]);
|
|
137
166
|
summary.setAttribute("aria-disabled", "true");
|
|
138
167
|
summary.setAttribute("tabindex", "-1");
|
|
139
168
|
summary.style.setProperty("pointer-events", "none");
|
|
@@ -157,7 +186,10 @@ var Disclosure = class _Disclosure {
|
|
|
157
186
|
this.#toggle(details, !details.hasAttribute("data-disclosure-open"));
|
|
158
187
|
};
|
|
159
188
|
#onSummaryKeyDown = (event) => {
|
|
160
|
-
const { key } = event;
|
|
189
|
+
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
190
|
+
if (altKey || ctrlKey || metaKey || shiftKey) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
161
193
|
if (!["End", "Home", "ArrowUp", "ArrowDown"].includes(key)) {
|
|
162
194
|
return;
|
|
163
195
|
}
|
|
@@ -297,11 +329,24 @@ function waitAnimationFinish(animation) {
|
|
|
297
329
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
298
330
|
* Using the <details> and <summary> element.
|
|
299
331
|
*
|
|
300
|
-
* @version 1.2.
|
|
332
|
+
* @version 1.2.8
|
|
301
333
|
* @author Yusuke Kamiyamane
|
|
302
334
|
* @license MIT
|
|
303
335
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
304
336
|
* @see {@link https://github.com/y14e/disclosure}
|
|
305
337
|
*/
|
|
338
|
+
/*! Bundled license information:
|
|
339
|
+
|
|
340
|
+
@y14e/attributes-utils/dist/index.js:
|
|
341
|
+
(**
|
|
342
|
+
* Attributes Utils
|
|
343
|
+
*
|
|
344
|
+
* @version 1.0.5
|
|
345
|
+
* @author Yusuke Kamiyamane
|
|
346
|
+
* @license MIT
|
|
347
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
348
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
349
|
+
*)
|
|
350
|
+
*/
|
|
306
351
|
|
|
307
352
|
export { Disclosure as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/y14e/disclosure#readme",
|
|
45
45
|
"devDependencies": {
|
|
46
|
+
"@y14e/attributes-utils": "^1.0.5",
|
|
46
47
|
"bun-types": "latest",
|
|
47
48
|
"tsup": "^8.0.0",
|
|
48
49
|
"typescript": "^5.6.0",
|