import { KeyboardEvent, RefObject } from 'react'; import { SegmentAdjustment, SegmentType } from './DateField.types'; /** Per-call context passed to each key binding. */ export interface SegmentKeyContext { /** Segment the key event fired on. */ segment: SegmentType; /** The originating keydown event. */ event: KeyboardEvent; /** Whether the field is rendered right-to-left. */ isRTL: boolean; } /** * A key binding: runs the action for one key, given the call context, and * returns whether it handled the key. The dispatcher `preventDefault`s only when * a binding returns `true`, so a binding can decline (return `false`) to leave * the key to the browser's native default (e.g. page scroll). */ export type SegmentKeyBinding = (ctx: SegmentKeyContext) => boolean; export interface UseDateFieldKeyboardArgs { /** When true, the dispatcher ignores all keys. */ disabled: boolean; /** * When true, value-mutation keys (ArrowUp/Down, PageUp/Down, Home, End) are * left unbound so they fall through to the browser (native page scroll); * only the navigation keys (ArrowLeft/Right) are bound. Blocks value mutation * without suppressing scroll. */ readOnly: boolean; /** Field root ref, used to detect RTL direction. */ fieldRef: RefObject; /** Move focus to the next segment in the locale-derived `partsOrder`. */ focusNext: (segment: SegmentType) => void; /** Move focus to the previous segment in the locale-derived `partsOrder`. */ focusPrevious: (segment: SegmentType) => void; /** * Steps a segment, or jumps it to a boundary for Home/End. Returns `false` on * a no-op so the dispatcher leaves the key to native page scroll. */ adjustSegment: (type: SegmentType, amount: SegmentAdjustment) => boolean; /** * Clears the entire segment buffer to `''` — shared by Backspace and Delete. * Returns `{ wasEmpty: true }` when the buffer was already * empty, signalling Backspace to move focus to the previous segment instead; * Delete ignores the result and leaves focus on the current segment. * Provided by `useDateFieldValue`. */ clearSegment: (type: SegmentType) => { wasEmpty: boolean; }; } export declare function useDateFieldKeyboard({ disabled, readOnly, fieldRef, focusNext, focusPrevious, adjustSegment, clearSegment, }: UseDateFieldKeyboardArgs): (segment: SegmentType, event: KeyboardEvent) => void;