aria-ease 7.3.0 → 7.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.
@@ -1 +1 @@
1
- 'use strict';function E({radioGroupId:s,radiosClass:l,defaultSelectedIndex:f=0}){if(s==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let c=document.querySelector(`#${s}`);if(!c)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let t=Array.from(c.querySelectorAll(`.${l}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let u=new WeakMap,d=new WeakMap,r=f;function b(){c.getAttribute("role")||c.setAttribute("role","radiogroup"),t.forEach((e,n)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex",n===r?"0":"-1"),n===r?e.setAttribute("aria-checked","true"):e.setAttribute("aria-checked","false");});}function i(e){if(e<0||e>=t.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}r>=0&&r<t.length&&(t[r].setAttribute("aria-checked","false"),t[r].setAttribute("tabindex","-1")),t[e].setAttribute("aria-checked","true"),t[e].setAttribute("tabindex","0"),t[e].focus(),r=e;}function m(e){return ()=>{i(e);}}function h(e){return n=>{let{key:a}=n,o=e;switch(a){case "ArrowDown":case "ArrowRight":n.preventDefault(),o=(e+1)%t.length,i(o);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),o=(e-1+t.length)%t.length,i(o);break;case " ":case "Enter":n.preventDefault(),i(e);break}}}function k(){t.forEach((e,n)=>{let a=m(n),o=h(n);e.addEventListener("click",a),e.addEventListener("keydown",o),u.set(e,o),d.set(e,a);});}function g(){t.forEach(e=>{let n=u.get(e),a=d.get(e);n&&(e.removeEventListener("keydown",n),u.delete(e)),a&&(e.removeEventListener("click",a),d.delete(e));});}function A(){g();}function p(){return r}return b(),k(),{selectRadio:i,getSelectedIndex:p,cleanup:A}}exports.makeRadioAccessible=E;
1
+ 'use strict';function y({radioGroupId:s,radiosClass:l,defaultSelectedIndex:d,callback:b}){if(s==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${s}`);if(!i)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let r=Array.from(i.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let u=new WeakMap,f=new WeakMap,n;d&&(n=d);function m(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),r.forEach((e,t)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex","0"),t===n?e.setAttribute("aria-checked","true"):e.setAttribute("aria-checked","false");});}function c(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}if(n>=0&&n<r.length&&r[n].setAttribute("aria-checked","false"),r[e].setAttribute("aria-checked","true"),r[e].focus(),b?.onCheck)try{b.onCheck(e);}catch(t){console.error("[aria-ease] Error in radio onCheck callback:",t);}n=e;}function h(e){return ()=>{c(e);}}function k(e){return t=>{let{key:o}=t,a=e;switch(o){case "ArrowDown":case "ArrowRight":t.preventDefault(),a=(e+1)%r.length,c(a);break;case "ArrowUp":case "ArrowLeft":t.preventDefault(),a=(e-1+r.length)%r.length,c(a);break;case " ":case "Enter":t.preventDefault(),c(e);break}}}function g(){r.forEach((e,t)=>{let o=h(t),a=k(t);e.addEventListener("click",o),e.addEventListener("keydown",a),u.set(e,a),f.set(e,o);});}function p(){r.forEach(e=>{let t=u.get(e),o=f.get(e);t&&(e.removeEventListener("keydown",t),u.delete(e)),o&&(e.removeEventListener("click",o),f.delete(e));});}function A(){p();}function E(){return n}return m(),g(),{selectRadio:c,getSelectedIndex:E,cleanup:A}}exports.makeRadioAccessible=y;
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a radio group accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -6,13 +6,9 @@ import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
6
6
  * @param {string} radioGroupId - The id of the radio group container.
7
7
  * @param {string} radiosClass - The shared class of all radio buttons.
8
8
  * @param {number} defaultSelectedIndex - The index of the initially selected radio (default: 0).
9
+ * @param {RadioCallback} callback - Configuration options for callbacks.
9
10
  */
10
11
 
11
- interface RadioConfig {
12
- radioGroupId: string;
13
- radiosClass: string;
14
- defaultSelectedIndex?: number;
15
- }
16
- declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex }: RadioConfig): AccessibilityInstance;
12
+ declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex, callback }: RadioConfig): AccessibilityInstance;
17
13
 
18
14
  export { makeRadioAccessible };
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Makes a radio group accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -6,13 +6,9 @@ import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
6
6
  * @param {string} radioGroupId - The id of the radio group container.
7
7
  * @param {string} radiosClass - The shared class of all radio buttons.
8
8
  * @param {number} defaultSelectedIndex - The index of the initially selected radio (default: 0).
9
+ * @param {RadioCallback} callback - Configuration options for callbacks.
9
10
  */
10
11
 
11
- interface RadioConfig {
12
- radioGroupId: string;
13
- radiosClass: string;
14
- defaultSelectedIndex?: number;
15
- }
16
- declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex }: RadioConfig): AccessibilityInstance;
12
+ declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex, callback }: RadioConfig): AccessibilityInstance;
17
13
 
