forked from Kiarash-Z/react-modern-calendar-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
110 lines (93 loc) · 3.16 KB
/
index.d.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
import React from 'react';
export type Day = {
year: number;
month: number;
day: number;
};
export type DayValue = Day | null | undefined;
export type DayRange = { from: DayValue; to: DayValue };
type Value = DayValue | Day[] | DayRange;
type CustomDayClassNameItem = Day & { className: string };
export interface CalendarProps<TValue extends Value> {
value: TValue;
onChange?(value: TValue): void;
onDisabledDayError?(value: Day): void;
selectorStartingYear?: number;
selectorEndingYear?: number;
locale?: string | Locale;
minimumDate?: Day;
maximumDate?: Day;
disabledDays?: Day[];
shouldHighlightWeekends?: boolean;
colorPrimary?: string;
colorPrimaryLight?: string;
slideAnimationDuration?: string;
calendarClassName?: string;
calendarTodayClassName?: string;
calendarSelectedDayClassName?: string;
calendarRangeStartClassName?: string;
calendarRangeBetweenClassName?: string;
calendarRangeEndClassName?: string;
renderFooter?: React.FC;
customDaysClassName?: CustomDayClassNameItem[];
}
export function Calendar(props: Optional<CalendarProps<DayValue>, 'value'>): React.ReactElement;
export function Calendar(props: CalendarProps<Day[]>): React.ReactElement;
export function Calendar(props: CalendarProps<DayRange>): React.ReactElement;
export type RenderInputProps = {
ref: React.RefObject<HTMLElement>;
};
export interface DatePickerProps<TValue extends Value> extends CalendarProps<TValue> {
wrapperClassName?: string;
inputClassName?: string;
inputName?: string;
calendarPopperPosition?: 'auto' | 'top' | 'bottom';
inputPlaceholder?: string;
formatInputText?: () => string;
renderInput?: React.FC<RenderInputProps>;
}
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
declare function DatePicker(props: Optional<DatePickerProps<DayValue>, 'value'>): React.ReactElement;
declare function DatePicker(props: DatePickerProps<Day[]>): React.ReactElement;
declare function DatePicker(props: DatePickerProps<DayRange>): React.ReactElement;
type WeekDay = {
name: string;
short: string;
isWeekend?: boolean;
}
export type Utils = {
monthsList: string[];
weekDaysList: WeekDay[];
getToday(): Day;
getMonthName(number: number): string;
getMonthNumber(name: string): number;
getMonthLength(day: Day): number;
getMonthFirstWeekday(day: Day): number;
isBeforeDate(a: Day, b: Day): boolean;
checkDayInDayRange(props: Required<DayRange> & { day: Day }): boolean;
getLanguageDigits(digit: string | number): string;
};
export function utils(locale: string): Utils;
export type CalendarDigit = string | number;
export interface Locale {
months: string[];
weekDays: WeekDay[];
weekStartingIndex: number;
getToday: (gregorainTodayObject: Day) => Day;
toNativeDate: (date: Day) => Date;
getMonthLength: (date: Day) => number;
transformDigit: (digit: CalendarDigit) => CalendarDigit;
nextMonth: string;
previousMonth: string;
openMonthSelector: string;
openYearSelector: string;
closeMonthSelector: string;
closeYearSelector: string;
from: string;
to: string;
defaultPlaceholder: string;
digitSeparator: string;
yearLetterSkip: number;
isRtl: boolean;
}
export default DatePicker;