@y14e/disclosure 2.2.5 → 3.0.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 +4 -4
- package/dist/index.bundle.cjs +12 -11
- package/dist/index.bundle.js +12 -11
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -60,10 +60,10 @@ new Disclosure(root);
|
|
|
60
60
|
|
|
61
61
|
## 📦 APIs
|
|
62
62
|
|
|
63
|
-
### `
|
|
63
|
+
### `close`
|
|
64
64
|
|
|
65
65
|
```ts
|
|
66
|
-
disclosure.
|
|
66
|
+
disclosure.close(details);
|
|
67
67
|
// => void
|
|
68
68
|
//
|
|
69
69
|
// details: HTMLDetailsElement
|
|
@@ -80,10 +80,10 @@ disclosure.destroy(force);
|
|
|
80
80
|
// force (optional): If true, skips waiting for animations to finish.
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
### `
|
|
83
|
+
### `open`
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
disclosure.
|
|
86
|
+
disclosure.open(details);
|
|
87
87
|
// => void
|
|
88
88
|
//
|
|
89
89
|
// details: HTMLDetailsElement
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -588,6 +588,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
588
588
|
continue;
|
|
589
589
|
}
|
|
590
590
|
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
591
|
+
console.warn("Skipping duplicate initialization:", focusable);
|
|
591
592
|
continue;
|
|
592
593
|
}
|
|
593
594
|
this.#focusables.add(focusable);
|
|
@@ -759,7 +760,7 @@ var Disclosure = class _Disclosure {
|
|
|
759
760
|
});
|
|
760
761
|
this.#initialize();
|
|
761
762
|
}
|
|
762
|
-
|
|
763
|
+
close(details) {
|
|
763
764
|
if (this.#isDestroyed) {
|
|
764
765
|
return;
|
|
765
766
|
}
|
|
@@ -800,7 +801,7 @@ var Disclosure = class _Disclosure {
|
|
|
800
801
|
this.#contentElements.length = 0;
|
|
801
802
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
802
803
|
}
|
|
803
|
-
|
|
804
|
+
open(details) {
|
|
804
805
|
if (this.#isDestroyed) {
|
|
805
806
|
return;
|
|
806
807
|
}
|
|
@@ -865,20 +866,20 @@ var Disclosure = class _Disclosure {
|
|
|
865
866
|
content.style.removeProperty(name2);
|
|
866
867
|
}
|
|
867
868
|
}
|
|
868
|
-
#toggle(details,
|
|
869
|
-
if (details.hasAttribute("data-disclosure-open") ===
|
|
869
|
+
#toggle(details, isOpen, isProgrammatic = false) {
|
|
870
|
+
if (details.hasAttribute("data-disclosure-open") === isOpen) {
|
|
870
871
|
return;
|
|
871
872
|
}
|
|
872
|
-
if (!
|
|
873
|
+
if (!isOpen && !isProgrammatic && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.hasAttribute("data-disclosure-open")).length <= 1) {
|
|
873
874
|
return;
|
|
874
875
|
}
|
|
875
876
|
const name = details.getAttribute("data-disclosure-name");
|
|
876
|
-
if (name &&
|
|
877
|
+
if (name && isOpen) {
|
|
877
878
|
details.removeAttribute("name");
|
|
878
|
-
const
|
|
879
|
+
const opened = this.#detailsElements.find(
|
|
879
880
|
(d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
|
|
880
881
|
);
|
|
881
|
-
|
|
882
|
+
opened && this.#toggle(opened, false, true);
|
|
882
883
|
}
|
|
883
884
|
const binding = this.#bindings.get(details);
|
|
884
885
|
if (!binding) {
|
|
@@ -887,12 +888,12 @@ var Disclosure = class _Disclosure {
|
|
|
887
888
|
const { content } = binding;
|
|
888
889
|
const startSize = details.open ? content.offsetHeight : 0;
|
|
889
890
|
binding.animation?.cancel();
|
|
890
|
-
if (
|
|
891
|
+
if (isOpen) {
|
|
891
892
|
details.open = true;
|
|
892
893
|
}
|
|
893
|
-
const endSize =
|
|
894
|
+
const endSize = isOpen ? content.scrollHeight : 0;
|
|
894
895
|
binding.animation?.cancel();
|
|
895
|
-
details.toggleAttribute("data-disclosure-open",
|
|
896
|
+
details.toggleAttribute("data-disclosure-open", isOpen);
|
|
896
897
|
content.style.setProperty("overflow", "clip");
|
|
897
898
|
const { duration, easing } = this.#settings.animation;
|
|
898
899
|
const animation = content.animate(
|
package/dist/index.bundle.js
CHANGED
|
@@ -586,6 +586,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
586
586
|
continue;
|
|
587
587
|
}
|
|
588
588
|
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
589
|
+
console.warn("Skipping duplicate initialization:", focusable);
|
|
589
590
|
continue;
|
|
590
591
|
}
|
|
591
592
|
this.#focusables.add(focusable);
|
|
@@ -757,7 +758,7 @@ var Disclosure = class _Disclosure {
|
|
|
757
758
|
});
|
|
758
759
|
this.#initialize();
|
|
759
760
|
}
|
|
760
|
-
|
|
761
|
+
close(details) {
|
|
761
762
|
if (this.#isDestroyed) {
|
|
762
763
|
return;
|
|
763
764
|
}
|
|
@@ -798,7 +799,7 @@ var Disclosure = class _Disclosure {
|
|
|
798
799
|
this.#contentElements.length = 0;
|
|
799
800
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
800
801
|
}
|
|
801
|
-
|
|
802
|
+
open(details) {
|
|
802
803
|
if (this.#isDestroyed) {
|
|
803
804
|
return;
|
|
804
805
|
}
|
|
@@ -863,20 +864,20 @@ var Disclosure = class _Disclosure {
|
|
|
863
864
|
content.style.removeProperty(name2);
|
|
864
865
|
}
|
|
865
866
|
}
|
|
866
|
-
#toggle(details,
|
|
867
|
-
if (details.hasAttribute("data-disclosure-open") ===
|
|
867
|
+
#toggle(details, isOpen, isProgrammatic = false) {
|
|
868
|
+
if (details.hasAttribute("data-disclosure-open") === isOpen) {
|
|
868
869
|
return;
|
|
869
870
|
}
|
|
870
|
-
if (!
|
|
871
|
+
if (!isOpen && !isProgrammatic && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.hasAttribute("data-disclosure-open")).length <= 1) {
|
|
871
872
|
return;
|
|
872
873
|
}
|
|
873
874
|
const name = details.getAttribute("data-disclosure-name");
|
|
874
|
-
if (name &&
|
|
875
|
+
if (name && isOpen) {
|
|
875
876
|
details.removeAttribute("name");
|
|
876
|
-
const
|
|
877
|
+
const opened = this.#detailsElements.find(
|
|
877
878
|
(d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
|
|
878
879
|
);
|
|
879
|
-
|
|
880
|
+
opened && this.#toggle(opened, false, true);
|
|
880
881
|
}
|
|
881
882
|
const binding = this.#bindings.get(details);
|
|
882
883
|
if (!binding) {
|
|
@@ -885,12 +886,12 @@ var Disclosure = class _Disclosure {
|
|
|
885
886
|
const { content } = binding;
|
|
886
887
|
const startSize = details.open ? content.offsetHeight : 0;
|
|
887
888
|
binding.animation?.cancel();
|
|
888
|
-
if (
|
|
889
|
+
if (isOpen) {
|
|
889
890
|
details.open = true;
|
|
890
891
|
}
|
|
891
|
-
const endSize =
|
|
892
|
+
const endSize = isOpen ? content.scrollHeight : 0;
|
|
892
893
|
binding.animation?.cancel();
|
|
893
|
-
details.toggleAttribute("data-disclosure-open",
|
|
894
|
+
details.toggleAttribute("data-disclosure-open", isOpen);
|
|
894
895
|
content.style.setProperty("overflow", "clip");
|
|
895
896
|
const { duration, easing } = this.#settings.animation;
|
|
896
897
|
const animation = content.animate(
|
package/dist/index.cjs
CHANGED
|
@@ -108,7 +108,7 @@ var Disclosure = class _Disclosure {
|
|
|
108
108
|
});
|
|
109
109
|
this.#initialize();
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
close(details) {
|
|
112
112
|
if (this.#isDestroyed) {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
@@ -149,7 +149,7 @@ var Disclosure = class _Disclosure {
|
|
|
149
149
|
this.#contentElements.length = 0;
|
|
150
150
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
open(details) {
|
|
153
153
|
if (this.#isDestroyed) {
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
@@ -214,20 +214,20 @@ var Disclosure = class _Disclosure {
|
|
|
214
214
|
content.style.removeProperty(name2);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
#toggle(details,
|
|
218
|
-
if (details.hasAttribute("data-disclosure-open") ===
|
|
217
|
+
#toggle(details, isOpen, isProgrammatic = false) {
|
|
218
|
+
if (details.hasAttribute("data-disclosure-open") === isOpen) {
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
if (!
|
|
221
|
+
if (!isOpen && !isProgrammatic && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.hasAttribute("data-disclosure-open")).length <= 1) {
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
const name = details.getAttribute("data-disclosure-name");
|
|
225
|
-
if (name &&
|
|
225
|
+
if (name && isOpen) {
|
|
226
226
|
details.removeAttribute("name");
|
|
227
|
-
const
|
|
227
|
+
const opened = this.#detailsElements.find(
|
|
228
228
|
(d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
|
|
229
229
|
);
|
|
230
|
-
|
|
230
|
+
opened && this.#toggle(opened, false, true);
|
|
231
231
|
}
|
|
232
232
|
const binding = this.#bindings.get(details);
|
|
233
233
|
if (!binding) {
|
|
@@ -236,12 +236,12 @@ var Disclosure = class _Disclosure {
|
|
|
236
236
|
const { content } = binding;
|
|
237
237
|
const startSize = details.open ? content.offsetHeight : 0;
|
|
238
238
|
binding.animation?.cancel();
|
|
239
|
-
if (
|
|
239
|
+
if (isOpen) {
|
|
240
240
|
details.open = true;
|
|
241
241
|
}
|
|
242
|
-
const endSize =
|
|
242
|
+
const endSize = isOpen ? content.scrollHeight : 0;
|
|
243
243
|
binding.animation?.cancel();
|
|
244
|
-
details.toggleAttribute("data-disclosure-open",
|
|
244
|
+
details.toggleAttribute("data-disclosure-open", isOpen);
|
|
245
245
|
content.style.setProperty("overflow", "clip");
|
|
246
246
|
const { duration, easing } = this.#settings.animation;
|
|
247
247
|
const animation = content.animate(
|
package/dist/index.d.cts
CHANGED
|
@@ -10,9 +10,9 @@ declare class Disclosure {
|
|
|
10
10
|
#private;
|
|
11
11
|
static defaults: Partial<DisclosureOptions>;
|
|
12
12
|
constructor(root: HTMLElement, options?: Partial<DisclosureOptions>);
|
|
13
|
-
|
|
13
|
+
close(details: HTMLDetailsElement): void;
|
|
14
14
|
destroy(force?: boolean): Promise<void>;
|
|
15
|
-
|
|
15
|
+
open(details: HTMLDetailsElement): void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { Disclosure, type DisclosureOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ declare class Disclosure {
|
|
|
10
10
|
#private;
|
|
11
11
|
static defaults: Partial<DisclosureOptions>;
|
|
12
12
|
constructor(root: HTMLElement, options?: Partial<DisclosureOptions>);
|
|
13
|
-
|
|
13
|
+
close(details: HTMLDetailsElement): void;
|
|
14
14
|
destroy(force?: boolean): Promise<void>;
|
|
15
|
-
|
|
15
|
+
open(details: HTMLDetailsElement): void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { Disclosure, type DisclosureOptions };
|
package/dist/index.js
CHANGED
|
@@ -106,7 +106,7 @@ var Disclosure = class _Disclosure {
|
|
|
106
106
|
});
|
|
107
107
|
this.#initialize();
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
close(details) {
|
|
110
110
|
if (this.#isDestroyed) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
@@ -147,7 +147,7 @@ var Disclosure = class _Disclosure {
|
|
|
147
147
|
this.#contentElements.length = 0;
|
|
148
148
|
this.#rootElement.removeAttribute("data-disclosure-initialized");
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
open(details) {
|
|
151
151
|
if (this.#isDestroyed) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -212,20 +212,20 @@ var Disclosure = class _Disclosure {
|
|
|
212
212
|
content.style.removeProperty(name2);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
#toggle(details,
|
|
216
|
-
if (details.hasAttribute("data-disclosure-open") ===
|
|
215
|
+
#toggle(details, isOpen, isProgrammatic = false) {
|
|
216
|
+
if (details.hasAttribute("data-disclosure-open") === isOpen) {
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
|
-
if (!
|
|
219
|
+
if (!isOpen && !isProgrammatic && !this.#settings.collapsible && this.#detailsElements.filter((d) => d.hasAttribute("data-disclosure-open")).length <= 1) {
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
const name = details.getAttribute("data-disclosure-name");
|
|
223
|
-
if (name &&
|
|
223
|
+
if (name && isOpen) {
|
|
224
224
|
details.removeAttribute("name");
|
|
225
|
-
const
|
|
225
|
+
const opened = this.#detailsElements.find(
|
|
226
226
|
(d) => d.hasAttribute("data-disclosure-open") && d.getAttribute("data-disclosure-name") === name
|
|
227
227
|
);
|
|
228
|
-
|
|
228
|
+
opened && this.#toggle(opened, false, true);
|
|
229
229
|
}
|
|
230
230
|
const binding = this.#bindings.get(details);
|
|
231
231
|
if (!binding) {
|
|
@@ -234,12 +234,12 @@ var Disclosure = class _Disclosure {
|
|
|
234
234
|
const { content } = binding;
|
|
235
235
|
const startSize = details.open ? content.offsetHeight : 0;
|
|
236
236
|
binding.animation?.cancel();
|
|
237
|
-
if (
|
|
237
|
+
if (isOpen) {
|
|
238
238
|
details.open = true;
|
|
239
239
|
}
|
|
240
|
-
const endSize =
|
|
240
|
+
const endSize = isOpen ? content.scrollHeight : 0;
|
|
241
241
|
binding.animation?.cancel();
|
|
242
|
-
details.toggleAttribute("data-disclosure-open",
|
|
242
|
+
details.toggleAttribute("data-disclosure-open", isOpen);
|
|
243
243
|
content.style.setProperty("overflow", "clip");
|
|
244
244
|
const { duration, easing } = this.#settings.animation;
|
|
245
245
|
const animation = content.animate(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a11y",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@y14e/attribute-utils": "^2.0.18",
|
|
58
|
-
"@y14e/roving-tabindex": "^3.5.
|
|
58
|
+
"@y14e/roving-tabindex": "^3.5.6"
|
|
59
59
|
}
|
|
60
60
|
}
|