@compa11y/core 0.1.3 → 0.1.6

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 CHANGED
@@ -8,152 +8,34 @@ Framework-agnostic accessibility primitives for building accessible UI component
8
8
  npm install @compa11y/core
9
9
  ```
10
10
 
11
- ## Features
11
+ ## What's included
12
12
 
13
- - **Focus Management** — Focus traps, focus scope, roving tabindex
14
- - **Keyboard Navigation** — Pre-built patterns for menus, tabs, grids
15
- - **Screen Reader Support** — Live region announcements
16
- - **ARIA Utilities** — Helpers for managing ARIA attributes
13
+ - **Focus Management** — Focus traps, focus scope, roving tabindex, focus neighbor/return
14
+ - **Keyboard Navigation** — Pre-built patterns for menus, tabs, grids, dialogs
15
+ - **Screen Reader Support** — Live region announcements (polite & assertive)
16
+ - **ARIA Utilities** — Helpers for managing ARIA attributes and relationships
17
+ - **Platform Detection** — Detect reduced motion, high contrast, dark mode preferences
17
18
  - **Dev Warnings** — Catch accessibility issues during development
18
19
 
19
- ## Usage
20
-
21
- ### Focus Trap
20
+ ## Quick start
22
21
 
23
22
  ```ts
24
- import { createFocusTrap } from '@compa11y/core';
25
-
26
- const dialog = document.getElementById('dialog');
27
- const trap = createFocusTrap(dialog, {
28
- escapeDeactivates: true,
29
- returnFocus: true,
30
- });
23
+ import { createFocusTrap, announce, aria } from '@compa11y/core';
31
24
 
32
- // Activate when dialog opens
25
+ // Trap focus in a dialog
26
+ const trap = createFocusTrap(dialogElement, { escapeDeactivates: true });
33
27
  trap.activate();
34
28
 
35
- // Deactivate when dialog closes
36
- trap.deactivate();
37
- ```
38
-
39
- ### Announcements
40
-
41
- ```ts
42
- import { announce, announcePolite, announceAssertive } from '@compa11y/core';
43
-
44
- // Polite announcement (doesn't interrupt)
45
- announcePolite('Item added to cart');
46
-
47
- // Assertive announcement (interrupts current speech)
48
- announceAssertive('Error: Form submission failed');
49
- ```
50
-
51
- ### Keyboard Navigation
29
+ // Announce to screen readers
30
+ announce('Item added to cart');
52
31
 
53
- ```ts
54
- import { createKeyboardManager, KeyboardPatterns } from '@compa11y/core';
55
-
56
- const manager = createKeyboardManager(
57
- KeyboardPatterns.menu({
58
- onUp: () => focusPreviousItem(),
59
- onDown: () => focusNextItem(),
60
- onEnter: () => selectItem(),
61
- onEscape: () => closeMenu(),
62
- })
63
- );
64
-
65
- manager.attach(menuElement);
66
- ```
67
-
68
- ### ARIA Utilities
69
-
70
- ```ts
71
- import { aria, buildAriaProps, hasAccessibleName } from '@compa11y/core';
72
-
73
- // Set individual ARIA attributes
32
+ // Set ARIA attributes
74
33
  aria.setExpanded(button, true);
