/** * The visible month of a travel calendar, which the app keeps. All five * travel calendars take these two props, and useVisibleMonthState returns * them, ready to spread onto one. */ export interface VisibleMonthState { /** * The month the calendar shows. Only its year and month are read, so any * day of the month will do. The calendar never changes it by itself; see * onVisibleMonthChange. * * It is not taken from the value. To open on the month of the value, pass * that month; useVisibleMonthState shows how. */ visibleMonth: Date; /** * Called when the calendar should show another month: from the month * buttons, the month picker, the arrow keys, or a date in another month * that the calendar follows. The single date calendars follow their value, * typed or set from outside. The range calendars only follow a date typed * into one of their fields. * * It gets the first day of that month, and the calendar moves once * visibleMonth is set to it. It is not called for the month already shown. * * When it follows a date, it never asks for a month before the current * one: a date in the past asks for the current month, unless it is in the * month already shown. The month buttons and the arrow keys are not * limited that way. To keep the user out of past months, set * prevMonthDisabled and isDateDisabled, for example with * usePrevMonthDisabledBeforeToday() and useDisabledBeforeToday(). The * month picker starts at firstMonthInMonthPicker, the current month by * default. * * useVisibleMonthState() keeps this state, for when nothing else needs it. */ onVisibleMonthChange: (visibleMonth: Date) => void; } /** * Keeps the visible month of a travel calendar, for when nothing else needs to * know it. * * The travel calendars do not keep their visible month themselves; the app * passes it in as visibleMonth and changes it in onVisibleMonthChange. This is * that state, returned as those two props, so it can be spread onto the * calendar. Keep the state elsewhere instead when something else depends on * the month, such as data loaded for it. * * It starts at the current month, not at the month of a value. Before the * month was controlled, a calendar without initialMonthInFocus opened on the * month of its value. To keep that, start from the value's date, with a * function, the way useState takes one: * * const visibleMonthState = useVisibleMonthState(() => * value ? parseLocalizedDateString(value, localeCode) : undefined, * ); * * The function only runs on the first render, so the value is not parsed * again on every render after it, and the check for a missing value keeps * it type safe for an optional value. parseLocalizedDateString returns * undefined for an incomplete value as well, and undefined falls back to * the current month. * * The value of a range calendar is an object of two strings, so parse its * start date instead: * * const visibleMonthState = useVisibleMonthState(() => * value?.startDate * ? parseLocalizedDateString(value.startDate, localeCode) * : undefined, * ); * * A calendar that had initialMonthInFocus passes that month instead: * useVisibleMonthState(initialMonthInFocus). * * @param initialMonth The month to show first, or a function that returns it, * called once. Defaults to the current month, also when it is or returns * undefined. * * @example * const visibleMonthState = useVisibleMonthState(); * * */ export declare const useVisibleMonthState: (initialMonth?: Date | (() => Date | undefined)) => VisibleMonthState;