nexlide 1.0.4 → 1.1.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
@@ -2,7 +2,6 @@
2
2
  <img src="https://nexlide.netlify.app/assets/logo-full.png" width="420"/>
3
3
  </p>
4
4
 
5
-
6
5
  [![GitHub](https://img.shields.io/badge/GitHub-000000?style=flat-square&logo=github&logoColor=white)](https://github.com/ERPalmer/nexlide)
7
6
  [![npm version](https://img.shields.io/npm/v/nexlide?style=flat-square&logo=npm&logoColor=white&color=CB3837)](https://www.npmjs.com/package/nexlide)
8
7
  [![npm downloads](https://img.shields.io/npm/dm/nexlide?style=flat-square&logo=npm&logoColor=white&color=0baa45)](https://www.npmjs.com/package/nexlide)
@@ -12,35 +11,144 @@
12
11
  [![Tailwind CSS v4](https://img.shields.io/badge/Tailwind%20CSS-00bcff?style=flat-square&logo=tailwind-css&logoColor=white)](https://tailwindcss.com/)
13
12
  [![Framer Motion](https://img.shields.io/badge/Framer%20Motion-EF5DA8?style=flat-square&logo=framer&logoColor=white)](https://www.framer.com/motion/)
14
13
 
15
-
16
14
  # Nexlide
17
15
 
18
16
  A modern, lightweight, and fully customizable React carousel component built with **Framer Motion** for smooth animations and **Tailwind CSS** for flexible styling.
19
17
 
18
+ ---
20
19
 
21
20
  ## ✨ Features
22
21
 
23
- - Smooth slide transitions (fade, slide left/right/top/bottom)
24
- - Independent caption animations (title + description)
25
- - Responsive design
26
- - Lazy loading images
27
- - ARIA accessible
28
- - Dark mode compatible
29
- - No external CSS import required (uses Tailwind classes inline)
30
- - Others in development process
31
-
22
+ ### Core
23
+ - **Smooth slide transitions** with 10+ animation variants (fade, slide, zoom, bounce, flip)
24
+ - **Independent caption animations** with customizable delay (0.5s default) and duration (0.8s default)
25
+ - **Full RTL support** — mirrored navigation, reversed swipe, and proper layout for Arabic, Hebrew, Persian, and other RTL languages
26
+ - **Intelligent autoplay system** with direction control (`forward` | `reverse`) and smart pause behaviors
27
+ - **Advanced touch/swipe gestures** with Framer Motion — inertia scrolling and elastic snap-back
28
+ - **Accessibility first** ARIA labels, keyboard navigation, visible focus rings
29
+ - **Performance optimized** lazy loading, image optimizations (`decoding="async"`, `draggable=false`), clean event cleanup
30
+ - **Responsive design** with aspect ratio preservation (default 4:3, fully customizable)
31
+ - **Dark mode compatible** by default
32
+ - **Zero CSS imports** — uses Tailwind classes inline
33
+ - **Next.js App Router ready** with `'use client'` directive
34
+
35
+ ### 🆕 What's New in v1.1.0?
36
+
37
+ #### Enhanced Autoplay Control
38
+ - **`autoPlayDirection`** — Choose between `"forward"` (next slide) or `"reverse"` (previous slide) for autoplay progression
39
+ - **Smart pause triggers** — All default to `true` for optimal UX:
40
+ - `pauseOnHover` — Pauses when mouse enters the carousel
41
+ - `pauseOnFocus` — Pauses when carousel receives keyboard focus
42
+ - `pauseOnDrag` — Pauses during active swipe/drag interactions
43
+ - **Tab visibility awareness** — Autoplay automatically pauses when the page/tab is hidden and resumes when visible
44
+
45
+ #### Complete RTL Support
46
+ **`rtl` prop** — Enables full right-to-left mode with:
47
+ - Reversed swipe/drag direction (swipe left → next slide)
48
+ - Swapped navigation arrow positions and functions
49
+ - Default animation switches to `slideRight` (if not overridden)
50
+ - `dir="rtl"` attribute applied to root container
51
+ - Proper ARIA labels for arrows in RTL context
52
+ - Mirror-friendly pagination dots
53
+
54
+ #### Refined Animation System
55
+ - **`captionDuration`** — Fine-tune caption animation speed (default: `0.8` seconds)
56
+ - **Independent direction handling** — Slide animations automatically respect RTL and autoplay direction
57
+ - **Improved transition logic** — Better wrapping in infinite loop mode
58
+
59
+ #### Advanced Interaction
60
+ - **Framer Motion drag enhancements** — Inertia-based scrolling with elastic snap-back
61
+ - **Touch-optimized** — Removed legacy touch handlers for cleaner, more performant code
62
+ - **Visual polish** — Improved focus outlines and pointer-events handling
63
+
64
+ ---
32
65
 
33
66
  ## 🧩 Supports
34
67
 
35
- - Autoplay with configurable interval
36
- - Infinite loop
37
- - Touch swipe gestures (mobile-friendly)
38
- - Navigation arrows
39
- - Pagination dots
40
- - Multiple animation variants for slides and captions
41
- - Fully customizable styles via className props
42
- - Designed for seamless integration with **Next.js** (App Router) and any React project
43
-
68
+ ### Navigation & Controls
69
+ | Feature | Description |
70
+ |---------|-------------|
71
+ | ⬅️➡️ **Navigation arrows** | Fully customizable via `arrowClassName` |
72
+ | 🔘 **Pagination dots** | Active states with smooth transitions |
73
+ | ⌨️ **Keyboard navigation** | Arrow keys (auto-adapts to RTL) |
74
+ | 👆 **Touch swipe gestures** | Momentum-based with elastic snap-back |
75
+ | 🖱️ **Drag to slide** | Desktop support with spring physics |
76
+ | ♾️ **Infinite loop** | Seamless wrapping from last to first |
77
+
78
+ ### Autoplay System
79
+ | Feature | Options | Default |
80
+ |---------|---------|---------|
81
+ | ⏯️ **Interval control** | `autoPlayInterval` (ms) | `3000` |
82
+ | 🔄 **Direction control** 🆕 | `"forward"` \| `"reverse"` | `"forward"` |
83
+ | ⏸️ **Pause on hover** 🆕 | `pauseOnHover` | `true` |
84
+ | ⏸️ **Pause on focus** 🆕 | `pauseOnFocus` | `true` |
85
+ | ⏸️ **Pause on drag** 🆕 | `pauseOnDrag` | `true` |
86
+ | 📱 **Tab visibility** | Auto-pauses when hidden | Built-in |
87
+
88
+ ### Animation Library
89
+
90
+ #### Slide Animations (`animation` prop)
91
+ | Value | Effect |
92
+ |-------|--------|
93
+ | `slideLeft` | Enters from right, exits to left |
94
+ | `slideRight` | Enters from left, exits to right |
95
+ | `slideTop` | Enters from bottom, exits to top |
96
+ | `slideBottom` | Enters from top, exits to bottom |
97
+ | `fade` | Smooth fade in/out |
98
+ | `fadeIn` | Fade in only (no exit fade) |
99
+ | `zoomIn` | Zooms in from small to full |
100
+ | `zoomOut` | Zooms out from large to normal |
101
+ | `flip` | Flips like a card (horizontal axis) |
102
+ | `bounce` | Bounces in with elastic easing |
103
+
104
+ #### Caption Animations (`captionAnimation` prop)
105
+ - Supports all animation values above
106
+ - **Independent timing**:
107
+ - `captionDelay` (default: `0.5`s) — Delay before caption starts
108
+ - `captionDuration` 🆕 (default: `0.8`s) — Animation duration
109
+ - Perfect for creating layered reveal effects
110
+
111
+ ### Internationalization (RTL) 🆕
112
+ | Aspect | Behavior in RTL mode |
113
+ |--------|---------------------|
114
+ | **Swipe direction** | Swipe left → next, swipe right → previous |
115
+ | **Arrow positions** | Left arrow becomes "Next", right arrow becomes "Previous" |
116
+ | **Default animation** | Automatically switches to `slideRight` |
117
+ | **Layout** | `dir="rtl"` applied to root container |
118
+ | **Pagination** | Dots display in reverse order visually |
119
+ | **ARIA labels** | Automatically swap for arrows |
120
+
121
+ ### Customization API
122
+ | Prop | Targets |
123
+ |------|---------|
124
+ | `className` | Main container |
125
+ | `slideClassName` | Individual slide wrapper |
126
+ | `captionClassName` | Caption overlay |
127
+ | `arrowClassName` | Navigation arrows (both) |
128
+ | `paginationClassName` | Dots container |
129
+ | `dotClassName` | Individual pagination dots |
130
+
131
+ ### Performance Optimizations
132
+ - **Lazy loading** — Non-active slides use `loading="lazy"`
133
+ - **Image optimization** — `decoding="async"`, `draggable=false`
134
+ - **Clean architecture** — No legacy touch handlers
135
+ - **Smart re-renders** — Optimized with `useCallback` and `useMemo`
136
+
137
+ ### Accessibility
138
+ - **Visible focus ring** — Clear keyboard navigation indicators
139
+ - **ARIA labels** — Proper roles and descriptions
140
+ - **Full keyboard support** — Arrow keys, tab navigation
141
+ - **Live regions** — `aria-live="polite"` (off when autoplay active)
142
+ - **Focus management** — Container receives focus, maintains context
143
+
144
+ ### Technical Stack
145
+ - **React 18+** — Modern hooks architecture
146
+ - **Framer Motion** — Production-ready animations
147
+ - **Tailwind CSS v4** — Utility-first styling
148
+ - **TypeScript** — Full type definitions included
149
+ - **Next.js** — App Router compatible with `'use client'`
150
+
151
+ ---
44
152
 
45
153
  ## ⚙️ Installation
46
154
 
@@ -52,44 +160,59 @@ yarn add nexlide
52
160
  pnpm add nexlide
53
161
  ```
54
162
 
55
-
56
163
  ## 📦 Peer Dependencies
57
164
 
58
- These dependencies are usually already present in React/Next.js projects:
165
+ These dependencies are usually already present in React / Next.js projects:
166
+
167
+ - react (>=18)
168
+ - framer-motion (required)
59
169
 
60
- - react, react-dom
61
- - framer-motion
62
- - clsx, tailwind-merge, class-variance-authority
170
+ ### Optional (Styling Utilities)
63
171
 
172
+ Nexlide uses a `cn()` utility internally for className merging, inspired by the common Tailwind pattern.
64
173
 
65
- ## 🚀 Usage (Next.js App Router)
174
+ If you are customizing or extending the component and want to reuse this utility, it relies on:
175
+
176
+ - clsx
177
+ - tailwind-merge
178
+ - class-variance-authority
179
+
180
+ > ⚠️ These are already bundled within Nexlide and **do NOT need to be installed manually** unless you plan to use the same utility pattern in your own components.
181
+
182
+ ---
183
+
184
+ ## 🚀 Usage
185
+
186
+ ### Basic Example (Next.js App Router)
66
187
 
67
188
  The component is a **Client Component** — you **must** use it inside a file that starts with `'use client';`
68
189
 
69
190
  ```tsx
70
- 'use client' // ← Required in Next.js App Router
191
+ 'use client'; // ← Required in Next.js App Router
71
192
 
72
193
  import { Carousel } from 'nexlide'
73
194
 
74
- const slides = [
195
+ const carouselItems = [
196
+ {
197
+ imageUrl: "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200&q=75&fm=webp",
198
+ title: "Incredible Mountains",
199
+ description: "A breathtaking landscape at sunset",
200
+ },
75
201
  {
76
- imageUrl: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4',
77
- title: 'Mountain View',
78
- description: 'Breathtaking sunset over the peaks'
202
+ imageUrl: "https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=1200&q=75&fm=webp",
79
203
  },
80
204
  {
81
- imageUrl: 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e',
82
- title: 'Tropical Beach',
83
- description: 'Crystal clear waters and white sand'
205
+ imageUrl: "https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=1200&q=75&fm=webp",
206
+ title: "Vibrant Night City",
84
207
  },
85
- // add more...
86
- ]
208
+ // ...
209
+ ];
87
210
 
88
211
  export default function MyPage() {
89
212
  return (
90
213
  <div className="p-8">
91
214
  <Carousel
92
- items={slides}
215
+ items={carouselItems}
93
216
  autoPlay
94
217
  autoPlayInterval={5000}
95
218
  showPagination
@@ -104,6 +227,47 @@ export default function MyPage() {
104
227
  }
105
228
  ```
106
229
 
230
+ ### React Standard (No Next.js)
231
+
232
+ If you're using Pages Router, Create React App, or any other React setup without App Router restrictions, you can omit the `'use client';` directive.
233
+
234
+ ```tsx
235
+ import { Carousel } from 'nexlide'
236
+
237
+ // ... your component logic (same as above)
238
+ ```
239
+
240
+ ### Example usage in RTL context
241
+
242
+ For right-to-left languages (Arabic, Hebrew, Persian, etc.), enable the `rtl` prop to automatically adapt the carousel's behavior and layout.
243
+
244
+ ```tsx
245
+ 'use client';
246
+
247
+ import { Carousel } from 'nexlide'
248
+
249
+ const items = [ /* ... */ ];
250
+
251
+ export default function RTLPage() {
252
+ return (
253
+ <div className="p-8" dir="rtl"> {/* Optional: Set dir on a parent */}
254
+ <Carousel
255
+ rtl={true} // Enables full RTL support
256
+ items={items}
257
+ autoPlay
258
+ autoPlayInterval={4000}
259
+ animation="slideRight" // Recommended for RTL, but optional
260
+ showArrows
261
+ showPagination
262
+ />
263
+ </div>
264
+ );
265
+ }
266
+ ```
267
+
268
+ **Note:** If you are using a standard React setup without App Router restrictions, you can omit `'use client';`.
269
+
270
+ ---
107
271
 
108
272
  ## 🌀 Available Animations
109
273
 
@@ -124,27 +288,64 @@ Use `animation` for the image slide transition and `captionAnimation` for the ti
124
288
 
125
289
  All animations use smooth easing curves and can be combined freely (e.g., slideLeft for image + bounce for caption). Adjust timing with `captionDelay` prop if needed.
126
290
 
291
+ ---
127
292
 
128
293
  ## 🔧 Props
129
294
 
130
- | Prop | Type | Default | Description |
131
- |---------------------|----------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------|
132
- | `items` | `CarouselItem[]` | — | **Required**. Array of slides: `{ imageUrl: string, title: string, description: string }` |
133
- | `autoPlay` | `boolean` | `false` | Enable automatic slide transition |
134
- | `autoPlayInterval` | `number` | `3000` | Time (ms) between slides when autoPlay is true |
135
- | `showPagination` | `boolean` | `true` | Show pagination dots |
136
- | `showArrows` | `boolean` | `true` | Show previous/next arrows |
137
- | `infiniteLoop` | `boolean` | `true` | Enable infinite looping |
138
- | `className` | `string` | | Custom Tailwind classes for main container |
139
- | `slideClassName` | `string` | | Custom classes for each slide wrapper |
140
- | `captionClassName` | `string` | | Custom classes for caption (title + description) |
141
- | `arrowClassName` | `string` | | Custom classes for navigation arrows |
142
- | `paginationClassName`| `string` | | Custom classes for pagination container |
143
- | `dotClassName` | `string` | | Custom classes for each pagination dot |
144
- | `animation` | `"bounce" \| "fade" \| "fadeIn" \| "flip" \| "slideLeft" \| "slideRight" \| "slideTop" \| "slideBottom" \| "zoomIn" \| "zoomOut"` | `"slideLeft"` | Animation for image slide transition |
145
- | `captionAnimation` | `"bounce" \| "fade" \| "fadeIn" \| "flip" \| "slideLeft" \| "slideRight" \| "slideTop" \| "slideBottom" \| "zoomIn" \| "zoomOut"` | `"fade"` | Animation for caption appearance |
146
- `captionDelay` | `number` | `0.5` | Custom delay time in seconds |
295
+ | Prop | Type | Default | Description |
296
+ |-------------------|-----------|-------------|-----------------------------------------------------------------------------|
297
+ | `items` | `CarouselItem[]` | — **(required)** | Array of carousel items. Each item must include `imageUrl`, while `title` and `description` are optional. |
298
+ | `autoPlay` | `boolean` | `false` | Whether the carousel should automatically advance to the next slide. |
299
+ | `autoPlayInterval` | `number` | `3000` | Interval in milliseconds between automatic slides (only used when `autoPlay` is `true`). |
300
+ | `autoPlayDirection🆕` | `"forward" \| "reverse"` | `"forward"` | Direction of autoplay: `"forward"` (normal) or `"reverse"` (backward). |
301
+ | `infiniteLoop` | `boolean` | `true` | Enable infinite looping (goes back to first slide after last). |
302
+ | `pauseOnHover` 🆕 | `boolean` | `true` | Pause autoplay when the user hovers over the carousel. |
303
+ | `pauseOnFocus` 🆕 | `boolean` | `true` | Pause autoplay when the carousel receives focus (improves accessibility). |
304
+ | `pauseOnDrag` 🆕 | `boolean` | `true` | Pause autoplay while the user is actively dragging/swiping the carousel. |
305
+ | `showPagination` | `boolean` | `true` | Show/hide pagination dots. By default at the bottom. |
306
+ | `showArrows` | `boolean` | `true` | Show/hide navigation arrows on the sides. |
307
+ | `animation` | `AnimationType` | `"slideLeft"` | Animation type for slide transitions. |
308
+ | `rtl` 🆕 | `boolean` | `false` | Enable right-to-left (RTL) mode. Reverses swipe direction, arrow positions, autoplay direction (if not overridden), and default animation. Ideal for Arabic, Hebrew, etc. |
309
+ | `className` | `string` | | Additional Tailwind classes for the main carousel container. |
310
+ | `slideClassName` | `string` | | Additional classes for each slide wrapper. |
311
+ | `captionClassName` | `string` | | Additional classes for the caption overlay container. |
312
+ | `arrowClassName` | `string` | — | Additional classes for navigation arrows. |
313
+ | `paginationClassName` | `string` | — | Additional classes for the pagination dots container. |
314
+ | `dotClassName` | `string` | — | Additional classes for individual pagination dots. |
315
+ | `captionAnimation`| `AnimationType` | `"fade"` | Animation type for the caption appearance. |
316
+ | `captionDelay` | `number` | `0.5` | Delay in seconds before the caption animation starts (after slide appears). |
317
+ | `captionDuration` 🆕 | `number` | `0.8` | Duration in seconds of the caption animation itself. | |
318
+
319
+ #### Type: AnimationType
320
+
321
+ ```tsx
322
+ type AnimationType =
323
+ | "bounce" | "flip" | "fade" | "fadeIn"
324
+ | "slideLeft" | "slideRight" | "slideTop"
325
+ | "slideBottom" | "zoomIn" | "zoomOut";
326
+ ```
327
+
328
+ ### Important Notes
329
+
330
+ **Pause behavior**
331
+ All pause-related props (`pauseOnHover`, `pauseOnFocus`, `pauseOnDrag`) are only active when `autoPlay={true}`. If `autoPlay={false}`, they are ignored.
332
+
333
+ **RTL mode (`rtl` prop)**
334
+ When `rtl={true}`, the carousel automatically adapts for right-to-left languages (Arabic, Hebrew, Persian, etc.):
335
+
336
+ - **Swipe / Drag**: Direction is reversed
337
+ Swipe left → next slide
338
+ Swipe right → previous slide
339
+
340
+ - **Navigation arrows**: Positions and actions are mirrored
341
+ Left arrow becomes "Next"
342
+ Right arrow becomes "Previous"
343
+
344
+ - **Default animation**: Switches to `slideRight` (instead of `slideLeft`) when no `animation` prop is specified
345
+
346
+ - **Layout & direction**: `dir="rtl"` is applied to the root container, ensuring correct text flow, gradient direction, positioning, and CSS mirroring
147
347
 
348
+ ---
148
349
 
149
350
  ## 🛠️ Development
150
351
 
@@ -164,6 +365,7 @@ npm pack
164
365
  # Then in your test project: npm install ../nexlide/nexlide-1.0.0.tgz
165
366
  ```
166
367
 
368
+ ---
167
369
 
168
370
  ## 📄 License
169
371
 
@@ -1,25 +1,32 @@
1
- import { slideVariants } from "./lib/animations";
1
+ import * as React from "react";
2
+ import { animationVariants } from "./lib/animationVariants";
2
3
  interface CarouselItem {
3
4
  imageUrl: string;
4
- title: string;
5
- description: string;
5
+ title?: string;
6
+ description?: string;
6
7
  }
7
8
  interface CarouselProps {
8
9
  items: CarouselItem[];
9
10
  autoPlay?: boolean;
10
11
  autoPlayInterval?: number;
12
+ autoPlayDirection?: "forward" | "reverse";
13
+ infiniteLoop?: boolean;
14
+ rtl?: boolean;
15
+ pauseOnHover?: boolean;
16
+ pauseOnFocus?: boolean;
17
+ pauseOnDrag?: boolean;
11
18
  showPagination?: boolean;
12
19
  showArrows?: boolean;
13
- infiniteLoop?: boolean;
20
+ animation?: keyof typeof animationVariants;
21
+ captionAnimation?: keyof typeof animationVariants;
22
+ captionDelay?: number;
23
+ captionDuration?: number;
14
24
  className?: string;
15
25
  slideClassName?: string;
16
- captionClassName?: string;
17
26
  arrowClassName?: string;
18
27
  paginationClassName?: string;
19
28
  dotClassName?: string;
20
- animation?: keyof typeof slideVariants;
21
- captionAnimation?: keyof typeof slideVariants;
22
- captionDelay?: number;
29
+ captionClassName?: string;
23
30
  }
24
- export default function Carousel({ items, autoPlay, autoPlayInterval, showPagination, showArrows, infiniteLoop, className, slideClassName, captionClassName, arrowClassName, paginationClassName, dotClassName, animation, captionAnimation, captionDelay, }: CarouselProps): import("react/jsx-runtime").JSX.Element | null;
31
+ export default function Carousel(props: CarouselProps): React.ReactElement | null;
25
32
  export {};