UNPKG

1.98 kBTypeScriptView Raw
1import * as React from 'react';
2import type { GenerateConfig } from 'rc-picker/lib/generate';
3import type { CellRenderInfo } from 'rc-picker/lib/interface';
4import type { AnyObject } from '../_util/type';
5import enUS from './locale/en_US';
6export type CalendarMode = 'year' | 'month';
7export type HeaderRender<DateType> = (config: {
8 value: DateType;
9 type: CalendarMode;
10 onChange: (date: DateType) => void;
11 onTypeChange: (type: CalendarMode) => void;
12}) => React.ReactNode;
13export interface SelectInfo {
14 source: 'year' | 'month' | 'date' | 'customize';
15}
16export interface CalendarProps<DateType> {
17 prefixCls?: string;
18 className?: string;
19 rootClassName?: string;
20 style?: React.CSSProperties;
21 locale?: typeof enUS;
22 validRange?: [DateType, DateType];
23 disabledDate?: (date: DateType) => boolean;
24 /** @deprecated Please use fullCellRender instead. */
25 dateFullCellRender?: (date: DateType) => React.ReactNode;
26 /** @deprecated Please use cellRender instead. */
27 dateCellRender?: (date: DateType) => React.ReactNode;
28 /** @deprecated Please use fullCellRender instead. */
29 monthFullCellRender?: (date: DateType) => React.ReactNode;
30 /** @deprecated Please use cellRender instead. */
31 monthCellRender?: (date: DateType) => React.ReactNode;
32 cellRender?: (date: DateType, info: CellRenderInfo<DateType>) => React.ReactNode;
33 fullCellRender?: (date: DateType, info: CellRenderInfo<DateType>) => React.ReactNode;
34 headerRender?: HeaderRender<DateType>;
35 value?: DateType;
36 defaultValue?: DateType;
37 mode?: CalendarMode;
38 fullscreen?: boolean;
39 onChange?: (date: DateType) => void;
40 onPanelChange?: (date: DateType, mode: CalendarMode) => void;
41 onSelect?: (date: DateType, selectInfo: SelectInfo) => void;
42}
43declare const generateCalendar: <DateType extends AnyObject>(generateConfig: GenerateConfig<DateType>) => React.FC<Readonly<CalendarProps<DateType>>>;
44export default generateCalendar;