-
Notifications
You must be signed in to change notification settings - Fork 97
/
index.d.ts
256 lines (220 loc) · 6.56 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import React from 'react';
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
import { Moment } from 'moment';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface WeekViewEvent extends Record<string, any> {
id: number;
description?: string;
startDate: Date;
endDate: Date;
eventKind?: 'block' | 'standard';
resolveOverlap?: 'stack' | 'lane' | 'ignore';
stackKey?: string;
color?: string;
style?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
disableDrag?: boolean;
disablePress?: boolean;
disableLongPress?: boolean;
}
export interface HeaderComponentProps {
date: Moment;
formattedDate: string;
textStyle: StyleProp<TextStyle>;
isToday: boolean;
}
export interface EventComponentProps {
event: WeekViewEvent;
position: {
top: number;
left: number;
height: number;
width: number;
};
}
export interface RefreshComponentProps {
style: ViewStyle;
}
export interface PageStartAtOptions {
left?: number;
weekday?: number;
}
export interface WeekViewProps {
ref: React.MutableRefObject;
events: WeekViewEvent[];
selectedDate: Date;
numberOfDays: 1 | 3 | 5 | 7;
// Gesture interactions
/**
* Callback when an event item is pressed, receives the event-item pressed
* @param event
*/
onEventPress?: (event: WeekViewEvent) => void;
/**
* Callback when an event item is long pressed, same signature as onEventPress
* @param event
*/
onEventLongPress?: (event: WeekViewEvent) => void;
/**
* Callback when week-view is swiped to next week/days,
* receives new date shown.
* @param date
*/
onSwipeNext?(date: Date): void;
/**
* Callback when week-view is swiped to previous week/days,
* same signature as onSwipeNext.
* @param date
*/
onSwipePrev?(date: Date): void;
/**
* Callback when the grid view is pressed. Arguments: pressEvent:
* object passed by the
* [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/api/gestures/touch-events)
* touch events (not an event item); startHour: Number, hour pressed;
* date Date, date object indicating day and time pressed with precision up
* to seconds.
*
* Note: startHour is redundant (can be extracted from date),
* but is kept for backward-compatibility.
* @param pressEvent
* @param startHour
* @param date
*/
onGridClick?(pressEvent: TouchEvent, startHour: number, date: Date): void;
/**
* Callback when the grid view is long-pressed. Same signature as onGridClick
* @param pressEvent
* @param startHour
* @param date
*/
onGridLongPress?(pressEvent: TouchEvent, startHour: number, date: Date): void;
/**
* Callback when a day from the header is pressed.
* @param date
* @param formattedDate
*/
onDayPress?(date: Date, formattedDate: string): void;
/**
* Callback when the month at the top left (title) is pressed.
* @param date
* @param formattedDate
*/
onMonthPress?(date: Date, formattedDate: string): void;
/**
* Callback when the agenda is scrolled vertically.
* @param dateWithTime
*/
onTimeScrolled?(dateWithTime: Date): void;
/**
* Callback when an event item is dragged to another position.
* Arguments: event: event-item moved,and the newStartDate and newEndDate
* are Date objects with day and hour of the new position (precision up
* to minutes). With this callback you must trigger an update on the events
* prop (i.e. update your DB), with the updated information from the event.
* @param event
* @param newStartDate
* @param newEndDate
*/
onDragEvent?(
event: WeekViewEvent,
newStartDate: Date,
newEndDate: Date,
): void;
/**
* If provided, events are draggable only after being long pressed
* for some time.
* **Requires rn-gesture-handler v2.6.0 or higher.**
* Disables the `onLongPress` callback.
*/
dragEventConfig?: {
afterLongPressDuration: number;
} | null;
/**
* Which event is being edited.
*/
editingEvent?: number | string | null;
/**
* Callback when an event item is edited by dragging its borders.
* @param event
* @param newStartDate
* @param newEndDate
*/
onEditEvent?(
event: WeekViewEvent,
newStartDate: Date,
newEndDate: Date,
): void;
editEventConfig?: {
bottom: boolean;
top: boolean;
left: boolean;
right: boolean;
};
// Week-view customizations
/**
* Vertical position of the week-view in the first render (vertically in the agenda).
*
* Default value: 8 (8 am)
*/
startHour?: number;
/**
* Indicates what date to show in the top-left corner.
*
* If `left = value` provided, the `selectedDate` will appear
* at `value` days from the left.
*
* If `weekday = value` _(e.g. tuesday = 2)_ is provided,
* the latest tuesday will appear in the left.
*/
pageStartAt?: PageStartAtOptions;
/**
* When `true`, the component can scroll horizontally one day at the time.
* When `false`, the horizontal scroll can only be done one page
* at the time (i.e. `numberOfDays` at the time).
*/
allowScrollByDay?: boolean;
/**
* Show or hide the selected month and year in the top-left corner (a.k.a the title).
*/
showTitle?: boolean;
hoursInDisplay?: number;
beginAgendaAt?: number;
endAgendaAt?: number;
timeStep?: number;
formatDateHeader?: string;
formatTimeLabel?: string;
timesColumnWidth?: number;
EventComponent?: React.ComponentType<EventComponentProps>;
TodayHeaderComponent?: React.ComponentType<HeaderComponentProps>;
DayHeaderComponent?: React.ComponentType<HeaderComponentProps>;
showNowLine?: boolean;
nowLineColor?: string;
fixedHorizontally?: boolean;
isRefreshing?: boolean;
enableVerticalPinch?: boolean;
RefreshComponent?: React.ComponentType<RefreshComponentProps>;
locale?: string;
rightToLeft?: boolean;
// Style props
headerStyle?: StyleProp<ViewStyle>;
headerTextStyle?: StyleProp<TextStyle>;
hourTextStyle?: StyleProp<TextStyle>;
eventContainerStyle?: StyleProp<ViewStyle>;
eventTextStyle?: StyleProp<TextStyle>;
// Grid lines props
gridRowStyle?: StyleProp<ViewStyle>;
gridColumnStyle?: StyleProp<ViewStyle>;
// Horizontal list optimizations
windowSize?: number;
initialNumToRender?: number;
maxToRenderPerBatch?: number;
updateCellsBatchingPeriod?: number;
removeClippedSubviews?: boolean;
disableVirtualization?: boolean;
// Other props (patch RN bugs)
prependMostRecent?: boolean;
runOnJS?: boolean;
}
declare const WeekView: React.ComponentType<WeekViewProps>;
export default WeekView;