/** * Reason the calendar popover closed. Surfaced via `notifyPickerClose` so consumers (e.g. * server-side validation) can decide whether to act on the close event: * - `"apply"`: user clicked the Apply button. * - `"clear"`: user clicked the Clear button. * - `"cancel"`: user clicked the Cancel button (selection discarded). * - `"outside"`: user clicked/tapped outside the popover or pressed Escape — selection auto-applied. */ export type DateFieldPickerCloseReason = "apply" | "clear" | "cancel" | "outside"; type CalendarView = "month" | "year" | "century" | "decade"; export interface UseDatePickerControllerInput { /** Currently committed date held by the input (the source of truth shown in the field). */ selectedDate: Date | undefined; /** Lower bound for the calendar (already parsed). */ minDate: Date | undefined; /** Upper bound for the calendar (already parsed). */ maxDate: Date | undefined; /** Called when the user commits a new canonical (ISO `YYYY-MM-DD` or empty) value. */ commitValue: (canonicalValue: string) => void; /** Called whenever the popover closes, with the canonical value at close time and the reason. */ notifyPickerClose: (canonicalValue: string, reason: DateFieldPickerCloseReason) => void; } export interface DatePickerController { /** Currently staged date inside the open popover (not yet committed to the input). */ pendingDate: Date | null; /** Disables individual day tiles based on the current `[min, max]` range. */ tileDisabled: (info: { date: Date; view: CalendarView; }) => boolean; /** Stages a new date as the user navigates the calendar. */ onCalendarChange: (next: Date | null) => void; /** Clears the field and notifies picker-close with reason `"clear"`. */ onClear: () => void; /** Discards the staged date and notifies picker-close with reason `"cancel"`. */ onCancel: () => void; /** Commits the staged date (clamped to bounds) and notifies picker-close with reason `"apply"`. */ onApply: () => void; /** * Stages and commits the given date in one step (clamped to bounds), and notifies * picker-close with reason `"apply"`. Used for keyboard-driven selection (Enter on a * day tile) where the staged value must be applied without an extra Apply click. */ applyDate: (next: Date | null) => void; /** * Reacts to the popover open/close lifecycle. On open: stages the currently selected date. * On close: auto-applies the staged date (only commits if it differs from current) and * notifies picker-close with reason `"outside"`. */ onPopoverOpenStateChange: (open: boolean) => void; } /** * Picker state machine for `DateBaseInput`. Owns the staged date, the popover's * "was-open" tracking, the tile-disabled predicate, and all four user-driven action handlers * plus the auto-apply behaviour for outside dismissals. */ export declare const useDatePickerController: ({ selectedDate, minDate, maxDate, commitValue, notifyPickerClose, }: UseDatePickerControllerInput) => DatePickerController; export {};