forked from reactrondev/react-native-web-swiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
368 lines (314 loc) · 7.5 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
import * as React from 'react';
import {
ViewStyle,
TextStyle,
StyleProp,
} from 'react-native';
type Falsy = undefined | null | false;
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {}
/** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle<T>` and return `T`. */
type RegisteredStyle<T> = number & { __registeredStyleBrand: T };
export type SwiperControlsCorners =
| 'top-left'
| 'top'
| 'top-right'
| 'left'
| 'center'
| 'right'
| 'bottom-left'
| 'bottom'
| 'bottom-right';
// TODO: optimize
interface SwiperControlsCellsStyle {
'top-left'?: StyleProp<ViewStyle>;
top?: StyleProp<ViewStyle>;
'top-right'?: StyleProp<ViewStyle>;
left?: StyleProp<ViewStyle>;
center?: StyleProp<ViewStyle>;
right?: StyleProp<ViewStyle>;
'bottom-left'?: StyleProp<ViewStyle>;
bottom?: StyleProp<ViewStyle>;
'bottom-right'?: StyleProp<ViewStyle>;
}
interface SwiperControlsCellsContent {
'top-left'?: React.ReactElement<{}>;
top?: React.ReactElement<{}>;
'top-right'?: React.ReactElement<{}>;
left?: React.ReactElement<{}>;
center?: React.ReactElement<{}>;
right?: React.ReactElement<{}>;
'bottom-left'?: React.ReactElement<{}>;
bottom?: React.ReactElement<{}>;
'bottom-right'?: React.ReactElement<{}>;
}
export interface BadgeProps {
/**
* Text value to be displayed by badge
*
* @default null
*/
value?: React.ReactNode;
/**
* Additional styling for badge (background) view component
*/
badgeStyle?: StyleProp<ViewStyle>;
/**
* Style for the container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Style for the text in the badge
*/
textStyle?: StyleProp<TextStyle>;
/**
* Custom component to replace the badge component
*
* @default View (if onPress then TouchableOpacity)
*/
Component?: React.ComponentClass;
/**
* Determines color of the indicator
*
* @default primary
*/
status?: 'primary' | 'success' | 'warning' | 'error';
/**
* Function called when pressed on the badge
*/
onPress?(): void;
}
interface SwiperControlsProps {
/**
* Controls corners placeholders styles
*/
cellsStyle?: SwiperControlsCellsStyle;
/**
* Controls corners placeholders additional content
*/
cellsContent?: SwiperControlsCellsContent;
/**
* Dots position
*
* @default 'bottom' | 'right' if vertical
*/
dotsPos?: SwiperControlsCorners | boolean;
/**
* Prev button position
*
* @default 'bottom-left' | 'top-right' if vertical
*/
prevPos?: SwiperControlsCorners | boolean;
/**
* Next button position
*
* @default 'bottom-right'
*/
nextPos?: SwiperControlsCorners | boolean;
/**
* Prev button title
*
* @default Prev
*/
prevTitle?: string;
/**
* Next button title
*
* @default Next
*/
nextTitle?: string;
/**
* Touches over dots will move swiper to relative slide
*
* @default false
*/
dotsTouchable?: boolean;
/**
* Dots wrapper View style
*/
dotsWrapperStyle?: StyleProp<ViewStyle>;
/**
* Customizing dot with Badge props
*/
dotProps?: BadgeProps;
/**
* Additional style to active dot
*/
dotActiveStyle?: StyleProp<ViewStyle>;
/**
* Custom dot component
*/
DotComponent?: React.ComponentType;
/**
* Customize prev button title
*/
prevTitleStyle?: StyleProp<TextStyle>;
/**
* Customize next button title
*/
nextTitleStyle?: StyleProp<TextStyle>;
/**
* Custom prev button component
*/
PrevComponent?: React.ComponentClass;
/**
* Custom next button component
*/
NextComponent?: React.ComponentClass;
/**
* Custom prev element on first slide (if not loop)
*/
firstPrevElement?: React.ReactElement<{}>;
/**
* Custom next element on last slide (if not loop)
*/
lastNextElement?: React.ReactElement<{}>;
}
// TODO: extends Animated.SpringAnimationConfig but without toValue
interface SwiperSpringAnimationConfig {
overshootClamping?: boolean;
restDisplacementThreshold?: number;
restSpeedThreshold?: number;
velocity?: number | { x: number; y: number };
bounciness?: number;
speed?: number;
tension?: number;
friction?: number;
stiffness?: number;
mass?: number;
damping?: number;
}
export interface SwiperProps {
/**
* Swiper vertical layout
*
* @default false
*/
vertical?: boolean;
/**
* Initial slide index
*
* @default 0
*/
from?: number;
/**
* Allow loop
*
* @default false
*/
loop?: boolean;
/**
* Autoplay slider timeout in secs. Negative value will play reverse
*
* @default 0 (autoplay disabled)
*/
timeout?: number;
/**
* Should the swiper's swiping gesture be enabled?
*
* @default true
*/
gesturesEnabled?: () => boolean;
/**
* Tune spring animation on autoplay, touch release or slides changes via buttons
*/
springConfig?: SwiperSpringAnimationConfig;
/**
* Initiate animation after swipe this distance.
* It fix gesture collisions inside ScrollView
*
* @default 5
*/
minDistanceToCapture?: number;
/**
* Minimal part of swiper width (or height for vertical) must be swiped
* for changing index. Otherwise animation restore current slide.
* Default value 0.2 means that 20% must be swiped for change index
*
* @default 0.2
*/
minDistanceForAction?: number;
/**
* Swiper inner container position 'fixed' instead 'relative'.
* Fix mobile safari vertical bounces
*
* @default false
*/
positionFixed?: boolean;
/**
* Outer (root) container style
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Inner container style
*/
innerContainerStyle?: StyleProp<ViewStyle>;
/**
* Swipe area style
*/
swipeAreaStyle?: StyleProp<ViewStyle>;
/**
* Each slide wrapper style
*/
slideWrapperStyle?: StyleProp<ViewStyle>;
/**
* Dots and control buttons enabled
*
* @default true
*/
controlsEnabled?: boolean;
/**
* Controls Properties
*/
controlsProps?: SwiperControlsProps;
/**
* Custom controls component
*/
Controls?: React.ComponentClass;
/**
* Any swiper animation start
*
* @param currentIndex
*/
onAnimationStart?(currentIndex: number): void;
/**
* Any swiper animation end
*
* @param index
*/
onAnimationEnd?(index: number): void;
/**
* Called when active index changed
*
* @param index
*/
onIndexChanged?(index: number): void;
}
/**
* Swiper component
*/
export default class Swiper extends React.Component<SwiperProps, any> {
/**
* Go to next slide
*/
goToNext(): void;
/**
* Go to previous slide
*/
goToPrev(): void;
/**
* Go to slide by index
*/
goTo(index: number): void;
/**
* Get current slide index
*/
getActiveIndex(): number;
/**
* Manual start autoplay after manual stop
*/
startAutoplay(): void;
/**
* Manual stop autoplay. Will be automatically restarted after any animation
*/
stopAutoplay(): void;
}