@y14e/disclosure 1.3.9 → 1.3.11
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.cjs +55 -74
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -74
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@ npm i @y14e/disclosure
|
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// npm
|
|
13
|
-
import Disclosure from '@y14e/disclosure@1.3.
|
|
13
|
+
import Disclosure from '@y14e/disclosure@1.3.11';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import Disclosure from 'https://esm.sh/@y14e/disclosure@1.3.
|
|
16
|
+
import Disclosure from 'https://esm.sh/@y14e/disclosure@1.3.11';
|
|
17
17
|
// or
|
|
18
|
-
import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@1.3.
|
|
18
|
+
import Disclosure from 'https://cdn.jsdelivr.net/npm/@y14e/disclosure@1.3.11/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@1.3.
|
|
20
|
+
import Disclosure from 'https://esm.unpkg.com/@y14e/disclosure@1.3.11';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -28,13 +28,13 @@ function saveAttributes(elements, attributes) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
31
|
-
var
|
|
32
|
-
var
|
|
31
|
+
var DEFAULT_PARSER = (value) => value.split(/\s+/);
|
|
32
|
+
var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
|
|
33
33
|
function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
34
34
|
const {
|
|
35
35
|
caseInsensitive = false,
|
|
36
|
-
parse =
|
|
37
|
-
serialize =
|
|
36
|
+
parse = DEFAULT_PARSER,
|
|
37
|
+
serialize = DEFAULT_SERIALIZER
|
|
38
38
|
} = options;
|
|
39
39
|
const value = element.getAttribute(attribute)?.trim();
|
|
40
40
|
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
@@ -44,11 +44,11 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
|
44
44
|
tokens.push(token);
|
|
45
45
|
element.setAttribute(attribute, serialize(tokens));
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
} else {
|
|
48
|
+
const set = new Set(tokens);
|
|
49
|
+
set.add(token);
|
|
50
|
+
element.setAttribute(attribute, serialize([...set]));
|
|
48
51
|
}
|
|
49
|
-
const set = new Set(tokens);
|
|
50
|
-
set.add(token);
|
|
51
|
-
element.setAttribute(attribute, serialize([...set]));
|
|
52
52
|
}
|
|
53
53
|
var snapshots2 = /* @__PURE__ */ new WeakMap();
|
|
54
54
|
function restoreAttributes2(elements) {
|
|
@@ -115,21 +115,16 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
115
115
|
const elements = [];
|
|
116
116
|
if (composed || include) {
|
|
117
117
|
let traverse2 = function(node) {
|
|
118
|
-
if (node instanceof Element) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
elements[elements.length] = node;
|
|
124
|
-
}
|
|
118
|
+
if (!(node instanceof Element)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (isFocusable(node, { skipNegativeTabIndexCheck, skipVisibilityCheck }) || include?.(node)) {
|
|
122
|
+
elements[elements.length] = node;
|
|
125
123
|
}
|
|
126
124
|
const children = getComposedChildren(node);
|
|
127
125
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
128
126
|
const child = children[i];
|
|
129
|
-
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
traverse2(child);
|
|
127
|
+
child && traverse2(child);
|
|
133
128
|
}
|
|
134
129
|
};
|
|
135
130
|
traverse2(container);
|
|
@@ -137,10 +132,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
137
132
|
const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
138
133
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
139
134
|
const candidate = candidates[i];
|
|
140
|
-
if (
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (isFocusable(candidate, {
|
|
135
|
+
if (candidate && isFocusable(candidate, {
|
|
144
136
|
skipNegativeTabIndexCheck,
|
|
145
137
|
skipVisibilityCheck
|
|
146
138
|
})) {
|
|
@@ -243,23 +235,19 @@ function normalizeRadioGroup(elements) {
|
|
|
243
235
|
for (const group of map.values()) {
|
|
244
236
|
placeholder.add(group.find((radio) => radio.checked) ?? group[0]);
|
|
245
237
|
}
|
|
246
|
-
return elements.filter(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
return true;
|
|
251
|
-
});
|
|
238
|
+
return elements.filter(
|
|
239
|
+
(element) => isUngroupedRadio(element) ? placeholder.has(element) : true
|
|
240
|
+
);
|
|
252
241
|
}
|
|
253
242
|
function sortByTabIndex(elements) {
|
|
254
243
|
const ordered = [];
|
|
255
244
|
const natural = [];
|
|
256
245
|
for (let i = 0, l = elements.length; i < l; i++) {
|
|
257
246
|
const element = elements[i];
|
|
258
|
-
if (
|
|
259
|
-
|
|
247
|
+
if (element) {
|
|
248
|
+
const target = getTabIndex(element) > 0 ? ordered : natural;
|
|
249
|
+
target[target.length] = element;
|
|
260
250
|
}
|
|
261
|
-
const target = getTabIndex(element) > 0 ? ordered : natural;
|
|
262
|
-
target[target.length] = element;
|
|
263
251
|
}
|
|
264
252
|
ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
|
|
265
253
|
let count = 0;
|
|
@@ -416,11 +404,7 @@ var RovingTabIndex = class {
|
|
|
416
404
|
return;
|
|
417
405
|
}
|
|
418
406
|
const isFocusable22 = this.#focusables.has(target);
|
|
419
|
-
|
|
420
|
-
this.#update(null);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
isFocusable22 && this.#update(target);
|
|
407
|
+
this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
|
|
424
408
|
};
|
|
425
409
|
#onKeyDown = (event) => {
|
|
426
410
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -453,8 +437,7 @@ var RovingTabIndex = class {
|
|
|
453
437
|
}
|
|
454
438
|
event.preventDefault();
|
|
455
439
|
const currentIndex = current.indexOf(active);
|
|
456
|
-
let
|
|
457
|
-
let newIndex = currentIndex;
|
|
440
|
+
let newIndex;
|
|
458
441
|
let target = current;
|
|
459
442
|
switch (key) {
|
|
460
443
|
case "End":
|
|
@@ -464,15 +447,17 @@ var RovingTabIndex = class {
|
|
|
464
447
|
newIndex = 0;
|
|
465
448
|
break;
|
|
466
449
|
case "ArrowLeft":
|
|
467
|
-
case "ArrowUp":
|
|
468
|
-
rawIndex = currentIndex - 1;
|
|
450
|
+
case "ArrowUp": {
|
|
451
|
+
const rawIndex = currentIndex - 1;
|
|
469
452
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
470
453
|
break;
|
|
454
|
+
}
|
|
471
455
|
case "ArrowRight":
|
|
472
|
-
case "ArrowDown":
|
|
473
|
-
rawIndex = currentIndex + 1;
|
|
456
|
+
case "ArrowDown": {
|
|
457
|
+
const rawIndex = currentIndex + 1;
|
|
474
458
|
newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
|
|
475
459
|
break;
|
|
460
|
+
}
|
|
476
461
|
default: {
|
|
477
462
|
target = this.#focusablesByFirstChar.get(key.toUpperCase()) ?? [];
|
|
478
463
|
const foundIndex = target.findIndex(
|
|
@@ -487,15 +472,14 @@ var RovingTabIndex = class {
|
|
|
487
472
|
#update(active) {
|
|
488
473
|
const current = new Set(this.#getFocusables());
|
|
489
474
|
for (const focusable of this.#focusables) {
|
|
490
|
-
if (current.has(focusable)) {
|
|
491
|
-
|
|
475
|
+
if (!current.has(focusable)) {
|
|
476
|
+
focusable.isConnected && restoreAttributes2([focusable]);
|
|
477
|
+
this.#focusables.delete(focusable);
|
|
478
|
+
this.#focusablesByFirstChar.forEach((focusables) => {
|
|
479
|
+
const index = focusables.indexOf(focusable);
|
|
480
|
+
index >= 0 && focusables.splice(index, 1);
|
|
481
|
+
});
|
|
492
482
|
}
|
|
493
|
-
focusable.isConnected && restoreAttributes2([focusable]);
|
|
494
|
-
this.#focusables.delete(focusable);
|
|
495
|
-
this.#focusablesByFirstChar.forEach((focusables) => {
|
|
496
|
-
const index = focusables.indexOf(focusable);
|
|
497
|
-
index >= 0 && focusables.splice(index, 1);
|
|
498
|
-
});
|
|
499
483
|
}
|
|
500
484
|
const { navigationOnly, noStart, typeahead } = this.#options;
|
|
501
485
|
for (const focusable of current) {
|
|
@@ -528,18 +512,17 @@ var RovingTabIndex = class {
|
|
|
528
512
|
this.#focusablesByFirstChar.set(key, focusables);
|
|
529
513
|
});
|
|
530
514
|
}
|
|
531
|
-
if (navigationOnly) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
515
|
+
if (!navigationOnly) {
|
|
516
|
+
if (active && this.#focusables.has(active)) {
|
|
517
|
+
this.#focusables.forEach((focusable) => {
|
|
518
|
+
focusable.setAttribute("tabindex", focusable === active ? "0" : "-1");
|
|
519
|
+
});
|
|
520
|
+
} else {
|
|
521
|
+
[...this.#focusables].forEach((focusable, i) => {
|
|
522
|
+
focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
|
|
523
|
+
});
|
|
524
|
+
}
|
|
539
525
|
}
|
|
540
|
-
[...this.#focusables].forEach((focusable, i) => {
|
|
541
|
-
focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
|
|
542
|
-
});
|
|
543
526
|
}
|
|
544
527
|
#createSelectorFilter() {
|
|
545
528
|
const { selector } = this.#options;
|
|
@@ -785,11 +768,10 @@ var Disclosure = class _Disclosure {
|
|
|
785
768
|
animation.addEventListener(
|
|
786
769
|
"finish",
|
|
787
770
|
() => {
|
|
788
|
-
if (binding?.animation
|
|
789
|
-
|
|
771
|
+
if (binding?.animation === animation) {
|
|
772
|
+
this.#onAnimationFinish(content);
|
|
773
|
+
cleanup();
|
|
790
774
|
}
|
|
791
|
-
this.#onAnimationFinish(content);
|
|
792
|
-
cleanup();
|
|
793
775
|
},
|
|
794
776
|
{ once: true, signal }
|
|
795
777
|
);
|
|
@@ -833,8 +815,7 @@ function isFocusable2(element) {
|
|
|
833
815
|
return element.tabIndex >= 0;
|
|
834
816
|
}
|
|
835
817
|
function waitAnimationFinish(animation) {
|
|
836
|
-
|
|
837
|
-
if (playState === "idle" || playState === "finished") {
|
|
818
|
+
if (["idle", "finished"].includes(animation.playState)) {
|
|
838
819
|
return Promise.resolve();
|
|
839
820
|
}
|
|
840
821
|
return new Promise(
|
|
@@ -846,7 +827,7 @@ function waitAnimationFinish(animation) {
|
|
|
846
827
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
847
828
|
* Using the <details> and <summary> element.
|
|
848
829
|
*
|
|
849
|
-
* @version 1.3.
|
|
830
|
+
* @version 1.3.11
|
|
850
831
|
* @author Yusuke Kamiyamane
|
|
851
832
|
* @license MIT
|
|
852
833
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -858,7 +839,7 @@ function waitAnimationFinish(animation) {
|
|
|
858
839
|
(**
|
|
859
840
|
* Attributes Utils
|
|
860
841
|
*
|
|
861
|
-
* @version 1.1.
|
|
842
|
+
* @version 1.1.2
|
|
862
843
|
* @author Yusuke Kamiyamane
|
|
863
844
|
* @license MIT
|
|
864
845
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -871,7 +852,7 @@ function waitAnimationFinish(animation) {
|
|
|
871
852
|
* Lightweight roving tabindex utility with fully focus management.
|
|
872
853
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
873
854
|
*
|
|
874
|
-
* @version 3.0.
|
|
855
|
+
* @version 3.0.2
|
|
875
856
|
* @author Yusuke Kamiyamane
|
|
876
857
|
* @license MIT
|
|
877
858
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -883,7 +864,7 @@ function waitAnimationFinish(animation) {
|
|
|
883
864
|
(**
|
|
884
865
|
* Attributes Utils
|
|
885
866
|
*
|
|
886
|
-
* @version 1.1.
|
|
867
|
+
* @version 1.1.2
|
|
887
868
|
* @author Yusuke Kamiyamane
|
|
888
869
|
* @license MIT
|
|
889
870
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -896,7 +877,7 @@ function waitAnimationFinish(animation) {
|
|
|
896
877
|
* High-precision focus management utility with full composed tree support.
|
|
897
878
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
898
879
|
*
|
|
899
|
-
* @version 4.3.
|
|
880
|
+
* @version 4.3.3
|
|
900
881
|
* @author Yusuke Kamiyamane
|
|
901
882
|
* @license MIT
|
|
902
883
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -26,13 +26,13 @@ function saveAttributes(elements, attributes) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
29
|
-
var
|
|
30
|
-
var
|
|
29
|
+
var DEFAULT_PARSER = (value) => value.split(/\s+/);
|
|
30
|
+
var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
|
|
31
31
|
function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
32
32
|
const {
|
|
33
33
|
caseInsensitive = false,
|
|
34
|
-
parse =
|
|
35
|
-
serialize =
|
|
34
|
+
parse = DEFAULT_PARSER,
|
|
35
|
+
serialize = DEFAULT_SERIALIZER
|
|
36
36
|
} = options;
|
|
37
37
|
const value = element.getAttribute(attribute)?.trim();
|
|
38
38
|
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
@@ -42,11 +42,11 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
|
42
42
|
tokens.push(token);
|
|
43
43
|
element.setAttribute(attribute, serialize(tokens));
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
} else {
|
|
46
|
+
const set = new Set(tokens);
|
|
47
|
+
set.add(token);
|
|
48
|
+
element.setAttribute(attribute, serialize([...set]));
|
|
46
49
|
}
|
|
47
|
-
const set = new Set(tokens);
|
|
48
|
-
set.add(token);
|
|
49
|
-
element.setAttribute(attribute, serialize([...set]));
|
|
50
50
|
}
|
|
51
51
|
var snapshots2 = /* @__PURE__ */ new WeakMap();
|
|
52
52
|
function restoreAttributes2(elements) {
|
|
@@ -113,21 +113,16 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
113
113
|
const elements = [];
|
|
114
114
|
if (composed || include) {
|
|
115
115
|
let traverse2 = function(node) {
|
|
116
|
-
if (node instanceof Element) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
elements[elements.length] = node;
|
|
122
|
-
}
|
|
116
|
+
if (!(node instanceof Element)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (isFocusable(node, { skipNegativeTabIndexCheck, skipVisibilityCheck }) || include?.(node)) {
|
|
120
|
+
elements[elements.length] = node;
|
|
123
121
|
}
|
|
124
122
|
const children = getComposedChildren(node);
|
|
125
123
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
126
124
|
const child = children[i];
|
|
127
|
-
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
traverse2(child);
|
|
125
|
+
child && traverse2(child);
|
|
131
126
|
}
|
|
132
127
|
};
|
|
133
128
|
traverse2(container);
|
|
@@ -135,10 +130,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
135
130
|
const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
136
131
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
137
132
|
const candidate = candidates[i];
|
|
138
|
-
if (
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (isFocusable(candidate, {
|
|
133
|
+
if (candidate && isFocusable(candidate, {
|
|
142
134
|
skipNegativeTabIndexCheck,
|
|
143
135
|
skipVisibilityCheck
|
|
144
136
|
})) {
|
|
@@ -241,23 +233,19 @@ function normalizeRadioGroup(elements) {
|
|
|
241
233
|
for (const group of map.values()) {
|
|
242
234
|
placeholder.add(group.find((radio) => radio.checked) ?? group[0]);
|
|
243
235
|
}
|
|
244
|
-
return elements.filter(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
return true;
|
|
249
|
-
});
|
|
236
|
+
return elements.filter(
|
|
237
|
+
(element) => isUngroupedRadio(element) ? placeholder.has(element) : true
|
|
238
|
+
);
|
|
250
239
|
}
|
|
251
240
|
function sortByTabIndex(elements) {
|
|
252
241
|
const ordered = [];
|
|
253
242
|
const natural = [];
|
|
254
243
|
for (let i = 0, l = elements.length; i < l; i++) {
|
|
255
244
|
const element = elements[i];
|
|
256
|
-
if (
|
|
257
|
-
|
|
245
|
+
if (element) {
|
|
246
|
+
const target = getTabIndex(element) > 0 ? ordered : natural;
|
|
247
|
+
target[target.length] = element;
|
|
258
248
|
}
|
|
259
|
-
const target = getTabIndex(element) > 0 ? ordered : natural;
|
|
260
|
-
target[target.length] = element;
|
|
261
249
|
}
|
|
262
250
|
ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
|
|
263
251
|
let count = 0;
|
|
@@ -414,11 +402,7 @@ var RovingTabIndex = class {
|
|
|
414
402
|
return;
|
|
415
403
|
}
|
|
416
404
|
const isFocusable22 = this.#focusables.has(target);
|
|
417
|
-
|
|
418
|
-
this.#update(null);
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
isFocusable22 && this.#update(target);
|
|
405
|
+
this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
|
|
422
406
|
};
|
|
423
407
|
#onKeyDown = (event) => {
|
|
424
408
|
if (!event.composedPath().includes(this.#container)) {
|
|
@@ -451,8 +435,7 @@ var RovingTabIndex = class {
|
|
|
451
435
|
}
|
|
452
436
|
event.preventDefault();
|
|
453
437
|
const currentIndex = current.indexOf(active);
|
|
454
|
-
let
|
|
455
|
-
let newIndex = currentIndex;
|
|
438
|
+
let newIndex;
|
|
456
439
|
let target = current;
|
|
457
440
|
switch (key) {
|
|
458
441
|
case "End":
|
|
@@ -462,15 +445,17 @@ var RovingTabIndex = class {
|
|
|
462
445
|
newIndex = 0;
|
|
463
446
|
break;
|
|
464
447
|
case "ArrowLeft":
|
|
465
|
-
case "ArrowUp":
|
|
466
|
-
rawIndex = currentIndex - 1;
|
|
448
|
+
case "ArrowUp": {
|
|
449
|
+
const rawIndex = currentIndex - 1;
|
|
467
450
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
468
451
|
break;
|
|
452
|
+
}
|
|
469
453
|
case "ArrowRight":
|
|
470
|
-
case "ArrowDown":
|
|
471
|
-
rawIndex = currentIndex + 1;
|
|
454
|
+
case "ArrowDown": {
|
|
455
|
+
const rawIndex = currentIndex + 1;
|
|
472
456
|
newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
|
|
473
457
|
break;
|
|
458
|
+
}
|
|
474
459
|
default: {
|
|
475
460
|
target = this.#focusablesByFirstChar.get(key.toUpperCase()) ?? [];
|
|
476
461
|
const foundIndex = target.findIndex(
|
|
@@ -485,15 +470,14 @@ var RovingTabIndex = class {
|
|
|
485
470
|
#update(active) {
|
|
486
471
|
const current = new Set(this.#getFocusables());
|
|
487
472
|
for (const focusable of this.#focusables) {
|
|
488
|
-
if (current.has(focusable)) {
|
|
489
|
-
|
|
473
|
+
if (!current.has(focusable)) {
|
|
474
|
+
focusable.isConnected && restoreAttributes2([focusable]);
|
|
475
|
+
this.#focusables.delete(focusable);
|
|
476
|
+
this.#focusablesByFirstChar.forEach((focusables) => {
|
|
477
|
+
const index = focusables.indexOf(focusable);
|
|
478
|
+
index >= 0 && focusables.splice(index, 1);
|
|
479
|
+
});
|
|
490
480
|
}
|
|
491
|
-
focusable.isConnected && restoreAttributes2([focusable]);
|
|
492
|
-
this.#focusables.delete(focusable);
|
|
493
|
-
this.#focusablesByFirstChar.forEach((focusables) => {
|
|
494
|
-
const index = focusables.indexOf(focusable);
|
|
495
|
-
index >= 0 && focusables.splice(index, 1);
|
|
496
|
-
});
|
|
497
481
|
}
|
|
498
482
|
const { navigationOnly, noStart, typeahead } = this.#options;
|
|
499
483
|
for (const focusable of current) {
|
|
@@ -526,18 +510,17 @@ var RovingTabIndex = class {
|
|
|
526
510
|
this.#focusablesByFirstChar.set(key, focusables);
|
|
527
511
|
});
|
|
528
512
|
}
|
|
529
|
-
if (navigationOnly) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
513
|
+
if (!navigationOnly) {
|
|
514
|
+
if (active && this.#focusables.has(active)) {
|
|
515
|
+
this.#focusables.forEach((focusable) => {
|
|
516
|
+
focusable.setAttribute("tabindex", focusable === active ? "0" : "-1");
|
|
517
|
+
});
|
|
518
|
+
} else {
|
|
519
|
+
[...this.#focusables].forEach((focusable, i) => {
|
|
520
|
+
focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
|
|
521
|
+
});
|
|
522
|
+
}
|
|
537
523
|
}
|
|
538
|
-
[...this.#focusables].forEach((focusable, i) => {
|
|
539
|
-
focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
|
|
540
|
-
});
|
|
541
524
|
}
|
|
542
525
|
#createSelectorFilter() {
|
|
543
526
|
const { selector } = this.#options;
|
|
@@ -783,11 +766,10 @@ var Disclosure = class _Disclosure {
|
|
|
783
766
|
animation.addEventListener(
|
|
784
767
|
"finish",
|
|
785
768
|
() => {
|
|
786
|
-
if (binding?.animation
|
|
787
|
-
|
|
769
|
+
if (binding?.animation === animation) {
|
|
770
|
+
this.#onAnimationFinish(content);
|
|
771
|
+
cleanup();
|
|
788
772
|
}
|
|
789
|
-
this.#onAnimationFinish(content);
|
|
790
|
-
cleanup();
|
|
791
773
|
},
|
|
792
774
|
{ once: true, signal }
|
|
793
775
|
);
|
|
@@ -831,8 +813,7 @@ function isFocusable2(element) {
|
|
|
831
813
|
return element.tabIndex >= 0;
|
|
832
814
|
}
|
|
833
815
|
function waitAnimationFinish(animation) {
|
|
834
|
-
|
|
835
|
-
if (playState === "idle" || playState === "finished") {
|
|
816
|
+
if (["idle", "finished"].includes(animation.playState)) {
|
|
836
817
|
return Promise.resolve();
|
|
837
818
|
}
|
|
838
819
|
return new Promise(
|
|
@@ -844,7 +825,7 @@ function waitAnimationFinish(animation) {
|
|
|
844
825
|
* WAI-ARIA compliant disclosure pattern implementation in TypeScript.
|
|
845
826
|
* Using the <details> and <summary> element.
|
|
846
827
|
*
|
|
847
|
-
* @version 1.3.
|
|
828
|
+
* @version 1.3.11
|
|
848
829
|
* @author Yusuke Kamiyamane
|
|
849
830
|
* @license MIT
|
|
850
831
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -856,7 +837,7 @@ function waitAnimationFinish(animation) {
|
|
|
856
837
|
(**
|
|
857
838
|
* Attributes Utils
|
|
858
839
|
*
|
|
859
|
-
* @version 1.1.
|
|
840
|
+
* @version 1.1.2
|
|
860
841
|
* @author Yusuke Kamiyamane
|
|
861
842
|
* @license MIT
|
|
862
843
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -869,7 +850,7 @@ function waitAnimationFinish(animation) {
|
|
|
869
850
|
* Lightweight roving tabindex utility with fully focus management.
|
|
870
851
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
871
852
|
*
|
|
872
|
-
* @version 3.0.
|
|
853
|
+
* @version 3.0.2
|
|
873
854
|
* @author Yusuke Kamiyamane
|
|
874
855
|
* @license MIT
|
|
875
856
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -881,7 +862,7 @@ function waitAnimationFinish(animation) {
|
|
|
881
862
|
(**
|
|
882
863
|
* Attributes Utils
|
|
883
864
|
*
|
|
884
|
-
* @version 1.1.
|
|
865
|
+
* @version 1.1.2
|
|
885
866
|
* @author Yusuke Kamiyamane
|
|
886
867
|
* @license MIT
|
|
887
868
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -894,7 +875,7 @@ function waitAnimationFinish(animation) {
|
|
|
894
875
|
* High-precision focus management utility with full composed tree support.
|
|
895
876
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
896
877
|
*
|
|
897
|
-
* @version 4.3.
|
|
878
|
+
* @version 4.3.3
|
|
898
879
|
* @author Yusuke Kamiyamane
|
|
899
880
|
* @license MIT
|
|
900
881
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "WAI-ARIA compliant disclosure pattern implementation in TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/y14e/disclosure#readme",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@y14e/attributes-utils": "^1.1.
|
|
47
|
-
"@y14e/roving-tabindex": "^3.0.
|
|
46
|
+
"@y14e/attributes-utils": "^1.1.2",
|
|
47
|
+
"@y14e/roving-tabindex": "^3.0.2",
|
|
48
48
|
"bun-types": "latest",
|
|
49
49
|
"tsup": "^8.0.0",
|
|
50
50
|
"typescript": "^5.6.0",
|