75
- aria.setControls(button, 'menu-id');
76
-
77
- // Build props object for React/frameworks
78
- const props = buildAriaProps({
79
- expanded: true,
80
- controls: 'menu-id',
81
- hasPopup: 'menu',
82
- });
83
-
84
- // Check accessibility
85
- if (!hasAccessibleName(element)) {
86
- console.warn('Element needs an accessible name');
87
- }
88
34
  ```
89
35
 
90
- ### Dev Warnings
91
-
92
- ```ts
93
- import { checks, createComponentWarnings } from '@compa11y/core';
94
-
95
- // Use pre-built checks
96
- checks.accessibleLabel(element, 'MyComponent');
97
-
98
- // Create component-scoped warnings
99
- const warnings = createComponentWarnings('MyComponent');
100
- warnings.error('Missing required prop', 'Add the "label" prop');
101
- ```
102
-
103
- ## API Reference
104
-
105
- ### Focus
106
-
107
- - `createFocusTrap(container, options)` — Create a focus trap
108
- - `createFocusScope(container, options)` — Manage focus within a scope
109
- - `createRovingTabindex(container, selector, options)` — Roving tabindex pattern
110
- - `initFocusVisible()` — Initialize focus-visible detection
111
-
112
- ### Announcer
113
-
114
- - `initAnnouncer()` — Initialize live regions
115
- - `announce(message, options)` — General announcement
116
- - `announcePolite(message)` — Non-interrupting announcement
117
- - `announceAssertive(message)` — Interrupting announcement
118
- - `createAnnouncer(defaults)` — Create scoped announcer
119
-
120
- ### Keyboard
121
-
122
- - `createKeyboardManager(handlers, options)` — Keyboard event handling
123
- - `KeyboardPatterns.menu(handlers)` — Menu navigation pattern
124
- - `KeyboardPatterns.tabs(handlers)` — Tabs navigation pattern
125
- - `KeyboardPatterns.grid(handlers)` — Grid navigation pattern
126
- - `createTypeAhead(items, options)` — Type-ahead search
127
-
128
- ### ARIA
129
-
130
- - `aria.*` — ARIA attribute setters
131
- - `buildAriaProps(props)` — Build props object
132
- - `hasAccessibleName(element)` — Check for accessible name
133
- - `mergeAriaIds(...ids)` — Merge ARIA ID lists
134
-
135
- ### Dev
136
-
137
- - `warn(warning)` — Issue a warning
138
- - `checks.*` — Pre-built accessibility checks
139
- - `createComponentWarnings(name)` — Create scoped warnings
140
-
141
- ### DOM Utilities
142
-
143
- - `isFocusable(element)` — Check if focusable
144
- - `isTabbable(element)` — Check if tabbable
145
- - `getFocusableElements(container)` — Get all focusable elements
146
- - `getTabbableElements(container)` — Get all tabbable elements
147
- - `getFirstFocusable(container)` — Get first focusable
148
- - `getLastFocusable(container)` — Get last focusable
149
-
150
- ### Platform
36
+ ## Documentation
151
37
 
152
- - `isBrowser()` Check if in browser
153
- - `isMac()` — Check if macOS
154
- - `prefersReducedMotion()` — Check motion preference
155
- - `prefersHighContrast()` — Check contrast preference
156
- - `prefersDarkMode()` — Check color scheme preference
38
+ Full documentation, API reference, and examples at **[compa11y.org](https://compa11y.org)**.
157
39
 
158
40
  ## License
159
41
 
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-C3VZQUKG.js';var D=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","iframe"].join(","),K=['a[href]:not([tabindex="-1"])','area[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])','[contenteditable="true"]:not([tabindex="-1"])','audio[controls]:not([tabindex="-1"])','video[controls]:not([tabindex="-1"])','details > summary:first-of-type:not([tabindex="-1"])','iframe:not([tabindex="-1"])'].join(",");function U(e){if(!(e instanceof HTMLElement)||e.hidden||e.style.display==="none"||e.style.visibility==="hidden")return false;let t=window.getComputedStyle(e);return !(t.display==="none"||t.visibility==="hidden"||!e.isConnected)}function V(e){return !(!(e instanceof HTMLElement)||!U(e)||!e.matches(D)||e.closest("[inert]"))}function I(e){return !V(e)||e.tabIndex<0?false:e.matches(K)}function oe(e){return Array.from(e.querySelectorAll(D)).filter(V)}function T(e){return Array.from(e.querySelectorAll(K)).filter(I).sort((u,r)=>{let n=Math.max(0,u.tabIndex),i=Math.max(0,r.tabIndex);return n===0&&i===0?0:n===0?1:i===0?-1:n-i})}function k(e){return T(e)[0]??null}function re(e){let t=T(e);return t[t.length-1]??null}function P(e){let t=document.activeElement;return t!==null&&e.contains(t)}function N(e,t,a=true){let u=T(e),r=u.indexOf(t);if(r===-1)return u[0]??null;let n=r+1;return n<u.length?u[n]:a?u[0]??null:null}function C(e,t,a=true){let u=T(e),r=u.indexOf(t);if(r===-1)return u[u.length-1]??null;let n=r-1;return n>=0?u[n]:a?u[u.length-1]??null:null}function ie(e,t){return t.contains(e)}function q(e,t=document.body){return e?typeof e=="string"?t.querySelector(e):typeof e=="function"?e():e:null}var F=[];function _(e,t={}){let{initialFocus:a,returnFocus:u=true,clickOutsideDeactivates:r=false,escapeDeactivates:n=true,onDeactivate:i,onEscapeFocus:c}=t,o=false,b=false,f=null;function h(l){b||!o||(l.key==="Tab"?y(l):l.key==="Escape"&&n&&(l.preventDefault(),l.stopPropagation(),v()));}function y(l){let E=T(e);if(E.length===0){l.preventDefault();return}let w=E[0],g=E[E.length-1],S=document.activeElement;l.shiftKey?(S===w||!e.contains(S))&&(l.preventDefault(),g.focus()):(S===g||!e.contains(S))&&(l.preventDefault(),w.focus());}function p(l){if(b||!o)return;let E=l.target;e.contains(E)||(c?.(E),k(e)?.focus());}function d(l){if(b||!o)return;let E=l.target;r&&!e.contains(E)&&v();}function m(){if(!o){f=document.activeElement,F.push(A);for(let l=0;l<F.length-1;l++)F[l].pause();document.addEventListener("keydown",h,true),document.addEventListener("focusin",p,true),document.addEventListener("click",d,true),o=true,requestAnimationFrame(()=>{if(!o)return;let l=q(a,e);if(l)l.focus();else {let E=k(e);E?E.focus():(e.setAttribute("tabindex","-1"),e.focus());}});}}function s(l){if(!o)return;document.removeEventListener("keydown",h,true),document.removeEventListener("focusin",p,true),document.removeEventListener("click",d,true),o=false,b=false;let E=F.indexOf(A);if(E>-1&&F.splice(E,1),F[F.length-1]?.unpause(),u&&f){let g=typeof u=="boolean"?f:u;requestAnimationFrame(()=>{g&&"focus"in g&&g.focus();});}l&&i?.();}function v(){s(true);}function L(){s(false);}function M(){!o||b||(b=true);}function H(){!o||!b||(b=false,P(e)||k(e)?.focus());}let A={activate:m,deactivate:v,destroy:L,pause:M,unpause:H,isActive:()=>o,isPaused:()=>b};return A}function z(){return F[F.length-1]??null}function W(){return F.length>0}var x={hadKeyboardEvent:true,isPointerInput:false,lastFocusSource:"unknown"},O=false,j=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown","Escape"]);function G(){if(!a()||O)return ()=>{};O=true;function e(n){j.has(n.key)&&(x.hadKeyboardEvent=true,x.isPointerInput=false,x.lastFocusSource="keyboard");}function t(n){x.isPointerInput=true,x.hadKeyboardEvent=false,x.lastFocusSource="pointerType"in n&&n.pointerType==="touch"?"touch":"mouse";}function a$1(n){let i=n.target;i instanceof HTMLElement&&(x.hadKeyboardEvent||Y(i))&&(i.dataset.a11ykitFocusVisible="true");}function u(n){let i=n.target;i instanceof HTMLElement&&delete i.dataset.a11ykitFocusVisible;}function r(){document.visibilityState==="hidden"&&(x.hadKeyboardEvent=true);}return document.addEventListener("keydown",e,true),document.addEventListener("mousedown",t,true),document.addEventListener("pointerdown",t,true),document.addEventListener("focus",a$1,true),document.addEventListener("blur",u,true),document.addEventListener("visibilitychange",r,true),()=>{document.removeEventListener("keydown",e,true),document.removeEventListener("mousedown",t,true),document.removeEventListener("pointerdown",t,true),document.removeEventListener("focus",a$1,true),document.removeEventListener("blur",u,true),document.removeEventListener("visibilitychange",r,true),O=false;}}function Y(e){let t=e.tagName.toLowerCase(),a=e.getAttribute("type")?.toLowerCase();return !!(t==="input"&&(!a||a==="text"||a==="email"||a==="password"||a==="search"||a==="tel"||a==="url"||a==="number")||t==="textarea"||e.isContentEditable)}function J(){return x.hadKeyboardEvent}function Q(e){return e.dataset.a11ykitFocusVisible==="true"}function X(){return x.lastFocusSource}function Z(e,t){t?e.dataset.a11ykitFocusVisible="true":delete e.dataset.a11ykitFocusVisible;}function $(e,t){x.hadKeyboardEvent=true,x.lastFocusSource="keyboard",e.focus(t);}function ee(e,t={}){let{contain:a=false,restoreFocus:u=false,autoFocus:r=false}=t,n=null,i=false;u&&(n=document.activeElement);function c(){return i?[]:T(e)}function o(){let s=document.activeElement;return s&&e.contains(s)?s:null}function b(){if(i)return;c()[0]?.focus();}function f(){if(i)return;let s=c();s[s.length-1]?.focus();}function h({wrap:s=true}={}){if(i)return;let v=o();if(!v){b();return}N(e,v,s)?.focus();}function y({wrap:s=true}={}){if(i)return;let v=o();if(!v){f();return}C(e,v,s)?.focus();}function p(s){if(i)return;c()[s]?.focus();}function d(s){if(!(i||!a)&&s.key==="Tab"){let v=c();if(v.length===0){s.preventDefault();return}let L=v[0],M=v[v.length-1],H=o();s.shiftKey&&H===L?(s.preventDefault(),M.focus()):!s.shiftKey&&H===M&&(s.preventDefault(),L.focus());}}function m(){i||(i=true,document.removeEventListener("keydown",d,true),u&&n&&n.focus());}return a&&document.addEventListener("keydown",d,true),r&&requestAnimationFrame(()=>{i||b();}),{focusFirst:b,focusLast:f,focusNext:h,focusPrevious:y,focusAt:p,getFocused:o,getElements:c,destroy:m}}function te(e,t,a={}){let{initialIndex:u=0,orientation:r="both",wrap:n=true,onSelectionChange:i}=a,c=[],o=u;function b(){c=Array.from(e.querySelectorAll(t)),c.forEach((p,d)=>{p.setAttribute("tabindex",d===o?"0":"-1");});}function f(p){if(c.length===0)return;let d=p;d<0?d=n?c.length-1:0:d>=c.length&&(d=n?0:c.length-1);let m=c[o],s=c[d];m&&m.setAttribute("tabindex","-1"),s&&(s.setAttribute("tabindex","0"),s.focus(),i?.(d,s)),o=d;}function h(p){let d=p.target;if(!c.includes(d))return;let m=false;switch(p.key){case "ArrowRight":(r==="horizontal"||r==="both")&&(f(o+1),m=true);break;case "ArrowLeft":(r==="horizontal"||r==="both")&&(f(o-1),m=true);break;case "ArrowDown":(r==="vertical"||r==="both")&&(f(o+1),m=true);break;case "ArrowUp":(r==="vertical"||r==="both")&&(f(o-1),m=true);break;case "Home":f(0),m=true;break;case "End":f(c.length-1),m=true;break}m&&(p.preventDefault(),p.stopPropagation());}function y(p){let d=p.target,m=c.indexOf(d);if(m!==-1&&m!==o){let s=c[o];s&&s.setAttribute("tabindex","-1"),d.setAttribute("tabindex","0"),o=m;}}return b(),e.addEventListener("keydown",h),e.addEventListener("focusin",y),{next:()=>f(o+1),previous:()=>f(o-1),first:()=>f(0),last:()=>f(c.length-1),goto:f,getIndex:()=>o,update:b,destroy:()=>{e.removeEventListener("keydown",h),e.removeEventListener("focusin",y);}}}function B(e,t={}){let{scope:a=e.parentElement??document.body,prefer:u="previous"}=t,r=T(a),n=r.indexOf(e);n===-1&&(n=r.findIndex(f=>e.compareDocumentPosition(f)&Node.DOCUMENT_POSITION_FOLLOWING),n===-1&&(n=r.length));let i=n-1,c=n+1,o=i>=0&&r[i]!==e?r[i]:null,b=c<r.length&&r[c]!==e?r[c]:null;return u==="previous"?o??b:b??o}function ne(e){let t=e??null;function a(n){t=n??document.activeElement??null;}function u(n={}){let{fallback:i,prefer:c="previous"}=n;if(!t){i?.focus();return}if(t.isConnected&&I(t)){t.focus(),t=null;return}if(t.isConnected){let o=B(t,{prefer:c});if(o){o.focus(),t=null;return}}i&&i.focus(),t=null;}function r(){t=null;}return {get element(){return t},save:a,return:u,clear:r}}export{ne as A,D as a,K as b,U as c,V as d,I as e,oe as f,T as g,k as h,re as i,P as j,N as k,C as l,ie as m,q as n,_ as o,z as p,W as q,G as r,J as s,Q as t,X as u,Z as v,$ as w,ee as x,te as y,B as z};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7BL2ABLF_cjs=require('./chunk-7BL2ABLF.cjs');var D=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","iframe"].join(","),K=['a[href]:not([tabindex="-1"])','area[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])','[contenteditable="true"]:not([tabindex="-1"])','audio[controls]:not([tabindex="-1"])','video[controls]:not([tabindex="-1"])','details > summary:first-of-type:not([tabindex="-1"])','iframe:not([tabindex="-1"])'].join(",");function U(e){if(!(e instanceof HTMLElement)||e.hidden||e.style.display==="none"||e.style.visibility==="hidden")return false;let t=window.getComputedStyle(e);return !(t.display==="none"||t.visibility==="hidden"||!e.isConnected)}function V(e){return !(!(e instanceof HTMLElement)||!U(e)||!e.matches(D)||e.closest("[inert]"))}function I(e){return !V(e)||e.tabIndex<0?false:e.matches(K)}function oe(e){return Array.from(e.querySelectorAll(D)).filter(V)}function T(e){return Array.from(e.querySelectorAll(K)).filter(I).sort((u,r)=>{let n=Math.max(0,u.tabIndex),i=Math.max(0,r.tabIndex);return n===0&&i===0?0:n===0?1:i===0?-1:n-i})}function k(e){return T(e)[0]??null}function re(e){let t=T(e);return t[t.length-1]??null}function P(e){let t=document.activeElement;return t!==null&&e.contains(t)}function N(e,t,a=true){let u=T(e),r=u.indexOf(t);if(r===-1)return u[0]??null;let n=r+1;return n<u.length?u[n]:a?u[0]??null:null}function C(e,t,a=true){let u=T(e),r=u.indexOf(t);if(r===-1)return u[u.length-1]??null;let n=r-1;return n>=0?u[n]:a?u[u.length-1]??null:null}function ie(e,t){return t.contains(e)}function q(e,t=document.body){return e?typeof e=="string"?t.querySelector(e):typeof e=="function"?e():e:null}var F=[];function _(e,t={}){let{initialFocus:a,returnFocus:u=true,clickOutsideDeactivates:r=false,escapeDeactivates:n=true,onDeactivate:i,onEscapeFocus:c}=t,o=false,b=false,f=null;function h(l){b||!o||(l.key==="Tab"?y(l):l.key==="Escape"&&n&&(l.preventDefault(),l.stopPropagation(),v()));}function y(l){let E=T(e);if(E.length===0){l.preventDefault();return}let w=E[0],g=E[E.length-1],S=document.activeElement;l.shiftKey?(S===w||!e.contains(S))&&(l.preventDefault(),g.focus()):(S===g||!e.contains(S))&&(l.preventDefault(),w.focus());}function p(l){if(b||!o)return;let E=l.target;e.contains(E)||(c?.(E),k(e)?.focus());}function d(l){if(b||!o)return;let E=l.target;r&&!e.contains(E)&&v();}function m(){if(!o){f=document.activeElement,F.push(A);for(let l=0;l<F.length-1;l++)F[l].pause();document.addEventListener("keydown",h,true),document.addEventListener("focusin",p,true),document.addEventListener("click",d,true),o=true,requestAnimationFrame(()=>{if(!o)return;let l=q(a,e);if(l)l.focus();else {let E=k(e);E?E.focus():(e.setAttribute("tabindex","-1"),e.focus());}});}}function s(l){if(!o)return;document.removeEventListener("keydown",h,true),document.removeEventListener("focusin",p,true),document.removeEventListener("click",d,true),o=false,b=false;let E=F.indexOf(A);if(E>-1&&F.splice(E,1),F[F.length-1]?.unpause(),u&&f){let g=typeof u=="boolean"?f:u;requestAnimationFrame(()=>{g&&"focus"in g&&g.focus();});}l&&i?.();}function v(){s(true);}function L(){s(false);}function M(){!o||b||(b=true);}function H(){!o||!b||(b=false,P(e)||k(e)?.focus());}let A={activate:m,deactivate:v,destroy:L,pause:M,unpause:H,isActive:()=>o,isPaused:()=>b};return A}function z(){return F[F.length-1]??null}function W(){return F.length>0}var x={hadKeyboardEvent:true,isPointerInput:false,lastFocusSource:"unknown"},O=false,j=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown","Escape"]);function G(){if(!chunk7BL2ABLF_cjs.a()||O)return ()=>{};O=true;function e(n){j.has(n.key)&&(x.hadKeyboardEvent=true,x.isPointerInput=false,x.lastFocusSource="keyboard");}function t(n){x.isPointerInput=true,x.hadKeyboardEvent=false,x.lastFocusSource="pointerType"in n&&n.pointerType==="touch"?"touch":"mouse";}function a(n){let i=n.target;i instanceof HTMLElement&&(x.hadKeyboardEvent||Y(i))&&(i.dataset.a11ykitFocusVisible="true");}function u(n){let i=n.target;i instanceof HTMLElement&&delete i.dataset.a11ykitFocusVisible;}function r(){document.visibilityState==="hidden"&&(x.hadKeyboardEvent=true);}return document.addEventListener("keydown",e,true),document.addEventListener("mousedown",t,true),document.addEventListener("pointerdown",t,true),document.addEventListener("focus",a,true),document.addEventListener("blur",u,true),document.addEventListener("visibilitychange",r,true),()=>{document.removeEventListener("keydown",e,true),document.removeEventListener("mousedown",t,true),document.removeEventListener("pointerdown",t,true),document.removeEventListener("focus",a,true),document.removeEventListener("blur",u,true),document.removeEventListener("visibilitychange",r,true),O=false;}}function Y(e){let t=e.tagName.toLowerCase(),a=e.getAttribute("type")?.toLowerCase();return !!(t==="input"&&(!a||a==="text"||a==="email"||a==="password"||a==="search"||a==="tel"||a==="url"||a==="number")||t==="textarea"||e.isContentEditable)}function J(){return x.hadKeyboardEvent}function Q(e){return e.dataset.a11ykitFocusVisible==="true"}function X(){return x.lastFocusSource}function Z(e,t){t?e.dataset.a11ykitFocusVisible="true":delete e.dataset.a11ykitFocusVisible;}function $(e,t){x.hadKeyboardEvent=true,x.lastFocusSource="keyboard",e.focus(t);}function ee(e,t={}){let{contain:a=false,restoreFocus:u=false,autoFocus:r=false}=t,n=null,i=false;u&&(n=document.activeElement);function c(){return i?[]:T(e)}function o(){let s=document.activeElement;return s&&e.contains(s)?s:null}function b(){if(i)return;c()[0]?.focus();}function f(){if(i)return;let s=c();s[s.length-1]?.focus();}function h({wrap:s=true}={}){if(i)return;let v=o();if(!v){b();return}N(e,v,s)?.focus();}function y({wrap:s=true}={}){if(i)return;let v=o();if(!v){f();return}C(e,v,s)?.focus();}function p(s){if(i)return;c()[s]?.focus();}function d(s){if(!(i||!a)&&s.key==="Tab"){let v=c();if(v.length===0){s.preventDefault();return}let L=v[0],M=v[v.length-1],H=o();s.shiftKey&&H===L?(s.preventDefault(),M.focus()):!s.shiftKey&&H===M&&(s.preventDefault(),L.focus());}}function m(){i||(i=true,document.removeEventListener("keydown",d,true),u&&n&&n.focus());}return a&&document.addEventListener("keydown",d,true),r&&requestAnimationFrame(()=>{i||b();}),{focusFirst:b,focusLast:f,focusNext:h,focusPrevious:y,focusAt:p,getFocused:o,getElements:c,destroy:m}}function te(e,t,a={}){let{initialIndex:u=0,orientation:r="both",wrap:n=true,onSelectionChange:i}=a,c=[],o=u;function b(){c=Array.from(e.querySelectorAll(t)),c.forEach((p,d)=>{p.setAttribute("tabindex",d===o?"0":"-1");});}function f(p){if(c.length===0)return;let d=p;d<0?d=n?c.length-1:0:d>=c.length&&(d=n?0:c.length-1);let m=c[o],s=c[d];m&&m.setAttribute("tabindex","-1"),s&&(s.setAttribute("tabindex","0"),s.focus(),i?.(d,s)),o=d;}function h(p){let d=p.target;if(!c.includes(d))return;let m=false;switch(p.key){case "ArrowRight":(r==="horizontal"||r==="both")&&(f(o+1),m=true);break;case "ArrowLeft":(r==="horizontal"||r==="both")&&(f(o-1),m=true);break;case "ArrowDown":(r==="vertical"||r==="both")&&(f(o+1),m=true);break;case "ArrowUp":(r==="vertical"||r==="both")&&(f(o-1),m=true);break;case "Home":f(0),m=true;break;case "End":f(c.length-1),m=true;break}m&&(p.preventDefault(),p.stopPropagation());}function y(p){let d=p.target,m=c.indexOf(d);if(m!==-1&&m!==o){let s=c[o];s&&s.setAttribute("tabindex","-1"),d.setAttribute("tabindex","0"),o=m;}}return b(),e.addEventListener("keydown",h),e.addEventListener("focusin",y),{next:()=>f(o+1),previous:()=>f(o-1),first:()=>f(0),last:()=>f(c.length-1),goto:f,getIndex:()=>o,update:b,destroy:()=>{e.removeEventListener("keydown",h),e.removeEventListener("focusin",y);}}}function B(e,t={}){let{scope:a=e.parentElement??document.body,prefer:u="previous"}=t,r=T(a),n=r.indexOf(e);n===-1&&(n=r.findIndex(f=>e.compareDocumentPosition(f)&Node.DOCUMENT_POSITION_FOLLOWING),n===-1&&(n=r.length));let i=n-1,c=n+1,o=i>=0&&r[i]!==e?r[i]:null,b=c<r.length&&r[c]!==e?r[c]:null;return u==="previous"?o??b:b??o}function ne(e){let t=e??null;function a(n){t=n??document.activeElement??null;}function u(n={}){let{fallback:i,prefer:c="previous"}=n;if(!t){i?.focus();return}if(t.isConnected&&I(t)){t.focus(),t=null;return}if(t.isConnected){let o=B(t,{prefer:c});if(o){o.focus(),t=null;return}}i&&i.focus(),t=null;}function r(){t=null;}return {get element(){return t},save:a,return:u,clear:r}}exports.A=ne;exports.a=D;exports.b=K;exports.c=U;exports.d=V;exports.e=I;exports.f=oe;exports.g=T;exports.h=k;exports.i=re;exports.j=P;exports.k=N;exports.l=C;exports.m=ie;exports.n=q;exports.o=_;exports.p=z;exports.q=W;exports.r=G;exports.s=J;exports.t=Q;exports.u=X;exports.v=Z;exports.w=$;exports.x=ee;exports.y=te;exports.z=B;
@@ -1 +1 @@
1
- 'use strict';var chunkOSJIG3A2_cjs=require('../chunk-OSJIG3A2.cjs');require('../chunk-7BL2ABLF.cjs');Object.defineProperty(exports,"createFocusScope",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.x}});Object.defineProperty(exports,"createFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.o}});Object.defineProperty(exports,"createRovingTabindex",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.y}});Object.defineProperty(exports,"focusWithVisibleRing",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.w}});Object.defineProperty(exports,"getActiveFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.p}});Object.defineProperty(exports,"getLastFocusSource",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.u}});Object.defineProperty(exports,"hasFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.q}});Object.defineProperty(exports,"hasVisibleFocus",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.t}});Object.defineProperty(exports,"initFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.r}});Object.defineProperty(exports,"isFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.s}});Object.defineProperty(exports,"setFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.v}});
1
+ 'use strict';var chunkY2RTDE4A_cjs=require('../chunk-Y2RTDE4A.cjs');require('../chunk-7BL2ABLF.cjs');Object.defineProperty(exports,"createFocusReturn",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.A}});Object.defineProperty(exports,"createFocusScope",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.x}});Object.defineProperty(exports,"createFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.o}});Object.defineProperty(exports,"createRovingTabindex",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.y}});Object.defineProperty(exports,"findFocusNeighbor",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.z}});Object.defineProperty(exports,"focusWithVisibleRing",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.w}});Object.defineProperty(exports,"getActiveFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.p}});Object.defineProperty(exports,"getLastFocusSource",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.u}});Object.defineProperty(exports,"hasFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.q}});Object.defineProperty(exports,"hasVisibleFocus",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.t}});Object.defineProperty(exports,"initFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.r}});Object.defineProperty(exports,"isFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.s}});Object.defineProperty(exports,"setFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.v}});
@@ -136,4 +136,66 @@ interface RovingTabindex {
136
136
  }
137
137
  declare function createRovingTabindex(container: HTMLElement, selector: string, options?: RovingTabindexOptions): RovingTabindex;
138
138
 
139
- export { type FocusScope, type FocusScopeOptions, type RovingTabindex, type RovingTabindexOptions, createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible };
139
+ /**
140
+ * Focus Neighbor & Focus Return
141
+ *
142
+ * Utilities for graceful focus recovery when the focused element
143
+ * becomes disabled, removed, or otherwise unfocusable.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * // Find where focus should go if this button is about to be removed
148
+ * const neighbor = findFocusNeighbor(button);
149
+ * neighbor?.focus();
150
+ *
151
+ * // Remember focus target, restore later (with fallback to neighbor)
152
+ * const focusReturn = createFocusReturn();
153
+ * focusReturn.save(triggerButton);
154
+ * // ... later, after modal closes:
155
+ * focusReturn.return(); // focuses trigger, or its neighbor if trigger is disabled
156
+ * ```
157
+ */
158
+ interface FocusNeighborOptions {
159
+ /** Container to search within (default: element.parentElement ?? document.body) */
160
+ scope?: HTMLElement;
161
+ /** Which direction to try first: 'previous' (default) or 'next' */
162
+ prefer?: 'previous' | 'next';
163
+ }
164
+ /**
165
+ * Find the nearest focusable neighbor of an element within a scope.
166
+ *
167
+ * Useful when an element is about to be removed or disabled and you
168
+ * need to know where to move focus.
169
+ *
170
+ * @param element - The reference element to find a neighbor for
171
+ * @param options - Search scope and direction preference
172
+ * @returns The nearest tabbable neighbor, or null if none found
173
+ */
174
+ declare function findFocusNeighbor(element: HTMLElement, options?: FocusNeighborOptions): HTMLElement | null;
175
+ interface FocusReturnOptions {
176
+ /** Fallback element if saved element and its neighbors are all unfocusable */
177
+ fallback?: HTMLElement;
178
+ /** Direction preference for neighbor search */
179
+ prefer?: 'previous' | 'next';
180
+ }
181
+ interface FocusReturn {
182
+ /** The currently saved element (may be null) */
183
+ readonly element: HTMLElement | null;
184
+ /** Save an element (or current activeElement) as the return target */
185
+ save(element?: HTMLElement): void;
186
+ /** Return focus to the saved element, or its nearest neighbor if unavailable */
187
+ return(options?: FocusReturnOptions): void;
188
+ /** Clear the saved reference without moving focus */
189
+ clear(): void;
190
+ }
191
+ /**
192
+ * Create a focus return manager that remembers an element and can
193
+ * restore focus to it later — with smart fallback to the nearest
194
+ * focusable neighbor if the saved element is no longer available.
195
+ *
196
+ * @param initialElement - Optional element to save immediately
197
+ * @returns FocusReturn controller
198
+ */
199
+ declare function createFocusReturn(initialElement?: HTMLElement): FocusReturn;
200
+
201
+ export { type FocusNeighborOptions, type FocusReturn, type FocusReturnOptions, type FocusScope, type FocusScopeOptions, type RovingTabindex, type RovingTabindexOptions, createFocusReturn, createFocusScope, createFocusTrap, createRovingTabindex, findFocusNeighbor, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible };
@@ -136,4 +136,66 @@ interface RovingTabindex {
136
136
  }
