aria-ease 2.3.0 → 2.4.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 CHANGED
@@ -53,8 +53,8 @@ export default {
53
53
  output: {
54
54
  format: "html", // 'json' | 'csv' | 'html' | 'all'
55
55
  out: "./accessibility-reports",
56
- }
57
- }
56
+ },
57
+ },
58
58
  };
59
59
  ```
60
60
 
@@ -65,6 +65,7 @@ npx aria-ease audit
65
65
  ```
66
66
 
67
67
  **Supported config formats:**
68
+
68
69
  - `ariaease.config.js` (ES modules)
69
70
  - `ariaease.config.mjs` (ES modules explicit)
70
71
  - `ariaease.config.cjs` (CommonJS)
@@ -79,9 +80,9 @@ The CLI will automatically find and load your config file, with validation to ca
79
80
 
80
81
  ## 📚 Component API
81
82
 
82
- ### 🍔 Menu (Dropdowns, Combo Boxes, Navigation)
83
+ ### 🍔 Menu (Dropdowns)
83
84
 
84
- Creates accessible menus with focus trapping and keyboard navigation. Works for dropdowns, combo boxes, navigation menus - any component that toggles display with interactive items.
85
+ Creates accessible menus with focus trapping and keyboard navigation. Works for dropdowns that toggles display with interactive items.
85
86
 
86
87
  **Features:**
87
88
 
@@ -95,15 +96,20 @@ import * as Menu from "aria-ease/menu";
95
96
 
96
97
  // React Example
