import React from "react"; import { DateInputProps } from "../../Date.Input.js"; import { DatePickerProps } from "../DatePicker.js"; export interface UseDatepickerOptions extends Pick { /** * The initially selected Date */ defaultSelected?: Date; /** * Default shown month */ defaultMonth?: Date; /** * Make selection of Date required */ required?: boolean; /** * Callback for changed state */ onDateChange?: (val?: Date) => void; /** * Input-format * @default "dd.MM.yyyy" */ inputFormat?: string; /** * validation-callback */ onValidate?: (val: DateValidationT) => void; /** * Allows input of with `yy` year format. * * Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th. * e.g. In 2024 this equals to 1944 - 2043. * @default true */ allowTwoDigitYear?: boolean; } interface UseDatepickerValue { /** * Use: */ datepickerProps: DatePickerProps; /** * Use: */ inputProps: Pick & { /** * @private */ setAnchorRef: React.Dispatch>; }; /** * Resets all states (callback) */ reset: () => void; /** * Currently selected date * Up to user to validate date */ selectedDay?: Date; /** * Manually override currently selected day */ setSelected: (date?: Date) => void; } export type DateValidationT = { /** * Whether there are any validation errors. * - When `true`, all the other properties will be `false`. * - When `false`, at least one of the other properties will be `true`. */ isValidDate: boolean; /** Whether the date is a disabled date */ isDisabled: boolean; /** Whether the date falls on a weekend and `disableWeekends` is true */ isWeekend: boolean; /** Whether the input field is empty */ isEmpty: boolean; /** Whether the entered value cannot be parsed as a date (i.e. wrong format or non-existing date) */ isInvalid: boolean; /** Whether the date is before `fromDate` */ isBefore: boolean; /** Whether the date is after `toDate` */ isAfter: boolean; }; /** * * @see 🏷️ {@link UseDatepickerOptions} * @see 🏷️ {@link UseDatepickerValue} * @see 🏷️ {@link DateValidationT} * @example * const { datepickerProps, inputProps } = useDatepicker({ * fromDate: new Date("Aug 23 2019"), * toDate: new Date("Feb 23 2024"), * onDateChange: console.log, * onValidate: console.log, * }); */ export declare const useDatepicker: (opt?: UseDatepickerOptions) => UseDatepickerValue; export {};