Files
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

40 lines
2.1 KiB
TypeScript

import { SlideDirection } from './PickersSlideTransition';
import { MuiPickersAdapter } from '../internals/models';
import type { CalendarPickerDefaultizedProps } from './CalendarPicker';
interface CalendarState<TDate> {
currentMonth: TDate;
focusedDay: TDate | null;
isMonthSwitchingAnimating: boolean;
slideDirection: SlideDirection;
}
declare type ReducerAction<TType, TAdditional = {}> = {
type: TType;
} & TAdditional;
interface ChangeMonthPayload<TDate> {
direction: SlideDirection;
newMonth: TDate;
}
interface ChangeFocusedDayPayload<TDate> {
focusedDay: TDate | null;
/**
* The update does not trigger month switching animation.
* For example: when selecting month from the month view.
*/
withoutMonthSwitchingAnimation?: boolean;
}
export declare const createCalendarStateReducer: <TDate extends unknown>(reduceAnimations: boolean, disableSwitchToMonthOnDayFocus: boolean, utils: MuiPickersAdapter<TDate>) => (state: CalendarState<TDate>, action: {
type: "finishMonthSwitchingAnimation";
} | ReducerAction<"changeMonth", ChangeMonthPayload<TDate>> | ReducerAction<"changeFocusedDay", ChangeFocusedDayPayload<TDate>>) => CalendarState<TDate>;
interface CalendarStateInput<TDate> extends Pick<CalendarPickerDefaultizedProps<TDate>, 'date' | 'defaultCalendarMonth' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'reduceAnimations' | 'shouldDisableDate'> {
disableSwitchToMonthOnDayFocus?: boolean;
}
export declare const useCalendarState: <TDate extends unknown>({ date, defaultCalendarMonth, disableFuture, disablePast, disableSwitchToMonthOnDayFocus, maxDate, minDate, onMonthChange, reduceAnimations, shouldDisableDate, }: CalendarStateInput<TDate>) => {
calendarState: CalendarState<TDate>;
changeMonth: (newDate: TDate) => void;
changeFocusedDay: (newFocusedDate: TDate | null, withoutMonthSwitchingAnimation?: boolean) => void;
isDateDisabled: (day: TDate | null) => boolean;
onMonthSwitchingAnimationEnd: () => void;
handleChangeMonth: (payload: ChangeMonthPayload<TDate>) => void;
};
export {};