137
137
  declare function createRovingTabindex(container: HTMLElement, selector: string, options?: RovingTabindexOptions): RovingTabindex;
138
138
 
139
- export { type FocusScope, type FocusScopeOptions, type RovingTabindex, type RovingTabindexOptions, createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible };
139
+ /**
140
+ * Focus Neighbor & Focus Return
141
+ *
142
+ * Utilities for graceful focus recovery when the focused element
143
+ * becomes disabled, removed, or otherwise unfocusable.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * // Find where focus should go if this button is about to be removed
148
+ * const neighbor = findFocusNeighbor(button);
149
+ * neighbor?.focus();
150
+ *
151
+ * // Remember focus target, restore later (with fallback to neighbor)
152
+ * const focusReturn = createFocusReturn();
153
+ * focusReturn.save(triggerButton);
154
+ * // ... later, after modal closes:
155
+ * focusReturn.return(); // focuses trigger, or its neighbor if trigger is disabled
156
+ * ```
157
+ */
158
+ interface FocusNeighborOptions {
159
+ /** Container to search within (default: element.parentElement ?? document.body) */
160
+ scope?: HTMLElement;
161
+ /** Which direction to try first: 'previous' (default) or 'next' */
162
+ prefer?: 'previous' | 'next';
163
+ }
164
+ /**
165
+ * Find the nearest focusable neighbor of an element within a scope.
166
+ *
167
+ * Useful when an element is about to be removed or disabled and you
168
+ * need to know where to move focus.
169
+ *
170
+ * @param element - The reference element to find a neighbor for
171
+ * @param options - Search scope and direction preference
172
+ * @returns The nearest tabbable neighbor, or null if none found
173
+ */
174
+ declare function findFocusNeighbor(element: HTMLElement, options?: FocusNeighborOptions): HTMLElement | null;
175
+ interface FocusReturnOptions {
176
+ /** Fallback element if saved element and its neighbors are all unfocusable */
177
+ fallback?: HTMLElement;
178
+ /** Direction preference for neighbor search */
179
+ prefer?: 'previous' | 'next';
180
+ }
181
+ interface FocusReturn {
182
+ /** The currently saved element (may be null) */
183
+ readonly element: HTMLElement | null;
184
+ /** Save an element (or current activeElement) as the return target */
185
+ save(element?: HTMLElement): void;
186
+ /** Return focus to the saved element, or its nearest neighbor if unavailable */
187
+ return(options?: FocusReturnOptions): void;
188
+ /** Clear the saved reference without moving focus */
189
+ clear(): void;
190
+ }
191
+ /**
192
+ * Create a focus return manager that remembers an element and can
193
+ * restore focus to it later — with smart fallback to the nearest
194
+ * focusable neighbor if the saved element is no longer available.
195
+ *
196
+ * @param initialElement - Optional element to save immediately
197
+ * @returns FocusReturn controller
198
+ */
199
+ declare function createFocusReturn(initialElement?: HTMLElement): FocusReturn;
200
+
201
+ export { type FocusNeighborOptions, type FocusReturn, type FocusReturnOptions, type FocusScope, type FocusScopeOptions, type RovingTabindex, type RovingTabindexOptions, createFocusReturn, createFocusScope, createFocusTrap, createRovingTabindex, findFocusNeighbor, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible };
@@ -1 +1 @@
1
- export{x as createFocusScope,o as createFocusTrap,y as createRovingTabindex,w as focusWithVisibleRing,p as getActiveFocusTrap,u as getLastFocusSource,q as hasFocusTrap,t as hasVisibleFocus,r as initFocusVisible,s as isFocusVisible,v as setFocusVisible}from'../chunk-BAFKUMWA.js';import'../chunk-C3VZQUKG.js';
1
+ export{A as createFocusReturn,x as createFocusScope,o as createFocusTrap,y as createRovingTabindex,z as findFocusNeighbor,w as focusWithVisibleRing,p as getActiveFocusTrap,u as getLastFocusSource,q as hasFocusTrap,t as hasVisibleFocus,r as initFocusVisible,s as isFocusVisible,v as setFocusVisible}from'../chunk-QGEFH2VG.js';import'../chunk-C3VZQUKG.js';
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var chunkOSJIG3A2_cjs=require('./chunk-OSJIG3A2.cjs'),chunkEM45V5TK_cjs=require('./chunk-EM45V5TK.cjs'),chunkAQ6HEUSD_cjs=require('./chunk-AQ6HEUSD.cjs'),chunk7BL2ABLF_cjs=require('./chunk-7BL2ABLF.cjs'),chunkKQUAJKTG_cjs=require('./chunk-KQUAJKTG.cjs');var g=0,d="compa11y";function u(e){let n=++g;return e?`${d}-${e}-${n}`:`${d}-${n}`}function he(e,n){let r=u(n),t={};for(let o of e)t[o]=`${r}-${o}`;return t}function ke(){g=0;}function $e(e){let n=u(e);return {id:n,generate:r=>`${n}-${r}`,generateMultiple:r=>{let t={};for(let o of r)t[o]=`${n}-${o}`;return t}}}var a=null,l=new Set;function p(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function b(e){a=e;}function f(e){return `${e.component}:${e.message}`}function i(e){if(!p())return;let n=f(e);if(l.has(n))return;if(l.add(n),a){a(e);return}let r=`[compa11y/${e.component}]`,t=m(e.type),o=e.suggestion?`${e.message}
1
+ 'use strict';var chunkY2RTDE4A_cjs=require('./chunk-Y2RTDE4A.cjs'),chunkEM45V5TK_cjs=require('./chunk-EM45V5TK.cjs'),chunkAQ6HEUSD_cjs=require('./chunk-AQ6HEUSD.cjs'),chunk7BL2ABLF_cjs=require('./chunk-7BL2ABLF.cjs'),chunkKQUAJKTG_cjs=require('./chunk-KQUAJKTG.cjs');var g=0,d="compa11y";function u(e){let n=++g;return e?`${d}-${e}-${n}`:`${d}-${n}`}function $e(e,n){let r=u(n),t={};for(let o of e)t[o]=`${r}-${o}`;return t}function we(){g=0;}function Ae(e){let n=u(e);return {id:n,generate:r=>`${n}-${r}`,generateMultiple:r=>{let t={};for(let o of r)t[o]=`${n}-${o}`;return t}}}var a=null,l=new Set;function p(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function b(e){a=e;}function f(e){return `${e.component}:${e.message}`}function i(e){if(!p())return;let n=f(e);if(l.has(n))return;if(l.add(n),a){a(e);return}let r=`[compa11y/${e.component}]`,t=m(e.type),o=e.suggestion?`${e.message}
2
2
 
3
- \u{1F4A1} Suggestion: ${e.suggestion}`:e.message;switch(e.type){case "error":console.error(`%c${r}%c ${o}`,t,"");break;case "warning":console.warn(`%c${r}%c ${o}`,t,"");break;case "info":console.info(`%c${r}%c ${o}`,t,"");break}e.element&&console.log("Element:",e.element);}function m(e){switch(e){case "error":return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "warning":return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "info":return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;"}}function x(){l.clear();}var s={accessibleLabel(e,n,r="aria-label"){e&&(chunkKQUAJKTG_cjs.d(e)||i({type:"error",component:n,message:"Missing accessible label. Screen reader users will not be able to understand this element.",suggestion:`Add ${r}, aria-labelledby, or visible text content.`,element:e}));},requiredProp(e,n,r){(e==null||e==="")&&i({type:"error",component:r,message:`Missing required prop "${n}".`,suggestion:`Provide a value for the "${n}" prop.`});},validRole(e,n,r){if(!e)return;new Set(["alert","alertdialog","application","article","banner","button","cell","columnheader","combobox","complementary","contentinfo","definition","dialog","directory","document","feed","figure","form","grid","gridcell","group","heading","img","link","list","listbox","listitem","log","main","marquee","math","menu","menubar","menuitem","navigation","none","note","option","presentation","progressbar","region","row","rowgroup","rowheader","scrollbar","search","searchbox","separator","slider","spinbutton","status","switch","tab","table","tablist","tabpanel","term","textbox","timer","toolbar","tooltip","tree","treegrid","treeitem"]).has(e)||i({type:"warning",component:n,message:`Invalid ARIA role "${e}".`,suggestion:"Use a valid ARIA role from the WAI-ARIA specification.",element:r});},keyboardAccessible(e,n,r){if(e&&r.onClick&&!r.onKeyDown){let t=e.tagName.toLowerCase(),o=e.getAttribute("role");if(["button","a","input","select","textarea"].includes(t))return;o&&["button","link","menuitem","option","tab"].includes(o)&&i({type:"warning",component:n,message:"Element has onClick but no onKeyDown handler.",suggestion:"Add keyboard event handling for Enter and Space keys.",element:e});}},tabIndex(e,n,r){e!==void 0&&e>0&&i({type:"warning",component:n,message:`Positive tabIndex (${e}) disrupts natural tab order.`,suggestion:"Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",element:r});},dialogAutoFocus(e,n){e||i({type:"info",component:n,message:"No initial focus element specified for dialog.",suggestion:"Consider setting initialFocus to guide keyboard users."});},formLabel(e,n,r){if(!e)return;n||e.getAttribute("aria-label")||e.getAttribute("aria-labelledby")||e.labels?.length||i({type:"error",component:r,message:"Form input is missing an accessible label.",suggestion:"Add a <label>, aria-label, or aria-labelledby.",element:e});},imageAlt(e,n){if(!e||e.tagName!=="IMG")return;let r=e.getAttribute("alt"),t=e.getAttribute("role");r===null&&t!=="presentation"&&t!=="none"&&i({type:"error",component:n,message:"Image is missing alt attribute.",suggestion:'Add alt="" for decorative images or descriptive alt text for meaningful images.',element:e});}};function y(e){return {error:(n,r,t)=>i({type:"error",component:e,message:n,suggestion:r,element:t}),warning:(n,r,t)=>i({type:"warning",component:e,message:n,suggestion:r,element:t}),info:(n,r,t)=>i({type:"info",component:e,message:n,suggestion:r,element:t}),checks:{accessibleLabel:(n,r)=>s.accessibleLabel(n,e,r),requiredProp:(n,r)=>s.requiredProp(n,r,e),keyboardAccessible:(n,r)=>s.keyboardAccessible(n,e,r),tabIndex:(n,r)=>s.tabIndex(n,e,r)}}}function Ee(){let e=[];return import('./focus/index.cjs').then(({initFocusVisible:n})=>{e.push(n());}),import('./announcer/index.cjs').then(({initAnnouncer:n})=>{e.push(n());}),()=>{e.forEach(n=>n());}}Object.defineProperty(exports,"FOCUSABLE_SELECTORS",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.a}});Object.defineProperty(exports,"TABBABLE_SELECTORS",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.b}});Object.defineProperty(exports,"containsFocus",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.j}});Object.defineProperty(exports,"createFocusScope",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.x}});Object.defineProperty(exports,"createFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.o}});Object.defineProperty(exports,"createRovingTabindex",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.y}});Object.defineProperty(exports,"focusWithVisibleRing",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.w}});Object.defineProperty(exports,"getActiveFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.p}});Object.defineProperty(exports,"getFirstFocusable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.h}});Object.defineProperty(exports,"getFocusableElements",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.f}});Object.defineProperty(exports,"getLastFocusSource",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.u}});Object.defineProperty(exports,"getLastFocusable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.i}});Object.defineProperty(exports,"getNextFocusable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.k}});Object.defineProperty(exports,"getPreviousFocusable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.l}});Object.defineProperty(exports,"getTabbableElements",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.g}});Object.defineProperty(exports,"hasFocusTrap",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.q}});Object.defineProperty(exports,"hasVisibleFocus",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.t}});Object.defineProperty(exports,"initFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.r}});Object.defineProperty(exports,"isFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.s}});Object.defineProperty(exports,"isFocusable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.d}});Object.defineProperty(exports,"isTabbable",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.e}});Object.defineProperty(exports,"isVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.c}});Object.defineProperty(exports,"isWithinContainer",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.m}});Object.defineProperty(exports,"resolveElement",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.n}});Object.defineProperty(exports,"setFocusVisible",{enumerable:true,get:function(){return chunkOSJIG3A2_cjs.v}});Object.defineProperty(exports,"KeyboardPatterns",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.d}});Object.defineProperty(exports,"createKeyboardManager",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.c}});Object.defineProperty(exports,"createTypeAhead",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.e}});Object.defineProperty(exports,"getKeyCombo",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.b}});Object.defineProperty(exports,"normalizeKey",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.a}});Object.defineProperty(exports,"announce",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.b}});Object.defineProperty(exports,"announceAssertive",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.d}});Object.defineProperty(exports,"announceError",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.i}});Object.defineProperty(exports,"announcePolite",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.c}});Object.defineProperty(exports,"announceProgress",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.j}});Object.defineProperty(exports,"announceStatus",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.h}});Object.defineProperty(exports,"clearAnnouncements",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.e}});Object.defineProperty(exports,"createAnnouncer",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.g}});Object.defineProperty(exports,"initAnnouncer",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.a}});Object.defineProperty(exports,"queueAnnouncement",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.f}});Object.defineProperty(exports,"createMediaQueryListener",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.k}});Object.defineProperty(exports,"getScreenReaderHints",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.j}});Object.defineProperty(exports,"isAndroid",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.d}});Object.defineProperty(exports,"isBrowser",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.a}});Object.defineProperty(exports,"isIOS",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.c}});Object.defineProperty(exports,"isMac",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.b}});Object.defineProperty(exports,"isTouchDevice",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.f}});Object.defineProperty(exports,"isWindows",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.e}});Object.defineProperty(exports,"prefersDarkMode",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.i}});Object.defineProperty(exports,"prefersHighContrast",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.h}});Object.defineProperty(exports,"prefersReducedMotion",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.g}});Object.defineProperty(exports,"aria",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.a}});Object.defineProperty(exports,"buildAriaProps",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.b}});Object.defineProperty(exports,"hasAccessibleName",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.d}});Object.defineProperty(exports,"mergeAriaIds",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.c}});exports.checks=s;exports.clearWarnings=x;exports.createComponentWarnings=y;exports.createIdScope=$e;exports.generateId=u;exports.generateIds=he;exports.initCompa11y=Ee;exports.resetIdCounter=ke;exports.setWarningHandler=b;exports.warn=i;
3
+ \u{1F4A1} Suggestion: ${e.suggestion}`:e.message;switch(e.type){case "error":console.error(`%c${r}%c ${o}`,t,"");break;case "warning":console.warn(`%c${r}%c ${o}`,t,"");break;case "info":console.info(`%c${r}%c ${o}`,t,"");break}e.element&&console.log("Element:",e.element);}function m(e){switch(e){case "error":return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "warning":return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "info":return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;"}}function x(){l.clear();}var s={accessibleLabel(e,n,r="aria-label"){e&&(chunkKQUAJKTG_cjs.d(e)||i({type:"error",component:n,message:"Missing accessible label. Screen reader users will not be able to understand this element.",suggestion:`Add ${r}, aria-labelledby, or visible text content.`,element:e}));},requiredProp(e,n,r){(e==null||e==="")&&i({type:"error",component:r,message:`Missing required prop "${n}".`,suggestion:`Provide a value for the "${n}" prop.`});},validRole(e,n,r){if(!e)return;new Set(["alert","alertdialog","application","article","banner","button","cell","columnheader","combobox","complementary","contentinfo","definition","dialog","directory","document","feed","figure","form","grid","gridcell","group","heading","img","link","list","listbox","listitem","log","main","marquee","math","menu","menubar","menuitem","navigation","none","note","option","presentation","progressbar","region","row","rowgroup","rowheader","scrollbar","search","searchbox","separator","slider","spinbutton","status","switch","tab","table","tablist","tabpanel","term","textbox","timer","toolbar","tooltip","tree","treegrid","treeitem"]).has(e)||i({type:"warning",component:n,message:`Invalid ARIA role "${e}".`,suggestion:"Use a valid ARIA role from the WAI-ARIA specification.",element:r});},keyboardAccessible(e,n,r){if(e&&r.onClick&&!r.onKeyDown){let t=e.tagName.toLowerCase(),o=e.getAttribute("role");if(["button","a","input","select","textarea"].includes(t))return;o&&["button","link","menuitem","option","tab"].includes(o)&&i({type:"warning",component:n,message:"Element has onClick but no onKeyDown handler.",suggestion:"Add keyboard event handling for Enter and Space keys.",element:e});}},tabIndex(e,n,r){e!==void 0&&e>0&&i({type:"warning",component:n,message:`Positive tabIndex (${e}) disrupts natural tab order.`,suggestion:"Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",element:r});},dialogAutoFocus(e,n){e||i({type:"info",component:n,message:"No initial focus element specified for dialog.",suggestion:"Consider setting initialFocus to guide keyboard users."});},formLabel(e,n,r){if(!e)return;n||e.getAttribute("aria-label")||e.getAttribute("aria-labelledby")||e.labels?.length||i({type:"error",component:r,message:"Form input is missing an accessible label.",suggestion:"Add a <label>, aria-label, or aria-labelledby.",element:e});},imageAlt(e,n){if(!e||e.tagName!=="IMG")return;let r=e.getAttribute("alt"),t=e.getAttribute("role");r===null&&t!=="presentation"&&t!=="none"&&i({type:"error",component:n,message:"Image is missing alt attribute.",suggestion:'Add alt="" for decorative images or descriptive alt text for meaningful images.',element:e});}};function y(e){return {error:(n,r,t)=>i({type:"error",component:e,message:n,suggestion:r,element:t}),warning:(n,r,t)=>i({type:"warning",component:e,message:n,suggestion:r,element:t}),info:(n,r,t)=>i({type:"info",component:e,message:n,suggestion:r,element:t}),checks:{accessibleLabel:(n,r)=>s.accessibleLabel(n,e,r),requiredProp:(n,r)=>s.requiredProp(n,r,e),keyboardAccessible:(n,r)=>s.keyboardAccessible(n,e,r),tabIndex:(n,r)=>s.tabIndex(n,e,r)}}}function We(){let e=[];return import('./focus/index.cjs').then(({initFocusVisible:n})=>{e.push(n());}),import('./announcer/index.cjs').then(({initAnnouncer:n})=>{e.push(n());}),()=>{e.forEach(n=>n());}}Object.defineProperty(exports,"FOCUSABLE_SELECTORS",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.a}});Object.defineProperty(exports,"TABBABLE_SELECTORS",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.b}});Object.defineProperty(exports,"containsFocus",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.j}});Object.defineProperty(exports,"createFocusReturn",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.A}});Object.defineProperty(exports,"createFocusScope",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.x}});Object.defineProperty(exports,"createFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.o}});Object.defineProperty(exports,"createRovingTabindex",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.y}});Object.defineProperty(exports,"findFocusNeighbor",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.z}});Object.defineProperty(exports,"focusWithVisibleRing",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.w}});Object.defineProperty(exports,"getActiveFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.p}});Object.defineProperty(exports,"getFirstFocusable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.h}});Object.defineProperty(exports,"getFocusableElements",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.f}});Object.defineProperty(exports,"getLastFocusSource",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.u}});Object.defineProperty(exports,"getLastFocusable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.i}});Object.defineProperty(exports,"getNextFocusable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.k}});Object.defineProperty(exports,"getPreviousFocusable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.l}});Object.defineProperty(exports,"getTabbableElements",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.g}});Object.defineProperty(exports,"hasFocusTrap",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.q}});Object.defineProperty(exports,"hasVisibleFocus",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.t}});Object.defineProperty(exports,"initFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.r}});Object.defineProperty(exports,"isFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.s}});Object.defineProperty(exports,"isFocusable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.d}});Object.defineProperty(exports,"isTabbable",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.e}});Object.defineProperty(exports,"isVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.c}});Object.defineProperty(exports,"isWithinContainer",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.m}});Object.defineProperty(exports,"resolveElement",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.n}});Object.defineProperty(exports,"setFocusVisible",{enumerable:true,get:function(){return chunkY2RTDE4A_cjs.v}});Object.defineProperty(exports,"KeyboardPatterns",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.d}});Object.defineProperty(exports,"createKeyboardManager",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.c}});Object.defineProperty(exports,"createTypeAhead",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.e}});Object.defineProperty(exports,"getKeyCombo",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.b}});Object.defineProperty(exports,"normalizeKey",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.a}});Object.defineProperty(exports,"announce",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.b}});Object.defineProperty(exports,"announceAssertive",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.d}});Object.defineProperty(exports,"announceError",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.i}});Object.defineProperty(exports,"announcePolite",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.c}});Object.defineProperty(exports,"announceProgress",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.j}});Object.defineProperty(exports,"announceStatus",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.h}});Object.defineProperty(exports,"clearAnnouncements",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.e}});Object.defineProperty(exports,"createAnnouncer",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.g}});Object.defineProperty(exports,"initAnnouncer",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.a}});Object.defineProperty(exports,"queueAnnouncement",{enumerable:true,get:function(){return chunkAQ6HEUSD_cjs.f}});Object.defineProperty(exports,"createMediaQueryListener",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.k}});Object.defineProperty(exports,"getScreenReaderHints",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.j}});Object.defineProperty(exports,"isAndroid",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.d}});Object.defineProperty(exports,"isBrowser",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.a}});Object.defineProperty(exports,"isIOS",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.c}});Object.defineProperty(exports,"isMac",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.b}});Object.defineProperty(exports,"isTouchDevice",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.f}});Object.defineProperty(exports,"isWindows",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.e}});Object.defineProperty(exports,"prefersDarkMode",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.i}});Object.defineProperty(exports,"prefersHighContrast",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.h}});Object.defineProperty(exports,"prefersReducedMotion",{enumerable:true,get:function(){return chunk7BL2ABLF_cjs.g}});Object.defineProperty(exports,"aria",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.a}});Object.defineProperty(exports,"buildAriaProps",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.b}});Object.defineProperty(exports,"hasAccessibleName",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.d}});Object.defineProperty(exports,"mergeAriaIds",{enumerable:true,get:function(){return chunkKQUAJKTG_cjs.c}});exports.checks=s;exports.clearWarnings=x;exports.createComponentWarnings=y;exports.createIdScope=Ae;exports.generateId=u;exports.generateIds=$e;exports.initCompa11y=We;exports.resetIdCounter=we;exports.setWarningHandler=b;exports.warn=i;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { D as DevWarningHandler, a as DevWarning } from './types-DpTUSAxr.cjs';
2
2
  export { A as AnnouncerOptions, b as AriaLivePoliteness, c as AriaRole, F as FocusTrapOptions, d as FocusableElement, K as KeyboardNavigationOptions } from './types-DpTUSAxr.cjs';
3
- export { FocusScope, FocusScopeOptions, RovingTabindex, RovingTabindexOptions, createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible } from './focus/index.cjs';
3
+ export { FocusNeighborOptions, FocusReturn, FocusReturnOptions, FocusScope, FocusScopeOptions, RovingTabindex, RovingTabindexOptions, createFocusReturn, createFocusScope, createFocusTrap, createRovingTabindex, findFocusNeighbor, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible } from './focus/index.cjs';
4
4
  export { KeyboardHandler, KeyboardHandlers, KeyboardManager, KeyboardManagerOptions, KeyboardPatterns, TypeAhead, createKeyboardManager, createTypeAhead, getKeyCombo, normalizeKey } from './keyboard/index.cjs';
5
5
  export { announce, announceAssertive, announceError, announcePolite, announceProgress, announceStatus, clearAnnouncements, createAnnouncer, initAnnouncer, queueAnnouncement } from './announcer/index.cjs';
6
6
  export { aria, buildAriaProps, hasAccessibleName, mergeAriaIds } from './aria/index.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { D as DevWarningHandler, a as DevWarning } from './types-DpTUSAxr.js';
2
2
  export { A as AnnouncerOptions, b as AriaLivePoliteness, c as AriaRole, F as FocusTrapOptions, d as FocusableElement, K as KeyboardNavigationOptions } from './types-DpTUSAxr.js';
3
- export { FocusScope, FocusScopeOptions, RovingTabindex, RovingTabindexOptions, createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible } from './focus/index.js';
3
+ export { FocusNeighborOptions, FocusReturn, FocusReturnOptions, FocusScope, FocusScopeOptions, RovingTabindex, RovingTabindexOptions, createFocusReturn, createFocusScope, createFocusTrap, createRovingTabindex, findFocusNeighbor, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible } from './focus/index.js';
4
4
  export { KeyboardHandler, KeyboardHandlers, KeyboardManager, KeyboardManagerOptions, KeyboardPatterns, TypeAhead, createKeyboardManager, createTypeAhead, getKeyCombo, normalizeKey } from './keyboard/index.js';
5
5
  export { announce, announceAssertive, announceError, announcePolite, announceProgress, announceStatus, clearAnnouncements, createAnnouncer, initAnnouncer, queueAnnouncement } from './announcer/index.js';
6
6
  export { aria, buildAriaProps, hasAccessibleName, mergeAriaIds } from './aria/index.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export{a as FOCUSABLE_SELECTORS,b as TABBABLE_SELECTORS,j as containsFocus,x as createFocusScope,o as createFocusTrap,y as createRovingTabindex,w as focusWithVisibleRing,p as getActiveFocusTrap,h as getFirstFocusable,f as getFocusableElements,u as getLastFocusSource,i as getLastFocusable,k as getNextFocusable,l as getPreviousFocusable,g as getTabbableElements,q as hasFocusTrap,t as hasVisibleFocus,r as initFocusVisible,s as isFocusVisible,d as isFocusable,e as isTabbable,c as isVisible,m as isWithinContainer,n as resolveElement,v as setFocusVisible}from'./chunk-BAFKUMWA.js';export{d as KeyboardPatterns,c as createKeyboardManager,e as createTypeAhead,b as getKeyCombo,a as normalizeKey}from'./chunk-RE4QIUWR.js';export{b as announce,d as announceAssertive,i as announceError,c as announcePolite,j as announceProgress,h as announceStatus,e as clearAnnouncements,g as createAnnouncer,a as initAnnouncer,f as queueAnnouncement}from'./chunk-ZAQMM5TA.js';export{k as createMediaQueryListener,j as getScreenReaderHints,d as isAndroid,a as isBrowser,c as isIOS,b as isMac,f as isTouchDevice,e as isWindows,i as prefersDarkMode,h as prefersHighContrast,g as prefersReducedMotion}from'./chunk-C3VZQUKG.js';import {d as d$1}from'./chunk-TGXWODB3.js';export{a as aria,b as buildAriaProps,d as hasAccessibleName,c as mergeAriaIds}from'./chunk-TGXWODB3.js';var g=0,d="compa11y";function u(e){let n=++g;return e?`${d}-${e}-${n}`:`${d}-${n}`}function he(e,n){let r=u(n),t={};for(let o of e)t[o]=`${r}-${o}`;return t}function ke(){g=0;}function $e(e){let n=u(e);return {id:n,generate:r=>`${n}-${r}`,generateMultiple:r=>{let t={};for(let o of r)t[o]=`${n}-${o}`;return t}}}var a=null,l=new Set;function p(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function b(e){a=e;}function f(e){return `${e.component}:${e.message}`}function i(e){if(!p())return;let n=f(e);if(l.has(n))return;if(l.add(n),a){a(e);return}let r=`[compa11y/${e.component}]`,t=m(e.type),o=e.suggestion?`${e.message}
1
+ export{a as FOCUSABLE_SELECTORS,b as TABBABLE_SELECTORS,j as containsFocus,A as createFocusReturn,x as createFocusScope,o as createFocusTrap,y as createRovingTabindex,z as findFocusNeighbor,w as focusWithVisibleRing,p as getActiveFocusTrap,h as getFirstFocusable,f as getFocusableElements,u as getLastFocusSource,i as getLastFocusable,k as getNextFocusable,l as getPreviousFocusable,g as getTabbableElements,q as hasFocusTrap,t as hasVisibleFocus,r as initFocusVisible,s as isFocusVisible,d as isFocusable,e as isTabbable,c as isVisible,m as isWithinContainer,n as resolveElement,v as setFocusVisible}from'./chunk-QGEFH2VG.js';export{d as KeyboardPatterns,c as createKeyboardManager,e as createTypeAhead,b as getKeyCombo,a as normalizeKey}from'./chunk-RE4QIUWR.js';export{b as announce,d as announceAssertive,i as announceError,c as announcePolite,j as announceProgress,h as announceStatus,e as clearAnnouncements,g as createAnnouncer,a as initAnnouncer,f as queueAnnouncement}from'./chunk-ZAQMM5TA.js';export{k as createMediaQueryListener,j as getScreenReaderHints,d as isAndroid,a as isBrowser,c as isIOS,b as isMac,f as isTouchDevice,e as isWindows,i as prefersDarkMode,h as prefersHighContrast,g as prefersReducedMotion}from'./chunk-C3VZQUKG.js';import {d as d$1}from'./chunk-TGXWODB3.js';export{a as aria,b as buildAriaProps,d as hasAccessibleName,c as mergeAriaIds}from'./chunk-TGXWODB3.js';var g=0,d="compa11y";function u(e){let n=++g;return e?`${d}-${e}-${n}`:`${d}-${n}`}function $e(e,n){let r=u(n),t={};for(let o of e)t[o]=`${r}-${o}`;return t}function we(){g=0;}function Ae(e){let n=u(e);return {id:n,generate:r=>`${n}-${r}`,generateMultiple:r=>{let t={};for(let o of r)t[o]=`${n}-${o}`;return t}}}var a=null,l=new Set;function p(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function b(e){a=e;}function f(e){return `${e.component}:${e.message}`}function i(e){if(!p())return;let n=f(e);if(l.has(n))return;if(l.add(n),a){a(e);return}let r=`[compa11y/${e.component}]`,t=m(e.type),o=e.suggestion?`${e.message}
2
2
 
3
- \u{1F4A1} Suggestion: ${e.suggestion}`:e.message;switch(e.type){case "error":console.error(`%c${r}%c ${o}`,t,"");break;case "warning":console.warn(`%c${r}%c ${o}`,t,"");break;case "info":console.info(`%c${r}%c ${o}`,t,"");break}e.element&&console.log("Element:",e.element);}function m(e){switch(e){case "error":return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "warning":return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "info":return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;"}}function x(){l.clear();}var s={accessibleLabel(e,n,r="aria-label"){e&&(d$1(e)||i({type:"error",component:n,message:"Missing accessible label. Screen reader users will not be able to understand this element.",suggestion:`Add ${r}, aria-labelledby, or visible text content.`,element:e}));},requiredProp(e,n,r){(e==null||e==="")&&i({type:"error",component:r,message:`Missing required prop "${n}".`,suggestion:`Provide a value for the "${n}" prop.`});},validRole(e,n,r){if(!e)return;new Set(["alert","alertdialog","application","article","banner","button","cell","columnheader","combobox","complementary","contentinfo","definition","dialog","directory","document","feed","figure","form","grid","gridcell","group","heading","img","link","list","listbox","listitem","log","main","marquee","math","menu","menubar","menuitem","navigation","none","note","option","presentation","progressbar","region","row","rowgroup","rowheader","scrollbar","search","searchbox","separator","slider","spinbutton","status","switch","tab","table","tablist","tabpanel","term","textbox","timer","toolbar","tooltip","tree","treegrid","treeitem"]).has(e)||i({type:"warning",component:n,message:`Invalid ARIA role "${e}".`,suggestion:"Use a valid ARIA role from the WAI-ARIA specification.",element:r});},keyboardAccessible(e,n,r){if(e&&r.onClick&&!r.onKeyDown){let t=e.tagName.toLowerCase(),o=e.getAttribute("role");if(["button","a","input","select","textarea"].includes(t))return;o&&["button","link","menuitem","option","tab"].includes(o)&&i({type:"warning",component:n,message:"Element has onClick but no onKeyDown handler.",suggestion:"Add keyboard event handling for Enter and Space keys.",element:e});}},tabIndex(e,n,r){e!==void 0&&e>0&&i({type:"warning",component:n,message:`Positive tabIndex (${e}) disrupts natural tab order.`,suggestion:"Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",element:r});},dialogAutoFocus(e,n){e||i({type:"info",component:n,message:"No initial focus element specified for dialog.",suggestion:"Consider setting initialFocus to guide keyboard users."});},formLabel(e,n,r){if(!e)return;n||e.getAttribute("aria-label")||e.getAttribute("aria-labelledby")||e.labels?.length||i({type:"error",component:r,message:"Form input is missing an accessible label.",suggestion:"Add a <label>, aria-label, or aria-labelledby.",element:e});},imageAlt(e,n){if(!e||e.tagName!=="IMG")return;let r=e.getAttribute("alt"),t=e.getAttribute("role");r===null&&t!=="presentation"&&t!=="none"&&i({type:"error",component:n,message:"Image is missing alt attribute.",suggestion:'Add alt="" for decorative images or descriptive alt text for meaningful images.',element:e});}};function y(e){return {error:(n,r,t)=>i({type:"error",component:e,message:n,suggestion:r,element:t}),warning:(n,r,t)=>i({type:"warning",component:e,message:n,suggestion:r,element:t}),info:(n,r,t)=>i({type:"info",component:e,message:n,suggestion:r,element:t}),checks:{accessibleLabel:(n,r)=>s.accessibleLabel(n,e,r),requiredProp:(n,r)=>s.requiredProp(n,r,e),keyboardAccessible:(n,r)=>s.keyboardAccessible(n,e,r),tabIndex:(n,r)=>s.tabIndex(n,e,r)}}}function Ee(){let e=[];return import('./focus/index.js').then(({initFocusVisible:n})=>{e.push(n());}),import('./announcer/index.js').then(({initAnnouncer:n})=>{e.push(n());}),()=>{e.forEach(n=>n());}}export{s as checks,x as clearWarnings,y as createComponentWarnings,$e as createIdScope,u as generateId,he as generateIds,Ee as initCompa11y,ke as resetIdCounter,b as setWarningHandler,i as warn};
3
+ \u{1F4A1} Suggestion: ${e.suggestion}`:e.message;switch(e.type){case "error":console.error(`%c${r}%c ${o}`,t,"");break;case "warning":console.warn(`%c${r}%c ${o}`,t,"");break;case "info":console.info(`%c${r}%c ${o}`,t,"");break}e.element&&console.log("Element:",e.element);}function m(e){switch(e){case "error":return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "warning":return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "info":return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;"}}function x(){l.clear();}var s={accessibleLabel(e,n,r="aria-label"){e&&(d$1(e)||i({type:"error",component:n,message:"Missing accessible label. Screen reader users will not be able to understand this element.",suggestion:`Add ${r}, aria-labelledby, or visible text content.`,element:e}));},requiredProp(e,n,r){(e==null||e==="")&&i({type:"error",component:r,message:`Missing required prop "${n}".`,suggestion:`Provide a value for the "${n}" prop.`});},validRole(e,n,r){if(!e)return;new Set(["alert","alertdialog","application","article","banner","button","cell","columnheader","combobox","complementary","contentinfo","definition","dialog","directory","document","feed","figure","form","grid","gridcell","group","heading","img","link","list","listbox","listitem","log","main","marquee","math","menu","menubar","menuitem","navigation","none","note","option","presentation","progressbar","region","row","rowgroup","rowheader","scrollbar","search","searchbox","separator","slider","spinbutton","status","switch","tab","table","tablist","tabpanel","term","textbox","timer","toolbar","tooltip","tree","treegrid","treeitem"]).has(e)||i({type:"warning",component:n,message:`Invalid ARIA role "${e}".`,suggestion:"Use a valid ARIA role from the WAI-ARIA specification.",element:r});},keyboardAccessible(e,n,r){if(e&&r.onClick&&!r.onKeyDown){let t=e.tagName.toLowerCase(),o=e.getAttribute("role");if(["button","a","input","select","textarea"].includes(t))return;o&&["button","link","menuitem","option","tab"].includes(o)&&i({type:"warning",component:n,message:"Element has onClick but no onKeyDown handler.",suggestion:"Add keyboard event handling for Enter and Space keys.",element:e});}},tabIndex(e,n,r){e!==void 0&&e>0&&i({type:"warning",component:n,message:`Positive tabIndex (${e}) disrupts natural tab order.`,suggestion:"Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",element:r});},dialogAutoFocus(e,n){e||i({type:"info",component:n,message:"No initial focus element specified for dialog.",suggestion:"Consider setting initialFocus to guide keyboard users."});},formLabel(e,n,r){if(!e)return;n||e.getAttribute("aria-label")||e.getAttribute("aria-labelledby")||e.labels?.length||i({type:"error",component:r,message:"Form input is missing an accessible label.",suggestion:"Add a <label>, aria-label, or aria-labelledby.",element:e});},imageAlt(e,n){if(!e||e.tagName!=="IMG")return;let r=e.getAttribute("alt"),t=e.getAttribute("role");r===null&&t!=="presentation"&&t!=="none"&&i({type:"error",component:n,message:"Image is missing alt attribute.",suggestion:'Add alt="" for decorative images or descriptive alt text for meaningful images.',element:e});}};function y(e){return {error:(n,r,t)=>i({type:"error",component:e,message:n,suggestion:r,element:t}),warning:(n,r,t)=>i({type:"warning",component:e,message:n,suggestion:r,element:t}),info:(n,r,t)=>i({type:"info",component:e,message:n,suggestion:r,element:t}),checks:{accessibleLabel:(n,r)=>s.accessibleLabel(n,e,r),requiredProp:(n,r)=>s.requiredProp(n,r,e),keyboardAccessible:(n,r)=>s.keyboardAccessible(n,e,r),tabIndex:(n,r)=>s.tabIndex(n,e,r)}}}function We(){let e=[];return import('./focus/index.js').then(({initFocusVisible:n})=>{e.push(n());}),import('./announcer/index.js').then(({initAnnouncer:n})=>{e.push(n());}),()=>{e.forEach(n=>n());}}export{s as checks,x as clearWarnings,y as createComponentWarnings,Ae as createIdScope,u as generateId,$e as generateIds,We as initCompa11y,we as resetIdCounter,b as setWarningHandler,i as warn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compa11y/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "Framework-agnostic accessibility primitives",
5
5
  "author": "Ivan Trajkovski",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  "main": "./dist/index.js",
12
12
  "module": "./dist/index.mjs",
13
13
  "types": "./dist/index.d.ts",
14
- "homepage": "https://github.com/trajkovskiivan/compa11y#readme",
14
+ "homepage": "https://compa11y.org",
15
15
  "bugs": {
16
16
  "url": "https://github.com/trajkovskiivan/compa11y/issues"
17
17
  },
@@ -1 +0,0 @@
1
- import {a}from'./chunk-C3VZQUKG.js';var D=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","iframe"].join(","),V=['a[href]:not([tabindex="-1"])','area[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])','[contenteditable="true"]:not([tabindex="-1"])','audio[controls]:not([tabindex="-1"])','video[controls]:not([tabindex="-1"])','details > summary:first-of-type:not([tabindex="-1"])','iframe:not([tabindex="-1"])'].join(",");function q(e){if(!(e instanceof HTMLElement)||e.hidden||e.style.display==="none"||e.style.visibility==="hidden")return false;let t=window.getComputedStyle(e);return !(t.display==="none"||t.visibility==="hidden"||!e.isConnected)}function O(e){return !(!(e instanceof HTMLElement)||!q(e)||!e.matches(D)||e.closest("[inert]"))}function B(e){return !O(e)||e.tabIndex<0?false:e.matches(V)}function te(e){return Array.from(e.querySelectorAll(D)).filter(O)}function y(e){return Array.from(e.querySelectorAll(V)).filter(B).sort((r,l)=>{let i=Math.max(0,r.tabIndex),s=Math.max(0,l.tabIndex);return i===0&&s===0?0:i===0?1:s===0?-1:i-s})}function A(e){return y(e)[0]??null}function ne(e){let t=y(e);return t[t.length-1]??null}function P(e){let t=document.activeElement;return t!==null&&e.contains(t)}function R(e,t,a=true){let r=y(e),l=r.indexOf(t);if(l===-1)return r[0]??null;let i=l+1;return i<r.length?r[i]:a?r[0]??null:null}function C(e,t,a=true){let r=y(e),l=r.indexOf(t);if(l===-1)return r[r.length-1]??null;let i=l-1;return i>=0?r[i]:a?r[r.length-1]??null:null}function oe(e,t){return t.contains(e)}function N(e,t=document.body){return e?typeof e=="string"?t.querySelector(e):typeof e=="function"?e():e:null}var T=[];function z(e,t={}){let{initialFocus:a,returnFocus:r=true,clickOutsideDeactivates:l=false,escapeDeactivates:i=true,onDeactivate:s,onEscapeFocus:c}=t,o=false,m=false,f=null;function h(u){m||!o||(u.key==="Tab"?L(u):u.key==="Escape"&&i&&(u.preventDefault(),u.stopPropagation(),v()));}function L(u){let E=y(e);if(E.length===0){u.preventDefault();return}let w=E[0],g=E[E.length-1],S=document.activeElement;u.shiftKey?(S===w||!e.contains(S))&&(u.preventDefault(),g.focus()):(S===g||!e.contains(S))&&(u.preventDefault(),w.focus());}function p(u){if(m||!o)return;let E=u.target;e.contains(E)||(c?.(E),A(e)?.focus());}function d(u){if(m||!o)return;let E=u.target;l&&!e.contains(E)&&v();}function b(){if(!o){f=document.activeElement,T.push(k);for(let u=0;u<T.length-1;u++)T[u].pause();document.addEventListener("keydown",h,true),document.addEventListener("focusin",p,true),document.addEventListener("click",d,true),o=true,requestAnimationFrame(()=>{if(!o)return;let u=N(a,e);if(u)u.focus();else {let E=A(e);E?E.focus():(e.setAttribute("tabindex","-1"),e.focus());}});}}function n(u){if(!o)return;document.removeEventListener("keydown",h,true),document.removeEventListener("focusin",p,true),document.removeEventListener("click",d,true),o=false,m=false;let E=T.indexOf(k);if(E>-1&&T.splice(E,1),T[T.length-1]?.unpause(),r&&f){let g=typeof r=="boolean"?f:r;requestAnimationFrame(()=>{g&&"focus"in g&&g.focus();});}u&&s?.();}function v(){n(true);}function F(){n(false);}function M(){!o||m||(m=true);}function H(){!o||!m||(m=false,P(e)||A(e)?.focus());}let k={activate:b,deactivate:v,destroy:F,pause:M,unpause:H,isActive:()=>o,isPaused:()=>m};return k}function U(){return T[T.length-1]??null}function W(){return T.length>0}var x={hadKeyboardEvent:true,isPointerInput:false,lastFocusSource:"unknown"},I=false,_=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown","Escape"]);function j(){if(!a()||I)return ()=>{};I=true;function e(i){_.has(i.key)&&(x.hadKeyboardEvent=true,x.isPointerInput=false,x.lastFocusSource="keyboard");}function t(i){x.isPointerInput=true,x.hadKeyboardEvent=false,x.lastFocusSource="pointerType"in i&&i.pointerType==="touch"?"touch":"mouse";}function a$1(i){let s=i.target;s instanceof HTMLElement&&(x.hadKeyboardEvent||G(s))&&(s.dataset.a11ykitFocusVisible="true");}function r(i){let s=i.target;s instanceof HTMLElement&&delete s.dataset.a11ykitFocusVisible;}function l(){document.visibilityState==="hidden"&&(x.hadKeyboardEvent=true);}return document.addEventListener("keydown",e,true),document.addEventListener("mousedown",t,true),document.addEventListener("pointerdown",t,true),document.addEventListener("focus",a$1,true),document.addEventListener("blur",r,true),document.addEventListener("visibilitychange",l,true),()=>{document.removeEventListener("keydown",e,true),document.removeEventListener("mousedown",t,true),document.removeEventListener("pointerdown",t,true),document.removeEventListener("focus",a$1,true),document.removeEventListener("blur",r,true),document.removeEventListener("visibilitychange",l,true),I=false;}}function G(e){let t=e.tagName.toLowerCase(),a=e.getAttribute("type")?.toLowerCase();return !!(t==="input"&&(!a||a==="text"||a==="email"||a==="password"||a==="search"||a==="tel"||a==="url"||a==="number")||t==="textarea"||e.isContentEditable)}function Y(){return x.hadKeyboardEvent}function J(e){return e.dataset.a11ykitFocusVisible==="true"}function Q(){return x.lastFocusSource}function X(e,t){t?e.dataset.a11ykitFocusVisible="true":delete e.dataset.a11ykitFocusVisible;}function Z(e,t){x.hadKeyboardEvent=true,x.lastFocusSource="keyboard",e.focus(t);}function $(e,t={}){let{contain:a=false,restoreFocus:r=false,autoFocus:l=false}=t,i=null,s=false;r&&(i=document.activeElement);function c(){return s?[]:y(e)}function o(){let n=document.activeElement;return n&&e.contains(n)?n:null}function m(){if(s)return;c()[0]?.focus();}function f(){if(s)return;let n=c();n[n.length-1]?.focus();}function h({wrap:n=true}={}){if(s)return;let v=o();if(!v){m();return}R(e,v,n)?.focus();}function L({wrap:n=true}={}){if(s)return;let v=o();if(!v){f();return}C(e,v,n)?.focus();}function p(n){if(s)return;c()[n]?.focus();}function d(n){if(!(s||!a)&&n.key==="Tab"){let v=c();if(v.length===0){n.preventDefault();return}let F=v[0],M=v[v.length-1],H=o();n.shiftKey&&H===F?(n.preventDefault(),M.focus()):!n.shiftKey&&H===M&&(n.preventDefault(),F.focus());}}function b(){s||(s=true,document.removeEventListener("keydown",d,true),r&&i&&i.focus());}return a&&document.addEventListener("keydown",d,true),l&&requestAnimationFrame(()=>{s||m();}),{focusFirst:m,focusLast:f,focusNext:h,focusPrevious:L,focusAt:p,getFocused:o,getElements:c,destroy:b}}function ee(e,t,a={}){let{initialIndex:r=0,orientation:l="both",wrap:i=true,onSelectionChange:s}=a,c=[],o=r;function m(){c=Array.from(e.querySelectorAll(t)),c.forEach((p,d)=>{p.setAttribute("tabindex",d===o?"0":"-1");});}function f(p){if(c.length===0)return;let d=p;d<0?d=i?c.length-1:0:d>=c.length&&(d=i?0:c.length-1);let b=c[o],n=c[d];b&&b.setAttribute("tabindex","-1"),n&&(n.setAttribute("tabindex","0"),n.focus(),s?.(d,n)),o=d;}function h(p){let d=p.target;if(!c.includes(d))return;let b=false;switch(p.key){case "ArrowRight":(l==="horizontal"||l==="both")&&(f(o+1),b=true);break;case "ArrowLeft":(l==="horizontal"||l==="both")&&(f(o-1),b=true);break;case "ArrowDown":(l==="vertical"||l==="both")&&(f(o+1),b=true);break;case "ArrowUp":(l==="vertical"||l==="both")&&(f(o-1),b=true);break;case "Home":f(0),b=true;break;case "End":f(c.length-1),b=true;break}b&&(p.preventDefault(),p.stopPropagation());}function L(p){let d=p.target,b=c.indexOf(d);if(b!==-1&&b!==o){let n=c[o];n&&n.setAttribute("tabindex","-1"),d.setAttribute("tabindex","0"),o=b;}}return m(),e.addEventListener("keydown",h),e.addEventListener("focusin",L),{next:()=>f(o+1),previous:()=>f(o-1),first:()=>f(0),last:()=>f(c.length-1),goto:f,getIndex:()=>o,update:m,destroy:()=>{e.removeEventListener("keydown",h),e.removeEventListener("focusin",L);}}}export{D as a,V as b,q as c,O as d,B as e,te as f,y as g,A as h,ne as i,P as j,R as k,C as l,oe as m,N as n,z as o,U as p,W as q,j as r,Y as s,J as t,Q as u,X as v,Z as w,$ as x,ee as y};
@@ -1 +0,0 @@
1
- 'use strict';var chunk7BL2ABLF_cjs=require('./chunk-7BL2ABLF.cjs');var D=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","iframe"].join(","),V=['a[href]:not([tabindex="-1"])','area[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])','[contenteditable="true"]:not([tabindex="-1"])','audio[controls]:not([tabindex="-1"])','video[controls]:not([tabindex="-1"])','details > summary:first-of-type:not([tabindex="-1"])','iframe:not([tabindex="-1"])'].join(",");function q(e){if(!(e instanceof HTMLElement)||e.hidden||e.style.display==="none"||e.style.visibility==="hidden")return false;let t=window.getComputedStyle(e);return !(t.display==="none"||t.visibility==="hidden"||!e.isConnected)}function O(e){return !(!(e instanceof HTMLElement)||!q(e)||!e.matches(D)||e.closest("[inert]"))}function B(e){return !O(e)||e.tabIndex<0?false:e.matches(V)}function te(e){return Array.from(e.querySelectorAll(D)).filter(O)}function y(e){return Array.from(e.querySelectorAll(V)).filter(B).sort((r,l)=>{let i=Math.max(0,r.tabIndex),s=Math.max(0,l.tabIndex);return i===0&&s===0?0:i===0?1:s===0?-1:i-s})}function A(e){return y(e)[0]??null}function ne(e){let t=y(e);return t[t.length-1]??null}function P(e){let t=document.activeElement;return t!==null&&e.contains(t)}function R(e,t,a=true){let r=y(e),l=r.indexOf(t);if(l===-1)return r[0]??null;let i=l+1;return i<r.length?r[i]:a?r[0]??null:null}function C(e,t,a=true){let r=y(e),l=r.indexOf(t);if(l===-1)return r[r.length-1]??null;let i=l-1;return i>=0?r[i]:a?r[r.length-1]??null:null}function oe(e,t){return t.contains(e)}function N(e,t=document.body){return e?typeof e=="string"?t.querySelector(e):typeof e=="function"?e():e:null}var T=[];function z(e,t={}){let{initialFocus:a,returnFocus:r=true,clickOutsideDeactivates:l=false,escapeDeactivates:i=true,onDeactivate:s,onEscapeFocus:c}=t,o=false,m=false,f=null;function h(u){m||!o||(u.key==="Tab"?L(u):u.key==="Escape"&&i&&(u.preventDefault(),u.stopPropagation(),v()));}function L(u){let E=y(e);if(E.length===0){u.preventDefault();return}let w=E[0],g=E[E.length-1],S=document.activeElement;u.shiftKey?(S===w||!e.contains(S))&&(u.preventDefault(),g.focus()):(S===g||!e.contains(S))&&(u.preventDefault(),w.focus());}function p(u){if(m||!o)return;let E=u.target;e.contains(E)||(c?.(E),A(e)?.focus());}function d(u){if(m||!o)return;let E=u.target;l&&!e.contains(E)&&v();}function b(){if(!o){f=document.activeElement,T.push(k);for(let u=0;u<T.length-1;u++)T[u].pause();document.addEventListener("keydown",h,true),document.addEventListener("focusin",p,true),document.addEventListener("click",d,true),o=true,requestAnimationFrame(()=>{if(!o)return;let u=N(a,e);if(u)u.focus();else {let E=A(e);E?E.focus():(e.setAttribute("tabindex","-1"),e.focus());}});}}function n(u){if(!o)return;document.removeEventListener("keydown",h,true),document.removeEventListener("focusin",p,true),document.removeEventListener("click",d,true),o=false,m=false;let E=T.indexOf(k);if(E>-1&&T.splice(E,1),T[T.length-1]?.unpause(),r&&f){let g=typeof r=="boolean"?f:r;requestAnimationFrame(()=>{g&&"focus"in g&&g.focus();});}u&&s?.();}function v(){n(true);}function F(){n(false);}function M(){!o||m||(m=true);}function H(){!o||!m||(m=false,P(e)||A(e)?.focus());}let k={activate:b,deactivate:v,destroy:F,pause:M,unpause:H,isActive:()=>o,isPaused:()=>m};return k}function U(){return T[T.length-1]??null}function W(){return T.length>0}var x={hadKeyboardEvent:true,isPointerInput:false,lastFocusSource:"unknown"},I=false,_=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown","Escape"]);function j(){if(!chunk7BL2ABLF_cjs.a()||I)return ()=>{};I=true;function e(i){_.has(i.key)&&(x.hadKeyboardEvent=true,x.isPointerInput=false,x.lastFocusSource="keyboard");}function t(i){x.isPointerInput=true,x.hadKeyboardEvent=false,x.lastFocusSource="pointerType"in i&&i.pointerType==="touch"?"touch":"mouse";}function a(i){let s=i.target;s instanceof HTMLElement&&(x.hadKeyboardEvent||G(s))&&(s.dataset.a11ykitFocusVisible="true");}function r(i){let s=i.target;s instanceof HTMLElement&&delete s.dataset.a11ykitFocusVisible;}function l(){document.visibilityState==="hidden"&&(x.hadKeyboardEvent=true);}return document.addEventListener("keydown",e,true),document.addEventListener("mousedown",t,true),document.addEventListener("pointerdown",t,true),document.addEventListener("focus",a,true),document.addEventListener("blur",r,true),document.addEventListener("visibilitychange",l,true),()=>{document.removeEventListener("keydown",e,true),document.removeEventListener("mousedown",t,true),document.removeEventListener("pointerdown",t,true),document.removeEventListener("focus",a,true),document.removeEventListener("blur",r,true),document.removeEventListener("visibilitychange",l,true),I=false;}}function G(e){let t=e.tagName.toLowerCase(),a=e.getAttribute("type")?.toLowerCase();return !!(t==="input"&&(!a||a==="text"||a==="email"||a==="password"||a==="search"||a==="tel"||a==="url"||a==="number")||t==="textarea"||e.isContentEditable)}function Y(){return x.hadKeyboardEvent}function J(e){return e.dataset.a11ykitFocusVisible==="true"}function Q(){return x.lastFocusSource}function X(e,t){t?e.dataset.a11ykitFocusVisible="true":delete e.dataset.a11ykitFocusVisible;}function Z(e,t){x.hadKeyboardEvent=true,x.lastFocusSource="keyboard",e.focus(t);}function $(e,t={}){let{contain:a=false,restoreFocus:r=false,autoFocus:l=false}=t,i=null,s=false;r&&(i=document.activeElement);function c(){return s?[]:y(e)}function o(){let n=document.activeElement;return n&&e.contains(n)?n:null}function m(){if(s)return;c()[0]?.focus();}function f(){if(s)return;let n=c();n[n.length-1]?.focus();}function h({wrap:n=true}={}){if(s)return;let v=o();if(!v){m();return}R(e,v,n)?.focus();}function L({wrap:n=true}={}){if(s)return;let v=o();if(!v){f();return}C(e,v,n)?.focus();}function p(n){if(s)return;c()[n]?.focus();}function d(n){if(!(s||!a)&&n.key==="Tab"){let v=c();if(v.length===0){n.preventDefault();return}let F=v[0],M=v[v.length-1],H=o();n.shiftKey&&H===F?(n.preventDefault(),M.focus()):!n.shiftKey&&H===M&&(n.preventDefault(),F.focus());}}function b(){s||(s=true,document.removeEventListener("keydown",d,true),r&&i&&i.focus());}return a&&document.addEventListener("keydown",d,true),l&&requestAnimationFrame(()=>{s||m();}),{focusFirst:m,focusLast:f,focusNext:h,focusPrevious:L,focusAt:p,getFocused:o,getElements:c,destroy:b}}function ee(e,t,a={}){let{initialIndex:r=0,orientation:l="both",wrap:i=true,onSelectionChange:s}=a,c=[],o=r;function m(){c=Array.from(e.querySelectorAll(t)),c.forEach((p,d)=>{p.setAttribute("tabindex",d===o?"0":"-1");});}function f(p){if(c.length===0)return;let d=p;d<0?d=i?c.length-1:0:d>=c.length&&(d=i?0:c.length-1);let b=c[o],n=c[d];b&&b.setAttribute("tabindex","-1"),n&&(n.setAttribute("tabindex","0"),n.focus(),s?.(d,n)),o=d;}function h(p){let d=p.target;if(!c.includes(d))return;let b=false;switch(p.key){case "ArrowRight":(l==="horizontal"||l==="both")&&(f(o+1),b=true);break;case "ArrowLeft":(l==="horizontal"||l==="both")&&(f(o-1),b=true);break;case "ArrowDown":(l==="vertical"||l==="both")&&(f(o+1),b=true);break;case "ArrowUp":(l==="vertical"||l==="both")&&(f(o-1),b=true);break;case "Home":f(0),b=true;break;case "End":f(c.length-1),b=true;break}b&&(p.preventDefault(),p.stopPropagation());}function L(p){let d=p.target,b=c.indexOf(d);if(b!==-1&&b!==o){let n=c[o];n&&n.setAttribute("tabindex","-1"),d.setAttribute("tabindex","0"),o=b;}}return m(),e.addEventListener("keydown",h),e.addEventListener("focusin",L),{next:()=>f(o+1),previous:()=>f(o-1),first:()=>f(0),last:()=>f(c.length-1),goto:f,getIndex:()=>o,update:m,destroy:()=>{e.removeEventListener("keydown",h),e.removeEventListener("focusin",L);}}}exports.a=D;exports.b=V;exports.c=q;exports.d=O;exports.e=B;exports.f=te;exports.g=y;exports.h=A;exports.i=ne;exports.j=P;exports.k=R;exports.l=C;exports.m=oe;exports.n=N;exports.o=z;exports.p=U;exports.q=W;exports.r=j;exports.s=Y;exports.t=J;exports.u=Q;exports.v=X;exports.w=Z;exports.x=$;exports.y=ee;