import type { DateFrameworkType, Timezone } from "@salt-ds/date-adapters"; import { type SyntheticEvent } from "react"; import type { DateRangeSelection, SingleDateSelection } from "../calendar"; import type { DateInputRangeDetails, DateInputSingleDetails } from "../date-input"; import type { RangeDatePickerState, SingleDatePickerState } from "./DatePickerContext"; interface UseDatePickerBaseProps { /** If `true`, the component is disabled. */ disabled?: boolean; /** * Function to determine if a day is highlighted. * @param date - The date to check. * @returns A string reason if the day is highlighted, otherwise `false` or `undefined`. */ isDayHighlighted?: (date: TDate) => string | false | undefined; /** * Function to determine if a day is unselectable. * @param date - The date to check. * @returns A string reason if the day is unselectable, otherwise `false` or `undefined`. */ isDayUnselectable?: (date: TDate) => string | false | undefined; /** If `true`, the component is read-only. */ readOnly?: boolean; /** * The minimum date for the range, default is 1900. */ minDate?: TDate; /** * The maximum date for the range, default is 2100. */ maxDate?: TDate; /** * Handler for when the date selection is cancelled. */ onCancel?: () => void; /** * Timezone, if un-defined will take the timezone from passed date (or defaultSelectedDate/selectedDate) * Can also be set to "default" to use the default timezone of the date library * Can also be set to "system" to take the timezone of the local system. */ timezone?: Timezone; } /** * Props for single date selection. * @template TDate - The type of the date object. */ export interface UseDatePickerSingleProps extends UseDatePickerBaseProps { /** * Single date selection. */ selectionVariant: "single"; /** * The selected date. The selected date will be controlled when this prop is provided. */ selectedDate?: SingleDateSelection | null; /** * The initial selected date, when the selected date is uncontrolled. */ defaultSelectedDate?: SingleDateSelection | null; /** * Handler called when the selected date changes. * @param event - The synthetic event. * @param date - The selected date or null. * @param details - The selected date details. */ onSelectionChange?: (event: SyntheticEvent, date: SingleDateSelection | null, details?: DateInputSingleDetails) => void; /** * Handler called when the selected date is confirmed/applied. * @param event - The synthetic event. * @param date - The selected date or null. */ onApply?: (event: SyntheticEvent, date: SingleDateSelection | null) => void; } /** * Props for date range selection. * @template TDate - The type of the date object. */ export interface UseDatePickerRangeProps extends UseDatePickerBaseProps { /** * Date range selection. */ selectionVariant: "range"; /** * The selected date range. The selected date will be controlled when this prop is provided. */ selectedDate?: DateRangeSelection | null; /** * The initial selected date range, when the selected date is uncontrolled. */ defaultSelectedDate?: DateRangeSelection | null; /** * Handler called when the selected date range changes. * @param event - The synthetic event. * @param date - The selected date range or null. * @param details - The selected date range details. */ onSelectionChange?: (event: SyntheticEvent, date: DateRangeSelection | null, details?: DateInputRangeDetails) => void; /** * Handler called when the selected date range is confirmed/applied. * @param event - The synthetic event. * @param date - The selected date range. */ onApply?: (event: SyntheticEvent, date: DateRangeSelection | null) => void; } /** * Props for the useDatePicker hook. * @template TDate - The type of the date object. * @template SelectionVariant - The selection variant, either "single" or "range". */ export type UseDatePickerProps = SelectionVariant extends "single" ? UseDatePickerSingleProps : SelectionVariant extends "range" ? UseDatePickerRangeProps : never; /** * Custom hook for managing date picker state. * @template TDate - The type of the date object. * @template SelectionVariant - The selection variant, either "single" or "range". * @param props - The props for the date picker. * @param ref - The ref for the date picker container. * @returns The date picker state and helpers. */ export declare function useDatePicker(props: UseDatePickerProps, ref: React.ForwardedRef): SingleDatePickerState | RangeDatePickerState; export {};