@y14e/accordion 2.0.3 → 2.0.5
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 +7 -8
- package/dist/index.bundle.cjs +220 -95
- package/dist/index.bundle.js +220 -95
- package/dist/index.cjs +34 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@ npm i @y14e/accordion
|
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// npm
|
|
13
|
-
import Accordion from
|
|
13
|
+
import Accordion from "@y14e/accordion";
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import Accordion from
|
|
16
|
+
import Accordion from "https://esm.sh/@y14e/accordion@2.0.5";
|
|
17
17
|
// or
|
|
18
|
-
import Accordion from
|
|
18
|
+
import Accordion from "https://cdn.jsdelivr.net/npm/@y14e/accordion@2.0.5/+esm";
|
|
19
19
|
// or
|
|
20
|
-
import Accordion from
|
|
20
|
+
import Accordion from "https://esm.unpkg.com/@y14e/accordion@2.0.5";
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
@@ -28,7 +28,6 @@ new Accordion(root, options);
|
|
|
28
28
|
//
|
|
29
29
|
// root: HTMLElement
|
|
30
30
|
// options (optional): AccordionOptions
|
|
31
|
-
|
|
32
31
|
```
|
|
33
32
|
|
|
34
33
|
## 🪄 Options
|
|
@@ -52,15 +51,15 @@ interface AccordionOptions {
|
|
|
52
51
|
Override the global default settings applied to all accordion instances.
|
|
53
52
|
|
|
54
53
|
```ts
|
|
55
|
-
import Accordion from
|
|
54
|
+
import Accordion from "@y14e/accordion";
|
|
56
55
|
|
|
57
56
|
Accordion.defaults = {
|
|
58
57
|
animation: {
|
|
59
58
|
duration: 1000,
|
|
60
59
|
},
|
|
61
60
|
selector: {
|
|
62
|
-
content:
|
|
63
|
-
trigger:
|
|
61
|
+
content: ".content",
|
|
62
|
+
trigger: ".trigger",
|
|
64
63
|
},
|
|
65
64
|
};
|
|
66
65
|
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// node_modules/@y14e/
|
|
3
|
+
// node_modules/@y14e/attribute-util/dist/index.js
|
|
4
4
|
var DEFAULT_PARSER = (value) => value.split(/\s+/);
|
|
5
5
|
var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
|
|
6
|
-
function
|
|
7
|
-
const value = element.getAttribute(
|
|
6
|
+
function addAttributeToken(element, name, token, options = {}) {
|
|
7
|
+
const value = element.getAttribute(name)?.trim();
|
|
8
8
|
const {
|
|
9
9
|
caseInsensitive = false,
|
|
10
10
|
parse = DEFAULT_PARSER,
|
|
@@ -15,42 +15,47 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
|
15
15
|
const lower = token.toLowerCase();
|
|
16
16
|
if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
|
|
17
17
|
tokens.push(token);
|
|
18
|
-
element.setAttribute(
|
|
18
|
+
element.setAttribute(name, serialize(tokens));
|
|
19
19
|
}
|
|
20
20
|
} else {
|
|
21
21
|
const set = new Set(tokens);
|
|
22
22
|
set.add(token);
|
|
23
|
-
element.setAttribute(
|
|
23
|
+
element.setAttribute(name, serialize([...set]));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
27
|
-
function restoreAttributes(
|
|
28
|
-
for (const element of
|
|
27
|
+
function restoreAttributes(element_or_elements) {
|
|
28
|
+
for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
|
|
29
29
|
const snapshot = snapshots.get(element);
|
|
30
30
|
if (!snapshot) {
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
for (const [
|
|
34
|
-
value === null ? element.removeAttribute(
|
|
33
|
+
for (const [name, value] of snapshot.entries()) {
|
|
34
|
+
value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
|
|
35
35
|
}
|
|
36
36
|
snapshots.delete(element);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function saveAttributes(
|
|
40
|
-
|
|
39
|
+
function saveAttributes(element_or_elements, name_or_names) {
|
|
40
|
+
const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
|
|
41
|
+
(Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
|
|
41
42
|
let snapshot = snapshots.get(element);
|
|
42
43
|
if (!snapshot) {
|
|
43
44
|
snapshot = /* @__PURE__ */ new Map();
|
|
44
45
|
snapshots.set(element, snapshot);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
snapshot.set(
|
|
47
|
+
names.forEach((name) => {
|
|
48
|
+
snapshot.set(name, element.getAttribute(name));
|
|
48
49
|
});
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
// node_modules/power-focusable/dist/index.js
|
|
53
54
|
var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
|
|
55
|
+
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
56
|
+
/(,\s*)?\[tabindex="-1"\]/g,
|
|
57
|
+
""
|
|
58
|
+
);
|
|
54
59
|
function getFocusables(container = document.body, options = {}) {
|
|
55
60
|
if (!(container instanceof Element)) {
|
|
56
61
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
@@ -87,36 +92,43 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
87
92
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
88
93
|
skipVisibilityCheck = false;
|
|
89
94
|
}
|
|
90
|
-
const
|
|
95
|
+
const candidates = [];
|
|
91
96
|
if (composed || include) {
|
|
92
97
|
let traverse2 = function(node) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
if (isFocusable(node, {
|
|
99
|
+
skipNegativeTabIndexCheck,
|
|
100
|
+
skipVisibilityCheck
|
|
101
|
+
}) || include?.(node)) {
|
|
102
|
+
candidates[candidates.length] = node;
|
|
98
103
|
}
|
|
99
|
-
const
|
|
100
|
-
for (let i = 0, l =
|
|
101
|
-
const child =
|
|
104
|
+
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
105
|
+
for (let i = 0, l = children2.length; i < l; i++) {
|
|
106
|
+
const child = children2[i];
|
|
102
107
|
child && traverse2(child);
|
|
103
108
|
}
|
|
104
109
|
};
|
|
105
|
-
|
|
110
|
+
const children = composed ? getComposedChildren(container) : getChildren(container);
|
|
111
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
112
|
+
const child = children[i];
|
|
113
|
+
child && traverse2(child);
|
|
114
|
+
}
|
|
106
115
|
} else {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
const matches = container.querySelectorAll(
|
|
117
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
118
|
+
);
|
|
119
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
120
|
+
const matched = matches[i];
|
|
121
|
+
if (matched && isFocusable(matched, {
|
|
111
122
|
skipNegativeTabIndexCheck,
|
|
112
123
|
skipVisibilityCheck
|
|
113
124
|
})) {
|
|
114
|
-
|
|
125
|
+
candidates[candidates.length] = matched;
|
|
115
126
|
}
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
return normalizeRadioGroup(
|
|
130
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
131
|
+
);
|
|
120
132
|
}
|
|
121
133
|
function isFocusable(element, options = {}) {
|
|
122
134
|
if (!(element instanceof Element)) {
|
|
@@ -139,7 +151,7 @@ function isFocusable(element, options = {}) {
|
|
|
139
151
|
return false;
|
|
140
152
|
}
|
|
141
153
|
if (!element.matches(
|
|
142
|
-
skipNegativeTabIndexCheck ?
|
|
154
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
143
155
|
)) {
|
|
144
156
|
return false;
|
|
145
157
|
}
|
|
@@ -197,22 +209,42 @@ function normalizeRadioGroup(elements) {
|
|
|
197
209
|
if (!map) {
|
|
198
210
|
map = /* @__PURE__ */ new Map();
|
|
199
211
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
|
|
212
|
+
const root = element.getRootNode();
|
|
213
|
+
let value = map.get(root);
|
|
214
|
+
if (!value) {
|
|
215
|
+
value = /* @__PURE__ */ new Map();
|
|
216
|
+
map.set(root, value);
|
|
217
|
+
}
|
|
218
|
+
let v = value.get(element.form);
|
|
219
|
+
if (!v) {
|
|
220
|
+
v = /* @__PURE__ */ new Map();
|
|
221
|
+
value.set(element.form, v);
|
|
222
|
+
}
|
|
223
|
+
let vv = v.get(element.name);
|
|
224
|
+
if (!vv) {
|
|
225
|
+
vv = [];
|
|
226
|
+
v.set(element.name, vv);
|
|
204
227
|
}
|
|
228
|
+
vv[vv.length] = element;
|
|
205
229
|
}
|
|
206
230
|
if (!map) {
|
|
207
231
|
return elements;
|
|
208
232
|
}
|
|
209
233
|
const placeholder = /* @__PURE__ */ new Set();
|
|
210
|
-
for (const
|
|
211
|
-
|
|
234
|
+
for (const value of map.values()) {
|
|
235
|
+
for (const v of value.values()) {
|
|
236
|
+
for (const vv of v.values()) {
|
|
237
|
+
const radio = vv.find((element) => element.checked) ?? vv[0];
|
|
238
|
+
radio && placeholder.add(radio);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
212
241
|
}
|
|
213
|
-
return elements.filter(
|
|
214
|
-
|
|
215
|
-
|
|
242
|
+
return elements.filter((element) => {
|
|
243
|
+
if (!(element instanceof HTMLInputElement)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
return !isUngroupedRadio(element) || placeholder.has(element);
|
|
247
|
+
});
|
|
216
248
|
}
|
|
217
249
|
function sortByTabIndex(elements) {
|
|
218
250
|
const ordered = [];
|
|
@@ -284,7 +316,7 @@ function isInert(element) {
|
|
|
284
316
|
return "inert" in element && !!element.inert;
|
|
285
317
|
}
|
|
286
318
|
function isUngroupedRadio(element) {
|
|
287
|
-
return element
|
|
319
|
+
return element.type === "radio" && !!element.name;
|
|
288
320
|
}
|
|
289
321
|
|
|
290
322
|
// node_modules/@y14e/button/dist/index.js
|
|
@@ -336,6 +368,56 @@ var Button = class {
|
|
|
336
368
|
};
|
|
337
369
|
};
|
|
338
370
|
|
|
371
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
372
|
+
var DEFAULT_PARSER2 = (value) => value.split(/\s+/);
|
|
373
|
+
var DEFAULT_SERIALIZER2 = (tokens) => tokens.join(" ");
|
|
374
|
+
function addTokenToAttribute(element, name, token, options = {}) {
|
|
375
|
+
const value = element.getAttribute(name)?.trim();
|
|
376
|
+
const {
|
|
377
|
+
caseInsensitive = false,
|
|
378
|
+
parse = DEFAULT_PARSER2,
|
|
379
|
+
serialize = DEFAULT_SERIALIZER2
|
|
380
|
+
} = options;
|
|
381
|
+
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
382
|
+
if (caseInsensitive) {
|
|
383
|
+
const lower = token.toLowerCase();
|
|
384
|
+
if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
|
|
385
|
+
tokens.push(token);
|
|
386
|
+
element.setAttribute(name, serialize(tokens));
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
const set = new Set(tokens);
|
|
390
|
+
set.add(token);
|
|
391
|
+
element.setAttribute(name, serialize([...set]));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
var snapshots2 = /* @__PURE__ */ new WeakMap();
|
|
395
|
+
function restoreAttributes2(element_or_elements) {
|
|
396
|
+
for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
|
|
397
|
+
const snapshot = snapshots2.get(element);
|
|
398
|
+
if (!snapshot) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
for (const [name, value] of snapshot.entries()) {
|
|
402
|
+
value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
|
|
403
|
+
}
|
|
404
|
+
snapshots2.delete(element);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function saveAttributes2(element_or_elements, name_or_names) {
|
|
408
|
+
const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
|
|
409
|
+
(Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
|
|
410
|
+
let snapshot = snapshots2.get(element);
|
|
411
|
+
if (!snapshot) {
|
|
412
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
413
|
+
snapshots2.set(element, snapshot);
|
|
414
|
+
}
|
|
415
|
+
names.forEach((name) => {
|
|
416
|
+
snapshot.set(name, element.getAttribute(name));
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
339
421
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
340
422
|
function createRovingTabIndex(container, options = {}) {
|
|
341
423
|
if (!(container instanceof Element)) {
|
|
@@ -343,14 +425,8 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
343
425
|
return () => {
|
|
344
426
|
};
|
|
345
427
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return () => roving.destroy();
|
|
349
|
-
} catch (error) {
|
|
350
|
-
error instanceof Error && console.warn(error.message || error);
|
|
351
|
-
return () => {
|
|
352
|
-
};
|
|
353
|
-
}
|
|
428
|
+
const roving = new RovingTabIndex(container, options);
|
|
429
|
+
return () => roving.destroy();
|
|
354
430
|
}
|
|
355
431
|
var RovingTabIndex = class _RovingTabIndex {
|
|
356
432
|
static #initialized = /* @__PURE__ */ new Set();
|
|
@@ -364,17 +440,17 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
364
440
|
constructor(container, options = {}) {
|
|
365
441
|
this.#container = container;
|
|
366
442
|
let {
|
|
367
|
-
direction,
|
|
443
|
+
direction = "both",
|
|
368
444
|
navigationOnly = false,
|
|
369
445
|
noMemory = false,
|
|
370
446
|
noStart = false,
|
|
371
|
-
selector,
|
|
447
|
+
selector = "",
|
|
372
448
|
typeahead = false,
|
|
373
449
|
wrap = false
|
|
374
450
|
} = options;
|
|
375
|
-
if (
|
|
376
|
-
console.warn("Invalid direction option. Fallback: both
|
|
377
|
-
direction =
|
|
451
|
+
if (!["both", "horizontal", "vertical"].includes(direction)) {
|
|
452
|
+
console.warn("Invalid direction option. Fallback: 'both'.");
|
|
453
|
+
direction = "both";
|
|
378
454
|
}
|
|
379
455
|
if (typeof navigationOnly !== "boolean") {
|
|
380
456
|
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
@@ -388,11 +464,21 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
388
464
|
console.warn("Invalid noStart option. Fallback: false.");
|
|
389
465
|
noStart = false;
|
|
390
466
|
}
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
467
|
+
if (selector !== "") {
|
|
468
|
+
let hasError = false;
|
|
469
|
+
if (typeof selector !== "string" || !selector.trim()) {
|
|
470
|
+
hasError = true;
|
|
471
|
+
} else {
|
|
472
|
+
try {
|
|
473
|
+
this.#container.querySelector(selector);
|
|
474
|
+
} catch {
|
|
475
|
+
hasError = true;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (hasError) {
|
|
479
|
+
console.warn("Invalid selector. Fallback: no selector string.");
|
|
480
|
+
selector = "";
|
|
481
|
+
}
|
|
396
482
|
}
|
|
397
483
|
if (typeof typeahead !== "boolean") {
|
|
398
484
|
console.warn("Invalid typeahead option. Fallback: false.");
|
|
@@ -402,9 +488,15 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
402
488
|
console.warn("Invalid wrap option. Fallback: false.");
|
|
403
489
|
wrap = false;
|
|
404
490
|
}
|
|
405
|
-
this.#settings = {
|
|
406
|
-
|
|
407
|
-
|
|
491
|
+
this.#settings = {
|
|
492
|
+
direction,
|
|
493
|
+
navigationOnly,
|
|
494
|
+
noMemory,
|
|
495
|
+
noStart,
|
|
496
|
+
selector,
|
|
497
|
+
typeahead,
|
|
498
|
+
wrap
|
|
499
|
+
};
|
|
408
500
|
this.#selectorFilter = this.#createSelectorFilter();
|
|
409
501
|
this.#initialize();
|
|
410
502
|
}
|
|
@@ -415,7 +507,10 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
415
507
|
this.#isDestroyed = true;
|
|
416
508
|
this.#controller?.abort();
|
|
417
509
|
this.#controller = null;
|
|
418
|
-
|
|
510
|
+
this.#focusables.forEach((focusable) => {
|
|
511
|
+
_RovingTabIndex.#initialized.delete(focusable);
|
|
512
|
+
restoreAttributes2(focusable);
|
|
513
|
+
});
|
|
419
514
|
this.#focusables.clear();
|
|
420
515
|
this.#focusablesByFirstChar.clear();
|
|
421
516
|
}
|
|
@@ -452,7 +547,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
452
547
|
return;
|
|
453
548
|
}
|
|
454
549
|
const { direction, typeahead, wrap } = this.#settings;
|
|
455
|
-
const isBoth =
|
|
550
|
+
const isBoth = direction === "both";
|
|
456
551
|
const isHorizontal = direction === "horizontal";
|
|
457
552
|
if (![
|
|
458
553
|
"End",
|
|
@@ -464,18 +559,20 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
464
559
|
return;
|
|
465
560
|
}
|
|
466
561
|
}
|
|
562
|
+
const candidates = this.#getFocusables().filter(
|
|
563
|
+
(focusable2) => this.#focusables.has(focusable2)
|
|
564
|
+
);
|
|
467
565
|
const active = getActiveElement();
|
|
468
566
|
if (!(active instanceof Element)) {
|
|
469
567
|
return;
|
|
470
568
|
}
|
|
471
|
-
|
|
472
|
-
if (!current.includes(active)) {
|
|
569
|
+
if (!candidates.includes(active)) {
|
|
473
570
|
return;
|
|
474
571
|
}
|
|
475
572
|
event.preventDefault();
|
|
476
|
-
const currentIndex = current.indexOf(active);
|
|
477
573
|
let newIndex;
|
|
478
|
-
|
|
574
|
+
const activeIndex = candidates.indexOf(active);
|
|
575
|
+
let focusables = candidates;
|
|
479
576
|
switch (key) {
|
|
480
577
|
case "End":
|
|
481
578
|
newIndex = -1;
|
|
@@ -485,37 +582,47 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
485
582
|
break;
|
|
486
583
|
case "ArrowLeft":
|
|
487
584
|
case "ArrowUp": {
|
|
488
|
-
const rawIndex =
|
|
585
|
+
const rawIndex = activeIndex - 1;
|
|
489
586
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
490
587
|
break;
|
|
491
588
|
}
|
|
492
589
|
case "ArrowRight":
|
|
493
590
|
case "ArrowDown": {
|
|
494
|
-
const rawIndex =
|
|
495
|
-
|
|
591
|
+
const rawIndex = activeIndex + 1;
|
|
592
|
+
const length = focusables.length;
|
|
593
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
496
594
|
break;
|
|
497
595
|
}
|
|
498
596
|
default: {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
597
|
+
const focusablesByFirstChar = new Set(
|
|
598
|
+
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
599
|
+
);
|
|
600
|
+
focusables = candidates.filter(
|
|
601
|
+
(candidate) => focusablesByFirstChar.has(candidate)
|
|
502
602
|
);
|
|
503
|
-
|
|
603
|
+
const afterIndex = focusables.findIndex(
|
|
604
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
605
|
+
);
|
|
606
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
504
607
|
}
|
|
505
608
|
}
|
|
506
|
-
const focusable =
|
|
609
|
+
const focusable = focusables.at(newIndex);
|
|
507
610
|
focusable && focusElement(focusable);
|
|
508
611
|
};
|
|
509
612
|
#update(active) {
|
|
510
613
|
const current = new Set(this.#getFocusables());
|
|
511
614
|
for (const focusable of this.#focusables) {
|
|
512
615
|
if (!current.has(focusable)) {
|
|
513
|
-
|
|
616
|
+
_RovingTabIndex.#initialized.delete(focusable);
|
|
617
|
+
restoreAttributes2(focusable);
|
|
514
618
|
this.#focusables.delete(focusable);
|
|
515
|
-
this.#focusablesByFirstChar
|
|
619
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
516
620
|
const index = focusables.indexOf(focusable);
|
|
517
|
-
index >= 0
|
|
518
|
-
|
|
621
|
+
if (index >= 0) {
|
|
622
|
+
focusables.splice(index, 1);
|
|
623
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
519
626
|
}
|
|
520
627
|
}
|
|
521
628
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
@@ -524,12 +631,12 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
524
631
|
continue;
|
|
525
632
|
}
|
|
526
633
|
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
527
|
-
|
|
634
|
+
continue;
|
|
528
635
|
}
|
|
529
636
|
this.#focusables.add(focusable);
|
|
530
637
|
_RovingTabIndex.#initialized.add(focusable);
|
|
531
638
|
if (!navigationOnly) {
|
|
532
|
-
|
|
639
|
+
saveAttributes2(focusable, "tabindex");
|
|
533
640
|
focusable.setAttribute("tabindex", "-1");
|
|
534
641
|
}
|
|
535
642
|
if (!typeahead) {
|
|
@@ -542,7 +649,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
542
649
|
);
|
|
543
650
|
if (char) {
|
|
544
651
|
keys.add(char);
|
|
545
|
-
|
|
652
|
+
saveAttributes2(focusable, "aria-keyshortcuts");
|
|
546
653
|
addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
|
|
547
654
|
caseInsensitive: true
|
|
548
655
|
});
|
|
@@ -673,7 +780,10 @@ var Accordion = class _Accordion {
|
|
|
673
780
|
});
|
|
674
781
|
this.#animationController?.abort();
|
|
675
782
|
this.#animationController = null;
|
|
676
|
-
restoreAttributes([
|
|
783
|
+
restoreAttributes([
|
|
784
|
+
...this.#triggerElements,
|
|
785
|
+
...this.#contentElements
|
|
786
|
+
]);
|
|
677
787
|
this.#triggerElements.length = 0;
|
|
678
788
|
this.#contentElements.length = 0;
|
|
679
789
|
this.#rootElement.removeAttribute("data-accordion-initialized");
|
|
@@ -696,7 +806,11 @@ var Accordion = class _Accordion {
|
|
|
696
806
|
"style",
|
|
697
807
|
"tabindex"
|
|
698
808
|
]);
|
|
699
|
-
saveAttributes(this.#contentElements, [
|
|
809
|
+
saveAttributes(this.#contentElements, [
|
|
810
|
+
"aria-labelledby",
|
|
811
|
+
"id",
|
|
812
|
+
"role"
|
|
813
|
+
]);
|
|
700
814
|
this.#eventController = new AbortController();
|
|
701
815
|
const { signal } = this.#eventController;
|
|
702
816
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
@@ -706,7 +820,7 @@ var Accordion = class _Accordion {
|
|
|
706
820
|
return;
|
|
707
821
|
}
|
|
708
822
|
content2.id ||= `accordion-content-${id}`;
|
|
709
|
-
|
|
823
|
+
addAttributeToken(trigger2, "aria-controls", content2.id);
|
|
710
824
|
trigger2.setAttribute(
|
|
711
825
|
"aria-expanded",
|
|
712
826
|
String(trigger2.ariaExpanded === "true")
|
|
@@ -718,7 +832,7 @@ var Accordion = class _Accordion {
|
|
|
718
832
|
trigger2.style.setProperty("pointer-events", "none");
|
|
719
833
|
}
|
|
720
834
|
trigger2.addEventListener("click", this.#onTriggerClick, { signal });
|
|
721
|
-
|
|
835
|
+
addAttributeToken(content2, "aria-labelledby", trigger2.id);
|
|
722
836
|
content2.setAttribute("role", "region");
|
|
723
837
|
content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
|
|
724
838
|
signal
|
|
@@ -822,7 +936,7 @@ var Accordion = class _Accordion {
|
|
|
822
936
|
);
|
|
823
937
|
}
|
|
824
938
|
#createBinding(trigger, content) {
|
|
825
|
-
return {
|
|
939
|
+
return { animation: null, content, trigger };
|
|
826
940
|
}
|
|
827
941
|
#isFocusable(element) {
|
|
828
942
|
return !element.hasAttribute("disabled") && element.tabIndex >= 0;
|
|
@@ -853,7 +967,7 @@ function waitAnimationFinish(animation) {
|
|
|
853
967
|
* Accordion
|
|
854
968
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
855
969
|
*
|
|
856
|
-
* @version 2.0.
|
|
970
|
+
* @version 2.0.5
|
|
857
971
|
* @author Yusuke Kamiyamane
|
|
858
972
|
* @license MIT
|
|
859
973
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -861,15 +975,15 @@ function waitAnimationFinish(animation) {
|
|
|
861
975
|
*/
|
|
862
976
|
/*! Bundled license information:
|
|
863
977
|
|
|
864
|
-
@y14e/
|
|
978
|
+
@y14e/attribute-util/dist/index.js:
|
|
865
979
|
(**
|
|
866
|
-
*
|
|
980
|
+
* Attribute Util
|
|
867
981
|
*
|
|
868
|
-
* @version
|
|
982
|
+
* @version 2.0.0
|
|
869
983
|
* @author Yusuke Kamiyamane
|
|
870
984
|
* @license MIT
|
|
871
985
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
872
|
-
* @see {@link https://github.com/y14e/
|
|
986
|
+
* @see {@link https://github.com/y14e/attribute-util}
|
|
873
987
|
*)
|
|
874
988
|
|
|
875
989
|
power-focusable/dist/index.js:
|
|
@@ -878,7 +992,7 @@ power-focusable/dist/index.js:
|
|
|
878
992
|
* High-precision focus management utility with full composed tree support.
|
|
879
993
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
880
994
|
*
|
|
881
|
-
* @version 4.3.
|
|
995
|
+
* @version 4.3.23
|
|
882
996
|
* @author Yusuke Kamiyamane
|
|
883
997
|
* @license MIT
|
|
884
998
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -896,13 +1010,24 @@ power-focusable/dist/index.js:
|
|
|
896
1010
|
* @see {@link https://github.com/y14e/button}
|
|
897
1011
|
*)
|
|
898
1012
|
|
|
1013
|
+
@y14e/attributes-utils/dist/index.js:
|
|
1014
|
+
(**
|
|
1015
|
+
* Attributes Utils
|
|
1016
|
+
*
|
|
1017
|
+
* @version 1.1.7
|
|
1018
|
+
* @author Yusuke Kamiyamane
|
|
1019
|
+
* @license MIT
|
|
1020
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
1021
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
1022
|
+
*)
|
|
1023
|
+
|
|
899
1024
|
@y14e/roving-tabindex/dist/index.js:
|
|
900
1025
|
(**
|
|
901
1026
|
* Roving Tabindex
|
|
902
1027
|
* Lightweight roving tabindex utility with fully focus management.
|
|
903
1028
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
904
1029
|
*
|
|
905
|
-
* @version 3.1.
|
|
1030
|
+
* @version 3.1.20
|
|
906
1031
|
* @author Yusuke Kamiyamane
|
|
907
1032
|
* @license MIT
|
|
908
1033
|
* @copyright Copyright (c) Yusuke Kamiyamane
|