@donotdev/components 0.0.21 → 0.0.22

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 (84) hide show
  1. package/dist/advanced/Carousel/Carousel.d.ts +21 -0
  2. package/dist/advanced/Carousel/Carousel.d.ts.map +1 -0
  3. package/dist/advanced/Carousel/Carousel.js +34 -0
  4. package/dist/advanced/Carousel/CarouselContent.d.ts +67 -0
  5. package/dist/advanced/Carousel/CarouselContent.d.ts.map +1 -0
  6. package/dist/advanced/Carousel/CarouselContent.js +529 -0
  7. package/dist/advanced/Carousel/CarouselSkeleton.d.ts +10 -0
  8. package/dist/advanced/Carousel/CarouselSkeleton.d.ts.map +1 -0
  9. package/dist/advanced/Carousel/CarouselSkeleton.js +51 -0
  10. package/dist/advanced/Carousel/index.d.ts +3 -0
  11. package/dist/advanced/Carousel/index.d.ts.map +1 -0
  12. package/dist/advanced/Carousel/index.js +2 -0
  13. package/dist/advanced/Code/CodeContent.js +2 -2
  14. package/dist/advanced/Crawl/Crawl.d.ts +44 -0
  15. package/dist/advanced/Crawl/Crawl.d.ts.map +1 -0
  16. package/dist/advanced/Crawl/Crawl.js +72 -0
  17. package/dist/advanced/Crawl/CrawlContent.d.ts +32 -0
  18. package/dist/advanced/Crawl/CrawlContent.d.ts.map +1 -0
  19. package/dist/advanced/Crawl/CrawlContent.js +118 -0
  20. package/dist/advanced/Crawl/index.d.ts +3 -0
  21. package/dist/advanced/Crawl/index.d.ts.map +1 -0
  22. package/dist/advanced/Crawl/index.js +3 -0
  23. package/dist/advanced/Crawl/utils/parseHtml.d.ts +72 -0
  24. package/dist/advanced/Crawl/utils/parseHtml.d.ts.map +1 -0
  25. package/dist/advanced/Crawl/utils/parseHtml.js +145 -0
  26. package/dist/advanced/Marquee/Marquee.d.ts +19 -0
  27. package/dist/advanced/Marquee/Marquee.d.ts.map +1 -0
  28. package/dist/advanced/Marquee/Marquee.js +35 -0
  29. package/dist/advanced/Marquee/MarqueeContent.d.ts +32 -0
  30. package/dist/advanced/Marquee/MarqueeContent.d.ts.map +1 -0
  31. package/dist/advanced/Marquee/MarqueeContent.js +192 -0
  32. package/dist/advanced/Marquee/MarqueeSkeleton.d.ts +10 -0
  33. package/dist/advanced/Marquee/MarqueeSkeleton.d.ts.map +1 -0
  34. package/dist/advanced/Marquee/MarqueeSkeleton.js +36 -0
  35. package/dist/advanced/Marquee/index.d.ts +3 -0
  36. package/dist/advanced/Marquee/index.d.ts.map +1 -0
  37. package/dist/advanced/Marquee/index.js +3 -0
  38. package/dist/advanced/Reveal/Reveal.d.ts +39 -0
  39. package/dist/advanced/Reveal/Reveal.d.ts.map +1 -0
  40. package/dist/advanced/Reveal/Reveal.js +69 -0
  41. package/dist/advanced/Reveal/index.d.ts +3 -0
  42. package/dist/advanced/Reveal/index.d.ts.map +1 -0
  43. package/dist/advanced/Reveal/index.js +3 -0
  44. package/dist/advanced/Roadmap/Roadmap.d.ts +15 -0
  45. package/dist/advanced/Roadmap/Roadmap.d.ts.map +1 -0
  46. package/dist/advanced/Roadmap/Roadmap.js +16 -0
  47. package/dist/advanced/Roadmap/RoadmapContent.d.ts +32 -0
  48. package/dist/advanced/Roadmap/RoadmapContent.d.ts.map +1 -0
  49. package/dist/advanced/Roadmap/RoadmapContent.js +61 -0
  50. package/dist/advanced/Roadmap/index.d.ts +4 -0
  51. package/dist/advanced/Roadmap/index.d.ts.map +1 -0
  52. package/dist/advanced/Roadmap/index.js +3 -0
  53. package/dist/advanced/SplitReveal/SplitReveal.d.ts +97 -0
  54. package/dist/advanced/SplitReveal/SplitReveal.d.ts.map +1 -0
  55. package/dist/advanced/SplitReveal/SplitReveal.js +43 -0
  56. package/dist/advanced/SplitReveal/index.d.ts +3 -0
  57. package/dist/advanced/SplitReveal/index.d.ts.map +1 -0
  58. package/dist/advanced/SplitReveal/index.js +2 -0
  59. package/dist/advanced/StackedCards/StackedCards.d.ts +19 -0
  60. package/dist/advanced/StackedCards/StackedCards.d.ts.map +1 -0
  61. package/dist/advanced/StackedCards/StackedCards.js +22 -0
  62. package/dist/advanced/StackedCards/StackedCardsContent.d.ts +43 -0
  63. package/dist/advanced/StackedCards/StackedCardsContent.d.ts.map +1 -0
  64. package/dist/advanced/StackedCards/StackedCardsContent.js +52 -0
  65. package/dist/advanced/StackedCards/index.d.ts +4 -0
  66. package/dist/advanced/StackedCards/index.d.ts.map +1 -0
  67. package/dist/advanced/StackedCards/index.js +3 -0
  68. package/dist/advanced/index.d.ts +14 -0
  69. package/dist/advanced/index.d.ts.map +1 -1
  70. package/dist/advanced/index.js +7 -0
  71. package/dist/atomic/Combobox/index.d.ts +3 -1
  72. package/dist/atomic/Combobox/index.d.ts.map +1 -1
  73. package/dist/atomic/Combobox/index.js +2 -2
  74. package/dist/atomic/CommandDialog/index.d.ts.map +1 -1
  75. package/dist/atomic/CommandDialog/index.js +1 -1
  76. package/dist/atomic/Dialog/index.d.ts.map +1 -1
  77. package/dist/atomic/Dialog/index.js +1 -1
  78. package/dist/atomic/Sheet/index.d.ts.map +1 -1
  79. package/dist/atomic/Sheet/index.js +1 -1
  80. package/dist/index.d.ts +14 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +7 -7
  83. package/dist/styles/index.css +1410 -111
  84. package/package.json +1 -1
