aria-ease 6.0.1 → 6.1.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 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,9 @@ 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
+ callback.onExpand(index);
888
+ }
886
889
  }
887
890
  function collapseItem(index) {
888
891
  if (index < 0 || index >= triggers.length) {
@@ -893,6 +896,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
893
896
  const panel = panels[index];
894
897
  trigger.setAttribute("aria-expanded", "false");
895
898
  panel.style.display = "none";
899
+ if (callback?.onCollapse) {
900
+ callback.onCollapse(index);
901
+ }
896
902
  }
897
903
  function toggleItem(index) {
898
904
  const trigger = triggers[index];
@@ -1755,7 +1761,7 @@ function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle = true })
1755
1761
  }
1756
1762
 
1757
1763
  // src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
1758
- function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
1764
+ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }) {
1759
1765
  const comboboxInput = document.getElementById(`${comboboxInputId}`);
1760
1766
  if (!comboboxInput) {
1761
1767
  console.error(`[aria-ease] Element with id="${comboboxInputId}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`);
@@ -1802,9 +1808,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1802
1808
  if (typeof activeItem.scrollIntoView === "function") {
1803
1809
  activeItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
1804
1810
  }
1805
- if (config?.onActiveDescendantChange) {
1811
+ if (callback?.onActiveDescendantChange) {
1806
1812
  try {
1807
- config.onActiveDescendantChange(itemId, activeItem);
1813
+ callback.onActiveDescendantChange(itemId, activeItem);
1808
1814
  } catch (error) {
1809
1815
  console.error("[aria-ease] Error in onActiveDescendantChange callback:", error);
1810
1816
  }
@@ -1816,9 +1822,10 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1816
1822
  }
1817
1823
  function openListbox() {
1818
1824
  comboboxInput.setAttribute("aria-expanded", "true");
1819
- if (config?.onOpenChange) {
1825
+ listBox.style.display = "block";
1826
+ if (callback?.onOpenChange) {
1820
1827
  try {
1821
- config.onOpenChange(true);
1828
+ callback.onOpenChange(true);
1822
1829
  } catch (error) {
1823
1830
  console.error("[aria-ease] Error in onOpenChange callback:", error);
1824
1831
  }
@@ -1827,12 +1834,13 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1827
1834
  function closeListbox() {
1828
1835
  comboboxInput.setAttribute("aria-expanded", "false");
1829
1836
  comboboxInput.setAttribute("aria-activedescendant", "");
1837
+ listBox.style.display = "none";
1830
1838
  activeIndex = -1;
1831
1839
  const visibleItems = getVisibleItems();
1832
1840
  visibleItems.forEach((item) => item.setAttribute("aria-selected", "false"));
1833
- if (config?.onOpenChange) {
1841
+ if (callback?.onOpenChange) {
1834
1842
  try {
1835
- config.onOpenChange(false);
1843
+ callback.onOpenChange(false);
1836
1844
  } catch (error) {
1837
1845
  console.error("[aria-ease] Error in onOpenChange callback:", error);
1838
1846
  }
@@ -1842,9 +1850,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1842
1850
  const value = item.textContent?.trim() || "";
1843
1851
  comboboxInput.value = value;
1844
1852
  closeListbox();
1845
- if (config?.onSelect) {
1853
+ if (callback?.onSelect) {
1846
1854
  try {
1847
- config.onSelect(item, value);
1855
+ callback.onSelect(item);
1848
1856
  } catch (error) {
1849
1857
  console.error("[aria-ease] Error in onSelect callback:", error);
1850
1858
  }
@@ -1887,9 +1895,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1887
1895
  } else if (comboboxInput.value) {
1888
1896
  event.preventDefault();
1889
1897
  comboboxInput.value = "";
1890
- if (config?.onClear) {
1898
+ if (callback?.onClear) {
1891
1899
  try {
1892
- config.onClear();
1900
+ callback.onClear();
1893
1901
  } catch (error) {
1894
1902
  console.error("[aria-ease] Error in onClear callback:", error);
1895
1903
  }
package/dist/index.d.cts CHANGED
@@ -28,16 +28,29 @@ 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
- config?: config;
49
+ callback?: ComboboxCallback;
37
50
  }
38
51
 
39
- interface config {
40
- onSelect?: (item: HTMLElement, value: string) => void;
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;
@@ -50,15 +63,10 @@ interface config {
50
63
  * @param {string} triggersClass - The shared class of all accordion trigger buttons.
51
64
  * @param {string} panelsClass - The shared class of all accordion panels.
52
65
  * @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
66
+ * @param {AccordionCallback} callback - Configuration options for callbacks.
53
67
  */
54
68
 
55
- interface AccordionConfig {
56
- accordionId: string;
57
- triggersClass: string;
58
- panelsClass: string;
59
- allowMultipleOpen?: boolean;
60
- }
61
- declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
69
+ declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
62
70
 
63
71
  /**
64
72
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -134,10 +142,10 @@ declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }
134
142
  * @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
135
143
  * @param {string} listBoxId - The id of the listbox element.
136
144
  * @param {string} listBoxItemsClass - The class of the items within the listbox.
137
- * @param {ComboboxConfig} config - Configuration options for callbacks.
145
+ * @param {ComboboxCallback} callback - Configuration options for callbacks.
138
146
  */
139
147
 
140
- declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }: ComboboxConfig): AccessibilityInstance;
148
+ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
141
149
 
142
150
  /**
143
151
  * Runs static and interactions accessibility test on UI components.
package/dist/index.d.ts CHANGED
@@ -28,16 +28,29 @@ 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
- config?: config;
49
+ callback?: ComboboxCallback;
37
50
  }
38
51
 
39
- interface config {
40
- onSelect?: (item: HTMLElement, value: string) => void;
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;
@@ -50,15 +63,10 @@ interface config {
50
63
  * @param {string} triggersClass - The shared class of all accordion trigger buttons.
51
64
  * @param {string} panelsClass - The shared class of all accordion panels.
52
65
  * @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
66
+ * @param {AccordionCallback} callback - Configuration options for callbacks.
53
67
  */
54
68
 
55
- interface AccordionConfig {
56
- accordionId: string;
57
- triggersClass: string;
58
- panelsClass: string;
59
- allowMultipleOpen?: boolean;
60
- }
61
- declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
69
+ declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
62
70
 
63
71
  /**
64
72
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -134,10 +142,10 @@ declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }
134
142
  * @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
135
143
  * @param {string} listBoxId - The id of the listbox element.
136
144
  * @param {string} listBoxItemsClass - The class of the items within the listbox.
137
- * @param {ComboboxConfig} config - Configuration options for callbacks.
145
+ * @param {ComboboxCallback} callback - Configuration options for callbacks.
138
146
  */
139
147
 
140
- declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }: ComboboxConfig): AccessibilityInstance;
148
+ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
141
149
 
142
150
  /**
143
151
  * Runs static and interactions accessibility test on UI components.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-PDZQOXUN.js";
6
6
 
7
7
  // src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
8
- function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false }) {
8
+ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false, callback }) {
9
9
  const accordionContainer = document.querySelector(`#${accordionId}`);
10
10
  if (!accordionContainer) {
11
11
  console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`);
@@ -56,6 +56,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
56
56
  const panel = panels[index];
57
57
  trigger.setAttribute("aria-expanded", "true");
58
58
  panel.style.display = "block";
59
+ if (callback?.onExpand) {
60
+ callback.onExpand(index);
61
+ }
59
62
  }
60
63
  function collapseItem(index) {
61
64
  if (index < 0 || index >= triggers.length) {
@@ -66,6 +69,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
66
69
  const panel = panels[index];
67
70
  trigger.setAttribute("aria-expanded", "false");
68
71
  panel.style.display = "none";
72
+ if (callback?.onCollapse) {
73
+ callback.onCollapse(index);
74
+ }
69
75
  }
70
76
  function toggleItem(index) {
71
77
  const trigger = triggers[index];
@@ -928,7 +934,7 @@ function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle = true })
928
934
  }
929
935
 
930
936
  // src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
931
- function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
937
+ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }) {
932
938
  const comboboxInput = document.getElementById(`${comboboxInputId}`);
933
939
  if (!comboboxInput) {
934
940
  console.error(`[aria-ease] Element with id="${comboboxInputId}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`);
@@ -975,9 +981,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
975
981
  if (typeof activeItem.scrollIntoView === "function") {
976
982
  activeItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
977
983
  }
978
- if (config?.onActiveDescendantChange) {
984
+ if (callback?.onActiveDescendantChange) {
979
985
  try {
980
- config.onActiveDescendantChange(itemId, activeItem);
986
+ callback.onActiveDescendantChange(itemId, activeItem);
981
987
  } catch (error) {
982
988
  console.error("[aria-ease] Error in onActiveDescendantChange callback:", error);
983
989
  }
@@ -989,9 +995,10 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
989
995
  }
990
996
  function openListbox() {
991
997
  comboboxInput.setAttribute("aria-expanded", "true");
992
- if (config?.onOpenChange) {
998
+ listBox.style.display = "block";
999
+ if (callback?.onOpenChange) {
993
1000
  try {
994
- config.onOpenChange(true);
1001
+ callback.onOpenChange(true);
995
1002
  } catch (error) {
996
1003
  console.error("[aria-ease] Error in onOpenChange callback:", error);
997
1004
  }
@@ -1000,12 +1007,13 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1000
1007
  function closeListbox() {
1001
1008
  comboboxInput.setAttribute("aria-expanded", "false");
1002
1009
  comboboxInput.setAttribute("aria-activedescendant", "");
1010
+ listBox.style.display = "none";
1003
1011
  activeIndex = -1;
1004
1012
  const visibleItems = getVisibleItems();
1005
1013
  visibleItems.forEach((item) => item.setAttribute("aria-selected", "false"));
1006
- if (config?.onOpenChange) {
1014
+ if (callback?.onOpenChange) {
1007
1015
  try {
1008
- config.onOpenChange(false);
1016
+ callback.onOpenChange(false);
1009
1017
  } catch (error) {
1010
1018
  console.error("[aria-ease] Error in onOpenChange callback:", error);
1011
1019
  }
@@ -1015,9 +1023,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1015
1023
  const value = item.textContent?.trim() || "";
1016
1024
  comboboxInput.value = value;
1017
1025
  closeListbox();
1018
- if (config?.onSelect) {
1026
+ if (callback?.onSelect) {
1019
1027
  try {
1020
- config.onSelect(item, value);
1028
+ callback.onSelect(item);
1021
1029
  } catch (error) {
1022
1030
  console.error("[aria-ease] Error in onSelect callback:", error);
1023
1031
  }
@@ -1060,9 +1068,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
1060
1068
  } else if (comboboxInput.value) {
1061
1069
  event.preventDefault();
1062
1070
  comboboxInput.value = "";
1063
- if (config?.onClear) {
1071
+ if (callback?.onClear) {
1064
1072
  try {
1065
- config.onClear();
1073
+ callback.onClear();
1066
1074
  } catch (error) {
1067
1075
  console.error("[aria-ease] Error in onClear callback:", error);
1068
1076
  }
@@ -22,19 +22,32 @@ interface AccessibilityInstance {
22
22
  getPressedIndices?: () => number[];
23
23
  }
24
24
 
25
+ interface AccordionConfig {
26
+ accordionId: string;
27
+ triggersClass: string;
28
+ panelsClass: string;
29
+ allowMultipleOpen?: boolean;
30
+ callback?: AccordionCallback;
31
+ }
32
+
33
+ interface AccordionCallback {
34
+ onExpand?: (index: number) => void;
35
+ onCollapse?: (index: number) => void;
36
+ }
37
+
25
38
  interface ComboboxConfig {
26
39
  comboboxInputId: string;
27
40
  comboboxButtonId?: string;
28
41
  listBoxId: string;
29
42
  listBoxItemsClass: string;
30
- config?: config;
43
+ callback?: ComboboxCallback;
31
44
  }
32
45
 
33
- interface config {
34
- onSelect?: (item: HTMLElement, value: string) => void;
46
+ interface ComboboxCallback {
47
+ onSelect?: (item: HTMLElement) => void;
35
48
  onOpenChange?: (isOpen: boolean) => void;
36
49
  onActiveDescendantChange?: (optionId: string, item: HTMLElement) => void;
37
50
  onClear?: () => void;
38
51
  }
39
52
 
40
- export type { AccessibilityInstance as A, ComboboxConfig as C };
53
+ export type { AccessibilityInstance as A, ComboboxConfig as C, AccordionConfig as a };
@@ -22,19 +22,32 @@ interface AccessibilityInstance {
22
22
  getPressedIndices?: () => number[];
23
23
  }
24
24
 
25
+ interface AccordionConfig {
26
+ accordionId: string;
27
+ triggersClass: string;
28
+ panelsClass: string;
29
+ allowMultipleOpen?: boolean;
30
+ callback?: AccordionCallback;
31
+ }
32
+
33
+ interface AccordionCallback {
34
+ onExpand?: (index: number) => void;
35
+ onCollapse?: (index: number) => void;
36
+ }
37
+
25
38
  interface ComboboxConfig {
26
39
  comboboxInputId: string;
27
40
  comboboxButtonId?: string;
28
41
  listBoxId: string;
29
42
  listBoxItemsClass: string;
30
- config?: config;
43
+ callback?: ComboboxCallback;
31
44
  }
32
45
 
33
- interface config {
34
- onSelect?: (item: HTMLElement, value: string) => void;
46
+ interface ComboboxCallback {
47
+ onSelect?: (item: HTMLElement) => void;
35
48
  onOpenChange?: (isOpen: boolean) => void;
36
49
  onActiveDescendantChange?: (optionId: string, item: HTMLElement) => void;
37
50
  onClear?: () => void;
38
51
  }
39
52
 
40
- export type { AccessibilityInstance as A, ComboboxConfig as C };
53
+ export type { AccessibilityInstance as A, ComboboxConfig as C, AccordionConfig as a };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
4
- function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false }) {
4
+ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false, callback }) {
5
5
  const accordionContainer = document.querySelector(`#${accordionId}`);
6
6
  if (!accordionContainer) {
7
7
  console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`);
@@ -52,6 +52,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
52
52
  const panel = panels[index];
53
53
  trigger.setAttribute("aria-expanded", "true");
54
54
  panel.style.display = "block";
55
+ if (callback?.onExpand) {
56
+ callback.onExpand(index);
57
+ }
55
58
  }
56
59
  function collapseItem(index) {
57
60
  if (index < 0 || index >= triggers.length) {
@@ -62,6 +65,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
62
65
  const panel = panels[index];
63
66
  trigger.setAttribute("aria-expanded", "false");
64
67
  panel.style.display = "none";
68
+ if (callback?.onCollapse) {
69
+ callback.onCollapse(index);
70
+ }
65
71
  }
66
72
  function toggleItem(index) {
67
73
  const trigger = triggers[index];
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { a as AccordionConfig, A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
@@ -7,14 +7,9 @@ import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
7
7
  * @param {string} triggersClass - The shared class of all accordion trigger buttons.
8
8
  * @param {string} panelsClass - The shared class of all accordion panels.
9
9
  * @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
10
+ * @param {AccordionCallback} callback - Configuration options for callbacks.
10
11
  */
11
12
 
12
- interface AccordionConfig {
13
- accordionId: string;
14
- triggersClass: string;
15
- panelsClass: string;
16
- allowMultipleOpen?: boolean;
17
- }
18
- declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
13
+ declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
19
14
 
20
15
  export { makeAccordionAccessible };
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { a as AccordionConfig, A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Makes an accordion accessible by managing ARIA attributes, keyboard navigation, and state.
@@ -7,14 +7,9 @@ import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
7
7
  * @param {string} triggersClass - The shared class of all accordion trigger buttons.
8
8
  * @param {string} panelsClass - The shared class of all accordion panels.
9
9
  * @param {boolean} allowMultipleOpen - Whether multiple panels can be open simultaneously (default: false).
10
+ * @param {AccordionCallback} callback - Configuration options for callbacks.
10
11
  */
11
12
 
12
- interface AccordionConfig {
13
- accordionId: string;
14
- triggersClass: string;
15
- panelsClass: string;
16
- allowMultipleOpen?: boolean;
17
- }
18
- declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen }: AccordionConfig): AccessibilityInstance;
13
+ declare function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen, callback }: AccordionConfig): AccessibilityInstance;
19
14
 
20
15
  export { makeAccordionAccessible };
@@ -1,5 +1,5 @@
1
1
  // src/accordion/src/makeAccordionAccessible/makeAccordionAccessible.ts
2
- function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false }) {
2
+ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allowMultipleOpen = false, callback }) {
3
3
  const accordionContainer = document.querySelector(`#${accordionId}`);
4
4
  if (!accordionContainer) {
5
5
  console.error(`[aria-ease] Element with id="${accordionId}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`);
@@ -50,6 +50,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
50
50
  const panel = panels[index];
51
51
  trigger.setAttribute("aria-expanded", "true");
52
52
  panel.style.display = "block";
53
+ if (callback?.onExpand) {
54
+ callback.onExpand(index);
55
+ }
53
56
  }
54
57
  function collapseItem(index) {
55
58
  if (index < 0 || index >= triggers.length) {
@@ -60,6 +63,9 @@ function makeAccordionAccessible({ accordionId, triggersClass, panelsClass, allo
60
63
  const panel = panels[index];
61
64
  trigger.setAttribute("aria-expanded", "false");
62
65
  panel.style.display = "none";
66
+ if (callback?.onCollapse) {
67
+ callback.onCollapse(index);
68
+ }
63
69
  }
64
70
  function toggleItem(index) {
65
71
  const trigger = triggers[index];
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a checkbox group accessible by managing ARIA attributes and keyboard navigation.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Makes a checkbox group accessible by managing ARIA attributes and keyboard navigation.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
4
- function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
4
+ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }) {
5
5
  const comboboxInput = document.getElementById(`${comboboxInputId}`);
6
6
  if (!comboboxInput) {
7
7
  console.error(`[aria-ease] Element with id="${comboboxInputId}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`);
@@ -48,9 +48,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
48
48
  if (typeof activeItem.scrollIntoView === "function") {
49
49
  activeItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
50
50
  }
51
- if (config?.onActiveDescendantChange) {
51
+ if (callback?.onActiveDescendantChange) {
52
52
  try {
53
- config.onActiveDescendantChange(itemId, activeItem);
53
+ callback.onActiveDescendantChange(itemId, activeItem);
54
54
  } catch (error) {
55
55
  console.error("[aria-ease] Error in onActiveDescendantChange callback:", error);
56
56
  }
@@ -62,9 +62,10 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
62
62
  }
63
63
  function openListbox() {
64
64
  comboboxInput.setAttribute("aria-expanded", "true");
65
- if (config?.onOpenChange) {
65
+ listBox.style.display = "block";
66
+ if (callback?.onOpenChange) {
66
67
  try {
67
- config.onOpenChange(true);
68
+ callback.onOpenChange(true);
68
69
  } catch (error) {
69
70
  console.error("[aria-ease] Error in onOpenChange callback:", error);
70
71
  }
@@ -73,12 +74,13 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
73
74
  function closeListbox() {
74
75
  comboboxInput.setAttribute("aria-expanded", "false");
75
76
  comboboxInput.setAttribute("aria-activedescendant", "");
77
+ listBox.style.display = "none";
76
78
  activeIndex = -1;
77
79
  const visibleItems = getVisibleItems();
78
80
  visibleItems.forEach((item) => item.setAttribute("aria-selected", "false"));
79
- if (config?.onOpenChange) {
81
+ if (callback?.onOpenChange) {
80
82
  try {
81
- config.onOpenChange(false);
83
+ callback.onOpenChange(false);
82
84
  } catch (error) {
83
85
  console.error("[aria-ease] Error in onOpenChange callback:", error);
84
86
  }
@@ -88,9 +90,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
88
90
  const value = item.textContent?.trim() || "";
89
91
  comboboxInput.value = value;
90
92
  closeListbox();
91
- if (config?.onSelect) {
93
+ if (callback?.onSelect) {
92
94
  try {
93
- config.onSelect(item, value);
95
+ callback.onSelect(item);
94
96
  } catch (error) {
95
97
  console.error("[aria-ease] Error in onSelect callback:", error);
96
98
  }
@@ -133,9 +135,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
133
135
  } else if (comboboxInput.value) {
134
136
  event.preventDefault();
135
137
  comboboxInput.value = "";
136
- if (config?.onClear) {
138
+ if (callback?.onClear) {
137
139
  try {
138
- config.onClear();
140
+ callback.onClear();
139
141
  } catch (error) {
140
142
  console.error("[aria-ease] Error in onClear callback:", error);
141
143
  }
@@ -1,4 +1,4 @@
1
- import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
@@ -6,9 +6,9 @@ import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5
6
6
  * @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
7
7
  * @param {string} listBoxId - The id of the listbox element.
8
8
  * @param {string} listBoxItemsClass - The class of the items within the listbox.
9
- * @param {ComboboxConfig} config - Configuration options for callbacks.
9
+ * @param {ComboboxCallback} callback - Configuration options for callbacks.
10
10
  */
11
11
 
12
- declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }: ComboboxConfig): AccessibilityInstance;
12
+ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
13
13
 
14
14
  export { makeComboboxAccessible };
@@ -1,4 +1,4 @@
1
- import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
@@ -6,9 +6,9 @@ import { C as ComboboxConfig, A as AccessibilityInstance } from '../Types.d-COr5
6
6
  * @param {string} comboboxButtonId - The id of the button that toggles the listbox (optional).
7
7
  * @param {string} listBoxId - The id of the listbox element.
8
8
  * @param {string} listBoxItemsClass - The class of the items within the listbox.
9
- * @param {ComboboxConfig} config - Configuration options for callbacks.
9
+ * @param {ComboboxCallback} callback - Configuration options for callbacks.
10
10
  */
11
11
 
12
- declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }: ComboboxConfig): AccessibilityInstance;
12
+ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }: ComboboxConfig): AccessibilityInstance;
13
13
 
14
14
  export { makeComboboxAccessible };
@@ -1,5 +1,5 @@
1
1
  // src/combobox/src/makeComboBoxAccessible/makeComboBoxAccessible.ts
2
- function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, config }) {
2
+ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId, listBoxItemsClass, callback }) {
3
3
  const comboboxInput = document.getElementById(`${comboboxInputId}`);
4
4
  if (!comboboxInput) {
5
5
  console.error(`[aria-ease] Element with id="${comboboxInputId}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`);
@@ -46,9 +46,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
46
46
  if (typeof activeItem.scrollIntoView === "function") {
47
47
  activeItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
48
48
  }
49
- if (config?.onActiveDescendantChange) {
49
+ if (callback?.onActiveDescendantChange) {
50
50
  try {
51
- config.onActiveDescendantChange(itemId, activeItem);
51
+ callback.onActiveDescendantChange(itemId, activeItem);
52
52
  } catch (error) {
53
53
  console.error("[aria-ease] Error in onActiveDescendantChange callback:", error);
54
54
  }
@@ -60,9 +60,10 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
60
60
  }
61
61
  function openListbox() {
62
62
  comboboxInput.setAttribute("aria-expanded", "true");
63
- if (config?.onOpenChange) {
63
+ listBox.style.display = "block";
64
+ if (callback?.onOpenChange) {
64
65
  try {
65
- config.onOpenChange(true);
66
+ callback.onOpenChange(true);
66
67
  } catch (error) {
67
68
  console.error("[aria-ease] Error in onOpenChange callback:", error);
68
69
  }
@@ -71,12 +72,13 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
71
72
  function closeListbox() {
72
73
  comboboxInput.setAttribute("aria-expanded", "false");
73
74
  comboboxInput.setAttribute("aria-activedescendant", "");
75
+ listBox.style.display = "none";
74
76
  activeIndex = -1;
75
77
  const visibleItems = getVisibleItems();
76
78
  visibleItems.forEach((item) => item.setAttribute("aria-selected", "false"));
77
- if (config?.onOpenChange) {
79
+ if (callback?.onOpenChange) {
78
80
  try {
79
- config.onOpenChange(false);
81
+ callback.onOpenChange(false);
80
82
  } catch (error) {
81
83
  console.error("[aria-ease] Error in onOpenChange callback:", error);
82
84
  }
@@ -86,9 +88,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
86
88
  const value = item.textContent?.trim() || "";
87
89
  comboboxInput.value = value;
88
90
  closeListbox();
89
- if (config?.onSelect) {
91
+ if (callback?.onSelect) {
90
92
  try {
91
- config.onSelect(item, value);
93
+ callback.onSelect(item);
92
94
  } catch (error) {
93
95
  console.error("[aria-ease] Error in onSelect callback:", error);
94
96
  }
@@ -131,9 +133,9 @@ function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, listBoxId,
131
133
  } else if (comboboxInput.value) {
132
134
  event.preventDefault();
133
135
  comboboxInput.value = "";
134
- if (config?.onClear) {
136
+ if (callback?.onClear) {
135
137
  try {
136
- config.onClear();
138
+ callback.onClear();
137
139
  } catch (error) {
138
140
  console.error("[aria-ease] Error in onClear callback:", error);
139
141
  }
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.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.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.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.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a radio group accessible by managing ARIA attributes, keyboard navigation, and state.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Makes a radio group accessible by managing ARIA attributes, keyboard navigation, and state.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.cjs';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
@@ -1,4 +1,4 @@
1
- import { A as AccessibilityInstance } from '../Types.d-COr5IFp5.js';
1
+ import { A as AccessibilityInstance } from '../Types.d-B-NDbH_q.js';
2
2
 
3
3
  /**
4
4
  * Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-ease",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "Out-of-the-box accessibility utility package to develop production ready applications.",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",