97
98
  useEffect(() => {
98
- const menuInstance = Menu.makeMenuAccessible({
99
- menuId: "dropdown-menu",
100
- menuItemsClass: "menu-item",
101
- triggerId: "menu-button",
99
+ menuRef.current = Menu.makeMenuAccessible({
100
+ menuId: "menu-div",
101
+ menuItemsClass: "profile-menu-items",
102
+ triggerId: "display-button",
102
103
  });
103
104
 
104
- return () => menuInstance.cleanup(); // Clean up on unmount
105
+ return () => menuRef.current.cleanup(); // Clean up on unmount
105
106
  }, []);
106
107
 
108
+ // Programmatically control
109
+ menuRef.current.openMenu(); // Open the menu
110
+ menuRef.current.closeMenu(); // Close the menu
111
+ menuRef.current.refresh(); // Refresh the cache after dynamically adding/removing a menu item
112
+
107
113
  // Vanilla JS Example
108
114
  const menu = Menu.makeMenuAccessible({
109
115
  menuId: "dropdown-menu",
@@ -116,22 +122,36 @@ menu.openMenu();
116
122
  menu.closeMenu();
117
123
 
118
124
  // If you dynamically add/remove menu items, refresh the cache
119
- menu.refresh();
125
+ menu.refresh();
120
126
  ```
121
127
 
122
128
  **Required HTML structure:**
123
129
 
124
130
  ```html
125
- <button id="menu-button" aria-expanded="false" aria-controls="dropdown-menu">
131
+ <button
132
+ id="menu-button"
133
+ aria-expanded="false"
134
+ aria-controls="dropdown-menu"
135
+ aria-haspopup="true"
136
+ >
126
137
  Menu
127
138
  </button>
128
- <div id="dropdown-menu" style="display: none;">
129
- <a href="#" class="menu-item">Item 1</a>
130
- <a href="#" class="menu-item">Item 2</a>
131
- <button class="menu-item">Item 3</button>
139
+ <div
140
+ id="dropdown-menu"
141
+ style="display: none;"
142
+ aria-labelledby="menu-button"
143
+ role="menu"
144
+ >
145
+ <a role="menuitem" href="#" class="menu-item">Item 1</a>
146
+ <a role="menuitem" href="#" class="menu-item">Item 2</a>
147
+ <button role="menuitem" class="menu-item">Item 3</button>
132
148
  </div>
133
149
  ```
134
150
 
151
+ ## 🎮 Live Demo
152
+
153
+ - [Menu Component](https://codesandbox.io/p/sandbox/szsclq) - Dropdown with keyboard navigation
154
+
135
155
  ---
136
156
 
137
157
  ### 🪗 Accordion
@@ -281,7 +301,7 @@ const blockInstance = makeBlockAccessible({
281
301
  });
282
302
 
283
303
  // Clean up when done
284
- blockInstance.cleanup();
304
+ blockInstance.current.cleanup();
285
305
  ```
286
306
 
287
307
  ---
@@ -329,6 +349,8 @@ Aria-Ease is designed to be lightweight and tree-shakable:
329
349
  ```javascript
330
350
  // ✅ Good - only imports menu code (~3.7KB)
331
351
  import { makeMenuAccessible } from "aria-ease/menu";
352
+ //or
353
+ import * as Block from "aria-ease/block";
332
354
 
333
355
  // ❌ Avoid - imports everything (~416KB)
334
356
  import { makeMenuAccessible } from "aria-ease";
@@ -345,8 +367,8 @@ If using React StrictMode, be aware it intentionally calls effects twice in deve
345
367
 
346
368
  ```javascript
347
369
  useEffect(() => {
348
- const instance = makeMenuAccessible({...});
349
- return () => instance.cleanup(); // Prevents double-initialization
370
+ menuRef.current = Menu.makeMenuAccessible({...});
371
+ return () => menuRef.current.cleanup(); // Prevents double-initialization
350
372
  }, []);
351
373
  ```
352
374
 
@@ -378,7 +400,7 @@ Without visible focus indicators, keyboard users cannot tell which element is ac
378
400
  Aria-Ease supports all modern browsers:
379
401
 
380
402
  | Browser | Minimum Version |
381
- |---------|----------------|
403
+ | ------- | --------------- |
382
404
  | Chrome | Last 2 versions |
383
405
  | Firefox | Last 2 versions |
384
406
  | Safari | Last 2 versions |
@@ -387,6 +409,7 @@ Aria-Ease supports all modern browsers:
387
409
  **Not supported:** Internet Explorer 11 and below
388
410
 
389
411
  **Requirements:**
412
+
390
413
  - ES6+ support
391
414
  - `querySelector` and `querySelectorAll`
392
415
  - `addEventListener` and `removeEventListener`
@@ -417,4 +440,4 @@ ISC License - see [LICENSE](LICENSE) file for details.
417
440
 
418
441
  ---
419
442
 
420
- **Created by [Isaac Victor](https://isaacvictordev.web.app/)**
443
+ **Created by [Isaac Victor](https://github.com/Scriptkidd98)**
package/dist/index.cjs CHANGED
@@ -9816,14 +9816,14 @@ function makeBlockAccessible(blockId, blockItemsClass) {
9816
9816
  const blockDiv = document.querySelector(`#${blockId}`);
9817
9817
  if (!blockDiv) {
9818
9818
  console.error(`[aria-ease] Element with id="${blockId}" not found. Make sure the block element exists before calling makeBlockAccessible.`);
9819
- return function cleanUpBlockEventListeners() {
9820
- };
9819
+ return { cleanup: () => {
9820
+ } };
9821
9821
  }
9822
9822
  const blockItems = blockDiv.querySelectorAll(`.${blockItemsClass}`);
9823
9823
  if (!blockItems || blockItems.length === 0) {
9824
9824
  console.error(`[aria-ease] Element with class="${blockItemsClass}" not found. Make sure the block items exist before calling makeBlockAccessible.`);
9825
- return function cleanUpBlockEventListeners() {
9826
- };
9825
+ return { cleanup: () => {
9826
+ } };
9827
9827
  }
9828
9828
  blockItems.forEach((blockItem) => {
9829
9829
  if (!eventListenersMap.has(blockItem)) {
@@ -9836,7 +9836,7 @@ function makeBlockAccessible(blockId, blockItemsClass) {
9836
9836
  eventListenersMap.set(blockItem, handler);
9837
9837
  }
9838
9838
  });
9839
- return function cleanUpBlockEventListeners() {
9839
+ function cleanup() {
9840
9840
  blockItems.forEach((blockItem) => {
9841
9841
  const handler = eventListenersMap.get(blockItem);
9842
9842
  if (handler) {
@@ -9844,7 +9844,9 @@ function makeBlockAccessible(blockId, blockItemsClass) {
9844
9844
  eventListenersMap.delete(blockItem);
9845
9845
  }
9846
9846
  });
9847
- };
9847
+ }
9848
+ ;
9849
+ return { cleanup };
9848
9850
  }
9849
9851
 
9850
9852
  // src/checkbox/src/updateCheckboxAriaAttributes/updateCheckboxAriaAttributes.ts