UNPKG

4.63 kBTypeScriptView Raw
1import * as React from 'react';
2import { SlideDirection } from './SlideTransition';
3import { Theme } from '@material-ui/core/styles';
4import { MaterialUiPickersDate } from '../../typings/date';
5import { IconButtonProps } from '@material-ui/core/IconButton';
6import { WithStyles } from '@material-ui/core/styles';
7import { WithUtilsProps } from '../../_shared/WithUtils';
8export interface OutterCalendarProps {
9 /** Left arrow icon */
10 leftArrowIcon?: React.ReactNode;
11 /** Right arrow icon */
12 rightArrowIcon?: React.ReactNode;
13 /** Custom renderer for day @DateIOType */
14 renderDay?: (day: MaterialUiPickersDate, selectedDate: MaterialUiPickersDate, dayInCurrentMonth: boolean, dayComponent: JSX.Element) => JSX.Element;
15 /**
16 * Enables keyboard listener for moving between days in calendar
17 * @default true
18 */
19 allowKeyboardControl?: boolean;
20 /**
21 * Props to pass to left arrow button
22 * @type {Partial<IconButtonProps>}
23 */
24 leftArrowButtonProps?: Partial<IconButtonProps>;
25 /**
26 * Props to pass to right arrow button
27 * @type {Partial<IconButtonProps>}
28 */
29 rightArrowButtonProps?: Partial<IconButtonProps>;
30 /** Disable specific date @DateIOType */
31 shouldDisableDate?: (day: MaterialUiPickersDate) => boolean;
32 /** Callback firing on month change. Return promise to render spinner till it will not be resolved @DateIOType */
33 onMonthChange?: (date: MaterialUiPickersDate) => void | Promise<void>;
34 /** Custom loading indicator */
35 loadingIndicator?: JSX.Element;
36}
37export interface CalendarProps extends OutterCalendarProps, WithUtilsProps, WithStyles<typeof styles, true> {
38 /** Calendar Date @DateIOType */
39 date: MaterialUiPickersDate;
40 /** Calendar onChange */
41 onChange: (date: MaterialUiPickersDate, isFinish?: boolean) => void;
42 /** Min date @DateIOType */
43 minDate?: MaterialUiPickersDate;
44 /** Max date @DateIOType */
45 maxDate?: MaterialUiPickersDate;
46 /** Disable past dates */
47 disablePast?: boolean;
48 /** Disable future dates */
49 disableFuture?: boolean;
50}
51export interface CalendarState {
52 slideDirection: SlideDirection;
53 currentMonth: MaterialUiPickersDate;
54 lastDate?: MaterialUiPickersDate;
55 loadingQueue: number;
56}
57export declare class Calendar extends React.Component<CalendarProps, CalendarState> {
58 static contextType: React.Context<"dialog" | "inline" | "static" | null>;
59 static propTypes: any;
60 static defaultProps: Partial<CalendarProps>;
61 static getDerivedStateFromProps(nextProps: CalendarProps, state: CalendarState): {
62 lastDate: MaterialUiPickersDate;
63 currentMonth: MaterialUiPickersDate;
64 slideDirection: SlideDirection;
65 } | null;
66 state: CalendarState;
67 componentDidMount(): void;
68 private pushToLoadingQueue;
69 private popFromLoadingQueue;
70 handleChangeMonth: (newMonth: MaterialUiPickersDate, slideDirection: SlideDirection) => void;
71 validateMinMaxDate: (day: MaterialUiPickersDate) => boolean;
72 shouldDisablePrevMonth: () => boolean;
73 shouldDisableNextMonth: () => boolean;
74 shouldDisableDate: (day: MaterialUiPickersDate) => boolean;
75 handleDaySelect: (day: MaterialUiPickersDate, isFinish?: boolean) => void;
76 moveToDay: (day: MaterialUiPickersDate) => void;
77 handleKeyDown: (event: KeyboardEvent) => void;
78 private renderWeeks;
79 private renderDays;
80 render(): JSX.Element;
81}
82export declare const styles: (theme: Theme) => {
83 transitionContainer: {
84 minHeight: number;
85 marginTop: number;
86 };
87 progressContainer: {
88 width: string;
89 height: string;
90 display: string;
91 justifyContent: string;
92 alignItems: string;
93 };
94 week: {
95 display: string;
96 justifyContent: string;
97 };
98};
99declare const _default: React.ComponentType<Pick<React.PropsWithChildren<Pick<CalendarProps, "classes" | "theme" | "onChange" | "date" | "onMonthChange" | "leftArrowIcon" | "rightArrowIcon" | "leftArrowButtonProps" | "rightArrowButtonProps" | "minDate" | "maxDate" | "disablePast" | "disableFuture" | "renderDay" | "allowKeyboardControl" | "shouldDisableDate" | "loadingIndicator">>, "children" | "onChange" | "date" | "onMonthChange" | "leftArrowIcon" | "rightArrowIcon" | "leftArrowButtonProps" | "rightArrowButtonProps" | "minDate" | "maxDate" | "disablePast" | "disableFuture" | "renderDay" | "allowKeyboardControl" | "shouldDisableDate" | "loadingIndicator"> & import("@material-ui/core/styles").StyledComponentProps<"transitionContainer" | "progressContainer" | "week">>;
100export default _default;