react-flex-picker
Version:
Helps to build your own calendar by using prepared components and api to control them
112 lines (111 loc) • 3.7 kB
TypeScript
import * as React from 'react';
import * as moment from 'moment';
import { Moment } from 'moment';
import { Month } from './month/Month';
import { Year } from './year/Year';
export declare class PickerProvider extends React.Component<IPickerProps, IPickerState> {
static defaultProps: {
pickerType: string;
unitCount: number;
locale: string;
isSingle: boolean;
};
static getDerivedStateFromProps(props: IPickerProps, state: IPickerState): {
pickerType: "day" | "month";
unitWidth: any;
startDate?: undefined;
endDate?: undefined;
currentMonth?: undefined;
pickerProps?: undefined;
} | {
startDate: moment.Moment;
endDate: moment.Moment;
currentMonth: moment.Moment;
pickerProps: IPickerProps;
unitWidth: any;
pickerType?: undefined;
} | {
endDate: moment.Moment;
pickerProps: IPickerProps;
unitWidth: any;
pickerType?: undefined;
startDate?: undefined;
currentMonth?: undefined;
};
units: Map<string, HTMLDivElement>;
constructor(props: IPickerProps);
componentDidMount(): void;
componentDidUpdate(prevProps: IPickerProps): void;
getUnit(): "month" | "year";
getPickerHeight(currentMonth?: moment.Moment): number;
setUnitSize(): void;
setRef(key: any): (e: any) => Map<string, HTMLDivElement>;
handleUnit(add: any): void;
handlePrevUnit(): void;
handleNextUnit(): void;
handleClick(day: Moment): void;
handleHover(hoveredDate?: Moment): void;
render(): JSX.Element;
}
export declare type Focus = 'startDate' | 'endDate';
export interface IPickerProps {
/** Number of month/years for displaying */
unitCount?: number;
/** Initial start date in range */
initialStartDate?: Moment;
/** Initial end date in range */
initialEndDate?: Moment;
/** Current locale is used by Moment */
locale?: string;
/** Show days from adjoining month for filling a week */
showOutsideDays?: boolean;
/** Minimal valid date */
minDate?: Moment;
/** Maximum valid date */
maxDate?: Moment;
/** Minimal count of days in range */
minDaysCount?: number;
/** Maximum count of days in range */
maxDaysCount?: number;
/** Weeks selection */
isWeeksSelection?: boolean;
/** Type of elements in unit (day for DayPickerController or month for MonthPickerController */
pickerType?: 'day' | 'month';
/** Single picker or range picker */
isSingle?: boolean;
/** When new date is picked up */
onDatesChange?: (startDate: Moment, endDate: Moment) => void;
/** When unit title is clicked */
onTitleClick?: () => void;
/** When picker width was changed sometimes this info can be useful when you build your own calendar */
onChangeWidth?: (width: number) => void;
/**
*
*/
styles?: {
[key: string]: string;
};
}
export interface IPickerState {
pickerType: string;
setRef: (key: string) => (e: Month | Year) => any;
handlePrevUnit: () => void;
handleNextUnit: () => void;
handleTitleClick: (date: Moment) => void;
handleClick: (date: Moment) => void;
handleHover: (date: Moment) => void;
focus: Focus;
startDate?: Moment;
endDate?: Moment;
currentMonth: Moment;
hoveredDate?: Moment | Moment[];
height: number;
unitWidth: number;
translateX: number;
isAnimating: boolean;
unitWrapper: React.RefObject<HTMLDivElement>;
pickerProps: IPickerProps;
}
export declare const PickerConsumer: React.ComponentType<{
children: (value: IPickerState) => React.ReactNode;
}>;