@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/dist/index.bundle.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// node_modules/@y14e/
|
|
1
|
+
// node_modules/@y14e/attribute-util/dist/index.js
|
|
2
2
|
var DEFAULT_PARSER = (value) => value.split(/\s+/);
|
|
3
3
|
var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
|
|
4
|
-
function
|
|
5
|
-
const value = element.getAttribute(
|
|
4
|
+
function addAttributeToken(element, name, token, options = {}) {
|
|
5
|
+
const value = element.getAttribute(name)?.trim();
|
|
6
6
|
const {
|
|
7
7
|
caseInsensitive = false,
|
|
8
8
|
parse = DEFAULT_PARSER,
|
|
@@ -13,42 +13,47 @@ function addTokenToAttribute(element, attribute, token, options = {}) {
|
|
|
13
13
|
const lower = token.toLowerCase();
|
|
14
14
|
if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
|
|
15
15
|
tokens.push(token);
|
|
16
|
-
element.setAttribute(
|
|
16
|
+
element.setAttribute(name, serialize(tokens));
|
|
17
17
|
}
|
|
18
18
|
} else {
|
|
19
19
|
const set = new Set(tokens);
|
|
20
20
|
set.add(token);
|
|
21
|
-
element.setAttribute(
|
|
21
|
+
element.setAttribute(name, serialize([...set]));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
25
|
-
function restoreAttributes(
|
|
26
|
-
for (const element of
|
|
25
|
+
function restoreAttributes(element_or_elements) {
|
|
26
|
+
for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
|
|
27
27
|
const snapshot = snapshots.get(element);
|
|
28
28
|
if (!snapshot) {
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
for (const [
|
|
32
|
-
value === null ? element.removeAttribute(
|
|
31
|
+
for (const [name, value] of snapshot.entries()) {
|
|
32
|
+
value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
|
|
33
33
|
}
|
|
34
34
|
snapshots.delete(element);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function saveAttributes(
|
|
38
|
-
|
|
37
|
+
function saveAttributes(element_or_elements, name_or_names) {
|
|
38
|
+
const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
|
|
39
|
+
(Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
|
|
39
40
|
let snapshot = snapshots.get(element);
|
|
40
41
|
if (!snapshot) {
|
|
41
42
|
snapshot = /* @__PURE__ */ new Map();
|
|
42
43
|
snapshots.set(element, snapshot);
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
snapshot.set(
|
|
45
|
+
names.forEach((name) => {
|
|
46
|
+
snapshot.set(name, element.getAttribute(name));
|
|
46
47
|
});
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// node_modules/power-focusable/dist/index.js
|
|
51
52
|
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"])`;
|
|
53
|
+
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
54
|
+
/(,\s*)?\[tabindex="-1"\]/g,
|
|
55
|
+
""
|
|
56
|
+
);
|
|
52
57
|
function getFocusables(container = document.body, options = {}) {
|
|
53
58
|
if (!(container instanceof Element)) {
|
|
54
59
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
@@ -85,36 +90,43 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
85
90
|
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
86
91
|
skipVisibilityCheck = false;
|
|
87
92
|
}
|
|
88
|
-
const
|
|
93
|
+
const candidates = [];
|
|
89
94
|
if (composed || include) {
|
|
90
95
|
let traverse2 = function(node) {
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
if (isFocusable(node, {
|
|
97
|
+
skipNegativeTabIndexCheck,
|
|
98
|
+
skipVisibilityCheck
|
|
99
|
+
}) || include?.(node)) {
|
|
100
|
+
candidates[candidates.length] = node;
|
|
96
101
|
}
|
|
97
|
-
const
|
|
98
|
-
for (let i = 0, l =
|
|
99
|
-
const child =
|
|
102
|
+
const children2 = composed ? getComposedChildren(node) : getChildren(node);
|
|
103
|
+
for (let i = 0, l = children2.length; i < l; i++) {
|
|
104
|
+
const child = children2[i];
|
|
100
105
|
child && traverse2(child);
|
|
101
106
|
}
|
|
102
107
|
};
|
|
103
|
-
|
|
108
|
+
const children = composed ? getComposedChildren(container) : getChildren(container);
|
|
109
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
110
|
+
const child = children[i];
|
|
111
|
+
child && traverse2(child);
|
|
112
|
+
}
|
|
104
113
|
} else {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const matches = container.querySelectorAll(
|
|
115
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
116
|
+
);
|
|
117
|
+
for (let i = 0, l = matches.length; i < l; i++) {
|
|
118
|
+
const matched = matches[i];
|
|
119
|
+
if (matched && isFocusable(matched, {
|
|
109
120
|
skipNegativeTabIndexCheck,
|
|
110
121
|
skipVisibilityCheck
|
|
111
122
|
})) {
|
|
112
|
-
|
|
123
|
+
candidates[candidates.length] = matched;
|
|
113
124
|
}
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
return normalizeRadioGroup(
|
|
128
|
+
sortByTabIndex(filter ? candidates.filter(filter) : candidates)
|
|
129
|
+
);
|
|
118
130
|
}
|
|
119
131
|
function isFocusable(element, options = {}) {
|
|
120
132
|
if (!(element instanceof Element)) {
|
|
@@ -137,7 +149,7 @@ function isFocusable(element, options = {}) {
|
|
|
137
149
|
return false;
|
|
138
150
|
}
|
|
139
151
|
if (!element.matches(
|
|
140
|
-
skipNegativeTabIndexCheck ?
|
|
152
|
+
skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
|
|
141
153
|
)) {
|
|
142
154
|
return false;
|
|
143
155
|
}
|
|
@@ -195,22 +207,42 @@ function normalizeRadioGroup(elements) {
|
|
|
195
207
|
if (!map) {
|
|
196
208
|
map = /* @__PURE__ */ new Map();
|
|
197
209
|
}
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
210
|
+
const root = element.getRootNode();
|
|
211
|
+
let value = map.get(root);
|
|
212
|
+
if (!value) {
|
|
213
|
+
value = /* @__PURE__ */ new Map();
|
|
214
|
+
map.set(root, value);
|
|
215
|
+
}
|
|
216
|
+
let v = value.get(element.form);
|
|
217
|
+
if (!v) {
|
|
218
|
+
v = /* @__PURE__ */ new Map();
|
|
219
|
+
value.set(element.form, v);
|
|
220
|
+
}
|
|
221
|
+
let vv = v.get(element.name);
|
|
222
|
+
if (!vv) {
|
|
223
|
+
vv = [];
|
|
224
|
+
v.set(element.name, vv);
|
|
202
225
|
}
|
|
226
|
+
vv[vv.length] = element;
|
|
203
227
|
}
|
|
204
228
|
if (!map) {
|
|
205
229
|
return elements;
|
|
206
230
|
}
|
|
207
231
|
const placeholder = /* @__PURE__ */ new Set();
|
|
208
|
-
for (const
|
|
209
|
-
|
|
232
|
+
for (const value of map.values()) {
|
|
233
|
+
for (const v of value.values()) {
|
|
234
|
+
for (const vv of v.values()) {
|
|
235
|
+
const radio = vv.find((element) => element.checked) ?? vv[0];
|
|
236
|
+
radio && placeholder.add(radio);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
210
239
|
}
|
|
211
|
-
return elements.filter(
|
|
212
|
-
|
|
213
|
-
|
|
240
|
+
return elements.filter((element) => {
|
|
241
|
+
if (!(element instanceof HTMLInputElement)) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return !isUngroupedRadio(element) || placeholder.has(element);
|
|
245
|
+
});
|
|
214
246
|
}
|
|
215
247
|
function sortByTabIndex(elements) {
|
|
216
248
|
const ordered = [];
|
|
@@ -282,7 +314,7 @@ function isInert(element) {
|
|
|
282
314
|
return "inert" in element && !!element.inert;
|
|
283
315
|
}
|
|
284
316
|
function isUngroupedRadio(element) {
|
|
285
|
-
return element
|
|
317
|
+
return element.type === "radio" && !!element.name;
|
|
286
318
|
}
|
|
287
319
|
|
|
288
320
|
// node_modules/@y14e/button/dist/index.js
|
|
@@ -334,6 +366,56 @@ var Button = class {
|
|
|
334
366
|
};
|
|
335
367
|
};
|
|
336
368
|
|
|
369
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
370
|
+
var DEFAULT_PARSER2 = (value) => value.split(/\s+/);
|
|
371
|
+
var DEFAULT_SERIALIZER2 = (tokens) => tokens.join(" ");
|
|
372
|
+
function addTokenToAttribute(element, name, token, options = {}) {
|
|
373
|
+
const value = element.getAttribute(name)?.trim();
|
|
374
|
+
const {
|
|
375
|
+
caseInsensitive = false,
|
|
376
|
+
parse = DEFAULT_PARSER2,
|
|
377
|
+
serialize = DEFAULT_SERIALIZER2
|
|
378
|
+
} = options;
|
|
379
|
+
const tokens = value ? parse(value).filter(Boolean) : [];
|
|
380
|
+
if (caseInsensitive) {
|
|
381
|
+
const lower = token.toLowerCase();
|
|
382
|
+
if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
|
|
383
|
+
tokens.push(token);
|
|
384
|
+
element.setAttribute(name, serialize(tokens));
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
const set = new Set(tokens);
|
|
388
|
+
set.add(token);
|
|
389
|
+
element.setAttribute(name, serialize([...set]));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
var snapshots2 = /* @__PURE__ */ new WeakMap();
|
|
393
|
+
function restoreAttributes2(element_or_elements) {
|
|
394
|
+
for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
|
|
395
|
+
const snapshot = snapshots2.get(element);
|
|
396
|
+
if (!snapshot) {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
for (const [name, value] of snapshot.entries()) {
|
|
400
|
+
value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
|
|
401
|
+
}
|
|
402
|
+
snapshots2.delete(element);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function saveAttributes2(element_or_elements, name_or_names) {
|
|
406
|
+
const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
|
|
407
|
+
(Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
|
|
408
|
+
let snapshot = snapshots2.get(element);
|
|
409
|
+
if (!snapshot) {
|
|
410
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
411
|
+
snapshots2.set(element, snapshot);
|
|
412
|
+
}
|
|
413
|
+
names.forEach((name) => {
|
|
414
|
+
snapshot.set(name, element.getAttribute(name));
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
337
419
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
338
420
|
function createRovingTabIndex(container, options = {}) {
|
|
339
421
|
if (!(container instanceof Element)) {
|
|
@@ -341,14 +423,8 @@ function createRovingTabIndex(container, options = {}) {
|
|
|
341
423
|
return () => {
|
|
342
424
|
};
|
|
343
425
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return () => roving.destroy();
|
|
347
|
-
} catch (error) {
|
|
348
|
-
error instanceof Error && console.warn(error.message || error);
|
|
349
|
-
return () => {
|
|
350
|
-
};
|
|
351
|
-
}
|
|
426
|
+
const roving = new RovingTabIndex(container, options);
|
|
427
|
+
return () => roving.destroy();
|
|
352
428
|
}
|
|
353
429
|
var RovingTabIndex = class _RovingTabIndex {
|
|
354
430
|
static #initialized = /* @__PURE__ */ new Set();
|
|
@@ -362,17 +438,17 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
362
438
|
constructor(container, options = {}) {
|
|
363
439
|
this.#container = container;
|
|
364
440
|
let {
|
|
365
|
-
direction,
|
|
441
|
+
direction = "both",
|
|
366
442
|
navigationOnly = false,
|
|
367
443
|
noMemory = false,
|
|
368
444
|
noStart = false,
|
|
369
|
-
selector,
|
|
445
|
+
selector = "",
|
|
370
446
|
typeahead = false,
|
|
371
447
|
wrap = false
|
|
372
448
|
} = options;
|
|
373
|
-
if (
|
|
374
|
-
console.warn("Invalid direction option. Fallback: both
|
|
375
|
-
direction =
|
|
449
|
+
if (!["both", "horizontal", "vertical"].includes(direction)) {
|
|
450
|
+
console.warn("Invalid direction option. Fallback: 'both'.");
|
|
451
|
+
direction = "both";
|
|
376
452
|
}
|
|
377
453
|
if (typeof navigationOnly !== "boolean") {
|
|
378
454
|
console.warn("Invalid navigationOnly option. Fallback: false.");
|
|
@@ -386,11 +462,21 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
386
462
|
console.warn("Invalid noStart option. Fallback: false.");
|
|
387
463
|
noStart = false;
|
|
388
464
|
}
|
|
389
|
-
if (
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
465
|
+
if (selector !== "") {
|
|
466
|
+
let hasError = false;
|
|
467
|
+
if (typeof selector !== "string" || !selector.trim()) {
|
|
468
|
+
hasError = true;
|
|
469
|
+
} else {
|
|
470
|
+
try {
|
|
471
|
+
this.#container.querySelector(selector);
|
|
472
|
+
} catch {
|
|
473
|
+
hasError = true;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (hasError) {
|
|
477
|
+
console.warn("Invalid selector. Fallback: no selector string.");
|
|
478
|
+
selector = "";
|
|
479
|
+
}
|
|
394
480
|
}
|
|
395
481
|
if (typeof typeahead !== "boolean") {
|
|
396
482
|
console.warn("Invalid typeahead option. Fallback: false.");
|
|
@@ -400,9 +486,15 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
400
486
|
console.warn("Invalid wrap option. Fallback: false.");
|
|
401
487
|
wrap = false;
|
|
402
488
|
}
|
|
403
|
-
this.#settings = {
|
|
404
|
-
|
|
405
|
-
|
|
489
|
+
this.#settings = {
|
|
490
|
+
direction,
|
|
491
|
+
navigationOnly,
|
|
492
|
+
noMemory,
|
|
493
|
+
noStart,
|
|
494
|
+
selector,
|
|
495
|
+
typeahead,
|
|
496
|
+
wrap
|
|
497
|
+
};
|
|
406
498
|
this.#selectorFilter = this.#createSelectorFilter();
|
|
407
499
|
this.#initialize();
|
|
408
500
|
}
|
|
@@ -413,7 +505,10 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
413
505
|
this.#isDestroyed = true;
|
|
414
506
|
this.#controller?.abort();
|
|
415
507
|
this.#controller = null;
|
|
416
|
-
|
|
508
|
+
this.#focusables.forEach((focusable) => {
|
|
509
|
+
_RovingTabIndex.#initialized.delete(focusable);
|
|
510
|
+
restoreAttributes2(focusable);
|
|
511
|
+
});
|
|
417
512
|
this.#focusables.clear();
|
|
418
513
|
this.#focusablesByFirstChar.clear();
|
|
419
514
|
}
|
|
@@ -450,7 +545,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
450
545
|
return;
|
|
451
546
|
}
|
|
452
547
|
const { direction, typeahead, wrap } = this.#settings;
|
|
453
|
-
const isBoth =
|
|
548
|
+
const isBoth = direction === "both";
|
|
454
549
|
const isHorizontal = direction === "horizontal";
|
|
455
550
|
if (![
|
|
456
551
|
"End",
|
|
@@ -462,18 +557,20 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
462
557
|
return;
|
|
463
558
|
}
|
|
464
559
|
}
|
|
560
|
+
const candidates = this.#getFocusables().filter(
|
|
561
|
+
(focusable2) => this.#focusables.has(focusable2)
|
|
562
|
+
);
|
|
465
563
|
const active = getActiveElement();
|
|
466
564
|
if (!(active instanceof Element)) {
|
|
467
565
|
return;
|
|
468
566
|
}
|
|
469
|
-
|
|
470
|
-
if (!current.includes(active)) {
|
|
567
|
+
if (!candidates.includes(active)) {
|
|
471
568
|
return;
|
|
472
569
|
}
|
|
473
570
|
event.preventDefault();
|
|
474
|
-
const currentIndex = current.indexOf(active);
|
|
475
571
|
let newIndex;
|
|
476
|
-
|
|
572
|
+
const activeIndex = candidates.indexOf(active);
|
|
573
|
+
let focusables = candidates;
|
|
477
574
|
switch (key) {
|
|
478
575
|
case "End":
|
|
479
576
|
newIndex = -1;
|
|
@@ -483,37 +580,47 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
483
580
|
break;
|
|
484
581
|
case "ArrowLeft":
|
|
485
582
|
case "ArrowUp": {
|
|
486
|
-
const rawIndex =
|
|
583
|
+
const rawIndex = activeIndex - 1;
|
|
487
584
|
newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
|
|
488
585
|
break;
|
|
489
586
|
}
|
|
490
587
|
case "ArrowRight":
|
|
491
588
|
case "ArrowDown": {
|
|
492
|
-
const rawIndex =
|
|
493
|
-
|
|
589
|
+
const rawIndex = activeIndex + 1;
|
|
590
|
+
const length = focusables.length;
|
|
591
|
+
newIndex = wrap ? rawIndex % length : Math.min(rawIndex, length - 1);
|
|
494
592
|
break;
|
|
495
593
|
}
|
|
496
594
|
default: {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
595
|
+
const focusablesByFirstChar = new Set(
|
|
596
|
+
this.#focusablesByFirstChar.get(key.toUpperCase()) ?? []
|
|
597
|
+
);
|
|
598
|
+
focusables = candidates.filter(
|
|
599
|
+
(candidate) => focusablesByFirstChar.has(candidate)
|
|
500
600
|
);
|
|
501
|
-
|
|
601
|
+
const afterIndex = focusables.findIndex(
|
|
602
|
+
(focusable2) => candidates.indexOf(focusable2) > activeIndex
|
|
603
|
+
);
|
|
604
|
+
newIndex = afterIndex >= 0 ? afterIndex : 0;
|
|
502
605
|
}
|
|
503
606
|
}
|
|
504
|
-
const focusable =
|
|
607
|
+
const focusable = focusables.at(newIndex);
|
|
505
608
|
focusable && focusElement(focusable);
|
|
506
609
|
};
|
|
507
610
|
#update(active) {
|
|
508
611
|
const current = new Set(this.#getFocusables());
|
|
509
612
|
for (const focusable of this.#focusables) {
|
|
510
613
|
if (!current.has(focusable)) {
|
|
511
|
-
|
|
614
|
+
_RovingTabIndex.#initialized.delete(focusable);
|
|
615
|
+
restoreAttributes2(focusable);
|
|
512
616
|
this.#focusables.delete(focusable);
|
|
513
|
-
this.#focusablesByFirstChar
|
|
617
|
+
for (const [key, focusables] of this.#focusablesByFirstChar) {
|
|
514
618
|
const index = focusables.indexOf(focusable);
|
|
515
|
-
index >= 0
|
|
516
|
-
|
|
619
|
+
if (index >= 0) {
|
|
620
|
+
focusables.splice(index, 1);
|
|
621
|
+
!focusables.length && this.#focusablesByFirstChar.delete(key);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
517
624
|
}
|
|
518
625
|
}
|
|
519
626
|
const { navigationOnly, noStart, typeahead } = this.#settings;
|
|
@@ -522,12 +629,12 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
522
629
|
continue;
|
|
523
630
|
}
|
|
524
631
|
if (_RovingTabIndex.#initialized.has(focusable)) {
|
|
525
|
-
|
|
632
|
+
continue;
|
|
526
633
|
}
|
|
527
634
|
this.#focusables.add(focusable);
|
|
528
635
|
_RovingTabIndex.#initialized.add(focusable);
|
|
529
636
|
if (!navigationOnly) {
|
|
530
|
-
|
|
637
|
+
saveAttributes2(focusable, "tabindex");
|
|
531
638
|
focusable.setAttribute("tabindex", "-1");
|
|
532
639
|
}
|
|
533
640
|
if (!typeahead) {
|
|
@@ -540,7 +647,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
540
647
|
);
|
|
541
648
|
if (char) {
|
|
542
649
|
keys.add(char);
|
|
543
|
-
|
|
650
|
+
saveAttributes2(focusable, "aria-keyshortcuts");
|
|
544
651
|
addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
|
|
545
652
|
caseInsensitive: true
|
|
546
653
|
});
|
|
@@ -671,7 +778,10 @@ var Accordion = class _Accordion {
|
|
|
671
778
|
});
|
|
672
779
|
this.#animationController?.abort();
|
|
673
780
|
this.#animationController = null;
|
|
674
|
-
restoreAttributes([
|
|
781
|
+
restoreAttributes([
|
|
782
|
+
...this.#triggerElements,
|
|
783
|
+
...this.#contentElements
|
|
784
|
+
]);
|
|
675
785
|
this.#triggerElements.length = 0;
|
|
676
786
|
this.#contentElements.length = 0;
|
|
677
787
|
this.#rootElement.removeAttribute("data-accordion-initialized");
|
|
@@ -694,7 +804,11 @@ var Accordion = class _Accordion {
|
|
|
694
804
|
"style",
|
|
695
805
|
"tabindex"
|
|
696
806
|
]);
|
|
697
|
-
saveAttributes(this.#contentElements, [
|
|
807
|
+
saveAttributes(this.#contentElements, [
|
|
808
|
+
"aria-labelledby",
|
|
809
|
+
"id",
|
|
810
|
+
"role"
|
|
811
|
+
]);
|
|
698
812
|
this.#eventController = new AbortController();
|
|
699
813
|
const { signal } = this.#eventController;
|
|
700
814
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
@@ -704,7 +818,7 @@ var Accordion = class _Accordion {
|
|
|
704
818
|
return;
|
|
705
819
|
}
|
|
706
820
|
content2.id ||= `accordion-content-${id}`;
|
|
707
|
-
|
|
821
|
+
addAttributeToken(trigger2, "aria-controls", content2.id);
|
|
708
822
|
trigger2.setAttribute(
|
|
709
823
|
"aria-expanded",
|
|
710
824
|
String(trigger2.ariaExpanded === "true")
|
|
@@ -716,7 +830,7 @@ var Accordion = class _Accordion {
|
|
|
716
830
|
trigger2.style.setProperty("pointer-events", "none");
|
|
717
831
|
}
|
|
718
832
|
trigger2.addEventListener("click", this.#onTriggerClick, { signal });
|
|
719
|
-
|
|
833
|
+
addAttributeToken(content2, "aria-labelledby", trigger2.id);
|
|
720
834
|
content2.setAttribute("role", "region");
|
|
721
835
|
content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
|
|
722
836
|
signal
|
|
@@ -820,7 +934,7 @@ var Accordion = class _Accordion {
|
|
|
820
934
|
);
|
|
821
935
|
}
|
|
822
936
|
#createBinding(trigger, content) {
|
|
823
|
-
return {
|
|
937
|
+
return { animation: null, content, trigger };
|
|
824
938
|
}
|
|
825
939
|
#isFocusable(element) {
|
|
826
940
|
return !element.hasAttribute("disabled") && element.tabIndex >= 0;
|
|
@@ -851,7 +965,7 @@ function waitAnimationFinish(animation) {
|
|
|
851
965
|
* Accordion
|
|
852
966
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
853
967
|
*
|
|
854
|
-
* @version 2.0.
|
|
968
|
+
* @version 2.0.5
|
|
855
969
|
* @author Yusuke Kamiyamane
|
|
856
970
|
* @license MIT
|
|
857
971
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -859,15 +973,15 @@ function waitAnimationFinish(animation) {
|
|
|
859
973
|
*/
|
|
860
974
|
/*! Bundled license information:
|
|
861
975
|
|
|
862
|
-
@y14e/
|
|
976
|
+
@y14e/attribute-util/dist/index.js:
|
|
863
977
|
(**
|
|
864
|
-
*
|
|
978
|
+
* Attribute Util
|
|
865
979
|
*
|
|
866
|
-
* @version
|
|
980
|
+
* @version 2.0.0
|
|
867
981
|
* @author Yusuke Kamiyamane
|
|
868
982
|
* @license MIT
|
|
869
983
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
870
|
-
* @see {@link https://github.com/y14e/
|
|
984
|
+
* @see {@link https://github.com/y14e/attribute-util}
|
|
871
985
|
*)
|
|
872
986
|
|
|
873
987
|
power-focusable/dist/index.js:
|
|
@@ -876,7 +990,7 @@ power-focusable/dist/index.js:
|
|
|
876
990
|
* High-precision focus management utility with full composed tree support.
|
|
877
991
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
878
992
|
*
|
|
879
|
-
* @version 4.3.
|
|
993
|
+
* @version 4.3.23
|
|
880
994
|
* @author Yusuke Kamiyamane
|
|
881
995
|
* @license MIT
|
|
882
996
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -894,13 +1008,24 @@ power-focusable/dist/index.js:
|
|
|
894
1008
|
* @see {@link https://github.com/y14e/button}
|
|
895
1009
|
*)
|
|
896
1010
|
|
|
1011
|
+
@y14e/attributes-utils/dist/index.js:
|
|
1012
|
+
(**
|
|
1013
|
+
* Attributes Utils
|
|
1014
|
+
*
|
|
1015
|
+
* @version 1.1.7
|
|
1016
|
+
* @author Yusuke Kamiyamane
|
|
1017
|
+
* @license MIT
|
|
1018
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
1019
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
1020
|
+
*)
|
|
1021
|
+
|
|
897
1022
|
@y14e/roving-tabindex/dist/index.js:
|
|
898
1023
|
(**
|
|
899
1024
|
* Roving Tabindex
|
|
900
1025
|
* Lightweight roving tabindex utility with fully focus management.
|
|
901
1026
|
* Designed for accessible menus, tabs, toolbars, and composite widgets.
|
|
902
1027
|
*
|
|
903
|
-
* @version 3.1.
|
|
1028
|
+
* @version 3.1.20
|
|
904
1029
|
* @author Yusuke Kamiyamane
|
|
905
1030
|
* @license MIT
|
|
906
1031
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var util = require('@y14e/attribute-util');
|
|
4
4
|
var Button = require('@y14e/button');
|
|
5
5
|
var rovingTabindex = require('@y14e/roving-tabindex');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var util__namespace = /*#__PURE__*/_interopNamespace(util);
|
|
9
28
|
var Button__default = /*#__PURE__*/_interopDefault(Button);
|
|
10
29
|
|
|
11
30
|
// src/index.ts
|
|
@@ -102,7 +121,10 @@ var Accordion = class _Accordion {
|
|
|
102
121
|
});
|
|
103
122
|
this.#animationController?.abort();
|
|
104
123
|
this.#animationController = null;
|
|
105
|
-
|
|
124
|
+
util__namespace.restoreAttributes([
|
|
125
|
+
...this.#triggerElements,
|
|
126
|
+
...this.#contentElements
|
|
127
|
+
]);
|
|
106
128
|
this.#triggerElements.length = 0;
|
|
107
129
|
this.#contentElements.length = 0;
|
|
108
130
|
this.#rootElement.removeAttribute("data-accordion-initialized");
|
|
@@ -118,14 +140,18 @@ var Accordion = class _Accordion {
|
|
|
118
140
|
this.#toggle(trigger, true);
|
|
119
141
|
}
|
|
120
142
|
#initialize() {
|
|
121
|
-
|
|
143
|
+
util__namespace.saveAttributes(this.#triggerElements, [
|
|
122
144
|
"aria-controls",
|
|
123
145
|
"aria-disabled",
|
|
124
146
|
"id",
|
|
125
147
|
"style",
|
|
126
148
|
"tabindex"
|
|
127
149
|
]);
|
|
128
|
-
|
|
150
|
+
util__namespace.saveAttributes(this.#contentElements, [
|
|
151
|
+
"aria-labelledby",
|
|
152
|
+
"id",
|
|
153
|
+
"role"
|
|
154
|
+
]);
|
|
129
155
|
this.#eventController = new AbortController();
|
|
130
156
|
const { signal } = this.#eventController;
|
|
131
157
|
this.#triggerElements.forEach((trigger2, i) => {
|
|
@@ -135,7 +161,7 @@ var Accordion = class _Accordion {
|
|
|
135
161
|
return;
|
|
136
162
|
}
|
|
137
163
|
content2.id ||= `accordion-content-${id}`;
|
|
138
|
-
|
|
164
|
+
util__namespace.addAttributeToken(trigger2, "aria-controls", content2.id);
|
|
139
165
|
trigger2.setAttribute(
|
|
140
166
|
"aria-expanded",
|
|
141
167
|
String(trigger2.ariaExpanded === "true")
|
|
@@ -147,7 +173,7 @@ var Accordion = class _Accordion {
|
|
|
147
173
|
trigger2.style.setProperty("pointer-events", "none");
|
|
148
174
|
}
|
|
149
175
|
trigger2.addEventListener("click", this.#onTriggerClick, { signal });
|
|
150
|
-
|
|
176
|
+
util__namespace.addAttributeToken(content2, "aria-labelledby", trigger2.id);
|
|
151
177
|
content2.setAttribute("role", "region");
|
|
152
178
|
content2.addEventListener("beforematch", this.#onContentBeforeMatch, {
|
|
153
179
|
signal
|
|
@@ -251,7 +277,7 @@ var Accordion = class _Accordion {
|
|
|
251
277
|
);
|
|
252
278
|
}
|
|
253
279
|
#createBinding(trigger, content) {
|
|
254
|
-
return {
|
|
280
|
+
return { animation: null, content, trigger };
|
|
255
281
|
}
|
|
256
282
|
#isFocusable(element) {
|
|
257
283
|
return !element.hasAttribute("disabled") && element.tabIndex >= 0;
|
|
@@ -282,7 +308,7 @@ function waitAnimationFinish(animation) {
|
|
|
282
308
|
* Accordion
|
|
283
309
|
* WAI-ARIA compliant accordion pattern implementation in TypeScript.
|
|
284
310
|
*
|
|
285
|
-
* @version 2.0.
|
|
311
|
+
* @version 2.0.5
|
|
286
312
|
* @author Yusuke Kamiyamane
|
|
287
313
|
* @license MIT
|
|
288
314
|
* @copyright Copyright (c) Yusuke Kamiyamane
|