react-spring-carousel 2.0.19 → 3.0.0-beta-1.0.1

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/README.md CHANGED
@@ -1,54 +1,50 @@
1
- # react-spring-carousel
1
+ # React + TypeScript + Vite
2
2
 
3
- > A performant React carousel component powered by `react-spring` and `@use-gesture`.
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
4
 
5
- [![NPM](https://img.shields.io/npm/v/react-spring-carousel.svg)](https://www.npmjs.com/package/react-spring-carousel) [![NPM](https://img.shields.io/bundlephobia/minzip/react-spring-carousel)](https://img.shields.io/bundlephobia/minzip/react-spring-carousel)
5
+ Currently, two official plugins are available:
6
6
 
7
- ## Install
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
8
9
 
9
- ```bash
10
- // npm v7.x
11
- npm install --save react-spring-carousel
12
- ```
13
-
14
- ```bash
15
- // npm v6.x or less
16
- npm install --save react-spring react-spring-carousel
17
- ```
10
+ ## Expanding the ESLint configuration
18
11
 
19
- ```bash
20
- yarn add react-spring react-spring-carousel
21
- ```
22
-
23
- ## Usage
12
+ If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
24
13
 
25
- ```tsx
26
- import { useSpringCarousel } from 'react-spring-carousel'
14
+ - Configure the top-level `parserOptions` property like this:
27
15
 
28
- const { carouselFragment, slideToPrevItem, slideToNextItem } = useSpringCarousel({
29
- items: [
30
- {
31
- id: 'item-1',
32
- renderItem: <div>Item 1</div>,
33
- },
34
- {
35
- id: 'item-2',
36
- renderItem: <div>Item 2</div>,
16
+ ```js
17
+ export default tseslint.config({
18
+ languageOptions: {
19
+ // other options...
20
+ parserOptions: {
21
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
22
+ tsconfigRootDir: import.meta.dirname,
37
23
  },
38
- ],
24
+ },
39
25
  })
40
-
41
- return (
42
- <div>
43
- <button onClick={slideToPrevItem}>Prev item</button>
44
- <div>{carouselFragment}</div>
45
- <button onClick={slideToNextItem}>Next item</button>
46
- </div>
47
- )
48
26
  ```
49
27
 
50
- ## Official documentation
51
-
52
- For a complete overview of the library, please visit the official documentation.
53
-
54
- [Visit here](https://react-spring-carousel.emilianobucci.com)
28
+ - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29
+ - Optionally add `...tseslint.configs.stylisticTypeChecked`
30
+ - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31
+
32
+ ```js
33
+ // eslint.config.js
34
+ import react from 'eslint-plugin-react'
35
+
36
+ export default tseslint.config({
37
+ // Set the react version
38
+ settings: { react: { version: '18.3' } },
39
+ plugins: {
40
+ // Add the react plugin
41
+ react,
42
+ },
43
+ rules: {
44
+ // other rules...
45
+ // Enable its recommended rules
46
+ ...react.configs.recommended.rules,
47
+ ...react.configs['jsx-runtime'].rules,
48
+ },
49
+ })
50
+ ```
@@ -0,0 +1,106 @@
1
+ import { FullGestureState } from '@use-gesture/react';
2
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ declare type FixedSlideTypeProps = {
6
+ slideType?: "fixed";
7
+ scrollAmount?: never;
8
+ itemsPerSlide?: number;
9
+ scrollAmountType?: "group" | "slide";
10
+ };
11
+
12
+ declare type FluidSlideTypeProps = {
13
+ slideType?: "fluid";
14
+ scrollAmount?: number;
15
+ itemsPerSlide?: never;
16
+ scrollAmountType?: never;
17
+ };
18
+
19
+ declare type FreeScrollSlideTypeProps = {
20
+ slideType?: "freeScroll";
21
+ scrollAmount?: number;
22
+ itemsPerSlide?: never;
23
+ scrollAmountType?: never;
24
+ withLoop?: never;
25
+ };
26
+
27
+ declare type Item = {
28
+ id: string;
29
+ renderItem: ReactNode;
30
+ renderThumb?: ReactNode;
31
+ };
32
+
33
+ declare type OnDrag = Omit<FullGestureState<"drag">, "event"> & {
34
+ eventName: "onDrag";
35
+ slideActionType: SlideActionType;
36
+ };
37
+
38
+ declare type OnSlideChangeComplete = {
39
+ eventName: "onSlideChangeComplete";
40
+ slideDirection: SlideDirection;
41
+ sliceActionType: SlideActionType;
42
+ currentItem: {
43
+ index: number;
44
+ id: string;
45
+ startReached: boolean | undefined;
46
+ endReached: boolean | undefined;
47
+ };
48
+ };
49
+
50
+ declare type OnSlideStartChange = {
51
+ eventName: "onSlideStartChange";
52
+ slideDirection: SlideDirection;
53
+ sliceActionType: SlideActionType;
54
+ nextItem: {
55
+ index: number;
56
+ id: string;
57
+ startReached: boolean | undefined;
58
+ endReached: boolean | undefined;
59
+ };
60
+ };
61
+
62
+ declare type Props = {
63
+ init?: boolean;
64
+ slideType?: SlideType;
65
+ items: Item[];
66
+ withLoop?: boolean;
67
+ enableGestures?: boolean;
68
+ carouselAxis?: "x" | "y";
69
+ slideWhenDragThresholdIsReached?: boolean;
70
+ gutter?: number;
71
+ startEndGutter?: number;
72
+ fadeIn?: boolean;
73
+ } & (FixedSlideTypeProps | FluidSlideTypeProps | FreeScrollSlideTypeProps);
74
+
75
+ declare type SlideActionType = "drag" | "click";
76
+
77
+ declare type SlideDirection = "prev" | "next";
78
+
79
+ declare type SlideType = "fixed" | "fluid" | "freeScroll";
80
+
81
+ declare type SpringCarouselEvents = OnSlideStartChange | OnSlideChangeComplete | OnDrag;
82
+
83
+ declare type SpringCarouselEventsEventHandler = (props: SpringCarouselEvents) => void;
84
+
85
+ export declare function useSpringCarousel({ init, items: _items, slideType, scrollAmount: _scrollAmount, withLoop, enableGestures, carouselAxis, slideWhenDragThresholdIsReached, itemsPerSlide: _itemsPerSlide, scrollAmountType: _scrollAmountType, gutter, startEndGutter, fadeIn, }: Props): {
86
+ carouselFragment: JSX_2.Element;
87
+ useListenToCustomEvent: (eventHandler: SpringCarouselEventsEventHandler) => void;
88
+ slideToNextItem: () => void;
89
+ slideToPrevItem: () => void;
90
+ slideToIem: (id: string | number) => void;
91
+ handleThumbsContainerScroll: ({ getContainer, activeItem, updateTotalValue, }: {
92
+ activeItem: number;
93
+ getContainer(): HTMLElement | null;
94
+ updateTotalValue?(props: {
95
+ from: number;
96
+ to: number;
97
+ itemOutOfViewport: {
98
+ isOut: boolean;
99
+ direction: "start" | "end" | null;
100
+ };
101
+ }): number;
102
+ }) => void;
103
+ carouselId: string;
104
+ };
105
+
106
+ export { }