react-view-transition-swiper 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chris Lu Yi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,57 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface SlideItem {
5
+ id: string;
6
+ content: ReactNode;
7
+ }
8
+ type DragPermission = "all" | "left" | "right" | "up" | "down" | "none";
9
+ interface SlideOptions {
10
+ keepDom?: boolean;
11
+ animate?: boolean;
12
+ drag?: DragPermission;
13
+ }
14
+ interface NavOptions {
15
+ /** Skip the view transition and swap instantly. Default: false */
16
+ instant?: boolean;
17
+ }
18
+ type SwipeDeckErrorCode = "NAV_MISSING_ELEMENT" | "NAV_ELEMENT_NOT_VISIBLE" | "POINTER_CAPTURE_FAILED" | "POINTER_RELEASE_FAILED";
19
+ interface SwipeDeckError {
20
+ code: SwipeDeckErrorCode;
21
+ message: string;
22
+ /** Extra context: cur, delta, next, retries, element ids, etc. */
23
+ detail?: Record<string, unknown>;
24
+ }
25
+ interface SwipeDeckHandle {
26
+ readonly currentIndex: number;
27
+ readonly currentSlides: SlideItem[];
28
+ addSlide: (slide: SlideItem, options?: SlideOptions) => void;
29
+ removeSlide: (id: string, options?: Pick<SlideOptions, "animate">) => void;
30
+ removeSlides: (ids: string[], options?: Pick<SlideOptions, "animate">) => void;
31
+ goTo: (index: number, options?: NavOptions) => void;
32
+ next: (options?: NavOptions) => void;
33
+ prev: (options?: NavOptions) => void;
34
+ setPeek: (index: number | null) => void;
35
+ }
36
+ interface SwipeDeckProps {
37
+ width?: number;
38
+ showDots?: boolean;
39
+ fade?: boolean;
40
+ dimOnDrag?: boolean;
41
+ maxDragRatio?: number;
42
+ dragDisabled?: boolean;
43
+ keyboardDisabled?: boolean;
44
+ /** Drag and nav direction. "y" uses scroll-boundary detection so card
45
+ * content can still scroll freely; nav only triggers when the scroll
46
+ * hits the top/bottom edge and the user continues pulling. Default: "x" */
47
+ navAxis?: "x" | "y";
48
+ dragDelayMs?: number;
49
+ /** Duration of the view transition and gesture fly-out in ms. Default: 360 */
50
+ transitionMs?: number;
51
+ onSlideChange?: (index: number) => void;
52
+ onError?: (error: SwipeDeckError) => void;
53
+ className?: string;
54
+ }
55
+ declare const SwipeDeck: react.ForwardRefExoticComponent<SwipeDeckProps & react.RefAttributes<SwipeDeckHandle>>;
56
+
57
+ export { type DragPermission, type NavOptions, type SlideItem, type SlideOptions, type SwipeDeckError, type SwipeDeckErrorCode, type SwipeDeckHandle, type SwipeDeckProps, SwipeDeck as default };
@@ -0,0 +1,57 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface SlideItem {
5
+ id: string;
6
+ content: ReactNode;
7
+ }
8
+ type DragPermission = "all" | "left" | "right" | "up" | "down" | "none";
9
+ interface SlideOptions {
10
+ keepDom?: boolean;
11
+ animate?: boolean;
12
+ drag?: DragPermission;
13
+ }
14
+ interface NavOptions {
15
+ /** Skip the view transition and swap instantly. Default: false */
16
+ instant?: boolean;
17
+ }
18
+ type SwipeDeckErrorCode = "NAV_MISSING_ELEMENT" | "NAV_ELEMENT_NOT_VISIBLE" | "POINTER_CAPTURE_FAILED" | "POINTER_RELEASE_FAILED";
19
+ interface SwipeDeckError {
20
+ code: SwipeDeckErrorCode;
21
+ message: string;
22
+ /** Extra context: cur, delta, next, retries, element ids, etc. */
23
+ detail?: Record<string, unknown>;
24
+ }
25
+ interface SwipeDeckHandle {
26
+ readonly currentIndex: number;
27
+ readonly currentSlides: SlideItem[];
28
+ addSlide: (slide: SlideItem, options?: SlideOptions) => void;
29
+ removeSlide: (id: string, options?: Pick<SlideOptions, "animate">) => void;
30
+ removeSlides: (ids: string[], options?: Pick<SlideOptions, "animate">) => void;
31
+ goTo: (index: number, options?: NavOptions) => void;
32
+ next: (options?: NavOptions) => void;
33
+ prev: (options?: NavOptions) => void;
34
+ setPeek: (index: number | null) => void;
35
+ }
36
+ interface SwipeDeckProps {
37
+ width?: number;
38
+ showDots?: boolean;
39
+ fade?: boolean;
40
+ dimOnDrag?: boolean;
41
+ maxDragRatio?: number;
42
+ dragDisabled?: boolean;
43
+ keyboardDisabled?: boolean;
44
+ /** Drag and nav direction. "y" uses scroll-boundary detection so card
45
+ * content can still scroll freely; nav only triggers when the scroll
46
+ * hits the top/bottom edge and the user continues pulling. Default: "x" */
47
+ navAxis?: "x" | "y";
48
+ dragDelayMs?: number;
49
+ /** Duration of the view transition and gesture fly-out in ms. Default: 360 */
50
+ transitionMs?: number;
51
+ onSlideChange?: (index: number) => void;
52
+ onError?: (error: SwipeDeckError) => void;
53
+ className?: string;
54
+ }
55
+ declare const SwipeDeck: react.ForwardRefExoticComponent<SwipeDeckProps & react.RefAttributes<SwipeDeckHandle>>;
56
+
57
+ export { type DragPermission, type NavOptions, type SlideItem, type SlideOptions, type SwipeDeckError, type SwipeDeckErrorCode, type SwipeDeckHandle, type SwipeDeckProps, SwipeDeck as default };