@y14e/disclosure-css 2.0.11 → 2.1.0
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 +3 -3
- package/dist/index.bundle.cjs +35 -44
- package/dist/index.bundle.js +35 -44
- package/dist/index.cjs +5 -25
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm i @y14e/disclosure-css
|
|
|
13
13
|
import { Disclosure } from '@y14e/disclosure-css';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { Disclosure } from 'https://esm.sh/@y14e/disclosure-css@2.0
|
|
16
|
+
import { Disclosure } from 'https://esm.sh/@y14e/disclosure-css@2.1.0';
|
|
17
17
|
// or
|
|
18
|
-
import { Disclosure } from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure-css@2.0
|
|
18
|
+
import { Disclosure } from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure-css@2.1.0/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { Disclosure } from 'https://esm.unpkg.com/@y14e/disclosure-css@2.0
|
|
20
|
+
import { Disclosure } from 'https://esm.unpkg.com/@y14e/disclosure-css@2.1.0';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// node_modules/@y14e/attribute-utils/dist/index.js
|
|
4
|
-
var DEFAULT_PARSER = (
|
|
5
|
-
var DEFAULT_SERIALIZER = (
|
|
4
|
+
var DEFAULT_PARSER = (v) => v.split(/\s+/);
|
|
5
|
+
var DEFAULT_SERIALIZER = (t) => t.join(" ");
|
|
6
6
|
function addAttributeToken(element, name, token, options = {}) {
|
|
7
7
|
if (!isValid(element, name, token)) {
|
|
8
8
|
return;
|
|
@@ -12,7 +12,7 @@ function addAttributeToken(element, name, token, options = {}) {
|
|
|
12
12
|
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
13
13
|
if (caseInsensitive) {
|
|
14
14
|
const lower = token.toLowerCase();
|
|
15
|
-
if (tokens.every((
|
|
15
|
+
if (tokens.every((t) => t.toLowerCase() !== lower)) {
|
|
16
16
|
tokens.push(token);
|
|
17
17
|
element.setAttribute(name, serialize(tokens));
|
|
18
18
|
}
|
|
@@ -115,11 +115,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
115
115
|
skipNegativeTabIndexCheck,
|
|
116
116
|
skipVisibilityCheck
|
|
117
117
|
}) || include?.(node)) {
|
|
118
|
-
candidates
|
|
118
|
+
candidates.push(node);
|
|
119
119
|
}
|
|
120
|
-
(composed ? getComposedChildren(node) :
|
|
120
|
+
(composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
|
|
121
121
|
};
|
|
122
|
-
(composed ? getComposedChildren(container) :
|
|
122
|
+
(composed ? getComposedChildren(container) : [...container.children]).map(
|
|
123
123
|
traverse2
|
|
124
124
|
);
|
|
125
125
|
} else {
|
|
@@ -207,31 +207,31 @@ function normalizeRadioGroup(elements) {
|
|
|
207
207
|
map = /* @__PURE__ */ new Map();
|
|
208
208
|
}
|
|
209
209
|
const root = element.getRootNode();
|
|
210
|
-
let
|
|
211
|
-
if (!
|
|
212
|
-
|
|
213
|
-
map.set(root,
|
|
210
|
+
let groups = map.get(root);
|
|
211
|
+
if (!groups) {
|
|
212
|
+
groups = /* @__PURE__ */ new Map();
|
|
213
|
+
map.set(root, groups);
|
|
214
214
|
}
|
|
215
|
-
let
|
|
216
|
-
if (!
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
let group = groups.get(element.form);
|
|
216
|
+
if (!group) {
|
|
217
|
+
group = /* @__PURE__ */ new Map();
|
|
218
|
+
groups.set(element.form, group);
|
|
219
219
|
}
|
|
220
|
-
let
|
|
221
|
-
if (!
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
let radios = group.get(element.name);
|
|
221
|
+
if (!radios) {
|
|
222
|
+
radios = [];
|
|
223
|
+
group.set(element.name, radios);
|
|
224
224
|
}
|
|
225
|
-
|
|
225
|
+
radios.push(element);
|
|
226
226
|
}
|
|
227
227
|
if (!map) {
|
|
228
228
|
return elements;
|
|
229
229
|
}
|
|
230
230
|
const placeholder = /* @__PURE__ */ new Set();
|
|
231
|
-
for (const
|
|
232
|
-
for (const
|
|
233
|
-
for (const
|
|
234
|
-
const radio =
|
|
231
|
+
for (const groups of map.values()) {
|
|
232
|
+
for (const group of groups.values()) {
|
|
233
|
+
for (const radios of group.values()) {
|
|
234
|
+
const radio = radios.find((r) => r.checked) ?? radios[0];
|
|
235
235
|
radio && placeholder.add(radio);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -253,7 +253,7 @@ function sortByTabIndex(elements) {
|
|
|
253
253
|
}
|
|
254
254
|
function getComposedChildren(node) {
|
|
255
255
|
if (node instanceof ShadowRoot) {
|
|
256
|
-
return
|
|
256
|
+
return [...node.children];
|
|
257
257
|
}
|
|
258
258
|
if (!(node instanceof Element)) {
|
|
259
259
|
return [];
|
|
@@ -265,9 +265,9 @@ function getComposedChildren(node) {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
|
|
268
|
-
return
|
|
268
|
+
return [...node.shadowRoot.children];
|
|
269
269
|
}
|
|
270
|
-
return
|
|
270
|
+
return [...node.children];
|
|
271
271
|
}
|
|
272
272
|
function focusElement(element) {
|
|
273
273
|
"focus" in element && typeof element.focus === "function" && element.focus();
|
|
@@ -279,13 +279,6 @@ function getActiveElement() {
|
|
|
279
279
|
}
|
|
280
280
|
return current;
|
|
281
281
|
}
|
|
282
|
-
function getChildren(node) {
|
|
283
|
-
const elements = [];
|
|
284
|
-
for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
|
|
285
|
-
elements[elements.length] = child;
|
|
286
|
-
}
|
|
287
|
-
return elements;
|
|
288
|
-
}
|
|
289
282
|
function getTabIndex(element) {
|
|
290
283
|
return "tabIndex" in element ? Number(element.tabIndex) : 0;
|
|
291
284
|
}
|
|
@@ -443,7 +436,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
443
436
|
}
|
|
444
437
|
}
|
|
445
438
|
const candidates = this.#getFocusables().filter(
|
|
446
|
-
(
|
|
439
|
+
(f) => this.#focusables.has(f)
|
|
447
440
|
);
|
|
448
441
|
const active = getActiveElement();
|
|
449
442
|
if (!(active instanceof Element)) {
|
|
@@ -480,11 +473,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
480
473
|
const focusablesByFirstChar = new Set(
|
|
481
474
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
482
475
|
);
|
|
483
|
-
focusables = candidates.filter(
|
|
484
|
-
(candidate) => focusablesByFirstChar.has(candidate)
|
|
485
|
-
);
|
|
476
|
+
focusables = candidates.filter((c) => focusablesByFirstChar.has(c));
|
|
486
477
|
const afterIndex = focusables.findIndex(
|
|
487
|
-
(
|
|
478
|
+
(f) => candidates.indexOf(f) > activeIndex
|
|
488
479
|
);
|
|
489
480
|
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
490
481
|
}
|
|
@@ -528,7 +519,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
528
519
|
const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
|
|
529
520
|
const value = focusable.ariaKeyShortcuts?.trim();
|
|
530
521
|
const keys = new Set(
|
|
531
|
-
value ? value.split(/\s+/).filter((
|
|
522
|
+
value ? value.split(/\s+/).filter((k) => /^\S$/i.test(k)).map((k) => k.toUpperCase()) : []
|
|
532
523
|
);
|
|
533
524
|
if (char) {
|
|
534
525
|
keys.add(char);
|
|
@@ -763,7 +754,7 @@ var Disclosure = class _Disclosure {
|
|
|
763
754
|
if (details.open === isExpand) {
|
|
764
755
|
return;
|
|
765
756
|
}
|
|
766
|
-
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((
|
|
757
|
+
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.open).length <= 1) {
|
|
767
758
|
return;
|
|
768
759
|
}
|
|
769
760
|
details.open = isExpand;
|
|
@@ -789,7 +780,7 @@ var Disclosure = class _Disclosure {
|
|
|
789
780
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
790
781
|
* Using the <details> and <summary> element.
|
|
791
782
|
*
|
|
792
|
-
* @version 2.0
|
|
783
|
+
* @version 2.1.0
|
|
793
784
|
* @author Yusuke Kamiyamane
|
|
794
785
|
* @license MIT
|
|
795
786
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -801,7 +792,7 @@ var Disclosure = class _Disclosure {
|
|
|
801
792
|
(**
|
|
802
793
|
* Attribute Utils
|
|
803
794
|
*
|
|
804
|
-
* @version 2.0.
|
|
795
|
+
* @version 2.0.12
|
|
805
796
|
* @author Yusuke Kamiyamane
|
|
806
797
|
* @license MIT
|
|
807
798
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -814,7 +805,7 @@ power-focusable/dist/index.js:
|
|
|
814
805
|
* High-precision focus management utility with full composed tree support.
|
|
815
806
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
816
807
|
*
|
|
817
|
-
* @version 4.3.
|
|
808
|
+
* @version 4.3.33
|
|
818
809
|
* @author Yusuke Kamiyamane
|
|
819
810
|
* @license MIT
|
|
820
811
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -827,7 +818,7 @@ power-focusable/dist/index.js:
|
|
|
827
818
|
* Lightweight roving tabindex utility with fully focus management.
|
|
828
819
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
829
820
|
*
|
|
830
|
-
* @version 3.1.
|
|
821
|
+
* @version 3.1.31
|
|
831
822
|
* @author Yusuke Kamiyamane
|
|
832
823
|
* @license MIT
|
|
833
824
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.bundle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// node_modules/@y14e/attribute-utils/dist/index.js
|
|
2
|
-
var DEFAULT_PARSER = (
|
|
3
|
-
var DEFAULT_SERIALIZER = (
|
|
2
|
+
var DEFAULT_PARSER = (v) => v.split(/\s+/);
|
|
3
|
+
var DEFAULT_SERIALIZER = (t) => t.join(" ");
|
|
4
4
|
function addAttributeToken(element, name, token, options = {}) {
|
|
5
5
|
if (!isValid(element, name, token)) {
|
|
6
6
|
return;
|
|
@@ -10,7 +10,7 @@ function addAttributeToken(element, name, token, options = {}) {
|
|
|
10
10
|
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
11
11
|
if (caseInsensitive) {
|
|
12
12
|
const lower = token.toLowerCase();
|
|
13
|
-
if (tokens.every((
|
|
13
|
+
if (tokens.every((t) => t.toLowerCase() !== lower)) {
|
|
14
14
|
tokens.push(token);
|
|
15
15
|
element.setAttribute(name, serialize(tokens));
|
|
16
16
|
}
|
|
@@ -113,11 +113,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
113
113
|
skipNegativeTabIndexCheck,
|
|
114
114
|
skipVisibilityCheck
|
|
115
115
|
}) || include?.(node)) {
|
|
116
|
-
candidates
|
|
116
|
+
candidates.push(node);
|
|
117
117
|
}
|
|
118
|
-
(composed ? getComposedChildren(node) :
|
|
118
|
+
(composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
|
|
119
119
|
};
|
|
120
|
-
(composed ? getComposedChildren(container) :
|
|
120
|
+
(composed ? getComposedChildren(container) : [...container.children]).map(
|
|
121
121
|
traverse2
|
|
122
122
|
);
|
|
123
123
|
} else {
|
|
@@ -205,31 +205,31 @@ function normalizeRadioGroup(elements) {
|
|
|
205
205
|
map = /* @__PURE__ */ new Map();
|
|
206
206
|
}
|
|
207
207
|
const root = element.getRootNode();
|
|
208
|
-
let
|
|
209
|
-
if (!
|
|
210
|
-
|
|
211
|
-
map.set(root,
|
|
208
|
+
let groups = map.get(root);
|
|
209
|
+
if (!groups) {
|
|
210
|
+
groups = /* @__PURE__ */ new Map();
|
|
211
|
+
map.set(root, groups);
|
|
212
212
|
}
|
|
213
|
-
let
|
|
214
|
-
if (!
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
let group = groups.get(element.form);
|
|
214
|
+
if (!group) {
|
|
215
|
+
group = /* @__PURE__ */ new Map();
|
|
216
|
+
groups.set(element.form, group);
|
|
217
217
|
}
|
|
218
|
-
let
|
|
219
|
-
if (!
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
let radios = group.get(element.name);
|
|
219
|
+
if (!radios) {
|
|
220
|
+
radios = [];
|
|
221
|
+
group.set(element.name, radios);
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
radios.push(element);
|
|
224
224
|
}
|
|
225
225
|
if (!map) {
|
|
226
226
|
return elements;
|
|
227
227
|
}
|
|
228
228
|
const placeholder = /* @__PURE__ */ new Set();
|
|
229
|
-
for (const
|
|
230
|
-
for (const
|
|
231
|
-
for (const
|
|
232
|
-
const radio =
|
|
229
|
+
for (const groups of map.values()) {
|
|
230
|
+
for (const group of groups.values()) {
|
|
231
|
+
for (const radios of group.values()) {
|
|
232
|
+
const radio = radios.find((r) => r.checked) ?? radios[0];
|
|
233
233
|
radio && placeholder.add(radio);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -251,7 +251,7 @@ function sortByTabIndex(elements) {
|
|
|
251
251
|
}
|
|
252
252
|
function getComposedChildren(node) {
|
|
253
253
|
if (node instanceof ShadowRoot) {
|
|
254
|
-
return
|
|
254
|
+
return [...node.children];
|
|
255
255
|
}
|
|
256
256
|
if (!(node instanceof Element)) {
|
|
257
257
|
return [];
|
|
@@ -263,9 +263,9 @@ function getComposedChildren(node) {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
|
|
266
|
-
return
|
|
266
|
+
return [...node.shadowRoot.children];
|
|
267
267
|
}
|
|
268
|
-
return
|
|
268
|
+
return [...node.children];
|
|
269
269
|
}
|
|
270
270
|
function focusElement(element) {
|
|
271
271
|
"focus" in element && typeof element.focus === "function" && element.focus();
|
|
@@ -277,13 +277,6 @@ function getActiveElement() {
|
|
|
277
277
|
}
|
|
278
278
|
return current;
|
|
279
279
|
}
|
|
280
|
-
function getChildren(node) {
|
|
281
|
-
const elements = [];
|
|
282
|
-
for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
|
|
283
|
-
elements[elements.length] = child;
|
|
284
|
-
}
|
|
285
|
-
return elements;
|
|
286
|
-
}
|
|
287
280
|
function getTabIndex(element) {
|
|
288
281
|
return "tabIndex" in element ? Number(element.tabIndex) : 0;
|
|
289
282
|
}
|
|
@@ -441,7 +434,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
441
434
|
}
|
|
442
435
|
}
|
|
443
436
|
const candidates = this.#getFocusables().filter(
|
|
444
|
-
(
|
|
437
|
+
(f) => this.#focusables.has(f)
|
|
445
438
|
);
|
|
446
439
|
const active = getActiveElement();
|
|
447
440
|
if (!(active instanceof Element)) {
|
|
@@ -478,11 +471,9 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
478
471
|
const focusablesByFirstChar = new Set(
|
|
479
472
|
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
480
473
|
);
|
|
481
|
-
focusables = candidates.filter(
|
|
482
|
-
(candidate) => focusablesByFirstChar.has(candidate)
|
|
483
|
-
);
|
|
474
|
+
focusables = candidates.filter((c) => focusablesByFirstChar.has(c));
|
|
484
475
|
const afterIndex = focusables.findIndex(
|
|
485
|
-
(
|
|
476
|
+
(f) => candidates.indexOf(f) > activeIndex
|
|
486
477
|
);
|
|
487
478
|
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
488
479
|
}
|
|
@@ -526,7 +517,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
526
517
|
const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
|
|
527
518
|
const value = focusable.ariaKeyShortcuts?.trim();
|
|
528
519
|
const keys = new Set(
|
|
529
|
-
value ? value.split(/\s+/).filter((
|
|
520
|
+
value ? value.split(/\s+/).filter((k) => /^\S$/i.test(k)).map((k) => k.toUpperCase()) : []
|
|
530
521
|
);
|
|
531
522
|
if (char) {
|
|
532
523
|
keys.add(char);
|
|
@@ -761,7 +752,7 @@ var Disclosure = class _Disclosure {
|
|
|
761
752
|
if (details.open === isExpand) {
|
|
762
753
|
return;
|
|
763
754
|
}
|
|
764
|
-
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((
|
|
755
|
+
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.open).length <= 1) {
|
|
765
756
|
return;
|
|
766
757
|
}
|
|
767
758
|
details.open = isExpand;
|
|
@@ -787,7 +778,7 @@ var Disclosure = class _Disclosure {
|
|
|
787
778
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
788
779
|
* Using the <details> and <summary> element.
|
|
789
780
|
*
|
|
790
|
-
* @version 2.0
|
|
781
|
+
* @version 2.1.0
|
|
791
782
|
* @author Yusuke Kamiyamane
|
|
792
783
|
* @license MIT
|
|
793
784
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -799,7 +790,7 @@ var Disclosure = class _Disclosure {
|
|
|
799
790
|
(**
|
|
800
791
|
* Attribute Utils
|
|
801
792
|
*
|
|
802
|
-
* @version 2.0.
|
|
793
|
+
* @version 2.0.12
|
|
803
794
|
* @author Yusuke Kamiyamane
|
|
804
795
|
* @license MIT
|
|
805
796
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -812,7 +803,7 @@ power-focusable/dist/index.js:
|
|
|
812
803
|
* High-precision focus management utility with full composed tree support.
|
|
813
804
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
814
805
|
*
|
|
815
|
-
* @version 4.3.
|
|
806
|
+
* @version 4.3.33
|
|
816
807
|
* @author Yusuke Kamiyamane
|
|
817
808
|
* @license MIT
|
|
818
809
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -825,7 +816,7 @@ power-focusable/dist/index.js:
|
|
|
825
816
|
* Lightweight roving tabindex utility with fully focus management.
|
|
826
817
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
827
818
|
*
|
|
828
|
-
* @version 3.1.
|
|
819
|
+
* @version 3.1.31
|
|
829
820
|
* @author Yusuke Kamiyamane
|
|
830
821
|
* @license MIT
|
|
831
822
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var attributeUtils = require('@y14e/attribute-utils');
|
|
4
4
|
var rovingTabindex = require('@y14e/roving-tabindex');
|
|
5
5
|
|
|
6
|
-
function _interopNamespace(e) {
|
|
7
|
-
if (e && e.__esModule) return e;
|
|
8
|
-
var n = Object.create(null);
|
|
9
|
-
if (e) {
|
|
10
|
-
Object.keys(e).forEach(function (k) {
|
|
11
|
-
if (k !== 'default') {
|
|
12
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return e[k]; }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
|
|
25
|
-
|
|
26
6
|
// src/index.ts
|
|
27
7
|
var Disclosure = class _Disclosure {
|
|
28
8
|
static defaults = {};
|
|
@@ -108,7 +88,7 @@ var Disclosure = class _Disclosure {
|
|
|
108
88
|
this.#cleanupRovingTabIndex?.();
|
|
109
89
|
this.#cleanupRovingTabIndex = null;
|
|
110
90
|
this.#detailsElements.length = 0;
|
|
111
|
-
|
|
91
|
+
attributeUtils.restoreAttributes(this.#summaryElements);
|
|
112
92
|
this.#summaryElements.length = 0;
|
|
113
93
|
this.#contentElements.length = 0;
|
|
114
94
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
@@ -124,7 +104,7 @@ var Disclosure = class _Disclosure {
|
|
|
124
104
|
this.#toggle(details, true);
|
|
125
105
|
}
|
|
126
106
|
#initialize() {
|
|
127
|
-
|
|
107
|
+
attributeUtils.saveAttributes(this.#summaryElements, [
|
|
128
108
|
"aria-disabled",
|
|
129
109
|
"style",
|
|
130
110
|
"tabindex"
|
|
@@ -164,7 +144,7 @@ var Disclosure = class _Disclosure {
|
|
|
164
144
|
if (details.open === isExpand) {
|
|
165
145
|
return;
|
|
166
146
|
}
|
|
167
|
-
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((
|
|
147
|
+
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.open).length <= 1) {
|
|
168
148
|
return;
|
|
169
149
|
}
|
|
170
150
|
details.open = isExpand;
|
|
@@ -190,7 +170,7 @@ var Disclosure = class _Disclosure {
|
|
|
190
170
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
191
171
|
* Using the <details> and <summary> element.
|
|
192
172
|
*
|
|
193
|
-
* @version 2.0
|
|
173
|
+
* @version 2.1.0
|
|
194
174
|
* @author Yusuke Kamiyamane
|
|
195
175
|
* @license MIT
|
|
196
176
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { restoreAttributes, saveAttributes } from '@y14e/attribute-utils';
|
|
2
2
|
import { createRovingTabIndex } from '@y14e/roving-tabindex';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
@@ -86,7 +86,7 @@ var Disclosure = class _Disclosure {
|
|
|
86
86
|
this.#cleanupRovingTabIndex?.();
|
|
87
87
|
this.#cleanupRovingTabIndex = null;
|
|
88
88
|
this.#detailsElements.length = 0;
|
|
89
|
-
|
|
89
|
+
restoreAttributes(this.#summaryElements);
|
|
90
90
|
this.#summaryElements.length = 0;
|
|
91
91
|
this.#contentElements.length = 0;
|
|
92
92
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
@@ -102,7 +102,7 @@ var Disclosure = class _Disclosure {
|
|
|
102
102
|
this.#toggle(details, true);
|
|
103
103
|
}
|
|
104
104
|
#initialize() {
|
|
105
|
-
|
|
105
|
+
saveAttributes(this.#summaryElements, [
|
|
106
106
|
"aria-disabled",
|
|
107
107
|
"style",
|
|
108
108
|
"tabindex"
|
|
@@ -142,7 +142,7 @@ var Disclosure = class _Disclosure {
|
|
|
142
142
|
if (details.open === isExpand) {
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((
|
|
145
|
+
if (!isExpand && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.open).length <= 1) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
details.open = isExpand;
|
|
@@ -168,7 +168,7 @@ var Disclosure = class _Disclosure {
|
|
|
168
168
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
169
169
|
* Using the <details> and <summary> element.
|
|
170
170
|
*
|
|
171
|
-
* @version 2.0
|
|
171
|
+
* @version 2.1.0
|
|
172
172
|
* @author Yusuke Kamiyamane
|
|
173
173
|
* @license MIT
|
|
174
174
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure-css",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a11y",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"esbuild": true
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@y14e/attribute-utils": "^2.0.
|
|
58
|
-
"@y14e/roving-tabindex": "^3.1.
|
|
57
|
+
"@y14e/attribute-utils": "^2.0.12",
|
|
58
|
+
"@y14e/roving-tabindex": "^3.1.31"
|
|
59
59
|
}
|
|
60
60
|
}
|