aria-ease 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ComboboxComponentStrategy-DHZS4NW6.js +5 -0
- package/dist/MenuComponentStrategy-L3QXLC6S.js +5 -0
- package/dist/cli.cjs +3 -3
- package/dist/cli.js +1 -1
- package/dist/{contractTestRunnerPlaywright-IUUAGMXP.js → contractTestRunnerPlaywright-2CEH3GPM.js} +2 -2
- package/dist/{contractTestRunnerPlaywright-44QPA5JG.js → contractTestRunnerPlaywright-RUKMUY5P.js} +2 -2
- package/dist/index.cjs +11 -11
- package/dist/index.js +9 -9
- package/dist/src/utils/test/ComboboxComponentStrategy-5AWO63DA.js +5 -0
- package/dist/src/utils/test/MenuComponentStrategy-QHVBLUBR.js +5 -0
- package/dist/src/utils/test/{contractTestRunnerPlaywright-VALOFEZZ.js → contractTestRunnerPlaywright-LUWM3RIL.js} +2 -2
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +5 -5
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-MWX7KH44.js → test-PCRWMQUO.js} +1 -1
- package/package.json +1 -1
- package/dist/ComboboxComponentStrategy-YSYLR2U5.js +0 -5
- package/dist/MenuComponentStrategy-C22BZEBH.js +0 -5
- package/dist/src/utils/test/ComboboxComponentStrategy-SICWLI27.js +0 -5
- package/dist/src/utils/test/MenuComponentStrategy-R4VPAHDE.js +0 -5
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 He({accordionId:e,triggersClass:t,panelsClass:g,allowMultipleOpen:i=!1,callback:o}){if(e==="")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 a=document.querySelector(`#${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" 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 n=Array.from(a.querySelectorAll(`.${t}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(g==="")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 r=Array.from(a.querySelectorAll(`.${g}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${g}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(n.length!==r.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${n.length} triggers but ${r.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,s=new WeakMap;function p(){n.forEach((v,L)=>{let H=r[L];v.id||(v.id=`${e}-trigger-${L}`),H.id||(H.id=`${e}-panel-${L}`),v.setAttribute("aria-controls",H.id),v.setAttribute("aria-expanded","false"),(!i||n.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",v.id),H.style.display="none"})}function m(v){if(v<0||v>=n.length){console.error(`[aria-ease] Invalid accordion index: ${v}`);return}let L=n[v],H=r[v];if(L.setAttribute("aria-expanded","true"),H.style.display="block",o?.onExpand)try{o.onExpand(v)}catch(f){console.error("[aria-ease] Error in accordion onExpand callback:",f)}}function y(v){if(v<0||v>=n.length){console.error(`[aria-ease] Invalid accordion index: ${v}`);return}let L=n[v],H=r[v];if(L.setAttribute("aria-expanded","false"),H.style.display="none",o?.onCollapse)try{o.onCollapse(v)}catch(f){console.error("[aria-ease] Error in accordion onCollapse callback:",f)}}function x(v){n[v].getAttribute("aria-expanded")==="true"?y(v):(i||n.forEach((f,E)=>{E!==v&&y(E)}),m(v))}function C(v){return()=>{x(v)}}function D(v){return L=>{let{key:H}=L;switch(H){case"Enter":case" ":L.preventDefault(),x(v);break;case"ArrowDown":L.preventDefault();{let f=(v+1)%n.length;n[f].focus()}break;case"ArrowUp":L.preventDefault();{let f=(v-1+n.length)%n.length;n[f].focus()}break;case"Home":L.preventDefault(),n[0].focus();break;case"End":L.preventDefault(),n[n.length-1].focus();break}}}function c(){n.forEach((v,L)=>{let H=C(L),f=D(L);v.addEventListener("click",H),v.addEventListener("keydown",f),l.set(v,f),s.set(v,H)})}function u(){n.forEach(v=>{let L=l.get(v),H=s.get(v);L&&(v.removeEventListener("keydown",L),l.delete(v)),H&&(v.removeEventListener("click",H),s.delete(v))})}function k(){u(),n.forEach((v,L)=>{y(L)})}function S(){u();let v=Array.from(a.querySelectorAll(`.${t}`)),L=Array.from(a.querySelectorAll(`.${g}`));n.length=0,n.push(...v),r.length=0,r.push(...L),p(),c()}return p(),c(),{expandItem:m,collapseItem:y,toggleItem:x,cleanup:k,refresh:S}}function O(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function R(e){return e.tagName==="TEXTAREA"}function z(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function ee(e){return e.tagName==="A"}function _(e,t,g){let i=e.length,o=(t+g+i)%i;e.item(o).focus()}function te(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function W(e,t,g){let i=t.item(g);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!O(i)&&!R(i)||(O(i)||R(i))&&i.selectionStart===0)&&(e.preventDefault(),_(t,g,-1));break}case"ArrowDown":case"ArrowRight":{if(!O(i)&&!R(i))e.preventDefault(),_(t,g,1);else if(O(i)||R(i)){let o=i.value;i.selectionStart===o.length&&(e.preventDefault(),_(t,g,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!z(i)&&!ee(i)&&te(i)||z(i))&&(e.preventDefault(),i.click());break}case"Tab":break;default:break}}function $e({blockId:e,blockItemsClass:t}){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 g=document.querySelector(`#${e}`);if(!g)return console.error(`[aria-ease] Element with id="${e}" 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 o(){return i||(i=g.querySelectorAll(`.${t}`)),i}let a=o();if(!a||a.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let n=new Map;a.forEach(s=>{if(!n.has(s)){let p=m=>{let y=g.querySelectorAll(`.${t}`),x=Array.prototype.indexOf.call(y,s);W(m,y,x)};s.addEventListener("keydown",p),n.set(s,p)}});function r(){a.forEach(s=>{let p=n.get(s);p&&(s.removeEventListener("keydown",p),n.delete(s))})}function l(){i=null}return{cleanup:r,refresh:l}}function Ie({checkboxGroupId:e,checkboxesClass:t}){if(e==="")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 g=document.querySelector(`#${e}`);if(!g)return console.error(`[aria-ease] Element with id="${e}" 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(g.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 o=new WeakMap,a=new WeakMap;function n(){g.getAttribute("role")||g.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 r(c){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}let u=i[c],k=u.getAttribute("aria-checked")==="true";u.setAttribute("aria-checked",k?"false":"true")}function l(c,u){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}i[c].setAttribute("aria-checked",u?"true":"false")}function s(c){return()=>{r(c)}}function p(c){return u=>{let{key:k}=u;switch(k){case" ":u.preventDefault(),r(c);break}}}function m(){i.forEach((c,u)=>{let k=s(u),S=p(u);c.addEventListener("click",k),c.addEventListener("keydown",S),o.set(c,S),a.set(c,k)})}function y(){i.forEach(c=>{let u=o.get(c),k=a.get(c);u&&(c.removeEventListener("keydown",u),o.delete(c)),k&&(c.removeEventListener("click",k),a.delete(c))})}function x(){y()}function C(){return i.map(c=>c.getAttribute("aria-checked")==="true")}function D(){return i.map((c,u)=>c.getAttribute("aria-checked")==="true"?u:-1).filter(c=>c!==-1)}return n(),m(),{toggleCheckbox:r,setCheckboxState:l,getCheckedStates:C,getCheckedIndices:D,cleanup:x}}function ne({menuId:e,menuItemsClass:t,triggerId:g,callback:i}){if(e==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let o=document.querySelector(`#${e}`);if(!o)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(g==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let a=document.querySelector(`#${g}`);if(!a)return console.error(`[aria-ease] Element with id="${g}" 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(e))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-controls",e),a.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",g);let n=new WeakMap,r=new Map,l=null,s=null;function p(){return l||(l=o.querySelectorAll(`.${t}`)),l}function m(){if(!s){let b=p();s=[];for(let h=0;h<b.length;h++){let w=b.item(h),$=S(w),P=w.getAttribute("aria-disabled")==="true";$||(w.hasAttribute("tabindex")||w.setAttribute("tabindex","-1"),P||s.push(w))}}return s}function y(b){return{length:b.length,item:w=>b[w],forEach:w=>{b.forEach(w)},[Symbol.iterator]:function*(){for(let w of b)yield w}}}function x(){p().forEach(h=>{h.setAttribute("role","menuitem");let w=h.getAttribute("data-submenu-id")??h.getAttribute("aria-controls"),$=h.hasAttribute("aria-haspopup")&&w;w&&(h.hasAttribute("data-submenu-id")||$)&&(h.setAttribute("aria-haspopup","menu"),h.setAttribute("aria-controls",w),h.hasAttribute("aria-expanded")||h.setAttribute("aria-expanded","false"))})}function C(b,h,w){let $=b.length,P=(h+w+$)%$;b.item(P).focus()}function D(b,h){b.length!==0&&b[h]?.focus()}function c(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function u(b){let h=b;for(;h&&h.getAttribute("role")==="menuitem";){let w=h.closest('[role="menu"]');if(!w)break;w.style.display="none",h.setAttribute("aria-expanded","false");let $=w.getAttribute("aria-labelledby");if(!$)break;let P=document.getElementById($);if(!P)break;h=P}}x();function k(b,h,w){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&a.getAttribute("role")==="menuitem"){b.preventDefault(),d();return}break}case"ArrowUp":{b.preventDefault(),C(y(m()),w,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&c(h)){b.preventDefault();let $=h.getAttribute("aria-controls");if($){L($);return}}break}case"ArrowDown":{b.preventDefault(),C(y(m()),w,1);break}case"Home":{b.preventDefault(),D(m(),0);break}case"End":{b.preventDefault();let $=m();D($,$.length-1);break}case"Escape":{b.preventDefault(),d(),a.focus(),H&&H(!1);break}case"Enter":case" ":{if(b.preventDefault(),c(h)){let $=h.getAttribute("aria-controls");if($){L($);return}}h.click(),d(),H&&H(!1);break}case"Tab":{d(),u(a),H&&H(!1);break}default:break}}function S(b){let h=b.parentElement;for(;h&&h!==o;){if(h.getAttribute("role")==="menu"||h.id&&o.querySelector(`[aria-controls="${h.id}"]`))return!0;h=h.parentElement}return!1}function v(b){a.setAttribute("aria-expanded",b?"true":"false")}function L(b){let h=r.get(b);if(!h){let w=o.querySelector(`[aria-controls="${b}"]`);if(!w){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${e}".`);return}if(!w.id){let P=`trigger-${b}`;w.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}h=ne({menuId:b,menuItemsClass:t,triggerId:w.id,callback:i}),r.set(b,h)}h.openMenu()}function H(b){if(i?.onOpenChange)try{i.onOpenChange(b)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function f(){m().forEach((h,w)=>{if(!n.has(h)){let $=P=>k(P,h,w);h.addEventListener("keydown",$),n.set(h,$)}})}function E(){m().forEach(h=>{let w=n.get(h);w&&(h.removeEventListener("keydown",w),n.delete(h))})}function M(){v(!0),o.style.display="block";let b=m();if(f(),b&&b.length>0&&b[0].focus(),i?.onOpenChange)try{i.onOpenChange(!0)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function d(){if(r.forEach(b=>b.closeMenu()),v(!1),o.style.display="none",E(),a.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function A(){a.getAttribute("aria-expanded")==="true"?d():M()}function T(b){if(!(a.getAttribute("aria-expanded")==="true"))return;let w=a.contains(b.target),$=o.contains(b.target);!w&&!$&&d()}a.addEventListener("click",A),document.addEventListener("click",T);function q(){E(),a.removeEventListener("click",A),document.removeEventListener("click",T),o.style.display="none",v(!1),r.forEach(b=>b.cleanup()),r.clear()}function I(){l=null,s=null}return{openMenu:M,closeMenu:d,cleanup:q,refresh:I}}function Re({radioGroupId:e,radiosClass:t,defaultSelectedIndex:g=0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" 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 o=Array.from(i.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let a=new WeakMap,n=new WeakMap,r=g;function l(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),o.forEach((c,u)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex",u===r?"0":"-1"),u===r?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function s(c){if(c<0||c>=o.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}r>=0&&r<o.length&&(o[r].setAttribute("aria-checked","false"),o[r].setAttribute("tabindex","-1")),o[c].setAttribute("aria-checked","true"),o[c].setAttribute("tabindex","0"),o[c].focus(),r=c}function p(c){return()=>{s(c)}}function m(c){return u=>{let{key:k}=u,S=c;switch(k){case"ArrowDown":case"ArrowRight":u.preventDefault(),S=(c+1)%o.length,s(S);break;case"ArrowUp":case"ArrowLeft":u.preventDefault(),S=(c-1+o.length)%o.length,s(S);break;case" ":case"Enter":u.preventDefault(),s(c);break}}}function y(){o.forEach((c,u)=>{let k=p(u),S=m(u);c.addEventListener("click",k),c.addEventListener("keydown",S),a.set(c,S),n.set(c,k)})}function x(){o.forEach(c=>{let u=a.get(c),k=n.get(c);u&&(c.removeEventListener("keydown",u),a.delete(c)),k&&(c.removeEventListener("click",k),n.delete(c))})}function C(){x()}function D(){return r}return l(),y(),{selectRadio:s,getSelectedIndex:D,cleanup:C}}function Ne({toggleId:e,togglesClass:t,isSingleToggle:g=!0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let o;if(g)o=[i];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(o=Array.from(i.querySelectorAll(`.${t}`)),o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,n=new WeakMap;function r(){o.forEach(u=>{u.tagName.toLowerCase()!=="button"&&!u.getAttribute("role")&&u.setAttribute("role","button"),u.hasAttribute("aria-pressed")||u.setAttribute("aria-pressed","false"),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0")})}function l(u){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}let k=o[u],S=k.getAttribute("aria-pressed")==="true";k.setAttribute("aria-pressed",S?"false":"true")}function s(u,k){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}o[u].setAttribute("aria-pressed",k?"true":"false")}function p(u){return()=>{l(u)}}function m(u){return k=>{let{key:S}=k;switch(S){case"Enter":case" ":k.preventDefault(),l(u);break}}}function y(){o.forEach((u,k)=>{let S=p(k),v=m(k);u.addEventListener("click",S),u.addEventListener("keydown",v),a.set(u,v),n.set(u,S)})}function x(){o.forEach(u=>{let k=a.get(u),S=n.get(u);k&&(u.removeEventListener("keydown",k),a.delete(u)),S&&(u.removeEventListener("click",S),n.delete(u))})}function C(){x()}function D(){return o.map(u=>u.getAttribute("aria-pressed")==="true")}function c(){return o.map((u,k)=>u.getAttribute("aria-pressed")==="true"?k:-1).filter(u=>u!==-1)}return r(),y(),{toggleButton:l,setPressed:s,getPressedStates:D,getPressedIndices:c,cleanup:C}}function Be({comboboxInputId:e,comboboxButtonId:t,listBoxId:g,listBoxItemsClass:i,callback:o}){if(e==="")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 a=document.getElementById(`${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(g==="")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 n=document.getElementById(`${g}`);if(!n)return console.error(`[aria-ease] Element with id="${g}" 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 l=t?document.getElementById(`${t}`):null,s=-1;a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-controls",g),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-haspopup","listbox"),n.setAttribute("role","listbox");let p=null;function m(){return p||(p=n.querySelectorAll(`.${i}`)),Array.from(p).filter(d=>!d.hidden&&d.style.display!=="none")}function y(){return a.getAttribute("aria-expanded")==="true"}function x(d){let A=m();if(d>=0&&d<A.length){let T=A[d],q=T.id||`${g}-option-${d}`;if(T.id||(T.id=q),a.setAttribute("aria-activedescendant",q),typeof T.scrollIntoView=="function"&&T.scrollIntoView({block:"nearest",behavior:"smooth"}),o?.onActiveDescendantChange)try{o.onActiveDescendantChange(q,T)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else a.setAttribute("aria-activedescendant","");s=d}function C(){if(a.setAttribute("aria-expanded","true"),n.style.display="block",o?.onOpenChange)try{o.onOpenChange(!0)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function D(){if(a.setAttribute("aria-expanded","false"),a.setAttribute("aria-activedescendant",""),n.style.display="none",s=-1,o?.onOpenChange)try{o.onOpenChange(!1)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function c(d){let A=d.textContent?.trim()||"";if(a.value=A,d.setAttribute("aria-selected","true"),D(),o?.onSelect)try{o.onSelect(d)}catch(T){console.error("[aria-ease] Error in combobox onSelect callback:",T)}}function u(d){let A=m(),T=y();switch(d.key){case"ArrowDown":if(d.preventDefault(),!T){C();return}if(A.length===0)return;{let q=s>=A.length-1?0:s+1;x(q)}break;case"ArrowUp":if(d.preventDefault(),!T)return;if(A.length>0){let q=s<=0?A.length-1:s-1;x(q)}break;case"Enter":T&&s>=0&&s<A.length&&(d.preventDefault(),c(A[s]));break;case"Escape":if(T)d.preventDefault(),D();else if(a.value&&(d.preventDefault(),a.value="",a.setAttribute("aria-activedescendant",""),m().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),o?.onClear))try{o.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":T&&A.length>0&&(d.preventDefault(),x(0));break;case"End":T&&A.length>0&&(d.preventDefault(),x(A.length-1));break;case"Tab":T&&s>=0&&s<A.length&&c(A[s]),T&&D();break}}function k(d){let A=d.target;if(A.classList.contains(i)){let q=m().indexOf(A);q>=0&&x(q)}}function S(d){let A=d.target;A.classList.contains(i)&&(d.preventDefault(),c(A))}function v(d){let A=d.target;!a.contains(A)&&!n.contains(A)&&(!l||!l.contains(A))&&D()}function L(){y()?D():(C(),a.focus())}function H(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),L())}a.addEventListener("keydown",u),n.addEventListener("mousemove",k),n.addEventListener("mousedown",S),document.addEventListener("mousedown",v),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",L),l.addEventListener("keydown",H));function f(){let d=n.querySelectorAll(`.${i}`);if(d.length===0)return;let A=null;for(let T of d)if(T.getAttribute("aria-selected")==="true"){A=T.textContent?.trim()||null;break}!A&&a.value&&(A=a.value.trim()),d.forEach((T,q)=>{T.setAttribute("role","option");let I=T.textContent?.trim()||"";A&&I===A?T.setAttribute("aria-selected","true"):T.setAttribute("aria-selected","false");let b=T.getAttribute("id");if(!b||b===""){let h=`${g}-option-${q}`;T.id=h,T.setAttribute("id",h)}})}f();function E(){a.removeEventListener("keydown",u),n.removeEventListener("mousemove",k),n.removeEventListener("mousedown",S),document.removeEventListener("mousedown",v),l&&(l.removeEventListener("click",L),l.removeEventListener("keydown",H))}function M(){p=null,f(),s=-1,x(-1)}return{cleanup:E,refresh:M,openListbox:C,closeListbox:D}}function Ke({tabListId:e,tabsClass:t,tabPanelsClass:g,orientation:i="horizontal",activateOnFocus:o=!0,callback:a}){if(e==="")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 n=document.querySelector(`#${e}`);if(!n)return console.error(`[aria-ease] Element with id="${e}" 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 r=Array.from(n.querySelectorAll(`.${t}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(g==="")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 l=Array.from(document.querySelectorAll(`.${g}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${g}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${r.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,p=new WeakMap,m=new WeakMap,y=0;function x(){n.setAttribute("role","tablist"),n.setAttribute("aria-orientation",i),r.forEach((f,E)=>{let M=l[E];f.id||(f.id=`${e}-tab-${E}`),M.id||(M.id=`${e}-panel-${E}`),f.setAttribute("role","tab"),f.setAttribute("aria-controls",M.id),f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1"),M.setAttribute("role","tabpanel"),M.setAttribute("aria-labelledby",f.id),M.hidden=!0,M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||M.setAttribute("tabindex","0")}),C(0,!1)}function C(f,E=!0){if(f<0||f>=r.length){console.error(`[aria-ease] Invalid tab index: ${f}`);return}let M=y;r.forEach((T,q)=>{let I=l[q];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),I.hidden=!0});let d=r[f],A=l[f];if(d.setAttribute("aria-selected","true"),d.setAttribute("tabindex","0"),A.hidden=!1,E&&d.focus(),y=f,a?.onTabChange&&M!==f)try{a.onTabChange(f,M)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function D(f){let E=r.findIndex(A=>A===document.activeElement),M=E!==-1?E:y,d=M;switch(f){case"first":d=0;break;case"last":d=r.length-1;break;case"next":d=(M+1)%r.length;break;case"prev":d=(M-1+r.length)%r.length;break}if(r[d].focus(),r[d].setAttribute("tabindex","0"),r[y].setAttribute("tabindex","-1"),o)C(d,!1);else{let A=y;r.forEach((T,q)=>{q===d?T.setAttribute("tabindex","0"):q!==A&&T.setAttribute("tabindex","-1")})}}function c(f){return()=>{C(f)}}function u(f){return E=>{let{key:M}=E,d=!1;if(i==="horizontal")switch(M){case"ArrowLeft":E.preventDefault(),D("prev"),d=!0;break;case"ArrowRight":E.preventDefault(),D("next"),d=!0;break}else switch(M){case"ArrowUp":E.preventDefault(),D("prev"),d=!0;break;case"ArrowDown":E.preventDefault(),D("next"),d=!0;break}if(!d)switch(M){case"Home":E.preventDefault(),D("first");break;case"End":E.preventDefault(),D("last");break;case" ":case"Enter":o||(E.preventDefault(),C(f));break;case"F10":if(E.shiftKey&&a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function k(f){return E=>{if(a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(M){console.error("[aria-ease] Error in tabs onContextMenu callback:",M)}}}}function S(){r.forEach((f,E)=>{let M=c(E),d=u(E),A=k(E);f.addEventListener("click",M),f.addEventListener("keydown",d),a?.onContextMenu&&(f.addEventListener("contextmenu",A),m.set(f,A)),s.set(f,d),p.set(f,M)})}function v(){r.forEach(f=>{let E=s.get(f),M=p.get(f),d=m.get(f);E&&(f.removeEventListener("keydown",E),s.delete(f)),M&&(f.removeEventListener("click",M),p.delete(f)),d&&(f.removeEventListener("contextmenu",d),m.delete(f))})}function L(){v(),r.forEach((f,E)=>{let M=l[E];f.removeAttribute("role"),f.removeAttribute("aria-selected"),f.removeAttribute("aria-controls"),f.removeAttribute("tabindex"),M.removeAttribute("role"),M.removeAttribute("aria-labelledby"),M.removeAttribute("tabindex"),M.hidden=!1}),n.removeAttribute("role"),n.removeAttribute("aria-orientation")}function H(){v();let f=Array.from(n.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${g}`));r.length=0,r.push(...f),l.length=0,l.push(...E),x(),S()}return x(),S(),{activateTab:C,cleanup:L,refresh:H}}var j={"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:[...ie(),...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:{requires:["popup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"input",key:"ArrowDown"})):e.relativeTarget==="first"?[]:e.relativeTarget==="last"?[{type:"keypress",target:"input",key:"ArrowUp"}]:[]}],assertion:(e={})=>se(e.relativeTarget)},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ae},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},selectedOption:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function ie(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function se(e){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,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:"!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 oe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} 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 G={"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:ge},activeItem:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>me(e.relativeTarget)},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:he},"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:ye},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:Ae},activeSubmenuItem:{requires:["submenu.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ke(e.relativeTarget)}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected 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:"Expected menu main to have aria-expanded='false'."}]}function be(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function ge(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function me(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function he(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected 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:"Expected submenu trigger to have aria-expanded='false'."}]}function ye(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Ae(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function ke(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var X={activeTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Me(e.relativeTarget)},focusedTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ee(e.relativeTarget)}};function Ee(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function Te(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function Me(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},Te(e)]}function we(e,t){return t.some(g=>e.capabilities.includes(g))}function N(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let g of e)if(we(t,g.when))return g.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var xe={combobox:j,menu:G,tabs:X},B=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},F=class{constructor(t){this.componentName=t;this.statePack=xe[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let g=this.statePack,i={capabilities:["keyboard"]},o=(n,r=new Set)=>{if(r.has(n))return[];r.add(n);let l=g[n];if(!l)return[];let s=[];if(Array.isArray(l.requires))for(let p of l.requires)s=s.concat(o(p,r));return l.setup&&(s=s.concat(N(l.setup,i))),s};return t({ariaReference:(n,r,l)=>({requires:s=>{let p=o(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended"})}),contains:(n,r)=>({requires:l=>{let s=o(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended"})})}),this}static(t){return t({target:i=>{let o=r=>{let l=this.statePack,s={capabilities:["keyboard"]},p=(m,y=new Set)=>{if(y.has(m))return[];y.add(m);let x=l[m];if(!x)return[];let C=[];if(Array.isArray(x.requires))for(let D of x.requires)C=C.concat(p(D,y));return x.setup&&(C=C.concat(N(x.setup,s))),C};return p(r,new Set)},a=r=>r==="role"?"toHaveRole":"toHaveAttribute",n=(r,l,s)=>{let p=a(r);return{required:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"recommended",setup:s})}};return{has:(r,l)=>({...n(r,l),requires:p=>{let m=o(p);return n(r,l,m)}})}}}),this}when(t){return new K(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}}},K=class{constructor(t,g,i){this.parent=t;this.statePack=g;this.event=i}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,g){return this._onTarget=t,this._onRelativeTarget=g,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return(Array.isArray(t)?t:[t]).flatMap(i=>typeof i=="string"?[i]:typeof i=="object"&&i!==null&&"type"in i&&"ref"in i?this._findStateKeyByTypeAndRef(i.type)?[{type:i.type,ref:i.ref}]:[]:[i])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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"]},o=(s,p=new Set)=>{if(p.has(s))return[];p.add(s);let m=this.statePack[s];if(!m)return[];let y=[];if(Array.isArray(m.requires))for(let x of m.requires)y=y.concat(o(x,p));return m.setup&&(y=y.concat(N(m.setup,i))),y},a=[];for(let s of this._given)if(typeof s=="string")a.push(...o(s));else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let m=this.statePack[p];if(m&&m.setup)for(let y of m.setup)typeof y.steps=="function"?a.push(...y.steps({relativeTarget:s.ref})):Array.isArray(y.steps)&&a.push(...y.steps)}}let n=new Set;a=a.filter(s=>{let p=JSON.stringify(s);return n.has(p)?!1:(n.add(p),!0)});let r=[];for(let s of this._then)if(typeof s=="string"){let p=this.statePack[s];if(p&&p.assertion!==void 0){let m=p.assertion;if(typeof m=="function")try{m=m()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(m)?r.push(...m):r.push(m)}}else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let m=this.statePack[p];if(m&&m.assertion!==void 0){let y=m.assertion;if(typeof y=="function")try{y=y({relativeTarget:s.ref})}catch(x){throw new Error(`Error calling assertion function for state '${p}': ${x.message}`)}Array.isArray(y)?r.push(...y):r.push(y)}}}let l=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:l,assertions:r,...a.length?{setup:a}:{}})}};function et(e,t){let g=new F(e);return t(g),new B(g.build())}import Le from"path";async function Q(e,t,g={}){if(!e||typeof e!="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 o(p){try{let m=await fetch(p,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(m.ok||m.status===304)return p}catch{return null}return null}let a=V(g.strictness),n={},r=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:p}=await import("./configLoader-ZEJVXLX7.js"),m=await p(process.cwd());if(n=m.config,m.configPath&&(r=Le.dirname(m.configPath)),g.strictness===void 0){let y=n.test?.components?.find(x=>x?.name===e)?.strictness;a=V(y??n.test?.strictness)}}catch{g.strictness===void 0&&(a="balanced")}let l;try{if(t){let p=await o(t);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:m}=await import("./contractTestRunnerPlaywright-44QPA5JG.js");l=await m(e,p,a,n,r)}else throw new Error(`\u274C Dev server not running at ${t}
|
|
1
|
+
import{b as U,d as B}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function He({accordionId:e,triggersClass:t,panelsClass:m,allowMultipleOpen:i=!1,callback:o}){if(e==="")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 a=document.querySelector(`#${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" 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 n=Array.from(a.querySelectorAll(`.${t}`));if(n.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 r=Array.from(a.querySelectorAll(`.${m}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(n.length!==r.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${n.length} triggers but ${r.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,s=new WeakMap;function p(){n.forEach((y,L)=>{let H=r[L];y.id||(y.id=`${e}-trigger-${L}`),H.id||(H.id=`${e}-panel-${L}`),y.setAttribute("aria-controls",H.id),y.setAttribute("aria-expanded","false"),(!i||n.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",y.id),H.style.display="none"})}function g(y){if(y<0||y>=n.length){console.error(`[aria-ease] Invalid accordion index: ${y}`);return}let L=n[y],H=r[y];if(L.setAttribute("aria-expanded","true"),H.style.display="block",o?.onExpand)try{o.onExpand(y)}catch(f){console.error("[aria-ease] Error in accordion onExpand callback:",f)}}function v(y){if(y<0||y>=n.length){console.error(`[aria-ease] Invalid accordion index: ${y}`);return}let L=n[y],H=r[y];if(L.setAttribute("aria-expanded","false"),H.style.display="none",o?.onCollapse)try{o.onCollapse(y)}catch(f){console.error("[aria-ease] Error in accordion onCollapse callback:",f)}}function x(y){n[y].getAttribute("aria-expanded")==="true"?v(y):(i||n.forEach((f,E)=>{E!==y&&v(E)}),g(y))}function C(y){return()=>{x(y)}}function D(y){return L=>{let{key:H}=L;switch(H){case"Enter":case" ":L.preventDefault(),x(y);break;case"ArrowDown":L.preventDefault();{let f=(y+1)%n.length;n[f].focus()}break;case"ArrowUp":L.preventDefault();{let f=(y-1+n.length)%n.length;n[f].focus()}break;case"Home":L.preventDefault(),n[0].focus();break;case"End":L.preventDefault(),n[n.length-1].focus();break}}}function c(){n.forEach((y,L)=>{let H=C(L),f=D(L);y.addEventListener("click",H),y.addEventListener("keydown",f),l.set(y,f),s.set(y,H)})}function u(){n.forEach(y=>{let L=l.get(y),H=s.get(y);L&&(y.removeEventListener("keydown",L),l.delete(y)),H&&(y.removeEventListener("click",H),s.delete(y))})}function k(){u(),n.forEach((y,L)=>{v(L)})}function S(){u();let y=Array.from(a.querySelectorAll(`.${t}`)),L=Array.from(a.querySelectorAll(`.${m}`));n.length=0,n.push(...y),r.length=0,r.push(...L),p(),c()}return p(),c(),{expandItem:g,collapseItem:v,toggleItem:x,cleanup:k,refresh:S}}function R(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function O(e){return e.tagName==="TEXTAREA"}function z(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function ee(e){return e.tagName==="A"}function _(e,t,m){let i=e.length,o=(t+m+i)%i;e.item(o).focus()}function te(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function W(e,t,m){let i=t.item(m);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!R(i)&&!O(i)||(R(i)||O(i))&&i.selectionStart===0)&&(e.preventDefault(),_(t,m,-1));break}case"ArrowDown":case"ArrowRight":{if(!R(i)&&!O(i))e.preventDefault(),_(t,m,1);else if(R(i)||O(i)){let o=i.value;i.selectionStart===o.length&&(e.preventDefault(),_(t,m,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!z(i)&&!ee(i)&&te(i)||z(i))&&(e.preventDefault(),i.click());break}case"Tab":break;default:break}}function $e({blockId:e,blockItemsClass:t}){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 m=document.querySelector(`#${e}`);if(!m)return console.error(`[aria-ease] Element with id="${e}" 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 o(){return i||(i=m.querySelectorAll(`.${t}`)),i}let a=o();if(!a||a.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let n=new Map;a.forEach(s=>{if(!n.has(s)){let p=g=>{let v=m.querySelectorAll(`.${t}`),x=Array.prototype.indexOf.call(v,s);W(g,v,x)};s.addEventListener("keydown",p),n.set(s,p)}});function r(){a.forEach(s=>{let p=n.get(s);p&&(s.removeEventListener("keydown",p),n.delete(s))})}function l(){i=null}return{cleanup:r,refresh:l}}function Ie({checkboxGroupId:e,checkboxesClass:t}){if(e==="")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(`#${e}`);if(!m)return console.error(`[aria-ease] Element with id="${e}" 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 o=new WeakMap,a=new WeakMap;function n(){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 r(c){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}let u=i[c],k=u.getAttribute("aria-checked")==="true";u.setAttribute("aria-checked",k?"false":"true")}function l(c,u){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}i[c].setAttribute("aria-checked",u?"true":"false")}function s(c){return()=>{r(c)}}function p(c){return u=>{let{key:k}=u;switch(k){case" ":u.preventDefault(),r(c);break}}}function g(){i.forEach((c,u)=>{let k=s(u),S=p(u);c.addEventListener("click",k),c.addEventListener("keydown",S),o.set(c,S),a.set(c,k)})}function v(){i.forEach(c=>{let u=o.get(c),k=a.get(c);u&&(c.removeEventListener("keydown",u),o.delete(c)),k&&(c.removeEventListener("click",k),a.delete(c))})}function x(){v()}function C(){return i.map(c=>c.getAttribute("aria-checked")==="true")}function D(){return i.map((c,u)=>c.getAttribute("aria-checked")==="true"?u:-1).filter(c=>c!==-1)}return n(),g(),{toggleCheckbox:r,setCheckboxState:l,getCheckedStates:C,getCheckedIndices:D,cleanup:x}}function ne({menuId:e,menuItemsClass:t,triggerId:m,callback:i}){if(e==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let o=document.querySelector(`#${e}`);if(!o)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let a=document.querySelector(`#${m}`);if(!a)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(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(e))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-controls",e),a.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",m);let n=new WeakMap,r=new Map,l=null,s=null;function p(){return l||(l=o.querySelectorAll(`.${t}`)),l}function g(){if(!s){let b=p();s=[];for(let h=0;h<b.length;h++){let M=b.item(h),$=S(M),P=M.getAttribute("aria-disabled")==="true";$||(M.hasAttribute("tabindex")||M.setAttribute("tabindex","-1"),P||s.push(M))}}return s}function v(b){return{length:b.length,item:M=>b[M],forEach:M=>{b.forEach(M)},[Symbol.iterator]:function*(){for(let M of b)yield M}}}function x(){p().forEach(h=>{h.setAttribute("role","menuitem");let M=h.getAttribute("data-submenu-id")??h.getAttribute("aria-controls"),$=h.hasAttribute("aria-haspopup")&&M;M&&(h.hasAttribute("data-submenu-id")||$)&&(h.setAttribute("aria-haspopup","menu"),h.setAttribute("aria-controls",M),h.hasAttribute("aria-expanded")||h.setAttribute("aria-expanded","false"))})}function C(b,h,M){let $=b.length,P=(h+M+$)%$;b.item(P).focus()}function D(b,h){b.length!==0&&b[h]?.focus()}function c(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function u(b){let h=b;for(;h&&h.getAttribute("role")==="menuitem";){let M=h.closest('[role="menu"]');if(!M)break;M.style.display="none",h.setAttribute("aria-expanded","false");let $=M.getAttribute("aria-labelledby");if(!$)break;let P=document.getElementById($);if(!P)break;h=P}}x();function k(b,h,M){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&a.getAttribute("role")==="menuitem"){b.preventDefault(),d();return}break}case"ArrowUp":{b.preventDefault(),C(v(g()),M,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&c(h)){b.preventDefault();let $=h.getAttribute("aria-controls");if($){L($);return}}break}case"ArrowDown":{b.preventDefault(),C(v(g()),M,1);break}case"Home":{b.preventDefault(),D(g(),0);break}case"End":{b.preventDefault();let $=g();D($,$.length-1);break}case"Escape":{b.preventDefault(),d(),a.focus(),H&&H(!1);break}case"Enter":case" ":{if(b.preventDefault(),c(h)){let $=h.getAttribute("aria-controls");if($){L($);return}}h.click(),d(),H&&H(!1);break}case"Tab":{d(),u(a),H&&H(!1);break}default:break}}function S(b){let h=b.parentElement;for(;h&&h!==o;){if(h.getAttribute("role")==="menu"||h.id&&o.querySelector(`[aria-controls="${h.id}"]`))return!0;h=h.parentElement}return!1}function y(b){a.setAttribute("aria-expanded",b?"true":"false")}function L(b){let h=r.get(b);if(!h){let M=o.querySelector(`[aria-controls="${b}"]`);if(!M){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${e}".`);return}if(!M.id){let P=`trigger-${b}`;M.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}h=ne({menuId:b,menuItemsClass:t,triggerId:M.id,callback:i}),r.set(b,h)}h.openMenu()}function H(b){if(i?.onOpenChange)try{i.onOpenChange(b)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function f(){g().forEach((h,M)=>{if(!n.has(h)){let $=P=>k(P,h,M);h.addEventListener("keydown",$),n.set(h,$)}})}function E(){g().forEach(h=>{let M=n.get(h);M&&(h.removeEventListener("keydown",M),n.delete(h))})}function w(){y(!0),o.style.display="block";let b=g();if(f(),b&&b.length>0&&b[0].focus(),i?.onOpenChange)try{i.onOpenChange(!0)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function d(){if(r.forEach(b=>b.closeMenu()),y(!1),o.style.display="none",E(),a.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function A(){a.getAttribute("aria-expanded")==="true"?d():w()}function T(b){if(!(a.getAttribute("aria-expanded")==="true"))return;let M=a.contains(b.target),$=o.contains(b.target);!M&&!$&&d()}a.addEventListener("click",A),document.addEventListener("click",T);function q(){E(),a.removeEventListener("click",A),document.removeEventListener("click",T),o.style.display="none",y(!1),r.forEach(b=>b.cleanup()),r.clear()}function I(){l=null,s=null}return{openMenu:w,closeMenu:d,cleanup:q,refresh:I}}function Oe({radioGroupId:e,radiosClass:t,defaultSelectedIndex:m=0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" 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 o=Array.from(i.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let a=new WeakMap,n=new WeakMap,r=m;function l(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),o.forEach((c,u)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex",u===r?"0":"-1"),u===r?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function s(c){if(c<0||c>=o.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}r>=0&&r<o.length&&(o[r].setAttribute("aria-checked","false"),o[r].setAttribute("tabindex","-1")),o[c].setAttribute("aria-checked","true"),o[c].setAttribute("tabindex","0"),o[c].focus(),r=c}function p(c){return()=>{s(c)}}function g(c){return u=>{let{key:k}=u,S=c;switch(k){case"ArrowDown":case"ArrowRight":u.preventDefault(),S=(c+1)%o.length,s(S);break;case"ArrowUp":case"ArrowLeft":u.preventDefault(),S=(c-1+o.length)%o.length,s(S);break;case" ":case"Enter":u.preventDefault(),s(c);break}}}function v(){o.forEach((c,u)=>{let k=p(u),S=g(u);c.addEventListener("click",k),c.addEventListener("keydown",S),a.set(c,S),n.set(c,k)})}function x(){o.forEach(c=>{let u=a.get(c),k=n.get(c);u&&(c.removeEventListener("keydown",u),a.delete(c)),k&&(c.removeEventListener("click",k),n.delete(c))})}function C(){x()}function D(){return r}return l(),v(),{selectRadio:s,getSelectedIndex:D,cleanup:C}}function Ve({toggleId:e,togglesClass:t,isSingleToggle:m=!0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let o;if(m)o=[i];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(o=Array.from(i.querySelectorAll(`.${t}`)),o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,n=new WeakMap;function r(){o.forEach(u=>{u.tagName.toLowerCase()!=="button"&&!u.getAttribute("role")&&u.setAttribute("role","button"),u.hasAttribute("aria-pressed")||u.setAttribute("aria-pressed","false"),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0")})}function l(u){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}let k=o[u],S=k.getAttribute("aria-pressed")==="true";k.setAttribute("aria-pressed",S?"false":"true")}function s(u,k){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}o[u].setAttribute("aria-pressed",k?"true":"false")}function p(u){return()=>{l(u)}}function g(u){return k=>{let{key:S}=k;switch(S){case"Enter":case" ":k.preventDefault(),l(u);break}}}function v(){o.forEach((u,k)=>{let S=p(k),y=g(k);u.addEventListener("click",S),u.addEventListener("keydown",y),a.set(u,y),n.set(u,S)})}function x(){o.forEach(u=>{let k=a.get(u),S=n.get(u);k&&(u.removeEventListener("keydown",k),a.delete(u)),S&&(u.removeEventListener("click",S),n.delete(u))})}function C(){x()}function D(){return o.map(u=>u.getAttribute("aria-pressed")==="true")}function c(){return o.map((u,k)=>u.getAttribute("aria-pressed")==="true"?k:-1).filter(u=>u!==-1)}return r(),v(),{toggleButton:l,setPressed:s,getPressedStates:D,getPressedIndices:c,cleanup:C}}function Ne({comboboxInputId:e,comboboxButtonId:t,listBoxId:m,listBoxItemsClass:i,callback:o}){if(e==="")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 a=document.getElementById(`${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" 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 n=document.getElementById(`${m}`);if(!n)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 l=t?document.getElementById(`${t}`):null,s=-1;a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-controls",m),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-haspopup","listbox"),n.setAttribute("role","listbox");let p=null;function g(){return p||(p=n.querySelectorAll(`.${i}`)),Array.from(p).filter(d=>!d.hidden&&d.style.display!=="none")}function v(){return a.getAttribute("aria-expanded")==="true"}function x(d){let A=g();if(d>=0&&d<A.length){let T=A[d],q=T.id||`${m}-option-${d}`;if(T.id||(T.id=q),a.setAttribute("aria-activedescendant",q),typeof T.scrollIntoView=="function"&&T.scrollIntoView({block:"nearest",behavior:"smooth"}),o?.onActiveDescendantChange)try{o.onActiveDescendantChange(q,T)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else a.setAttribute("aria-activedescendant","");s=d}function C(){if(a.setAttribute("aria-expanded","true"),n.style.display="block",o?.onOpenChange)try{o.onOpenChange(!0)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function D(){if(a.setAttribute("aria-expanded","false"),a.setAttribute("aria-activedescendant",""),n.style.display="none",s=-1,o?.onOpenChange)try{o.onOpenChange(!1)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function c(d){let A=d.textContent?.trim()||"";if(a.value=A,d.setAttribute("aria-selected","true"),D(),o?.onSelect)try{o.onSelect(d)}catch(T){console.error("[aria-ease] Error in combobox onSelect callback:",T)}}function u(d){let A=g(),T=v();switch(d.key){case"ArrowDown":if(d.preventDefault(),!T){C();return}if(A.length===0)return;{let q=s>=A.length-1?0:s+1;x(q)}break;case"ArrowUp":if(d.preventDefault(),!T)return;if(A.length>0){let q=s<=0?A.length-1:s-1;x(q)}break;case"Enter":T&&s>=0&&s<A.length&&(d.preventDefault(),c(A[s]));break;case"Escape":if(T)d.preventDefault(),D();else if(a.value&&(d.preventDefault(),a.value="",a.setAttribute("aria-activedescendant",""),g().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),o?.onClear))try{o.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":T&&A.length>0&&(d.preventDefault(),x(0));break;case"End":T&&A.length>0&&(d.preventDefault(),x(A.length-1));break;case"Tab":T&&s>=0&&s<A.length&&c(A[s]),T&&D();break}}function k(d){let A=d.target;if(A.classList.contains(i)){let q=g().indexOf(A);q>=0&&x(q)}}function S(d){let A=d.target;A.classList.contains(i)&&(d.preventDefault(),c(A))}function y(d){let A=d.target;!a.contains(A)&&!n.contains(A)&&(!l||!l.contains(A))&&D()}function L(){v()?D():(C(),a.focus())}function H(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),L())}a.addEventListener("keydown",u),n.addEventListener("mousemove",k),n.addEventListener("mousedown",S),document.addEventListener("mousedown",y),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",L),l.addEventListener("keydown",H));function f(){let d=n.querySelectorAll(`.${i}`);if(d.length===0)return;let A=null;for(let T of d)if(T.getAttribute("aria-selected")==="true"){A=T.textContent?.trim()||null;break}!A&&a.value&&(A=a.value.trim()),d.forEach((T,q)=>{T.setAttribute("role","option");let I=T.textContent?.trim()||"";A&&I===A?T.setAttribute("aria-selected","true"):T.setAttribute("aria-selected","false");let b=T.getAttribute("id");if(!b||b===""){let h=`${m}-option-${q}`;T.id=h,T.setAttribute("id",h)}})}f();function E(){a.removeEventListener("keydown",u),n.removeEventListener("mousemove",k),n.removeEventListener("mousedown",S),document.removeEventListener("mousedown",y),l&&(l.removeEventListener("click",L),l.removeEventListener("keydown",H))}function w(){p=null,f(),s=-1,x(-1)}return{cleanup:E,refresh:w,openListbox:C,closeListbox:D}}function Fe({tabListId:e,tabsClass:t,tabPanelsClass:m,orientation:i="horizontal",activateOnFocus:o=!0,callback:a}){if(e==="")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 n=document.querySelector(`#${e}`);if(!n)return console.error(`[aria-ease] Element with id="${e}" 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 r=Array.from(n.querySelectorAll(`.${t}`));if(r.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 l=Array.from(document.querySelectorAll(`.${m}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${r.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,p=new WeakMap,g=new WeakMap,v=0;function x(){n.setAttribute("role","tablist"),n.setAttribute("aria-orientation",i),r.forEach((f,E)=>{let w=l[E];f.id||(f.id=`${e}-tab-${E}`),w.id||(w.id=`${e}-panel-${E}`),f.setAttribute("role","tab"),f.setAttribute("aria-controls",w.id),f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1"),w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",f.id),w.hidden=!0,w.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||w.setAttribute("tabindex","0")}),C(0,!1)}function C(f,E=!0){if(f<0||f>=r.length){console.error(`[aria-ease] Invalid tab index: ${f}`);return}let w=v;r.forEach((T,q)=>{let I=l[q];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),I.hidden=!0});let d=r[f],A=l[f];if(d.setAttribute("aria-selected","true"),d.setAttribute("tabindex","0"),A.hidden=!1,E&&d.focus(),v=f,a?.onTabChange&&w!==f)try{a.onTabChange(f,w)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function D(f){let E=r.findIndex(A=>A===document.activeElement),w=E!==-1?E:v,d=w;switch(f){case"first":d=0;break;case"last":d=r.length-1;break;case"next":d=(w+1)%r.length;break;case"prev":d=(w-1+r.length)%r.length;break}if(r[d].focus(),r[d].setAttribute("tabindex","0"),r[v].setAttribute("tabindex","-1"),o)C(d,!1);else{let A=v;r.forEach((T,q)=>{q===d?T.setAttribute("tabindex","0"):q!==A&&T.setAttribute("tabindex","-1")})}}function c(f){return()=>{C(f)}}function u(f){return E=>{let{key:w}=E,d=!1;if(i==="horizontal")switch(w){case"ArrowLeft":E.preventDefault(),D("prev"),d=!0;break;case"ArrowRight":E.preventDefault(),D("next"),d=!0;break}else switch(w){case"ArrowUp":E.preventDefault(),D("prev"),d=!0;break;case"ArrowDown":E.preventDefault(),D("next"),d=!0;break}if(!d)switch(w){case"Home":E.preventDefault(),D("first");break;case"End":E.preventDefault(),D("last");break;case" ":case"Enter":o||(E.preventDefault(),C(f));break;case"F10":if(E.shiftKey&&a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function k(f){return E=>{if(a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(w){console.error("[aria-ease] Error in tabs onContextMenu callback:",w)}}}}function S(){r.forEach((f,E)=>{let w=c(E),d=u(E),A=k(E);f.addEventListener("click",w),f.addEventListener("keydown",d),a?.onContextMenu&&(f.addEventListener("contextmenu",A),g.set(f,A)),s.set(f,d),p.set(f,w)})}function y(){r.forEach(f=>{let E=s.get(f),w=p.get(f),d=g.get(f);E&&(f.removeEventListener("keydown",E),s.delete(f)),w&&(f.removeEventListener("click",w),p.delete(f)),d&&(f.removeEventListener("contextmenu",d),g.delete(f))})}function L(){y(),r.forEach((f,E)=>{let w=l[E];f.removeAttribute("role"),f.removeAttribute("aria-selected"),f.removeAttribute("aria-controls"),f.removeAttribute("tabindex"),w.removeAttribute("role"),w.removeAttribute("aria-labelledby"),w.removeAttribute("tabindex"),w.hidden=!1}),n.removeAttribute("role"),n.removeAttribute("aria-orientation")}function H(){y();let f=Array.from(n.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${m}`));r.length=0,r.push(...f),l.length=0,l.push(...E),x(),S()}return x(),S(),{activateTab:C,cleanup:L,refresh:H}}var j={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...ie(),...J()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>se(e.relativeTarget)},"activedescendant.set":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ae},"activedescendant.unset":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:J},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function ie(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function se(e){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function ae(){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 oe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} item 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 G={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:be},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:me},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ge(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:he},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ye},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:ve},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Ae},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ke(e.relativeTarget)}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected 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:"Expected 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(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function he(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function ye(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function ve(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Ae(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function ke(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var X={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>we(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ee(e.relativeTarget)}};function Ee(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function Te(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function we(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},Te(e)]}function Me(e,t){return t.some(m=>e.capabilities.includes(m))}function V(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let m of e)if(Me(t,m.when))return m.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var xe={combobox:j,menu:G,tabs:X},N=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=xe[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"]},o=(n,r=new Set)=>{if(r.has(n))return[];r.add(n);let l=m[n];if(!l)return[];let s=[];if(Array.isArray(l.requires))for(let p of l.requires)s=s.concat(o(p,r));return l.setup&&(s=s.concat(V(l.setup,i))),s};return t({ariaReference:(n,r,l)=>({requires:s=>{let p=o(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended"})}),contains:(n,r)=>({requires:l=>{let s=o(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended"})})}),this}static(t){return t({target:i=>{let o=r=>{let l=this.statePack,s={capabilities:["keyboard"]},p=(g,v=new Set)=>{if(v.has(g))return[];v.add(g);let x=l[g];if(!x)return[];let C=[];if(Array.isArray(x.requires))for(let D of x.requires)C=C.concat(p(D,v));return x.setup&&(C=C.concat(V(x.setup,s))),C};return p(r,new Set)},a=r=>r==="role"?"toHaveRole":"toHaveAttribute",n=(r,l,s)=>{let p=a(r);return{required:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"recommended",setup:s})}};return{has:(r,l)=>({...n(r,l),requires:p=>{let g=o(p);return n(r,l,g)}})}}}),this}when(t){return new F(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}}},F=class{constructor(t,m,i){this.parent=t;this.statePack=m;this.event=i}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,m){return this._onTarget=t,this._onRelativeTarget=m,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return(Array.isArray(t)?t:[t]).flatMap(i=>typeof i=="string"?[i]:typeof i=="object"&&i!==null&&"type"in i&&"ref"in i?this._findStateKeyByTypeAndRef(i.type)?[{type:i.type,ref:i.ref}]:[]:[i])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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"]},o=(s,p=new Set)=>{if(p.has(s))return[];p.add(s);let g=this.statePack[s];if(!g)return[];let v=[];if(Array.isArray(g.requires))for(let x of g.requires)v=v.concat(o(x,p));return g.setup&&(v=v.concat(V(g.setup,i))),v},a=[];for(let s of this._given)if(typeof s=="string")a.push(...o(s));else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let g=this.statePack[p];if(g&&g.setup)for(let v of g.setup)typeof v.steps=="function"?a.push(...v.steps({relativeTarget:s.ref})):Array.isArray(v.steps)&&a.push(...v.steps)}}let n=new Set;a=a.filter(s=>{let p=JSON.stringify(s);return n.has(p)?!1:(n.add(p),!0)});let r=[];for(let s of this._then)if(typeof s=="string"){let p=this.statePack[s];if(p&&p.assertion!==void 0){let g=p.assertion;if(typeof g=="function")try{g=g()}catch(v){throw new Error(`Error calling assertion function for state '${s}': ${v.message}`)}Array.isArray(g)?r.push(...g):r.push(g)}}else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let g=this.statePack[p];if(g&&g.assertion!==void 0){let v=g.assertion;if(typeof v=="function")try{v=v({relativeTarget:s.ref})}catch(x){throw new Error(`Error calling assertion function for state '${p}': ${x.message}`)}Array.isArray(v)?r.push(...v):r.push(v)}}}let l=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:l,assertions:r,...a.length?{setup:a}:{}})}};function et(e,t){let m=new K(e);return t(m),new N(m.build())}import Le from"path";async function Q(e,t,m={}){if(!e||typeof e!="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 o(p){try{let g=await fetch(p,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(g.ok||g.status===304)return p}catch{return null}return null}let a=B(m.strictness),n={},r=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:p}=await import("./configLoader-ZEJVXLX7.js"),g=await p(process.cwd());if(n=g.config,g.configPath&&(r=Le.dirname(g.configPath)),m.strictness===void 0){let v=n.test?.components?.find(x=>x?.name===e)?.strictness;a=B(v??n.test?.strictness)}}catch{m.strictness===void 0&&(a="balanced")}let l;try{if(t){let p=await o(t);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:g}=await import("./contractTestRunnerPlaywright-RUKMUY5P.js");l=await g(e,p,a,n,r)}else throw new Error(`\u274C Dev server not running at ${t}
|
|
2
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 s={violations:i.violations,raw:i,contract:l};if(l.failures.length>0&&t==="Playwright")throw new Error(`
|
|
3
3
|
\u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
|
|
4
4
|
\u2705 ${l.passes.length} test${l.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(i.violations.length>0){let p=i.violations.length,
|
|
8
|
-
- ${
|
|
9
|
-
Impact: ${
|
|
10
|
-
Affected elements: ${
|
|
11
|
-
Help: ${
|
|
7
|
+
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(i.violations.length>0){let p=i.violations.length,g=i.violations.map(v=>`
|
|
8
|
+
- ${v.id}: ${v.description}
|
|
9
|
+
Impact: ${v.impact}
|
|
10
|
+
Affected elements: ${v.nodes.length}
|
|
11
|
+
Help: ${v.helpUrl}`).join(`
|
|
12
12
|
`);throw new Error(`
|
|
13
13
|
\u274C ${p} axe accessibility violation${p>1?"s":""} detected
|
|
14
|
-
${
|
|
14
|
+
${g}
|
|
15
15
|
|
|
16
16
|
\u{1F4CB} Full details available in result.violations`)}return s}var Y=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Y=async()=>{console.log(`\u{1F680} Running component accessibility tests...
|
|
17
|
-
`);let{exec:e}=await import("child_process"),t=(await import("chalk")).default;return new Promise((
|
|
17
|
+
`);let{exec:e}=await import("child_process"),t=(await import("chalk")).default;return new Promise((m,i)=>{e("npx vitest --run --reporter verbose",async(o,a,n)=>{if(console.log(a),n&&console.error(n),!o||o.code===0){try{let{displayBadgeInfo:l,promptAddBadge:s}=await import("./badgeHelper-IB5RTMAG.js");l("component"),await s("component",process.cwd()),console.log(t.dim(`
|
|
18
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(l){console.error("Warning: Could not display badge prompt:",l)}
|
|
19
|
+
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}m({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=o?.code||1;i(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})});async function Z(){await U()}export{Z as cleanupTests,et as createContract,He as makeAccordionAccessible,$e as makeBlockAccessible,Ie as makeCheckboxAccessible,Ne as makeComboboxAccessible,ne as makeMenuAccessible,Oe as makeRadioAccessible,Fe as makeTabsAccessible,Ve as makeToggleAccessible,Q as testUiComponent};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {expect}from'@playwright/test';var r=class{constructor(t,i,o=400,c=400){this.mainSelector=t;this.selectors=i;this.actionTimeoutMs=o;this.assertionTimeoutMs=c;}async resetState(t){if(!this.selectors.popup)return;let i=this.selectors.popup,o=t.locator(i).first();if(!await o.isVisible().catch(()=>false))return;let e=false,n=this.selectors.main;if(n&&(await t.locator(n).first().focus(),await t.keyboard.press("Escape"),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!e&&this.selectors.button&&(await t.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),e||(await t.mouse.click(10,10),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!e)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
2
|
+
1. Escape key
|
|
3
|
+
2. Clicking button
|
|
4
|
+
3. Clicking outside
|
|
5
|
+
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await t.locator(this.selectors.input).first().clear();}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};export{r as ComboboxComponentStrategy};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {expect}from'@playwright/test';var c=class{constructor(e,r,i=400,o=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=i;this.assertionTimeoutMs=o;}async resetState(e){if(!this.selectors.popup)return;let r=this.selectors.popup,i=e.locator(r).first();if(!await i.isVisible().catch(()=>false))return;let s=false,t=this.selectors.main;if(t&&(await e.locator(t).first().focus(),await e.keyboard.press("Escape"),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!s&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),s||(await e.mouse.click(10,10),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!s)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
|
+
1. Escape key
|
|
3
|
+
2. Clicking trigger
|
|
4
|
+
3. Clicking outside
|
|
5
|
+
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,r){if(!(e.action.some(t=>t.target==="submenu"||t.target==="submenuTrigger"||t.target==="submenuItems")||e.assertions.some(t=>t.target==="submenu"||t.target==="submenuTrigger"||t.target==="submenuItems")))return false;let o=this.selectors.submenuTrigger;return o?await r.locator(o).count()===0:true}getMainSelector(){return this.mainSelector}};export{c as MenuComponentStrategy};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,a,c,e}from'./chunk-APUMBDOT.js';import {a as a$1}from'./chunk-WIWSYIGK.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ne=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-
|
|
1
|
+
import {d,a,c,e}from'./chunk-APUMBDOT.js';import {a as a$1}from'./chunk-WIWSYIGK.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ne=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-QHVBLUBR.js').then(t=>t.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>import('./AccordionComponentStrategy-X2GSQ5KT.js').then(t=>t.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>import('./ComboboxComponentStrategy-5AWO63DA.js').then(t=>t.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>import('./TabsComponentStrategy-DTQQUCK2.js').then(t=>t.TabsComponentStrategy));}async loadStrategy(t,s,r){try{if(s)try{let n=ge.isAbsolute(s)?s:ge.resolve(r||process.cwd(),s),u=await import(pathToFileURL(n).href),i=u.default||u;if(!i)throw new Error(`No default export found in ${s}`);return i}catch(n){throw new Error(`Failed to load custom strategy from ${s}: ${n instanceof Error?n.message:String(n)}`)}let o=this.builtInStrategies.get(t);return o?o():null}catch(o){throw new Error(`Strategy loading failed for ${t}: ${o instanceof Error?o.message:String(o)}`)}}has(t,s){return !!s||this.builtInStrategies.has(t)}};var oe=class{static strategyRegistry=new ne;static isComponentConfig(t){return typeof t=="object"&&t!==null}static async detect(t,s,r=400,o=400,n){let u=this.isComponentConfig(s)?s:void 0,i=u?.contractPath;if(!i)throw new Error(`Contract path not found for component: ${t}`);let R=(()=>{if(ge.isAbsolute(i))return i;if(n){let re=ge.resolve(n,i);try{return readFileSync(re,"utf-8"),re}catch{}}let X=ge.resolve(process.cwd(),i);try{return readFileSync(X,"utf-8"),X}catch{return new URL(i,import.meta.url).pathname}})(),C=readFileSync(R,"utf-8"),ee=JSON.parse(C).selectors,_=await this.strategyRegistry.loadStrategy(t,u?.strategyPath,n);if(!_)return null;let z=ee.main;return t==="tabs"?new _(z,ee):new _(z,ee,r,o)}};var ae=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(t=false,s=false){this.isPlaywright=t,this.isCustomContract=s;}log(t){process.stderr.write(t+`
|
|
2
2
|
`);}start(t,s,r){this.startTime=Date.now(),this.componentName=t,this.totalTests=s,this.hasPrintedStaticSection=false,this.hasPrintedDynamicSection=false,r&&(this.apgUrl=r);let o="Playwright (Real Browser)";this.log(`
|
|
3
3
|
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${t.charAt(0).toUpperCase()+t.slice(1)} Component - ${o}`),this.log(`${"\u2550".repeat(60)}
|
|
4
4
|
`);}reportStatic(t,s,r=0){this.staticPasses=t,this.staticFailures=s,this.staticWarnings=r;}reportStaticTest(t,s,r,o){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=true);let n=s==="pass"?"\u2713":s==="warn"?"\u26A0":s==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${t}`),o&&this.log(` \u21B3 level=${o}`),(s==="fail"||s==="warn"||s==="skip")&&r&&this.log(` \u21B3 ${r}`);}reportTest(t,s,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=true);let o={description:t.description,status:s,failureMessage:r,level:t.level};s==="skip"&&(o.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(o);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},u=t.level?`[${t.level.toUpperCase()}] `:"";this.log(` ${n[s]} ${u}${t.description}`),s==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),s==="fail"&&r&&this.log(` \u21B3 ${r}`),s==="warn"&&r&&this.log(` \u21B3 ${r}`),s==="skip"&&r&&this.log(` \u21B3 ${r}`);}reportFailures(t){t.length!==0&&(this.log(`
|
|
@@ -19,7 +19,7 @@ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
|
19
19
|
`),i>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
|
|
20
20
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
21
21
|
`),{passes:u,failures:i,skipped:this.skipped,duration:s}}error(t,s){this.log(`
|
|
22
|
-
\u274C Error: ${t}`),s&&this.log(` Context: ${s}`),this.log("");}};var N=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}isBrowserClosedError(t){return t instanceof Error&&t.message.includes("Target page, context or browser has been closed")}async focus(t,s,r){try{if(t==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let u=this.page.locator(n).first();return await u.count()?(await u.evaluate((R,C)=>{R.setAttribute("aria-activedescendant",C);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(t==="relative"&&s){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let u=await a$1.resolve(this.page,n,s);return u?(await u.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for focus.`}}let o=this.selectors[t];return o?(await this.page.locator(o).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${t} not found.`}}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${t}: ${o instanceof Error?o.message:String(o)}`}}}async type(t,s){try{let r=this.selectors[t];return r?(await this.page.locator(r).first().fill(s,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${t}: ${r instanceof Error?r.message:String(r)}`}}}async click(t,s){try{if(t==="document")return await this.page.mouse.click(10,10),{success:!0};if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for click action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for click.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${t}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(t,s,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[s]||s;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),t==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(n))return await this.page.keyboard.press(n),{success:!0};if(t==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let C=this.selectors.relative;if(!C)return {success:!1,error:"Relative selector not defined for keypress action."};let A=await a$1.resolve(this.page,C,r);return A?(await A.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let u=this.selectors[t];if(!u)return {success:!1,error:`Selector for keypress target ${t} not found.`};let i=this.page.locator(u).first();return await i.count()===0?{success:!1,error:`${t} element not found.`,shouldBreak:!0}:(await i.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${s} on ${t}: ${o instanceof Error?o.message:String(o)}`}}}async hover(t,s){try{if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for hover action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for hover.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${t}: ${r instanceof Error?r.message:String(r)}`}}}};var se=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}async resolveTarget(t,s,r){try{if(t==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!s)return {target:null,error:"Relative target or expected value is not defined."};let u=await a$1.resolve(this.page,n,s);return u?{target:u}:{target:null,error:`Target ${t} not found.`}}let o=this.selectors[t];return o?{target:this.page.locator(o).first()}:{target:null,error:`Selector for assertion target ${t} not found.`}}catch(o){return {target:null,error:`Failed to resolve target ${t}: ${o instanceof Error?o.message:String(o)}`}}}async validateVisibility(t,s,r,o,n){try{return r?(await expect(t).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is visible as expected. Test: "${n}".`}):(await expect(t).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is not visible as expected. Test: "${n}".`})}catch{let u=this.selectors[s]||"",i=await this.page.evaluate(R=>{let C=R?document.querySelector(R):null;if(!C)return "element not found";let A=window.getComputedStyle(C);return `display:${A.display}, visibility:${A.visibility}, opacity:${A.opacity}`},u);return r?{success:false,failMessage:`${o} (actual: ${i})`}:{success:false,failMessage:`${o} ${s} is still visible (actual: ${i}).`}}}async validateAttribute(t,s,r,o,n,u){if(o==="!empty"){let C=await t.getAttribute(r);return C&&C.trim()!==""?{success:true,passMessage:`${s} has non-empty "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should not be empty, found "${C}".`}}if(typeof o!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",o),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(o)}`);let i=o.split(" | ").map(C=>C.trim()),R=await t.getAttribute(r);return R!==null&&i.includes(R)?{success:true,passMessage:`${s} has expected "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should be "${o}", found "${R}".`}}async validateValue(t,s,r,o,n){let u=await t.inputValue().catch(()=>"");return r==="!empty"?u&&u.trim()!==""?{success:true,passMessage:`${s} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should not be empty, found "${u}".`}:r===""?u===""?{success:true,passMessage:`${s} has empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be empty, found "${u}".`}:u===r?{success:true,passMessage:`${s} has expected value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be "${r}", found "${u}".`}}async validateFocus(t,s,r,o,n){try{return r?(await expect(t).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} has focus as expected. Test: "${n}".`}):(await expect(t).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} does not have focus as expected. Test: "${n}".`})}catch{let u=await this.page.evaluate(()=>{let i=document.activeElement;return i?`${i.tagName}#${i.id||"no-id"}.${i.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${o} (actual focus: ${u})`}}}async validateRole(t,s,r,o,n){let u=await t.getAttribute("role");return u===r?{success:true,passMessage:`${s} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${o} Expected role "${r}", found "${u}".`}}async validate(t,s){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,o;if(t.controlledBy){let n=t.controlledBy,u=this.selectors[n.target];if(!u)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let i=null;if(n.relativeTarget?i=await a$1.resolve(this.page,u,n.relativeTarget):i=this.page.locator(u).first(),!i)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let R=n.attribute||"aria-controls",C=await i.getAttribute(R);if(!C)return {success:false,failMessage:`Controlling element does not have attribute '${R}'.`,target:null};if(r=this.page.locator(`#${C}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${C}' not found.`,target:null}}else {let n=await this.resolveTarget(t.target,t.relativeTarget||t.expectedValue,t.selectorKey);if(r=n.target,o=n.error,o||!r)return {success:false,failMessage:o||`Target ${t.target} not found.`,target:null}}if(t.target==="input"&&t.attribute==="aria-activedescendant"&&t.expectedValue==="!empty"&&t.relativeTarget&&t.selectorKey){let n=await a$1.resolve(this.page,this.selectors[t.selectorKey],t.relativeTarget),u=n?await n.getAttribute("id"):null,i=await r.getAttribute("aria-activedescendant");return u&&i===u?{success:true,passMessage:`input[aria-activedescendant] matches id of ${t.relativeTarget}(${t.selectorKey}). Test: "${s}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${t.relativeTarget}(${t.selectorKey}), found "${i}".`}}switch(t.assertion){case "toBeVisible":return this.validateVisibility(r,t.target,true,t.failureMessage||"",s);case "notToBeVisible":return this.validateVisibility(r,t.target,false,t.failureMessage||"",s);case "toHaveAttribute":return t.attribute&&t.expectedValue!==void 0?this.validateAttribute(r,t.target,t.attribute,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return t.expectedValue!==void 0?this.validateValue(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,t.target,true,t.failureMessage||"",s);case "notToHaveFocus":return this.validateFocus(r,t.target,false,t.failureMessage||"",s);case "toHaveRole":return t.expectedValue!==void 0?this.validateRole(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${t.assertion}`}}}};async function tt(M,t,s,r,o){let n=r?.test?.components?.find(d=>d.name===M),u=!!n?.contractPath,i=new ae(true,u),R={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},C=r?.test?.disableTimeouts===true,ee=n?.disableTimeouts===true||C,_=(d,H,O)=>{if(ee)return 0;let F=d??H;return typeof F!="number"||!Number.isFinite(F)||F<0?O:F},z=_(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,R.actionTimeoutMs),X=_(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,R.assertionTimeoutMs),re=_(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,R.navigationTimeoutMs),le=_(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,R.componentReadyTimeoutMs),me=d(s),Y=n?.contractPath;if(!Y)throw new Error(`Contract path not found for component: ${M}`);let Re=(()=>{if(ge.isAbsolute(Y))return Y;if(o){let H=ge.resolve(o,Y);try{return readFileSync(H,"utf-8"),H}catch{}}let d=ge.resolve(process.cwd(),Y);try{return readFileSync(d,"utf-8"),d}catch{return new URL(Y,import.meta.url).pathname}})(),Ae=readFileSync(Re,"utf-8"),b=JSON.parse(Ae),Me=(b.relationships?.length||0)+(b.static[0]?.assertions.length||0)+b.dynamic.length,Ee=b.meta?.source?.apg,V=[],K=[],q=[],x=[],y=null,E=(d,H)=>{let O=c(H),F=e(O,me);if(F==="error")return V.push(d),{status:"fail",level:O,detail:d};if(F==="warning")return K.push(d),{status:"warn",level:O,detail:d};let D=`${d} (ignored by strictness=${me}, level=${O})`;return x.push(D),{status:"skip",level:O,detail:D}};try{if(y=await a(),t){try{await y.goto(t,{waitUntil:"domcontentloaded",timeout:re});}catch(e){throw new Error(`Failed to navigate to ${t}. Ensure dev server is running and accessible. Original error: ${e instanceof Error?e.message:String(e)}`)}await y.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let d=await oe.detect(M,n,z,X,o);if(!d)throw new Error(`Unsupported component: ${M}`);let H=d.getMainSelector();if(!H)throw new Error(`CRITICAL: No selector found in contract for ${M}`);try{await y.locator(H).first().waitFor({state:"attached",timeout:le});}catch(e){throw new Error(`
|
|
22
|
+
\u274C Error: ${t}`),s&&this.log(` Context: ${s}`),this.log("");}};var N=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}isBrowserClosedError(t){return t instanceof Error&&t.message.includes("Target page, context or browser has been closed")}async focus(t,s,r){try{if(t==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let u=this.page.locator(n).first();return await u.count()?(await u.evaluate((R,C)=>{R.setAttribute("aria-activedescendant",C);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(t==="relative"&&s){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let u=await a$1.resolve(this.page,n,s);return u?(await u.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for focus.`}}let o=this.selectors[t];return o?(await this.page.locator(o).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${t} not found.`}}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${t}: ${o instanceof Error?o.message:String(o)}`}}}async type(t,s){try{let r=this.selectors[t];return r?(await this.page.locator(r).first().fill(s,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${t}: ${r instanceof Error?r.message:String(r)}`}}}async click(t,s){try{if(t==="document")return await this.page.mouse.click(10,10),{success:!0};if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for click action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for click.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${t}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(t,s,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[s]||s;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),t==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let C=this.selectors.relative;if(!C)return {success:!1,error:"Relative selector not defined for keypress action."};let A=await a$1.resolve(this.page,C,r);return A?(await A.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let u=this.selectors[t];if(!u)return {success:!1,error:`Selector for keypress target ${t} not found.`};let i=this.page.locator(u).first();return await i.count()===0?{success:!1,error:`${t} element not found.`,shouldBreak:!0}:(await i.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${s} on ${t}: ${o instanceof Error?o.message:String(o)}`}}}async hover(t,s){try{if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for hover action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for hover.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${t}: ${r instanceof Error?r.message:String(r)}`}}}};var se=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}async resolveTarget(t,s,r){try{if(t==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!s)return {target:null,error:"Relative target or expected value is not defined."};let u=await a$1.resolve(this.page,n,s);return u?{target:u}:{target:null,error:`Target ${t} not found.`}}let o=this.selectors[t];return o?{target:this.page.locator(o).first()}:{target:null,error:`Selector for assertion target ${t} not found.`}}catch(o){return {target:null,error:`Failed to resolve target ${t}: ${o instanceof Error?o.message:String(o)}`}}}async validateVisibility(t,s,r,o,n){try{return r?(await expect(t).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is visible as expected. Test: "${n}".`}):(await expect(t).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is not visible as expected. Test: "${n}".`})}catch{let u=this.selectors[s]||"",i=await this.page.evaluate(R=>{let C=R?document.querySelector(R):null;if(!C)return "element not found";let A=window.getComputedStyle(C);return `display:${A.display}, visibility:${A.visibility}, opacity:${A.opacity}`},u);return r?{success:false,failMessage:`${o} (actual: ${i})`}:{success:false,failMessage:`${o} ${s} is still visible (actual: ${i}).`}}}async validateAttribute(t,s,r,o,n,u){if(o==="!empty"){let C=await t.getAttribute(r);return C&&C.trim()!==""?{success:true,passMessage:`${s} has non-empty "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should not be empty, found "${C}".`}}if(typeof o!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",o),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(o)}`);let i=o.split(" | ").map(C=>C.trim()),R=await t.getAttribute(r);return R!==null&&i.includes(R)?{success:true,passMessage:`${s} has expected "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should be "${o}", found "${R}".`}}async validateValue(t,s,r,o,n){let u=await t.inputValue().catch(()=>"");return r==="!empty"?u&&u.trim()!==""?{success:true,passMessage:`${s} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should not be empty, found "${u}".`}:r===""?u===""?{success:true,passMessage:`${s} has empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be empty, found "${u}".`}:u===r?{success:true,passMessage:`${s} has expected value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be "${r}", found "${u}".`}}async validateFocus(t,s,r,o,n){try{return r?(await expect(t).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} has focus as expected. Test: "${n}".`}):(await expect(t).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} does not have focus as expected. Test: "${n}".`})}catch{let u=await this.page.evaluate(()=>{let i=document.activeElement;return i?`${i.tagName}#${i.id||"no-id"}.${i.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${o} (actual focus: ${u})`}}}async validateRole(t,s,r,o,n){let u=await t.getAttribute("role");return u===r?{success:true,passMessage:`${s} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${o} Expected role "${r}", found "${u}".`}}async validate(t,s){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,o;if(t.controlledBy){let n=t.controlledBy,u=this.selectors[n.target];if(!u)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let i=null;if(n.relativeTarget?i=await a$1.resolve(this.page,u,n.relativeTarget):i=this.page.locator(u).first(),!i)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let R=n.attribute||"aria-controls",C=await i.getAttribute(R);if(!C)return {success:false,failMessage:`Controlling element does not have attribute '${R}'.`,target:null};if(r=this.page.locator(`#${C}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${C}' not found.`,target:null}}else {let n=await this.resolveTarget(t.target,t.relativeTarget||t.expectedValue,t.selectorKey);if(r=n.target,o=n.error,o||!r)return {success:false,failMessage:o||`Target ${t.target} not found.`,target:null}}if(t.target==="input"&&t.attribute==="aria-activedescendant"&&t.expectedValue==="!empty"&&t.relativeTarget&&t.selectorKey){let n=await a$1.resolve(this.page,this.selectors[t.selectorKey],t.relativeTarget),u=n?await n.getAttribute("id"):null,i=await r.getAttribute("aria-activedescendant");return u&&i===u?{success:true,passMessage:`input[aria-activedescendant] matches id of ${t.relativeTarget}(${t.selectorKey}). Test: "${s}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${t.relativeTarget}(${t.selectorKey}), found "${i}".`}}switch(t.assertion){case "toBeVisible":return this.validateVisibility(r,t.target,true,t.failureMessage||"",s);case "notToBeVisible":return this.validateVisibility(r,t.target,false,t.failureMessage||"",s);case "toHaveAttribute":return t.attribute&&t.expectedValue!==void 0?this.validateAttribute(r,t.target,t.attribute,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return t.expectedValue!==void 0?this.validateValue(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,t.target,true,t.failureMessage||"",s);case "notToHaveFocus":return this.validateFocus(r,t.target,false,t.failureMessage||"",s);case "toHaveRole":return t.expectedValue!==void 0?this.validateRole(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${t.assertion}`}}}};async function tt(M,t,s,r,o){let n=r?.test?.components?.find(d=>d.name===M),u=!!n?.contractPath,i=new ae(true,u),R={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},C=r?.test?.disableTimeouts===true,ee=n?.disableTimeouts===true||C,_=(d,H,O)=>{if(ee)return 0;let F=d??H;return typeof F!="number"||!Number.isFinite(F)||F<0?O:F},z=_(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,R.actionTimeoutMs),X=_(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,R.assertionTimeoutMs),re=_(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,R.navigationTimeoutMs),le=_(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,R.componentReadyTimeoutMs),me=d(s),Y=n?.contractPath;if(!Y)throw new Error(`Contract path not found for component: ${M}`);let Re=(()=>{if(ge.isAbsolute(Y))return Y;if(o){let H=ge.resolve(o,Y);try{return readFileSync(H,"utf-8"),H}catch{}}let d=ge.resolve(process.cwd(),Y);try{return readFileSync(d,"utf-8"),d}catch{return new URL(Y,import.meta.url).pathname}})(),Ae=readFileSync(Re,"utf-8"),b=JSON.parse(Ae),Me=(b.relationships?.length||0)+(b.static[0]?.assertions.length||0)+b.dynamic.length,Ee=b.meta?.source?.apg,V=[],K=[],q=[],x=[],y=null,E=(d,H)=>{let O=c(H),F=e(O,me);if(F==="error")return V.push(d),{status:"fail",level:O,detail:d};if(F==="warning")return K.push(d),{status:"warn",level:O,detail:d};let D=`${d} (ignored by strictness=${me}, level=${O})`;return x.push(D),{status:"skip",level:O,detail:D}};try{if(y=await a(),t){try{await y.goto(t,{waitUntil:"domcontentloaded",timeout:re});}catch(e){throw new Error(`Failed to navigate to ${t}. Ensure dev server is running and accessible. Original error: ${e instanceof Error?e.message:String(e)}`)}await y.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let d=await oe.detect(M,n,z,X,o);if(!d)throw new Error(`Unsupported component: ${M}`);let H=d.getMainSelector();if(!H)throw new Error(`CRITICAL: No selector found in contract for ${M}`);try{await y.locator(H).first().waitFor({state:"attached",timeout:le});}catch(e){throw new Error(`
|
|
23
23
|
\u274C CRITICAL: Component not found on page!
|
|
24
24
|
This usually means:
|
|
25
25
|
- The component didn't render
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var T={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:S},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...w(),...b()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:_},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:D},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:C},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:V},activeOption:{requires:["popup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"input",key:"ArrowDown"})):e.relativeTarget==="first"?[]:e.relativeTarget==="last"?[{type:"keypress",target:"input",key:"ArrowUp"}]:[]}],assertion:(e={})=>M(e.relativeTarget)},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:E},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:b},selectedOption:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>q(e.relativeTarget)}};function S(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function w(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function M(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function E(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function b(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function q(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} option to have aria-selected='true'.`}]}function _(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function D(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function C(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function V(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var A={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:H},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:I},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:F},activeItem:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>B(e.relativeTarget)},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:P},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:O},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:z},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:$},activeSubmenuItem:{requires:["submenu.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)}};function H(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function I(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function F(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function B(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function P(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function O(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function z(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function $(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function L(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var k={activeTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>K(e.relativeTarget)},focusedTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>j(e.relativeTarget)}};function j(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function J(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function K(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},J(e)]}function N(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(N(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var U={combobox:T,menu:A,tabs:k},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=U[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},g=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let a=c[o];if(!a)return [];let r=[];if(Array.isArray(a.requires))for(let s of a.requires)r=r.concat(g(s,i));return a.setup&&(r=r.concat(y(a.setup,p))),r};return t({ariaReference:(o,i,a)=>({requires:r=>{let s=g(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended"})}),contains:(o,i)=>({requires:a=>{let r=g(a,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let g=i=>{let a=this.statePack,r={capabilities:["keyboard"]},s=(n,u=new Set)=>{if(u.has(n))return [];u.add(n);let d=a[n];if(!d)return [];let v=[];if(Array.isArray(d.requires))for(let x of d.requires)v=v.concat(s(x,u));return d.setup&&(v=v.concat(y(d.setup,r))),v};return s(i,new Set)},l=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,a,r)=>{let s=l(i);return {required:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,a)=>({...o(i,a),requires:s=>{let n=g(s);return o(i,a,n)}})}}}),this}when(t){return new h(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}}},h=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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 p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},g=(r,s=new Set)=>{if(s.has(r))return [];s.add(r);let n=this.statePack[r];if(!n)return [];let u=[];if(Array.isArray(n.requires))for(let d of n.requires)u=u.concat(g(d,s));return n.setup&&(u=u.concat(y(n.setup,p))),u},l=[];for(let r of this._given)if(typeof r=="string")l.push(...g(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.setup)for(let u of n.setup)typeof u.steps=="function"?l.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&l.push(...u.steps);}}let o=new Set;l=l.filter(r=>{let s=JSON.stringify(r);return o.has(s)?false:(o.add(s),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let s=this.statePack[r];if(s&&s.assertion!==void 0){let n=s.assertion;if(typeof n=="function")try{n=n();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(n)?i.push(...n):i.push(n);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.assertion!==void 0){let u=n.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(d){throw new Error(`Error calling assertion function for state '${s}': ${d.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let a=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:a,assertions:i,...l.length?{setup:l}:{}});}};function ie(e,t){let c=new f(e);return t(c),new m(c.build())}exports.createContract=ie;
|
|
1
|
+
'use strict';var A={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:w},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...S(),...h()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:q},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:D},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:C},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:V},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>M(e.relativeTarget)},"activedescendant.set":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:E},"activedescendant.unset":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:h},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>_(e.relativeTarget)}};function w(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function S(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function M(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function E(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function h(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function _(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} item to have aria-selected='true'.`}]}function q(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function D(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function C(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function V(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var T={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:H},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:B},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>P(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:F},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:z},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:O},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)}};function H(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function I(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function B(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function P(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function F(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function z(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function O(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function $(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function L(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var k={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>K(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>j(e.relativeTarget)}};function j(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function J(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function K(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},J(e)]}function U(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(U(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var X={combobox:A,menu:T,tabs:k},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=X[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},g=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let a=c[o];if(!a)return [];let r=[];if(Array.isArray(a.requires))for(let s of a.requires)r=r.concat(g(s,i));return a.setup&&(r=r.concat(y(a.setup,p))),r};return t({ariaReference:(o,i,a)=>({requires:r=>{let s=g(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended"})}),contains:(o,i)=>({requires:a=>{let r=g(a,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let g=i=>{let a=this.statePack,r={capabilities:["keyboard"]},s=(n,u=new Set)=>{if(u.has(n))return [];u.add(n);let d=a[n];if(!d)return [];let v=[];if(Array.isArray(d.requires))for(let x of d.requires)v=v.concat(s(x,u));return d.setup&&(v=v.concat(y(d.setup,r))),v};return s(i,new Set)},l=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,a,r)=>{let s=l(i);return {required:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,a)=>({...o(i,a),requires:s=>{let n=g(s);return o(i,a,n)}})}}}),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,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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 p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},g=(r,s=new Set)=>{if(s.has(r))return [];s.add(r);let n=this.statePack[r];if(!n)return [];let u=[];if(Array.isArray(n.requires))for(let d of n.requires)u=u.concat(g(d,s));return n.setup&&(u=u.concat(y(n.setup,p))),u},l=[];for(let r of this._given)if(typeof r=="string")l.push(...g(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.setup)for(let u of n.setup)typeof u.steps=="function"?l.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&l.push(...u.steps);}}let o=new Set;l=l.filter(r=>{let s=JSON.stringify(r);return o.has(s)?false:(o.add(s),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let s=this.statePack[r];if(s&&s.assertion!==void 0){let n=s.assertion;if(typeof n=="function")try{n=n();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(n)?i.push(...n):i.push(n);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.assertion!==void 0){let u=n.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(d){throw new Error(`Error calling assertion function for state '${s}': ${d.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let a=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:a,assertions:i,...l.length?{setup:l}:{}});}};function ie(e,t){let c=new f(e);return t(c),new m(c.build())}exports.createContract=ie;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var T={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:S},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...w(),...b()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:_},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:D},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:C},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:V},activeOption:{requires:["popup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"input",key:"ArrowDown"})):e.relativeTarget==="first"?[]:e.relativeTarget==="last"?[{type:"keypress",target:"input",key:"ArrowUp"}]:[]}],assertion:(e={})=>M(e.relativeTarget)},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:E},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:b},selectedOption:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>q(e.relativeTarget)}};function S(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function w(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function M(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function E(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function b(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function q(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} option to have aria-selected='true'.`}]}function _(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function D(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function C(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function V(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var A={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:H},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:I},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:F},activeItem:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>B(e.relativeTarget)},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:P},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:O},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:z},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:$},activeSubmenuItem:{requires:["submenu.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)}};function H(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function I(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function F(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function B(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function P(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function O(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function z(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function $(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function L(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var k={activeTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>K(e.relativeTarget)},focusedTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>j(e.relativeTarget)}};function j(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function J(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function K(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},J(e)]}function N(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(N(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var U={combobox:T,menu:A,tabs:k},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=U[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},g=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let a=c[o];if(!a)return [];let r=[];if(Array.isArray(a.requires))for(let s of a.requires)r=r.concat(g(s,i));return a.setup&&(r=r.concat(y(a.setup,p))),r};return t({ariaReference:(o,i,a)=>({requires:r=>{let s=g(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended"})}),contains:(o,i)=>({requires:a=>{let r=g(a,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let g=i=>{let a=this.statePack,r={capabilities:["keyboard"]},s=(n,u=new Set)=>{if(u.has(n))return [];u.add(n);let d=a[n];if(!d)return [];let v=[];if(Array.isArray(d.requires))for(let x of d.requires)v=v.concat(s(x,u));return d.setup&&(v=v.concat(y(d.setup,r))),v};return s(i,new Set)},l=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,a,r)=>{let s=l(i);return {required:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,a)=>({...o(i,a),requires:s=>{let n=g(s);return o(i,a,n)}})}}}),this}when(t){return new h(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}}},h=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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 p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},g=(r,s=new Set)=>{if(s.has(r))return [];s.add(r);let n=this.statePack[r];if(!n)return [];let u=[];if(Array.isArray(n.requires))for(let d of n.requires)u=u.concat(g(d,s));return n.setup&&(u=u.concat(y(n.setup,p))),u},l=[];for(let r of this._given)if(typeof r=="string")l.push(...g(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.setup)for(let u of n.setup)typeof u.steps=="function"?l.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&l.push(...u.steps);}}let o=new Set;l=l.filter(r=>{let s=JSON.stringify(r);return o.has(s)?false:(o.add(s),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let s=this.statePack[r];if(s&&s.assertion!==void 0){let n=s.assertion;if(typeof n=="function")try{n=n();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(n)?i.push(...n):i.push(n);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.assertion!==void 0){let u=n.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(d){throw new Error(`Error calling assertion function for state '${s}': ${d.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let a=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:a,assertions:i,...l.length?{setup:l}:{}});}};function ie(e,t){let c=new f(e);return t(c),new m(c.build())}export{ie as createContract};
|
|
1
|
+
var A={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:w},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...S(),...h()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:q},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:D},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:C},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:V},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>M(e.relativeTarget)},"activedescendant.set":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:E},"activedescendant.unset":{requires:[],setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:h},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>_(e.relativeTarget)}};function w(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function S(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function M(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function E(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function h(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function _(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} item to have aria-selected='true'.`}]}function q(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function D(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function C(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function V(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var T={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:H},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:B},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>P(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:F},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:z},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:O},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)}};function H(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function I(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function B(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function P(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function F(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function z(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function O(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function $(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function L(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var k={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>K(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>j(e.relativeTarget)}};function j(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function J(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function K(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},J(e)]}function U(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(U(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var X={combobox:A,menu:T,tabs:k},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=X[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},g=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let a=c[o];if(!a)return [];let r=[];if(Array.isArray(a.requires))for(let s of a.requires)r=r.concat(g(s,i));return a.setup&&(r=r.concat(y(a.setup,p))),r};return t({ariaReference:(o,i,a)=>({requires:r=>{let s=g(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:a,level:"recommended"})}),contains:(o,i)=>({requires:a=>{let r=g(a,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let g=i=>{let a=this.statePack,r={capabilities:["keyboard"]},s=(n,u=new Set)=>{if(u.has(n))return [];u.add(n);let d=a[n];if(!d)return [];let v=[];if(Array.isArray(d.requires))for(let x of d.requires)v=v.concat(s(x,u));return d.setup&&(v=v.concat(y(d.setup,r))),v};return s(i,new Set)},l=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,a,r)=>{let s=l(i);return {required:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:s,attribute:i,expectedValue:a,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,a)=>({...o(i,a),requires:s=>{let n=g(s);return o(i,a,n)}})}}}),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,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}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 p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},g=(r,s=new Set)=>{if(s.has(r))return [];s.add(r);let n=this.statePack[r];if(!n)return [];let u=[];if(Array.isArray(n.requires))for(let d of n.requires)u=u.concat(g(d,s));return n.setup&&(u=u.concat(y(n.setup,p))),u},l=[];for(let r of this._given)if(typeof r=="string")l.push(...g(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.setup)for(let u of n.setup)typeof u.steps=="function"?l.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&l.push(...u.steps);}}let o=new Set;l=l.filter(r=>{let s=JSON.stringify(r);return o.has(s)?false:(o.add(s),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let s=this.statePack[r];if(s&&s.assertion!==void 0){let n=s.assertion;if(typeof n=="function")try{n=n();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(n)?i.push(...n):i.push(n);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let s=this._findStateKeyByTypeAndRef(r.type);if(s){let n=this.statePack[s];if(n&&n.assertion!==void 0){let u=n.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(d){throw new Error(`Error calling assertion function for state '${s}': ${d.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let a=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:a,assertions:i,...l.length?{setup:l}:{}});}};function ie(e,t){let c=new f(e);return t(c),new m(c.build())}export{ie as createContract};
|