aria-ease 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/RelativeTargetResolver-PDJM3ZJI.js +1 -0
- package/dist/TabsComponentStrategy-LKV6D2B7.js +1 -0
- package/dist/{audit-APAPHXRO.js → audit-WBKVW7H6.js} +2 -2
- package/dist/chunk-WIWSYIGK.js +1 -0
- package/dist/cli.cjs +60 -60
- package/dist/cli.js +3 -3
- package/dist/contractTestRunnerPlaywright-44QPA5JG.js +46 -0
- package/dist/contractTestRunnerPlaywright-IUUAGMXP.js +46 -0
- package/dist/index.cjs +40 -40
- package/dist/index.d.cts +35 -11
- package/dist/index.d.ts +35 -11
- package/dist/index.js +14 -14
- package/dist/src/accordion/index.cjs +1 -1
- package/dist/src/accordion/index.js +1 -1
- package/dist/src/block/index.cjs +1 -1
- package/dist/src/block/index.js +1 -1
- package/dist/src/checkbox/index.cjs +1 -1
- package/dist/src/checkbox/index.js +1 -1
- package/dist/src/combobox/index.cjs +1 -1
- package/dist/src/combobox/index.js +1 -1
- package/dist/src/menu/index.cjs +1 -1
- package/dist/src/menu/index.js +1 -1
- package/dist/src/radio/index.cjs +1 -1
- package/dist/src/radio/index.js +1 -1
- package/dist/src/tabs/index.cjs +1 -1
- package/dist/src/tabs/index.js +1 -1
- package/dist/src/toggle/index.cjs +1 -1
- package/dist/src/toggle/index.js +1 -1
- package/dist/src/utils/test/RelativeTargetResolver-5SIQLWPN.js +1 -0
- package/dist/src/utils/test/TabsComponentStrategy-DTQQUCK2.js +1 -0
- package/dist/src/utils/test/chunk-WIWSYIGK.js +1 -0
- package/dist/src/utils/test/contractTestRunnerPlaywright-VALOFEZZ.js +46 -0
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.d.cts +35 -11
- package/dist/src/utils/test/dsl/index.d.ts +35 -11
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +36 -36
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-VXSCSKV5.js → test-MWX7KH44.js} +1 -1
- package/package.json +2 -2
- package/dist/RelativeTargetResolver-T4P25J2M.js +0 -1
- package/dist/TabsComponentStrategy-ADEEFJXM.js +0 -1
- package/dist/chunk-BHNO4ZI3.js +0 -1
- package/dist/contractTestRunnerPlaywright-FOCQTM4L.js +0 -46
- package/dist/contractTestRunnerPlaywright-QPU6HZXG.js +0 -46
- package/dist/src/utils/test/RelativeTargetResolver-UQQMZHI6.js +0 -1
- package/dist/src/utils/test/TabsComponentStrategy-L2PYNEW6.js +0 -1
- package/dist/src/utils/test/chunk-BHNO4ZI3.js +0 -1
- package/dist/src/utils/test/contractTestRunnerPlaywright-YZCMF64Q.js +0 -46
package/dist/index.d.cts
CHANGED
|
@@ -195,10 +195,21 @@ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, lis
|
|
|
195
195
|
declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
|
|
196
196
|
|
|
197
197
|
type StatePack = Record<string, {
|
|
198
|
-
setup?:
|
|
199
|
-
|
|
198
|
+
setup?: Array<{
|
|
199
|
+
when: string[];
|
|
200
|
+
steps: ((arg?: {
|
|
201
|
+
relativeTarget?: string | number;
|
|
202
|
+
}) => DynamicAction[]) | DynamicAction[];
|
|
203
|
+
}>;
|
|
204
|
+
assertion?: ((arg?: {
|
|
205
|
+
relativeTarget?: string | number;
|
|
206
|
+
}) => DynamicAssertion[] | DynamicAssertion) | DynamicAssertion[] | DynamicAssertion;
|
|
200
207
|
requires?: string[];
|
|
201
208
|
}>;
|
|
209
|
+
type RelativeState = {
|
|
210
|
+
type: string;
|
|
211
|
+
ref: string | number;
|
|
212
|
+
};
|
|
202
213
|
type Level = "required" | "recommended" | "optional";
|
|
203
214
|
type ContractMeta = {
|
|
204
215
|
id?: string;
|
|
@@ -229,9 +240,10 @@ type RelationshipInvariant = {
|
|
|
229
240
|
};
|
|
230
241
|
type StaticAssertion = {
|
|
231
242
|
target: string;
|
|
243
|
+
assertion: "toBeVisible" | "notToBeVisible" | "toHaveAttribute" | "toHaveValue" | "toHaveFocus" | "notToHaveFocus" | "toHaveRole";
|
|
232
244
|
attribute: string;
|
|
233
245
|
expectedValue?: string;
|
|
234
|
-
failureMessage
|
|
246
|
+
failureMessage?: string;
|
|
235
247
|
level: Level;
|
|
236
248
|
requires?: string;
|
|
237
249
|
setup?: DynamicAction[];
|
|
@@ -242,7 +254,7 @@ type DynamicAssertion = {
|
|
|
242
254
|
attribute?: string;
|
|
243
255
|
expectedValue?: string;
|
|
244
256
|
failureMessage?: string;
|
|
245
|
-
relativeTarget?: string;
|
|
257
|
+
relativeTarget?: string | number;
|
|
246
258
|
virtualId?: string;
|
|
247
259
|
selectorKey?: string;
|
|
248
260
|
level?: Level;
|
|
@@ -250,17 +262,18 @@ type DynamicAssertion = {
|
|
|
250
262
|
type DynamicAction = {
|
|
251
263
|
type: "focus";
|
|
252
264
|
target: string;
|
|
253
|
-
relativeTarget?: "first" | "last" | "next" | "previous";
|
|
265
|
+
relativeTarget?: "first" | "last" | "next" | "previous" | number;
|
|
254
266
|
virtualId?: string;
|
|
255
267
|
} | {
|
|
256
|
-
type: "click" | "keypress" | "type" | "hover";
|
|
268
|
+
type: "click" | "keypress" | "type" | "hover" | "focus";
|
|
257
269
|
target: string;
|
|
258
270
|
key?: string;
|
|
259
271
|
value?: string;
|
|
260
|
-
relativeTarget?: string;
|
|
272
|
+
relativeTarget?: string | number;
|
|
261
273
|
};
|
|
262
274
|
type DynamicTest = {
|
|
263
275
|
description: string;
|
|
276
|
+
orientation?: "vertical" | "horizontal";
|
|
264
277
|
level?: Level;
|
|
265
278
|
action: DynamicAction[];
|
|
266
279
|
assertions: DynamicAssertion[];
|
|
@@ -335,16 +348,27 @@ declare class DynamicTestBuilder {
|
|
|
335
348
|
private statePack;
|
|
336
349
|
private event;
|
|
337
350
|
private _as;
|
|
338
|
-
private
|
|
351
|
+
private _onTarget;
|
|
352
|
+
private _onRelativeTarget;
|
|
339
353
|
private _given;
|
|
340
354
|
private _then;
|
|
341
355
|
private _desc;
|
|
342
356
|
private _level;
|
|
357
|
+
private _orientation;
|
|
343
358
|
constructor(parent: ContractBuilder, statePack: StatePack, event: string);
|
|
344
359
|
as(actionType: string): this;
|
|
345
|
-
on(target: string): this;
|
|
346
|
-
given(states: string | string[]): this;
|
|
347
|
-
then(states: string | string[]): this;
|
|
360
|
+
on(target: string, relativeTarget?: string | number): this;
|
|
361
|
+
given(states: string | string[] | RelativeState | RelativeState[]): this;
|
|
362
|
+
then(states: string | string[] | RelativeState | RelativeState[]): this;
|
|
363
|
+
orientation(orientation: "vertical" | "horizontal"): this;
|
|
364
|
+
/**
|
|
365
|
+
* Normalize states to an array of string or resolved state keys from relative state objects.
|
|
366
|
+
*/
|
|
367
|
+
private _normalizeStates;
|
|
368
|
+
/**
|
|
369
|
+
* Find a generic state key in the state pack by type.
|
|
370
|
+
*/
|
|
371
|
+
private _findStateKeyByTypeAndRef;
|
|
348
372
|
describe(desc: string): this;
|
|
349
373
|
required(): ContractBuilder;
|
|
350
374
|
optional(): ContractBuilder;
|
package/dist/index.d.ts
CHANGED
|
@@ -195,10 +195,21 @@ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, lis
|
|
|
195
195
|
declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
|
|
196
196
|
|
|
197
197
|
type StatePack = Record<string, {
|
|
198
|
-
setup?:
|
|
199
|
-
|
|
198
|
+
setup?: Array<{
|
|
199
|
+
when: string[];
|
|
200
|
+
steps: ((arg?: {
|
|
201
|
+
relativeTarget?: string | number;
|
|
202
|
+
}) => DynamicAction[]) | DynamicAction[];
|
|
203
|
+
}>;
|
|
204
|
+
assertion?: ((arg?: {
|
|
205
|
+
relativeTarget?: string | number;
|
|
206
|
+
}) => DynamicAssertion[] | DynamicAssertion) | DynamicAssertion[] | DynamicAssertion;
|
|
200
207
|
requires?: string[];
|
|
201
208
|
}>;
|
|
209
|
+
type RelativeState = {
|
|
210
|
+
type: string;
|
|
211
|
+
ref: string | number;
|
|
212
|
+
};
|
|
202
213
|
type Level = "required" | "recommended" | "optional";
|
|
203
214
|
type ContractMeta = {
|
|
204
215
|
id?: string;
|
|
@@ -229,9 +240,10 @@ type RelationshipInvariant = {
|
|
|
229
240
|
};
|
|
230
241
|
type StaticAssertion = {
|
|
231
242
|
target: string;
|
|
243
|
+
assertion: "toBeVisible" | "notToBeVisible" | "toHaveAttribute" | "toHaveValue" | "toHaveFocus" | "notToHaveFocus" | "toHaveRole";
|
|
232
244
|
attribute: string;
|
|
233
245
|
expectedValue?: string;
|
|
234
|
-
failureMessage
|
|
246
|
+
failureMessage?: string;
|
|
235
247
|
level: Level;
|
|
236
248
|
requires?: string;
|
|
237
249
|
setup?: DynamicAction[];
|
|
@@ -242,7 +254,7 @@ type DynamicAssertion = {
|
|
|
242
254
|
attribute?: string;
|
|
243
255
|
expectedValue?: string;
|
|
244
256
|
failureMessage?: string;
|
|
245
|
-
relativeTarget?: string;
|
|
257
|
+
relativeTarget?: string | number;
|
|
246
258
|
virtualId?: string;
|
|
247
259
|
selectorKey?: string;
|
|
248
260
|
level?: Level;
|
|
@@ -250,17 +262,18 @@ type DynamicAssertion = {
|
|
|
250
262
|
type DynamicAction = {
|
|
251
263
|
type: "focus";
|
|
252
264
|
target: string;
|
|
253
|
-
relativeTarget?: "first" | "last" | "next" | "previous";
|
|
265
|
+
relativeTarget?: "first" | "last" | "next" | "previous" | number;
|
|
254
266
|
virtualId?: string;
|
|
255
267
|
} | {
|
|
256
|
-
type: "click" | "keypress" | "type" | "hover";
|
|
268
|
+
type: "click" | "keypress" | "type" | "hover" | "focus";
|
|
257
269
|
target: string;
|
|
258
270
|
key?: string;
|
|
259
271
|
value?: string;
|
|
260
|
-
relativeTarget?: string;
|
|
272
|
+
relativeTarget?: string | number;
|
|
261
273
|
};
|
|
262
274
|
type DynamicTest = {
|
|
263
275
|
description: string;
|
|
276
|
+
orientation?: "vertical" | "horizontal";
|
|
264
277
|
level?: Level;
|
|
265
278
|
action: DynamicAction[];
|
|
266
279
|
assertions: DynamicAssertion[];
|
|
@@ -335,16 +348,27 @@ declare class DynamicTestBuilder {
|
|
|
335
348
|
private statePack;
|
|
336
349
|
private event;
|
|
337
350
|
private _as;
|
|
338
|
-
private
|
|
351
|
+
private _onTarget;
|
|
352
|
+
private _onRelativeTarget;
|
|
339
353
|
private _given;
|
|
340
354
|
private _then;
|
|
341
355
|
private _desc;
|
|
342
356
|
private _level;
|
|
357
|
+
private _orientation;
|
|
343
358
|
constructor(parent: ContractBuilder, statePack: StatePack, event: string);
|
|
344
359
|
as(actionType: string): this;
|
|
345
|
-
on(target: string): this;
|
|
346
|
-
given(states: string | string[]): this;
|
|
347
|
-
then(states: string | string[]): this;
|
|
360
|
+
on(target: string, relativeTarget?: string | number): this;
|
|
361
|
+
given(states: string | string[] | RelativeState | RelativeState[]): this;
|
|
362
|
+
then(states: string | string[] | RelativeState | RelativeState[]): this;
|
|
363
|
+
orientation(orientation: "vertical" | "horizontal"): this;
|
|
364
|
+
/**
|
|
365
|
+
* Normalize states to an array of string or resolved state keys from relative state objects.
|
|
366
|
+
*/
|
|
367
|
+
private _normalizeStates;
|
|
368
|
+
/**
|
|
369
|
+
* Find a generic state key in the state pack by type.
|
|
370
|
+
*/
|
|
371
|
+
private _findStateKeyByTypeAndRef;
|
|
348
372
|
describe(desc: string): this;
|
|
349
373
|
required(): ContractBuilder;
|
|
350
374
|
optional(): ContractBuilder;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{b as U,d as V}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Le({accordionId:c,triggersClass:n,panelsClass:h,allowMultipleOpen:o=!1,callback:s}){let i=document.querySelector(`#${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};let e=Array.from(i.querySelectorAll(`.${n}`));if(e.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};let t=Array.from(i.querySelectorAll(`.${h}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e.length!==t.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${e.length} triggers but ${t.length} panels.`),{cleanup:()=>{}};let r=new WeakMap,m=new WeakMap;function p(){e.forEach((g,T)=>{let L=t[T];g.id||(g.id=`${c}-trigger-${T}`),L.id||(L.id=`${c}-panel-${T}`),g.setAttribute("aria-controls",L.id),g.setAttribute("aria-expanded","false"),(!o||e.length<=6)&&L.setAttribute("role","region"),L.setAttribute("aria-labelledby",g.id),L.style.display="none"})}function v(g){if(g<0||g>=e.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let T=e[g],L=t[g];if(T.setAttribute("aria-expanded","true"),L.style.display="block",s?.onExpand)try{s.onExpand(g)}catch(d){console.error("[aria-ease] Error in accordion onExpand callback:",d)}}function A(g){if(g<0||g>=e.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let T=e[g],L=t[g];if(T.setAttribute("aria-expanded","false"),L.style.display="none",s?.onCollapse)try{s.onCollapse(g)}catch(d){console.error("[aria-ease] Error in accordion onCollapse callback:",d)}}function H(g){e[g].getAttribute("aria-expanded")==="true"?A(g):(o||e.forEach((d,w)=>{w!==g&&A(w)}),v(g))}function C(g){return()=>{H(g)}}function $(g){return T=>{let{key:L}=T;switch(L){case"Enter":case" ":T.preventDefault(),H(g);break;case"ArrowDown":T.preventDefault();{let d=(g+1)%e.length;e[d].focus()}break;case"ArrowUp":T.preventDefault();{let d=(g-1+e.length)%e.length;e[d].focus()}break;case"Home":T.preventDefault(),e[0].focus();break;case"End":T.preventDefault(),e[e.length-1].focus();break}}}function a(){e.forEach((g,T)=>{let L=C(T),d=$(T);g.addEventListener("click",L),g.addEventListener("keydown",d),r.set(g,d),m.set(g,L)})}function l(){e.forEach(g=>{let T=r.get(g),L=m.get(g);T&&(g.removeEventListener("keydown",T),r.delete(g)),L&&(g.removeEventListener("click",L),m.delete(g))})}function k(){l(),e.forEach((g,T)=>{A(T)})}function x(){l();let g=Array.from(i.querySelectorAll(`.${n}`)),T=Array.from(i.querySelectorAll(`.${h}`));e.length=0,e.push(...g),t.length=0,t.push(...T),p(),a()}return p(),a(),{expandItem:v,collapseItem:A,toggleItem:H,cleanup:k,refresh:x}}function P(c){if(c.tagName!=="INPUT")return!1;let n=c.type;return["text","email","password","tel","number"].includes(n)}function N(c){return c.tagName==="TEXTAREA"}function z(c){return c.tagName==="BUTTON"||c.tagName==="INPUT"&&["button","submit","reset"].includes(c.type)}function ee(c){return c.tagName==="A"}function F(c,n,h){let o=c.length,s=(n+h+o)%o;c.item(s).focus()}function te(c){return c.getAttribute("data-custom-click")!==null&&c.getAttribute("data-custom-click")!==void 0}function W(c,n,h){let o=n.item(h);switch(c.key){case"ArrowUp":case"ArrowLeft":{(!P(o)&&!N(o)||(P(o)||N(o))&&o.selectionStart===0)&&(c.preventDefault(),F(n,h,-1));break}case"ArrowDown":case"ArrowRight":{if(!P(o)&&!N(o))c.preventDefault(),F(n,h,1);else if(P(o)||N(o)){let s=o.value;o.selectionStart===s.length&&(c.preventDefault(),F(n,h,1))}break}case"Escape":{c.preventDefault();break}case"Enter":case" ":{(!z(o)&&!ee(o)&&te(o)||z(o))&&(c.preventDefault(),o.click());break}case"Tab":break;default:break}}function Se({blockId:c,blockItemsClass:n}){let h=document.querySelector(`#${c}`);if(!h)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};let o=null;function s(){return o||(o=h.querySelectorAll(`.${n}`)),o}let i=s();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let e=new Map;i.forEach(m=>{if(!e.has(m)){let p=v=>{let A=h.querySelectorAll(`.${n}`),H=Array.prototype.indexOf.call(A,m);W(v,A,H)};m.addEventListener("keydown",p),e.set(m,p)}});function t(){i.forEach(m=>{let p=e.get(m);p&&(m.removeEventListener("keydown",p),e.delete(m))})}function r(){o=null}return{cleanup:t,refresh:r}}function $e({checkboxGroupId:c,checkboxesClass:n}){let h=document.querySelector(`#${c}`);if(!h)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let o=Array.from(h.querySelectorAll(`.${n}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let s=new WeakMap,i=new WeakMap;function e(){h.getAttribute("role")||h.setAttribute("role","group"),o.forEach(a=>{a.setAttribute("role","checkbox"),a.hasAttribute("aria-checked")||a.setAttribute("aria-checked","false"),a.hasAttribute("tabindex")||a.setAttribute("tabindex","0")})}function t(a){if(a<0||a>=o.length){console.error(`[aria-ease] Invalid checkbox index: ${a}`);return}let l=o[a],k=l.getAttribute("aria-checked")==="true";l.setAttribute("aria-checked",k?"false":"true")}function r(a,l){if(a<0||a>=o.length){console.error(`[aria-ease] Invalid checkbox index: ${a}`);return}o[a].setAttribute("aria-checked",l?"true":"false")}function m(a){return()=>{t(a)}}function p(a){return l=>{let{key:k}=l;switch(k){case" ":l.preventDefault(),t(a);break}}}function v(){o.forEach((a,l)=>{let k=m(l),x=p(l);a.addEventListener("click",k),a.addEventListener("keydown",x),s.set(a,x),i.set(a,k)})}function A(){o.forEach(a=>{let l=s.get(a),k=i.get(a);l&&(a.removeEventListener("keydown",l),s.delete(a)),k&&(a.removeEventListener("click",k),i.delete(a))})}function H(){A()}function C(){return o.map(a=>a.getAttribute("aria-checked")==="true")}function $(){return o.map((a,l)=>a.getAttribute("aria-checked")==="true"?l:-1).filter(a=>a!==-1)}return e(),v(),{toggleCheckbox:t,setCheckboxState:r,getCheckedStates:C,getCheckedIndices:$,cleanup:H}}function ne({menuId:c,menuItemsClass:n,triggerId:h,callback:o}){let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${h}`);if(!i)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(c))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",c),i.setAttribute("aria-expanded","false"),s.setAttribute("role","menu"),s.setAttribute("aria-labelledby",h);let e=new WeakMap,t=new Map,r=null,m=null;function p(){return r||(r=s.querySelectorAll(`.${n}`)),r}function v(){if(!m){let f=p();m=[];for(let y=0;y<f.length;y++){let M=f.item(y),D=x(M),I=M.getAttribute("aria-disabled")==="true";D||(M.hasAttribute("tabindex")||M.setAttribute("tabindex","-1"),I||m.push(M))}}return m}function A(f){return{length:f.length,item:M=>f[M],forEach:M=>{f.forEach(M)},[Symbol.iterator]:function*(){for(let M of f)yield M}}}function H(){p().forEach(y=>{y.setAttribute("role","menuitem");let M=y.getAttribute("data-submenu-id")??y.getAttribute("aria-controls"),D=y.hasAttribute("aria-haspopup")&&M;M&&(y.hasAttribute("data-submenu-id")||D)&&(y.setAttribute("aria-haspopup","menu"),y.setAttribute("aria-controls",M),y.hasAttribute("aria-expanded")||y.setAttribute("aria-expanded","false"))})}function C(f,y,M){let D=f.length,I=(y+M+D)%D;f.item(I).focus()}function $(f,y){f.length!==0&&f[y]?.focus()}function a(f){return f.hasAttribute("aria-controls")&&f.hasAttribute("aria-haspopup")&&f.getAttribute("role")==="menuitem"}function l(f){let y=f;for(;y&&y.getAttribute("role")==="menuitem";){let M=y.closest('[role="menu"]');if(!M)break;M.style.display="none",y.setAttribute("aria-expanded","false");let D=M.getAttribute("aria-labelledby");if(!D)break;let I=document.getElementById(D);if(!I)break;y=I}}H();function k(f,y,M){switch(f.key){case"ArrowLeft":{if(f.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){f.preventDefault(),b();return}break}case"ArrowUp":{f.preventDefault(),C(A(v()),M,-1);break}case"ArrowRight":{if(f.key==="ArrowRight"&&a(y)){f.preventDefault();let D=y.getAttribute("aria-controls");if(D){T(D);return}}break}case"ArrowDown":{f.preventDefault(),C(A(v()),M,1);break}case"Home":{f.preventDefault(),$(v(),0);break}case"End":{f.preventDefault();let D=v();$(D,D.length-1);break}case"Escape":{f.preventDefault(),b(),i.focus(),L&&L(!1);break}case"Enter":case" ":{if(f.preventDefault(),a(y)){let D=y.getAttribute("aria-controls");if(D){T(D);return}}y.click(),b(),L&&L(!1);break}case"Tab":{b(),l(i),L&&L(!1);break}default:break}}function x(f){let y=f.parentElement;for(;y&&y!==s;){if(y.getAttribute("role")==="menu"||y.id&&s.querySelector(`[aria-controls="${y.id}"]`))return!0;y=y.parentElement}return!1}function g(f){i.setAttribute("aria-expanded",f?"true":"false")}function T(f){let y=t.get(f);if(!y){let M=s.querySelector(`[aria-controls="${f}"]`);if(!M){console.error(`[aria-ease] Submenu trigger with aria-controls="${f}" not found in menu "${c}".`);return}if(!M.id){let I=`trigger-${f}`;M.id=I,console.warn(`[aria-ease] Submenu trigger for "${f}" had no ID. Auto-generated ID: "${I}".`)}if(!document.querySelector(`#${f}`)){console.error(`[aria-ease] Submenu element with id="${f}" not found. Cannot create submenu instance.`);return}y=ne({menuId:f,menuItemsClass:n,triggerId:M.id,callback:o}),t.set(f,y)}y.openMenu()}function L(f){if(o?.onOpenChange)try{o.onOpenChange(f)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function d(){v().forEach((y,M)=>{if(!e.has(y)){let D=I=>k(I,y,M);y.addEventListener("keydown",D),e.set(y,D)}})}function w(){v().forEach(y=>{let M=e.get(y);M&&(y.removeEventListener("keydown",M),e.delete(y))})}function u(){g(!0),s.style.display="block";let f=v();if(d(),f&&f.length>0&&f[0].focus(),o?.onOpenChange)try{o.onOpenChange(!0)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function b(){if(t.forEach(f=>f.closeMenu()),g(!1),s.style.display="none",w(),i.focus(),o?.onOpenChange)try{o.onOpenChange(!1)}catch(f){console.error("[aria-ease] Error in menu onOpenChange callback:",f)}}function E(){i.getAttribute("aria-expanded")==="true"?b():u()}function S(f){if(!(i.getAttribute("aria-expanded")==="true"))return;let M=i.contains(f.target),D=s.contains(f.target);!M&&!D&&b()}i.addEventListener("click",E),document.addEventListener("click",S);function q(){w(),i.removeEventListener("click",E),document.removeEventListener("click",S),s.style.display="none",g(!1),t.forEach(f=>f.cleanup()),t.clear()}function O(){r=null,m=null}return{openMenu:u,closeMenu:b,cleanup:q,refresh:O}}function Oe({radioGroupId:c,radiosClass:n,defaultSelectedIndex:h=0}){let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};let s=Array.from(o.querySelectorAll(`.${n}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let i=new WeakMap,e=new WeakMap,t=h;function r(){o.getAttribute("role")||o.setAttribute("role","radiogroup"),s.forEach((a,l)=>{a.setAttribute("role","radio"),a.setAttribute("tabindex",l===t?"0":"-1"),l===t?a.setAttribute("aria-checked","true"):a.setAttribute("aria-checked","false")})}function m(a){if(a<0||a>=s.length){console.error(`[aria-ease] Invalid radio index: ${a}`);return}t>=0&&t<s.length&&(s[t].setAttribute("aria-checked","false"),s[t].setAttribute("tabindex","-1")),s[a].setAttribute("aria-checked","true"),s[a].setAttribute("tabindex","0"),s[a].focus(),t=a}function p(a){return()=>{m(a)}}function v(a){return l=>{let{key:k}=l,x=a;switch(k){case"ArrowDown":case"ArrowRight":l.preventDefault(),x=(a+1)%s.length,m(x);break;case"ArrowUp":case"ArrowLeft":l.preventDefault(),x=(a-1+s.length)%s.length,m(x);break;case" ":case"Enter":l.preventDefault(),m(a);break}}}function A(){s.forEach((a,l)=>{let k=p(l),x=v(l);a.addEventListener("click",k),a.addEventListener("keydown",x),i.set(a,x),e.set(a,k)})}function H(){s.forEach(a=>{let l=i.get(a),k=e.get(a);l&&(a.removeEventListener("keydown",l),i.delete(a)),k&&(a.removeEventListener("click",k),e.delete(a))})}function C(){H()}function $(){return t}return r(),A(),{selectRadio:m,getSelectedIndex:$,cleanup:C}}function Ne({toggleId:c,togglesClass:n,isSingleToggle:h=!0}){let o=document.querySelector(`#${c}`);if(!o)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let s;if(h)s=[o];else{if(!n)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(s=Array.from(o.querySelectorAll(`.${n}`)),s.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,e=new WeakMap;function t(){s.forEach(l=>{l.tagName.toLowerCase()!=="button"&&!l.getAttribute("role")&&l.setAttribute("role","button"),l.hasAttribute("aria-pressed")||l.setAttribute("aria-pressed","false"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","0")})}function r(l){if(l<0||l>=s.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}let k=s[l],x=k.getAttribute("aria-pressed")==="true";k.setAttribute("aria-pressed",x?"false":"true")}function m(l,k){if(l<0||l>=s.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}s[l].setAttribute("aria-pressed",k?"true":"false")}function p(l){return()=>{r(l)}}function v(l){return k=>{let{key:x}=k;switch(x){case"Enter":case" ":k.preventDefault(),r(l);break}}}function A(){s.forEach((l,k)=>{let x=p(k),g=v(k);l.addEventListener("click",x),l.addEventListener("keydown",g),i.set(l,g),e.set(l,x)})}function H(){s.forEach(l=>{let k=i.get(l),x=e.get(l);k&&(l.removeEventListener("keydown",k),i.delete(l)),x&&(l.removeEventListener("click",x),e.delete(l))})}function C(){H()}function $(){return s.map(l=>l.getAttribute("aria-pressed")==="true")}function a(){return s.map((l,k)=>l.getAttribute("aria-pressed")==="true"?k:-1).filter(l=>l!==-1)}return t(),A(),{toggleButton:r,setPressed:m,getPressedStates:$,getPressedIndices:a,cleanup:C}}function Re({comboboxInputId:c,comboboxButtonId:n,listBoxId:h,listBoxItemsClass:o,callback:s}){let i=document.getElementById(`${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let e=document.getElementById(`${h}`);if(!e)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let t=n?document.getElementById(`${n}`):null,r=-1;i.setAttribute("role","combobox"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-controls",h),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","listbox"),e.setAttribute("role","listbox");let m=null;function p(){return m||(m=e.querySelectorAll(`.${o}`)),Array.from(m).filter(u=>!u.hidden&&u.style.display!=="none")}function v(){return i.getAttribute("aria-expanded")==="true"}function A(u){let b=p();if(u>=0&&u<b.length){let E=b[u],S=E.id||`${h}-option-${u}`;if(E.id||(E.id=S),i.setAttribute("aria-activedescendant",S),typeof E.scrollIntoView=="function"&&E.scrollIntoView({block:"nearest",behavior:"smooth"}),s?.onActiveDescendantChange)try{s.onActiveDescendantChange(S,E)}catch(q){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",q)}}else i.setAttribute("aria-activedescendant","");r=u}function H(){if(i.setAttribute("aria-expanded","true"),e.style.display="block",s?.onOpenChange)try{s.onOpenChange(!0)}catch(u){console.error("[aria-ease] Error in combobox onOpenChange callback:",u)}}function C(){if(i.setAttribute("aria-expanded","false"),i.setAttribute("aria-activedescendant",""),e.style.display="none",r=-1,s?.onOpenChange)try{s.onOpenChange(!1)}catch(u){console.error("[aria-ease] Error in combobox onOpenChange callback:",u)}}function $(u){let b=u.textContent?.trim()||"";if(i.value=b,u.setAttribute("aria-selected","true"),C(),s?.onSelect)try{s.onSelect(u)}catch(E){console.error("[aria-ease] Error in combobox onSelect callback:",E)}}function a(u){let b=p(),E=v();switch(u.key){case"ArrowDown":if(u.preventDefault(),!E){H();return}if(b.length===0)return;{let S=r>=b.length-1?0:r+1;A(S)}break;case"ArrowUp":if(u.preventDefault(),!E)return;if(b.length>0){let S=r<=0?b.length-1:r-1;A(S)}break;case"Enter":E&&r>=0&&r<b.length&&(u.preventDefault(),$(b[r]));break;case"Escape":if(E)u.preventDefault(),C();else if(i.value&&(u.preventDefault(),i.value="",i.setAttribute("aria-activedescendant",""),p().forEach(q=>{q.getAttribute("aria-selected")==="true"&&q.setAttribute("aria-selected","false")}),s?.onClear))try{s.onClear()}catch(q){console.error("[aria-ease] Error in combobox onClear callback:",q)}break;case"Home":E&&b.length>0&&(u.preventDefault(),A(0));break;case"End":E&&b.length>0&&(u.preventDefault(),A(b.length-1));break;case"Tab":E&&r>=0&&r<b.length&&$(b[r]),E&&C();break}}function l(u){let b=u.target;if(b.classList.contains(o)){let S=p().indexOf(b);S>=0&&A(S)}}function k(u){let b=u.target;b.classList.contains(o)&&(u.preventDefault(),$(b))}function x(u){let b=u.target;!i.contains(b)&&!e.contains(b)&&(!t||!t.contains(b))&&C()}function g(){v()?C():(H(),i.focus())}function T(u){(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),g())}i.addEventListener("keydown",a),e.addEventListener("mousemove",l),e.addEventListener("mousedown",k),document.addEventListener("mousedown",x),t&&(t.setAttribute("tabindex","-1"),t.setAttribute("aria-label","Toggle options"),t.addEventListener("click",g),t.addEventListener("keydown",T));function L(){let u=e.querySelectorAll(`.${o}`);if(u.length===0)return;let b=null;for(let E of u)if(E.getAttribute("aria-selected")==="true"){b=E.textContent?.trim()||null;break}!b&&i.value&&(b=i.value.trim()),u.forEach((E,S)=>{E.setAttribute("role","option");let q=E.textContent?.trim()||"";b&&q===b?E.setAttribute("aria-selected","true"):E.setAttribute("aria-selected","false");let O=E.getAttribute("id");if(!O||O===""){let f=`${h}-option-${S}`;E.id=f,E.setAttribute("id",f)}})}L();function d(){i.removeEventListener("keydown",a),e.removeEventListener("mousemove",l),e.removeEventListener("mousedown",k),document.removeEventListener("mousedown",x),t&&(t.removeEventListener("click",g),t.removeEventListener("keydown",T))}function w(){m=null,L(),r=-1,A(-1)}return{cleanup:d,refresh:w,openListbox:H,closeListbox:C}}function _e({tabListId:c,tabsClass:n,tabPanelsClass:h,orientation:o="horizontal",activateOnFocus:s=!0,callback:i}){let e=document.querySelector(`#${c}`);if(!e)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};let t=Array.from(e.querySelectorAll(`.${n}`));if(t.length===0)return console.error(`[aria-ease] No elements with class="${n}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};let r=Array.from(document.querySelectorAll(`.${h}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t.length!==r.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${t.length} tabs but ${r.length} panels.`),{cleanup:()=>{}};let m=new WeakMap,p=new WeakMap,v=new WeakMap,A=0;function H(){e.setAttribute("role","tablist"),e.setAttribute("aria-orientation",o),t.forEach((d,w)=>{let u=r[w];d.id||(d.id=`${c}-tab-${w}`),u.id||(u.id=`${c}-panel-${w}`),d.setAttribute("role","tab"),d.setAttribute("aria-controls",u.id),d.setAttribute("aria-selected","false"),d.setAttribute("tabindex","-1"),u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",d.id),u.hidden=!0,u.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||u.setAttribute("tabindex","0")}),C(0,!1)}function C(d,w=!0){if(d<0||d>=t.length){console.error(`[aria-ease] Invalid tab index: ${d}`);return}let u=A;t.forEach((S,q)=>{let O=r[q];S.setAttribute("aria-selected","false"),S.setAttribute("tabindex","-1"),O.hidden=!0});let b=t[d],E=r[d];if(b.setAttribute("aria-selected","true"),b.setAttribute("tabindex","0"),E.hidden=!1,w&&b.focus(),A=d,i?.onTabChange&&u!==d)try{i.onTabChange(d,u)}catch(S){console.error("[aria-ease] Error in tabs onTabChange callback:",S)}}function $(d){let w=t.findIndex(E=>E===document.activeElement),u=w!==-1?w:A,b=u;switch(d){case"first":b=0;break;case"last":b=t.length-1;break;case"next":b=(u+1)%t.length;break;case"prev":b=(u-1+t.length)%t.length;break}if(t[b].focus(),t[b].setAttribute("tabindex","0"),t[A].setAttribute("tabindex","-1"),s)C(b,!1);else{let E=A;t.forEach((S,q)=>{q===b?S.setAttribute("tabindex","0"):q!==E&&S.setAttribute("tabindex","-1")})}}function a(d){return()=>{C(d)}}function l(d){return w=>{let{key:u}=w,b=!1;if(o==="horizontal")switch(u){case"ArrowLeft":w.preventDefault(),$("prev"),b=!0;break;case"ArrowRight":w.preventDefault(),$("next"),b=!0;break}else switch(u){case"ArrowUp":w.preventDefault(),$("prev"),b=!0;break;case"ArrowDown":w.preventDefault(),$("next"),b=!0;break}if(!b)switch(u){case"Home":w.preventDefault(),$("first");break;case"End":w.preventDefault(),$("last");break;case" ":case"Enter":s||(w.preventDefault(),C(d));break;case"F10":if(w.shiftKey&&i?.onContextMenu){w.preventDefault();try{i.onContextMenu(d,t[d])}catch(E){console.error("[aria-ease] Error in tabs onContextMenu callback:",E)}}break}}}function k(d){return w=>{if(i?.onContextMenu){w.preventDefault();try{i.onContextMenu(d,t[d])}catch(u){console.error("[aria-ease] Error in tabs onContextMenu callback:",u)}}}}function x(){t.forEach((d,w)=>{let u=a(w),b=l(w),E=k(w);d.addEventListener("click",u),d.addEventListener("keydown",b),i?.onContextMenu&&(d.addEventListener("contextmenu",E),v.set(d,E)),m.set(d,b),p.set(d,u)})}function g(){t.forEach(d=>{let w=m.get(d),u=p.get(d),b=v.get(d);w&&(d.removeEventListener("keydown",w),m.delete(d)),u&&(d.removeEventListener("click",u),p.delete(d)),b&&(d.removeEventListener("contextmenu",b),v.delete(d))})}function T(){g(),t.forEach((d,w)=>{let u=r[w];d.removeAttribute("role"),d.removeAttribute("aria-selected"),d.removeAttribute("aria-controls"),d.removeAttribute("tabindex"),u.removeAttribute("role"),u.removeAttribute("aria-labelledby"),u.removeAttribute("tabindex"),u.hidden=!1}),e.removeAttribute("role"),e.removeAttribute("aria-orientation")}function L(){g();let d=Array.from(e.querySelectorAll(`.${n}`)),w=Array.from(document.querySelectorAll(`.${h}`));t.length=0,t.push(...d),r.length=0,r.push(...w),H(),x()}return H(),x(),{activateTab:C,cleanup:T,refresh:L}}var G={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...se(),...J()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:ie},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:ae},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:oe},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>j("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>j("last")}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function se(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function ie(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function ae(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function oe(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function J(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function j(c){return[{target:"relative",relativeTarget:c,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${c} option to have aria-selected='true'.`}]}function ce(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function le(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ue(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:me},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:be},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ge},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:he},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ye},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ae},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:Ee},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:ke}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function fe(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function me(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function be(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function ge(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function he(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function ye(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ve(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function Ae(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Ee(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function ke(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function we(c,n){return n.some(h=>c.capabilities.includes(h))}function R(c,n){Array.isArray(c)&&c.length&&!c[0].when&&(c=[{when:["keyboard"],steps:()=>c}]);for(let h of c)if(we(n,h.when))return h.steps(n);throw new Error(`No setup strategy matches capabilities: ${n.capabilities.join(", ")}`)}var Me={combobox:G,menu:X},_=class{constructor(n){this.jsonContract=n}toJSON(){return this.jsonContract}},K=class{constructor(n){this.componentName=n;this.statePack=Me[n]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(n){return this.metaValue=n,this}selectors(n){return this.selectorsValue=n,this}relationships(n){let h=this.statePack,o={capabilities:["keyboard"]},s=(e,t=new Set)=>{if(t.has(e))return[];t.add(e);let r=h[e];if(!r)return[];let m=[];if(Array.isArray(r.requires))for(let p of r.requires)m=m.concat(s(p,t));return r.setup&&(m=m.concat(R(r.setup,o))),m};return n({ariaReference:(e,t,r)=>({requires:m=>{let p=s(m,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:t,to:r,level:"recommended"})}),contains:(e,t)=>({requires:r=>{let m=s(r,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"required",setup:m}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"optional",setup:m}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"recommended",setup:m})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:t,level:"recommended"})})}),this}static(n){return n({target:o=>{let s=e=>{let t=this.statePack,r={capabilities:["keyboard"]},m=(p,v=new Set)=>{if(v.has(p))return[];v.add(p);let A=t[p];if(!A)return[];let H=[];if(Array.isArray(A.requires))for(let C of A.requires)H=H.concat(m(C,v));return A.setup&&(H=H.concat(R(A.setup,r))),H};return m(e,new Set)},i=(e,t,r)=>({required:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:o,attribute:e,expectedValue:t,failureMessage:"",level:"recommended",setup:r})});return{has:(e,t)=>({...i(e,t),requires:m=>{let p=s(m);return i(e,t,p)}})}}}),this}when(n){return new B(this,this.statePack,n)}addDynamicTest(n){this.dynamicTests.push(n)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},B=class{constructor(n,h,o){this.parent=n;this.statePack=h;this.event=o}_as;_on;_given=[];_then=[];_desc="";_level="required";as(n){return this._as=n,this}on(n){return this._on=n,this}given(n){return this._given=Array.isArray(n)?n:[n],this}then(n){return this._then=Array.isArray(n)?n:[n],this}describe(n){return this._desc=n,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let o={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},s=(r,m=new Set)=>{if(m.has(r))return[];m.add(r);let p=this.statePack[r];if(!p)return[];let v=[];if(Array.isArray(p.requires))for(let A of p.requires)v=v.concat(s(A,m));return p.setup&&(v=v.concat(R(p.setup,o))),v},i=[];for(let r of this._given)i.push(...s(r));let e=[];for(let r of this._then){let m=this.statePack[r];if(m&&m.assertion!==void 0){let p=m.assertion;if(typeof p=="function")try{p=p()}catch(v){throw new Error(`Error calling assertion function for state '${r}': ${v.message}`)}Array.isArray(p)?e.push(...p):e.push(p)}}let t=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:t,assertions:e,...i.length?{setup:i}:{}})}};function Xe(c,n){let h=new K(c);return n(h),new _(h.build())}import Te from"path";async function Q(c,n,h={}){if(!c||typeof c!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!n)throw new Error("\u274C testUiComponent requires a URL");if(n&&typeof n!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let o={violations:[]};async function s(p){try{let v=await fetch(p,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(v.ok||v.status===304)return p}catch{return null}return null}let i=V(h.strictness),e={},t=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:p}=await import("./configLoader-ZEJVXLX7.js"),v=await p(process.cwd());if(e=v.config,v.configPath&&(t=Te.dirname(v.configPath)),h.strictness===void 0){let A=e.test?.components?.find(H=>H?.name===c)?.strictness;i=V(A??e.test?.strictness)}}catch{h.strictness===void 0&&(i="balanced")}let r;try{if(n){let p=await s(n);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:v}=await import("./contractTestRunnerPlaywright-QPU6HZXG.js");r=await v(c,p,i,e,t)}else throw new Error(`\u274C Dev server not running at ${n}
|
|
2
|
-
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(p){throw p instanceof Error?p:new Error(`\u274C Contract test execution failed: ${String(p)}`)}let
|
|
3
|
-
\u274C ${
|
|
4
|
-
\u2705 ${
|
|
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}
|
|
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
|
+
\u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
|
|
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(
|
|
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,m=i.violations.map(y=>`
|
|
8
|
+
- ${y.id}: ${y.description}
|
|
9
|
+
Impact: ${y.impact}
|
|
10
|
+
Affected elements: ${y.nodes.length}
|
|
11
|
+
Help: ${y.helpUrl}`).join(`
|
|
12
12
|
`);throw new Error(`
|
|
13
13
|
\u274C ${p} axe accessibility violation${p>1?"s":""} detected
|
|
14
|
-
${
|
|
14
|
+
${m}
|
|
15
15
|
|
|
16
|
-
\u{1F4CB} Full details available in result.violations`)}return
|
|
17
|
-
`);let{exec:
|
|
18
|
-
`+"\u2500".repeat(60))),console.log(
|
|
19
|
-
`))}catch(
|
|
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((g,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
|
+
`+"\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)}g({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,Be as makeComboboxAccessible,ne as makeMenuAccessible,Re as makeRadioAccessible,Ke as makeTabsAccessible,Ne as makeToggleAccessible,Q as testUiComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function H({accordionId:
|
|
1
|
+
'use strict';function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:h=false,callback:u}){if(c==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(s.querySelectorAll(`.${i}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r.length!==a.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${r.length} triggers but ${a.length} panels.`),{cleanup:()=>{}};let f=new WeakMap,m=new WeakMap;function b(){r.forEach((e,n)=>{let o=a[n];e.id||(e.id=`${c}-trigger-${n}`),o.id||(o.id=`${c}-panel-${n}`),e.setAttribute("aria-controls",o.id),e.setAttribute("aria-expanded","false"),(!h||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function A(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","true"),o.style.display="block",u?.onExpand)try{u.onExpand(e);}catch(t){console.error("[aria-ease] Error in accordion onExpand callback:",t);}}function d(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","false"),o.style.display="none",u?.onCollapse)try{u.onCollapse(e);}catch(t){console.error("[aria-ease] Error in accordion onCollapse callback:",t);}}function p(e){r[e].getAttribute("aria-expanded")==="true"?d(e):(h||r.forEach((t,E)=>{E!==e&&d(E);}),A(e));}function k(e){return ()=>{p(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),p(e);break;case "ArrowDown":n.preventDefault();{let t=(e+1)%r.length;r[t].focus();}break;case "ArrowUp":n.preventDefault();{let t=(e-1+r.length)%r.length;r[t].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function y(){r.forEach((e,n)=>{let o=k(n),t=v(n);e.addEventListener("click",o),e.addEventListener("keydown",t),f.set(e,t),m.set(e,o);});}function g(){r.forEach(e=>{let n=f.get(e),o=m.get(e);n&&(e.removeEventListener("keydown",n),f.delete(e)),o&&(e.removeEventListener("click",o),m.delete(e));});}function $(){g(),r.forEach((e,n)=>{d(n);});}function w(){g();let e=Array.from(s.querySelectorAll(`.${l}`)),n=Array.from(s.querySelectorAll(`.${i}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),y();}return b(),y(),{expandItem:A,collapseItem:d,toggleItem:p,cleanup:$,refresh:w}}exports.makeAccordionAccessible=H;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function H({accordionId:
|
|
1
|
+
function H({accordionId:c,triggersClass:l,panelsClass:i,allowMultipleOpen:h=false,callback:u}){if(c==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(l==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${l}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${l}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(s.querySelectorAll(`.${i}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r.length!==a.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${r.length} triggers but ${a.length} panels.`),{cleanup:()=>{}};let f=new WeakMap,m=new WeakMap;function b(){r.forEach((e,n)=>{let o=a[n];e.id||(e.id=`${c}-trigger-${n}`),o.id||(o.id=`${c}-panel-${n}`),e.setAttribute("aria-controls",o.id),e.setAttribute("aria-expanded","false"),(!h||r.length<=6)&&o.setAttribute("role","region"),o.setAttribute("aria-labelledby",e.id),o.style.display="none";});}function A(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","true"),o.style.display="block",u?.onExpand)try{u.onExpand(e);}catch(t){console.error("[aria-ease] Error in accordion onExpand callback:",t);}}function d(e){if(e<0||e>=r.length){console.error(`[aria-ease] Invalid accordion index: ${e}`);return}let n=r[e],o=a[e];if(n.setAttribute("aria-expanded","false"),o.style.display="none",u?.onCollapse)try{u.onCollapse(e);}catch(t){console.error("[aria-ease] Error in accordion onCollapse callback:",t);}}function p(e){r[e].getAttribute("aria-expanded")==="true"?d(e):(h||r.forEach((t,E)=>{E!==e&&d(E);}),A(e));}function k(e){return ()=>{p(e);}}function v(e){return n=>{let{key:o}=n;switch(o){case "Enter":case " ":n.preventDefault(),p(e);break;case "ArrowDown":n.preventDefault();{let t=(e+1)%r.length;r[t].focus();}break;case "ArrowUp":n.preventDefault();{let t=(e-1+r.length)%r.length;r[t].focus();}break;case "Home":n.preventDefault(),r[0].focus();break;case "End":n.preventDefault(),r[r.length-1].focus();break}}}function y(){r.forEach((e,n)=>{let o=k(n),t=v(n);e.addEventListener("click",o),e.addEventListener("keydown",t),f.set(e,t),m.set(e,o);});}function g(){r.forEach(e=>{let n=f.get(e),o=m.get(e);n&&(e.removeEventListener("keydown",n),f.delete(e)),o&&(e.removeEventListener("click",o),m.delete(e));});}function $(){g(),r.forEach((e,n)=>{d(n);});}function w(){g();let e=Array.from(s.querySelectorAll(`.${l}`)),n=Array.from(s.querySelectorAll(`.${i}`));r.length=0,r.push(...e),a.length=0,a.push(...n),b(),y();}return b(),y(),{expandItem:A,collapseItem:d,toggleItem:p,cleanup:$,refresh:w}}export{H as makeAccordionAccessible};
|
package/dist/src/block/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function c(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function k(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function M(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function E(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!c(t)&&!u(t)||(c(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!c(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(c(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!k(t)&&M(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){if(e==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(n==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let s=a();if(!s||s.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let l=new Map;s.forEach(o=>{if(!l.has(o)){let i=T=>{let m=r.querySelectorAll(`.${n}`),b=Array.prototype.indexOf.call(m,o);E(T,m,b);};o.addEventListener("keydown",i),l.set(o,i);}});function p(){s.forEach(o=>{let i=l.get(o);i&&(o.removeEventListener("keydown",i),l.delete(o));});}function L(){t=null;}return {cleanup:p,refresh:L}}exports.makeBlockAccessible=g;
|
package/dist/src/block/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(e){if(e.tagName!=="INPUT")return false;let n=e.type;return ["text","email","password","tel","number"].includes(n)}function u(e){return e.tagName==="TEXTAREA"}function d(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function k(e){return e.tagName==="A"}function f(e,n,r){let t=e.length,a=(n+r+t)%t;e.item(a).focus();}function M(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function E(e,n,r){let t=n.item(r);switch(e.key){case "ArrowUp":case "ArrowLeft":{(!c(t)&&!u(t)||(c(t)||u(t))&&t.selectionStart===0)&&(e.preventDefault(),f(n,r,-1));break}case "ArrowDown":case "ArrowRight":{if(!c(t)&&!u(t))e.preventDefault(),f(n,r,1);else if(c(t)||u(t)){let a=t.value;t.selectionStart===a.length&&(e.preventDefault(),f(n,r,1));}break}case "Escape":{e.preventDefault();break}case "Enter":case " ":{(!d(t)&&!k(t)&&M(t)||d(t))&&(e.preventDefault(),t.click());break}}}function g({blockId:e,blockItemsClass:n}){if(e==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${e}`);if(!r)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(n==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let t=null;function a(){return t||(t=r.querySelectorAll(`.${n}`)),t}let s=a();if(!s||s.length===0)return console.error(`[aria-ease] Element with class="${n}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let l=new Map;s.forEach(o=>{if(!l.has(o)){let i=T=>{let m=r.querySelectorAll(`.${n}`),b=Array.prototype.indexOf.call(m,o);E(T,m,b);};o.addEventListener("keydown",i),l.set(o,i);}});function p(){s.forEach(o=>{let i=l.get(o);i&&(o.removeEventListener("keydown",i),l.delete(o));});}function L(){t=null;}return {cleanup:p,refresh:L}}export{g as makeBlockAccessible};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function C({checkboxGroupId:o,checkboxesClass:i}){if(o==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}exports.makeCheckboxAccessible=C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C({checkboxGroupId:o,checkboxesClass:i}){if(o==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}export{C as makeCheckboxAccessible};
|