/** * focus-trap - keep Tab / Shift+Tab focus inside a container while it is active, * move focus in on activate, and restore it on release. Shared by SvModal, * SvDrawer, SvMenu and any dialog-like overlay so the WAI-ARIA dialog focus * behaviour lives in ONE place instead of being re-hand-rolled per component. * * Framework-free (DOM only): call `createFocusTrap(el).activate()` from a * component `$effect` and `release()` from its cleanup. * * ```ts * $effect(() => { * if (!open || !panel) return * const trap = createFocusTrap(panel) * trap.activate() * return () => trap.release() * }) * ``` */ /** Selector for elements that can, in principle, hold keyboard focus. */ export declare const FOCUSABLE_SELECTOR: string; /** Visible, Tab-focusable descendants of `container`, in DOM order. Elements * with `tabindex="-1"` are excluded (script-focusable, not Tab-reachable). */ export declare function getFocusable(container: HTMLElement): HTMLElement[]; export type FocusTrapOptions = { /** Where focus goes on activate: the first focusable (default), the container * itself, a specific element, or a getter resolved at activate time. */ initialFocus?: 'first' | 'container' | HTMLElement | (() => HTMLElement | null); /** Restore focus to the previously-focused element on release. Default true. */ returnFocus?: boolean; /** Called on Escape while active. Dismissal is usually owned by the layer * manager, so most consumers leave this unset. */ onEscape?: (e: KeyboardEvent) => void; }; export type FocusTrap = { activate: () => void; release: () => void; }; /** Create a focus trap for `container`. Inert until `activate()`. */ export declare function createFocusTrap(container: HTMLElement, options?: FocusTrapOptions): FocusTrap;