aria-ease 6.0.1 → 6.2.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/dist/index.cjs +83 -24
- package/dist/index.d.cts +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.js +83 -24
- package/dist/src/{Types.d-COr5IFp5.d.cts → Types.d-CBuuHF3d.d.cts} +28 -4
- package/dist/src/{Types.d-COr5IFp5.d.ts → Types.d-CBuuHF3d.d.ts} +28 -4
- package/dist/src/accordion/index.cjs +28 -2
- package/dist/src/accordion/index.d.cts +3 -8
- package/dist/src/accordion/index.d.ts +3 -8
- package/dist/src/accordion/index.js +28 -2
- package/dist/src/block/index.cjs +1 -1
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/block/index.js +1 -1
- package/dist/src/checkbox/index.d.cts +1 -1
- package/dist/src/checkbox/index.d.ts +1 -1
- package/dist/src/{chunk-TBJ6MIC7.js → chunk-ZJXZZDUR.js} +7 -1
- package/dist/src/combobox/index.cjs +18 -16
- package/dist/src/combobox/index.d.cts +3 -3
- package/dist/src/combobox/index.d.ts +3 -3
- package/dist/src/combobox/index.js +18 -16
- package/dist/src/menu/index.cjs +37 -6
- package/dist/src/menu/index.d.cts +2 -6
- package/dist/src/menu/index.d.ts +2 -6
- package/dist/src/menu/index.js +31 -6
- package/dist/src/radio/index.d.cts +1 -1
- package/dist/src/radio/index.d.ts +1 -1
- package/dist/src/toggle/index.d.cts +1 -1
- package/dist/src/toggle/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -832,7 +832,7 @@ __export(index_exports, {
|
|
|
832
832
|
module.exports = __toCommonJS(index_exports);
|
|
833
833
|
|
|
834
834
|
// src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
|
|
835
|
-
function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false }) {
|
|
835
|
+
function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false, callback }) {
|
|
836
836
|
const accordionContainer = document.querySelector(`#${accordionId}`);
|
|
837
837
|
if (!accordionContainer) {
|
|
838
838
|
console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`);
|
|
@@ -883,6 +883,13 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
|
|
|
883
883
|
const panel = panels[index];
|
|
884
884
|
trigger.setAttribute("aria-expanded", "true");
|
|
885
885
|
panel.style.display = "block";
|
|
886
|
+
if (callback?.onExpand) {
|
|
887
|
+
try {
|
|
888
|
+
callback.onExpand(index);
|
|
889
|
+
} catch (error) {
|
|
890
|
+
console.error("[aria-ease] Error in accordion onExpand callback:", error);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
886
893
|
}
|
|
887
894
|
function collapseItem(index) {
|
|
888
895
|
if (index < 0 || index >= triggers.length) {
|
|
@@ -893,6 +900,13 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
|
|
|
893
900
|
const panel = panels[index];
|
|
894
901
|
trigger.setAttribute("aria-expanded", "false");
|
|
895
902
|
panel.style.display = "none";
|
|
903
|
+
if (callback?.onCollapse) {
|
|
904
|
+
try {
|
|
905
|
+
callback.onCollapse(index);
|
|
906
|
+
} catch (error) {
|
|
907
|
+
console.error("[aria-ease] Error in accordion onCollapse callback:", error);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
896
910
|
}
|
|
897
911
|
function toggleItem(index) {
|
|
898
912
|
const trigger = triggers[index];
|
|
@@ -979,13 +993,25 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
|
|
|
979
993
|
collapseItem(index);
|
|
980
994
|
});
|
|
981
995
|
}
|
|
996
|
+
function refresh() {
|
|
997
|
+
removeListeners();
|
|
998
|
+
const newTriggers = Array.from(accordionContainer.querySelectorAll(`.${triggersClass}`));
|
|
999
|
+
const newPanels = Array.from(accordionContainer.querySelectorAll(`.${panelsClass}`));
|
|
1000
|
+
triggers.length = 0;
|
|
1001
|
+
triggers.push(...newTriggers);
|
|
1002
|
+
panels.length = 0;
|
|
1003
|
+
panels.push(...newPanels);
|
|
1004
|
+
initialize();
|
|
1005
|
+
addListeners();
|
|
1006
|
+
}
|
|
982
1007
|
initialize();
|
|
983
1008
|
addListeners();
|
|
984
1009
|
return {
|
|
985
1010
|
expandItem,
|
|
986
1011
|
collapseItem,
|
|
987
1012
|
toggleItem,
|
|
988
|
-
cleanup
|
|
1013
|
+
cleanup,
|
|
1014
|
+
refresh
|
|
989
1015
|
};
|
|
990
1016
|
}
|
|
991
1017
|
|
|
@@ -1027,7 +1053,7 @@ function hasSubmenu(menuItem) {
|
|
|
1027
1053
|
function getSubmenuId(menuItem) {
|
|
1028
1054
|
return menuItem.getAttribute("aria-controls");
|
|
1029
1055
|
}
|
|
1030
|
-
function handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, triggerButton, openSubmenu, closeSubmenu) {
|
|
1056
|
+
function handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, triggerButton, openSubmenu, closeSubmenu, onOpenChange) {
|
|
1031
1057
|
const currentEl = elementItems.item(elementItemIndex);
|
|
1032
1058
|
switch (event.key) {
|
|
1033
1059
|
case "ArrowUp":
|
|
@@ -1084,6 +1110,9 @@ function handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, t
|
|
|
1084
1110
|
if (menuElementDiv && triggerButton) {
|
|
1085
1111
|
if (getComputedStyle(menuElementDiv).display === "block") {
|
|
1086
1112
|
handleMenuClose(menuElementDiv, triggerButton);
|
|
1113
|
+
if (onOpenChange) {
|
|
1114
|
+
onOpenChange(false);
|
|
1115
|
+
}
|
|
1087
1116
|
}
|
|
1088
1117
|
triggerButton.focus();
|
|
1089
1118
|
}
|
|
@@ -1103,6 +1132,9 @@ function handleKeyPress(event, elementItems, elementItemIndex, menuElementDiv, t
|
|
|
1103
1132
|
case "Tab": {
|
|
1104
1133
|
if (menuElementDiv && triggerButton && (!event.shiftKey || event.shiftKey)) {
|
|
1105
1134
|
handleMenuClose(menuElementDiv, triggerButton);
|
|
1135
|
+
if (onOpenChange) {
|
|
1136
|
+
onOpenChange(false);
|
|
1137
|
+
}
|
|
1106
1138
|
}
|
|
1107
1139
|
break;
|
|
1108
1140
|
}
|
|
@@ -1288,7 +1320,7 @@ function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
|
1288
1320
|
}
|
|
1289
1321
|
|
|
1290
1322
|
// src/menu/src/makeMenuAccessible/makeMenuAccessible.ts
|
|
1291
|
-
function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
1323
|
+
function makeMenuAccessible({ menuId, menuItemsClass, triggerId, callback }) {
|
|
1292
1324
|
const menuDiv = document.querySelector(`#${menuId}`);
|
|
1293
1325
|
if (!menuDiv) {
|
|
1294
1326
|
console.error(`[aria-ease] Element with id="${menuId}" not found. Make sure the menu element exists before calling makeMenuAccessible.`);
|
|
@@ -1348,8 +1380,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
1348
1380
|
const nodeListLike = {
|
|
1349
1381
|
length: items.length,
|
|
1350
1382
|
item: (index) => items[index],
|
|
1351
|
-
forEach: (
|
|
1352
|
-
items.forEach(
|
|
1383
|
+
forEach: (callback2) => {
|
|
1384
|
+
items.forEach(callback2);
|
|
1353
1385
|
},
|
|
1354
1386
|
[Symbol.iterator]: function* () {
|
|
1355
1387
|
for (const item of items) {
|
|
@@ -1393,7 +1425,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
1393
1425
|
submenuInstance = makeMenuAccessible({
|
|
1394
1426
|
menuId: submenuId,
|
|
1395
1427
|
menuItemsClass,
|
|
1396
|
-
triggerId: submenuTrigger.id
|
|
1428
|
+
triggerId: submenuTrigger.id,
|
|
1429
|
+
callback
|
|
1397
1430
|
});
|
|
1398
1431
|
submenuInstances.set(submenuId, submenuInstance);
|
|
1399
1432
|
}
|
|
@@ -1402,6 +1435,15 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
1402
1435
|
function closeSubmenu() {
|
|
1403
1436
|
closeMenu();
|
|
1404
1437
|
}
|
|
1438
|
+
function onOpenChange(isOpen) {
|
|
1439
|
+
if (callback?.onOpenChange) {
|
|
1440
|
+
try {
|
|
1441
|
+
callback.onOpenChange(isOpen);
|
|
1442
|
+
} catch (error) {
|
|
1443
|
+
console.error("[aria-ease] Error in menu onOpenChange callback:", error);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1405
1447
|
function addListeners() {
|
|
1406
1448
|
const items = getFilteredItems();
|
|
1407
1449
|
const nodeListLike = toNodeListLike(items);
|
|
@@ -1414,7 +1456,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
1414
1456
|
menuDiv,
|
|
1415
1457
|
triggerButton,
|
|
1416
1458
|
openSubmenu,
|
|
1417
|
-
closeSubmenu
|
|
1459
|
+
closeSubmenu,
|
|
1460
|
+
onOpenChange
|
|
1418
1461
|
);
|
|
1419
1462
|
menuItem.addEventListener("keydown", handler);
|
|
1420
1463
|
handlerMap.set(menuItem, handler);
|
|
@@ -1439,12 +1482,26 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
1439
1482
|
if (items && items.length > 0) {
|
|
1440
1483
|
items[0].focus();
|
|
1441
1484
|
}
|
|
1485
|
+
if (callback?.onOpenChange) {
|
|
1486
|
+
try {
|
|
1487
|
+
callback.onOpenChange(true);
|
|
1488
|
+
} catch (error) {
|
|
1489
|
+
console.error("[aria-ease] Error in menu onOpenChange callback:", error);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1442
1492
|
}
|
|
1443
1493
|
function closeMenu() {
|
|
1444
1494
|
setAria(false);
|
|
1445
1495
|
menuDiv.style.display = "none";
|
|
1446
1496
|
removeListeners();
|
|
1447
1497
|
triggerButton.focus();
|
|
1498
|
+
if (callback?.onOpenChange) {
|
|
1499
|
+
try {
|
|
1500
|
+
callback.onOpenChange(false);
|
|
1501
|
+
} catch (error) {
|
|
1502
|
+
console.error("[aria-ease] Error in menu onOpenChange callback:", error);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1448
1505
|
}
|
|
1449
1506
|
function intializeMenuItems() {
|
|
1450
1507
|
const items = getItems();
|
|
@@ -1755,7 +1812,7 @@ function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle = true })
|
|
|
1755
1812
|
}
|
|
1756
1813
|
|
|
1757
1814
|
// src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
|
|
1758
|
-
function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass,
|
|
1815
|
+
function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }) {
|
|
1759
1816
|
const comboboxInput = document.getElementById(`${comboboxInputId}`);
|
|
1760
1817
|
if (!comboboxInput) {
|
|
1761
1818
|
console.error(`[aria-ease] Element with id="${comboboxInputId}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`);
|
|
@@ -1802,11 +1859,11 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
|
|
|
1802
1859
|
if (typeof activeItem.scrollIntoView === "function") {
|
|
1803
1860
|
activeItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
1804
1861
|
}
|
|
1805
|
-
if (
|
|
1862
|
+
if (callback?.onActiveDescendantChange) {
|
|
1806
1863
|
try {
|
|
1807
|
-
|
|
1864
|
+
callback.onActiveDescendantChange(itemId, activeItem);
|
|
1808
1865
|
} catch (error) {
|
|
1809
|
-
console.error("[aria-ease] Error in onActiveDescendantChange callback:", error);
|
|
1866
|
+
console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:", error);
|
|
1810
1867
|
}
|
|
1811
1868
|
}
|
|
1812
1869
|
} else {
|
|
@@ -1816,25 +1873,27 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
|
|
|
1816
1873
|
}
|
|
1817
1874
|
function openListbox() {
|
|
1818
1875
|
comboboxInput.setAttribute("aria-expanded", "true");
|
|
1819
|
-
|
|
1876
|
+
listBox.style.display = "block";
|
|
1877
|
+
if (callback?.onOpenChange) {
|
|
1820
1878
|
try {
|
|
1821
|
-
|
|
1879
|
+
callback.onOpenChange(true);
|
|
1822
1880
|
} catch (error) {
|
|
1823
|
-
console.error("[aria-ease] Error in onOpenChange callback:", error);
|
|
1881
|
+
console.error("[aria-ease] Error in combobox onOpenChange callback:", error);
|
|
1824
1882
|
}
|
|
1825
1883
|
}
|
|
1826
1884
|
}
|
|
1827
1885
|
function closeListbox() {
|
|
1828
1886
|
comboboxInput.setAttribute("aria-expanded", "false");
|
|
1829
1887
|
comboboxInput.setAttribute("aria-activedescendant", "");
|
|
1888
|
+
listBox.style.display = "none";
|
|
1830
1889
|
activeIndex = -1;
|
|
1831
1890
|
const visibleItems = getVisibleItems();
|
|
1832
1891
|
visibleItems.forEach((item) => item.setAttribute("aria-selected", "false"));
|
|
1833
|
-
if (
|
|
1892
|
+
if (callback?.onOpenChange) {
|
|
1834
1893
|
try {
|
|
1835
|
-
|
|
1894
|
+
callback.onOpenChange(false);
|
|
1836
1895
|
} catch (error) {
|
|
1837
|
-
console.error("[aria-ease] Error in onOpenChange callback:", error);
|
|
1896
|
+
console.error("[aria-ease] Error in combobox onOpenChange callback:", error);
|
|
1838
1897
|
}
|
|
1839
1898
|
}
|
|
1840
1899
|
}
|
|
@@ -1842,11 +1901,11 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
|
|
|
1842
1901
|
const value = item.textContent?.trim() || "";
|
|
1843
1902
|
comboboxInput.value = value;
|
|
1844
1903
|
closeListbox();
|
|
1845
|
-
if (
|
|
1904
|
+
if (callback?.onSelect) {
|
|
1846
1905
|
try {
|
|
1847
|
-
|
|
1906
|
+
callback.onSelect(item);
|
|
1848
1907
|
} catch (error) {
|
|
1849
|
-
console.error("[aria-ease] Error in onSelect callback:", error);
|
|
1908
|
+
console.error("[aria-ease] Error in combobox onSelect callback:", error);
|
|
1850
1909
|
}
|
|
1851
1910
|
}
|
|
1852
1911
|
}
|
|
@@ -1887,11 +1946,11 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
|
|
|
1887
1946
|
} else if (comboboxInput.value) {
|
|
1888
1947
|
event.preventDefault();
|
|
1889
1948
|
comboboxInput.value = "";
|
|
1890
|
-
if (
|
|
1949
|
+
if (callback?.onClear) {
|
|
1891
1950
|
try {
|
|
1892
|
-
|
|
1951
|
+
callback.onClear();
|
|
1893
1952
|
} catch (error) {
|
|
1894
|
-
console.error("[aria-ease] Error in onClear callback:", error);
|
|
1953
|
+
console.error("[aria-ease] Error in combobox onClear callback:", error);
|
|
1895
1954
|
}
|
|
1896
1955
|
}
|
|
1897
1956
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -28,21 +28,45 @@ interface AccessibilityInstance {
|
|
|
28
28
|
getPressedIndices?: () => number[];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
interface AccordionConfig {
|
|
32
|
+
accordionId: string;
|
|
33
|
+
triggersClass: string;
|
|
34
|
+
panelsClass: string;
|
|
35
|
+
allowMultipleOpen?: boolean;
|
|
36
|
+
callback?: AccordionCallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface AccordionCallback {
|
|
40
|
+
onExpand?: (index: number) => void;
|
|
41
|
+
onCollapse?: (index: number) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
interface ComboboxConfig {
|
|
32
45
|
comboboxInputId: string;
|
|
33
46
|
comboboxButtonId?: string;
|
|
34
47
|
listBoxId: string;
|
|
35
48
|
listBoxItemsClass: string;
|
|
36
|
-
|
|
49
|
+
callback?: ComboboxCallback;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
interface
|
|
40
|
-
onSelect?: (item: HTMLElement
|
|
52
|
+
interface ComboboxCallback {
|
|
53
|
+
onSelect?: (item: HTMLElement) => void;
|
|
41
54
|
onOpenChange?: (isOpen: boolean) => void;
|
|
42
55
|
onActiveDescendantChange?: (optionId: string, item: HTMLElement) => void;
|
|
43
56
|
onClear?: () => void;
|
|
44
57
|
}
|
|
45
58
|
|
|
59
|
+
interface MenuConfig {
|
|
60
|
+
menuId: string;
|
|
61
|
+
menuItemsClass: string;
|
|
62
|
+
triggerId: string;
|
|
63
|
+
callback: MenuCallback;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface MenuCallback {
|
|
67
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
/**
|
|
47
71
|
* Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
48
72
|
* Handles multiple accordion items with proper focus management and keyboard interactions.
|
|
@@ -50,15 +74,10 @@ interface config {
|
|
|
50
74
|
* @param {string} triggersClass - The shared class of all accordion trigger buttons.
|
|
51
75
|
* @param {string} panelsClass - The shared class of all accordion panels.
|
|
52
76
|
* @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
|
|
77
|
+
* @param {AccordionCallback} callback - Configuration options for callbacks.
|
|
53
78
|
*/
|
|
54
79
|
|
|
55
|
-
|
|
56
|
-
accordionId: string;
|
|
57
|
-
triggersClass: string;
|
|
58
|
-
panelsClass: string;
|
|
59
|
-
allowMultipleOpen?: boolean;
|
|
60
|
-
}
|
|
61
|
-
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
|
|
80
|
+
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
|
|
62
81
|
|
|
63
82
|
/**
|
|
64
83
|
* Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
|
|
@@ -92,11 +111,7 @@ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: Ch
|
|
|
92
111
|
* @param {string} triggerId - The id of the button that triggers the menu.
|
|
93
112
|
*/
|
|
94
113
|
|
|
95
|
-
declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId }:
|
|
96
|
-
menuId: string;
|
|
97
|
-
menuItemsClass: string;
|
|
98
|
-
triggerId: string;
|
|
99
|
-
}): AccessibilityInstance;
|
|
114
|
+
declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId, callback }: MenuConfig): AccessibilityInstance;
|
|
100
115
|
|
|
101
116
|
/**
|
|
102
117
|
* Makes a radio group accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
@@ -134,10 +149,10 @@ declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }
|
|
|
134
149
|
* @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
|
|
135
150
|
* @param {string} listBoxId - The id of the listbox element.
|
|
136
151
|
* @param {string} listBoxItemsClass - The class of the items within the listbox.
|
|
137
|
-
* @param {
|
|
152
|
+
* @param {ComboboxCallback} callback - Configuration options for callbacks.
|
|
138
153
|
*/
|
|
139
154
|
|
|
140
|
-
declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass,
|
|
155
|
+
declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
|
|
141
156
|
|
|
142
157
|
/**
|
|
143
158
|
* Runs static and interactions accessibility test on UI components.
|
package/dist/index.d.ts
CHANGED
|
@@ -28,21 +28,45 @@ interface AccessibilityInstance {
|
|
|
28
28
|
getPressedIndices?: () => number[];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
interface AccordionConfig {
|
|
32
|
+
accordionId: string;
|
|
33
|
+
triggersClass: string;
|
|
34
|
+
panelsClass: string;
|
|
35
|
+
allowMultipleOpen?: boolean;
|
|
36
|
+
callback?: AccordionCallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface AccordionCallback {
|
|
40
|
+
onExpand?: (index: number) => void;
|
|
41
|
+
onCollapse?: (index: number) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
interface ComboboxConfig {
|
|
32
45
|
comboboxInputId: string;
|
|
33
46
|
comboboxButtonId?: string;
|
|
34
47
|
listBoxId: string;
|
|
35
48
|
listBoxItemsClass: string;
|
|
36
|
-
|
|
49
|
+
callback?: ComboboxCallback;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
interface
|
|
40
|
-
onSelect?: (item: HTMLElement
|
|
52
|
+
interface ComboboxCallback {
|
|
53
|
+
onSelect?: (item: HTMLElement) => void;
|
|
41
54
|
onOpenChange?: (isOpen: boolean) => void;
|
|
42
55
|
onActiveDescendantChange?: (optionId: string, item: HTMLElement) => void;
|
|
43
56
|
onClear?: () => void;
|
|
44
57
|
}
|
|
45
58
|
|
|
59
|
+
interface MenuConfig {
|
|
60
|
+
menuId: string;
|
|
61
|
+
menuItemsClass: string;
|
|
62
|
+
triggerId: string;
|
|
63
|
+
callback: MenuCallback;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface MenuCallback {
|
|
67
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
/**
|
|
47
71
|
* Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
48
72
|
* Handles multiple accordion items with proper focus management and keyboard interactions.
|
|
@@ -50,15 +74,10 @@ interface config {
|
|
|
50
74
|
* @param {string} triggersClass - The shared class of all accordion trigger buttons.
|
|
51
75
|
* @param {string} panelsClass - The shared class of all accordion panels.
|
|
52
76
|
* @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
|
|
77
|
+
* @param {AccordionCallback} callback - Configuration options for callbacks.
|
|
53
78
|
*/
|
|
54
79
|
|
|
55
|
-
|
|
56
|
-
accordionId: string;
|
|
57
|
-
triggersClass: string;
|
|
58
|
-
panelsClass: string;
|
|
59
|
-
allowMultipleOpen?: boolean;
|
|
60
|
-
}
|
|
61
|
-
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
|
|
80
|
+
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
|
|
62
81
|
|
|
63
82
|
/**
|
|
64
83
|
* Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
|
|
@@ -92,11 +111,7 @@ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: Ch
|
|
|
92
111
|
* @param {string} triggerId - The id of the button that triggers the menu.
|
|
93
112
|
*/
|
|
94
113
|
|
|
95
|
-
declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId }:
|
|
96
|
-
menuId: string;
|
|
97
|
-
menuItemsClass: string;
|
|
98
|
-
triggerId: string;
|
|
99
|
-
}): AccessibilityInstance;
|
|
114
|
+
declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId, callback }: MenuConfig): AccessibilityInstance;
|
|
100
115
|
|
|
101
116
|
/**
|
|
102
117
|
* Makes a radio group accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
@@ -134,10 +149,10 @@ declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }
|
|
|
134
149
|
* @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
|
|
135
150
|
* @param {string} listBoxId - The id of the listbox element.
|
|
136
151
|
* @param {string} listBoxItemsClass - The class of the items within the listbox.
|
|
137
|
-
* @param {
|
|
152
|
+
* @param {ComboboxCallback} callback - Configuration options for callbacks.
|
|
138
153
|
*/
|
|
139
154
|
|
|
140
|
-
declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass,
|
|
155
|
+
declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
|
|
141
156
|
|
|
142
157
|
/**
|
|
143
158
|
* Runs static and interactions accessibility test on UI components.
|