react-spring-carousel 2.0.19 → 3.0.0-beta-1.0.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.
Files changed (65) hide show
  1. package/.storybook/main.ts +17 -0
  2. package/.storybook/preview.ts +15 -0
  3. package/README.md +39 -43
  4. package/eslint.config.js +28 -0
  5. package/index.html +13 -0
  6. package/lib/events.ts +39 -0
  7. package/lib/index.tsx +980 -0
  8. package/lib/types.ts +44 -0
  9. package/lib/useEventsModule.ts +51 -0
  10. package/lib/utils.ts +42 -0
  11. package/lib/vite-env.d.ts +1 -0
  12. package/package.json +41 -99
  13. package/src/stories/Button.stories.ts +52 -0
  14. package/src/stories/Button.tsx +48 -0
  15. package/src/stories/Configure.mdx +364 -0
  16. package/src/stories/Main.stories.ts +14 -0
  17. package/src/stories/Main.tsx +87 -0
  18. package/src/stories/assets/accessibility.png +0 -0
  19. package/src/stories/assets/accessibility.svg +1 -0
  20. package/src/stories/assets/addon-library.png +0 -0
  21. package/src/stories/assets/assets.png +0 -0
  22. package/src/stories/assets/avif-test-image.avif +0 -0
  23. package/src/stories/assets/context.png +0 -0
  24. package/src/stories/assets/discord.svg +1 -0
  25. package/src/stories/assets/docs.png +0 -0
  26. package/src/stories/assets/figma-plugin.png +0 -0
  27. package/src/stories/assets/github.svg +1 -0
  28. package/src/stories/assets/share.png +0 -0
  29. package/src/stories/assets/styling.png +0 -0
  30. package/src/stories/assets/testing.png +0 -0
  31. package/src/stories/assets/theming.png +0 -0
  32. package/src/stories/assets/tutorials.svg +1 -0
  33. package/src/stories/assets/youtube.svg +1 -0
  34. package/src/stories/button.css +30 -0
  35. package/src/stories/main.css +37 -0
  36. package/src/storybook.global.styles.css +5 -0
  37. package/tsconfig.app.json +24 -0
  38. package/tsconfig.json +7 -0
  39. package/tsconfig.node.json +22 -0
  40. package/vite.config.ts +30 -0
  41. package/dist/cjs/index.js +0 -2
  42. package/dist/cjs/index.js.map +0 -1
  43. package/dist/esm/index.js +0 -2
  44. package/dist/esm/index.js.map +0 -1
  45. package/dist/esm/index2.js +0 -2
  46. package/dist/esm/index2.js.map +0 -1
  47. package/dist/esm/index3.js +0 -2
  48. package/dist/esm/index3.js.map +0 -1
  49. package/dist/esm/index4.js +0 -2
  50. package/dist/esm/index4.js.map +0 -1
  51. package/dist/esm/useThumbsModule-0944decf.js +0 -2
  52. package/dist/esm/useThumbsModule-0944decf.js.map +0 -1
  53. package/dist/types/index.d.ts +0 -2
  54. package/dist/types/modules/index.d.ts +0 -3
  55. package/dist/types/modules/useCustomEventsModule.d.ts +0 -5
  56. package/dist/types/modules/useFullscreenModule.d.ts +0 -13
  57. package/dist/types/modules/useThumbsModule.d.ts +0 -19
  58. package/dist/types/types/index.d.ts +0 -51
  59. package/dist/types/types/useSpringCarousel.d.ts +0 -124
  60. package/dist/types/types/useTransitionCarousel.d.ts +0 -39
  61. package/dist/types/useSpringCarousel/index.d.ts +0 -8
  62. package/dist/types/useTransitionCarousel/index.d.ts +0 -24
  63. package/dist/types/utils.d.ts +0 -5
  64. package/dist/umd/index.js +0 -2
  65. package/dist/umd/index.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5
+ addons: [
6
+ "@storybook/addon-onboarding",
7
+ "@storybook/addon-links",
8
+ "@storybook/addon-essentials",
9
+ "@chromatic-com/storybook",
10
+ "@storybook/addon-interactions",
11
+ ],
12
+ framework: {
13
+ name: "@storybook/react-vite",
14
+ options: {},
15
+ },
16
+ };
17
+ export default config;
@@ -0,0 +1,15 @@
1
+ import type { Preview } from "@storybook/react";
2
+ import "../src/storybook.global.styles.css";
3
+
4
+ const preview: Preview = {
5
+ parameters: {
6
+ controls: {
7
+ matchers: {
8
+ color: /(background|color)$/i,
9
+ date: /Date$/i,
10
+ },
11
+ },
12
+ },
13
+ };
14
+
15
+ export default preview;
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,28 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import reactHooks from "eslint-plugin-react-hooks";
4
+ import reactRefresh from "eslint-plugin-react-refresh";
5
+ import tseslint from "typescript-eslint";
6
+
7
+ export default tseslint.config(
8
+ { ignores: ["dist"] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ["**/*.{ts,tsx}"],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ "react-hooks": reactHooks,
18
+ "react-refresh": reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ "react-refresh/only-export-components": [
23
+ "warn",
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ }
28
+ );
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
package/lib/events.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { FullGestureState } from "@use-gesture/react";
2
+
3
+ export type SlideActionType = "drag" | "click";
4
+ export type SlideDirection = "prev" | "next";
5
+
6
+ export type OnDrag = Omit<FullGestureState<"drag">, "event"> & {
7
+ eventName: "onDrag";
8
+ slideActionType: SlideActionType;
9
+ };
10
+ type OnSlideStartChange = {
11
+ eventName: "onSlideStartChange";
12
+ slideDirection: SlideDirection;
13
+ sliceActionType: SlideActionType;
14
+ nextItem: {
15
+ index: number;
16
+ id: string;
17
+ startReached: boolean | undefined;
18
+ endReached: boolean | undefined;
19
+ };
20
+ };
21
+ type OnSlideChangeComplete = {
22
+ eventName: "onSlideChangeComplete";
23
+ slideDirection: SlideDirection;
24
+ sliceActionType: SlideActionType;
25
+ currentItem: {
26
+ index: number;
27
+ id: string;
28
+ startReached: boolean | undefined;
29
+ endReached: boolean | undefined;
30
+ };
31
+ };
32
+
33
+ export type SpringCarouselEvents =
34
+ | OnSlideStartChange
35
+ | OnSlideChangeComplete
36
+ | OnDrag;
37
+ export type SpringCarouselEventsEventHandler = (
38
+ props: SpringCarouselEvents
39
+ ) => void;