@@ -0,0 +1,21 @@
1
+ export type { CarouselRef } from './CarouselContent';
2
+ import type { CarouselProps } from './CarouselContent';
3
+ export type { CarouselProps };
4
+ /**
5
+ * Premium Carousel Component with lazy loading built-in
6
+ *
7
+ * Features:
8
+ * - True infinite circular loop
9
+ * - Hardware-accelerated animations
10
+ * - Swipe/touch gestures
11
+ * - Autoplay with pause-on-hover
12
+ * - Lazy loading by default
13
+ * - Full accessibility support
14
+ * - SSR/CSR compatible
15
+ * - Responsive and RTL-aware
16
+ *
17
+ * Simply pass items and renderItem - everything else is handled automatically!
18
+ */
19
+ declare const Carousel: (props: CarouselProps) => import("react/jsx-runtime").JSX.Element;
20
+ export default Carousel;
21
+ //# sourceMappingURL=Carousel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/Carousel.tsx"],"names":[],"mappings":"AAgBA,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,CAAC;AAK9B;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAgBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // packages/components/src/advanced/Carousel/Carousel.tsx
3
+ /**
4
+ * @fileoverview Carousel Component
5
+ * @description Premium carousel component with lazy loading built-in. Features true infinite circular loop, hardware-accelerated animations, swipe/touch gestures, autoplay with pause-on-hover, and lazy loading by default.
6
+ *
7
+ * @version 0.0.1
8
+ * @since 0.0.1
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ import { Suspense, lazy } from 'react';
12
+ import CarouselSkeleton from './CarouselSkeleton';
13
+ // Lazy load the actual carousel implementation
14
+ const CarouselContent = lazy(() => import('./CarouselContent'));
15
+ /**
16
+ * Premium Carousel Component with lazy loading built-in
17
+ *
18
+ * Features:
19
+ * - True infinite circular loop
20
+ * - Hardware-accelerated animations
21
+ * - Swipe/touch gestures
22
+ * - Autoplay with pause-on-hover
23
+ * - Lazy loading by default
24
+ * - Full accessibility support
25
+ * - SSR/CSR compatible
26
+ * - Responsive and RTL-aware
27
+ *
28
+ * Simply pass items and renderItem - everything else is handled automatically!
29
+ */
30
+ const Carousel = (props) => {
31
+ const { showArrows = true, showDots = false, showProgress = true } = props;
32
+ return (_jsx(Suspense, { fallback: _jsx(CarouselSkeleton, { showArrows: showArrows, showDots: showDots, showProgress: showProgress }), children: _jsx(CarouselContent, { ...props }) }));
33
+ };
34
+ export default Carousel;
@@ -0,0 +1,67 @@
1
+ import { type ReactNode, type ReactElement } from 'react';
2
+ /**
3
+ * Carousel props interface
4
+ *
5
+ * @version 0.0.1
6
+ * @since 0.0.1
7
+ * @author AMBROISE PARK Consulting
8
+ */
9
+ export interface CarouselProps<T = unknown> {
10
+ /** Array of data items to render */
11
+ items: T[];
12
+ /** Function to render each item */
13
+ renderItem: (item: T, index: number, isActive: boolean) => ReactNode;
14
+ /** Optional className for the container */
15
+ className?: string;
16
+ /** Optional className for individual slides */
17
+ slideClassName?: string;
18
+ /** Whether to show navigation arrows */
19
+ showArrows?: boolean;
20
+ /** Whether to show scroll indicators (dots) */
21
+ showDots?: boolean;
22
+ /** Whether to show progress bar */
23
+ showProgress?: boolean;
24
+ /** Whether to enable autoplay */
25
+ autoplay?: boolean;
26
+ /** Autoplay interval in milliseconds */
27
+ autoplayInterval?: number;
28
+ /** Transition type */
29
+ transition?: 'slide' | 'fade' | 'scale' | 'parallax';
30
+ /** Whether to enable infinite loop */
31
+ infinite?: boolean;
32
+ /** Number of slides to show at once */
33
+ slidesToShow?: number;
34
+ /** Whether to enable swipe gestures */
35
+ swipeable?: boolean;
36
+ /** Whether to enable momentum scrolling */
37
+ momentum?: boolean;
38
+ /** Callback when active slide changes */
39
+ onActiveChange?: (index: number) => void;
40
+ /** Callback when slide is clicked */
41
+ onSlideClick?: (item: T, index: number) => void;
42
+ /** Optional unique key extractor */
43
+ keyExtractor?: (item: T, index: number) => string | number;
44
+ /** Accessibility label */
45
+ 'aria-label'?: string;
46
+ /** Whether to pause autoplay on hover */
47
+ pauseOnHover?: boolean;
48
+ /** Whether to pause autoplay when not visible */
49
+ pauseOnInvisible?: boolean;
50
+ /** Whether to show play/pause button (only when autoplay is enabled) */
51
+ showPlayPause?: boolean;
52
+ /** Whether to enable lazy loading */
53
+ lazy?: boolean;
54
+ /** Preload distance for lazy loading */
55
+ preloadDistance?: number;
56
+ }
57
+ export interface CarouselRef {
58
+ goToSlide: (index: number) => void;
59
+ goToNext: () => void;
60
+ goToPrevious: () => void;
61
+ play: () => void;
62
+ pause: () => void;
63
+ getCurrentIndex: () => number;
64
+ }
65
+ declare const Carousel: <T = unknown>(props: CarouselProps<T>) => ReactElement;
66
+ export default Carousel;
67
+ //# sourceMappingURL=CarouselContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarouselContent.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/CarouselContent.tsx"],"names":[],"mappings":"AAYA,OAAO,EAML,KAAK,SAAS,EAGd,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAQf;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,oCAAoC;IACpC,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,mCAAmC;IACnC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IAErE,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,mCAAmC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,sBAAsB;IACtB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IAErD,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC,qCAAqC;IACrC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhD,oCAAoC;IACpC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;IAE3D,0BAA0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yCAAyC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,eAAe,EAAE,MAAM,MAAM,CAAC;CAC/B;AAswBD,QAAA,MAAM,QAAQ,EAA8B,CAAC,CAAC,GAAG,OAAO,EACtD,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,YAAY,CAAC;AAGlB,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,529 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // packages/components/src/advanced/Carousel/CarouselContent.tsx
3
+ /**
4
+ * @fileoverview Carousel Component
5
+ * @description Premium carousel component with advanced features including autoplay, transitions, and accessibility
6
+ *
7
+ * @version 0.0.1
8
+ * @since 0.0.1
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ import { ChevronLeft, ChevronRight, Play, Pause } from 'lucide-react';
12
+ import { useRef, useState, useEffect, useCallback, useMemo, memo, } from 'react';
13
+ import { cn } from '../../utils/helpers';
14
+ import { observeElement } from '../../utils/intersectionObserver';
15
+ import { addEventListener } from '../../utils/eventListener';
16
+ import { isRTLLanguage } from '../../utils/rtl';
17
+ import Stack from '../../atomic/Stack';
18
+ function CarouselComponent({ items, renderItem, className, slideClassName, showArrows = true, showDots = false, showProgress = true, autoplay = true, autoplayInterval = 5000, transition = 'slide', infinite = true, slidesToShow = 1, swipeable = true, momentum = true, onActiveChange, onSlideClick, keyExtractor, 'aria-label': ariaLabel = 'Premium carousel', pauseOnHover = true, pauseOnInvisible = true, showPlayPause = true, lazy = false, preloadDistance = 1, }) {
19
+ const containerRef = useRef(null);
20
+ const trackRef = useRef(null);
21
+ const [currentIndex, setCurrentIndex] = useState(0);
22
+ const [isPlaying, setIsPlaying] = useState(autoplay);
23
+ const [isPaused, setIsPaused] = useState(false);
24
+ const [isVisible, setIsVisible] = useState(true);
25
+ const [dragState, setDragState] = useState({
26
+ isDragging: false,
27
+ startX: 0,
28
+ currentX: 0,
29
+ startTime: 0,
30
+ velocity: 0,
31
+ });
32
+ const autoplayRef = useRef(null);
33
+ const rafRef = useRef(null);
34
+ const transitionTimerRef = useRef(null);
35
+ // State Machine (SSR safe, performant)
36
+ const [state, setState] = useState('idle');
37
+ // Check for reduced motion preference (SSR-safe)
38
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
39
+ useEffect(() => {
40
+ if (typeof window === 'undefined')
41
+ return;
42
+ const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
43
+ setPrefersReducedMotion(mediaQuery.matches);
44
+ const handleChange = (e) => {
45
+ setPrefersReducedMotion(e.matches);
46
+ };
47
+ return addEventListener(mediaQuery, 'change', handleChange);
48
+ }, []);
49
+ // Spring physics for momentum scrolling
50
+ const springConfig = useMemo(() => ({
51
+ tension: 0.3,
52
+ friction: 0.8,
53
+ mass: 1.0,
54
+ }), []);
55
+ // Enhanced infinite loop with true circular DOM structure
56
+ const circularItems = useMemo(() => {
57
+ if (!infinite || items.length <= slidesToShow)
58
+ return items;
59
+ const cloneCount = Math.max(slidesToShow, 2);
60
+ const beforeClones = items.slice(-cloneCount);
61
+ const afterClones = items.slice(0, cloneCount);
62
+ return [...beforeClones, ...items, ...afterClones];
63
+ }, [items, infinite, slidesToShow]);
64
+ // Calculate slide width based on slidesToShow
65
+ const slideWidth = useMemo(() => {
66
+ return 100 / slidesToShow;
67
+ }, [slidesToShow]);
68
+ // Get the real index (accounting for clones)
69
+ const getRealIndex = useCallback((index) => {
70
+ if (!infinite)
71
+ return index;
72
+ const cloneCount = Math.max(slidesToShow, 2);
73
+ return ((((index - cloneCount) % items.length) + items.length) % items.length);
74
+ }, [infinite, items.length, slidesToShow]);
75
+ // Position Validation (SSR safe, performant)
76
+ const validateClonePosition = useCallback((index) => {
77
+ if (!infinite)
78
+ return true;
79
+ const cloneCount = Math.max(slidesToShow, 2);
80
+ const maxValidIndex = items.length + cloneCount - 1;
81
+ const minValidIndex = cloneCount;
82
+ return index >= minValidIndex && index <= maxValidIndex;
83
+ }, [infinite, items.length, slidesToShow]);
84
+ // Spring-based momentum animation
85
+ const animateWithSpring = useCallback((track, targetTranslateX, velocity = 0) => {
86
+ if (!momentum)
87
+ return;
88
+ let currentTranslateX = parseFloat(track.style.transform.replace('translateX(', '').replace('%)', '')) || 0;
89
+ let currentVelocity = velocity;
90
+ const startTime = Date.now();
91
+ const animate = () => {
92
+ const elapsed = Date.now() - startTime;
93
+ const deltaTime = elapsed / 1000;
94
+ const displacement = currentTranslateX - targetTranslateX;
95
+ const springForce = -springConfig.tension * displacement;
96
+ const dampingForce = -springConfig.friction * currentVelocity;
97
+ const totalForce = springForce + dampingForce;
98
+ const acceleration = totalForce / springConfig.mass;
99
+ currentVelocity += acceleration * deltaTime;
100
+ currentTranslateX += currentVelocity * deltaTime;
101
+ track.style.transform = `translateX(${currentTranslateX}%)`;
102
+ if (Math.abs(displacement) > 0.1 || Math.abs(currentVelocity) > 0.1) {
103
+ rafRef.current = requestAnimationFrame(animate);
104
+ }
105
+ else {
106
+ track.style.transform = `translateX(${targetTranslateX}%)`;
107
+ track.style.transition = 'none';
108
+ rafRef.current = null;
109
+ }
110
+ };
111
+ if (rafRef.current !== null)
112
+ cancelAnimationFrame(rafRef.current);
113
+ rafRef.current = requestAnimationFrame(animate);
114
+ }, [momentum, springConfig]);
115
+ // Apply transition effects based on transition type
116
+ const applyTransitionEffect = useCallback((track, translateX, duration) => {
117
+ switch (transition) {
118
+ case 'fade': {
119
+ track.style.transition = `opacity ${duration} ease-in-out`;
120
+ track.style.opacity = '0';
121
+ const fadeDuration = parseInt(duration, 10) || 300;
122
+ if (transitionTimerRef.current)
123
+ clearTimeout(transitionTimerRef.current);
124
+ transitionTimerRef.current = setTimeout(() => {
125
+ transitionTimerRef.current = null;
126
+ track.style.transform = `translateX(${translateX}%)`;
127
+ track.style.opacity = '1';
128
+ }, fadeDuration / 2);
129
+ break;
130
+ }
131
+ case 'scale': {
132
+ track.style.transition = `transform ${duration} cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
133
+ track.style.transform = `translateX(${translateX}%) scale(0.95)`;
134
+ const scaleDuration = parseInt(duration, 10) || 300;
135
+ if (transitionTimerRef.current)
136
+ clearTimeout(transitionTimerRef.current);
137
+ transitionTimerRef.current = setTimeout(() => {
138
+ transitionTimerRef.current = null;
139
+ track.style.transform = `translateX(${translateX}%) scale(1)`;
140
+ }, scaleDuration / 2);
141
+ break;
142
+ }
143
+ case 'parallax':
144
+ track.style.transition = `transform ${duration} cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
145
+ track.style.transform = `translateX(${translateX}%)`;
146
+ const slides = track.querySelectorAll('[role="group"]');
147
+ slides.forEach((slide, index) => {
148
+ const slideElement = slide;
149
+ const parallaxOffset = (index - Math.abs(translateX) / slideWidth) * 0.1;
150
+ slideElement.style.transform = `translateX(${parallaxOffset}%)`;
151
+ });
152
+ break;
153
+ default:
154
+ track.style.transition = `transform ${duration} cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
155
+ track.style.transform = `translateX(${translateX}%)`;
156
+ break;
157
+ }
158
+ }, [transition, slideWidth]);
159
+ // Smooth transition to index with proper circular handling
160
+ const goToSlide = useCallback((targetIndex, immediate = false) => {
161
+ if (state !== 'idle' && !immediate)
162
+ return;
163
+ const track = trackRef.current;
164
+ if (!track)
165
+ return;
166
+ let actualIndex = targetIndex;
167
+ if (infinite) {
168
+ const cloneCount = Math.max(slidesToShow, 2);
169
+ actualIndex = targetIndex + cloneCount;
170
+ if (targetIndex >= items.length) {
171
+ actualIndex = cloneCount + (targetIndex % items.length);
172
+ }
173
+ else if (targetIndex < 0) {
174
+ actualIndex = cloneCount + items.length + targetIndex;
175
+ }
176
+ }
177
+ const translateX = -(actualIndex * slideWidth);
178
+ const duration = immediate || prefersReducedMotion ? '0ms' : '300ms';
179
+ if (!immediate)
180
+ setState('transitioning');
181
+ applyTransitionEffect(track, translateX, duration);
182
+ const newIndex = getRealIndex(actualIndex);
183
+ setCurrentIndex(newIndex);
184
+ onActiveChange?.(newIndex);
185
+ if (infinite && !immediate && validateClonePosition(actualIndex)) {
186
+ const cloneCount = Math.max(slidesToShow, 2);
187
+ const needsReset = actualIndex <= cloneCount - 1 ||
188
+ actualIndex >= items.length + cloneCount;
189
+ if (needsReset) {
190
+ track.dataset.needsReset = 'true';
191
+ track.dataset.resetIndex =
192
+ actualIndex <= cloneCount - 1
193
+ ? (items.length + cloneCount - 1).toString()
194
+ : cloneCount.toString();
195
+ }
196
+ }
197
+ }, [
198
+ infinite,
199
+ items.length,
200
+ slideWidth,
201
+ slidesToShow,
202
+ getRealIndex,
203
+ onActiveChange,
204
+ prefersReducedMotion,
205
+ state,
206
+ validateClonePosition,
207
+ applyTransitionEffect,
208
+ ]);
209
+ const goToNext = useCallback(() => {
210
+ goToSlide(currentIndex + 1);
211
+ }, [currentIndex, goToSlide]);
212
+ const goToPrevious = useCallback(() => {
213
+ goToSlide(currentIndex - 1);
214
+ }, [currentIndex, goToSlide]);
215
+ const play = useCallback(() => {
216
+ setIsPlaying(true);
217
+ }, []);
218
+ const pause = useCallback(() => {
219
+ setIsPlaying(false);
220
+ }, []);
221
+ // Autoplay functionality
222
+ useEffect(() => {
223
+ if (!isPlaying || isPaused || !isVisible || items.length <= 1)
224
+ return;
225
+ autoplayRef.current = setTimeout(() => {
226
+ goToNext();
227
+ }, autoplayInterval);
228
+ return () => {
229
+ if (autoplayRef.current) {
230
+ clearTimeout(autoplayRef.current);
231
+ }
232
+ };
233
+ }, [
234
+ isPlaying,
235
+ isPaused,
236
+ isVisible,
237
+ currentIndex,
238
+ goToNext,
239
+ autoplayInterval,
240
+ items.length,
241
+ ]);
242
+ // Visibility observer for smart pausing (SSR-safe)
243
+ useEffect(() => {
244
+ if (!pauseOnInvisible || !containerRef.current)
245
+ return;
246
+ const cleanup = observeElement(containerRef.current, (entry) => setIsVisible(entry.isIntersecting), { threshold: 0.1 });
247
+ return cleanup;
248
+ }, [pauseOnInvisible]);
249
+ // Cleanup rAF and transition timers on unmount
250
+ useEffect(() => {
251
+ return () => {
252
+ if (rafRef.current !== null) {
253
+ cancelAnimationFrame(rafRef.current);
254
+ rafRef.current = null;
255
+ }
256
+ if (transitionTimerRef.current !== null) {
257
+ clearTimeout(transitionTimerRef.current);
258
+ transitionTimerRef.current = null;
259
+ }
260
+ };
261
+ }, []);
262
+ // Lazy loading logic
263
+ const shouldLoadSlide = useCallback((index) => {
264
+ if (!lazy)
265
+ return true;
266
+ const distance = Math.abs(index - currentIndex);
267
+ return distance <= preloadDistance;
268
+ }, [lazy, currentIndex, preloadDistance]);
269
+ // Touch/swipe handling with momentum
270
+ const handleTouchStart = useCallback((e) => {
271
+ if (!swipeable || state !== 'idle')
272
+ return;
273
+ const touch = e.touches[0];
274
+ if (!touch)
275
+ return;
276
+ setDragState({
277
+ isDragging: true,
278
+ startX: touch.clientX,
279
+ currentX: touch.clientX,
280
+ startTime: Date.now(),
281
+ velocity: 0,
282
+ });
283
+ }, [swipeable, state]);
284
+ const handleTouchMove = useCallback((e) => {
285
+ if (!dragState.isDragging)
286
+ return;
287
+ const touch = e.touches[0];
288
+ if (!touch)
289
+ return;
290
+ const deltaX = touch.clientX - dragState.startX;
291
+ const deltaTime = Date.now() - dragState.startTime;
292
+ const velocity = deltaTime > 0 ? deltaX / deltaTime : 0;
293
+ const track = trackRef.current;
294
+ if (track && Math.abs(deltaX) > 10) {
295
+ e.preventDefault();
296
+ const cloneOffset = infinite ? Math.max(slidesToShow, 2) : 0;
297
+ const currentTranslate = -((currentIndex + cloneOffset) * slideWidth);
298
+ const dragPercent = (deltaX / (containerRef.current?.clientWidth || 1)) * 100;
299
+ const resistance = Math.min(Math.abs(deltaX) / 200, 0.8);
300
+ const adjustedDragPercent = dragPercent * (1 - resistance);
301
+ track.style.transition = 'none';
302
+ track.style.transform = `translateX(${currentTranslate + adjustedDragPercent}%)`;
303
+ }
304
+ setDragState((prev) => ({
305
+ ...prev,
306
+ currentX: touch.clientX,
307
+ velocity,
308
+ }));
309
+ }, [
310
+ dragState.isDragging,
311
+ dragState.startX,
312
+ dragState.startTime,
313
+ currentIndex,
314
+ slideWidth,
315
+ infinite,
316
+ slidesToShow,
317
+ ]);
318
+ const handleTouchEnd = useCallback(() => {
319
+ if (!dragState.isDragging)
320
+ return;
321
+ const deltaX = dragState.currentX - dragState.startX;
322
+ const velocity = dragState.velocity;
323
+ const threshold = 50;
324
+ if (momentum && Math.abs(velocity) > 0.5) {
325
+ const track = trackRef.current;
326
+ if (track) {
327
+ const targetIndex = velocity > 0 ? currentIndex - 1 : currentIndex + 1;
328
+ const targetTranslateX = -(targetIndex * slideWidth);
329
+ animateWithSpring(track, targetTranslateX, velocity * 100);
330
+ goToSlide(targetIndex, true);
331
+ }
332
+ }
333
+ else if (Math.abs(deltaX) > threshold) {
334
+ if (deltaX > 0) {
335
+ goToPrevious();
336
+ }
337
+ else {
338
+ goToNext();
339
+ }
340
+ }
341
+ else {
342
+ const track = trackRef.current;
343
+ if (track && momentum) {
344
+ const targetTranslateX = -(currentIndex * slideWidth);
345
+ animateWithSpring(track, targetTranslateX, velocity * 100);
346
+ }
347
+ else {
348
+ goToSlide(currentIndex, true);
349
+ }
350
+ }
351
+ setDragState({
352
+ isDragging: false,
353
+ startX: 0,
354
+ currentX: 0,
355
+ startTime: 0,
356
+ velocity: 0,
357
+ });
358
+ }, [
359
+ dragState,
360
+ momentum,
361
+ goToNext,
362
+ goToPrevious,
363
+ goToSlide,
364
+ currentIndex,
365
+ animateWithSpring,
366
+ slideWidth,
367
+ ]);
368
+ // Transition Events (SSR safe, performant)
369
+ const handleTransitionEnd = useCallback(() => {
370
+ setState('idle');
371
+ const track = trackRef.current;
372
+ if (track?.dataset.needsReset === 'true') {
373
+ const resetIndex = parseInt(track.dataset.resetIndex || '0');
374
+ track.style.transition = 'none';
375
+ track.style.transform = `translateX(-${resetIndex * slideWidth}%)`;
376
+ delete track.dataset.needsReset;
377
+ delete track.dataset.resetIndex;
378
+ }
379
+ }, [slideWidth]);
380
+ // Keyboard navigation
381
+ const handleKeyDown = useCallback((e) => {
382
+ const isRTL = isRTLLanguage();
383
+ switch (e.key) {
384
+ case 'ArrowLeft':
385
+ e.preventDefault();
386
+ isRTL ? goToNext() : goToPrevious();
387
+ break;
388
+ case 'ArrowRight':
389
+ e.preventDefault();
390
+ isRTL ? goToPrevious() : goToNext();
391
+ break;
392
+ case 'Home':
393
+ e.preventDefault();
394
+ goToSlide(0);
395
+ break;
396
+ case 'End':
397
+ e.preventDefault();
398
+ goToSlide(items.length - 1);
399
+ break;
400
+ case ' ':
401
+ e.preventDefault();
402
+ isPlaying ? pause() : play();
403
+ break;
404
+ }
405
+ }, [goToNext, goToPrevious, goToSlide, items.length, isPlaying, play, pause]);
406
+ // Early return for empty items — placed after all hooks to satisfy Rules of Hooks
407
+ if (!items || items.length === 0) {
408
+ return (_jsx(Stack, { align: "center", justify: "center", className: cn('dndev-relative', className), children: _jsx("div", { style: { color: 'var(--muted-foreground)' }, children: "No items to display" }) }));
409
+ }
410
+ return (_jsxs("div", { ref: containerRef, className: cn('dndev-relative dndev-overflow-hidden', className), onMouseEnter: () => pauseOnHover && setIsPaused(true), onMouseLeave: () => pauseOnHover && setIsPaused(false), onKeyDown: handleKeyDown, tabIndex: 0, role: "region", "aria-label": ariaLabel, "aria-live": "polite", children: [_jsx("div", { className: "dndev-overflow-hidden", children: _jsx("div", { ref: trackRef, className: cn('dndev-flex', dragState.isDragging && 'dndev-pointer-events-none', state === 'transitioning' && 'dndev-pointer-events-none'), style: {
411
+ cursor: dragState.isDragging ? 'grabbing' : undefined,
412
+ }, onTransitionEnd: handleTransitionEnd, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, children: circularItems.map((item, index) => {
413
+ const realIndex = getRealIndex(index);
414
+ const isActive = realIndex === currentIndex;
415
+ const shouldLoad = shouldLoadSlide(realIndex);
416
+ return (_jsx("div", { className: cn('dndev-flex-shrink-0', slideClassName), style: {
417
+ width: `${slideWidth}%`,
418
+ opacity: shouldLoad ? 1 : 0,
419
+ }, role: "group", "aria-roledescription": "slide", "aria-label": `Slide ${realIndex + 1} of ${items.length}`, onClick: () => onSlideClick?.(item, realIndex), children: shouldLoad && renderItem(item, realIndex, isActive) }, keyExtractor
420
+ ? keyExtractor(item, realIndex)
421
+ : `${realIndex}-${index}`));
422
+ }) }) }), showArrows && items.length > 1 && (_jsxs(_Fragment, { children: [_jsx("button", { className: "dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center", style: {
423
+ insetInlineStart: '1rem',
424
+ top: '50%',
425
+ transform: 'translateY(-50%)',
426
+ width: '2.5rem',
427
+ height: '2.5rem',
428
+ opacity: 0,
429
+ transition: 'opacity var(--dur-normal)',
430
+ borderRadius: '9999px',
431
+ backgroundColor: 'rgb(from var(--background) r g b / 0.8)',
432
+ border: '1px solid var(--border)',
433
+ }, onMouseEnter: (e) => {
434
+ e.currentTarget.style.backgroundColor =
435
+ 'rgb(from var(--background) r g b / 0.9)';
436
+ e.currentTarget.style.opacity = '1';
437
+ }, onMouseLeave: (e) => {
438
+ e.currentTarget.style.backgroundColor =
439
+ 'rgb(from var(--background) r g b / 0.8)';
440
+ }, onClick: goToPrevious, "aria-label": "Previous slide", children: _jsx(ChevronLeft, { style: {
441
+ width: 'var(--icon-md)',
442
+ height: 'var(--icon-md)',
443
+ color: 'var(--foreground)',
444
+ } }) }), _jsx("button", { className: "dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center", style: {
445
+ insetInlineEnd: '1rem',
446
+ top: '50%',
447
+ transform: 'translateY(-50%)',
448
+ width: '2.5rem',
449
+ height: '2.5rem',
450
+ opacity: 0,
451
+ transition: 'opacity var(--dur-normal)',
452
+ borderRadius: '9999px',
453
+ backgroundColor: 'rgb(from var(--background) r g b / 0.8)',
454
+ border: '1px solid var(--border)',
455
+ }, onMouseEnter: (e) => {
456
+ e.currentTarget.style.backgroundColor =
457
+ 'rgb(from var(--background) r g b / 0.9)';
458
+ e.currentTarget.style.opacity = '1';
459
+ }, onMouseLeave: (e) => {
460
+ e.currentTarget.style.backgroundColor =
461
+ 'rgb(from var(--background) r g b / 0.8)';
462
+ }, onClick: goToNext, "aria-label": "Next slide", children: _jsx(ChevronRight, { style: {
463
+ width: 'var(--icon-md)',
464
+ height: 'var(--icon-md)',
465
+ color: 'var(--foreground)',
466
+ } }) })] })), autoplay && showPlayPause && (_jsx("button", { className: "dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center", style: {
467
+ insetBlockStart: 'var(--gap-md)',
468
+ insetInlineEnd: 'var(--gap-md)',
469
+ width: '2rem',
470
+ height: '2rem',
471
+ opacity: 0,
472
+ transition: 'opacity var(--dur-normal)',
473
+ borderRadius: '9999px',
474
+ backgroundColor: 'rgb(from var(--background) r g b / 0.8)',
475
+ border: '1px solid var(--border)',
476
+ }, onMouseEnter: (e) => {
477
+ e.currentTarget.style.backgroundColor =
478
+ 'rgb(from var(--background) r g b / 0.9)';
479
+ e.currentTarget.style.opacity = '1';
480
+ }, onMouseLeave: (e) => {
481
+ e.currentTarget.style.backgroundColor =
482
+ 'rgb(from var(--background) r g b / 0.8)';
483
+ }, onClick: () => (isPlaying ? pause() : play()), "aria-label": isPlaying ? 'Pause carousel' : 'Play carousel', children: isPlaying ? (_jsx(Pause, { style: {
484
+ width: 'var(--icon-md)',
485
+ height: 'var(--icon-md)',
486
+ color: 'var(--foreground)',
487
+ } })) : (_jsx(Play, { style: {
488
+ width: 'var(--icon-md)',
489
+ height: 'var(--icon-md)',
490
+ color: 'var(--foreground)',
491
+ } })) })), showDots && items.length > 1 && (_jsx("div", { className: "dndev-absolute dndev-flex dndev-gap-sm dndev-z-breadcrumbs", style: {
492
+ bottom: '1rem',
493
+ insetInlineStart: '50%',
494
+ transform: 'translateX(-50%)',
495
+ }, children: items.map((_, index) => (_jsx("button", { style: {
496
+ width: index === currentIndex ? '1.5rem' : '0.5rem',
497
+ height: '0.5rem',
498
+ borderRadius: '9999px',
499
+ transition: 'all 0.3s',
500
+ backgroundColor: index === currentIndex
501
+ ? 'var(--foreground)'
502
+ : 'rgb(from var(--foreground) r g b / 0.3)',
503
+ }, onMouseEnter: (e) => {
504
+ if (index !== currentIndex) {
505
+ e.currentTarget.style.backgroundColor =
506
+ 'rgb(from var(--foreground) r g b / 0.5)';
507
+ }
508
+ }, onMouseLeave: (e) => {
509
+ if (index !== currentIndex) {
510
+ e.currentTarget.style.backgroundColor =
511
+ 'rgb(from var(--foreground) r g b / 0.3)';
512
+ }
513
+ }, onClick: () => goToSlide(index), "aria-label": `Go to slide ${index + 1}` }, index))) })), showProgress && autoplay && (_jsx("div", { className: "dndev-absolute", style: {
514
+ bottom: 0,
515
+ insetInlineStart: 0,
516
+ insetInlineEnd: 0,
517
+ height: '0.25rem',
518
+ backgroundColor: 'rgb(from var(--foreground) r g b / 0.2)',
519
+ }, children: _jsx("div", { style: {
520
+ height: '100%',
521
+ width: `${((currentIndex + 1) / items.length) * 100}%`,
522
+ backgroundColor: 'var(--foreground)',
523
+ transition: 'width 0.1s linear',
524
+ } }) })), _jsxs("div", { className: "dndev-sr-only", "aria-live": "polite", "aria-atomic": "true", children: ["Slide ", currentIndex + 1, " of ", items.length] })] }));
525
+ }
526
+ // Create typed generic component with display name
527
+ const Carousel = memo(CarouselComponent);
528
+ Carousel.displayName = 'Carousel';
529
+ export default Carousel;
@@ -0,0 +1,10 @@
1
+ export type CarouselSkeletonProps = {
2
+ className?: string;
3
+ itemCount?: number;
4
+ showArrows?: boolean;
5
+ showDots?: boolean;
6
+ showProgress?: boolean;
7
+ };
8
+ declare function CarouselSkeleton({ className, itemCount, showArrows, showDots, showProgress, }: CarouselSkeletonProps): import("react/jsx-runtime").JSX.Element;
9
+ export default CarouselSkeleton;
10
+ //# sourceMappingURL=CarouselSkeleton.d.ts.map