import React from "react"; import { DateInputProps } from "../../Date.Input"; import { MonthPickerProps } from "../MonthPicker.types"; export interface UseMonthPickerOptions extends Pick { /** * Make Date-selection required */ required?: boolean; /** * Callback for month-change */ onMonthChange?: (date?: Date) => void; /** * Input-format * @default "MMMM yyyy" */ inputFormat?: string; /** * validation-callback */ onValidate?: (val: MonthValidationT) => void; /** * Default shown year */ defaultYear?: Date; /** * Allows input of with `yy` year format. * * Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th. * In 2024 this equals to 1944 - 2043 * @default true */ allowTwoDigitYear?: boolean; } interface UseMonthPickerValue { /** * Use: */ monthpickerProps: MonthPickerProps; /** * Use: */ inputProps: Pick & { /** * @private */ setAnchorRef: React.Dispatch>; }; /** * Currently selected Date * Up to user to validate value and extract month */ selectedMonth?: Date; /** * Manually set selected month if needed */ setSelected: (date?: Date) => void; /** * Resets all states */ reset: () => void; } export type MonthValidationT = { /** * 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`. */ isValidMonth: boolean; /** Whether the month is a disabled month */ isDisabled: boolean; /** Whether the input field is empty */ isEmpty: boolean; /** Whether the entered value cannot be parsed as a month (i.e. wrong format) */ isInvalid: boolean; /** Whether the month is before `fromDate` */ isBefore: boolean; /** Whether the month is after `toDate` */ isAfter: boolean; }; /** * * @see 🏷️ {@link UseMonthPickerOptions} * @see 🏷️ {@link UseMonthPickerValue} * @see 🏷️ {@link MonthValidationT} * @example * const { monthpickerProps, inputProps } = useMonthpicker({ * fromDate: new Date("Aug 23 2019"), * toDate: new Date("Feb 23 2024"), * onMonthChange: console.log, * onValidate: console.log, * }); */ export declare const useMonthpicker: (opt?: UseMonthPickerOptions) => UseMonthPickerValue; export {};