/** * Accessibility Actions * * Svelte actions for keyboard accessibility patterns. * Following WAI-ARIA best practices for interactive elements. */ /** * Options for the keyboardClick action */ export interface KeyboardClickOptions { /** * Callback fired on Enter or Space key press * If not provided, the action will dispatch a click event on the element */ onclick?: () => void; /** * Callback fired on Escape key press (for dismissal) */ onEscape?: () => void; /** * Whether to prevent default behavior on Enter/Space * @default true */ preventDefault?: boolean; /** * Whether to stop propagation on handled keys * @default false */ stopPropagation?: boolean; } /** * Svelte action for keyboard click accessibility. * * Makes elements keyboard-accessible by handling: * - Enter key: triggers click/activation * - Space key: triggers click/activation (with scroll prevention) * - Escape key: triggers dismissal callback * * Usage: * ```svelte *
* Clickable content *
* ``` * * Or with simpler syntax when you just want to fire a click event: * ```svelte *
* Clickable content *
* ``` * * Works with both HTML and SVG elements. */ export declare function keyboardClick(node: HTMLElement | SVGElement, options?: KeyboardClickOptions): { update: (options: KeyboardClickOptions) => void; destroy: () => void; }; /** * Options for the keyboardToggle action */ export interface KeyboardToggleOptions { /** * Current toggle state */ pressed: boolean; /** * Callback fired when toggle state should change */ onToggle: (pressed: boolean) => void; /** * Callback fired on Escape key press (for dismissal) */ onEscape?: () => void; } /** * Svelte action for keyboard toggle accessibility. * * Specialized variant for toggle buttons that need to manage pressed state. * Handles Enter/Space to toggle and Escape to dismiss. * * Usage: * ```svelte *
isActive = v }} * role="button" * tabindex="0" * aria-pressed={isActive} * > * Toggle content *
* ``` * * Works with both HTML and SVG elements. */ export declare function keyboardToggle(node: HTMLElement | SVGElement, options: KeyboardToggleOptions): { update: (options: KeyboardToggleOptions) => void; destroy: () => void; }; /** * Options for the focusTrap action */ export interface FocusTrapOptions { /** * Whether the focus trap is currently active * @default true */ active?: boolean; /** * Element to receive initial focus when trap activates * If not provided, focuses the first focusable element */ initialFocus?: HTMLElement | null; /** * Element to return focus to when trap deactivates * If not provided, returns focus to document.activeElement at mount time */ returnFocusTo?: HTMLElement | null; /** * Callback fired when Escape is pressed */ onEscape?: () => void; } /** * Svelte action for modal focus trapping. * * Traps keyboard focus within a container, cycling through focusable elements. * Essential for modal dialogs to meet WCAG 2.4.3 (Focus Order). * * Features: * - Traps Tab and Shift+Tab within container * - Auto-focuses first focusable element (or specified initialFocus) * - Returns focus to trigger element on deactivation * - Handles Escape key for dismissal * * Usage: * ```svelte *
* * * *
* ``` * * With explicit return focus element: * ```svelte * *
* ... *
* ``` */ export declare function focusTrap(node: HTMLElement, options?: FocusTrapOptions): { update: (options: FocusTrapOptions) => void; destroy: () => void; };