@y14e/disclosure 1.2.7 → 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 +43 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -1
- 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");
|
|
@@ -302,11 +331,24 @@ function waitAnimationFinish(animation) {
|
|
|
302
331
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
303
332
|
* Using the <details> and <summary> element.
|
|
304
333
|
*
|
|
305
|
-
* @version 1.2.
|
|
334
|
+
* @version 1.2.8
|
|
306
335
|
* @author Yusuke Kamiyamane
|
|
307
336
|
* @license MIT
|
|
308
337
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
309
338
|
* @see {@link https://github.com/y14e/disclosure}
|
|
310
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
|
+
*/
|
|
311
353
|
|
|
312
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");
|
|
@@ -300,11 +329,24 @@ function waitAnimationFinish(animation) {
|
|
|
300
329
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
301
330
|
* Using the <details> and <summary> element.
|
|
302
331
|
*
|
|
303
|
-
* @version 1.2.
|
|
332
|
+
* @version 1.2.8
|
|
304
333
|
* @author Yusuke Kamiyamane
|
|
305
334
|
* @license MIT
|
|
306
335
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
307
336
|
* @see {@link https://github.com/y14e/disclosure}
|
|
308
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
|
+
*/
|
|
309
351
|
|
|
310
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",
|