18
14
  export { makeRadioAccessible };
@@ -1 +1 @@
1
- function E({radioGroupId:s,radiosClass:l,defaultSelectedIndex:f=0}){if(s==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let c=document.querySelector(`#${s}`);if(!c)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let t=Array.from(c.querySelectorAll(`.${l}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let u=new WeakMap,d=new WeakMap,r=f;function b(){c.getAttribute("role")||c.setAttribute("role","radiogroup"),t.forEach((e,n)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex",n===r?"0":"-1"),n===r?e.setAttribute("aria-checked","true"):e.setAttribute("aria-checked","false");});}function i(e){if(e<0||e>=t.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}r>=0&&r<t.length&&(t[r].setAttribute("aria-checked","false"),t[r].setAttribute("tabindex","-1")),t[e].setAttribute("aria-checked","true"),t[e].setAttribute("tabindex","0"),t[e].focus(),r=e;}function m(e){return ()=>{i(e);}}function h(e){return n=>{let{key:a}=n,o=e;switch(a){case "ArrowDown":case "ArrowRight":n.preventDefault(),o=(e+1)%t.length,i(o);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),o=(e-1+t.length)%t.length,i(o);break;case " ":case "Enter":n.preventDefault(),i(e);break}}}function k(){t.forEach((e,n)=>{let a=m(n),o=h(n);e.addEventListener("click",a),e.addEventListener("keydown",o),u.set(e,o),d.set(e,a);});}function g(){t.forEach(e=>{let n=u.get(e),a=d.get(e);n&&(e.removeEventListener("keydown",n),u.delete(e)),a&&(e.removeEventListener("click",a),d.delete(e));});}function A(){g();}function p(){return r}return b(),k(),{selectRadio:i,getSelectedIndex:p,cleanup:A}}export{E as makeRadioAccessible};
1
+ function y({radioGroupId:s,radiosClass:l,defaultSelectedIndex:d,callback:b}){if(s==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${s}`);if(!i)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let r=Array.from(i.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let u=new WeakMap,f=new WeakMap,n;d&&(n=d);function m(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),r.forEach((e,t)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex","0"),t===n?e.setAttribute("aria-checked","true"):e.setAttribute("aria-checked","false");});}function c(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}if(n>=0&&n<r.length&&r[n].setAttribute("aria-checked","false"),r[e].setAttribute("aria-checked","true"),r[e].focus(),b?.onCheck)try{b.onCheck(e);}catch(t){console.error("[aria-ease] Error in radio onCheck callback:",t);}n=e;}function h(e){return ()=>{c(e);}}function k(e){return t=>{let{key:o}=t,a=e;switch(o){case "ArrowDown":case "ArrowRight":t.preventDefault(),a=(e+1)%r.length,c(a);break;case "ArrowUp":case "ArrowLeft":t.preventDefault(),a=(e-1+r.length)%r.length,c(a);break;case " ":case "Enter":t.preventDefault(),c(e);break}}}function g(){r.forEach((e,t)=>{let o=h(t),a=k(t);e.addEventListener("click",o),e.addEventListener("keydown",a),u.set(e,a),f.set(e,o);});}function p(){r.forEach(e=>{let t=u.get(e),o=f.get(e);t&&(e.removeEventListener("keydown",t),u.delete(e)),o&&(e.removeEventListener("click",o),f.delete(e));});}function A(){p();}function E(){return n}return m(),g(),{selectRadio:c,getSelectedIndex:E,cleanup:A}}export{y as makeRadioAccessible};
@@ -1,4 +1,4 @@
1
- import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Makes tabs accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -1,4 +1,4 @@
1
- import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Makes tabs accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.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-DYfYR3Vc.js';
1
+ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.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": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "Accessibility infrastructure for the entire frontend engineering lifecycle. Build accessible patterns, run automated audits, verify component interactions, and gate deployments — all in one system.",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",