import type { DayPickerProps } from "./props.js"; import type { DateRange, Mode, Modifiers } from "./shared.js"; export type Selection = { /** The selected date(s). */ selected: SelectedValue | undefined; /** Set a selection. */ select: SelectHandler | undefined; /** Whether the given date is selected. */ isSelected: (date: Date) => boolean; }; export type SelectedSingle = T["required"] extends true ? Date : Date | undefined; export type SelectedMulti = T["required"] extends true ? Date[] : Date[] | undefined; export type SelectedRange = T["required"] extends true ? DateRange : DateRange | undefined; export type SelectedValue = T extends { mode: "single"; required?: boolean; } ? SelectedSingle : T extends { mode: "multiple"; required?: boolean; } ? SelectedMulti : T extends { mode: "range"; required?: boolean; } ? SelectedRange : undefined; export type SelectHandlerSingle = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined; export type SelectHandlerMulti = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined; export type SelectHandlerRange = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined; export type SelectHandler = T extends { mode: "single"; } ? SelectHandlerSingle : T extends { mode: "multiple"; } ? SelectHandlerMulti : T extends { mode: "range"; } ? SelectHandlerRange : undefined;