@y14e/disclosure 2.2.0 → 2.2.1
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/dist/index.bundle.cjs +64 -58
- package/dist/index.bundle.js +64 -58
- package/dist/index.cjs +4 -3
- package/dist/index.js +4 -3
- package/package.json +2 -2
package/dist/index.bundle.cjs
CHANGED
|
@@ -344,6 +344,64 @@ function isFocusable(element, options = {}) {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
347
|
+
function getCellCoords(cell) {
|
|
348
|
+
const { left, top, width, height } = cell.getBoundingClientRect();
|
|
349
|
+
return { x: left + width / 2, y: top + height / 2 };
|
|
350
|
+
}
|
|
351
|
+
function getCellsOfActiveRow(cells) {
|
|
352
|
+
const active = getActiveElement();
|
|
353
|
+
if (!(active instanceof Element)) {
|
|
354
|
+
return [];
|
|
355
|
+
}
|
|
356
|
+
const activeRect = active.getBoundingClientRect();
|
|
357
|
+
return cells.filter((cell) => {
|
|
358
|
+
const cellRect = cell.getBoundingClientRect();
|
|
359
|
+
return cellRect.top < activeRect.bottom && cellRect.bottom > activeRect.top;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function getNextCell(cells, key, wrap) {
|
|
363
|
+
const active = getActiveElement();
|
|
364
|
+
if (!(active instanceof Element)) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const activeCoords = getCellCoords(active);
|
|
368
|
+
let min = Infinity;
|
|
369
|
+
let result = null;
|
|
370
|
+
for (const cell of cells) {
|
|
371
|
+
if (cell === active) {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
const cellCoords = getCellCoords(cell);
|
|
375
|
+
const distances = {
|
|
376
|
+
x: Math.abs(cellCoords.x - activeCoords.x),
|
|
377
|
+
y: Math.abs(cellCoords.y - activeCoords.y)
|
|
378
|
+
};
|
|
379
|
+
if (key === "ArrowUp" && cellCoords.y < activeCoords.y && distances.x < distances.y || key === "ArrowDown" && cellCoords.y > activeCoords.y && distances.x < distances.y) {
|
|
380
|
+
const distance = distances.x ** 2 + distances.y ** 2;
|
|
381
|
+
if (distance < min) {
|
|
382
|
+
min = distance;
|
|
383
|
+
result = cell;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (!result && wrap) {
|
|
388
|
+
let max = -Infinity;
|
|
389
|
+
for (const cell of cells) {
|
|
390
|
+
if (cell === active) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
const cellCoords = getCellCoords(cell);
|
|
394
|
+
if (Math.abs(cellCoords.x - activeCoords.x) < cell.getBoundingClientRect().width / 2) {
|
|
395
|
+
const distance = key === "ArrowUp" ? cellCoords.y - activeCoords.y : activeCoords.y - cellCoords.y;
|
|
396
|
+
if (distance > max) {
|
|
397
|
+
max = distance;
|
|
398
|
+
result = cell;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
347
405
|
var DIRECTIONS = ["both", "grid", "horizontal", "vertical"];
|
|
348
406
|
function resolveOptions3(options) {
|
|
349
407
|
let {
|
|
@@ -601,20 +659,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
601
659
|
const { selector } = this.#settings;
|
|
602
660
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
603
661
|
}
|
|
604
|
-
#getCellCoords(cell) {
|
|
605
|
-
const { left, top, width, height } = cell.getBoundingClientRect();
|
|
606
|
-
return { x: left + width / 2, y: top + height / 2 };
|
|
607
|
-
}
|
|
608
662
|
#getCellsOfActiveRow() {
|
|
609
|
-
|
|
610
|
-
if (!(active instanceof Element)) {
|
|
611
|
-
return [];
|
|
612
|
-
}
|
|
613
|
-
const activeRect = active.getBoundingClientRect();
|
|
614
|
-
return this.#getFocusables().filter((cell) => {
|
|
615
|
-
const cellRect = cell.getBoundingClientRect();
|
|
616
|
-
return cellRect.top < activeRect.bottom && cellRect.bottom > activeRect.top;
|
|
617
|
-
});
|
|
663
|
+
return getCellsOfActiveRow(this.#getFocusables());
|
|
618
664
|
}
|
|
619
665
|
#getFocusables() {
|
|
620
666
|
return getFocusables(this.#container, {
|
|
@@ -625,48 +671,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
625
671
|
});
|
|
626
672
|
}
|
|
627
673
|
#getNextCell(key, wrap) {
|
|
628
|
-
|
|
629
|
-
const active = getActiveElement();
|
|
630
|
-
if (!(active instanceof Element)) {
|
|
631
|
-
return null;
|
|
632
|
-
}
|
|
633
|
-
const activeCoords = this.#getCellCoords(active);
|
|
634
|
-
let min = Infinity;
|
|
635
|
-
let result = null;
|
|
636
|
-
for (const cell of cells) {
|
|
637
|
-
if (cell === active) {
|
|
638
|
-
continue;
|
|
639
|
-
}
|
|
640
|
-
const cellCoords = this.#getCellCoords(cell);
|
|
641
|
-
const distances = {
|
|
642
|
-
x: Math.abs(cellCoords.x - activeCoords.x),
|
|
643
|
-
y: Math.abs(cellCoords.y - activeCoords.y)
|
|
644
|
-
};
|
|
645
|
-
if (key === "ArrowUp" && cellCoords.y < activeCoords.y && distances.x < distances.y || key === "ArrowDown" && cellCoords.y > activeCoords.y && distances.x < distances.y) {
|
|
646
|
-
const distance = distances.x ** 2 + distances.y ** 2;
|
|
647
|
-
if (distance < min) {
|
|
648
|
-
min = distance;
|
|
649
|
-
result = cell;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
if (!result && wrap) {
|
|
654
|
-
let max = -Infinity;
|
|
655
|
-
for (const cell of cells) {
|
|
656
|
-
if (cell === active) {
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
const cellCoords = this.#getCellCoords(cell);
|
|
660
|
-
if (Math.abs(cellCoords.x - activeCoords.x) < cell.getBoundingClientRect().width / 2) {
|
|
661
|
-
const distance = key === "ArrowUp" ? cellCoords.y - activeCoords.y : activeCoords.y - cellCoords.y;
|
|
662
|
-
if (distance > max) {
|
|
663
|
-
max = distance;
|
|
664
|
-
result = cell;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return result;
|
|
674
|
+
return getNextCell(this.#getFocusables(), key, wrap);
|
|
670
675
|
}
|
|
671
676
|
};
|
|
672
677
|
|
|
@@ -715,7 +720,6 @@ function resolveOptions4(defaults2, source) {
|
|
|
715
720
|
var Disclosure = class _Disclosure {
|
|
716
721
|
static defaults = {};
|
|
717
722
|
#rootElement;
|
|
718
|
-
#defaults = defaults;
|
|
719
723
|
#settings;
|
|
720
724
|
#detailsElements;
|
|
721
725
|
#summaryElements;
|
|
@@ -735,8 +739,10 @@ var Disclosure = class _Disclosure {
|
|
|
735
739
|
return;
|
|
736
740
|
}
|
|
737
741
|
this.#rootElement = root;
|
|
738
|
-
this.#
|
|
739
|
-
|
|
742
|
+
this.#settings = resolveOptions4(
|
|
743
|
+
resolveOptions4(defaults, _Disclosure.defaults),
|
|
744
|
+
options
|
|
745
|
+
);
|
|
740
746
|
matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
|
|
741
747
|
const NOT_NESTED = ":not(:scope summary + * *)";
|
|
742
748
|
this.#detailsElements = [
|
package/dist/index.bundle.js
CHANGED
|
@@ -342,6 +342,64 @@ function isFocusable(element, options = {}) {
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
// node_modules/@y14e/roving-tabindex/dist/index.js
|
|
345
|
+
function getCellCoords(cell) {
|
|
346
|
+
const { left, top, width, height } = cell.getBoundingClientRect();
|
|
347
|
+
return { x: left + width / 2, y: top + height / 2 };
|
|
348
|
+
}
|
|
349
|
+
function getCellsOfActiveRow(cells) {
|
|
350
|
+
const active = getActiveElement();
|
|
351
|
+
if (!(active instanceof Element)) {
|
|
352
|
+
return [];
|
|
353
|
+
}
|
|
354
|
+
const activeRect = active.getBoundingClientRect();
|
|
355
|
+
return cells.filter((cell) => {
|
|
356
|
+
const cellRect = cell.getBoundingClientRect();
|
|
357
|
+
return cellRect.top < activeRect.bottom && cellRect.bottom > activeRect.top;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function getNextCell(cells, key, wrap) {
|
|
361
|
+
const active = getActiveElement();
|
|
362
|
+
if (!(active instanceof Element)) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
const activeCoords = getCellCoords(active);
|
|
366
|
+
let min = Infinity;
|
|
367
|
+
let result = null;
|
|
368
|
+
for (const cell of cells) {
|
|
369
|
+
if (cell === active) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
const cellCoords = getCellCoords(cell);
|
|
373
|
+
const distances = {
|
|
374
|
+
x: Math.abs(cellCoords.x - activeCoords.x),
|
|
375
|
+
y: Math.abs(cellCoords.y - activeCoords.y)
|
|
376
|
+
};
|
|
377
|
+
if (key === "ArrowUp" && cellCoords.y < activeCoords.y && distances.x < distances.y || key === "ArrowDown" && cellCoords.y > activeCoords.y && distances.x < distances.y) {
|
|
378
|
+
const distance = distances.x ** 2 + distances.y ** 2;
|
|
379
|
+
if (distance < min) {
|
|
380
|
+
min = distance;
|
|
381
|
+
result = cell;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (!result && wrap) {
|
|
386
|
+
let max = -Infinity;
|
|
387
|
+
for (const cell of cells) {
|
|
388
|
+
if (cell === active) {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
const cellCoords = getCellCoords(cell);
|
|
392
|
+
if (Math.abs(cellCoords.x - activeCoords.x) < cell.getBoundingClientRect().width / 2) {
|
|
393
|
+
const distance = key === "ArrowUp" ? cellCoords.y - activeCoords.y : activeCoords.y - cellCoords.y;
|
|
394
|
+
if (distance > max) {
|
|
395
|
+
max = distance;
|
|
396
|
+
result = cell;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
345
403
|
var DIRECTIONS = ["both", "grid", "horizontal", "vertical"];
|
|
346
404
|
function resolveOptions3(options) {
|
|
347
405
|
let {
|
|
@@ -599,20 +657,8 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
599
657
|
const { selector } = this.#settings;
|
|
600
658
|
return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
|
|
601
659
|
}
|
|
602
|
-
#getCellCoords(cell) {
|
|
603
|
-
const { left, top, width, height } = cell.getBoundingClientRect();
|
|
604
|
-
return { x: left + width / 2, y: top + height / 2 };
|
|
605
|
-
}
|
|
606
660
|
#getCellsOfActiveRow() {
|
|
607
|
-
|
|
608
|
-
if (!(active instanceof Element)) {
|
|
609
|
-
return [];
|
|
610
|
-
}
|
|
611
|
-
const activeRect = active.getBoundingClientRect();
|
|
612
|
-
return this.#getFocusables().filter((cell) => {
|
|
613
|
-
const cellRect = cell.getBoundingClientRect();
|
|
614
|
-
return cellRect.top < activeRect.bottom && cellRect.bottom > activeRect.top;
|
|
615
|
-
});
|
|
661
|
+
return getCellsOfActiveRow(this.#getFocusables());
|
|
616
662
|
}
|
|
617
663
|
#getFocusables() {
|
|
618
664
|
return getFocusables(this.#container, {
|
|
@@ -623,48 +669,7 @@ var RovingTabIndex = class _RovingTabIndex {
|
|
|
623
669
|
});
|
|
624
670
|
}
|
|
625
671
|
#getNextCell(key, wrap) {
|
|
626
|
-
|
|
627
|
-
const active = getActiveElement();
|
|
628
|
-
if (!(active instanceof Element)) {
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
const activeCoords = this.#getCellCoords(active);
|
|
632
|
-
let min = Infinity;
|
|
633
|
-
let result = null;
|
|
634
|
-
for (const cell of cells) {
|
|
635
|
-
if (cell === active) {
|
|
636
|
-
continue;
|
|
637
|
-
}
|
|
638
|
-
const cellCoords = this.#getCellCoords(cell);
|
|
639
|
-
const distances = {
|
|
640
|
-
x: Math.abs(cellCoords.x - activeCoords.x),
|
|
641
|
-
y: Math.abs(cellCoords.y - activeCoords.y)
|
|
642
|
-
};
|
|
643
|
-
if (key === "ArrowUp" && cellCoords.y < activeCoords.y && distances.x < distances.y || key === "ArrowDown" && cellCoords.y > activeCoords.y && distances.x < distances.y) {
|
|
644
|
-
const distance = distances.x ** 2 + distances.y ** 2;
|
|
645
|
-
if (distance < min) {
|
|
646
|
-
min = distance;
|
|
647
|
-
result = cell;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
if (!result && wrap) {
|
|
652
|
-
let max = -Infinity;
|
|
653
|
-
for (const cell of cells) {
|
|
654
|
-
if (cell === active) {
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
const cellCoords = this.#getCellCoords(cell);
|
|
658
|
-
if (Math.abs(cellCoords.x - activeCoords.x) < cell.getBoundingClientRect().width / 2) {
|
|
659
|
-
const distance = key === "ArrowUp" ? cellCoords.y - activeCoords.y : activeCoords.y - cellCoords.y;
|
|
660
|
-
if (distance > max) {
|
|
661
|
-
max = distance;
|
|
662
|
-
result = cell;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
return result;
|
|
672
|
+
return getNextCell(this.#getFocusables(), key, wrap);
|
|
668
673
|
}
|
|
669
674
|
};
|
|
670
675
|
|
|
@@ -713,7 +718,6 @@ function resolveOptions4(defaults2, source) {
|
|
|
713
718
|
var Disclosure = class _Disclosure {
|
|
714
719
|
static defaults = {};
|
|
715
720
|
#rootElement;
|
|
716
|
-
#defaults = defaults;
|
|
717
721
|
#settings;
|
|
718
722
|
#detailsElements;
|
|
719
723
|
#summaryElements;
|
|
@@ -733,8 +737,10 @@ var Disclosure = class _Disclosure {
|
|
|
733
737
|
return;
|
|
734
738
|
}
|
|
735
739
|
this.#rootElement = root;
|
|
736
|
-
this.#
|
|
737
|
-
|
|
740
|
+
this.#settings = resolveOptions4(
|
|
741
|
+
resolveOptions4(defaults, _Disclosure.defaults),
|
|
742
|
+
options
|
|
743
|
+
);
|
|
738
744
|
matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
|
|
739
745
|
const NOT_NESTED = ":not(:scope summary + * *)";
|
|
740
746
|
this.#detailsElements = [
|
package/dist/index.cjs
CHANGED
|
@@ -50,7 +50,6 @@ function resolveOptions(defaults2, source) {
|
|
|
50
50
|
var Disclosure = class _Disclosure {
|
|
51
51
|
static defaults = {};
|
|
52
52
|
#rootElement;
|
|
53
|
-
#defaults = defaults;
|
|
54
53
|
#settings;
|
|
55
54
|
#detailsElements;
|
|
56
55
|
#summaryElements;
|
|
@@ -70,8 +69,10 @@ var Disclosure = class _Disclosure {
|
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
71
|
this.#rootElement = root;
|
|
73
|
-
this.#
|
|
74
|
-
|
|
72
|
+
this.#settings = resolveOptions(
|
|
73
|
+
resolveOptions(defaults, _Disclosure.defaults),
|
|
74
|
+
options
|
|
75
|
+
);
|
|
75
76
|
matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
|
|
76
77
|
const NOT_NESTED = ":not(:scope summary + * *)";
|
|
77
78
|
this.#detailsElements = [
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,6 @@ function resolveOptions(defaults2, source) {
|
|
|
48
48
|
var Disclosure = class _Disclosure {
|
|
49
49
|
static defaults = {};
|
|
50
50
|
#rootElement;
|
|
51
|
-
#defaults = defaults;
|
|
52
51
|
#settings;
|
|
53
52
|
#detailsElements;
|
|
54
53
|
#summaryElements;
|
|
@@ -68,8 +67,10 @@ var Disclosure = class _Disclosure {
|
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
69
|
this.#rootElement = root;
|
|
71
|
-
this.#
|
|
72
|
-
|
|
70
|
+
this.#settings = resolveOptions(
|
|
71
|
+
resolveOptions(defaults, _Disclosure.defaults),
|
|
72
|
+
options
|
|
73
|
+
);
|
|
73
74
|
matchMedia("(prefers-reduced-motion: reduce)").matches && Object.assign(this.#settings.animation, { duration: 0 });
|
|
74
75
|
const NOT_NESTED = ":not(:scope summary + * *)";
|
|
75
76
|
this.#detailsElements = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/disclosure",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
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.16",
|
|
58
|
-
"@y14e/roving-tabindex": "^3.4.
|
|
58
|
+
"@y14e/roving-tabindex": "^3.4.1"
|
|
59
59
|
}
|
|
60
60
|
}
|