-
-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathinterface.ts
More file actions
141 lines (115 loc) Β· 3.87 KB
/
interface.ts
File metadata and controls
141 lines (115 loc) Β· 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import type React from 'react';
import type { GenerateConfig } from './generate';
export type Locale = {
locale: string;
// ===================== Date Panel =====================
/** Display month before year in date panel header */
monthBeforeYear?: boolean;
yearFormat: string;
monthFormat?: string;
weekFormat?: string;
quarterFormat?: string;
today: string;
now: string;
backToToday: string;
ok: string;
timeSelect: string;
dateSelect: string;
weekSelect?: string;
clear: string;
month: string;
year: string;
previousMonth: string;
nextMonth: string;
monthSelect: string;
yearSelect: string;
decadeSelect: string;
dayFormat: string;
dateFormat: string;
dateTimeFormat: string;
previousYear: string;
nextYear: string;
previousDecade: string;
nextDecade: string;
previousCentury: string;
nextCentury: string;
shortWeekDays?: string[];
shortMonths?: string[];
};
export type PanelMode = 'time' | 'date' | 'week' | 'month' | 'quarter' | 'year' | 'decade';
export type PickerMode = Exclude<PanelMode, 'datetime' | 'decade'>;
export type CellRenderInfo<DateType> = {
// The cell wrapper element
originNode: React.ReactElement;
today: DateType;
// mask current cell as start or end when range picker
range?: 'start' | 'end';
type: PanelMode;
locale?: Locale;
subType?: 'hour' | 'minute' | 'second' | 'meridiem';
};
export type CellRender<DateType, CurrentType = DateType | number> = (
current: CurrentType,
info: CellRenderInfo<DateType>,
) => React.ReactNode;
export type PanelRefProps = {
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => boolean;
onBlur?: React.FocusEventHandler<HTMLElement>;
onClose?: () => void;
};
export type NullableDateType<DateType> = DateType | null | undefined;
export type OnSelect<DateType> = (value: DateType, type: 'key' | 'mouse' | 'submit') => void;
export type PanelSharedProps<DateType> = {
prefixCls: string;
generateConfig: GenerateConfig<DateType>;
value?: NullableDateType<DateType>;
viewDate: DateType;
/**
* @deprecated please use `defaultValue` instead.
* Set default display picker view date
*/
defaultPickerValue?: DateType;
locale: Locale;
disabledDate?: (date: DateType) => boolean;
prevIcon?: React.ReactNode;
nextIcon?: React.ReactNode;
superPrevIcon?: React.ReactNode;
superNextIcon?: React.ReactNode;
/**
* Typescript can not handle generic type so we can not use `forwardRef` here.
* Thus, move ref into operationRef.
* This is little hack which should refactor after typescript support.
*/
operationRef: React.MutableRefObject<PanelRefProps>;
onSelect: OnSelect<DateType>;
onViewDateChange: (value: DateType) => void;
onPanelChange: (mode: PanelMode | null, viewValue: DateType) => void;
};
export type DisabledTimes = {
disabledHours?: () => number[];
disabledMinutes?: (hour: number) => number[];
disabledSeconds?: (hour: number, minute: number) => number[];
};
export type DisabledTime<DateType> = (date: DateType | null) => DisabledTimes;
export type OnPanelChange<DateType> = (value: DateType, mode: PanelMode) => void;
export type EventValue<DateType> = DateType | null;
export type RangeValue<DateType> = [EventValue<DateType>, EventValue<DateType>] | null;
export type Components = {
button?: React.ComponentType | string;
};
export type RangeList = {
label: React.ReactNode;
onClick: () => void;
onMouseEnter: () => void;
onMouseLeave: () => void;
}[];
export type CustomFormat<DateType> = (value: DateType) => string;
export interface PresetDate<T> {
label: React.ReactNode;
value: T | (() => T);
}
// https://stackoverflow.com/a/39495173; need TypeScript >= 4.5
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc['length']]>;
export type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;