-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
calendarx.d.ts
100 lines (84 loc) · 2.01 KB
/
calendarx.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
import * as React from 'react';
export type DateLike = Date | string | number;
export type Event =
| { date: DateLike }
| { startDate: DateLike; endDate: DateLike };
export type View = 'year' | 'month' | 'week' | 'day';
export type ButtonPropsGetter = (props?: {
onClick?: () => void;
}) => {
role: string;
'aria-label': string;
onClick: () => void;
};
export type Day = {
date: Date;
events: Event[];
isToday: boolean;
isSame: (view: View) => boolean;
};
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
export type JumpUnit =
| View
| 'years'
| 'y'
| 'months'
| 'M'
| 'weeks'
| 'w'
| 'days'
| 'd';
export type Properties = {
date: Date;
days: Day[][];
headers: string[];
view: View;
numDays: number;
jump: (n: number, v?: JumpUnit) => void;
goToNext: (n?: number) => void;
goToPrev: (n?: number) => void;
goToToday: () => void;
goToDate: (date: DateLike) => void;
getPrevButtonProps: ButtonPropsGetter;
getNextButtonProps: ButtonPropsGetter;
getTodayButtonProps: ButtonPropsGetter;
setNumDays: (numDays: number) => void;
};
export interface Options {
initialDate?: DateLike;
initialNumDays?: number;
date?: DateLike;
numDays?: number;
events?: Event[];
weekStartsOn?: Weekday;
headers?: string[];
}
export interface Props extends Options {
children: (properties: Properties) => React.ReactNode;
}
export function Calendar(props: Props): React.ReactNode;
export function useCalendar(options?: Options): Properties;
export namespace Calendar {
function useCalendar(options?: Options): Properties;
const days: {
SUNDAY: 0;
MONDAY: 1;
TUESDAY: 2;
WEDNESDAY: 3;
THURSDAY: 4;
FRIDAY: 5;
SATURDAY: 6;
};
const defaultProps: {
events: Event[];
headers: string[];
initialNumDays: number;
weekStartsOn: Weekday;
};
const views: {
DAY: 'day';
WEEK: 'week';
MONTH: 'month';
YEAR: 'year';
};
}