UNPKG

3.85 kBTypeScriptView Raw
1import type React from 'react';
2import type { GenerateConfig } from './generate';
3export type Locale = {
4 locale: string;
5 /** Display month before year in date panel header */
6 monthBeforeYear?: boolean;
7 yearFormat: string;
8 monthFormat?: string;
9 quarterFormat?: string;
10 today: string;
11 now: string;
12 backToToday: string;
13 ok: string;
14 timeSelect: string;
15 dateSelect: string;
16 weekSelect?: string;
17 clear: string;
18 month: string;
19 year: string;
20 previousMonth: string;
21 nextMonth: string;
22 monthSelect: string;
23 yearSelect: string;
24 decadeSelect: string;
25 dayFormat: string;
26 dateFormat: string;
27 dateTimeFormat: string;
28 previousYear: string;
29 nextYear: string;
30 previousDecade: string;
31 nextDecade: string;
32 previousCentury: string;
33 nextCentury: string;
34 shortWeekDays?: string[];
35 shortMonths?: string[];
36};
37export type PanelMode = 'time' | 'date' | 'week' | 'month' | 'quarter' | 'year' | 'decade';
38export type PickerMode = Exclude<PanelMode, 'datetime' | 'decade'>;
39export type CellRenderInfo<DateType> = {
40 originNode: React.ReactElement;
41 today: DateType;
42 range?: 'start' | 'end';
43 type: PanelMode;
44 locale?: Locale;
45 subType?: 'hour' | 'minute' | 'second' | 'meridiem';
46};
47export type CellRender<DateType, CurrentType = DateType | number> = (current: CurrentType, info: CellRenderInfo<DateType>) => React.ReactNode;
48export type PanelRefProps = {
49 onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => boolean;
50 onBlur?: React.FocusEventHandler<HTMLElement>;
51 onClose?: () => void;
52};
53export type NullableDateType<DateType> = DateType | null | undefined;
54export type OnSelect<DateType> = (value: DateType, type: 'key' | 'mouse' | 'submit') => void;
55export type PanelSharedProps<DateType> = {
56 prefixCls: string;
57 generateConfig: GenerateConfig<DateType>;
58 value?: NullableDateType<DateType>;
59 viewDate: DateType;
60 /**
61 * @deprecated please use `defaultValue` instead.
62 * Set default display picker view date
63 */
64 defaultPickerValue?: DateType;
65 locale: Locale;
66 disabledDate?: (date: DateType) => boolean;
67 prevIcon?: React.ReactNode;
68 nextIcon?: React.ReactNode;
69 superPrevIcon?: React.ReactNode;
70 superNextIcon?: React.ReactNode;
71 /**
72 * Typescript can not handle generic type so we can not use `forwardRef` here.
73 * Thus, move ref into operationRef.
74 * This is little hack which should refactor after typescript support.
75 */
76 operationRef: React.MutableRefObject<PanelRefProps>;
77 onSelect: OnSelect<DateType>;
78 onViewDateChange: (value: DateType) => void;
79 onPanelChange: (mode: PanelMode | null, viewValue: DateType) => void;
80};
81export type DisabledTimes = {
82 disabledHours?: () => number[];
83 disabledMinutes?: (hour: number) => number[];
84 disabledSeconds?: (hour: number, minute: number) => number[];
85};
86export type DisabledTime<DateType> = (date: DateType | null) => DisabledTimes;
87export type OnPanelChange<DateType> = (value: DateType, mode: PanelMode) => void;
88export type EventValue<DateType> = DateType | null;
89export type RangeValue<DateType> = [EventValue<DateType>, EventValue<DateType>] | null;
90export type Components = {
91 button?: React.ComponentType | string;
92};
93export type RangeList = {
94 label: React.ReactNode;
95 onClick: () => void;
96 onMouseEnter: () => void;
97 onMouseLeave: () => void;
98}[];
99export type CustomFormat<DateType> = (value: DateType) => string;
100export interface PresetDate<T> {
101 label: React.ReactNode;
102 value: T | (() => T);
103}
104type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
105export type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
106export {};
107
\No newline at end of file