react-smart-image-viewer 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.
- package/README.md +480 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +255 -0
- package/dist/index.js +649 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +81 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-smart-image-viewer
|
|
3
|
+
*
|
|
4
|
+
* A high-performance, TypeScript-first React image viewer
|
|
5
|
+
* with zoom, pan, keyboard, and mobile gesture support.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { default as default_2 } from 'react';
|
|
11
|
+
|
|
12
|
+
export declare const ChevronLeftIcon: default_2.FC<IconProps>;
|
|
13
|
+
|
|
14
|
+
export declare const ChevronRightIcon: default_2.FC<IconProps>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Clamps a value between min and max
|
|
18
|
+
*/
|
|
19
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* SVG Icons for the ImageViewer controls
|
|
23
|
+
* Using inline SVGs to avoid external dependencies
|
|
24
|
+
*/
|
|
25
|
+
export declare const CloseIcon: default_2.FC<IconProps>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Props passed to custom controls renderer
|
|
29
|
+
*/
|
|
30
|
+
export declare interface ControlsRenderProps {
|
|
31
|
+
zoomIn: () => void;
|
|
32
|
+
zoomOut: () => void;
|
|
33
|
+
resetZoom: () => void;
|
|
34
|
+
currentZoom: number;
|
|
35
|
+
minZoom: number;
|
|
36
|
+
maxZoom: number;
|
|
37
|
+
close: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare interface IconProps {
|
|
41
|
+
className?: string;
|
|
42
|
+
'aria-hidden'?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Input type that accepts either string URLs or ImageSource objects
|
|
47
|
+
*/
|
|
48
|
+
export declare type ImageInput = string | ImageSource;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for image sources with optional metadata
|
|
52
|
+
*/
|
|
53
|
+
export declare interface ImageSource {
|
|
54
|
+
/** Image URL */
|
|
55
|
+
src: string;
|
|
56
|
+
/** Alt text for accessibility */
|
|
57
|
+
alt?: string;
|
|
58
|
+
/** Optional thumbnail URL for gallery previews */
|
|
59
|
+
thumbnail?: string;
|
|
60
|
+
/** Optional title to display */
|
|
61
|
+
title?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* ImageViewer - A high-performance image viewer with zoom, pan, and gallery support
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* // Single image
|
|
70
|
+
* <ImageViewer images="https://example.com/image.jpg" isOpen={isOpen} onClose={() => setIsOpen(false)} />
|
|
71
|
+
*
|
|
72
|
+
* // Gallery
|
|
73
|
+
* <ImageViewer images={['image1.jpg', 'image2.jpg']} isOpen={isOpen} onClose={() => setIsOpen(false)} />
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const ImageViewer: default_2.FC<ImageViewerProps>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Props for the ImageViewer component
|
|
80
|
+
*/
|
|
81
|
+
export declare interface ImageViewerProps {
|
|
82
|
+
/** Single image or array of images */
|
|
83
|
+
images: ImageInput | ImageInput[];
|
|
84
|
+
/** Initial image index for gallery mode */
|
|
85
|
+
initialIndex?: number;
|
|
86
|
+
/** Controlled mode: whether the viewer is open */
|
|
87
|
+
isOpen?: boolean;
|
|
88
|
+
/** Default open state for uncontrolled mode */
|
|
89
|
+
defaultOpen?: boolean;
|
|
90
|
+
/** Callback when viewer closes */
|
|
91
|
+
onClose?: () => void;
|
|
92
|
+
/** Callback when image index changes */
|
|
93
|
+
onIndexChange?: (index: number) => void;
|
|
94
|
+
/** Zoom increment per step */
|
|
95
|
+
zoomStep?: number;
|
|
96
|
+
/** Minimum zoom level */
|
|
97
|
+
minZoom?: number;
|
|
98
|
+
/** Maximum zoom level */
|
|
99
|
+
maxZoom?: number;
|
|
100
|
+
/** Whether to show control buttons */
|
|
101
|
+
showControls?: boolean;
|
|
102
|
+
/** Whether to show navigation arrows */
|
|
103
|
+
showNavigation?: boolean;
|
|
104
|
+
/** Whether to show image counter */
|
|
105
|
+
showCounter?: boolean;
|
|
106
|
+
/** Whether to close on overlay click */
|
|
107
|
+
closeOnOverlayClick?: boolean;
|
|
108
|
+
/** Whether to close on ESC key */
|
|
109
|
+
closeOnEscape?: boolean;
|
|
110
|
+
/** Whether to enable keyboard navigation */
|
|
111
|
+
enableKeyboardNavigation?: boolean;
|
|
112
|
+
/** Whether to loop gallery navigation */
|
|
113
|
+
loop?: boolean;
|
|
114
|
+
/** Custom class name for the overlay */
|
|
115
|
+
className?: string;
|
|
116
|
+
/** Custom class name for the image */
|
|
117
|
+
imageClassName?: string;
|
|
118
|
+
/** Animation duration in ms */
|
|
119
|
+
animationDuration?: number;
|
|
120
|
+
/** Accessible label for the viewer */
|
|
121
|
+
ariaLabel?: string;
|
|
122
|
+
/** Custom render function for controls */
|
|
123
|
+
renderControls?: (props: ControlsRenderProps) => React.ReactNode;
|
|
124
|
+
/** Custom render function for navigation */
|
|
125
|
+
renderNavigation?: (props: NavigationRenderProps) => React.ReactNode;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check if we're in SSR environment
|
|
130
|
+
*/
|
|
131
|
+
export declare function isSSR(): boolean;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Detects if device supports touch
|
|
135
|
+
*/
|
|
136
|
+
export declare function isTouchDevice(): boolean;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Props passed to custom navigation renderer
|
|
140
|
+
*/
|
|
141
|
+
export declare interface NavigationRenderProps {
|
|
142
|
+
goToPrevious: () => void;
|
|
143
|
+
goToNext: () => void;
|
|
144
|
+
currentIndex: number;
|
|
145
|
+
totalImages: number;
|
|
146
|
+
canGoPrevious: boolean;
|
|
147
|
+
canGoNext: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Normalized image type used internally
|
|
152
|
+
*/
|
|
153
|
+
declare type NormalizedImage = ImageSource;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Normalizes image input to consistent ImageSource format
|
|
157
|
+
*/
|
|
158
|
+
export declare function normalizeImage(image: ImageInput): NormalizedImage;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Normalizes array of images
|
|
162
|
+
*/
|
|
163
|
+
export declare function normalizeImages(images: ImageInput | ImageInput[]): NormalizedImage[];
|
|
164
|
+
|
|
165
|
+
export declare const ResetIcon: default_2.FC<IconProps>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Transform state for zoom and pan
|
|
169
|
+
*/
|
|
170
|
+
export declare interface TransformState {
|
|
171
|
+
scale: number;
|
|
172
|
+
translateX: number;
|
|
173
|
+
translateY: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Hook for controlling the ImageViewer programmatically
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```tsx
|
|
181
|
+
* const viewer = useImageViewer({ totalImages: 5 });
|
|
182
|
+
*
|
|
183
|
+
* return (
|
|
184
|
+
* <>
|
|
185
|
+
* <button onClick={() => viewer.open(0)}>Open Gallery</button>
|
|
186
|
+
* <ImageViewer images={images} {...viewer.getViewerProps()} />
|
|
187
|
+
* </>
|
|
188
|
+
* );
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare function useImageViewer(options?: UseImageViewerOptions): UseImageViewerReturn;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Options for useImageViewer hook
|
|
195
|
+
*/
|
|
196
|
+
export declare interface UseImageViewerOptions {
|
|
197
|
+
/** Initial open state */
|
|
198
|
+
defaultOpen?: boolean;
|
|
199
|
+
/** Initial image index */
|
|
200
|
+
defaultIndex?: number;
|
|
201
|
+
/** Total number of images */
|
|
202
|
+
totalImages?: number;
|
|
203
|
+
/** Zoom step */
|
|
204
|
+
zoomStep?: number;
|
|
205
|
+
/** Minimum zoom */
|
|
206
|
+
minZoom?: number;
|
|
207
|
+
/** Maximum zoom */
|
|
208
|
+
maxZoom?: number;
|
|
209
|
+
/** Loop navigation */
|
|
210
|
+
loop?: boolean;
|
|
211
|
+
/** Callback when open state changes */
|
|
212
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
213
|
+
/** Callback when index changes */
|
|
214
|
+
onIndexChange?: (index: number) => void;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Return type for useImageViewer hook
|
|
219
|
+
*/
|
|
220
|
+
export declare interface UseImageViewerReturn {
|
|
221
|
+
/** Whether the viewer is open */
|
|
222
|
+
isOpen: boolean;
|
|
223
|
+
/** Open the viewer */
|
|
224
|
+
open: (index?: number) => void;
|
|
225
|
+
/** Close the viewer */
|
|
226
|
+
close: () => void;
|
|
227
|
+
/** Toggle the viewer */
|
|
228
|
+
toggle: () => void;
|
|
229
|
+
/** Current image index */
|
|
230
|
+
currentIndex: number;
|
|
231
|
+
/** Set current image index */
|
|
232
|
+
setCurrentIndex: (index: number) => void;
|
|
233
|
+
/** Go to next image */
|
|
234
|
+
goToNext: () => void;
|
|
235
|
+
/** Go to previous image */
|
|
236
|
+
goToPrevious: () => void;
|
|
237
|
+
/** Current zoom level */
|
|
238
|
+
zoom: number;
|
|
239
|
+
/** Zoom in */
|
|
240
|
+
zoomIn: () => void;
|
|
241
|
+
/** Zoom out */
|
|
242
|
+
zoomOut: () => void;
|
|
243
|
+
/** Reset zoom to 1 */
|
|
244
|
+
resetZoom: () => void;
|
|
245
|
+
/** Set specific zoom level */
|
|
246
|
+
setZoom: (zoom: number) => void;
|
|
247
|
+
/** Props to spread on ImageViewer component */
|
|
248
|
+
getViewerProps: () => Partial<ImageViewerProps>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export declare const ZoomInIcon: default_2.FC<IconProps>;
|
|
252
|
+
|
|
253
|
+
export declare const ZoomOutIcon: default_2.FC<IconProps>;
|
|
254
|
+
|
|
255
|
+
export { }
|