-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathindex.ts
116 lines (97 loc) · 2.88 KB
/
index.ts
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
import { MouseEventHandler, ReactNode } from "react";
import { COLORS, DATE_LOOKING_OPTIONS, DAYS } from "../constants";
export type DateType = null | Date;
export interface Period {
start: DateType;
end: DateType;
}
interface CustomShortcuts {
[key: string]: ShortcutsItem;
}
interface DefaultShortcuts {
today?: string;
yesterday?: string;
past?: (period: number) => string;
currentMonth?: string;
pastMonth?: string;
}
export interface Configs {
shortcuts?: DefaultShortcuts | CustomShortcuts;
footer?: {
cancel?: string;
apply?: string;
};
}
export interface ShortcutsItem {
text: string;
daysNumber?: number;
period: {
start: Date;
end: Date;
};
}
export type DateRangeType = {
startDate: DateType;
endDate: DateType;
};
export type DateValueType = DateRangeType | null;
export type ClassNameType = ((className: string) => string) | string | null;
export type ClassNamesTypeProp = {
container?: (p?: object | null | undefined) => string | undefined;
input?: (p?: object | null | undefined) => string | undefined;
toggleButton?: (p?: object | null | undefined) => string | undefined;
footer?: (p?: object | null | undefined) => string | undefined;
};
export type PopoverDirectionType = "up" | "down";
export type WeekStringType = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
export type WeekDaysIndexType = (typeof DAYS)[number];
export type DateLookingType = (typeof DATE_LOOKING_OPTIONS)[number];
export interface DatepickerType {
primaryColor?: ColorKeys;
value: DateValueType;
onChange: (value: DateValueType, e?: HTMLInputElement | null | undefined) => void;
useRange?: boolean;
showFooter?: boolean;
showShortcuts?: boolean;
configs?: Configs;
asSingle?: boolean;
placeholder?: string;
separator?: string;
startFrom?: DateType;
i18n?: string;
disabled?: boolean;
classNames?: ClassNamesTypeProp;
containerClassName?: ClassNameType;
popupClassName?: ClassNameType;
inputClassName?: ClassNameType;
toggleClassName?: ClassNameType;
toggleIcon?: (open: boolean) => ReactNode;
inputId?: string;
inputName?: string;
displayFormat?: string;
readOnly?: boolean;
minDate?: DateType;
maxDate?: DateType;
dateLooking?: DateLookingType;
disabledDates?: DateRangeType[];
startWeekOn?: WeekStringType;
popoverDirection?: PopoverDirectionType;
required?: boolean;
}
export type ColorKeys = (typeof COLORS)[number]; // "blue" | "orange"
export interface Colors {
[key: string]: {
[K in ColorKeys]: string;
};
}
export interface IconProps {
className: string;
}
export interface ButtonProps {
children: ReactNode;
onClick: MouseEventHandler<HTMLButtonElement>;
disabled?: boolean;
roundedFull?: boolean;
padding?: string;
active?: boolean;
}