1 | import * as React from 'react';
|
2 |
|
3 | import type { SwiperOptions, Swiper as SwiperClass } from './types/index.d.ts';
|
4 |
|
5 | interface SwiperProps extends SwiperOptions {
|
6 | /**
|
7 | * Swiper container tag
|
8 | *
|
9 | * @default 'div'
|
10 | */
|
11 | tag?: string;
|
12 |
|
13 | /**
|
14 | * Swiper wrapper tag
|
15 | *
|
16 | * @default 'div'
|
17 | */
|
18 | wrapperTag?: string;
|
19 |
|
20 | /**
|
21 | * Get Swiper instance
|
22 | */
|
23 | onSwiper?: (swiper: SwiperClass) => void;
|
24 |
|
25 | /**
|
26 | * Event will be fired in when autoplay started
|
27 | */
|
28 | onAutoplayStart?: (swiper: SwiperClass) => void;
|
29 | /**
|
30 | * Event will be fired when autoplay stopped
|
31 | */
|
32 | onAutoplayStop?: (swiper: SwiperClass) => void;
|
33 | /**
|
34 | * Event will be fired on autoplay pause
|
35 | */
|
36 | onAutoplayPause?: (swiper: SwiperClass) => void;
|
37 | /**
|
38 | * Event will be fired on autoplay resume
|
39 | */
|
40 | onAutoplayResume?: (swiper: SwiperClass) => void;
|
41 | /**
|
42 | * Event triggers continuously while autoplay is enabled. It contains time left (in ms) before transition to next slide and percentage of that time related to autoplay delay
|
43 | */
|
44 | onAutoplayTimeLeft?: (swiper: SwiperClass, timeLeft: number, percentage: number) => void;
|
45 | /**
|
46 | * Event will be fired when slide changed with autoplay
|
47 | */
|
48 | onAutoplay?: (swiper: SwiperClass) => void;/**
|
49 | * Event will be fired on window hash change
|
50 | */
|
51 | onHashChange?: (swiper: SwiperClass) => void;
|
52 | /**
|
53 | * Event will be fired when swiper updates the hash
|
54 | */
|
55 | onHashSet?: (swiper: SwiperClass) => void;/**
|
56 | * Event will be fired on mousewheel scroll
|
57 | */
|
58 | onScroll?: (swiper: SwiperClass, event: WheelEvent) => void;/**
|
59 | * Event will be fired on navigation hide
|
60 | */
|
61 | onNavigationHide?: (swiper: SwiperClass) => void;
|
62 | /**
|
63 | * Event will be fired on navigation show
|
64 | */
|
65 | onNavigationShow?: (swiper: SwiperClass) => void;
|
66 | /**
|
67 | * Event will be fired on navigation prev button click
|
68 | */
|
69 | onNavigationPrev?: (swiper: SwiperClass) => void;
|
70 | /**
|
71 | * Event will be fired on navigation next button click
|
72 | */
|
73 | onNavigationNext?: (swiper: SwiperClass) => void;/**
|
74 | * Event will be fired on key press
|
75 | */
|
76 | onKeyPress?: (swiper: SwiperClass, keyCode: string) => void;/**
|
77 | * Event will be fired after pagination rendered
|
78 | */
|
79 | onPaginationRender?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
|
80 |
|
81 | /**
|
82 | * Event will be fired when pagination updated
|
83 | */
|
84 | onPaginationUpdate?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
|
85 |
|
86 | /**
|
87 | * Event will be fired on pagination hide
|
88 | */
|
89 | onPaginationHide?: (swiper: SwiperClass) => void;
|
90 |
|
91 | /**
|
92 | * Event will be fired on pagination show
|
93 | */
|
94 | onPaginationShow?: (swiper: SwiperClass) => void;/**
|
95 | * Event will be fired on draggable scrollbar drag start
|
96 | */
|
97 | onScrollbarDragStart?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
98 |
|
99 | /**
|
100 | * Event will be fired on draggable scrollbar drag move
|
101 | */
|
102 | onScrollbarDragMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
103 |
|
104 | /**
|
105 | * Event will be fired on draggable scrollbar drag end
|
106 | */
|
107 | onScrollbarDragEnd?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;/**
|
108 | * Event will be fired on zoom change
|
109 | */
|
110 | onZoomChange?: (swiper: SwiperClass, scale: number, imageEl: HTMLElement, slideEl: HTMLElement) => void;
|
111 |
|
112 | /**
|
113 | * Fired right after Swiper initialization.
|
114 | * @note Note that with `swiper.on('init')` syntax it will
|
115 | * work only in case you set `init: false` parameter.
|
116 | *
|
117 | * @example
|
118 | * ```js
|
119 | * const swiper = new Swiper('.swiper', {
|
120 | * init: false,
|
121 | * // other parameters
|
122 | * });
|
123 | * swiper.on('init', function() {
|
124 | * // do something
|
125 | * });
|
126 | * // init Swiper
|
127 | * swiper.init();
|
128 | * ```
|
129 | *
|
130 | * @example
|
131 | * ```js
|
132 | * // Otherwise use it as the parameter:
|
133 | * const swiper = new Swiper('.swiper', {
|
134 | * // other parameters
|
135 | * on: {
|
136 | * init: function () {
|
137 | * // do something
|
138 | * },
|
139 | * }
|
140 | * });
|
141 | * ```
|
142 | */
|
143 | onInit?: (swiper: SwiperClass) => any;
|
144 |
|
145 | /**
|
146 | * Event will be fired right before Swiper destroyed
|
147 | */
|
148 | onBeforeDestroy?: (swiper: SwiperClass) => void;
|
149 |
|
150 | /**
|
151 | * Event will be fired when currently active slide is changed
|
152 | */
|
153 | onSlideChange?: (swiper: SwiperClass) => void;
|
154 |
|
155 | /**
|
156 | * Event will be fired in the beginning of animation to other slide (next or previous).
|
157 | */
|
158 | onSlideChangeTransitionStart?: (swiper: SwiperClass) => void;
|
159 |
|
160 | /**
|
161 | * Event will be fired after animation to other slide (next or previous).
|
162 | */
|
163 | onSlideChangeTransitionEnd?: (swiper: SwiperClass) => void;
|
164 |
|
165 | /**
|
166 | * Same as "slideChangeTransitionStart" but for "forward" direction only
|
167 | */
|
168 | onSlideNextTransitionStart?: (swiper: SwiperClass) => void;
|
169 |
|
170 | /**
|
171 | * Same as "slideChangeTransitionEnd" but for "forward" direction only
|
172 | */
|
173 | onSlideNextTransitionEnd?: (swiper: SwiperClass) => void;
|
174 |
|
175 | /**
|
176 | * Same as "slideChangeTransitionStart" but for "backward" direction only
|
177 | */
|
178 | onSlidePrevTransitionStart?: (swiper: SwiperClass) => void;
|
179 |
|
180 | /**
|
181 | * Same as "slideChangeTransitionEnd" but for "backward" direction only
|
182 | */
|
183 | onSlidePrevTransitionEnd?: (swiper: SwiperClass) => void;
|
184 |
|
185 | /**
|
186 | * Event will be fired in the beginning of transition.
|
187 | */
|
188 | onTransitionStart?: (swiper: SwiperClass) => void;
|
189 |
|
190 | /**
|
191 | * Event will be fired after transition.
|
192 | */
|
193 | onTransitionEnd?: (swiper: SwiperClass) => void;
|
194 |
|
195 | /**
|
196 | * Event will be fired when user touch Swiper. Receives `touchstart` event as an arguments.
|
197 | */
|
198 | onTouchStart?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
199 |
|
200 | /**
|
201 | * Event will be fired when user touch and move finger over Swiper. Receives `touchmove` event as an arguments.
|
202 | */
|
203 | onTouchMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
204 |
|
205 | /**
|
206 | * Event will be fired when user touch and move finger over Swiper in direction opposite to direction parameter. Receives `touchmove` event as an arguments.
|
207 | */
|
208 | onTouchMoveOpposite?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
209 |
|
210 | /**
|
211 | * Event will be fired when user touch and move finger over Swiper and move it. Receives `touchmove` event as an arguments.
|
212 | */
|
213 | onSliderMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
214 |
|
215 | /**
|
216 | * Event will be fired when user release Swiper. Receives `touchend` event as an arguments.
|
217 | */
|
218 | onTouchEnd?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
219 |
|
220 | /**
|
221 | * Event will be fired when user click/tap on Swiper. Receives `touchend` event as an arguments.
|
222 | */
|
223 | onClick?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
224 |
|
225 | /**
|
226 | * Event will be fired when user click/tap on Swiper. Receives `touchend` event as an arguments.
|
227 | */
|
228 | onTap?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
229 |
|
230 | /**
|
231 | * Event will be fired when user double tap on Swiper's container. Receives `touchend` event as an arguments
|
232 | */
|
233 | onDoubleTap?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
234 |
|
235 | /**
|
236 | * Event will be fired when Swiper progress is changed, as an arguments it receives progress that is always from 0 to 1
|
237 | */
|
238 | onProgress?: (swiper: SwiperClass, progress: number) => void;
|
239 |
|
240 | /**
|
241 | * Event will be fired when Swiper reach its beginning (initial position)
|
242 | */
|
243 | onReachBeginning?: (swiper: SwiperClass) => void;
|
244 |
|
245 | /**
|
246 | * Event will be fired when Swiper reach last slide
|
247 | */
|
248 | onReachEnd?: (swiper: SwiperClass) => void;
|
249 |
|
250 | /**
|
251 | * Event will be fired when Swiper goes to beginning or end position
|
252 | */
|
253 | onToEdge?: (swiper: SwiperClass) => void;
|
254 |
|
255 | /**
|
256 | * Event will be fired when Swiper goes from beginning or end position
|
257 | */
|
258 | onFromEdge?: (swiper: SwiperClass) => void;
|
259 |
|
260 | /**
|
261 | * Event will be fired when swiper's wrapper change its position. Receives current translate value as an arguments
|
262 | */
|
263 | onSetTranslate?: (swiper: SwiperClass, translate: number) => void;
|
264 |
|
265 | /**
|
266 | * Event will be fired everytime when swiper starts animation. Receives current transition duration (in ms) as an arguments
|
267 | */
|
268 | onSetTransition?: (swiper: SwiperClass, transition: number) => void;
|
269 |
|
270 | /**
|
271 | * Event will be fired on window resize right before swiper's onresize manipulation
|
272 | */
|
273 | onResize?: (swiper: SwiperClass) => void;
|
274 |
|
275 | /**
|
276 | * Event will be fired if observer is enabled and it detects DOM mutations
|
277 | */
|
278 | onObserverUpdate?: (swiper: SwiperClass) => void;
|
279 |
|
280 | /**
|
281 | * Event will be fired right before "loop fix"
|
282 | */
|
283 | onBeforeLoopFix?: (swiper: SwiperClass) => void;
|
284 |
|
285 | /**
|
286 | * Event will be fired after "loop fix"
|
287 | */
|
288 | onLoopFix?: (swiper: SwiperClass) => void;
|
289 |
|
290 | /**
|
291 | * Event will be fired on breakpoint change
|
292 | */
|
293 | onBreakpoint?: (swiper: SwiperClass, breakpointParams: SwiperOptions) => void;
|
294 |
|
295 | /**
|
296 | * !INTERNAL: Event will fired right before breakpoint change
|
297 | */
|
298 | _beforeBreakpoint?: (swiper: SwiperClass, breakpointParams: SwiperOptions) => void;
|
299 |
|
300 | /**
|
301 | * !INTERNAL: Event will fired after setting CSS classes on swiper container element
|
302 | */
|
303 | _containerClasses?: (swiper: SwiperClass, classNames: string) => void;
|
304 |
|
305 | /**
|
306 | * !INTERNAL: Event will fired after setting CSS classes on swiper slide element
|
307 | */
|
308 | _slideClass?: (swiper: SwiperClass, slideEl: HTMLElement, classNames: string) => void;
|
309 |
|
310 | /**
|
311 | * !INTERNAL: Event will fired after setting CSS classes on all swiper slides
|
312 | */
|
313 | _slideClasses?: (
|
314 | swiper: SwiperClass,
|
315 | slides: { slideEl: HTMLElement; classNames: string; index: number }[],
|
316 | ) => void;
|
317 |
|
318 | /**
|
319 | * !INTERNAL: Event will fired as soon as swiper instance available (before init)
|
320 | */
|
321 | _swiper?: (swiper: SwiperClass) => void;
|
322 |
|
323 | /**
|
324 | * !INTERNAL: Event will be fired on free mode touch end (release) and there will no be momentum
|
325 | */
|
326 | _freeModeNoMomentumRelease?: (swiper: SwiperClass) => void;
|
327 |
|
328 | /**
|
329 | * Event will fired on active index change
|
330 | */
|
331 | onActiveIndexChange?: (swiper: SwiperClass) => void;
|
332 | /**
|
333 | * Event will fired on snap index change
|
334 | */
|
335 | onSnapIndexChange?: (swiper: SwiperClass) => void;
|
336 | /**
|
337 | * Event will fired on real index change
|
338 | */
|
339 | onRealIndexChange?: (swiper: SwiperClass) => void;
|
340 | /**
|
341 | * Event will fired right after initialization
|
342 | */
|
343 | onAfterInit?: (swiper: SwiperClass) => void;
|
344 | /**
|
345 | * Event will fired right before initialization
|
346 | */
|
347 | onBeforeInit?: (swiper: SwiperClass) => void;
|
348 | /**
|
349 | * Event will fired before resize handler
|
350 | */
|
351 | onBeforeResize?: (swiper: SwiperClass) => void;
|
352 | /**
|
353 | * Event will fired before slide change transition start
|
354 | */
|
355 | onBeforeSlideChangeStart?: (swiper: SwiperClass) => void;
|
356 | /**
|
357 | * Event will fired before transition start
|
358 | */
|
359 | onBeforeTransitionStart?: (swiper: SwiperClass, speed: number, internal: any) => void; // what is internal?
|
360 | /**
|
361 | * Event will fired on direction change
|
362 | */
|
363 | onChangeDirection?: (swiper: SwiperClass) => void;
|
364 | /**
|
365 | * Event will be fired when user double click/tap on Swiper
|
366 | */
|
367 | onDoubleClick?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
|
368 | /**
|
369 | * Event will be fired on swiper destroy
|
370 | */
|
371 | onDestroy?: (swiper: SwiperClass) => void;
|
372 | /**
|
373 | * Event will be fired on momentum bounce
|
374 | */
|
375 | onMomentumBounce?: (swiper: SwiperClass) => void;
|
376 | /**
|
377 | * Event will be fired on orientation change (e.g. landscape -> portrait)
|
378 | */
|
379 | onOrientationchange?: (swiper: SwiperClass) => void;
|
380 | /**
|
381 | * Event will be fired in the beginning of animation of resetting slide to current one
|
382 | */
|
383 | onSlideResetTransitionStart?: (swiper: SwiperClass) => void;
|
384 | /**
|
385 | * Event will be fired in the end of animation of resetting slide to current one
|
386 | */
|
387 | onSlideResetTransitionEnd?: (swiper: SwiperClass) => void;
|
388 | /**
|
389 | * Event will be fired with first touch/drag move
|
390 | */
|
391 | onSliderFirstMove?: (swiper: SwiperClass, event: TouchEvent) => void;
|
392 | /**
|
393 | * Event will be fired when number of slides has changed
|
394 | */
|
395 | onSlidesLengthChange?: (swiper: SwiperClass) => void;
|
396 | /**
|
397 | * Event will be fired when slides grid has changed
|
398 | */
|
399 | onSlidesGridLengthChange?: (swiper: SwiperClass) => void;
|
400 | /**
|
401 | * Event will be fired when snap grid has changed
|
402 | */
|
403 | onSnapGridLengthChange?: (swiper: SwiperClass) => void;
|
404 | /**
|
405 | * Event will be fired after swiper.update() call
|
406 | */
|
407 | onUpdate?: (swiper: SwiperClass) => void;
|
408 | /**
|
409 | * Event will be fired when swiper is locked (when `watchOverflow` enabled)
|
410 | */
|
411 | onLock?: (swiper: SwiperClass) => void;
|
412 | /**
|
413 | * Event will be fired when swiper is unlocked (when `watchOverflow` enabled)
|
414 | */
|
415 | onUnlock?: (swiper: SwiperClass) => void;
|
416 |
|
417 | }
|
418 |
|
419 | interface SlideData {
|
420 | isActive: boolean;
|
421 | isVisible: boolean;
|
422 | isPrev: boolean;
|
423 | isNext: boolean;
|
424 | }
|
425 |
|
426 | interface SwiperSlideProps {
|
427 | /**
|
428 | * Slide tag
|
429 | *
|
430 | * @default 'div'
|
431 | */
|
432 | tag?: string;
|
433 |
|
434 | /**
|
435 | * Enables additional wrapper required for zoom mode
|
436 | *
|
437 | * @default false
|
438 | */
|
439 | zoom?: boolean;
|
440 |
|
441 | /**
|
442 | * Adds lazy preloader to the slide
|
443 | *
|
444 | * @default false
|
445 | */
|
446 | lazy?: boolean;
|
447 |
|
448 | /**
|
449 | * Slide's index in slides array/collection
|
450 | *
|
451 | * @default false
|
452 | */
|
453 | virtualIndex?: number;
|
454 |
|
455 | /**
|
456 | * Slide's child element or render function
|
457 | *
|
458 | * @default undefined
|
459 | */
|
460 | children?: React.ReactNode | ((slideData: SlideData) => React.ReactNode);
|
461 | }
|
462 |
|
463 | interface SwiperProps
|
464 | extends Omit<
|
465 | React.HTMLAttributes<HTMLElement>,
|
466 | | 'onProgress'
|
467 | | 'onClick'
|
468 | | 'onTouchEnd'
|
469 | | 'onTouchMove'
|
470 | | 'onTouchStart'
|
471 | | 'onTransitionEnd'
|
472 | | 'onKeyPress'
|
473 | | 'onDoubleClick'
|
474 | | 'onScroll'
|
475 | | 'onResize'
|
476 | > {}
|
477 | interface SwiperSlideProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {}
|
478 |
|
479 | interface SwiperRef extends React.HTMLAttributes<HTMLElement> {
|
480 | swiper: SwiperClass;
|
481 | }
|
482 |
|
483 | declare const Swiper: React.FunctionComponent<React.RefAttributes<SwiperRef> & SwiperProps>;
|
484 | declare const SwiperSlide: React.FunctionComponent<SwiperSlideProps>;
|
485 |
|
486 | declare const useSwiper: () => SwiperClass;
|
487 | declare const useSwiperSlide: () => SlideData;
|
488 |
|
489 | export {
|
490 | Swiper,
|
491 | SwiperSlide,
|
492 | SwiperProps,
|
493 | SwiperSlideProps,
|
494 | SwiperRef,
|
495 | useSwiper,
|
496 | useSwiperSlide,
|
497 | SwiperClass,
|
498 | };
|