import type { Readable } from '@vielzeug/ripple'; export type KeyboardDispatchOptions = { disabled?: Readable; keymap: Record boolean | void>; preventDefault?: 'after' | 'before' | false; }; export declare const dispatchKeyboardAction: (event: KeyboardEvent, options: KeyboardDispatchOptions) => boolean; export type PressTrigger = 'keyboard' | 'pointer'; /** * Options for `createInteraction` — a unified press + focus/blur interaction * handler for accessible interactive elements. */ export type InteractionOptions = { /** `true` when the element is disabled. All handlers become no-ops. */ disabled?: Readable; /** Keys that trigger a press. Defaults to `['Enter', ' ']`. */ keys?: string[]; /** Called when the element loses focus. */ onBlur?: (event: FocusEvent) => void; /** Called when the element receives focus. */ onFocus?: (event: FocusEvent) => void; /** Called when the element is pressed via keyboard or pointer. */ onPress?: (event: KeyboardEvent | MouseEvent, trigger: PressTrigger) => void; }; export type Interaction = { handleBlur: (event: FocusEvent) => void; handleClick: (event: MouseEvent) => boolean; handleFocus: (event: FocusEvent) => void; handleKeydown: (event: KeyboardEvent) => boolean; }; /** * Creates a set of event handlers for an interactive element that responds to * keyboard and pointer presses, and optionally focus/blur events. * * @example * ```ts * const interaction = createInteraction({ * disabled: props.disabled, * onPress: (event, trigger) => toggle(event), * onFocus: (event) => setFocused(true), * onBlur: (event) => setFocused(false), * }); * * // In template: * // @click="${interaction.handleClick}" * // @keydown="${interaction.handleKeydown}" * // @focus="${interaction.handleFocus}" * // @blur="${interaction.handleBlur}" * ``` */ export declare const createInteraction: (options: InteractionOptions) => Interaction; //# sourceMappingURL=keyboard.d.ts.map