aria-ease 7.5.0 → 7.8.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 +60 -75
- package/dist/ToggleComponentStrategy-TMRNXFSL.js +1 -0
- package/dist/cli.cjs +34 -34
- package/dist/cli.js +1 -1
- package/dist/{contractTestRunnerPlaywright-75NI6SN7.js → contractTestRunnerPlaywright-CJFYO766.js} +1 -1
- package/dist/{contractTestRunnerPlaywright-VLOD5IB3.js → contractTestRunnerPlaywright-OB2GWGOA.js} +1 -1
- package/dist/index.cjs +33 -33
- package/dist/index.d.cts +18 -14
- package/dist/index.d.ts +18 -14
- package/dist/index.js +10 -10
- package/dist/src/{Types.d-D96FYkCN.d.cts → Types.d-BjBTlIzl.d.cts} +18 -8
- package/dist/src/{Types.d-D96FYkCN.d.ts → Types.d-BjBTlIzl.d.ts} +18 -8
- package/dist/src/accordion/index.cjs +1 -1
- package/dist/src/accordion/index.d.cts +1 -1
- package/dist/src/accordion/index.d.ts +1 -1
- package/dist/src/accordion/index.js +1 -1
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/checkbox/index.cjs +1 -1
- package/dist/src/checkbox/index.d.cts +1 -1
- package/dist/src/checkbox/index.d.ts +1 -1
- package/dist/src/checkbox/index.js +1 -1
- 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 +1 -1
- package/dist/src/menu/index.d.cts +1 -1
- package/dist/src/menu/index.d.ts +1 -1
- package/dist/src/menu/index.js +1 -1
- package/dist/src/radio/index.cjs +1 -1
- package/dist/src/radio/index.d.cts +1 -1
- package/dist/src/radio/index.d.ts +1 -1
- package/dist/src/radio/index.js +1 -1
- package/dist/src/tabs/index.cjs +1 -1
- package/dist/src/tabs/index.d.cts +1 -2
- package/dist/src/tabs/index.d.ts +1 -2
- package/dist/src/tabs/index.js +1 -1
- package/dist/src/toggle/index.cjs +1 -1
- package/dist/src/toggle/index.d.cts +2 -7
- package/dist/src/toggle/index.d.ts +2 -7
- package/dist/src/toggle/index.js +1 -1
- package/dist/src/utils/test/ToggleComponentStrategy-UOGYK2U4.js +1 -0
- package/dist/src/utils/test/{contractTestRunnerPlaywright-FSZDW7IR.js → contractTestRunnerPlaywright-ZKVK7KUM.js} +1 -1
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +14 -14
- package/dist/src/utils/test/index.d.cts +1 -0
- package/dist/src/utils/test/index.d.ts +1 -0
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-FURQN5KO.js → test-TZFBWFCP.js} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:
|
|
1
|
+
'use strict';function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:p=false,callback:d}){if(c==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(s.querySelectorAll(`.${i}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r.length!==a.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${r.length} triggers but ${a.length} panels.`),{cleanup:()=>{}};let f=new WeakMap,m=new WeakMap;function b(){r.forEach((e,n)=>{let o=a[n];e.id||(e.id=`${c}-trigger-${n}`),o.id||(o.id=`${c}-panel-${n}`),e.setAttribute("aria-controls",o.id),e.setAttribute("aria-expanded","false"),(!p||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function g(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","true"),o.style.display="block",d?.onExpandedChange)try{d.onExpandedChange(e,!0);}catch(t){console.error("[aria-ease] Error in accordion onExpandedChange callback:",t);}}function u(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","false"),o.style.display="none",d?.onExpandedChange)try{d.onExpandedChange(e,!1);}catch(t){console.error("[aria-ease] Error in accordion onExpandedChange callback:",t);}}function h(e){r[e].getAttribute("aria-expanded")==="true"?u(e):(p||r.forEach((t,y)=>{y!==e&&u(y);}),g(e));}function k(e){return ()=>{h(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),h(e);break;case "ArrowDown":n.preventDefault();{let t=(e+1)%r.length;r[t].focus();}break;case "ArrowUp":n.preventDefault();{let t=(e-1+r.length)%r.length;r[t].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function A(){r.forEach((e,n)=>{let o=k(n),t=v(n);e.addEventListener("click",o),e.addEventListener("keydown",t),f.set(e,t),m.set(e,o);});}function E(){r.forEach(e=>{let n=f.get(e),o=m.get(e);n&&(e.removeEventListener("keydown",n),f.delete(e)),o&&(e.removeEventListener("click",o),m.delete(e));});}function $(){E(),r.forEach((e,n)=>{u(n);});}function w(){E();let e=Array.from(s.querySelectorAll(`.${l}`)),n=Array.from(s.querySelectorAll(`.${i}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),A();}return b(),A(),{expandItem:g,collapseItem:u,toggleItem:h,cleanup:$,refresh:w}}exports.makeAccordionAccessible=H;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:
|
|
1
|
+
function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:p=false,callback:d}){if(c==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(s.querySelectorAll(`.${i}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r.length!==a.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${r.length} triggers but ${a.length} panels.`),{cleanup:()=>{}};let f=new WeakMap,m=new WeakMap;function b(){r.forEach((e,n)=>{let o=a[n];e.id||(e.id=`${c}-trigger-${n}`),o.id||(o.id=`${c}-panel-${n}`),e.setAttribute("aria-controls",o.id),e.setAttribute("aria-expanded","false"),(!p||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function g(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","true"),o.style.display="block",d?.onExpandedChange)try{d.onExpandedChange(e,!0);}catch(t){console.error("[aria-ease] Error in accordion onExpandedChange callback:",t);}}function u(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","false"),o.style.display="none",d?.onExpandedChange)try{d.onExpandedChange(e,!1);}catch(t){console.error("[aria-ease] Error in accordion onExpandedChange callback:",t);}}function h(e){r[e].getAttribute("aria-expanded")==="true"?u(e):(p||r.forEach((t,y)=>{y!==e&&u(y);}),g(e));}function k(e){return ()=>{h(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),h(e);break;case "ArrowDown":n.preventDefault();{let t=(e+1)%r.length;r[t].focus();}break;case "ArrowUp":n.preventDefault();{let t=(e-1+r.length)%r.length;r[t].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function A(){r.forEach((e,n)=>{let o=k(n),t=v(n);e.addEventListener("click",o),e.addEventListener("keydown",t),f.set(e,t),m.set(e,o);});}function E(){r.forEach(e=>{let n=f.get(e),o=m.get(e);n&&(e.removeEventListener("keydown",n),f.delete(e)),o&&(e.removeEventListener("click",o),m.delete(e));});}function $(){E(),r.forEach((e,n)=>{u(n);});}function w(){E();let e=Array.from(s.querySelectorAll(`.${l}`)),n=Array.from(s.querySelectorAll(`.${i}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),A();}return b(),A(),{expandItem:g,collapseItem:u,toggleItem:h,cleanup:$,refresh:w}}export{H as makeAccordionAccessible};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function L({checkboxGroupId:o,checkboxesClass:s,callback:u}){if(o==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let c=document.querySelector(`#${o}`);if(!c)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let r=Array.from(c.querySelectorAll(`.${s}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${s}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let i=new WeakMap,l=new WeakMap;function k(){c.getAttribute("role")||c.setAttribute("role","group"),r.forEach(e=>{e.setAttribute("role","checkbox");let t=e.checked;e.setAttribute("aria-checked",t?"true":"false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function a(e,t){if(u?.onCheckedChange)try{u.onCheckedChange(e,t);}catch(n){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",n);}}function h(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=r[e],n=!t.checked;t.checked=n,t.setAttribute("aria-checked",n?"true":"false"),a(e,n);}function d(e,t){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let n=r[e];n.checked=t,n.setAttribute("aria-checked",t?"true":"false"),a(e,t);}function f(e){return ()=>{let t=r[e];if("checked"in t&&typeof t.checked=="boolean")setTimeout(()=>{let n=t.checked;t.setAttribute("aria-checked",n?"true":"false"),a(e,n);},0);else {let n=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",n?"false":"true"),a(e,!n);}}}function m(e){return t=>{let{key:n}=t;switch(n){case " ":case "Spacebar":t.preventDefault(),h(e);break}}}function p(){r.forEach((e,t)=>{let n=f(t),b=m(t);e.addEventListener("click",n),e.addEventListener("keydown",b),i.set(e,b),l.set(e,n);});}function g(){r.forEach(e=>{let t=i.get(e),n=l.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),n&&(e.removeEventListener("click",n),l.delete(e));});}function E(){g();}function C(){return r.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return r.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return k(),p(),{toggleCheckbox:h,setCheckboxState:d,getCheckedStates:C,getCheckedIndices:A,cleanup:E}}exports.makeCheckboxAccessible=L;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a checkbox group accessible by managing ARIA attributes and keyboard interaction.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a checkbox group accessible by managing ARIA attributes and keyboard interaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function L({checkboxGroupId:o,checkboxesClass:s,callback:u}){if(o==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let c=document.querySelector(`#${o}`);if(!c)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let r=Array.from(c.querySelectorAll(`.${s}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${s}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let i=new WeakMap,l=new WeakMap;function k(){c.getAttribute("role")||c.setAttribute("role","group"),r.forEach(e=>{e.setAttribute("role","checkbox");let t=e.checked;e.setAttribute("aria-checked",t?"true":"false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function a(e,t){if(u?.onCheckedChange)try{u.onCheckedChange(e,t);}catch(n){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",n);}}function h(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=r[e],n=!t.checked;t.checked=n,t.setAttribute("aria-checked",n?"true":"false"),a(e,n);}function d(e,t){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let n=r[e];n.checked=t,n.setAttribute("aria-checked",t?"true":"false"),a(e,t);}function f(e){return ()=>{let t=r[e];if("checked"in t&&typeof t.checked=="boolean")setTimeout(()=>{let n=t.checked;t.setAttribute("aria-checked",n?"true":"false"),a(e,n);},0);else {let n=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",n?"false":"true"),a(e,!n);}}}function m(e){return t=>{let{key:n}=t;switch(n){case " ":case "Spacebar":t.preventDefault(),h(e);break}}}function p(){r.forEach((e,t)=>{let n=f(t),b=m(t);e.addEventListener("click",n),e.addEventListener("keydown",b),i.set(e,b),l.set(e,n);});}function g(){r.forEach(e=>{let t=i.get(e),n=l.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),n&&(e.removeEventListener("click",n),l.delete(e));});}function E(){g();}function C(){return r.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return r.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return k(),p(),{toggleCheckbox:h,setCheckboxState:d,getCheckedStates:C,getCheckedIndices:A,cleanup:E}}export{L as makeCheckboxAccessible};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function $({comboboxInputId:h,comboboxButtonId:
|
|
1
|
+
'use strict';function $({comboboxInputId:h,comboboxButtonId:x,listBoxId:b,listBoxItemsClass:u,callback:s}){if(h==="")return console.error("[aria-ease] 'comboboxInputId' should not be an empty string. Provide an id to the combobox input element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let o=document.getElementById(`${h}`);if(!o)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(b==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let a=document.getElementById(`${b}`);if(!a)return console.error(`[aria-ease] Element with id="${b}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(u==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(u))return console.error(`[aria-ease] Listbox option(s) with class="${u}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=x?document.getElementById(`${x}`):null,r=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",b),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),a.setAttribute("role","listbox");let m=null;function p(){return m||(m=a.querySelectorAll(`.${u}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function A(){return o.getAttribute("aria-expanded")==="true"}function d(e){let t=p();if(e>=0&&e<t.length){let n=t[e],i=n.id||`${b}-option-${e}`;if(n.id||(n.id=i),o.setAttribute("aria-activedescendant",i),typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",behavior:"smooth"}),s?.onActiveDescendantChange)try{s.onActiveDescendantChange(i,n);}catch(c){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",c);}}else o.setAttribute("aria-activedescendant","");r=e;}function v(){if(o.setAttribute("aria-expanded","true"),a.style.display="block",s?.onExpandedChange)try{s.onExpandedChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onExpandedChange callback:",e);}}function f(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),a.style.display="none",r=-1,s?.onExpandedChange)try{s.onExpandedChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onExpandedChange callback:",e);}}function E(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),f(),s?.onSelect)try{s.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function L(e){let t=p(),n=A();switch(e.key){case "ArrowDown":if(e.preventDefault(),!n){v();return}if(t.length===0)return;{let i=r>=t.length-1?0:r+1;d(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;d(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),E(t[r]));break;case "Escape":if(n)e.preventDefault(),f();else if(o.value&&(e.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),p().forEach(c=>{c.getAttribute("aria-selected")==="true"&&c.setAttribute("aria-selected","false");}),s?.onClear))try{s.onClear();}catch(c){console.error("[aria-ease] Error in combobox onClear callback:",c);}break;case "Home":n&&t.length>0&&(e.preventDefault(),d(0));break;case "End":n&&t.length>0&&(e.preventDefault(),d(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&E(t[r]),n&&f();break}}function y(e){let t=e.target;if(t.classList.contains(u)){let i=p().indexOf(t);i>=0&&d(i);}}function k(e){let t=e.target;t.classList.contains(u)&&(e.preventDefault(),E(t));}function C(e){let t=e.target;!o.contains(t)&&!a.contains(t)&&(!l||!l.contains(t))&&f();}function g(){A()?f():(v(),o.focus());}function w(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),g());}o.addEventListener("keydown",L),a.addEventListener("mousemove",y),a.addEventListener("mousedown",k),document.addEventListener("mousedown",C),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",g),l.addEventListener("keydown",w));function M(){let e=a.querySelectorAll(`.${u}`);if(e.length===0)return;let t=null;for(let n of e)if(n.getAttribute("aria-selected")==="true"){t=n.textContent?.trim()||null;break}!t&&o.value&&(t=o.value.trim()),e.forEach((n,i)=>{n.setAttribute("role","option");let c=n.textContent?.trim()||"";t&&c===t?n.setAttribute("aria-selected","true"):n.setAttribute("aria-selected","false");let D=n.getAttribute("id");if(!D||D===""){let T=`${b}-option-${i}`;n.id=T,n.setAttribute("id",T);}});}M();function H(){o.removeEventListener("keydown",L),a.removeEventListener("mousemove",y),a.removeEventListener("mousedown",k),document.removeEventListener("mousedown",C),l&&(l.removeEventListener("click",g),l.removeEventListener("keydown",w));}function I(){m=null,M(),r=-1,d(-1);}return {cleanup:H,refresh:I,openListbox:v,closeListbox:f}}exports.makeComboboxAccessible=$;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.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 { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function $({comboboxInputId:h,comboboxButtonId:
|
|
1
|
+
function $({comboboxInputId:h,comboboxButtonId:x,listBoxId:b,listBoxItemsClass:u,callback:s}){if(h==="")return console.error("[aria-ease] 'comboboxInputId' should not be an empty string. Provide an id to the combobox input element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let o=document.getElementById(`${h}`);if(!o)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(b==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let a=document.getElementById(`${b}`);if(!a)return console.error(`[aria-ease] Element with id="${b}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(u==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(u))return console.error(`[aria-ease] Listbox option(s) with class="${u}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=x?document.getElementById(`${x}`):null,r=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",b),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),a.setAttribute("role","listbox");let m=null;function p(){return m||(m=a.querySelectorAll(`.${u}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function A(){return o.getAttribute("aria-expanded")==="true"}function d(e){let t=p();if(e>=0&&e<t.length){let n=t[e],i=n.id||`${b}-option-${e}`;if(n.id||(n.id=i),o.setAttribute("aria-activedescendant",i),typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",behavior:"smooth"}),s?.onActiveDescendantChange)try{s.onActiveDescendantChange(i,n);}catch(c){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",c);}}else o.setAttribute("aria-activedescendant","");r=e;}function v(){if(o.setAttribute("aria-expanded","true"),a.style.display="block",s?.onExpandedChange)try{s.onExpandedChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onExpandedChange callback:",e);}}function f(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),a.style.display="none",r=-1,s?.onExpandedChange)try{s.onExpandedChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onExpandedChange callback:",e);}}function E(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),f(),s?.onSelect)try{s.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function L(e){let t=p(),n=A();switch(e.key){case "ArrowDown":if(e.preventDefault(),!n){v();return}if(t.length===0)return;{let i=r>=t.length-1?0:r+1;d(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;d(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),E(t[r]));break;case "Escape":if(n)e.preventDefault(),f();else if(o.value&&(e.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),p().forEach(c=>{c.getAttribute("aria-selected")==="true"&&c.setAttribute("aria-selected","false");}),s?.onClear))try{s.onClear();}catch(c){console.error("[aria-ease] Error in combobox onClear callback:",c);}break;case "Home":n&&t.length>0&&(e.preventDefault(),d(0));break;case "End":n&&t.length>0&&(e.preventDefault(),d(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&E(t[r]),n&&f();break}}function y(e){let t=e.target;if(t.classList.contains(u)){let i=p().indexOf(t);i>=0&&d(i);}}function k(e){let t=e.target;t.classList.contains(u)&&(e.preventDefault(),E(t));}function C(e){let t=e.target;!o.contains(t)&&!a.contains(t)&&(!l||!l.contains(t))&&f();}function g(){A()?f():(v(),o.focus());}function w(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),g());}o.addEventListener("keydown",L),a.addEventListener("mousemove",y),a.addEventListener("mousedown",k),document.addEventListener("mousedown",C),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",g),l.addEventListener("keydown",w));function M(){let e=a.querySelectorAll(`.${u}`);if(e.length===0)return;let t=null;for(let n of e)if(n.getAttribute("aria-selected")==="true"){t=n.textContent?.trim()||null;break}!t&&o.value&&(t=o.value.trim()),e.forEach((n,i)=>{n.setAttribute("role","option");let c=n.textContent?.trim()||"";t&&c===t?n.setAttribute("aria-selected","true"):n.setAttribute("aria-selected","false");let D=n.getAttribute("id");if(!D||D===""){let T=`${b}-option-${i}`;n.id=T,n.setAttribute("id",T);}});}M();function H(){o.removeEventListener("keydown",L),a.removeEventListener("mousemove",y),a.removeEventListener("mousedown",k),document.removeEventListener("mousedown",C),l&&(l.removeEventListener("click",g),l.removeEventListener("keydown",w));}function I(){m=null,M(),r=-1,d(-1);}return {cleanup:H,refresh:I,openListbox:v,closeListbox:f}}export{$ as makeComboboxAccessible};
|
package/dist/src/menu/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function F({menuId:c,menuItemsClass:h,triggerId:m,callback:s}){if(c==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let
|
|
1
|
+
'use strict';function F({menuId:c,menuItemsClass:h,triggerId:m,callback:s}){if(c==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let a=document.querySelector(`#${m}`);if(!a)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(h==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(c))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-controls",c),a.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",m);let p=new WeakMap,d=new Map,g=null,b=null;function M(){return g||(g=o.querySelectorAll(`.${h}`)),g}function u(){if(!b){let e=M();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=D(n),i=n.getAttribute("aria-disabled")==="true";r||(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),i||b.push(n));}}return b}function A(e){return {length:e.length,item:n=>e[n],forEach:n=>{e.forEach(n);},[Symbol.iterator]:function*(){for(let n of e)yield n;}}}function C(){M().forEach(t=>{t.setAttribute("role","menuitem");let n=t.getAttribute("data-submenu-id")??t.getAttribute("aria-controls"),r=t.hasAttribute("aria-haspopup")&&n;n&&(t.hasAttribute("data-submenu-id")||r)&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-controls",n),t.hasAttribute("aria-expanded")||t.setAttribute("aria-expanded","false"));});}function L(e,t,n){let r=e.length,i=(t+n+r)%r;e.item(i).focus();}function k(e,t){e.length!==0&&e[t]?.focus();}function y(e){return e.hasAttribute("aria-controls")&&e.hasAttribute("aria-haspopup")&&e.getAttribute("role")==="menuitem"}function $(e){let t=e;for(;t&&t.getAttribute("role")==="menuitem";){let n=t.closest('[role="menu"]');if(!n)break;n.style.display="none",t.setAttribute("aria-expanded","false");let r=n.getAttribute("aria-labelledby");if(!r)break;let i=document.getElementById(r);if(!i)break;t=i;}}C();function S(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&a.getAttribute("role")==="menuitem"){e.preventDefault(),l();return}break}case "ArrowUp":{e.preventDefault(),L(A(u()),n,-1);break}case "ArrowRight":{if(e.key==="ArrowRight"&&y(t)){e.preventDefault();let r=t.getAttribute("aria-controls");if(r){T(r);return}}break}case "ArrowDown":{e.preventDefault(),L(A(u()),n,1);break}case "Home":{e.preventDefault(),k(u(),0);break}case "End":{e.preventDefault();let r=u();k(r,r.length-1);break}case "Escape":{e.preventDefault(),l(),a.focus(),f&&f(false);break}case "Enter":case " ":{if(e.preventDefault(),y(t)){let r=t.getAttribute("aria-controls");if(r){T(r);return}}t.click(),l(),f&&f(false);break}case "Tab":{l(),$(a),f&&f(false);break}}}function D(e){let t=e.parentElement;for(;t&&t!==o;){if(t.getAttribute("role")==="menu"||t.id&&o.querySelector(`[aria-controls="${t.id}"]`))return true;t=t.parentElement;}return false}function E(e){a.setAttribute("aria-expanded",e?"true":"false");}function T(e){let t=d.get(e);if(!t){let n=o.querySelector(`[aria-controls="${e}"]`);if(!n){console.error(`[aria-ease] Submenu trigger with aria-controls="${e}" not found in menu "${c}".`);return}if(!n.id){let i=`trigger-${e}`;n.id=i,console.warn(`[aria-ease] Submenu trigger for "${e}" had no ID. Auto-generated ID: "${i}".`);}if(!document.querySelector(`#${e}`)){console.error(`[aria-ease] Submenu element with id="${e}" not found. Cannot create submenu instance.`);return}t=F({menuId:e,menuItemsClass:h,triggerId:n.id,callback:s}),d.set(e,t);}t.openMenu();}function f(e){if(s?.onExpandedChange)try{s.onExpandedChange(e);}catch(t){console.error("[aria-ease] Error in menu onExpandedChange callback:",t);}}function N(){u().forEach((t,n)=>{if(!p.has(t)){let r=i=>S(i,t,n);t.addEventListener("keydown",r),p.set(t,r);}});}function x(){u().forEach(t=>{let n=p.get(t);n&&(t.removeEventListener("keydown",n),p.delete(t));});}function H(){E(true),o.style.display="block";let e=u();if(N(),e&&e.length>0&&e[0].focus(),s?.onExpandedChange)try{s.onExpandedChange(!0);}catch(t){console.error("[aria-ease] Error in menu onExpandedChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),E(false),o.style.display="none",x(),a.focus(),s?.onExpandedChange)try{s.onExpandedChange(!1);}catch(e){console.error("[aria-ease] Error in menu onExpandedChange callback:",e);}}function w(){a.getAttribute("aria-expanded")==="true"?l():H();}function v(e){if(!(a.getAttribute("aria-expanded")==="true"))return;let n=a.contains(e.target),r=o.contains(e.target);!n&&!r&&l();}a.addEventListener("click",w),document.addEventListener("click",v);function O(){x(),a.removeEventListener("click",w),document.removeEventListener("click",v),o.style.display="none",E(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){g=null,b=null;}return {openMenu:H,closeMenu:l,cleanup:O,refresh:q}}exports.makeMenuAccessible=F;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.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 { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.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.
|
package/dist/src/menu/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function F({menuId:c,menuItemsClass:h,triggerId:m,callback:s}){if(c==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let
|
|
1
|
+
function F({menuId:c,menuItemsClass:h,triggerId:m,callback:s}){if(c==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let a=document.querySelector(`#${m}`);if(!a)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(h==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(c))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-controls",c),a.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",m);let p=new WeakMap,d=new Map,g=null,b=null;function M(){return g||(g=o.querySelectorAll(`.${h}`)),g}function u(){if(!b){let e=M();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=D(n),i=n.getAttribute("aria-disabled")==="true";r||(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),i||b.push(n));}}return b}function A(e){return {length:e.length,item:n=>e[n],forEach:n=>{e.forEach(n);},[Symbol.iterator]:function*(){for(let n of e)yield n;}}}function C(){M().forEach(t=>{t.setAttribute("role","menuitem");let n=t.getAttribute("data-submenu-id")??t.getAttribute("aria-controls"),r=t.hasAttribute("aria-haspopup")&&n;n&&(t.hasAttribute("data-submenu-id")||r)&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-controls",n),t.hasAttribute("aria-expanded")||t.setAttribute("aria-expanded","false"));});}function L(e,t,n){let r=e.length,i=(t+n+r)%r;e.item(i).focus();}function k(e,t){e.length!==0&&e[t]?.focus();}function y(e){return e.hasAttribute("aria-controls")&&e.hasAttribute("aria-haspopup")&&e.getAttribute("role")==="menuitem"}function $(e){let t=e;for(;t&&t.getAttribute("role")==="menuitem";){let n=t.closest('[role="menu"]');if(!n)break;n.style.display="none",t.setAttribute("aria-expanded","false");let r=n.getAttribute("aria-labelledby");if(!r)break;let i=document.getElementById(r);if(!i)break;t=i;}}C();function S(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&a.getAttribute("role")==="menuitem"){e.preventDefault(),l();return}break}case "ArrowUp":{e.preventDefault(),L(A(u()),n,-1);break}case "ArrowRight":{if(e.key==="ArrowRight"&&y(t)){e.preventDefault();let r=t.getAttribute("aria-controls");if(r){T(r);return}}break}case "ArrowDown":{e.preventDefault(),L(A(u()),n,1);break}case "Home":{e.preventDefault(),k(u(),0);break}case "End":{e.preventDefault();let r=u();k(r,r.length-1);break}case "Escape":{e.preventDefault(),l(),a.focus(),f&&f(false);break}case "Enter":case " ":{if(e.preventDefault(),y(t)){let r=t.getAttribute("aria-controls");if(r){T(r);return}}t.click(),l(),f&&f(false);break}case "Tab":{l(),$(a),f&&f(false);break}}}function D(e){let t=e.parentElement;for(;t&&t!==o;){if(t.getAttribute("role")==="menu"||t.id&&o.querySelector(`[aria-controls="${t.id}"]`))return true;t=t.parentElement;}return false}function E(e){a.setAttribute("aria-expanded",e?"true":"false");}function T(e){let t=d.get(e);if(!t){let n=o.querySelector(`[aria-controls="${e}"]`);if(!n){console.error(`[aria-ease] Submenu trigger with aria-controls="${e}" not found in menu "${c}".`);return}if(!n.id){let i=`trigger-${e}`;n.id=i,console.warn(`[aria-ease] Submenu trigger for "${e}" had no ID. Auto-generated ID: "${i}".`);}if(!document.querySelector(`#${e}`)){console.error(`[aria-ease] Submenu element with id="${e}" not found. Cannot create submenu instance.`);return}t=F({menuId:e,menuItemsClass:h,triggerId:n.id,callback:s}),d.set(e,t);}t.openMenu();}function f(e){if(s?.onExpandedChange)try{s.onExpandedChange(e);}catch(t){console.error("[aria-ease] Error in menu onExpandedChange callback:",t);}}function N(){u().forEach((t,n)=>{if(!p.has(t)){let r=i=>S(i,t,n);t.addEventListener("keydown",r),p.set(t,r);}});}function x(){u().forEach(t=>{let n=p.get(t);n&&(t.removeEventListener("keydown",n),p.delete(t));});}function H(){E(true),o.style.display="block";let e=u();if(N(),e&&e.length>0&&e[0].focus(),s?.onExpandedChange)try{s.onExpandedChange(!0);}catch(t){console.error("[aria-ease] Error in menu onExpandedChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),E(false),o.style.display="none",x(),a.focus(),s?.onExpandedChange)try{s.onExpandedChange(!1);}catch(e){console.error("[aria-ease] Error in menu onExpandedChange callback:",e);}}function w(){a.getAttribute("aria-expanded")==="true"?l():H();}function v(e){if(!(a.getAttribute("aria-expanded")==="true"))return;let n=a.contains(e.target),r=o.contains(e.target);!n&&!r&&l();}a.addEventListener("click",w),document.addEventListener("click",v);function O(){x(),a.removeEventListener("click",w),document.removeEventListener("click",v),o.style.display="none",E(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){g=null,b=null;}return {openMenu:H,closeMenu:l,cleanup:O,refresh:q}}export{F as makeMenuAccessible};
|
package/dist/src/radio/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function L({radioGroupId:i,radiosClass:l,defaultSelectedIndex:d,callback:m}){if(i==="")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 s=document.querySelector(`#${i}`);if(!s)return console.error(`[aria-ease] Element with id="${i}" 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(s.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,f=new WeakMap,a;d&&(a=d);function h(){s.getAttribute("role")||s.setAttribute("role","radiogroup"),t.forEach((e,n)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let r=n===a;e.setAttribute("aria-checked",r?"true":"false"),e.checked!==void 0&&(e.checked=r);});}function c(e){if(e<0||e>=t.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}if(a>=0&&a<t.length&&(t[a].setAttribute("aria-checked","false"),t[a].checked!==void 0&&(t[a].checked=false)),t[e].setAttribute("aria-checked","true"),t[e].checked!==void 0&&(t[e].checked=true),t[e].focus(),m?.onValueChange)try{m.onValueChange(e,t[e].getAttribute("value"));}catch(n){console.error("[aria-ease] Error in radio onValueChange callback:",n);}a=e;}function b(e){return ()=>{let n=t[e];"checked"in n&&typeof n.checked=="boolean"?setTimeout(()=>{c(e);},0):c(e);}}function k(e){return n=>{let{key:r}=n,o=e;switch(r){case "ArrowDown":case "ArrowRight":n.preventDefault(),o=(e+1)%t.length,c(o);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),o=(e-1+t.length)%t.length,c(o);break;case " ":case "Enter":n.preventDefault(),c(e);break}}}function p(){t.forEach((e,n)=>{let r=b(n),o=k(n);e.addEventListener("click",r),e.addEventListener("keydown",o),u.set(e,o),f.set(e,r);});}function g(){t.forEach(e=>{let n=u.get(e),r=f.get(e);n&&(e.removeEventListener("keydown",n),u.delete(e)),r&&(e.removeEventListener("click",r),f.delete(e));});}function E(){g();}function A(){return a}return h(),p(),{selectRadio:c,getSelectedIndex:A,cleanup:E}}exports.makeRadioAccessible=L;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a radio group accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { R as RadioConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a radio group accessible by managing ARIA attributes, keyboard interaction, and state.
|
package/dist/src/radio/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function L({radioGroupId:i,radiosClass:l,defaultSelectedIndex:d,callback:m}){if(i==="")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 s=document.querySelector(`#${i}`);if(!s)return console.error(`[aria-ease] Element with id="${i}" 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(s.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,f=new WeakMap,a;d&&(a=d);function h(){s.getAttribute("role")||s.setAttribute("role","radiogroup"),t.forEach((e,n)=>{e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let r=n===a;e.setAttribute("aria-checked",r?"true":"false"),e.checked!==void 0&&(e.checked=r);});}function c(e){if(e<0||e>=t.length){console.error(`[aria-ease] Invalid radio index: ${e}`);return}if(a>=0&&a<t.length&&(t[a].setAttribute("aria-checked","false"),t[a].checked!==void 0&&(t[a].checked=false)),t[e].setAttribute("aria-checked","true"),t[e].checked!==void 0&&(t[e].checked=true),t[e].focus(),m?.onValueChange)try{m.onValueChange(e,t[e].getAttribute("value"));}catch(n){console.error("[aria-ease] Error in radio onValueChange callback:",n);}a=e;}function b(e){return ()=>{let n=t[e];"checked"in n&&typeof n.checked=="boolean"?setTimeout(()=>{c(e);},0):c(e);}}function k(e){return n=>{let{key:r}=n,o=e;switch(r){case "ArrowDown":case "ArrowRight":n.preventDefault(),o=(e+1)%t.length,c(o);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),o=(e-1+t.length)%t.length,c(o);break;case " ":case "Enter":n.preventDefault(),c(e);break}}}function p(){t.forEach((e,n)=>{let r=b(n),o=k(n);e.addEventListener("click",r),e.addEventListener("keydown",o),u.set(e,o),f.set(e,r);});}function g(){t.forEach(e=>{let n=u.get(e),r=f.get(e);n&&(e.removeEventListener("keydown",n),u.delete(e)),r&&(e.removeEventListener("click",r),f.delete(e));});}function E(){g();}function A(){return a}return h(),p(),{selectRadio:c,getSelectedIndex:A,cleanup:E}}export{L as makeRadioAccessible};
|
package/dist/src/tabs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function C({tabListId:u,tabsClass:f,tabPanelsClass:d,orientation:E="horizontal",activateOnFocus:M=true,callback:i}){if(u==="")return console.error("[aria-ease] 'tabListId' should not be an empty string. Provide an id to the tab list container element that exists before calling makeTabsAccessible."),{cleanup:()=>{}};let l=document.querySelector(`#${u}`);if(!l)return console.error(`[aria-ease] Element with id="${u}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(f==="")return console.error("[aria-ease] 'tabsClass' should not be an empty string. Provide a class name that exists on the tab button elements before calling makeTabsAccessible."),{cleanup:()=>{}};let r=Array.from(l.querySelectorAll(`.${f}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${f}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(d==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let s=Array.from(document.querySelectorAll(`.${d}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${d}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r.length!==s.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${r.length} tabs but ${s.length} panels.`),{cleanup:()=>{}};let p=new WeakMap,v=new WeakMap,k=new WeakMap,m=0;function g(){l.setAttribute("role","tablist"),l.setAttribute("aria-orientation",E),r.forEach((e,n)=>{let t=s[n];e.id||(e.id=`${u}-tab-${n}`),t.id||(t.id=`${u}-panel-${n}`),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.hidden=true,t.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||t.setAttribute("tabindex","0");}),b(0,false);}function b(e,n=true){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid tab index: ${e}`);return}r.forEach((o,h)=>{let A=s[h];o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),A.hidden=true;});let t=r[e],a=s[e];if(t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0"),a.hidden=false,n&&t.focus(),m=e,i?.onSelectedChange)try{i.onSelectedChange(e,!0);}catch(o){console.error("[aria-ease] Error in tabs onSelectedChange callback:",o);}}function c(e){let n=r.findIndex(o=>o===document.activeElement),t=n!==-1?n:m,a=t;switch(e){case "first":a=0;break;case "last":a=r.length-1;break;case "next":a=(t+1)%r.length;break;case "prev":a=(t-1+r.length)%r.length;break}if(r[a].focus(),r[a].setAttribute("tabindex","0"),r[m].setAttribute("tabindex","-1"),M)b(a,false);else {let o=m;r.forEach((h,A)=>{A===a?h.setAttribute("tabindex","0"):A!==o&&h.setAttribute("tabindex","-1");});}}function T(e){return ()=>{b(e);}}function w(e){return n=>{let{key:t}=n,a=false;if(E==="horizontal")switch(t){case "ArrowLeft":n.preventDefault(),c("prev"),a=true;break;case "ArrowRight":n.preventDefault(),c("next"),a=true;break}else switch(t){case "ArrowUp":n.preventDefault(),c("prev"),a=true;break;case "ArrowDown":n.preventDefault(),c("next"),a=true;break}if(!a)switch(t){case "Home":n.preventDefault(),c("first");break;case "End":n.preventDefault(),c("last");break;case " ":case "Enter":M||(n.preventDefault(),b(e));break;case "F10":if(n.shiftKey&&i?.onContextMenu){n.preventDefault();try{i.onContextMenu(e,r[e]);}catch(o){console.error("[aria-ease] Error in tabs onContextMenu callback:",o);}}break}}}function H(e){return n=>{if(i?.onContextMenu){n.preventDefault();try{i.onContextMenu(e,r[e]);}catch(t){console.error("[aria-ease] Error in tabs onContextMenu callback:",t);}}}}function x(){r.forEach((e,n)=>{let t=T(n),a=w(n),o=H(n);e.addEventListener("click",t),e.addEventListener("keydown",a),i?.onContextMenu&&(e.addEventListener("contextmenu",o),k.set(e,o)),p.set(e,a),v.set(e,t);});}function y(){r.forEach(e=>{let n=p.get(e),t=v.get(e),a=k.get(e);n&&(e.removeEventListener("keydown",n),p.delete(e)),t&&(e.removeEventListener("click",t),v.delete(e)),a&&(e.removeEventListener("contextmenu",a),k.delete(e));});}function L(){y(),r.forEach((e,n)=>{let t=s[n];e.removeAttribute("role"),e.removeAttribute("aria-selected"),e.removeAttribute("aria-controls"),e.removeAttribute("tabindex"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("tabindex"),t.hidden=false;}),l.removeAttribute("role"),l.removeAttribute("aria-orientation");}function $(){y();let e=Array.from(l.querySelectorAll(`.${f}`)),n=Array.from(document.querySelectorAll(`.${d}`));r.length=0,r.push(...e),s.length=0,s.push(...n),g(),x();}return g(),x(),{activateTab:b,cleanup:L,refresh:$}}exports.makeTabsAccessible=C;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes tabs accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -8,7 +8,6 @@ import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN
|
|
|
8
8
|
* @param {string} tabPanelsClass - The shared class of all tab panels.
|
|
9
9
|
* @param {('horizontal' | 'vertical')} orientation - Tab list orientation (default: 'horizontal').
|
|
10
10
|
* @param {boolean} activateOnFocus - Whether tabs activate automatically on focus (default: true).
|
|
11
|
-
* @param {TabsCallback} callback - Configuration options for callbacks.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
|
package/dist/src/tabs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes tabs accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -8,7 +8,6 @@ import { T as TabsConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN
|
|
|
8
8
|
* @param {string} tabPanelsClass - The shared class of all tab panels.
|
|
9
9
|
* @param {('horizontal' | 'vertical')} orientation - Tab list orientation (default: 'horizontal').
|
|
10
10
|
* @param {boolean} activateOnFocus - Whether tabs activate automatically on focus (default: true).
|
|
11
|
-
* @param {TabsCallback} callback - Configuration options for callbacks.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
|
package/dist/src/tabs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C({tabListId:u,tabsClass:f,tabPanelsClass:d,orientation:E="horizontal",activateOnFocus:M=true,callback:i}){if(u==="")return console.error("[aria-ease] 'tabListId' should not be an empty string. Provide an id to the tab list container element that exists before calling makeTabsAccessible."),{cleanup:()=>{}};let l=document.querySelector(`#${u}`);if(!l)return console.error(`[aria-ease] Element with id="${u}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(f==="")return console.error("[aria-ease] 'tabsClass' should not be an empty string. Provide a class name that exists on the tab button elements before calling makeTabsAccessible."),{cleanup:()=>{}};let r=Array.from(l.querySelectorAll(`.${f}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${f}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(d==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let s=Array.from(document.querySelectorAll(`.${d}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${d}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r.length!==s.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${r.length} tabs but ${s.length} panels.`),{cleanup:()=>{}};let p=new WeakMap,v=new WeakMap,k=new WeakMap,m=0;function g(){l.setAttribute("role","tablist"),l.setAttribute("aria-orientation",E),r.forEach((e,n)=>{let t=s[n];e.id||(e.id=`${u}-tab-${n}`),t.id||(t.id=`${u}-panel-${n}`),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.hidden=true,t.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||t.setAttribute("tabindex","0");}),b(0,false);}function b(e,n=true){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid tab index: ${e}`);return}r.forEach((o,h)=>{let A=s[h];o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),A.hidden=true;});let t=r[e],a=s[e];if(t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0"),a.hidden=false,n&&t.focus(),m=e,i?.onSelectedChange)try{i.onSelectedChange(e,!0);}catch(o){console.error("[aria-ease] Error in tabs onSelectedChange callback:",o);}}function c(e){let n=r.findIndex(o=>o===document.activeElement),t=n!==-1?n:m,a=t;switch(e){case "first":a=0;break;case "last":a=r.length-1;break;case "next":a=(t+1)%r.length;break;case "prev":a=(t-1+r.length)%r.length;break}if(r[a].focus(),r[a].setAttribute("tabindex","0"),r[m].setAttribute("tabindex","-1"),M)b(a,false);else {let o=m;r.forEach((h,A)=>{A===a?h.setAttribute("tabindex","0"):A!==o&&h.setAttribute("tabindex","-1");});}}function T(e){return ()=>{b(e);}}function w(e){return n=>{let{key:t}=n,a=false;if(E==="horizontal")switch(t){case "ArrowLeft":n.preventDefault(),c("prev"),a=true;break;case "ArrowRight":n.preventDefault(),c("next"),a=true;break}else switch(t){case "ArrowUp":n.preventDefault(),c("prev"),a=true;break;case "ArrowDown":n.preventDefault(),c("next"),a=true;break}if(!a)switch(t){case "Home":n.preventDefault(),c("first");break;case "End":n.preventDefault(),c("last");break;case " ":case "Enter":M||(n.preventDefault(),b(e));break;case "F10":if(n.shiftKey&&i?.onContextMenu){n.preventDefault();try{i.onContextMenu(e,r[e]);}catch(o){console.error("[aria-ease] Error in tabs onContextMenu callback:",o);}}break}}}function H(e){return n=>{if(i?.onContextMenu){n.preventDefault();try{i.onContextMenu(e,r[e]);}catch(t){console.error("[aria-ease] Error in tabs onContextMenu callback:",t);}}}}function x(){r.forEach((e,n)=>{let t=T(n),a=w(n),o=H(n);e.addEventListener("click",t),e.addEventListener("keydown",a),i?.onContextMenu&&(e.addEventListener("contextmenu",o),k.set(e,o)),p.set(e,a),v.set(e,t);});}function y(){r.forEach(e=>{let n=p.get(e),t=v.get(e),a=k.get(e);n&&(e.removeEventListener("keydown",n),p.delete(e)),t&&(e.removeEventListener("click",t),v.delete(e)),a&&(e.removeEventListener("contextmenu",a),k.delete(e));});}function L(){y(),r.forEach((e,n)=>{let t=s[n];e.removeAttribute("role"),e.removeAttribute("aria-selected"),e.removeAttribute("aria-controls"),e.removeAttribute("tabindex"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("tabindex"),t.hidden=false;}),l.removeAttribute("role"),l.removeAttribute("aria-orientation");}function $(){y();let e=Array.from(l.querySelectorAll(`.${f}`)),n=Array.from(document.querySelectorAll(`.${d}`));r.length=0,r.push(...e),s.length=0,s.push(...n),g(),x();}return g(),x(),{activateTab:b,cleanup:L,refresh:$}}export{C as makeTabsAccessible};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function v({toggleId:a,togglesClass:o,isSingleToggle:b=true,callback:u}){if(a==="")return console.error("[aria-ease] 'toggleId' should not be an empty string. Provide an id to the toggle element or toggle container before calling makeToggleAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${a}`);if(!s)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let r;if(b)r=[s];else {if(!o)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(r=Array.from(s.querySelectorAll(`.${o}`)),r.length===0)return console.error(`[aria-ease] No elements with class="${o}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,l=new WeakMap;function m(){r.forEach(e=>{e.tagName.toLowerCase()!=="button"&&!e.getAttribute("role")&&e.setAttribute("role","button"),e.hasAttribute("aria-pressed")||e.setAttribute("aria-pressed","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function c(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid toggle index: ${e}`);return}let n=r[e].getAttribute("aria-pressed")==="true";d(e,!n);}function d(e,t){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid toggle index: ${e}`);return}if(r[e].setAttribute("aria-pressed",t?"true":"false"),u?.onPressedChange)try{u.onPressedChange(e,t);}catch(n){console.error("[aria-ease] Error in checkbox onPressedChange callback:",n);}}function g(e){return ()=>{c(e);}}function h(e){return t=>{let{key:n}=t;switch(n){case "Enter":case " ":t.preventDefault(),c(e);break}}}function p(){r.forEach((e,t)=>{let n=g(t),f=h(t);e.addEventListener("click",n),e.addEventListener("keydown",f),i.set(e,f),l.set(e,n);});}function k(){r.forEach(e=>{let t=i.get(e),n=l.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),n&&(e.removeEventListener("click",n),l.delete(e));});}function E(){k();}function A(){return r.map(e=>e.getAttribute("aria-pressed")==="true")}function T(){return r.map((e,t)=>e.getAttribute("aria-pressed")==="true"?t:-1).filter(e=>e!==-1)}return m(),p(),{toggleButton:c,setPressed:d,getPressedStates:A,getPressedIndices:T,cleanup:E}}exports.makeToggleAccessible=v;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { c as ToggleConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
|
|
@@ -8,11 +8,6 @@ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
|
|
|
8
8
|
* @param {boolean} isSingleToggle - Whether this is a single toggle button (default: true).
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
toggleId: string;
|
|
13
|
-
togglesClass?: string;
|
|
14
|
-
isSingleToggle?: boolean;
|
|
15
|
-
}
|
|
16
|
-
declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }: ToggleConfig): AccessibilityInstance;
|
|
11
|
+
declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle, callback }: ToggleConfig): AccessibilityInstance;
|
|
17
12
|
|
|
18
13
|
export { makeToggleAccessible };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AccessibilityInstance } from '../Types.d-
|
|
1
|
+
import { c as ToggleConfig, a as AccessibilityInstance } from '../Types.d-BjBTlIzl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
|
|
@@ -8,11 +8,6 @@ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
|
|
|
8
8
|
* @param {boolean} isSingleToggle - Whether this is a single toggle button (default: true).
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
toggleId: string;
|
|
13
|
-
togglesClass?: string;
|
|
14
|
-
isSingleToggle?: boolean;
|
|
15
|
-
}
|
|
16
|
-
declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle }: ToggleConfig): AccessibilityInstance;
|
|
11
|
+
declare function makeToggleAccessible({ toggleId, togglesClass, isSingleToggle, callback }: ToggleConfig): AccessibilityInstance;
|
|
17
12
|
|
|
18
13
|
export { makeToggleAccessible };
|
package/dist/src/toggle/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function v({toggleId:a,togglesClass:o,isSingleToggle:b=true,callback:u}){if(a==="")return console.error("[aria-ease] 'toggleId' should not be an empty string. Provide an id to the toggle element or toggle container before calling makeToggleAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${a}`);if(!s)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let r;if(b)r=[s];else {if(!o)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(r=Array.from(s.querySelectorAll(`.${o}`)),r.length===0)return console.error(`[aria-ease] No elements with class="${o}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,l=new WeakMap;function m(){r.forEach(e=>{e.tagName.toLowerCase()!=="button"&&!e.getAttribute("role")&&e.setAttribute("role","button"),e.hasAttribute("aria-pressed")||e.setAttribute("aria-pressed","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function c(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid toggle index: ${e}`);return}let n=r[e].getAttribute("aria-pressed")==="true";d(e,!n);}function d(e,t){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid toggle index: ${e}`);return}if(r[e].setAttribute("aria-pressed",t?"true":"false"),u?.onPressedChange)try{u.onPressedChange(e,t);}catch(n){console.error("[aria-ease] Error in checkbox onPressedChange callback:",n);}}function g(e){return ()=>{c(e);}}function h(e){return t=>{let{key:n}=t;switch(n){case "Enter":case " ":t.preventDefault(),c(e);break}}}function p(){r.forEach((e,t)=>{let n=g(t),f=h(t);e.addEventListener("click",n),e.addEventListener("keydown",f),i.set(e,f),l.set(e,n);});}function k(){r.forEach(e=>{let t=i.get(e),n=l.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),n&&(e.removeEventListener("click",n),l.delete(e));});}function E(){k();}function A(){return r.map(e=>e.getAttribute("aria-pressed")==="true")}function T(){return r.map((e,t)=>e.getAttribute("aria-pressed")==="true"?t:-1).filter(e=>e!==-1)}return m(),p(),{toggleButton:c,setPressed:d,getPressedStates:A,getPressedIndices:T,cleanup:E}}export{v as makeToggleAccessible};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {expect}from'@playwright/test';var s=class{constructor(e,o,r=400,t=400){this.mainSelector=e;this.selectors=o;this.actionTimeoutMs=r;this.assertionTimeoutMs=t;}async resetState(e){if(!this.selectors.toggle||!this.selectors.relative)return;let o=this.selectors.toggle;if(!o)return;let r=await e.locator(o).all();for(let t of r)if(await t.getAttribute("aria-pressed")==="true"){await t.click({timeout:this.actionTimeoutMs});let i=e.locator(`#${t}`);await expect(i).toHaveAttribute("aria-pressed","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};export{s as ToggleComponentStrategy};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-WIWSYIGK.js';import {d,a,c,e}from'./chunk-APUMBDOT.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ne=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-QHVBLUBR.js').then(t=>t.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>import('./AccordionComponentStrategy-S35ZYITU.js').then(t=>t.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>import('./ComboboxComponentStrategy-5AWO63DA.js').then(t=>t.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>import('./TabsComponentStrategy-DTQQUCK2.js').then(t=>t.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>import('./RadioComponentStrategy-TWMIMSYX.js').then(t=>t.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>import('./CheckboxComponentStrategy-ST2DWNYT.js').then(t=>t.CheckboxComponentStrategy));}async loadStrategy(t,s,r){try{if(s)try{let n=ge.isAbsolute(s)?s:ge.resolve(r||process.cwd(),s),u=await import(pathToFileURL(n).href),i=u.default||u;if(!i)throw new Error(`No default export found in ${s}`);return i}catch(n){throw new Error(`Failed to load custom strategy from ${s}: ${n instanceof Error?n.message:String(n)}`)}let o=this.builtInStrategies.get(t);return o?o():null}catch(o){throw new Error(`Strategy loading failed for ${t}: ${o instanceof Error?o.message:String(o)}`)}}has(t,s){return !!s||this.builtInStrategies.has(t)}};var oe=class{static strategyRegistry=new ne;static isComponentConfig(t){return typeof t=="object"&&t!==null}static async detect(t,s,r=400,o=400,n){let u=this.isComponentConfig(s)?s:void 0,i=u?.contractPath;if(!i)throw new Error(`Contract path not found for component: ${t}`);let R=(()=>{if(ge.isAbsolute(i))return i;if(n){let re=ge.resolve(n,i);try{return readFileSync(re,"utf-8"),re}catch{}}let X=ge.resolve(process.cwd(),i);try{return readFileSync(X,"utf-8"),X}catch{return new URL(i,import.meta.url).pathname}})(),C=readFileSync(R,"utf-8"),ee=JSON.parse(C).selectors,_=await this.strategyRegistry.loadStrategy(t,u?.strategyPath,n);if(!_)return null;let z=ee.main;return t==="tabs"?new _(z,ee):new _(z,ee,r,o)}};var ae=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(t=false,s=false){this.isPlaywright=t,this.isCustomContract=s;}log(t){process.stderr.write(t+`
|
|
1
|
+
import {a as a$1}from'./chunk-WIWSYIGK.js';import {d,a,c,e}from'./chunk-APUMBDOT.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ne=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-QHVBLUBR.js').then(t=>t.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>import('./AccordionComponentStrategy-S35ZYITU.js').then(t=>t.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>import('./ComboboxComponentStrategy-5AWO63DA.js').then(t=>t.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>import('./TabsComponentStrategy-DTQQUCK2.js').then(t=>t.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>import('./RadioComponentStrategy-TWMIMSYX.js').then(t=>t.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>import('./CheckboxComponentStrategy-ST2DWNYT.js').then(t=>t.CheckboxComponentStrategy)),this.builtInStrategies.set("toggle",()=>import('./ToggleComponentStrategy-UOGYK2U4.js').then(t=>t.ToggleComponentStrategy));}async loadStrategy(t,s,r){try{if(s)try{let n=ge.isAbsolute(s)?s:ge.resolve(r||process.cwd(),s),u=await import(pathToFileURL(n).href),i=u.default||u;if(!i)throw new Error(`No default export found in ${s}`);return i}catch(n){throw new Error(`Failed to load custom strategy from ${s}: ${n instanceof Error?n.message:String(n)}`)}let o=this.builtInStrategies.get(t);return o?o():null}catch(o){throw new Error(`Strategy loading failed for ${t}: ${o instanceof Error?o.message:String(o)}`)}}has(t,s){return !!s||this.builtInStrategies.has(t)}};var oe=class{static strategyRegistry=new ne;static isComponentConfig(t){return typeof t=="object"&&t!==null}static async detect(t,s,r=400,o=400,n){let u=this.isComponentConfig(s)?s:void 0,i=u?.contractPath;if(!i)throw new Error(`Contract path not found for component: ${t}`);let R=(()=>{if(ge.isAbsolute(i))return i;if(n){let re=ge.resolve(n,i);try{return readFileSync(re,"utf-8"),re}catch{}}let X=ge.resolve(process.cwd(),i);try{return readFileSync(X,"utf-8"),X}catch{return new URL(i,import.meta.url).pathname}})(),C=readFileSync(R,"utf-8"),ee=JSON.parse(C).selectors,_=await this.strategyRegistry.loadStrategy(t,u?.strategyPath,n);if(!_)return null;let z=ee.main;return t==="tabs"?new _(z,ee):new _(z,ee,r,o)}};var ae=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(t=false,s=false){this.isPlaywright=t,this.isCustomContract=s;}log(t){process.stderr.write(t+`
|
|
2
2
|
`);}start(t,s,r){this.startTime=Date.now(),this.componentName=t,this.totalTests=s,this.hasPrintedStaticSection=false,this.hasPrintedDynamicSection=false,r&&(this.apgUrl=r);let o="Playwright (Real Browser)";this.log(`
|
|
3
3
|
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${t.charAt(0).toUpperCase()+t.slice(1)} Component - ${o}`),this.log(`${"\u2550".repeat(60)}
|
|
4
4
|
`);}reportStatic(t,s,r=0){this.staticPasses=t,this.staticFailures=s,this.staticWarnings=r;}reportStaticTest(t,s,r,o){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=true);let n=s==="pass"?"\u2713":s==="warn"?"\u26A0":s==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${t}`),o&&this.log(` \u21B3 level=${o}`),(s==="fail"||s==="warn"||s==="skip")&&r&&this.log(` \u21B3 ${r}`);}reportTest(t,s,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=true);let o={description:t.description,status:s,failureMessage:r,level:t.level};s==="skip"&&(o.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(o);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},u=t.level?`[${t.level.toUpperCase()}] `:"";this.log(` ${n[s]} ${u}${t.description}`),s==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),s==="fail"&&r&&this.log(` \u21B3 ${r}`),s==="warn"&&r&&this.log(` \u21B3 ${r}`),s==="skip"&&r&&this.log(` \u21B3 ${r}`);}reportFailures(t){t.length!==0&&(this.log(`
|