-
Notifications
You must be signed in to change notification settings - Fork 141
/
DatepickerContext.ts
99 lines (95 loc) · 3.52 KB
/
DatepickerContext.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
import dayjs from "dayjs";
import React, { createContext } from "react";
import { DATE_FORMAT, LANGUAGE, START_WEEK } from "../constants";
import {
Configs,
Period,
DateValueType,
DateType,
DateRangeType,
ClassNamesTypeProp
} from "../types";
interface DatepickerStore {
input?: React.RefObject<HTMLInputElement>;
asSingle?: boolean;
primaryColor: string;
configs?: Configs;
calendarContainer: React.RefObject<HTMLDivElement> | null;
arrowContainer: React.RefObject<HTMLDivElement> | null;
hideDatepicker: () => void;
period: Period;
changePeriod: (period: Period) => void;
dayHover: string | null;
changeDayHover: (day: string | null) => void;
inputText: string;
changeInputText: (text: string) => void;
updateFirstDate: (date: dayjs.Dayjs) => void;
changeDatepickerValue: (value: DateValueType, e?: HTMLInputElement | null | undefined) => void;
showFooter?: boolean;
placeholder?: string | null;
separator?: string;
i18n: string;
value: DateValueType;
disabled?: boolean;
inputClassName?: ((className: string) => string) | string | null;
containerClassName?: ((className: string) => string) | string | null;
toggleClassName?: ((className: string) => string) | string | null;
toggleIcon?: (open: boolean) => React.ReactNode;
readOnly?: boolean;
startWeekOn?: string | null;
displayFormat?: string;
minDate?: DateType | null;
maxDate?: DateType | null;
disabledDates?: DateRangeType[] | null;
inputId?: string;
inputName?: string;
classNames?: ClassNamesTypeProp;
popoverDirection?: string;
}
const DatepickerContext = createContext<DatepickerStore>({
input: undefined,
primaryColor: "blue",
configs: undefined,
calendarContainer: null,
arrowContainer: null,
// eslint-disable-next-line @typescript-eslint/no-empty-function
hideDatepicker: () => {},
period: { start: null, end: null },
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
changePeriod: period => {},
dayHover: null,
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
changeDayHover: (day: string | null) => {},
inputText: "",
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
changeInputText: text => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
updateFirstDate: date => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
changeDatepickerValue: (
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
value: DateValueType,
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
e: HTMLInputElement | null | undefined
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
) => {},
showFooter: false,
value: null,
i18n: LANGUAGE,
disabled: false,
inputClassName: "",
containerClassName: "",
toggleClassName: "",
readOnly: false,
displayFormat: DATE_FORMAT,
minDate: null,
maxDate: null,
disabledDates: null,
inputId: undefined,
inputName: undefined,
startWeekOn: START_WEEK,
toggleIcon: undefined,
classNames: undefined,
popoverDirection: undefined
});
export default DatepickerContext;