aria-ease 4.0.1 → 5.0.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/README.md +22 -24
- package/dist/index.cjs +12 -144
- package/dist/index.d.cts +1 -57
- package/dist/index.d.ts +1 -57
- package/dist/index.js +11 -139
- package/dist/src/{Types.d-BrHSyS03.d.cts → Types.d-COr5IFp5.d.cts} +1 -17
- package/dist/src/{Types.d-BrHSyS03.d.ts → Types.d-COr5IFp5.d.ts} +1 -17
- package/dist/src/accordion/index.cjs +0 -27
- package/dist/src/accordion/index.d.cts +2 -12
- package/dist/src/accordion/index.d.ts +2 -12
- package/dist/src/accordion/index.js +1 -27
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/checkbox/index.cjs +0 -32
- package/dist/src/checkbox/index.d.cts +2 -12
- package/dist/src/checkbox/index.d.ts +2 -12
- package/dist/src/checkbox/index.js +1 -32
- package/dist/src/combobox/index.cjs +1 -1
- package/dist/src/combobox/index.d.cts +1 -1
- package/dist/src/combobox/index.d.ts +1 -1
- package/dist/src/combobox/index.js +1 -1
- package/dist/src/menu/index.cjs +9 -18
- package/dist/src/menu/index.d.cts +1 -1
- package/dist/src/menu/index.d.ts +1 -1
- package/dist/src/menu/index.js +9 -18
- package/dist/src/radio/index.cjs +0 -31
- package/dist/src/radio/index.d.cts +2 -12
- package/dist/src/radio/index.d.ts +2 -12
- package/dist/src/radio/index.js +1 -31
- package/dist/src/toggle/index.cjs +0 -28
- package/dist/src/toggle/index.d.cts +2 -12
- package/dist/src/toggle/index.d.ts +2 -12
- package/dist/src/toggle/index.js +1 -28
- package/dist/src/utils/test/contracts/AccordionContract.json +55 -0
- package/dist/src/utils/test/contracts/MenuContract.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9182,32 +9182,6 @@ var require_lz_string = __commonJS({
|
|
|
9182
9182
|
}
|
|
9183
9183
|
});
|
|
9184
9184
|
|
|
9185
|
-
// src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts
|
|
9186
|
-
function updateAccordionTriggerAriaAttributes(accordionId, accordionTriggersClass, accordionStates, clickedTriggerIndex) {
|
|
9187
|
-
const accordionDiv = document.querySelector(`#${accordionId}`);
|
|
9188
|
-
if (!accordionDiv) {
|
|
9189
|
-
console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion element exists before calling updateAccordionTriggerAriaAttributes.`);
|
|
9190
|
-
return;
|
|
9191
|
-
}
|
|
9192
|
-
const accordionItems = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));
|
|
9193
|
-
if (accordionItems.length === 0) {
|
|
9194
|
-
console.error(`[aria-ease] Element with class="${accordionTriggersClass}" not found. Make sure the accordion items exist before calling updateAccordionTriggerAriaAttributes.`);
|
|
9195
|
-
return;
|
|
9196
|
-
}
|
|
9197
|
-
if (accordionItems.length !== accordionStates.length) {
|
|
9198
|
-
console.error(`[aria-ease] Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.'`);
|
|
9199
|
-
return;
|
|
9200
|
-
}
|
|
9201
|
-
accordionItems.forEach((accordionItem, index) => {
|
|
9202
|
-
const state = accordionStates[index];
|
|
9203
|
-
const expanded = accordionItem.getAttribute("aria-expanded");
|
|
9204
|
-
const shouldBeExpanded = index === clickedTriggerIndex ? state.display ? "true" : "false" : "false";
|
|
9205
|
-
if (expanded && expanded !== shouldBeExpanded) {
|
|
9206
|
-
accordionItem.setAttribute("aria-expanded", shouldBeExpanded);
|
|
9207
|
-
}
|
|
9208
|
-
});
|
|
9209
|
-
}
|
|
9210
|
-
|
|
9211
9185
|
// src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
|
|
9212
9186
|
function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultiple = false }) {
|
|
9213
9187
|
const accordionContainer = document.querySelector(`#${accordionId}`);
|
|
@@ -9536,38 +9510,6 @@ function makeBlockAccessible({ blockId, blockItemsClass }) {
|
|
|
9536
9510
|
return { cleanup, refresh };
|
|
9537
9511
|
}
|
|
9538
9512
|
|
|
9539
|
-
// src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts
|
|
9540
|
-
function updateCheckboxAriaAttributes(checkboxId, checkboxesClass, checkboxStates, currentPressedCheckboxIndex) {
|
|
9541
|
-
const checkboxDiv = document.querySelector(`#${checkboxId}`);
|
|
9542
|
-
if (!checkboxDiv) {
|
|
9543
|
-
console.error(`[aria-ease] Invalid checkbox main div id provided. No checkbox div with id '${checkboxDiv} found.'`);
|
|
9544
|
-
return;
|
|
9545
|
-
}
|
|
9546
|
-
const checkboxItems = Array.from(document.querySelectorAll(`.${checkboxesClass}`));
|
|
9547
|
-
if (checkboxItems.length === 0) {
|
|
9548
|
-
console.error(`[aria-ease] Element with class="${checkboxesClass}" not found. Make sure the checkbox items exist before calling updateCheckboxAriaAttributes.`);
|
|
9549
|
-
return;
|
|
9550
|
-
}
|
|
9551
|
-
;
|
|
9552
|
-
if (checkboxStates.length === 0) {
|
|
9553
|
-
console.error(`[aria-ease] Checkbox states array is empty. Make sure the checkboxStates array is populated before calling updateCheckboxAriaAttributes.`);
|
|
9554
|
-
return;
|
|
9555
|
-
}
|
|
9556
|
-
if (currentPressedCheckboxIndex < 0 || currentPressedCheckboxIndex >= checkboxStates.length) {
|
|
9557
|
-
console.error(`[aria-ease] Checkbox index ${currentPressedCheckboxIndex} is out of bounds for states array of length ${checkboxStates.length}.`);
|
|
9558
|
-
return;
|
|
9559
|
-
}
|
|
9560
|
-
checkboxItems.forEach((checkbox, index) => {
|
|
9561
|
-
if (index === currentPressedCheckboxIndex) {
|
|
9562
|
-
const checked = checkbox.getAttribute("aria-checked");
|
|
9563
|
-
const shouldBeChecked = checkboxStates[index].checked ? "true" : "false";
|
|
9564
|
-
if (checked && checked !== shouldBeChecked) {
|
|
9565
|
-
checkbox.setAttribute("aria-checked", shouldBeChecked);
|
|
9566
|
-
}
|
|
9567
|
-
}
|
|
9568
|
-
});
|
|
9569
|
-
}
|
|
9570
|
-
|
|
9571
9513
|
// src/checkbox/src/makeCheckboxAccessible/makeCheckboxAccessible.ts
|
|
9572
9514
|
function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
9573
9515
|
const checkboxGroup = document.querySelector(`#${checkboxGroupId}`);
|
|
@@ -9841,8 +9783,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
9841
9783
|
});
|
|
9842
9784
|
}
|
|
9843
9785
|
function openMenu() {
|
|
9844
|
-
menuDiv.style.display = "block";
|
|
9845
9786
|
setAria(true);
|
|
9787
|
+
menuDiv.style.display = "block";
|
|
9846
9788
|
const items = getFilteredItems();
|
|
9847
9789
|
addListeners();
|
|
9848
9790
|
if (items && items.length > 0) {
|
|
@@ -9850,9 +9792,9 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
9850
9792
|
}
|
|
9851
9793
|
}
|
|
9852
9794
|
function closeMenu() {
|
|
9853
|
-
removeListeners();
|
|
9854
|
-
menuDiv.style.display = "none";
|
|
9855
9795
|
setAria(false);
|
|
9796
|
+
menuDiv.style.display = "none";
|
|
9797
|
+
removeListeners();
|
|
9856
9798
|
triggerButton.focus();
|
|
9857
9799
|
}
|
|
9858
9800
|
function intializeMenuItems() {
|
|
@@ -9862,19 +9804,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
9862
9804
|
});
|
|
9863
9805
|
}
|
|
9864
9806
|
intializeMenuItems();
|
|
9865
|
-
function handleTriggerKeydown(event) {
|
|
9866
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
9867
|
-
event.preventDefault();
|
|
9868
|
-
const isOpen = menuDiv.style.display !== "none";
|
|
9869
|
-
if (isOpen) {
|
|
9870
|
-
closeMenu();
|
|
9871
|
-
} else {
|
|
9872
|
-
openMenu();
|
|
9873
|
-
}
|
|
9874
|
-
}
|
|
9875
|
-
}
|
|
9876
9807
|
function handleTriggerClick() {
|
|
9877
|
-
const isOpen =
|
|
9808
|
+
const isOpen = triggerButton.getAttribute("aria-expanded") === "true";
|
|
9878
9809
|
if (isOpen) {
|
|
9879
9810
|
closeMenu();
|
|
9880
9811
|
} else {
|
|
@@ -9882,17 +9813,19 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
9882
9813
|
}
|
|
9883
9814
|
}
|
|
9884
9815
|
function handleClickOutside(event) {
|
|
9885
|
-
|
|
9816
|
+
const isMenuOpen = triggerButton.getAttribute("aria-expanded") === "true";
|
|
9817
|
+
if (!isMenuOpen) return;
|
|
9818
|
+
const clickedTrigger = triggerButton.contains(event.target);
|
|
9819
|
+
const clickedMenu = menuDiv.contains(event.target);
|
|
9820
|
+
if (!clickedTrigger && !clickedMenu) {
|
|
9886
9821
|
closeMenu();
|
|
9887
9822
|
}
|
|
9888
9823
|
}
|
|
9889
|
-
triggerButton.addEventListener("keydown", handleTriggerKeydown);
|
|
9890
9824
|
triggerButton.addEventListener("click", handleTriggerClick);
|
|
9891
9825
|
document.addEventListener("click", handleClickOutside);
|
|
9892
9826
|
triggerButton.setAttribute("data-menu-initialized", "true");
|
|
9893
9827
|
function cleanup() {
|
|
9894
9828
|
removeListeners();
|
|
9895
|
-
triggerButton.removeEventListener("keydown", handleTriggerKeydown);
|
|
9896
9829
|
triggerButton.removeEventListener("click", handleTriggerClick);
|
|
9897
9830
|
document.removeEventListener("click", handleClickOutside);
|
|
9898
9831
|
menuDiv.style.display = "none";
|
|
@@ -9907,36 +9840,6 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
9907
9840
|
return { openMenu, closeMenu, cleanup, refresh };
|
|
9908
9841
|
}
|
|
9909
9842
|
|
|
9910
|
-
// src/radio/src/updateRadioAriaAttributes/updateRadioAriaAttributes.ts
|
|
9911
|
-
function updateRadioAriaAttributes(radioId, radiosClass, radioStates, currentPressedRadioIndex) {
|
|
9912
|
-
const radioDiv = document.querySelector(`#${radioId}`);
|
|
9913
|
-
if (!radioDiv) {
|
|
9914
|
-
console.error(`[aria-ease] Element with id="${radioId}" not found. Make sure the radio element exists before calling updateRadioAriaAttributes.`);
|
|
9915
|
-
return;
|
|
9916
|
-
}
|
|
9917
|
-
const radioItems = Array.from(radioDiv.querySelectorAll(`.${radiosClass}`));
|
|
9918
|
-
if (radioItems.length === 0) {
|
|
9919
|
-
console.error(`[aria-ease] Element with class="${radiosClass}" not found. Make sure the radio items exist before calling updateRadioAriaAttributes.`);
|
|
9920
|
-
return;
|
|
9921
|
-
}
|
|
9922
|
-
if (radioStates.length === 0) {
|
|
9923
|
-
console.error(`[aria-ease] Radio states array is empty. Make sure the radioStates array is populated before calling updateRadioAriaAttributes.`);
|
|
9924
|
-
return;
|
|
9925
|
-
}
|
|
9926
|
-
if (currentPressedRadioIndex < 0 || currentPressedRadioIndex >= radioStates.length) {
|
|
9927
|
-
console.error(`[aria-ease] Radio index ${currentPressedRadioIndex} is out of bounds for states array of length ${radioStates.length}.`);
|
|
9928
|
-
return;
|
|
9929
|
-
}
|
|
9930
|
-
radioItems.forEach((radioItem, index) => {
|
|
9931
|
-
const state = radioStates[index];
|
|
9932
|
-
const checked = radioItem.getAttribute("aria-checked");
|
|
9933
|
-
const shouldBeChecked = index === currentPressedRadioIndex ? state.checked ? "true" : "false" : "false";
|
|
9934
|
-
if (checked && checked !== shouldBeChecked) {
|
|
9935
|
-
radioItem.setAttribute("aria-checked", shouldBeChecked);
|
|
9936
|
-
}
|
|
9937
|
-
});
|
|
9938
|
-
}
|
|
9939
|
-
|
|
9940
9843
|
// src/radio/src/makeRadioAccessible/makeRadioAccessible.ts
|
|
9941
9844
|
function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex = 0 }) {
|
|
9942
9845
|
const radioGroup = document.querySelector(`#${radioGroupId}`);
|
|
@@ -10058,33 +9961,6 @@ function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex =
|
|
|
10058
9961
|
};
|
|
10059
9962
|
}
|
|
10060
9963
|
|
|
10061
|
-
// src/toggle/src/updateToggleAriaAttribute/updateToggleAriaAttribute.ts
|
|
10062
|
-
function updateToggleAriaAttribute(toggleId, togglesClass, toggleStates, currentPressedToggleIndex) {
|
|
10063
|
-
const toggleDiv = document.querySelector(`#${toggleId}`);
|
|
10064
|
-
if (!toggleDiv) {
|
|
10065
|
-
console.error(`[aria-ease] Element with id="${toggleId}" not found. Make sure the toggle element exists before calling updateToggleAriaAttribute.`);
|
|
10066
|
-
return;
|
|
10067
|
-
}
|
|
10068
|
-
const toggleItems = Array.from(toggleDiv.querySelectorAll(`.${togglesClass}`));
|
|
10069
|
-
if (toggleItems.length === 0) {
|
|
10070
|
-
console.error(`[aria-ease] Element with class="${togglesClass}" not found. Make sure the toggle items exist before calling updateToggleAriaAttribute.`);
|
|
10071
|
-
return;
|
|
10072
|
-
}
|
|
10073
|
-
if (toggleItems.length !== toggleStates.length) {
|
|
10074
|
-
console.error(`[aria-ease] Toggle state/DOM length mismatch: found ${toggleItems.length} triggers, but got ${toggleStates.length} state objects.'`);
|
|
10075
|
-
return;
|
|
10076
|
-
}
|
|
10077
|
-
toggleItems.forEach((toggle, index) => {
|
|
10078
|
-
if (index === currentPressedToggleIndex) {
|
|
10079
|
-
const pressed = toggle.getAttribute("aria-pressed");
|
|
10080
|
-
const shouldBePressed = toggleStates[index].pressed ? "true" : "false";
|
|
10081
|
-
if (pressed && pressed !== shouldBePressed) {
|
|
10082
|
-
toggle.setAttribute("aria-pressed", shouldBePressed);
|
|
10083
|
-
}
|
|
10084
|
-
}
|
|
10085
|
-
});
|
|
10086
|
-
}
|
|
10087
|
-
|
|
10088
9964
|
// src/toggle/src/makeTogggleAccessible/makeToggleAccessible.ts
|
|
10089
9965
|
function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle = true }) {
|
|
10090
9966
|
const toggleContainer = document.querySelector(`#${toggleId}`);
|
|
@@ -10229,7 +10105,7 @@ function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle = true })
|
|
|
10229
10105
|
};
|
|
10230
10106
|
}
|
|
10231
10107
|
|
|
10232
|
-
// src/combobox/src/makeComboBoxAccessible.ts
|
|
10108
|
+
// src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
|
|
10233
10109
|
function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config: config2 }) {
|
|
10234
10110
|
const comboboxInput = document.getElementById(`${comboboxInputId}`);
|
|
10235
10111
|
if (!comboboxInput) {
|
|
@@ -14144,11 +14020,7 @@ export {
|
|
|
14144
14020
|
makeMenuAccessible,
|
|
14145
14021
|
makeRadioAccessible,
|
|
14146
14022
|
makeToggleAccessible,
|
|
14147
|
-
testUiComponent
|
|
14148
|
-
updateAccordionTriggerAriaAttributes,
|
|
14149
|
-
updateCheckboxAriaAttributes,
|
|
14150
|
-
updateRadioAriaAttributes,
|
|
14151
|
-
updateToggleAriaAttribute
|
|
14023
|
+
testUiComponent
|
|
14152
14024
|
};
|
|
14153
14025
|
/*! Bundled license information:
|
|
14154
14026
|
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
interface AccordionStates {
|
|
2
|
-
display: boolean;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
interface CheckboxStates {
|
|
6
|
-
checked: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface RadioStates {
|
|
10
|
-
checked: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ToggleStates {
|
|
14
|
-
pressed: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
1
|
interface AccessibilityInstance {
|
|
18
2
|
cleanup: () => void;
|
|
19
3
|
refresh?: () => void;
|
|
@@ -53,4 +37,4 @@ interface config {
|
|
|
53
37
|
onClear?: () => void;
|
|
54
38
|
}
|
|
55
39
|
|
|
56
|
-
export type {
|
|
40
|
+
export type { AccessibilityInstance as A, ComboboxConfig as C };
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
interface AccordionStates {
|
|
2
|
-
display: boolean;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
interface CheckboxStates {
|
|
6
|
-
checked: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface RadioStates {
|
|
10
|
-
checked: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ToggleStates {
|
|
14
|
-
pressed: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
1
|
interface AccessibilityInstance {
|
|
18
2
|
cleanup: () => void;
|
|
19
3
|
refresh?: () => void;
|
|
@@ -53,4 +37,4 @@ interface config {
|
|
|
53
37
|
onClear?: () => void;
|
|
54
38
|
}
|
|
55
39
|
|
|
56
|
-
export type {
|
|
40
|
+
export type { AccessibilityInstance as A, ComboboxConfig as C };
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts
|
|
4
|
-
function updateAccordionTriggerAriaAttributes(accordionId, accordionTriggersClass, accordionStates, clickedTriggerIndex) {
|
|
5
|
-
const accordionDiv = document.querySelector(`#${accordionId}`);
|
|
6
|
-
if (!accordionDiv) {
|
|
7
|
-
console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion element exists before calling updateAccordionTriggerAriaAttributes.`);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const accordionItems = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));
|
|
11
|
-
if (accordionItems.length === 0) {
|
|
12
|
-
console.error(`[aria-ease] Element with class="${accordionTriggersClass}" not found. Make sure the accordion items exist before calling updateAccordionTriggerAriaAttributes.`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (accordionItems.length !== accordionStates.length) {
|
|
16
|
-
console.error(`[aria-ease] Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.'`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
accordionItems.forEach((accordionItem, index) => {
|
|
20
|
-
const state = accordionStates[index];
|
|
21
|
-
const expanded = accordionItem.getAttribute("aria-expanded");
|
|
22
|
-
const shouldBeExpanded = index === clickedTriggerIndex ? state.display ? "true" : "false" : "false";
|
|
23
|
-
if (expanded && expanded !== shouldBeExpanded) {
|
|
24
|
-
accordionItem.setAttribute("aria-expanded", shouldBeExpanded);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
3
|
// src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
|
|
30
4
|
function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultiple = false }) {
|
|
31
5
|
const accordionContainer = document.querySelector(`#${accordionId}`);
|
|
@@ -185,4 +159,3 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
|
|
|
185
159
|
}
|
|
186
160
|
|
|
187
161
|
exports.makeAccordionAccessible = makeAccordionAccessible;
|
|
188
|
-
exports.updateAccordionTriggerAriaAttributes = updateAccordionTriggerAriaAttributes;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds screen reader accessibility to accordions. Updates the aria attributes of the accordion trigger button. Trigger button element must possess the following aria attributes; aria-expanded, aria-controls, aria-label (for only non-text triggers).
|
|
5
|
-
* @param {string} accordionId The id of the accordion triggers parent container.
|
|
6
|
-
* @param {string} accordionTriggersClass The shared class of all the accordion triggers.
|
|
7
|
-
* @param {AccordionStates[]} accordionStates Array of objects containing accordions state information.
|
|
8
|
-
* @param {number} clickedTriggerIndex Index of the currently clicked accordion trigger within the accordion div container.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare function updateAccordionTriggerAriaAttributes(accordionId: string, accordionTriggersClass: string, accordionStates: AccordionStates[], clickedTriggerIndex: number): void;
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
|
|
12
2
|
|
|
13
3
|
/**
|
|
14
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
@@ -27,4 +17,4 @@ interface AccordionConfig {
|
|
|
27
17
|
}
|
|
28
18
|
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultiple }: AccordionConfig): AccessibilityInstance;
|
|
29
19
|
|
|
30
|
-
export { makeAccordionAccessible
|
|
20
|
+
export { makeAccordionAccessible };
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds screen reader accessibility to accordions. Updates the aria attributes of the accordion trigger button. Trigger button element must possess the following aria attributes; aria-expanded, aria-controls, aria-label (for only non-text triggers).
|
|
5
|
-
* @param {string} accordionId The id of the accordion triggers parent container.
|
|
6
|
-
* @param {string} accordionTriggersClass The shared class of all the accordion triggers.
|
|
7
|
-
* @param {AccordionStates[]} accordionStates Array of objects containing accordions state information.
|
|
8
|
-
* @param {number} clickedTriggerIndex Index of the currently clicked accordion trigger within the accordion div container.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare function updateAccordionTriggerAriaAttributes(accordionId: string, accordionTriggersClass: string, accordionStates: AccordionStates[], clickedTriggerIndex: number): void;
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
|
|
12
2
|
|
|
13
3
|
/**
|
|
14
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
|
|
@@ -27,4 +17,4 @@ interface AccordionConfig {
|
|
|
27
17
|
}
|
|
28
18
|
declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultiple }: AccordionConfig): AccessibilityInstance;
|
|
29
19
|
|
|
30
|
-
export { makeAccordionAccessible
|
|
20
|
+
export { makeAccordionAccessible };
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
// src/accordion/src/updateAccordionTriggerAriaAttributes/updateAccordionTriggerAriaAttributes.ts
|
|
2
|
-
function updateAccordionTriggerAriaAttributes(accordionId, accordionTriggersClass, accordionStates, clickedTriggerIndex) {
|
|
3
|
-
const accordionDiv = document.querySelector(`#${accordionId}`);
|
|
4
|
-
if (!accordionDiv) {
|
|
5
|
-
console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion element exists before calling updateAccordionTriggerAriaAttributes.`);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const accordionItems = Array.from(accordionDiv.querySelectorAll(`.${accordionTriggersClass}`));
|
|
9
|
-
if (accordionItems.length === 0) {
|
|
10
|
-
console.error(`[aria-ease] Element with class="${accordionTriggersClass}" not found. Make sure the accordion items exist before calling updateAccordionTriggerAriaAttributes.`);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (accordionItems.length !== accordionStates.length) {
|
|
14
|
-
console.error(`[aria-ease] Accordion state/DOM length mismatch: found ${accordionItems.length} triggers, but got ${accordionStates.length} state objects.'`);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
accordionItems.forEach((accordionItem, index) => {
|
|
18
|
-
const state = accordionStates[index];
|
|
19
|
-
const expanded = accordionItem.getAttribute("aria-expanded");
|
|
20
|
-
const shouldBeExpanded = index === clickedTriggerIndex ? state.display ? "true" : "false" : "false";
|
|
21
|
-
if (expanded && expanded !== shouldBeExpanded) {
|
|
22
|
-
accordionItem.setAttribute("aria-expanded", shouldBeExpanded);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
1
|
// src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
|
|
28
2
|
function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultiple = false }) {
|
|
29
3
|
const accordionContainer = document.querySelector(`#${accordionId}`);
|
|
@@ -182,4 +156,4 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
|
|
|
182
156
|
};
|
|
183
157
|
}
|
|
184
158
|
|
|
185
|
-
export { makeAccordionAccessible
|
|
159
|
+
export { makeAccordionAccessible };
|
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts
|
|
4
|
-
function updateCheckboxAriaAttributes(checkboxId, checkboxesClass, checkboxStates, currentPressedCheckboxIndex) {
|
|
5
|
-
const checkboxDiv = document.querySelector(`#${checkboxId}`);
|
|
6
|
-
if (!checkboxDiv) {
|
|
7
|
-
console.error(`[aria-ease] Invalid checkbox main div id provided. No checkbox div with id '${checkboxDiv} found.'`);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const checkboxItems = Array.from(document.querySelectorAll(`.${checkboxesClass}`));
|
|
11
|
-
if (checkboxItems.length === 0) {
|
|
12
|
-
console.error(`[aria-ease] Element with class="${checkboxesClass}" not found. Make sure the checkbox items exist before calling updateCheckboxAriaAttributes.`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (checkboxStates.length === 0) {
|
|
16
|
-
console.error(`[aria-ease] Checkbox states array is empty. Make sure the checkboxStates array is populated before calling updateCheckboxAriaAttributes.`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (currentPressedCheckboxIndex < 0 || currentPressedCheckboxIndex >= checkboxStates.length) {
|
|
20
|
-
console.error(`[aria-ease] Checkbox index ${currentPressedCheckboxIndex} is out of bounds for states array of length ${checkboxStates.length}.`);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
checkboxItems.forEach((checkbox, index) => {
|
|
24
|
-
if (index === currentPressedCheckboxIndex) {
|
|
25
|
-
const checked = checkbox.getAttribute("aria-checked");
|
|
26
|
-
const shouldBeChecked = checkboxStates[index].checked ? "true" : "false";
|
|
27
|
-
if (checked && checked !== shouldBeChecked) {
|
|
28
|
-
checkbox.setAttribute("aria-checked", shouldBeChecked);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
3
|
// src/checkbox/src/makeCheckboxAccessible/makeCheckboxAccessible.ts
|
|
35
4
|
function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
36
5
|
const checkboxGroup = document.querySelector(`#${checkboxGroupId}`);
|
|
@@ -160,4 +129,3 @@ function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
|
160
129
|
}
|
|
161
130
|
|
|
162
131
|
exports.makeCheckboxAccessible = makeCheckboxAccessible;
|
|
163
|
-
exports.updateCheckboxAriaAttributes = updateCheckboxAriaAttributes;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds screen reader accessibility to multiple checkboxes. Updates the aria attributes of the checkboxes. Checkbox elements must possess the following aria attributes; aria-checked and aria-label.
|
|
5
|
-
* @param {string} checkboxId The id of the checkbox parent container.
|
|
6
|
-
* @param {string} checkboxesClass The shared class of all the checkboxes.
|
|
7
|
-
* @param {CheckboxStates[]} checkboxStates Array of objects containing checkboxes state information.
|
|
8
|
-
* @param {number} currentPressedCheckboxIndex Index of the currently checked or unchecked checkbox.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare function updateCheckboxAriaAttributes(checkboxId: string, checkboxesClass: string, checkboxStates: CheckboxStates[], currentPressedCheckboxIndex: number): void;
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
|
|
12
2
|
|
|
13
3
|
/**
|
|
14
4
|
* Makes a checkbox group accessible by managing ARIA attributes and keyboard navigation.
|
|
@@ -23,4 +13,4 @@ interface CheckboxConfig {
|
|
|
23
13
|
}
|
|
24
14
|
declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
|
|
25
15
|
|
|
26
|
-
export { makeCheckboxAccessible
|
|
16
|
+
export { makeCheckboxAccessible };
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds screen reader accessibility to multiple checkboxes. Updates the aria attributes of the checkboxes. Checkbox elements must possess the following aria attributes; aria-checked and aria-label.
|
|
5
|
-
* @param {string} checkboxId The id of the checkbox parent container.
|
|
6
|
-
* @param {string} checkboxesClass The shared class of all the checkboxes.
|
|
7
|
-
* @param {CheckboxStates[]} checkboxStates Array of objects containing checkboxes state information.
|
|
8
|
-
* @param {number} currentPressedCheckboxIndex Index of the currently checked or unchecked checkbox.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare function updateCheckboxAriaAttributes(checkboxId: string, checkboxesClass: string, checkboxStates: CheckboxStates[], currentPressedCheckboxIndex: number): void;
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
|
|
12
2
|
|
|
13
3
|
/**
|
|
14
4
|
* Makes a checkbox group accessible by managing ARIA attributes and keyboard navigation.
|
|
@@ -23,4 +13,4 @@ interface CheckboxConfig {
|
|
|
23
13
|
}
|
|
24
14
|
declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
|
|
25
15
|
|
|
26
|
-
export { makeCheckboxAccessible
|
|
16
|
+
export { makeCheckboxAccessible };
|
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
// src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts
|
|
2
|
-
function updateCheckboxAriaAttributes(checkboxId, checkboxesClass, checkboxStates, currentPressedCheckboxIndex) {
|
|
3
|
-
const checkboxDiv = document.querySelector(`#${checkboxId}`);
|
|
4
|
-
if (!checkboxDiv) {
|
|
5
|
-
console.error(`[aria-ease] Invalid checkbox main div id provided. No checkbox div with id '${checkboxDiv} found.'`);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const checkboxItems = Array.from(document.querySelectorAll(`.${checkboxesClass}`));
|
|
9
|
-
if (checkboxItems.length === 0) {
|
|
10
|
-
console.error(`[aria-ease] Element with class="${checkboxesClass}" not found. Make sure the checkbox items exist before calling updateCheckboxAriaAttributes.`);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (checkboxStates.length === 0) {
|
|
14
|
-
console.error(`[aria-ease] Checkbox states array is empty. Make sure the checkboxStates array is populated before calling updateCheckboxAriaAttributes.`);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (currentPressedCheckboxIndex < 0 || currentPressedCheckboxIndex >= checkboxStates.length) {
|
|
18
|
-
console.error(`[aria-ease] Checkbox index ${currentPressedCheckboxIndex} is out of bounds for states array of length ${checkboxStates.length}.`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
checkboxItems.forEach((checkbox, index) => {
|
|
22
|
-
if (index === currentPressedCheckboxIndex) {
|
|
23
|
-
const checked = checkbox.getAttribute("aria-checked");
|
|
24
|
-
const shouldBeChecked = checkboxStates[index].checked ? "true" : "false";
|
|
25
|
-
if (checked && checked !== shouldBeChecked) {
|
|
26
|
-
checkbox.setAttribute("aria-checked", shouldBeChecked);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
1
|
// src/checkbox/src/makeCheckboxAccessible/makeCheckboxAccessible.ts
|
|
33
2
|
function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
34
3
|
const checkboxGroup = document.querySelector(`#${checkboxGroupId}`);
|
|
@@ -157,4 +126,4 @@ function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }) {
|
|
|
157
126
|
};
|
|
158
127
|
}
|
|
159
128
|
|
|
160
|
-
export { makeCheckboxAccessible
|
|
129
|
+
export { makeCheckboxAccessible };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/combobox/src/makeComboBoxAccessible.ts
|
|
3
|
+
// src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
|
|
4
4
|
function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
|
|
5
5
|
const comboboxInput = document.getElementById(`${comboboxInputId}`);
|
|
6
6
|
if (!comboboxInput) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/combobox/src/makeComboBoxAccessible.ts
|
|
1
|
+
// src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
|
|
2
2
|
function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
|
|
3
3
|
const comboboxInput = document.getElementById(`${comboboxInputId}`);
|
|
4
4
|
if (!comboboxInput) {
|
package/dist/src/menu/index.cjs
CHANGED
|
@@ -265,8 +265,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
function openMenu() {
|
|
268
|
-
menuDiv.style.display = "block";
|
|
269
268
|
setAria(true);
|
|
269
|
+
menuDiv.style.display = "block";
|
|
270
270
|
const items = getFilteredItems();
|
|
271
271
|
addListeners();
|
|
272
272
|
if (items && items.length > 0) {
|
|
@@ -274,9 +274,9 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
function closeMenu() {
|
|
277
|
-
removeListeners();
|
|
278
|
-
menuDiv.style.display = "none";
|
|
279
277
|
setAria(false);
|
|
278
|
+
menuDiv.style.display = "none";
|
|
279
|
+
removeListeners();
|
|
280
280
|
triggerButton.focus();
|
|
281
281
|
}
|
|
282
282
|
function intializeMenuItems() {
|
|
@@ -286,19 +286,8 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
intializeMenuItems();
|
|
289
|
-
function handleTriggerKeydown(event) {
|
|
290
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
291
|
-
event.preventDefault();
|
|
292
|
-
const isOpen = menuDiv.style.display !== "none";
|
|
293
|
-
if (isOpen) {
|
|
294
|
-
closeMenu();
|
|
295
|
-
} else {
|
|
296
|
-
openMenu();
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
289
|
function handleTriggerClick() {
|
|
301
|
-
const isOpen =
|
|
290
|
+
const isOpen = triggerButton.getAttribute("aria-expanded") === "true";
|
|
302
291
|
if (isOpen) {
|
|
303
292
|
closeMenu();
|
|
304
293
|
} else {
|
|
@@ -306,17 +295,19 @@ function makeMenuAccessible({ menuId, menuItemsClass, triggerId }) {
|
|
|
306
295
|
}
|
|
307
296
|
}
|
|
308
297
|
function handleClickOutside(event) {
|
|
309
|
-
|
|
298
|
+
const isMenuOpen = triggerButton.getAttribute("aria-expanded") === "true";
|
|
299
|
+
if (!isMenuOpen) return;
|
|
300
|
+
const clickedTrigger = triggerButton.contains(event.target);
|
|
301
|
+
const clickedMenu = menuDiv.contains(event.target);
|
|
302
|
+
if (!clickedTrigger && !clickedMenu) {
|
|
310
303
|
closeMenu();
|
|
311
304
|
}
|
|
312
305
|
}
|
|
313
|
-
triggerButton.addEventListener("keydown", handleTriggerKeydown);
|
|
314
306
|
triggerButton.addEventListener("click", handleTriggerClick);
|
|
315
307
|
document.addEventListener("click", handleClickOutside);
|
|
316
308
|
triggerButton.setAttribute("data-menu-initialized", "true");
|
|
317
309
|
function cleanup() {
|
|
318
310
|
removeListeners();
|
|
319
|
-
triggerButton.removeEventListener("keydown", handleTriggerKeydown);
|
|
320
311
|
triggerButton.removeEventListener("click", handleTriggerClick);
|
|
321
312
|
document.removeEventListener("click", handleClickOutside);
|
|
322
313
|
menuDiv.style.display = "none";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.
|
package/dist/src/menu/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.
|