aria-ease 7.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import{b as U,d as V}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Le({accordionId:c,triggersClass:n,panelsClass:h,allowMultipleOpen:o=!1,callback:s}){let i=document.querySelector(`#${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};let e=Array.from(i.querySelectorAll(`.${n}`));if(e.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};let t=Array.from(i.querySelectorAll(`.${h}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e.length!==t.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${e.length} triggers but ${t.length} panels.`),{cleanup:()=>{}};let r=new WeakMap,m=new WeakMap;function p(){e.forEach((g,T)=>{let L=t[T];g.id||(g.id=`${c}-trigger-${T}`),L.id||(L.id=`${c}-panel-${T}`),g.setAttribute("aria-controls",L.id),g.setAttribute("aria-expanded","false"),(!o||e.length<=6)&&L.setAttribute("role","region"),L.setAttribute("aria-labelledby",g.id),L.style.display="none"})}function v(g){if(g<0||g>=e.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let T=e[g],L=t[g];if(T.setAttribute("aria-expanded","true"),L.style.display="block",s?.onExpand)try{s.onExpand(g)}catch(d){console.error("[aria-ease] Error in accordion onExpand callback:",d)}}function A(g){if(g<0||g>=e.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let T=e[g],L=t[g];if(T.setAttribute("aria-expanded","false"),L.style.display="none",s?.onCollapse)try{s.onCollapse(g)}catch(d){console.error("[aria-ease] Error in accordion onCollapse callback:",d)}}function H(g){e[g].getAttribute("aria-expanded")==="true"?A(g):(o||e.forEach((d,w)=>{w!==g&&A(w)}),v(g))}function C(g){return()=>{H(g)}}function $(g){return T=>{let{key:L}=T;switch(L){case"Enter":case" ":T.preventDefault(),H(g);break;case"ArrowDown":T.preventDefault();{let d=(g+1)%e.length;e[d].focus()}break;case"ArrowUp":T.preventDefault();{let d=(g-1+e.length)%e.length;e[d].focus()}break;case"Home":T.preventDefault(),e[0].focus();break;case"End":T.preventDefault(),e[e.length-1].focus();break}}}function a(){e.forEach((g,T)=>{let L=C(T),d=$(T);g.addEventListener("click",L),g.addEventListener("keydown",d),r.set(g,d),m.set(g,L)})}function l(){e.forEach(g=>{let T=r.get(g),L=m.get(g);T&&(g.removeEventListener("keydown",T),r.delete(g)),L&&(g.removeEventListener("click",L),m.delete(g))})}function k(){l(),e.forEach((g,T)=>{A(T)})}function x(){l();let g=Array.from(i.querySelectorAll(`.${n}`)),T=Array.from(i.querySelectorAll(`.${h}`));e.length=0,e.push(...g),t.length=0,t.push(...T),p(),a()}return p(),a(),{expandItem:v,collapseItem:A,toggleItem:H,cleanup:k,refresh:x}}function P(c){if(c.tagName!=="INPUT")return!1;let n=c.type;return["text","email","password","tel","number"].includes(n)}function N(c){return c.tagName==="TEXTAREA"}function z(c){return c.tagName==="BUTTON"||c.tagName==="INPUT"&&["button","submit","reset"].includes(c.type)}function ee(c){return c.tagName==="A"}function F(c,n,h){let o=c.length,s=(n+h+o)%o;c.item(s).focus()}function te(c){return c.getAttribute("data-custom-click")!==null&&c.getAttribute("data-custom-click")!==void 0}function W(c,n,h){let o=n.item(h);switch(c.key){case"ArrowUp":case"ArrowLeft":{(!P(o)&&!N(o)||(P(o)||N(o))&&o.selectionStart===0)&&(c.preventDefault(),F(n,h,-1));break}case"ArrowDown":case"ArrowRight":{if(!P(o)&&!N(o))c.preventDefault(),F(n,h,1);else if(P(o)||N(o)){let s=o.value;o.selectionStart===s.length&&(c.preventDefault(),F(n,h,1))}break}case"Escape":{c.preventDefault();break}case"Enter":case" ":{(!z(o)&&!ee(o)&&te(o)||z(o))&&(c.preventDefault(),o.click());break}case"Tab":break;default:break}}function Se({blockId:c,blockItemsClass:n}){let h=document.querySelector(`#${c}`);if(!h)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};let o=null;function s(){return o||(o=h.querySelectorAll(`.${n}`)),o}let i=s();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let e=new Map;i.forEach(m=>{if(!e.has(m)){let p=v=>{let A=h.querySelectorAll(`.${n}`),H=Array.prototype.indexOf.call(A,m);W(v,A,H)};m.addEventListener("keydown",p),e.set(m,p)}});function t(){i.forEach(m=>{let p=e.get(m);p&&(m.removeEventListener("keydown",p),e.delete(m))})}function r(){o=null}return{cleanup:t,refresh:r}}function $e({checkboxGroupId:c,checkboxesClass:n}){let h=document.querySelector(`#${c}`);if(!h)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let o=Array.from(h.querySelectorAll(`.${n}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let s=new WeakMap,i=new WeakMap;function e(){h.getAttribute("role")||h.setAttribute("role","group"),o.forEach(a=>{a.setAttribute("role","checkbox"),a.hasAttribute("aria-checked")||a.setAttribute("aria-checked","false"),a.hasAttribute("tabindex")||a.setAttribute("tabindex","0")})}function t(a){if(a<0||a>=o.length){console.error(`[aria-ease] Invalid checkbox index: ${a}`);return}let l=o[a],k=l.getAttribute("aria-checked")==="true";l.setAttribute("aria-checked",k?"false":"true")}function r(a,l){if(a<0||a>=o.length){console.error(`[aria-ease] Invalid checkbox index: ${a}`);return}o[a].setAttribute("aria-checked",l?"true":"false")}function m(a){return()=>{t(a)}}function p(a){return l=>{let{key:k}=l;switch(k){case" ":l.preventDefault(),t(a);break}}}function v(){o.forEach((a,l)=>{let k=m(l),x=p(l);a.addEventListener("click",k),a.addEventListener("keydown",x),s.set(a,x),i.set(a,k)})}function A(){o.forEach(a=>{let l=s.get(a),k=i.get(a);l&&(a.removeEventListener("keydown",l),s.delete(a)),k&&(a.removeEventListener("click",k),i.delete(a))})}function H(){A()}function C(){return o.map(a=>a.getAttribute("aria-checked")==="true")}function $(){return o.map((a,l)=>a.getAttribute("aria-checked")==="true"?l:-1).filter(a=>a!==-1)}return e(),v(),{toggleCheckbox:t,setCheckboxState:r,getCheckedStates:C,getCheckedIndices:$,cleanup:H}}function ne({menuId:c,menuItemsClass:n,triggerId:h,callback:o}){let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${h}`);if(!i)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(c))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",c),i.setAttribute("aria-expanded","false"),s.setAttribute("role","menu"),s.setAttribute("aria-labelledby",h);let e=new WeakMap,t=new Map,r=null,m=null;function p(){return r||(r=s.querySelectorAll(`.${n}`)),r}function v(){if(!m){let f=p();m=[];for(let y=0;y<f.length;y++){let M=f.item(y),D=x(M),I=M.getAttribute("aria-disabled")==="true";D||(M.hasAttribute("tabindex")||M.setAttribute("tabindex","-1"),I||m.push(M))}}return m}function A(f){return{length:f.length,item:M=>f[M],forEach:M=>{f.forEach(M)},[Symbol.iterator]:function*(){for(let M of f)yield M}}}function H(){p().forEach(y=>{y.setAttribute("role","menuitem");let M=y.getAttribute("data-submenu-id")??y.getAttribute("aria-controls"),D=y.hasAttribute("aria-haspopup")&&M;M&&(y.hasAttribute("data-submenu-id")||D)&&(y.setAttribute("aria-haspopup","menu"),y.setAttribute("aria-controls",M),y.hasAttribute("aria-expanded")||y.setAttribute("aria-expanded","false"))})}function C(f,y,M){let D=f.length,I=(y+M+D)%D;f.item(I).focus()}function $(f,y){f.length!==0&&f[y]?.focus()}function a(f){return f.hasAttribute("aria-controls")&&f.hasAttribute("aria-haspopup")&&f.getAttribute("role")==="menuitem"}function l(f){let y=f;for(;y&&y.getAttribute("role")==="menuitem";){let M=y.closest('[role="menu"]');if(!M)break;M.style.display="none",y.setAttribute("aria-expanded","false");let D=M.getAttribute("aria-labelledby");if(!D)break;let I=document.getElementById(D);if(!I)break;y=I}}H();function k(f,y,M){switch(f.key){case"ArrowLeft":{if(f.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){f.preventDefault(),b();return}break}case"ArrowUp":{f.preventDefault(),C(A(v()),M,-1);break}case"ArrowRight":{if(f.key==="ArrowRight"&&a(y)){f.preventDefault();let D=y.getAttribute("aria-controls");if(D){T(D);return}}break}case"ArrowDown":{f.preventDefault(),C(A(v()),M,1);break}case"Home":{f.preventDefault(),$(v(),0);break}case"End":{f.preventDefault();let D=v();$(D,D.length-1);break}case"Escape":{f.preventDefault(),b(),i.focus(),L&&L(!1);break}case"Enter":case" ":{if(f.preventDefault(),a(y)){let D=y.getAttribute("aria-controls");if(D){T(D);return}}y.click(),b(),L&&L(!1);break}case"Tab":{b(),l(i),L&&L(!1);break}default:break}}function x(f){let y=f.parentElement;for(;y&&y!==s;){if(y.getAttribute("role")==="menu"||y.id&&s.querySelector(`[aria-controls="${y.id}"]`))return!0;y=y.parentElement}return!1}function g(f){i.setAttribute("aria-expanded",f?"true":"false")}function T(f){let y=t.get(f);if(!y){let M=s.querySelector(`[aria-controls="${f}"]`);if(!M){console.error(`[aria-ease] Submenu trigger with aria-controls="${f}" not found in menu "${c}".`);return}if(!M.id){let I=`trigger-${f}`;M.id=I,console.warn(`[aria-ease] Submenu trigger for "${f}" had no ID. Auto-generated ID: "${I}".`)}if(!document.querySelector(`#${f}`)){console.error(`[aria-ease] Submenu element with id="${f}" not found. Cannot create submenu instance.`);return}y=ne({menuId:f,menuItemsClass:n,triggerId:M.id,callback:o}),t.set(f,y)}y.openMenu()}function L(f){if(o?.onOpenChange)try{o.onOpenChange(f)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function d(){v().forEach((y,M)=>{if(!e.has(y)){let D=I=>k(I,y,M);y.addEventListener("keydown",D),e.set(y,D)}})}function w(){v().forEach(y=>{let M=e.get(y);M&&(y.removeEventListener("keydown",M),e.delete(y))})}function u(){g(!0),s.style.display="block";let f=v();if(d(),f&&f.length>0&&f[0].focus(),o?.onOpenChange)try{o.onOpenChange(!0)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function b(){if(t.forEach(f=>f.closeMenu()),g(!1),s.style.display="none",w(),i.focus(),o?.onOpenChange)try{o.onOpenChange(!1)}catch(f){console.error("[aria-ease] Error in menu onOpenChange callback:",f)}}function E(){i.getAttribute("aria-expanded")==="true"?b():u()}function S(f){if(!(i.getAttribute("aria-expanded")==="true"))return;let M=i.contains(f.target),D=s.contains(f.target);!M&&!D&&b()}i.addEventListener("click",E),document.addEventListener("click",S);function q(){w(),i.removeEventListener("click",E),document.removeEventListener("click",S),s.style.display="none",g(!1),t.forEach(f=>f.cleanup()),t.clear()}function O(){r=null,m=null}return{openMenu:u,closeMenu:b,cleanup:q,refresh:O}}function Oe({radioGroupId:c,radiosClass:n,defaultSelectedIndex:h=0}){let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};let s=Array.from(o.querySelectorAll(`.${n}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let i=new WeakMap,e=new WeakMap,t=h;function r(){o.getAttribute("role")||o.setAttribute("role","radiogroup"),s.forEach((a,l)=>{a.setAttribute("role","radio"),a.setAttribute("tabindex",l===t?"0":"-1"),l===t?a.setAttribute("aria-checked","true"):a.setAttribute("aria-checked","false")})}function m(a){if(a<0||a>=s.length){console.error(`[aria-ease] Invalid radio index: ${a}`);return}t>=0&&t<s.length&&(s[t].setAttribute("aria-checked","false"),s[t].setAttribute("tabindex","-1")),s[a].setAttribute("aria-checked","true"),s[a].setAttribute("tabindex","0"),s[a].focus(),t=a}function p(a){return()=>{m(a)}}function v(a){return l=>{let{key:k}=l,x=a;switch(k){case"ArrowDown":case"ArrowRight":l.preventDefault(),x=(a+1)%s.length,m(x);break;case"ArrowUp":case"ArrowLeft":l.preventDefault(),x=(a-1+s.length)%s.length,m(x);break;case" ":case"Enter":l.preventDefault(),m(a);break}}}function A(){s.forEach((a,l)=>{let k=p(l),x=v(l);a.addEventListener("click",k),a.addEventListener("keydown",x),i.set(a,x),e.set(a,k)})}function H(){s.forEach(a=>{let l=i.get(a),k=e.get(a);l&&(a.removeEventListener("keydown",l),i.delete(a)),k&&(a.removeEventListener("click",k),e.delete(a))})}function C(){H()}function $(){return t}return r(),A(),{selectRadio:m,getSelectedIndex:$,cleanup:C}}function Ne({toggleId:c,togglesClass:n,isSingleToggle:h=!0}){let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let s;if(h)s=[o];else{if(!n)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(s=Array.from(o.querySelectorAll(`.${n}`)),s.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,e=new WeakMap;function t(){s.forEach(l=>{l.tagName.toLowerCase()!=="button"&&!l.getAttribute("role")&&l.setAttribute("role","button"),l.hasAttribute("aria-pressed")||l.setAttribute("aria-pressed","false"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","0")})}function r(l){if(l<0||l>=s.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}let k=s[l],x=k.getAttribute("aria-pressed")==="true";k.setAttribute("aria-pressed",x?"false":"true")}function m(l,k){if(l<0||l>=s.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}s[l].setAttribute("aria-pressed",k?"true":"false")}function p(l){return()=>{r(l)}}function v(l){return k=>{let{key:x}=k;switch(x){case"Enter":case" ":k.preventDefault(),r(l);break}}}function A(){s.forEach((l,k)=>{let x=p(k),g=v(k);l.addEventListener("click",x),l.addEventListener("keydown",g),i.set(l,g),e.set(l,x)})}function H(){s.forEach(l=>{let k=i.get(l),x=e.get(l);k&&(l.removeEventListener("keydown",k),i.delete(l)),x&&(l.removeEventListener("click",x),e.delete(l))})}function C(){H()}function $(){return s.map(l=>l.getAttribute("aria-pressed")==="true")}function a(){return s.map((l,k)=>l.getAttribute("aria-pressed")==="true"?k:-1).filter(l=>l!==-1)}return t(),A(),{toggleButton:r,setPressed:m,getPressedStates:$,getPressedIndices:a,cleanup:C}}function Re({comboboxInputId:c,comboboxButtonId:n,listBoxId:h,listBoxItemsClass:o,callback:s}){let i=document.getElementById(`${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let e=document.getElementById(`${h}`);if(!e)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let t=n?document.getElementById(`${n}`):null,r=-1;i.setAttribute("role","combobox"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-controls",h),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","listbox"),e.setAttribute("role","listbox");let m=null;function p(){return m||(m=e.querySelectorAll(`.${o}`)),Array.from(m).filter(u=>!u.hidden&&u.style.display!=="none")}function v(){return i.getAttribute("aria-expanded")==="true"}function A(u){let b=p();if(u>=0&&u<b.length){let E=b[u],S=E.id||`${h}-option-${u}`;if(E.id||(E.id=S),i.setAttribute("aria-activedescendant",S),typeof E.scrollIntoView=="function"&&E.scrollIntoView({block:"nearest",behavior:"smooth"}),s?.onActiveDescendantChange)try{s.onActiveDescendantChange(S,E)}catch(q){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",q)}}else i.setAttribute("aria-activedescendant","");r=u}function H(){if(i.setAttribute("aria-expanded","true"),e.style.display="block",s?.onOpenChange)try{s.onOpenChange(!0)}catch(u){console.error("[aria-ease] Error in combobox onOpenChange callback:",u)}}function C(){if(i.setAttribute("aria-expanded","false"),i.setAttribute("aria-activedescendant",""),e.style.display="none",r=-1,s?.onOpenChange)try{s.onOpenChange(!1)}catch(u){console.error("[aria-ease] Error in combobox onOpenChange callback:",u)}}function $(u){let b=u.textContent?.trim()||"";if(i.value=b,u.setAttribute("aria-selected","true"),C(),s?.onSelect)try{s.onSelect(u)}catch(E){console.error("[aria-ease] Error in combobox onSelect callback:",E)}}function a(u){let b=p(),E=v();switch(u.key){case"ArrowDown":if(u.preventDefault(),!E){H();return}if(b.length===0)return;{let S=r>=b.length-1?0:r+1;A(S)}break;case"ArrowUp":if(u.preventDefault(),!E)return;if(b.length>0){let S=r<=0?b.length-1:r-1;A(S)}break;case"Enter":E&&r>=0&&r<b.length&&(u.preventDefault(),$(b[r]));break;case"Escape":if(E)u.preventDefault(),C();else if(i.value&&(u.preventDefault(),i.value="",i.setAttribute("aria-activedescendant",""),p().forEach(q=>{q.getAttribute("aria-selected")==="true"&&q.setAttribute("aria-selected","false")}),s?.onClear))try{s.onClear()}catch(q){console.error("[aria-ease] Error in combobox onClear callback:",q)}break;case"Home":E&&b.length>0&&(u.preventDefault(),A(0));break;case"End":E&&b.length>0&&(u.preventDefault(),A(b.length-1));break;case"Tab":E&&r>=0&&r<b.length&&$(b[r]),E&&C();break}}function l(u){let b=u.target;if(b.classList.contains(o)){let S=p().indexOf(b);S>=0&&A(S)}}function k(u){let b=u.target;b.classList.contains(o)&&(u.preventDefault(),$(b))}function x(u){let b=u.target;!i.contains(b)&&!e.contains(b)&&(!t||!t.contains(b))&&C()}function g(){v()?C():(H(),i.focus())}function T(u){(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),g())}i.addEventListener("keydown",a),e.addEventListener("mousemove",l),e.addEventListener("mousedown",k),document.addEventListener("mousedown",x),t&&(t.setAttribute("tabindex","-1"),t.setAttribute("aria-label","Toggle options"),t.addEventListener("click",g),t.addEventListener("keydown",T));function L(){let u=e.querySelectorAll(`.${o}`);if(u.length===0)return;let b=null;for(let E of u)if(E.getAttribute("aria-selected")==="true"){b=E.textContent?.trim()||null;break}!b&&i.value&&(b=i.value.trim()),u.forEach((E,S)=>{E.setAttribute("role","option");let q=E.textContent?.trim()||"";b&&q===b?E.setAttribute("aria-selected","true"):E.setAttribute("aria-selected","false");let O=E.getAttribute("id");if(!O||O===""){let f=`${h}-option-${S}`;E.id=f,E.setAttribute("id",f)}})}L();function d(){i.removeEventListener("keydown",a),e.removeEventListener("mousemove",l),e.removeEventListener("mousedown",k),document.removeEventListener("mousedown",x),t&&(t.removeEventListener("click",g),t.removeEventListener("keydown",T))}function w(){m=null,L(),r=-1,A(-1)}return{cleanup:d,refresh:w,openListbox:H,closeListbox:C}}function _e({tabListId:c,tabsClass:n,tabPanelsClass:h,orientation:o="horizontal",activateOnFocus:s=!0,callback:i}){let e=document.querySelector(`#${c}`);if(!e)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};let t=Array.from(e.querySelectorAll(`.${n}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};let r=Array.from(document.querySelectorAll(`.${h}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t.length!==r.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${t.length} tabs but ${r.length} panels.`),{cleanup:()=>{}};let m=new WeakMap,p=new WeakMap,v=new WeakMap,A=0;function H(){e.setAttribute("role","tablist"),e.setAttribute("aria-orientation",o),t.forEach((d,w)=>{let u=r[w];d.id||(d.id=`${c}-tab-${w}`),u.id||(u.id=`${c}-panel-${w}`),d.setAttribute("role","tab"),d.setAttribute("aria-controls",u.id),d.setAttribute("aria-selected","false"),d.setAttribute("tabindex","-1"),u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",d.id),u.hidden=!0,u.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||u.setAttribute("tabindex","0")}),C(0,!1)}function C(d,w=!0){if(d<0||d>=t.length){console.error(`[aria-ease] Invalid tab index: ${d}`);return}let u=A;t.forEach((S,q)=>{let O=r[q];S.setAttribute("aria-selected","false"),S.setAttribute("tabindex","-1"),O.hidden=!0});let b=t[d],E=r[d];if(b.setAttribute("aria-selected","true"),b.setAttribute("tabindex","0"),E.hidden=!1,w&&b.focus(),A=d,i?.onTabChange&&u!==d)try{i.onTabChange(d,u)}catch(S){console.error("[aria-ease] Error in tabs onTabChange callback:",S)}}function $(d){let w=t.findIndex(E=>E===document.activeElement),u=w!==-1?w:A,b=u;switch(d){case"first":b=0;break;case"last":b=t.length-1;break;case"next":b=(u+1)%t.length;break;case"prev":b=(u-1+t.length)%t.length;break}if(t[b].focus(),t[b].setAttribute("tabindex","0"),t[A].setAttribute("tabindex","-1"),s)C(b,!1);else{let E=A;t.forEach((S,q)=>{q===b?S.setAttribute("tabindex","0"):q!==E&&S.setAttribute("tabindex","-1")})}}function a(d){return()=>{C(d)}}function l(d){return w=>{let{key:u}=w,b=!1;if(o==="horizontal")switch(u){case"ArrowLeft":w.preventDefault(),$("prev"),b=!0;break;case"ArrowRight":w.preventDefault(),$("next"),b=!0;break}else switch(u){case"ArrowUp":w.preventDefault(),$("prev"),b=!0;break;case"ArrowDown":w.preventDefault(),$("next"),b=!0;break}if(!b)switch(u){case"Home":w.preventDefault(),$("first");break;case"End":w.preventDefault(),$("last");break;case" ":case"Enter":s||(w.preventDefault(),C(d));break;case"F10":if(w.shiftKey&&i?.onContextMenu){w.preventDefault();try{i.onContextMenu(d,t[d])}catch(E){console.error("[aria-ease] Error in tabs onContextMenu callback:",E)}}break}}}function k(d){return w=>{if(i?.onContextMenu){w.preventDefault();try{i.onContextMenu(d,t[d])}catch(u){console.error("[aria-ease] Error in tabs onContextMenu callback:",u)}}}}function x(){t.forEach((d,w)=>{let u=a(w),b=l(w),E=k(w);d.addEventListener("click",u),d.addEventListener("keydown",b),i?.onContextMenu&&(d.addEventListener("contextmenu",E),v.set(d,E)),m.set(d,b),p.set(d,u)})}function g(){t.forEach(d=>{let w=m.get(d),u=p.get(d),b=v.get(d);w&&(d.removeEventListener("keydown",w),m.delete(d)),u&&(d.removeEventListener("click",u),p.delete(d)),b&&(d.removeEventListener("contextmenu",b),v.delete(d))})}function T(){g(),t.forEach((d,w)=>{let u=r[w];d.removeAttribute("role"),d.removeAttribute("aria-selected"),d.removeAttribute("aria-controls"),d.removeAttribute("tabindex"),u.removeAttribute("role"),u.removeAttribute("aria-labelledby"),u.removeAttribute("tabindex"),u.hidden=!1}),e.removeAttribute("role"),e.removeAttribute("aria-orientation")}function L(){g();let d=Array.from(e.querySelectorAll(`.${n}`)),w=Array.from(document.querySelectorAll(`.${h}`));t.length=0,t.push(...d),r.length=0,r.push(...w),H(),x()}return H(),x(),{activateTab:C,cleanup:T,refresh:L}}var G={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...se(),...J()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:ie},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:ae},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:oe},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>j("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>j("last")}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function se(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function ie(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function ae(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function oe(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function J(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function j(c){return[{target:"relative",relativeTarget:c,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${c} option to have aria-selected='true'.`}]}function ce(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function le(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ue(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:me},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:be},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ge},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:he},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ye},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ae},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:Ee},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:ke}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function fe(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function me(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function be(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function ge(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function he(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function ye(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ve(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function Ae(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Ee(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function ke(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function we(c,n){return n.some(h=>c.capabilities.includes(h))}function R(c,n){Array.isArray(c)&&c.length&&!c[0].when&&(c=[{when:["keyboard"],steps:()=>c}]);for(let h of c)if(we(n,h.when))return h.steps(n);throw new Error(`No setup strategy matches capabilities: ${n.capabilities.join(", ")}`)}var Me={combobox:G,menu:X},_=class{constructor(n){this.jsonContract=n}toJSON(){return this.jsonContract}},K=class{constructor(n){this.componentName=n;this.statePack=Me[n]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(n){return this.metaValue=n,this}selectors(n){return this.selectorsValue=n,this}relationships(n){let h=this.statePack,o={capabilities:["keyboard"]},s=(e,t=new Set)=>{if(t.has(e))return[];t.add(e);let r=h[e];if(!r)return[];let m=[];if(Array.isArray(r.requires))for(let p of r.requires)m=m.concat(s(p,t));return r.setup&&(m=m.concat(R(r.setup,o))),m};return n({ariaReference:(e,t,r)=>({requires:m=>{let p=s(m,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"recommended"})}),contains:(e,t)=>({requires:r=>{let m=s(r,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"required",setup:m}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"optional",setup:m}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"recommended",setup:m})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"recommended"})})}),this}static(n){return n({target:o=>{let s=e=>{let t=this.statePack,r={capabilities:["keyboard"]},m=(p,v=new Set)=>{if(v.has(p))return[];v.add(p);let A=t[p];if(!A)return[];let H=[];if(Array.isArray(A.requires))for(let C of A.requires)H=H.concat(m(C,v));return A.setup&&(H=H.concat(R(A.setup,r))),H};return m(e,new Set)},i=(e,t,r)=>({required:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"recommended",setup:r})});return{has:(e,t)=>({...i(e,t),requires:m=>{let p=s(m);return i(e,t,p)}})}}}),this}when(n){return new B(this,this.statePack,n)}addDynamicTest(n){this.dynamicTests.push(n)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},B=class{constructor(n,h,o){this.parent=n;this.statePack=h;this.event=o}_as;_on;_given=[];_then=[];_desc="";_level="required";as(n){return this._as=n,this}on(n){return this._on=n,this}given(n){return this._given=Array.isArray(n)?n:[n],this}then(n){return this._then=Array.isArray(n)?n:[n],this}describe(n){return this._desc=n,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let o={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},s=(r,m=new Set)=>{if(m.has(r))return[];m.add(r);let p=this.statePack[r];if(!p)return[];let v=[];if(Array.isArray(p.requires))for(let A of p.requires)v=v.concat(s(A,m));return p.setup&&(v=v.concat(R(p.setup,o))),v},i=[];for(let r of this._given)i.push(...s(r));let e=[];for(let r of this._then){let m=this.statePack[r];if(m&&m.assertion!==void 0){let p=m.assertion;if(typeof p=="function")try{p=p()}catch(v){throw new Error(`Error calling assertion function for state '${r}': ${v.message}`)}Array.isArray(p)?e.push(...p):e.push(p)}}let t=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:t,assertions:e,...i.length?{setup:i}:{}})}};function Xe(c,n){let h=new K(c);return n(h),new _(h.build())}import Te from"path";async function Q(c,n,h={}){if(!c||typeof c!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!n)throw new Error("\u274C testUiComponent requires a URL");if(n&&typeof n!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let o={violations:[]};async function s(p){try{let v=await fetch(p,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(v.ok||v.status===304)return p}catch{return null}return null}let i=V(h.strictness),e={},t=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:p}=await import("./configLoader-ZEJVXLX7.js"),v=await p(process.cwd());if(e=v.config,v.configPath&&(t=Te.dirname(v.configPath)),h.strictness===void 0){let A=e.test?.components?.find(H=>H?.name===c)?.strictness;i=V(A??e.test?.strictness)}}catch{h.strictness===void 0&&(i="balanced")}let r;try{if(n){let p=await s(n);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:v}=await import("./contractTestRunnerPlaywright-QPU6HZXG.js");r=await v(c,p,i,e,t)}else throw new Error(`\u274C Dev server not running at ${n}
2
- Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(p){throw p instanceof Error?p:new Error(`\u274C Contract test execution failed: ${String(p)}`)}let m={violations:o.violations,raw:o,contract:r};if(r.failures.length>0&&n==="Playwright")throw new Error(`
3
- \u274C ${r.failures.length} accessibility contract test${r.failures.length>1?"s":""} failed (Playwright mode)
4
- \u2705 ${r.passes.length} test${r.passes.length>1?"s":""} passed
1
+ import{b as U,d as V}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Te({accordionId:r,triggersClass:t,panelsClass:m,allowMultipleOpen:i=!1,callback:a}){if(r==="")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 o=document.querySelector(`#${r}`);if(!o)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(t==="")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 e=Array.from(o.querySelectorAll(`.${t}`));if(e.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(m==="")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 n=Array.from(o.querySelectorAll(`.${m}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e.length!==n.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${e.length} triggers but ${n.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,u=new WeakMap;function f(){e.forEach((h,T)=>{let H=n[T];h.id||(h.id=`${r}-trigger-${T}`),H.id||(H.id=`${r}-panel-${T}`),h.setAttribute("aria-controls",H.id),h.setAttribute("aria-expanded","false"),(!i||e.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",h.id),H.style.display="none"})}function y(h){if(h<0||h>=e.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let T=e[h],H=n[h];if(T.setAttribute("aria-expanded","true"),H.style.display="block",a?.onExpand)try{a.onExpand(h)}catch(d){console.error("[aria-ease] Error in accordion onExpand callback:",d)}}function k(h){if(h<0||h>=e.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let T=e[h],H=n[h];if(T.setAttribute("aria-expanded","false"),H.style.display="none",a?.onCollapse)try{a.onCollapse(h)}catch(d){console.error("[aria-ease] Error in accordion onCollapse callback:",d)}}function L(h){e[h].getAttribute("aria-expanded")==="true"?k(h):(i||e.forEach((d,E)=>{E!==h&&k(E)}),y(h))}function $(h){return()=>{L(h)}}function S(h){return T=>{let{key:H}=T;switch(H){case"Enter":case" ":T.preventDefault(),L(h);break;case"ArrowDown":T.preventDefault();{let d=(h+1)%e.length;e[d].focus()}break;case"ArrowUp":T.preventDefault();{let d=(h-1+e.length)%e.length;e[d].focus()}break;case"Home":T.preventDefault(),e[0].focus();break;case"End":T.preventDefault(),e[e.length-1].focus();break}}}function c(){e.forEach((h,T)=>{let H=$(T),d=S(T);h.addEventListener("click",H),h.addEventListener("keydown",d),s.set(h,d),u.set(h,H)})}function l(){e.forEach(h=>{let T=s.get(h),H=u.get(h);T&&(h.removeEventListener("keydown",T),s.delete(h)),H&&(h.removeEventListener("click",H),u.delete(h))})}function A(){l(),e.forEach((h,T)=>{k(T)})}function C(){l();let h=Array.from(o.querySelectorAll(`.${t}`)),T=Array.from(o.querySelectorAll(`.${m}`));e.length=0,e.push(...h),n.length=0,n.push(...T),f(),c()}return f(),c(),{expandItem:y,collapseItem:k,toggleItem:L,cleanup:A,refresh:C}}function O(r){if(r.tagName!=="INPUT")return!1;let t=r.type;return["text","email","password","tel","number"].includes(t)}function N(r){return r.tagName==="TEXTAREA"}function z(r){return r.tagName==="BUTTON"||r.tagName==="INPUT"&&["button","submit","reset"].includes(r.type)}function ee(r){return r.tagName==="A"}function R(r,t,m){let i=r.length,a=(t+m+i)%i;r.item(a).focus()}function te(r){return r.getAttribute("data-custom-click")!==null&&r.getAttribute("data-custom-click")!==void 0}function W(r,t,m){let i=t.item(m);switch(r.key){case"ArrowUp":case"ArrowLeft":{(!O(i)&&!N(i)||(O(i)||N(i))&&i.selectionStart===0)&&(r.preventDefault(),R(t,m,-1));break}case"ArrowDown":case"ArrowRight":{if(!O(i)&&!N(i))r.preventDefault(),R(t,m,1);else if(O(i)||N(i)){let a=i.value;i.selectionStart===a.length&&(r.preventDefault(),R(t,m,1))}break}case"Escape":{r.preventDefault();break}case"Enter":case" ":{(!z(i)&&!ee(i)&&te(i)||z(i))&&(r.preventDefault(),i.click());break}case"Tab":break;default:break}}function Se({blockId:r,blockItemsClass:t}){if(r==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let m=document.querySelector(`#${r}`);if(!m)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let i=null;function a(){return i||(i=m.querySelectorAll(`.${t}`)),i}let o=a();if(!o||o.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let e=new Map;o.forEach(u=>{if(!e.has(u)){let f=y=>{let k=m.querySelectorAll(`.${t}`),L=Array.prototype.indexOf.call(k,u);W(y,k,L)};u.addEventListener("keydown",f),e.set(u,f)}});function n(){o.forEach(u=>{let f=e.get(u);f&&(u.removeEventListener("keydown",f),e.delete(u))})}function s(){i=null}return{cleanup:n,refresh:s}}function $e({checkboxGroupId:r,checkboxesClass:t}){if(r==="")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 m=document.querySelector(`#${r}`);if(!m)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(t==="")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 i=Array.from(m.querySelectorAll(`.${t}`));if(i.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let a=new WeakMap,o=new WeakMap;function e(){m.getAttribute("role")||m.setAttribute("role","group"),i.forEach(c=>{c.setAttribute("role","checkbox"),c.hasAttribute("aria-checked")||c.setAttribute("aria-checked","false"),c.hasAttribute("tabindex")||c.setAttribute("tabindex","0")})}function n(c){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}let l=i[c],A=l.getAttribute("aria-checked")==="true";l.setAttribute("aria-checked",A?"false":"true")}function s(c,l){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}i[c].setAttribute("aria-checked",l?"true":"false")}function u(c){return()=>{n(c)}}function f(c){return l=>{let{key:A}=l;switch(A){case" ":l.preventDefault(),n(c);break}}}function y(){i.forEach((c,l)=>{let A=u(l),C=f(l);c.addEventListener("click",A),c.addEventListener("keydown",C),a.set(c,C),o.set(c,A)})}function k(){i.forEach(c=>{let l=a.get(c),A=o.get(c);l&&(c.removeEventListener("keydown",l),a.delete(c)),A&&(c.removeEventListener("click",A),o.delete(c))})}function L(){k()}function $(){return i.map(c=>c.getAttribute("aria-checked")==="true")}function S(){return i.map((c,l)=>c.getAttribute("aria-checked")==="true"?l:-1).filter(c=>c!==-1)}return e(),y(),{toggleCheckbox:n,setCheckboxState:s,getCheckedStates:$,getCheckedIndices:S,cleanup:L}}function ne({menuId:r,menuItemsClass:t,triggerId:m,callback:i}){if(r==="")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 a=document.querySelector(`#${r}`);if(!a)return console.error(`[aria-ease] Element with id="${r}" 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 o=document.querySelector(`#${m}`);if(!o)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(t==="")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(r))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",r),o.setAttribute("aria-expanded","false"),a.setAttribute("role","menu"),a.setAttribute("aria-labelledby",m);let e=new WeakMap,n=new Map,s=null,u=null;function f(){return s||(s=a.querySelectorAll(`.${t}`)),s}function y(){if(!u){let b=f();u=[];for(let g=0;g<b.length;g++){let x=b.item(g),D=C(x),P=x.getAttribute("aria-disabled")==="true";D||(x.hasAttribute("tabindex")||x.setAttribute("tabindex","-1"),P||u.push(x))}}return u}function k(b){return{length:b.length,item:x=>b[x],forEach:x=>{b.forEach(x)},[Symbol.iterator]:function*(){for(let x of b)yield x}}}function L(){f().forEach(g=>{g.setAttribute("role","menuitem");let x=g.getAttribute("data-submenu-id")??g.getAttribute("aria-controls"),D=g.hasAttribute("aria-haspopup")&&x;x&&(g.hasAttribute("data-submenu-id")||D)&&(g.setAttribute("aria-haspopup","menu"),g.setAttribute("aria-controls",x),g.hasAttribute("aria-expanded")||g.setAttribute("aria-expanded","false"))})}function $(b,g,x){let D=b.length,P=(g+x+D)%D;b.item(P).focus()}function S(b,g){b.length!==0&&b[g]?.focus()}function c(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function l(b){let g=b;for(;g&&g.getAttribute("role")==="menuitem";){let x=g.closest('[role="menu"]');if(!x)break;x.style.display="none",g.setAttribute("aria-expanded","false");let D=x.getAttribute("aria-labelledby");if(!D)break;let P=document.getElementById(D);if(!P)break;g=P}}L();function A(b,g,x){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&o.getAttribute("role")==="menuitem"){b.preventDefault(),p();return}break}case"ArrowUp":{b.preventDefault(),$(k(y()),x,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&c(g)){b.preventDefault();let D=g.getAttribute("aria-controls");if(D){T(D);return}}break}case"ArrowDown":{b.preventDefault(),$(k(y()),x,1);break}case"Home":{b.preventDefault(),S(y(),0);break}case"End":{b.preventDefault();let D=y();S(D,D.length-1);break}case"Escape":{b.preventDefault(),p(),o.focus(),H&&H(!1);break}case"Enter":case" ":{if(b.preventDefault(),c(g)){let D=g.getAttribute("aria-controls");if(D){T(D);return}}g.click(),p(),H&&H(!1);break}case"Tab":{p(),l(o),H&&H(!1);break}default:break}}function C(b){let g=b.parentElement;for(;g&&g!==a;){if(g.getAttribute("role")==="menu"||g.id&&a.querySelector(`[aria-controls="${g.id}"]`))return!0;g=g.parentElement}return!1}function h(b){o.setAttribute("aria-expanded",b?"true":"false")}function T(b){let g=n.get(b);if(!g){let x=a.querySelector(`[aria-controls="${b}"]`);if(!x){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${r}".`);return}if(!x.id){let P=`trigger-${b}`;x.id=P,console.warn(`[aria-ease] Submenu trigger for "${b}" had no ID. Auto-generated ID: "${P}".`)}if(!document.querySelector(`#${b}`)){console.error(`[aria-ease] Submenu element with id="${b}" not found. Cannot create submenu instance.`);return}g=ne({menuId:b,menuItemsClass:t,triggerId:x.id,callback:i}),n.set(b,g)}g.openMenu()}function H(b){if(i?.onOpenChange)try{i.onOpenChange(b)}catch(g){console.error("[aria-ease] Error in menu onOpenChange callback:",g)}}function d(){y().forEach((g,x)=>{if(!e.has(g)){let D=P=>A(P,g,x);g.addEventListener("keydown",D),e.set(g,D)}})}function E(){y().forEach(g=>{let x=e.get(g);x&&(g.removeEventListener("keydown",x),e.delete(g))})}function w(){h(!0),a.style.display="block";let b=y();if(d(),b&&b.length>0&&b[0].focus(),i?.onOpenChange)try{i.onOpenChange(!0)}catch(g){console.error("[aria-ease] Error in menu onOpenChange callback:",g)}}function p(){if(n.forEach(b=>b.closeMenu()),h(!1),a.style.display="none",E(),o.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function v(){o.getAttribute("aria-expanded")==="true"?p():w()}function M(b){if(!(o.getAttribute("aria-expanded")==="true"))return;let x=o.contains(b.target),D=a.contains(b.target);!x&&!D&&p()}o.addEventListener("click",v),document.addEventListener("click",M);function q(){E(),o.removeEventListener("click",v),document.removeEventListener("click",M),a.style.display="none",h(!1),n.forEach(b=>b.cleanup()),n.clear()}function I(){s=null,u=null}return{openMenu:w,closeMenu:p,cleanup:q,refresh:I}}function Pe({radioGroupId:r,radiosClass:t,defaultSelectedIndex:m=0}){if(r==="")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(`#${r}`);if(!i)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(t==="")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 a=Array.from(i.querySelectorAll(`.${t}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let o=new WeakMap,e=new WeakMap,n=m;function s(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),a.forEach((c,l)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex",l===n?"0":"-1"),l===n?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function u(c){if(c<0||c>=a.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}n>=0&&n<a.length&&(a[n].setAttribute("aria-checked","false"),a[n].setAttribute("tabindex","-1")),a[c].setAttribute("aria-checked","true"),a[c].setAttribute("tabindex","0"),a[c].focus(),n=c}function f(c){return()=>{u(c)}}function y(c){return l=>{let{key:A}=l,C=c;switch(A){case"ArrowDown":case"ArrowRight":l.preventDefault(),C=(c+1)%a.length,u(C);break;case"ArrowUp":case"ArrowLeft":l.preventDefault(),C=(c-1+a.length)%a.length,u(C);break;case" ":case"Enter":l.preventDefault(),u(c);break}}}function k(){a.forEach((c,l)=>{let A=f(l),C=y(l);c.addEventListener("click",A),c.addEventListener("keydown",C),o.set(c,C),e.set(c,A)})}function L(){a.forEach(c=>{let l=o.get(c),A=e.get(c);l&&(c.removeEventListener("keydown",l),o.delete(c)),A&&(c.removeEventListener("click",A),e.delete(c))})}function $(){L()}function S(){return n}return s(),k(),{selectRadio:u,getSelectedIndex:S,cleanup:$}}function Ne({toggleId:r,togglesClass:t,isSingleToggle:m=!0}){if(r==="")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 i=document.querySelector(`#${r}`);if(!i)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let a;if(m)a=[i];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(a=Array.from(i.querySelectorAll(`.${t}`)),a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let o=new WeakMap,e=new WeakMap;function n(){a.forEach(l=>{l.tagName.toLowerCase()!=="button"&&!l.getAttribute("role")&&l.setAttribute("role","button"),l.hasAttribute("aria-pressed")||l.setAttribute("aria-pressed","false"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","0")})}function s(l){if(l<0||l>=a.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}let A=a[l],C=A.getAttribute("aria-pressed")==="true";A.setAttribute("aria-pressed",C?"false":"true")}function u(l,A){if(l<0||l>=a.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}a[l].setAttribute("aria-pressed",A?"true":"false")}function f(l){return()=>{s(l)}}function y(l){return A=>{let{key:C}=A;switch(C){case"Enter":case" ":A.preventDefault(),s(l);break}}}function k(){a.forEach((l,A)=>{let C=f(A),h=y(A);l.addEventListener("click",C),l.addEventListener("keydown",h),o.set(l,h),e.set(l,C)})}function L(){a.forEach(l=>{let A=o.get(l),C=e.get(l);A&&(l.removeEventListener("keydown",A),o.delete(l)),C&&(l.removeEventListener("click",C),e.delete(l))})}function $(){L()}function S(){return a.map(l=>l.getAttribute("aria-pressed")==="true")}function c(){return a.map((l,A)=>l.getAttribute("aria-pressed")==="true"?A:-1).filter(l=>l!==-1)}return n(),k(),{toggleButton:s,setPressed:u,getPressedStates:S,getPressedIndices:c,cleanup:$}}function Fe({comboboxInputId:r,comboboxButtonId:t,listBoxId:m,listBoxItemsClass:i,callback:a}){if(r==="")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(`${r}`);if(!o)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(m==="")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 e=document.getElementById(`${m}`);if(!e)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(i==="")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(i))return console.error(`[aria-ease] Listbox option(s) with class="${i}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let s=t?document.getElementById(`${t}`):null,u=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",m),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),e.setAttribute("role","listbox");let f=null;function y(){return f||(f=e.querySelectorAll(`.${i}`)),Array.from(f).filter(p=>!p.hidden&&p.style.display!=="none")}function k(){return o.getAttribute("aria-expanded")==="true"}function L(p){let v=y();if(p>=0&&p<v.length){let M=v[p],q=M.id||`${m}-option-${p}`;if(M.id||(M.id=q),o.setAttribute("aria-activedescendant",q),typeof M.scrollIntoView=="function"&&M.scrollIntoView({block:"nearest",behavior:"smooth"}),a?.onActiveDescendantChange)try{a.onActiveDescendantChange(q,M)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else o.setAttribute("aria-activedescendant","");u=p}function $(){if(o.setAttribute("aria-expanded","true"),e.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0)}catch(p){console.error("[aria-ease] Error in combobox onOpenChange callback:",p)}}function S(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),e.style.display="none",u=-1,a?.onOpenChange)try{a.onOpenChange(!1)}catch(p){console.error("[aria-ease] Error in combobox onOpenChange callback:",p)}}function c(p){let v=p.textContent?.trim()||"";if(o.value=v,p.setAttribute("aria-selected","true"),S(),a?.onSelect)try{a.onSelect(p)}catch(M){console.error("[aria-ease] Error in combobox onSelect callback:",M)}}function l(p){let v=y(),M=k();switch(p.key){case"ArrowDown":if(p.preventDefault(),!M){$();return}if(v.length===0)return;{let q=u>=v.length-1?0:u+1;L(q)}break;case"ArrowUp":if(p.preventDefault(),!M)return;if(v.length>0){let q=u<=0?v.length-1:u-1;L(q)}break;case"Enter":M&&u>=0&&u<v.length&&(p.preventDefault(),c(v[u]));break;case"Escape":if(M)p.preventDefault(),S();else if(o.value&&(p.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),y().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),a?.onClear))try{a.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":M&&v.length>0&&(p.preventDefault(),L(0));break;case"End":M&&v.length>0&&(p.preventDefault(),L(v.length-1));break;case"Tab":M&&u>=0&&u<v.length&&c(v[u]),M&&S();break}}function A(p){let v=p.target;if(v.classList.contains(i)){let q=y().indexOf(v);q>=0&&L(q)}}function C(p){let v=p.target;v.classList.contains(i)&&(p.preventDefault(),c(v))}function h(p){let v=p.target;!o.contains(v)&&!e.contains(v)&&(!s||!s.contains(v))&&S()}function T(){k()?S():($(),o.focus())}function H(p){(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),T())}o.addEventListener("keydown",l),e.addEventListener("mousemove",A),e.addEventListener("mousedown",C),document.addEventListener("mousedown",h),s&&(s.setAttribute("tabindex","-1"),s.setAttribute("aria-label","Toggle options"),s.addEventListener("click",T),s.addEventListener("keydown",H));function d(){let p=e.querySelectorAll(`.${i}`);if(p.length===0)return;let v=null;for(let M of p)if(M.getAttribute("aria-selected")==="true"){v=M.textContent?.trim()||null;break}!v&&o.value&&(v=o.value.trim()),p.forEach((M,q)=>{M.setAttribute("role","option");let I=M.textContent?.trim()||"";v&&I===v?M.setAttribute("aria-selected","true"):M.setAttribute("aria-selected","false");let b=M.getAttribute("id");if(!b||b===""){let g=`${m}-option-${q}`;M.id=g,M.setAttribute("id",g)}})}d();function E(){o.removeEventListener("keydown",l),e.removeEventListener("mousemove",A),e.removeEventListener("mousedown",C),document.removeEventListener("mousedown",h),s&&(s.removeEventListener("click",T),s.removeEventListener("keydown",H))}function w(){f=null,d(),u=-1,L(-1)}return{cleanup:E,refresh:w,openListbox:$,closeListbox:S}}function _e({tabListId:r,tabsClass:t,tabPanelsClass:m,orientation:i="horizontal",activateOnFocus:a=!0,callback:o}){if(r==="")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 e=document.querySelector(`#${r}`);if(!e)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t==="")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 n=Array.from(e.querySelectorAll(`.${t}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(m==="")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(`.${m}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(n.length!==s.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${n.length} tabs but ${s.length} panels.`),{cleanup:()=>{}};let u=new WeakMap,f=new WeakMap,y=new WeakMap,k=0;function L(){e.setAttribute("role","tablist"),e.setAttribute("aria-orientation",i),n.forEach((d,E)=>{let w=s[E];d.id||(d.id=`${r}-tab-${E}`),w.id||(w.id=`${r}-panel-${E}`),d.setAttribute("role","tab"),d.setAttribute("aria-controls",w.id),d.setAttribute("aria-selected","false"),d.setAttribute("tabindex","-1"),w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",d.id),w.hidden=!0,w.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||w.setAttribute("tabindex","0")}),$(0,!1)}function $(d,E=!0){if(d<0||d>=n.length){console.error(`[aria-ease] Invalid tab index: ${d}`);return}let w=k;n.forEach((M,q)=>{let I=s[q];M.setAttribute("aria-selected","false"),M.setAttribute("tabindex","-1"),I.hidden=!0});let p=n[d],v=s[d];if(p.setAttribute("aria-selected","true"),p.setAttribute("tabindex","0"),v.hidden=!1,E&&p.focus(),k=d,o?.onTabChange&&w!==d)try{o.onTabChange(d,w)}catch(M){console.error("[aria-ease] Error in tabs onTabChange callback:",M)}}function S(d){let E=n.findIndex(v=>v===document.activeElement),w=E!==-1?E:k,p=w;switch(d){case"first":p=0;break;case"last":p=n.length-1;break;case"next":p=(w+1)%n.length;break;case"prev":p=(w-1+n.length)%n.length;break}if(n[p].focus(),n[p].setAttribute("tabindex","0"),n[k].setAttribute("tabindex","-1"),a)$(p,!1);else{let v=k;n.forEach((M,q)=>{q===p?M.setAttribute("tabindex","0"):q!==v&&M.setAttribute("tabindex","-1")})}}function c(d){return()=>{$(d)}}function l(d){return E=>{let{key:w}=E,p=!1;if(i==="horizontal")switch(w){case"ArrowLeft":E.preventDefault(),S("prev"),p=!0;break;case"ArrowRight":E.preventDefault(),S("next"),p=!0;break}else switch(w){case"ArrowUp":E.preventDefault(),S("prev"),p=!0;break;case"ArrowDown":E.preventDefault(),S("next"),p=!0;break}if(!p)switch(w){case"Home":E.preventDefault(),S("first");break;case"End":E.preventDefault(),S("last");break;case" ":case"Enter":a||(E.preventDefault(),$(d));break;case"F10":if(E.shiftKey&&o?.onContextMenu){E.preventDefault();try{o.onContextMenu(d,n[d])}catch(v){console.error("[aria-ease] Error in tabs onContextMenu callback:",v)}}break}}}function A(d){return E=>{if(o?.onContextMenu){E.preventDefault();try{o.onContextMenu(d,n[d])}catch(w){console.error("[aria-ease] Error in tabs onContextMenu callback:",w)}}}}function C(){n.forEach((d,E)=>{let w=c(E),p=l(E),v=A(E);d.addEventListener("click",w),d.addEventListener("keydown",p),o?.onContextMenu&&(d.addEventListener("contextmenu",v),y.set(d,v)),u.set(d,p),f.set(d,w)})}function h(){n.forEach(d=>{let E=u.get(d),w=f.get(d),p=y.get(d);E&&(d.removeEventListener("keydown",E),u.delete(d)),w&&(d.removeEventListener("click",w),f.delete(d)),p&&(d.removeEventListener("contextmenu",p),y.delete(d))})}function T(){h(),n.forEach((d,E)=>{let w=s[E];d.removeAttribute("role"),d.removeAttribute("aria-selected"),d.removeAttribute("aria-controls"),d.removeAttribute("tabindex"),w.removeAttribute("role"),w.removeAttribute("aria-labelledby"),w.removeAttribute("tabindex"),w.hidden=!1}),e.removeAttribute("role"),e.removeAttribute("aria-orientation")}function H(){h();let d=Array.from(e.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${m}`));n.length=0,n.push(...d),s.length=0,s.push(...E),L(),C()}return L(),C(),{activateTab:$,cleanup:T,refresh:H}}var G={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...se(),...J()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:ie},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:ae},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:oe},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>j("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>j("last")}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function se(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function ie(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function ae(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function oe(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function J(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function j(r){return[{target:"relative",relativeTarget:r,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${r} option to have aria-selected='true'.`}]}function ce(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function le(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ue(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:be},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:me},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ge},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:he},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ye},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ae},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:ke},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:Ee}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function fe(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function be(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function me(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function ge(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function he(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function ye(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ve(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function Ae(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function ke(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Ee(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function Me(r,t){return t.some(m=>r.capabilities.includes(m))}function F(r,t){Array.isArray(r)&&r.length&&!r[0].when&&(r=[{when:["keyboard"],steps:()=>r}]);for(let m of r)if(Me(t,m.when))return m.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var we={combobox:G,menu:X},_=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=we[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let m=this.statePack,i={capabilities:["keyboard"]},a=(e,n=new Set)=>{if(n.has(e))return[];n.add(e);let s=m[e];if(!s)return[];let u=[];if(Array.isArray(s.requires))for(let f of s.requires)u=u.concat(a(f,n));return s.setup&&(u=u.concat(F(s.setup,i))),u};return t({ariaReference:(e,n,s)=>({requires:u=>{let f=a(u,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"required",setup:f}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"optional",setup:f}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"recommended",setup:f})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"recommended"})}),contains:(e,n)=>({requires:s=>{let u=a(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"recommended"})})}),this}static(t){return t({target:i=>{let a=e=>{let n=this.statePack,s={capabilities:["keyboard"]},u=(f,y=new Set)=>{if(y.has(f))return[];y.add(f);let k=n[f];if(!k)return[];let L=[];if(Array.isArray(k.requires))for(let $ of k.requires)L=L.concat(u($,y));return k.setup&&(L=L.concat(F(k.setup,s))),L};return u(e,new Set)},o=(e,n,s)=>({required:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"recommended",setup:s})});return{has:(e,n)=>({...o(e,n),requires:u=>{let f=a(u);return o(e,n,f)}})}}}),this}when(t){return new B(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},B=class{constructor(t,m,i){this.parent=t;this.statePack=m;this.event=i}_as;_on;_given=[];_then=[];_desc="";_level="required";as(t){return this._as=t,this}on(t){return this._on=t,this}given(t){return this._given=Array.isArray(t)?t:[t],this}then(t){return this._then=Array.isArray(t)?t:[t],this}describe(t){return this._desc=t,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let i={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return[];u.add(s);let f=this.statePack[s];if(!f)return[];let y=[];if(Array.isArray(f.requires))for(let k of f.requires)y=y.concat(a(k,u));return f.setup&&(y=y.concat(F(f.setup,i))),y},o=[];for(let s of this._given)o.push(...a(s));let e=[];for(let s of this._then){let u=this.statePack[s];if(u&&u.assertion!==void 0){let f=u.assertion;if(typeof f=="function")try{f=f()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(f)?e.push(...f):e.push(f)}}let n=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:n,assertions:e,...o.length?{setup:o}:{}})}};function Xe(r,t){let m=new K(r);return t(m),new _(m.build())}import xe from"path";async function Q(r,t,m={}){if(!r||typeof r!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!t)throw new Error("\u274C testUiComponent requires a URL");if(t&&typeof t!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function a(f){try{let y=await fetch(f,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(y.ok||y.status===304)return f}catch{return null}return null}let o=V(m.strictness),e={},n=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:f}=await import("./configLoader-ZEJVXLX7.js"),y=await f(process.cwd());if(e=y.config,y.configPath&&(n=xe.dirname(y.configPath)),m.strictness===void 0){let k=e.test?.components?.find(L=>L?.name===r)?.strictness;o=V(k??e.test?.strictness)}}catch{m.strictness===void 0&&(o="balanced")}let s;try{if(t){let f=await a(t);if(f){console.log(`\u{1F3AD} Running Playwright tests on ${f}`);let{runContractTestsPlaywright:y}=await import("./contractTestRunnerPlaywright-QPU6HZXG.js");s=await y(r,f,o,e,n)}else throw new Error(`\u274C Dev server not running at ${t}
2
+ Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(f){throw f instanceof Error?f:new Error(`\u274C Contract test execution failed: ${String(f)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&t==="Playwright")throw new Error(`
3
+ \u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
4
+ \u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
5
5
 
6
6
  \u{1F4CB} Review the detailed test report above for specific failures.
7
- \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(o.violations.length>0){let p=o.violations.length,v=o.violations.map(A=>`
8
- - ${A.id}: ${A.description}
9
- Impact: ${A.impact}
10
- Affected elements: ${A.nodes.length}
11
- Help: ${A.helpUrl}`).join(`
7
+ \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(i.violations.length>0){let f=i.violations.length,y=i.violations.map(k=>`
8
+ - ${k.id}: ${k.description}
9
+ Impact: ${k.impact}
10
+ Affected elements: ${k.nodes.length}
11
+ Help: ${k.helpUrl}`).join(`
12
12
  `);throw new Error(`
13
- \u274C ${p} axe accessibility violation${p>1?"s":""} detected
14
- ${v}
13
+ \u274C ${f} axe accessibility violation${f>1?"s":""} detected
14
+ ${y}
15
15
 
16
- \u{1F4CB} Full details available in result.violations`)}return m}var Y=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Y=async()=>{console.log(`\u{1F680} Running component accessibility tests...
17
- `);let{exec:c}=await import("child_process"),n=(await import("chalk")).default;return new Promise((h,o)=>{c("npx vitest --run --reporter verbose",async(s,i,e)=>{if(console.log(i),e&&console.error(e),!s||s.code===0){try{let{displayBadgeInfo:r,promptAddBadge:m}=await import("./badgeHelper-IB5RTMAG.js");r("component"),await m("component",process.cwd()),console.log(n.dim(`
18
- `+"\u2500".repeat(60))),console.log(n.cyan("\u{1F499} Found aria-ease helpful?")),console.log(n.white(" \u2022 Star us on GitHub: ")+n.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(n.white(" \u2022 Share feedback: ")+n.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(n.dim("\u2500".repeat(60)+`
19
- `))}catch(r){console.error("Warning: Could not display badge prompt:",r)}h({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let r=s?.code||1;o(new Error(`Tests failed with code ${r}`)),process.exit(r)}})})});async function Z(){await U()}export{Z as cleanupTests,Xe as createContract,Le as makeAccordionAccessible,Se as makeBlockAccessible,$e as makeCheckboxAccessible,Re as makeComboboxAccessible,ne as makeMenuAccessible,Oe as makeRadioAccessible,_e as makeTabsAccessible,Ne as makeToggleAccessible,Q as testUiComponent};
16
+ \u{1F4CB} Full details available in result.violations`)}return u}var Y=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Y=async()=>{console.log(`\u{1F680} Running component accessibility tests...
17
+ `);let{exec:r}=await import("child_process"),t=(await import("chalk")).default;return new Promise((m,i)=>{r("npx vitest --run --reporter verbose",async(a,o,e)=>{if(console.log(o),e&&console.error(e),!a||a.code===0){try{let{displayBadgeInfo:s,promptAddBadge:u}=await import("./badgeHelper-IB5RTMAG.js");s("component"),await u("component",process.cwd()),console.log(t.dim(`
18
+ `+"\u2500".repeat(60))),console.log(t.cyan("\u{1F499} Found aria-ease helpful?")),console.log(t.white(" \u2022 Star us on GitHub: ")+t.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(t.white(" \u2022 Share feedback: ")+t.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(t.dim("\u2500".repeat(60)+`
19
+ `))}catch(s){console.error("Warning: Could not display badge prompt:",s)}m({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let s=a?.code||1;i(new Error(`Tests failed with code ${s}`)),process.exit(s)}})})});async function Z(){await U()}export{Z as cleanupTests,Xe as createContract,Te as makeAccordionAccessible,Se as makeBlockAccessible,$e as makeCheckboxAccessible,Fe as makeComboboxAccessible,ne as makeMenuAccessible,Pe as makeRadioAccessible,_e as makeTabsAccessible,Ne as makeToggleAccessible,Q as testUiComponent};
@@ -1 +1 @@
1
- 'use strict';function H({accordionId:l,triggersClass:u,panelsClass:f,allowMultipleOpen:h=false,callback:s}){let c=document.querySelector(`#${l}`);if(!c)return console.error(`[aria-ease] Element with id="${l}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};let r=Array.from(c.querySelectorAll(`.${u}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${u}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};let a=Array.from(c.querySelectorAll(`.${f}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${f}" 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 d=new WeakMap,p=new WeakMap;function b(){r.forEach((e,n)=>{let t=a[n];e.id||(e.id=`${l}-trigger-${n}`),t.id||(t.id=`${l}-panel-${n}`),e.setAttribute("aria-controls",t.id),e.setAttribute("aria-expanded","false"),(!h||r.length<=6)&&t.setAttribute("role","region"),t.setAttribute("aria-labelledby",e.id),t.style.display="none";});}function A(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],t=a[e];if(n.setAttribute("aria-expanded","true"),t.style.display="block",s?.onExpand)try{s.onExpand(e);}catch(o){console.error("[aria-ease] Error in accordion onExpand callback:",o);}}function i(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],t=a[e];if(n.setAttribute("aria-expanded","false"),t.style.display="none",s?.onCollapse)try{s.onCollapse(e);}catch(o){console.error("[aria-ease] Error in accordion onCollapse callback:",o);}}function m(e){r[e].getAttribute("aria-expanded")==="true"?i(e):(h||r.forEach((o,k)=>{k!==e&&i(k);}),A(e));}function g(e){return ()=>{m(e);}}function $(e){return n=>{let{key:t}=n;switch(t){case "Enter":case " ":n.preventDefault(),m(e);break;case "ArrowDown":n.preventDefault();{let o=(e+1)%r.length;r[o].focus();}break;case "ArrowUp":n.preventDefault();{let o=(e-1+r.length)%r.length;r[o].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function E(){r.forEach((e,n)=>{let t=g(n),o=$(n);e.addEventListener("click",t),e.addEventListener("keydown",o),d.set(e,o),p.set(e,t);});}function y(){r.forEach(e=>{let n=d.get(e),t=p.get(e);n&&(e.removeEventListener("keydown",n),d.delete(e)),t&&(e.removeEventListener("click",t),p.delete(e));});}function v(){y(),r.forEach((e,n)=>{i(n);});}function w(){y();let e=Array.from(c.querySelectorAll(`.${u}`)),n=Array.from(c.querySelectorAll(`.${f}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),E();}return b(),E(),{expandItem:A,collapseItem:i,toggleItem:m,cleanup:v,refresh:w}}exports.makeAccordionAccessible=H;
1
+ 'use strict';function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:h=false,callback:u}){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"),(!h||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function A(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",u?.onExpand)try{u.onExpand(e);}catch(t){console.error("[aria-ease] Error in accordion onExpand callback:",t);}}function d(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",u?.onCollapse)try{u.onCollapse(e);}catch(t){console.error("[aria-ease] Error in accordion onCollapse callback:",t);}}function p(e){r[e].getAttribute("aria-expanded")==="true"?d(e):(h||r.forEach((t,E)=>{E!==e&&d(E);}),A(e));}function k(e){return ()=>{p(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),p(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 y(){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 g(){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 $(){g(),r.forEach((e,n)=>{d(n);});}function w(){g();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(),y();}return b(),y(),{expandItem:A,collapseItem:d,toggleItem:p,cleanup:$,refresh:w}}exports.makeAccordionAccessible=H;
@@ -1 +1 @@
1
- function H({accordionId:l,triggersClass:u,panelsClass:f,allowMultipleOpen:h=false,callback:s}){let c=document.querySelector(`#${l}`);if(!c)return console.error(`[aria-ease] Element with id="${l}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};let r=Array.from(c.querySelectorAll(`.${u}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${u}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};let a=Array.from(c.querySelectorAll(`.${f}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${f}" 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 d=new WeakMap,p=new WeakMap;function b(){r.forEach((e,n)=>{let t=a[n];e.id||(e.id=`${l}-trigger-${n}`),t.id||(t.id=`${l}-panel-${n}`),e.setAttribute("aria-controls",t.id),e.setAttribute("aria-expanded","false"),(!h||r.length<=6)&&t.setAttribute("role","region"),t.setAttribute("aria-labelledby",e.id),t.style.display="none";});}function A(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],t=a[e];if(n.setAttribute("aria-expanded","true"),t.style.display="block",s?.onExpand)try{s.onExpand(e);}catch(o){console.error("[aria-ease] Error in accordion onExpand callback:",o);}}function i(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],t=a[e];if(n.setAttribute("aria-expanded","false"),t.style.display="none",s?.onCollapse)try{s.onCollapse(e);}catch(o){console.error("[aria-ease] Error in accordion onCollapse callback:",o);}}function m(e){r[e].getAttribute("aria-expanded")==="true"?i(e):(h||r.forEach((o,k)=>{k!==e&&i(k);}),A(e));}function g(e){return ()=>{m(e);}}function $(e){return n=>{let{key:t}=n;switch(t){case "Enter":case " ":n.preventDefault(),m(e);break;case "ArrowDown":n.preventDefault();{let o=(e+1)%r.length;r[o].focus();}break;case "ArrowUp":n.preventDefault();{let o=(e-1+r.length)%r.length;r[o].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function E(){r.forEach((e,n)=>{let t=g(n),o=$(n);e.addEventListener("click",t),e.addEventListener("keydown",o),d.set(e,o),p.set(e,t);});}function y(){r.forEach(e=>{let n=d.get(e),t=p.get(e);n&&(e.removeEventListener("keydown",n),d.delete(e)),t&&(e.removeEventListener("click",t),p.delete(e));});}function v(){y(),r.forEach((e,n)=>{i(n);});}function w(){y();let e=Array.from(c.querySelectorAll(`.${u}`)),n=Array.from(c.querySelectorAll(`.${f}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),E();}return b(),E(),{expandItem:A,collapseItem:i,toggleItem:m,cleanup:v,refresh:w}}export{H as makeAccordionAccessible};
1
+ function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:h=false,callback:u}){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"),(!h||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function A(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",u?.onExpand)try{u.onExpand(e);}catch(t){console.error("[aria-ease] Error in accordion onExpand callback:",t);}}function d(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",u?.onCollapse)try{u.onCollapse(e);}catch(t){console.error("[aria-ease] Error in accordion onCollapse callback:",t);}}function p(e){r[e].getAttribute("aria-expanded")==="true"?d(e):(h||r.forEach((t,E)=>{E!==e&&d(E);}),A(e));}function k(e){return ()=>{p(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),p(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 y(){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 g(){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 $(){g(),r.forEach((e,n)=>{d(n);});}function w(){g();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(),y();}return b(),y(),{expandItem:A,collapseItem:d,toggleItem:p,cleanup:$,refresh:w}}export{H as makeAccordionAccessible};
@@ -1 +1 @@
1
- 'use strict';function l(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function b(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function H(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function m(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!l(t)&&!u(t)||(l(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!l(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(l(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!b(t)&&H(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let i=a();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let c=new Map;i.forEach(o=>{if(!c.has(o)){let s=p=>{let E=r.querySelectorAll(`.${n}`),M=Array.prototype.indexOf.call(E,o);m(p,E,M);};o.addEventListener("keydown",s),c.set(o,s);}});function L(){i.forEach(o=>{let s=c.get(o);s&&(o.removeEventListener("keydown",s),c.delete(o));});}function T(){t=null;}return {cleanup:L,refresh:T}}exports.makeBlockAccessible=g;
1
+ 'use strict';function c(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function k(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function M(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function E(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!c(t)&&!u(t)||(c(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!c(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(c(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!k(t)&&M(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){if(e==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(n==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let s=a();if(!s||s.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let l=new Map;s.forEach(o=>{if(!l.has(o)){let i=T=>{let m=r.querySelectorAll(`.${n}`),b=Array.prototype.indexOf.call(m,o);E(T,m,b);};o.addEventListener("keydown",i),l.set(o,i);}});function p(){s.forEach(o=>{let i=l.get(o);i&&(o.removeEventListener("keydown",i),l.delete(o));});}function L(){t=null;}return {cleanup:p,refresh:L}}exports.makeBlockAccessible=g;
@@ -1 +1 @@
1
- function l(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function b(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function H(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function m(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!l(t)&&!u(t)||(l(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!l(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(l(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!b(t)&&H(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let i=a();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let c=new Map;i.forEach(o=>{if(!c.has(o)){let s=p=>{let E=r.querySelectorAll(`.${n}`),M=Array.prototype.indexOf.call(E,o);m(p,E,M);};o.addEventListener("keydown",s),c.set(o,s);}});function L(){i.forEach(o=>{let s=c.get(o);s&&(o.removeEventListener("keydown",s),c.delete(o));});}function T(){t=null;}return {cleanup:L,refresh:T}}export{g as makeBlockAccessible};
1
+ function c(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function k(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function M(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function E(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!c(t)&&!u(t)||(c(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!c(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(c(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!k(t)&&M(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){if(e==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(n==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let s=a();if(!s||s.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let l=new Map;s.forEach(o=>{if(!l.has(o)){let i=T=>{let m=r.querySelectorAll(`.${n}`),b=Array.prototype.indexOf.call(m,o);E(T,m,b);};o.addEventListener("keydown",i),l.set(o,i);}});function p(){s.forEach(o=>{let i=l.get(o);i&&(o.removeEventListener("keydown",i),l.delete(o));});}function L(){t=null;}return {cleanup:p,refresh:L}}export{g as makeBlockAccessible};
@@ -1 +1 @@
1
- 'use strict';function E({checkboxGroupId:s,checkboxesClass:l}){let i=document.querySelector(`#${s}`);if(!i)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let n=Array.from(i.querySelectorAll(`.${l}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let a=new WeakMap,c=new WeakMap;function d(){i.getAttribute("role")||i.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function o(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function f(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function b(e){return ()=>{o(e);}}function k(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),o(e);break}}}function h(){n.forEach((e,t)=>{let r=b(t),u=k(t);e.addEventListener("click",r),e.addEventListener("keydown",u),a.set(e,u),c.set(e,r);});}function m(){n.forEach(e=>{let t=a.get(e),r=c.get(e);t&&(e.removeEventListener("keydown",t),a.delete(e)),r&&(e.removeEventListener("click",r),c.delete(e));});}function g(){m();}function A(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function p(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return d(),h(),{toggleCheckbox:o,setCheckboxState:f,getCheckedStates:A,getCheckedIndices:p,cleanup:g}}exports.makeCheckboxAccessible=E;
1
+ 'use strict';function C({checkboxGroupId:o,checkboxesClass:i}){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 a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")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 n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}exports.makeCheckboxAccessible=C;
@@ -1 +1 @@
1
- function E({checkboxGroupId:s,checkboxesClass:l}){let i=document.querySelector(`#${s}`);if(!i)return console.error(`[aria-ease] Element with id="${s}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let n=Array.from(i.querySelectorAll(`.${l}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let a=new WeakMap,c=new WeakMap;function d(){i.getAttribute("role")||i.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function o(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function f(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function b(e){return ()=>{o(e);}}function k(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),o(e);break}}}function h(){n.forEach((e,t)=>{let r=b(t),u=k(t);e.addEventListener("click",r),e.addEventListener("keydown",u),a.set(e,u),c.set(e,r);});}function m(){n.forEach(e=>{let t=a.get(e),r=c.get(e);t&&(e.removeEventListener("keydown",t),a.delete(e)),r&&(e.removeEventListener("click",r),c.delete(e));});}function g(){m();}function A(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function p(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return d(),h(),{toggleCheckbox:o,setCheckboxState:f,getCheckedStates:A,getCheckedIndices:p,cleanup:g}}export{E as makeCheckboxAccessible};
1
+ function C({checkboxGroupId:o,checkboxesClass:i}){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 a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")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 n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}export{C as makeCheckboxAccessible};
@@ -1 +1 @@
1
- 'use strict';function H({comboboxInputId:g,comboboxButtonId:A,listBoxId:d,listBoxItemsClass:b,callback:a}){let o=document.getElementById(`${g}`);if(!o)return console.error(`[aria-ease] Element with id="${g}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let s=document.getElementById(`${d}`);if(!s)return console.error(`[aria-ease] Element with id="${d}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let c=A?document.getElementById(`${A}`):null,r=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",d),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),s.setAttribute("role","listbox");let m=null;function v(){return m||(m=s.querySelectorAll(`.${b}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function L(){return o.getAttribute("aria-expanded")==="true"}function u(e){let t=v();if(e>=0&&e<t.length){let n=t[e],i=n.id||`${d}-option-${e}`;if(n.id||(n.id=i),o.setAttribute("aria-activedescendant",i),typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",behavior:"smooth"}),a?.onActiveDescendantChange)try{a.onActiveDescendantChange(i,n);}catch(l){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",l);}}else o.setAttribute("aria-activedescendant","");r=e;}function p(){if(o.setAttribute("aria-expanded","true"),s.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function f(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),s.style.display="none",r=-1,a?.onOpenChange)try{a.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function h(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),f(),a?.onSelect)try{a.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function y(e){let t=v(),n=L();switch(e.key){case "ArrowDown":if(e.preventDefault(),!n){p();return}if(t.length===0)return;{let i=r>=t.length-1?0:r+1;u(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;u(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),h(t[r]));break;case "Escape":if(n)e.preventDefault(),f();else if(o.value&&(e.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),v().forEach(l=>{l.getAttribute("aria-selected")==="true"&&l.setAttribute("aria-selected","false");}),a?.onClear))try{a.onClear();}catch(l){console.error("[aria-ease] Error in combobox onClear callback:",l);}break;case "Home":n&&t.length>0&&(e.preventDefault(),u(0));break;case "End":n&&t.length>0&&(e.preventDefault(),u(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&h(t[r]),n&&f();break}}function x(e){let t=e.target;if(t.classList.contains(b)){let i=v().indexOf(t);i>=0&&u(i);}}function k(e){let t=e.target;t.classList.contains(b)&&(e.preventDefault(),h(t));}function w(e){let t=e.target;!o.contains(t)&&!s.contains(t)&&(!c||!c.contains(t))&&f();}function E(){L()?f():(p(),o.focus());}function C(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E());}o.addEventListener("keydown",y),s.addEventListener("mousemove",x),s.addEventListener("mousedown",k),document.addEventListener("mousedown",w),c&&(c.setAttribute("tabindex","-1"),c.setAttribute("aria-label","Toggle options"),c.addEventListener("click",E),c.addEventListener("keydown",C));function M(){let e=s.querySelectorAll(`.${b}`);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 l=n.textContent?.trim()||"";t&&l===t?n.setAttribute("aria-selected","true"):n.setAttribute("aria-selected","false");let D=n.getAttribute("id");if(!D||D===""){let I=`${d}-option-${i}`;n.id=I,n.setAttribute("id",I);}});}M();function O(){o.removeEventListener("keydown",y),s.removeEventListener("mousemove",x),s.removeEventListener("mousedown",k),document.removeEventListener("mousedown",w),c&&(c.removeEventListener("click",E),c.removeEventListener("keydown",C));}function T(){m=null,M(),r=-1,u(-1);}return {cleanup:O,refresh:T,openListbox:p,closeListbox:f}}exports.makeComboboxAccessible=H;
1
+ 'use strict';function $({comboboxInputId:h,comboboxButtonId:A,listBoxId:b,listBoxItemsClass:u,callback:a}){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 s=document.getElementById(`${b}`);if(!s)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=A?document.getElementById(`${A}`):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"),s.setAttribute("role","listbox");let m=null;function p(){return m||(m=s.querySelectorAll(`.${u}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function x(){return o.getAttribute("aria-expanded")==="true"}function f(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"}),a?.onActiveDescendantChange)try{a.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"),s.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function d(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),s.style.display="none",r=-1,a?.onOpenChange)try{a.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function g(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),d(),a?.onSelect)try{a.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function L(e){let t=p(),n=x();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;f(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;f(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),g(t[r]));break;case "Escape":if(n)e.preventDefault(),d();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");}),a?.onClear))try{a.onClear();}catch(c){console.error("[aria-ease] Error in combobox onClear callback:",c);}break;case "Home":n&&t.length>0&&(e.preventDefault(),f(0));break;case "End":n&&t.length>0&&(e.preventDefault(),f(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&g(t[r]),n&&d();break}}function y(e){let t=e.target;if(t.classList.contains(u)){let i=p().indexOf(t);i>=0&&f(i);}}function k(e){let t=e.target;t.classList.contains(u)&&(e.preventDefault(),g(t));}function C(e){let t=e.target;!o.contains(t)&&!s.contains(t)&&(!l||!l.contains(t))&&d();}function E(){x()?d():(v(),o.focus());}function w(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E());}o.addEventListener("keydown",L),s.addEventListener("mousemove",y),s.addEventListener("mousedown",k),document.addEventListener("mousedown",C),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",E),l.addEventListener("keydown",w));function M(){let e=s.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 O=n.getAttribute("id");if(!O||O===""){let D=`${b}-option-${i}`;n.id=D,n.setAttribute("id",D);}});}M();function T(){o.removeEventListener("keydown",L),s.removeEventListener("mousemove",y),s.removeEventListener("mousedown",k),document.removeEventListener("mousedown",C),l&&(l.removeEventListener("click",E),l.removeEventListener("keydown",w));}function H(){m=null,M(),r=-1,f(-1);}return {cleanup:T,refresh:H,openListbox:v,closeListbox:d}}exports.makeComboboxAccessible=$;
@@ -1 +1 @@
1
- function H({comboboxInputId:g,comboboxButtonId:A,listBoxId:d,listBoxItemsClass:b,callback:a}){let o=document.getElementById(`${g}`);if(!o)return console.error(`[aria-ease] Element with id="${g}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let s=document.getElementById(`${d}`);if(!s)return console.error(`[aria-ease] Element with id="${d}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let c=A?document.getElementById(`${A}`):null,r=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",d),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),s.setAttribute("role","listbox");let m=null;function v(){return m||(m=s.querySelectorAll(`.${b}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function L(){return o.getAttribute("aria-expanded")==="true"}function u(e){let t=v();if(e>=0&&e<t.length){let n=t[e],i=n.id||`${d}-option-${e}`;if(n.id||(n.id=i),o.setAttribute("aria-activedescendant",i),typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",behavior:"smooth"}),a?.onActiveDescendantChange)try{a.onActiveDescendantChange(i,n);}catch(l){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",l);}}else o.setAttribute("aria-activedescendant","");r=e;}function p(){if(o.setAttribute("aria-expanded","true"),s.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function f(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),s.style.display="none",r=-1,a?.onOpenChange)try{a.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function h(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),f(),a?.onSelect)try{a.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function y(e){let t=v(),n=L();switch(e.key){case "ArrowDown":if(e.preventDefault(),!n){p();return}if(t.length===0)return;{let i=r>=t.length-1?0:r+1;u(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;u(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),h(t[r]));break;case "Escape":if(n)e.preventDefault(),f();else if(o.value&&(e.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),v().forEach(l=>{l.getAttribute("aria-selected")==="true"&&l.setAttribute("aria-selected","false");}),a?.onClear))try{a.onClear();}catch(l){console.error("[aria-ease] Error in combobox onClear callback:",l);}break;case "Home":n&&t.length>0&&(e.preventDefault(),u(0));break;case "End":n&&t.length>0&&(e.preventDefault(),u(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&h(t[r]),n&&f();break}}function x(e){let t=e.target;if(t.classList.contains(b)){let i=v().indexOf(t);i>=0&&u(i);}}function k(e){let t=e.target;t.classList.contains(b)&&(e.preventDefault(),h(t));}function w(e){let t=e.target;!o.contains(t)&&!s.contains(t)&&(!c||!c.contains(t))&&f();}function E(){L()?f():(p(),o.focus());}function C(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E());}o.addEventListener("keydown",y),s.addEventListener("mousemove",x),s.addEventListener("mousedown",k),document.addEventListener("mousedown",w),c&&(c.setAttribute("tabindex","-1"),c.setAttribute("aria-label","Toggle options"),c.addEventListener("click",E),c.addEventListener("keydown",C));function M(){let e=s.querySelectorAll(`.${b}`);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 l=n.textContent?.trim()||"";t&&l===t?n.setAttribute("aria-selected","true"):n.setAttribute("aria-selected","false");let D=n.getAttribute("id");if(!D||D===""){let I=`${d}-option-${i}`;n.id=I,n.setAttribute("id",I);}});}M();function O(){o.removeEventListener("keydown",y),s.removeEventListener("mousemove",x),s.removeEventListener("mousedown",k),document.removeEventListener("mousedown",w),c&&(c.removeEventListener("click",E),c.removeEventListener("keydown",C));}function T(){m=null,M(),r=-1,u(-1);}return {cleanup:O,refresh:T,openListbox:p,closeListbox:f}}export{H as makeComboboxAccessible};
1
+ function $({comboboxInputId:h,comboboxButtonId:A,listBoxId:b,listBoxItemsClass:u,callback:a}){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 s=document.getElementById(`${b}`);if(!s)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=A?document.getElementById(`${A}`):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"),s.setAttribute("role","listbox");let m=null;function p(){return m||(m=s.querySelectorAll(`.${u}`)),Array.from(m).filter(e=>!e.hidden&&e.style.display!=="none")}function x(){return o.getAttribute("aria-expanded")==="true"}function f(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"}),a?.onActiveDescendantChange)try{a.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"),s.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function d(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),s.style.display="none",r=-1,a?.onOpenChange)try{a.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in combobox onOpenChange callback:",e);}}function g(e){let t=e.textContent?.trim()||"";if(o.value=t,e.setAttribute("aria-selected","true"),d(),a?.onSelect)try{a.onSelect(e);}catch(n){console.error("[aria-ease] Error in combobox onSelect callback:",n);}}function L(e){let t=p(),n=x();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;f(i);}break;case "ArrowUp":if(e.preventDefault(),!n)return;if(t.length>0){let i=r<=0?t.length-1:r-1;f(i);}break;case "Enter":n&&r>=0&&r<t.length&&(e.preventDefault(),g(t[r]));break;case "Escape":if(n)e.preventDefault(),d();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");}),a?.onClear))try{a.onClear();}catch(c){console.error("[aria-ease] Error in combobox onClear callback:",c);}break;case "Home":n&&t.length>0&&(e.preventDefault(),f(0));break;case "End":n&&t.length>0&&(e.preventDefault(),f(t.length-1));break;case "Tab":n&&r>=0&&r<t.length&&g(t[r]),n&&d();break}}function y(e){let t=e.target;if(t.classList.contains(u)){let i=p().indexOf(t);i>=0&&f(i);}}function k(e){let t=e.target;t.classList.contains(u)&&(e.preventDefault(),g(t));}function C(e){let t=e.target;!o.contains(t)&&!s.contains(t)&&(!l||!l.contains(t))&&d();}function E(){x()?d():(v(),o.focus());}function w(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E());}o.addEventListener("keydown",L),s.addEventListener("mousemove",y),s.addEventListener("mousedown",k),document.addEventListener("mousedown",C),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",E),l.addEventListener("keydown",w));function M(){let e=s.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 O=n.getAttribute("id");if(!O||O===""){let D=`${b}-option-${i}`;n.id=D,n.setAttribute("id",D);}});}M();function T(){o.removeEventListener("keydown",L),s.removeEventListener("mousemove",y),s.removeEventListener("mousedown",k),document.removeEventListener("mousedown",C),l&&(l.removeEventListener("click",E),l.removeEventListener("keydown",w));}function H(){m=null,M(),r=-1,f(-1);}return {cleanup:T,refresh:H,openListbox:v,closeListbox:d}}export{$ as makeComboboxAccessible};
@@ -1 +1 @@
1
- 'use strict';function F({menuId:f,menuItemsClass:E,triggerId:p,callback:s}){let o=document.querySelector(`#${f}`);if(!o)return console.error(`[aria-ease] Element with id="${f}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${p}`);if(!i)return console.error(`[aria-ease] Element with id="${p}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(f))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",f),i.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",p);let g=new WeakMap,d=new Map,m=null,b=null;function M(){return m||(m=o.querySelectorAll(`.${E}`)),m}function u(){if(!b){let e=M();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=S(n),a=n.getAttribute("aria-disabled")==="true";r||(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),a||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,a=(t+n+r)%r;e.item(a).focus();}function k(e,t){e.length!==0&&e[t]?.focus();}function T(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 a=document.getElementById(r);if(!a)break;t=a;}}C();function v(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){e.preventDefault(),l();return}break}case "ArrowUp":{e.preventDefault(),L(A(u()),n,-1);break}case "ArrowRight":{if(e.key==="ArrowRight"&&T(t)){e.preventDefault();let r=t.getAttribute("aria-controls");if(r){y(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(),i.focus(),c&&c(false);break}case "Enter":case " ":{if(e.preventDefault(),T(t)){let r=t.getAttribute("aria-controls");if(r){y(r);return}}t.click(),l(),c&&c(false);break}case "Tab":{l(),$(i),c&&c(false);break}}}function S(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 h(e){i.setAttribute("aria-expanded",e?"true":"false");}function y(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 "${f}".`);return}if(!n.id){let a=`trigger-${e}`;n.id=a,console.warn(`[aria-ease] Submenu trigger for "${e}" had no ID. Auto-generated ID: "${a}".`);}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:E,triggerId:n.id,callback:s}),d.set(e,t);}t.openMenu();}function c(e){if(s?.onOpenChange)try{s.onOpenChange(e);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function D(){u().forEach((t,n)=>{if(!g.has(t)){let r=a=>v(a,t,n);t.addEventListener("keydown",r),g.set(t,r);}});}function H(){u().forEach(t=>{let n=g.get(t);n&&(t.removeEventListener("keydown",n),g.delete(t));});}function w(){h(true),o.style.display="block";let e=u();if(D(),e&&e.length>0&&e[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),h(false),o.style.display="none",H(),i.focus(),s?.onOpenChange)try{s.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in menu onOpenChange callback:",e);}}function O(){i.getAttribute("aria-expanded")==="true"?l():w();}function x(e){if(!(i.getAttribute("aria-expanded")==="true"))return;let n=i.contains(e.target),r=o.contains(e.target);!n&&!r&&l();}i.addEventListener("click",O),document.addEventListener("click",x);function N(){H(),i.removeEventListener("click",O),document.removeEventListener("click",x),o.style.display="none",h(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){m=null,b=null;}return {openMenu:w,closeMenu:l,cleanup:N,refresh:q}}exports.makeMenuAccessible=F;
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 a=document.querySelector(`#${c}`);if(!a)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 o=document.querySelector(`#${m}`);if(!o)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:()=>{}};o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",c),o.setAttribute("aria-expanded","false"),a.setAttribute("role","menu"),a.setAttribute("aria-labelledby",m);let p=new WeakMap,d=new Map,g=null,b=null;function E(){return g||(g=a.querySelectorAll(`.${h}`)),g}function u(){if(!b){let e=E();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=S(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 v(){E().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 C(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;}}v();function $(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&o.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(),o.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(),C(o),f&&f(false);break}}}function S(e){let t=e.parentElement;for(;t&&t!==a;){if(t.getAttribute("role")==="menu"||t.id&&a.querySelector(`[aria-controls="${t.id}"]`))return true;t=t.parentElement;}return false}function M(e){o.setAttribute("aria-expanded",e?"true":"false");}function T(e){let t=d.get(e);if(!t){let n=a.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?.onOpenChange)try{s.onOpenChange(e);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function D(){u().forEach((t,n)=>{if(!p.has(t)){let r=i=>$(i,t,n);t.addEventListener("keydown",r),p.set(t,r);}});}function H(){u().forEach(t=>{let n=p.get(t);n&&(t.removeEventListener("keydown",n),p.delete(t));});}function w(){M(true),a.style.display="block";let e=u();if(D(),e&&e.length>0&&e[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),M(false),a.style.display="none",H(),o.focus(),s?.onOpenChange)try{s.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in menu onOpenChange callback:",e);}}function O(){o.getAttribute("aria-expanded")==="true"?l():w();}function x(e){if(!(o.getAttribute("aria-expanded")==="true"))return;let n=o.contains(e.target),r=a.contains(e.target);!n&&!r&&l();}o.addEventListener("click",O),document.addEventListener("click",x);function N(){H(),o.removeEventListener("click",O),document.removeEventListener("click",x),a.style.display="none",M(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){g=null,b=null;}return {openMenu:w,closeMenu:l,cleanup:N,refresh:q}}exports.makeMenuAccessible=F;
@@ -1 +1 @@
1
- function F({menuId:f,menuItemsClass:E,triggerId:p,callback:s}){let o=document.querySelector(`#${f}`);if(!o)return console.error(`[aria-ease] Element with id="${f}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${p}`);if(!i)return console.error(`[aria-ease] Element with id="${p}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(f))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",f),i.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",p);let g=new WeakMap,d=new Map,m=null,b=null;function M(){return m||(m=o.querySelectorAll(`.${E}`)),m}function u(){if(!b){let e=M();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=S(n),a=n.getAttribute("aria-disabled")==="true";r||(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),a||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,a=(t+n+r)%r;e.item(a).focus();}function k(e,t){e.length!==0&&e[t]?.focus();}function T(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 a=document.getElementById(r);if(!a)break;t=a;}}C();function v(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){e.preventDefault(),l();return}break}case "ArrowUp":{e.preventDefault(),L(A(u()),n,-1);break}case "ArrowRight":{if(e.key==="ArrowRight"&&T(t)){e.preventDefault();let r=t.getAttribute("aria-controls");if(r){y(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(),i.focus(),c&&c(false);break}case "Enter":case " ":{if(e.preventDefault(),T(t)){let r=t.getAttribute("aria-controls");if(r){y(r);return}}t.click(),l(),c&&c(false);break}case "Tab":{l(),$(i),c&&c(false);break}}}function S(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 h(e){i.setAttribute("aria-expanded",e?"true":"false");}function y(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 "${f}".`);return}if(!n.id){let a=`trigger-${e}`;n.id=a,console.warn(`[aria-ease] Submenu trigger for "${e}" had no ID. Auto-generated ID: "${a}".`);}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:E,triggerId:n.id,callback:s}),d.set(e,t);}t.openMenu();}function c(e){if(s?.onOpenChange)try{s.onOpenChange(e);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function D(){u().forEach((t,n)=>{if(!g.has(t)){let r=a=>v(a,t,n);t.addEventListener("keydown",r),g.set(t,r);}});}function H(){u().forEach(t=>{let n=g.get(t);n&&(t.removeEventListener("keydown",n),g.delete(t));});}function w(){h(true),o.style.display="block";let e=u();if(D(),e&&e.length>0&&e[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),h(false),o.style.display="none",H(),i.focus(),s?.onOpenChange)try{s.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in menu onOpenChange callback:",e);}}function O(){i.getAttribute("aria-expanded")==="true"?l():w();}function x(e){if(!(i.getAttribute("aria-expanded")==="true"))return;let n=i.contains(e.target),r=o.contains(e.target);!n&&!r&&l();}i.addEventListener("click",O),document.addEventListener("click",x);function N(){H(),i.removeEventListener("click",O),document.removeEventListener("click",x),o.style.display="none",h(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){m=null,b=null;}return {openMenu:w,closeMenu:l,cleanup:N,refresh:q}}export{F as makeMenuAccessible};
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 a=document.querySelector(`#${c}`);if(!a)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 o=document.querySelector(`#${m}`);if(!o)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:()=>{}};o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",c),o.setAttribute("aria-expanded","false"),a.setAttribute("role","menu"),a.setAttribute("aria-labelledby",m);let p=new WeakMap,d=new Map,g=null,b=null;function E(){return g||(g=a.querySelectorAll(`.${h}`)),g}function u(){if(!b){let e=E();b=[];for(let t=0;t<e.length;t++){let n=e.item(t),r=S(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 v(){E().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 C(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;}}v();function $(e,t,n){switch(e.key){case "ArrowLeft":{if(e.key==="ArrowLeft"&&o.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(),o.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(),C(o),f&&f(false);break}}}function S(e){let t=e.parentElement;for(;t&&t!==a;){if(t.getAttribute("role")==="menu"||t.id&&a.querySelector(`[aria-controls="${t.id}"]`))return true;t=t.parentElement;}return false}function M(e){o.setAttribute("aria-expanded",e?"true":"false");}function T(e){let t=d.get(e);if(!t){let n=a.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?.onOpenChange)try{s.onOpenChange(e);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function D(){u().forEach((t,n)=>{if(!p.has(t)){let r=i=>$(i,t,n);t.addEventListener("keydown",r),p.set(t,r);}});}function H(){u().forEach(t=>{let n=p.get(t);n&&(t.removeEventListener("keydown",n),p.delete(t));});}function w(){M(true),a.style.display="block";let e=u();if(D(),e&&e.length>0&&e[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0);}catch(t){console.error("[aria-ease] Error in menu onOpenChange callback:",t);}}function l(){if(d.forEach(e=>e.closeMenu()),M(false),a.style.display="none",H(),o.focus(),s?.onOpenChange)try{s.onOpenChange(!1);}catch(e){console.error("[aria-ease] Error in menu onOpenChange callback:",e);}}function O(){o.getAttribute("aria-expanded")==="true"?l():w();}function x(e){if(!(o.getAttribute("aria-expanded")==="true"))return;let n=o.contains(e.target),r=a.contains(e.target);!n&&!r&&l();}o.addEventListener("click",O),document.addEventListener("click",x);function N(){H(),o.removeEventListener("click",O),document.removeEventListener("click",x),a.style.display="none",M(false),d.forEach(e=>e.cleanup()),d.clear();}function q(){g=null,b=null;}return {openMenu:w,closeMenu:l,cleanup:N,refresh:q}}export{F as makeMenuAccessible};
@@ -1 +1 @@
1
- 'use strict';function E({radioGroupId:u,radiosClass:d,defaultSelectedIndex:f=0}){let i=document.querySelector(`#${u}`);if(!i)return console.error(`[aria-ease] Element with id="${u}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};let t=Array.from(i.querySelectorAll(`.${d}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${d}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let s=new WeakMap,l=new WeakMap,r=f;function b(){i.getAttribute("role")||i.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 o(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 k(e){return ()=>{o(e);}}function m(e){return n=>{let{key:a}=n,c=e;switch(a){case "ArrowDown":case "ArrowRight":n.preventDefault(),c=(e+1)%t.length,o(c);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),c=(e-1+t.length)%t.length,o(c);break;case " ":case "Enter":n.preventDefault(),o(e);break}}}function h(){t.forEach((e,n)=>{let a=k(n),c=m(n);e.addEventListener("click",a),e.addEventListener("keydown",c),s.set(e,c),l.set(e,a);});}function A(){t.forEach(e=>{let n=s.get(e),a=l.get(e);n&&(e.removeEventListener("keydown",n),s.delete(e)),a&&(e.removeEventListener("click",a),l.delete(e));});}function g(){A();}function p(){return r}return b(),h(),{selectRadio:o,getSelectedIndex:p,cleanup:g}}exports.makeRadioAccessible=E;
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 +1 @@
1
- function E({radioGroupId:u,radiosClass:d,defaultSelectedIndex:f=0}){let i=document.querySelector(`#${u}`);if(!i)return console.error(`[aria-ease] Element with id="${u}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};let t=Array.from(i.querySelectorAll(`.${d}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${d}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let s=new WeakMap,l=new WeakMap,r=f;function b(){i.getAttribute("role")||i.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 o(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 k(e){return ()=>{o(e);}}function m(e){return n=>{let{key:a}=n,c=e;switch(a){case "ArrowDown":case "ArrowRight":n.preventDefault(),c=(e+1)%t.length,o(c);break;case "ArrowUp":case "ArrowLeft":n.preventDefault(),c=(e-1+t.length)%t.length,o(c);break;case " ":case "Enter":n.preventDefault(),o(e);break}}}function h(){t.forEach((e,n)=>{let a=k(n),c=m(n);e.addEventListener("click",a),e.addEventListener("keydown",c),s.set(e,c),l.set(e,a);});}function A(){t.forEach(e=>{let n=s.get(e),a=l.get(e);n&&(e.removeEventListener("keydown",n),s.delete(e)),a&&(e.removeEventListener("click",a),l.delete(e));});}function g(){A();}function p(){return r}return b(),h(),{selectRadio:o,getSelectedIndex:p,cleanup:g}}export{E as makeRadioAccessible};
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};