yet-another-react-lightbox 2.6.2 → 3.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 (129) hide show
  1. package/dist/Lightbox.d.ts +1 -1
  2. package/dist/Lightbox.js +17 -13
  3. package/dist/core/components/IconButton.js +2 -2
  4. package/dist/core/components/ImageSlide.js +0 -3
  5. package/dist/core/config.d.ts +3 -3
  6. package/dist/core/config.js +18 -13
  7. package/dist/core/consts.d.ts +2 -4
  8. package/dist/core/consts.js +2 -4
  9. package/dist/core/contexts/Events.d.ts +3 -2
  10. package/dist/core/contexts/Events.js +3 -3
  11. package/dist/core/contexts/LightboxProps.d.ts +6 -0
  12. package/dist/core/contexts/LightboxProps.js +7 -0
  13. package/dist/core/contexts/LightboxState.d.ts +15 -15
  14. package/dist/core/contexts/LightboxState.js +33 -20
  15. package/dist/core/contexts/Timeouts.d.ts +1 -0
  16. package/dist/core/contexts/Timeouts.js +3 -3
  17. package/dist/core/contexts/index.d.ts +1 -0
  18. package/dist/core/contexts/index.js +1 -0
  19. package/dist/core/hooks/useAnimation.d.ts +4 -1
  20. package/dist/core/hooks/useAnimation.js +12 -3
  21. package/dist/core/hooks/useLoseFocus.js +3 -3
  22. package/dist/core/modules/Carousel.d.ts +1 -1
  23. package/dist/core/modules/Carousel.js +19 -24
  24. package/dist/core/modules/Controller.d.ts +15 -16
  25. package/dist/core/modules/Controller.js +68 -34
  26. package/dist/core/modules/Navigation.d.ts +4 -5
  27. package/dist/core/modules/Navigation.js +15 -12
  28. package/dist/core/modules/Portal.js +5 -4
  29. package/dist/core/modules/Root.d.ts +4 -0
  30. package/dist/core/modules/Root.js +7 -0
  31. package/dist/core/modules/Toolbar.d.ts +0 -6
  32. package/dist/core/modules/Toolbar.js +6 -8
  33. package/dist/core/modules/index.d.ts +1 -1
  34. package/dist/core/modules/index.js +1 -1
  35. package/dist/core/utils.d.ts +7 -10
  36. package/dist/core/utils.js +14 -14
  37. package/dist/plugins/captions/Captions.d.ts +2 -6
  38. package/dist/plugins/captions/Captions.js +17 -20
  39. package/dist/plugins/captions/Description.d.ts +2 -2
  40. package/dist/plugins/captions/Description.js +5 -3
  41. package/dist/plugins/captions/Title.js +2 -3
  42. package/dist/plugins/captions/captions.css +1 -0
  43. package/dist/plugins/captions/index.d.ts +2 -2
  44. package/dist/plugins/captions/props.d.ts +9 -0
  45. package/dist/plugins/captions/props.js +8 -0
  46. package/dist/plugins/captions/utils.d.ts +1 -1
  47. package/dist/plugins/captions/utils.js +1 -3
  48. package/dist/plugins/fullscreen/Fullscreen.d.ts +2 -2
  49. package/dist/plugins/fullscreen/Fullscreen.js +5 -3
  50. package/dist/plugins/fullscreen/FullscreenButton.js +8 -5
  51. package/dist/plugins/fullscreen/FullscreenContext.d.ts +5 -9
  52. package/dist/plugins/fullscreen/FullscreenContext.js +16 -26
  53. package/dist/plugins/fullscreen/index.d.ts +21 -10
  54. package/dist/plugins/fullscreen/props.d.ts +10 -0
  55. package/dist/plugins/fullscreen/props.js +8 -0
  56. package/dist/plugins/inline/Inline.d.ts +2 -2
  57. package/dist/plugins/inline/Inline.js +4 -7
  58. package/dist/plugins/inline/InlineContainer.d.ts +4 -0
  59. package/dist/plugins/inline/InlineContainer.js +5 -0
  60. package/dist/plugins/inline/index.d.ts +1 -1
  61. package/dist/plugins/slideshow/Slideshow.d.ts +2 -6
  62. package/dist/plugins/slideshow/Slideshow.js +7 -10
  63. package/dist/plugins/slideshow/SlideshowButton.js +7 -5
  64. package/dist/plugins/slideshow/SlideshowContext.d.ts +5 -9
  65. package/dist/plugins/slideshow/SlideshowContext.js +21 -12
  66. package/dist/plugins/slideshow/index.d.ts +16 -11
  67. package/dist/plugins/slideshow/props.d.ts +12 -0
  68. package/dist/plugins/slideshow/props.js +9 -0
  69. package/dist/plugins/thumbnails/Thumbnail.d.ts +3 -7
  70. package/dist/plugins/thumbnails/Thumbnail.js +7 -3
  71. package/dist/plugins/thumbnails/Thumbnails.d.ts +2 -13
  72. package/dist/plugins/thumbnails/Thumbnails.js +6 -19
  73. package/dist/plugins/thumbnails/ThumbnailsContainer.d.ts +1 -1
  74. package/dist/plugins/thumbnails/ThumbnailsContainer.js +10 -10
  75. package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +4 -6
  76. package/dist/plugins/thumbnails/ThumbnailsTrack.js +16 -14
  77. package/dist/plugins/thumbnails/index.d.ts +5 -5
  78. package/dist/plugins/thumbnails/props.d.ts +34 -0
  79. package/dist/plugins/thumbnails/props.js +20 -0
  80. package/dist/plugins/video/Video.d.ts +2 -6
  81. package/dist/plugins/video/Video.js +11 -11
  82. package/dist/plugins/video/VideoSlide.d.ts +1 -1
  83. package/dist/plugins/video/VideoSlide.js +3 -3
  84. package/dist/plugins/video/index.d.ts +39 -42
  85. package/dist/plugins/video/props.d.ts +29 -0
  86. package/dist/plugins/video/props.js +13 -0
  87. package/dist/plugins/zoom/ResponsiveImage.js +23 -15
  88. package/dist/plugins/zoom/Zoom.d.ts +0 -11
  89. package/dist/plugins/zoom/Zoom.js +11 -33
  90. package/dist/plugins/zoom/ZoomButton.d.ts +6 -5
  91. package/dist/plugins/zoom/ZoomButton.js +11 -33
  92. package/dist/plugins/zoom/ZoomButtonsGroup.d.ts +1 -4
  93. package/dist/plugins/zoom/ZoomButtonsGroup.js +6 -7
  94. package/dist/plugins/zoom/ZoomController.d.ts +12 -0
  95. package/dist/plugins/zoom/ZoomController.js +17 -0
  96. package/dist/plugins/zoom/ZoomToolbarControl.d.ts +2 -0
  97. package/dist/plugins/zoom/ZoomToolbarControl.js +12 -0
  98. package/dist/plugins/zoom/ZoomWrapper.d.ts +5 -0
  99. package/dist/plugins/zoom/ZoomWrapper.js +36 -0
  100. package/dist/plugins/zoom/hooks/index.d.ts +6 -0
  101. package/dist/plugins/zoom/hooks/index.js +6 -0
  102. package/dist/plugins/zoom/hooks/useZoomAnimation.d.ts +2 -0
  103. package/dist/plugins/zoom/hooks/useZoomAnimation.js +39 -0
  104. package/dist/plugins/zoom/hooks/useZoomCallback.d.ts +1 -0
  105. package/dist/plugins/zoom/hooks/useZoomCallback.js +12 -0
  106. package/dist/plugins/zoom/hooks/useZoomImageRect.d.ts +5 -0
  107. package/dist/plugins/zoom/hooks/useZoomImageRect.js +41 -0
  108. package/dist/plugins/zoom/hooks/useZoomProps.d.ts +13 -0
  109. package/dist/plugins/zoom/hooks/useZoomProps.js +6 -0
  110. package/dist/plugins/zoom/hooks/useZoomSensors.d.ts +3 -0
  111. package/dist/plugins/zoom/hooks/useZoomSensors.js +154 -0
  112. package/dist/plugins/zoom/hooks/useZoomState.d.ts +12 -0
  113. package/dist/plugins/zoom/hooks/useZoomState.js +63 -0
  114. package/dist/plugins/zoom/index.d.ts +37 -24
  115. package/dist/plugins/zoom/index.js +0 -2
  116. package/dist/plugins/zoom/props.d.ts +25 -0
  117. package/dist/plugins/zoom/props.js +15 -0
  118. package/dist/props.d.ts +0 -4
  119. package/dist/props.js +10 -5
  120. package/dist/types.d.ts +173 -117
  121. package/package.json +41 -11
  122. package/dist/core/modules/Core.d.ts +0 -4
  123. package/dist/core/modules/Core.js +0 -10
  124. package/dist/plugins/captions/CaptionsContext.d.ts +0 -7
  125. package/dist/plugins/captions/CaptionsContext.js +0 -11
  126. package/dist/plugins/zoom/ZoomContainer.d.ts +0 -9
  127. package/dist/plugins/zoom/ZoomContainer.js +0 -316
  128. package/dist/plugins/zoom/ZoomContext.d.ts +0 -11
  129. package/dist/plugins/zoom/ZoomContext.js +0 -20
package/dist/types.d.ts CHANGED
@@ -1,22 +1,52 @@
1
1
  import * as React from "react";
2
- /** Image fit setting */
3
- export type ImageFit = "contain" | "cover";
4
- /** Image source */
5
- export interface ImageSource {
6
- /** image URL */
7
- src: string;
8
- /** image width in pixels */
9
- width: number;
10
- /** image height in pixels */
11
- height: number;
2
+ /** Lightbox external props */
3
+ export type LightboxExternalProps = DeepPartial<LightboxProps, "carousel" | "animation" | "controller" | "toolbar">;
4
+ /** Lightbox properties */
5
+ export interface LightboxProps {
6
+ /** if `true`, the lightbox is open */
7
+ open: boolean;
8
+ /** a callback to close the lightbox */
9
+ close: Callback;
10
+ /** starting slide index */
11
+ index: number;
12
+ /** slides to display in the lightbox */
13
+ slides: Slide[];
14
+ /** custom render functions */
15
+ render: Render;
16
+ /** custom UI labels */
17
+ labels: Labels;
18
+ /** enabled plugins */
19
+ plugins: Plugin[];
20
+ /** toolbar settings */
21
+ toolbar: ToolbarSettings;
22
+ /** carousel settings */
23
+ carousel: CarouselSettings;
24
+ /** animation settings */
25
+ animation: AnimationSettings;
26
+ /** controller settings */
27
+ controller: ControllerSettings;
28
+ /** lifecycle callbacks */
29
+ on: Callbacks;
30
+ /** customization styles */
31
+ styles: SlotStyles;
32
+ /** CSS class of the lightbox root element */
33
+ className: string;
12
34
  }
35
+ /** Slide */
36
+ export type Slide = SlideTypes[SlideTypeKey];
37
+ /** Supported slide types */
38
+ export interface SlideTypes {
39
+ /** image slide type */
40
+ image: SlideImage;
41
+ }
42
+ /** Slide type key */
43
+ export type SlideTypeKey = keyof SlideTypes;
13
44
  /** Generic slide */
14
45
  export interface GenericSlide {
46
+ type?: SlideTypeKey;
15
47
  }
16
48
  /** Image slide properties */
17
49
  export interface SlideImage extends GenericSlide {
18
- /** slide type */
19
- type?: "image";
20
50
  /** image URL */
21
51
  src: string;
22
52
  /** image 'alt' attribute */
@@ -30,18 +60,44 @@ export interface SlideImage extends GenericSlide {
30
60
  /** alternative images to be passed to the 'srcSet' */
31
61
  srcSet?: ImageSource[];
32
62
  }
33
- /** Supported slide types */
34
- export interface SlideTypes {
35
- /** image slide type */
36
- SlideImage: SlideImage;
63
+ /** Image source */
64
+ export interface ImageSource {
65
+ /** image URL */
66
+ src: string;
67
+ /** image width in pixels */
68
+ width: number;
69
+ /** image height in pixels */
70
+ height: number;
37
71
  }
38
- /** Slide */
39
- export type Slide = SlideTypes[keyof SlideTypes];
72
+ /** Image fit setting */
73
+ export type ImageFit = "contain" | "cover";
74
+ /** Lightbox component */
75
+ export type Component = React.ComponentType<ComponentProps>;
76
+ /** Lightbox component properties */
77
+ export type ComponentProps = React.PropsWithChildren<Omit<LightboxProps, "slides" | "index" | "plugins">>;
78
+ /** Lightbox component tree node */
79
+ export type Node = {
80
+ /** module */
81
+ module: Module;
82
+ /** module child nodes */
83
+ children?: Node[];
84
+ };
85
+ /** Lightbox module */
86
+ export type Module = {
87
+ /** module name */
88
+ name: string;
89
+ /** module component */
90
+ component: Component;
91
+ };
92
+ /** Lightbox props augmentation */
93
+ export type Augmentation = (props: ComponentProps) => ComponentProps;
40
94
  /** Container rect */
41
95
  export type ContainerRect = {
42
96
  width: number;
43
97
  height: number;
44
98
  };
99
+ /** Customization slots */
100
+ export type Slot = SlotType[keyof SlotType];
45
101
  /** Supported customization slots */
46
102
  export interface SlotType {
47
103
  /** lightbox root customization slot */
@@ -53,8 +109,6 @@ export interface SlotType {
53
109
  /** lightbox icon customization slot */
54
110
  icon: "icon";
55
111
  }
56
- /** Customization slots */
57
- export type Slot = SlotType[keyof SlotType];
58
112
  /** Customization slot CSS properties */
59
113
  interface SlotCSSProperties extends React.CSSProperties {
60
114
  [key: `--yarl__${string}`]: string | number;
@@ -69,33 +123,36 @@ export interface CarouselSettings {
69
123
  finite: boolean;
70
124
  /** the lightbox preloads (2 * preload + 1) slides */
71
125
  preload: number;
72
- /** padding around each slide (e.g., "16px", "10px 20px" or 0) */
73
- padding: string | 0;
126
+ /** padding around each slide (e.g., "16px", "10%" or 0) */
127
+ padding: LengthOrPercentage;
74
128
  /** spacing between slides (e.g., "100px", "50%" or 0) */
75
- spacing: string | 0;
129
+ spacing: LengthOrPercentage;
76
130
  /** `object-fit` setting for image slides */
77
131
  imageFit: ImageFit;
78
132
  }
133
+ export type LengthOrPercentage = `${number}px` | `${number}%` | number;
79
134
  /** Animation settings */
80
135
  export interface AnimationSettings {
81
136
  /** fade-in / fade-out animation settings */
82
- fade: AnimationSpec;
137
+ fade: number;
83
138
  /** swipe animation settings */
84
- swipe: AnimationSpec;
139
+ swipe: number;
85
140
  /** override for `swipe` animation settings when using keyboard navigation or navigation buttons */
86
- navigation?: AnimationSpec;
87
- }
88
- /** Animation duration or animation settings */
89
- export type AnimationSpec = {
90
- /** animation duration */
91
- duration?: number;
92
- /** animation easing function */
93
- easing?: string;
141
+ navigation?: number;
142
+ /** animation timing function settings */
143
+ easing: {
144
+ /** fade-in / fade-out animation timing function */
145
+ fade: string;
146
+ /** slide swipe animation timing function */
147
+ swipe: string;
148
+ /** slide navigation animation timing function (when using keyboard navigation or navigation buttons) */
149
+ navigation: string;
150
+ };
94
151
  }
95
- /** animation duration */
96
- | number;
97
152
  /** Controller settings */
98
153
  export interface ControllerSettings {
154
+ /** controller ref */
155
+ ref: React.ForwardedRef<ControllerRef>;
99
156
  /** if true, the lightbox captures focus when it opens */
100
157
  focus: boolean;
101
158
  /** controller `touch-action` */
@@ -105,33 +162,76 @@ export interface ControllerSettings {
105
162
  /** if `true`, close the lightbox when the backdrop is clicked */
106
163
  closeOnBackdropClick: boolean;
107
164
  }
165
+ /** Lightbox controller ref */
166
+ export interface ControllerRef {
167
+ /** navigate to the previous slide */
168
+ prev: Callback<NavigationAction | void>;
169
+ /** navigate to the next slide */
170
+ next: Callback<NavigationAction | void>;
171
+ /** close the lightbox */
172
+ close: Callback;
173
+ /** transfer focus to the lightbox controller */
174
+ focus: Callback;
175
+ /** get lightbox props */
176
+ getLightboxProps: () => ComponentProps;
177
+ /** get lightbox state */
178
+ getLightboxState: () => LightboxState;
179
+ }
180
+ /** Lightbox navigation action */
181
+ export interface NavigationAction {
182
+ /** navigate through the specified number of slides */
183
+ count?: number;
184
+ }
185
+ /** Lightbox state */
186
+ export interface LightboxState {
187
+ /** lightbox slides */
188
+ slides: Slide[];
189
+ /** current slide index */
190
+ currentIndex: number;
191
+ /** current slide index in the (-∞, +∞) range */
192
+ globalIndex: number;
193
+ /** current animation */
194
+ animation?: {
195
+ increment?: number;
196
+ duration?: number;
197
+ easing?: string;
198
+ };
199
+ }
108
200
  /** Render function */
109
- export type RenderFunction<T = void> = (props: T) => React.ReactNode;
201
+ export type RenderFunction<T = void> = [T] extends [void] ? () => React.ReactNode : (props: T) => React.ReactNode;
110
202
  /** `render.slide` render function props */
111
- export type RenderSlideProps = [
203
+ export interface RenderSlideProps {
112
204
  /** slide */
113
- slide: Slide,
205
+ slide: Slide;
114
206
  /** slide offset (`0` - current slide, `1` - next slide, `-1` - previous slide, etc.) */
115
- offset: number,
207
+ offset: number;
116
208
  /** container rect */
117
- rect: ContainerRect
118
- ];
209
+ rect: ContainerRect;
210
+ }
119
211
  /** `render.slideHeader` render function props */
120
- export type RenderSlideHeaderProps = [slide: Slide];
212
+ export interface RenderSlideHeaderProps {
213
+ slide: Slide;
214
+ }
121
215
  /** `render.slideFooter` render function props */
122
- export type RenderSlideFooterProps = [slide: Slide];
216
+ export interface RenderSlideFooterProps {
217
+ slide: Slide;
218
+ }
123
219
  /** `render.slideContainer` render function props */
124
- export type RenderSlideContainerProps = [slide: Slide, children: React.ReactNode];
220
+ export interface RenderSlideContainerProps extends React.PropsWithChildren {
221
+ slide: Slide;
222
+ }
125
223
  /** Custom render functions. */
126
224
  export interface Render {
127
225
  /** render custom slide type, or override the default image slide */
128
- slide?: (...props: RenderSlideProps) => React.ReactNode;
129
- /** render custom slide header */
130
- slideHeader?: (...props: RenderSlideHeaderProps) => React.ReactNode;
131
- /** render custom slide footer */
132
- slideFooter?: (...props: RenderSlideFooterProps) => React.ReactNode;
226
+ slide?: RenderFunction<RenderSlideProps>;
227
+ /** render custom slide header (use absolute positioning) */
228
+ slideHeader?: RenderFunction<RenderSlideHeaderProps>;
229
+ /** render custom slide footer (use absolute positioning) */
230
+ slideFooter?: RenderFunction<RenderSlideFooterProps>;
133
231
  /** render custom slide container */
134
- slideContainer?: (...props: RenderSlideContainerProps) => React.ReactNode;
232
+ slideContainer?: RenderFunction<RenderSlideContainerProps>;
233
+ /** render custom controls or additional elements in the lightbox (use absolute positioning) */
234
+ controls?: RenderFunction;
135
235
  /** render custom Prev icon */
136
236
  iconPrev?: RenderFunction;
137
237
  /** render custom Next icon */
@@ -149,54 +249,27 @@ export interface Render {
149
249
  /** render custom Close button */
150
250
  buttonClose?: RenderFunction;
151
251
  }
252
+ export type Callback<T = void> = [T] extends [void] ? () => void : (props: T) => void;
253
+ export interface ViewCallbackProps {
254
+ index: number;
255
+ }
256
+ export interface ClickCallbackProps {
257
+ index: number;
258
+ }
152
259
  /** Lifecycle callbacks */
153
260
  export interface Callbacks {
154
261
  /** a callback called when a slide becomes active */
155
- view?: (index: number) => void;
262
+ view?: Callback<ViewCallbackProps>;
156
263
  /** a callback called when a slide is clicked */
157
- click?: (index: number) => void;
264
+ click?: Callback<ClickCallbackProps>;
158
265
  /** a callback called when the portal starts opening */
159
- entering?: () => void;
266
+ entering?: Callback;
160
267
  /** a callback called when the portal opens */
161
- entered?: () => void;
268
+ entered?: Callback;
162
269
  /** a callback called when the portal starts closing */
163
- exiting?: () => void;
270
+ exiting?: Callback;
164
271
  /** a callback called when the portal closes */
165
- exited?: () => void;
166
- }
167
- /** Lightbox properties */
168
- export interface LightboxProps {
169
- /** if `true`, the lightbox is open */
170
- open: boolean;
171
- /** a callback to close the lightbox */
172
- close: () => void;
173
- /**
174
- * Starting slide index. The lightbox reads this property only when it opens.
175
- * Changing this property while the lightbox is already open has no effect.
176
- */
177
- index: number;
178
- /** slides to display in the lightbox */
179
- slides: Slide[];
180
- /** custom render functions */
181
- render: Render;
182
- /** custom UI labels */
183
- labels: Labels;
184
- /** enabled plugins */
185
- plugins: Plugin[];
186
- /** toolbar settings */
187
- toolbar: ToolbarSettings;
188
- /** carousel settings */
189
- carousel: CarouselSettings;
190
- /** animation settings */
191
- animation: AnimationSettings;
192
- /** controller settings */
193
- controller: ControllerSettings;
194
- /** lifecycle callbacks */
195
- on: Callbacks;
196
- /** customization styles */
197
- styles: SlotStyles;
198
- /** CSS class of the lightbox root element */
199
- className: string;
272
+ exited?: Callback;
200
273
  }
201
274
  /** Custom UI labels */
202
275
  export type Labels = {
@@ -207,28 +280,8 @@ export interface ToolbarSettings {
207
280
  /** buttons to render in the toolbar */
208
281
  buttons: ("close" | React.ReactNode)[];
209
282
  }
210
- /** Lightbox component properties */
211
- export type ComponentProps = React.PropsWithChildren<Omit<LightboxProps, "plugins">>;
212
- /** Lightbox component */
213
- export type Component = React.ComponentType<ComponentProps>;
214
- /** Lightbox module */
215
- export type Module = {
216
- /** module name */
217
- name: string;
218
- /** module component */
219
- component: Component;
220
- };
221
- /** Lightbox component tree node */
222
- export type Node = {
223
- /** module */
224
- module: Module;
225
- /** module child nodes */
226
- children?: Node[];
227
- };
228
- /** Lightbox props augmentation */
229
- export type Augmentation = (props: LightboxProps) => LightboxProps;
230
283
  /** Plugin methods */
231
- export type PluginMethods = {
284
+ export interface PluginProps {
232
285
  /** test if a target module is present */
233
286
  contains: (target: string) => boolean;
234
287
  /** add module as a parent */
@@ -237,6 +290,8 @@ export type PluginMethods = {
237
290
  addChild: (target: string, module: Module, precede?: boolean) => void;
238
291
  /** add module as a sibling */
239
292
  addSibling: (target: string, module: Module, precede?: boolean) => void;
293
+ /** append module to the Controller module */
294
+ addModule: (module: Module) => void;
240
295
  /** replace module */
241
296
  replace: (target: string, module: Module) => void;
242
297
  /** add module as a child and inherit all existing children */
@@ -245,17 +300,18 @@ export type PluginMethods = {
245
300
  remove: (target: string) => void;
246
301
  /** augment lightbox props */
247
302
  augment: (augmentation: Augmentation) => void;
248
- };
303
+ }
249
304
  /** Lightbox plugin */
250
- export type Plugin = ({ addParent, addChild, addSibling, replace, remove, append, augment }: PluginMethods) => void;
305
+ export type Plugin = (props: PluginProps) => void;
251
306
  /** Deep partial utility type */
252
- export type DeepPartial<T, K extends keyof T> = Omit<T, K> & {
253
- [P in keyof Pick<T, K>]?: Partial<Pick<T, K>[P]>;
307
+ export type DeepPartial<T extends {}, K extends keyof T> = Omit<Partial<T>, K> & {
308
+ [P in K]?: DeepPartialValue<T[P]>;
254
309
  };
310
+ export type DeepPartialValue<T> = T extends any[] ? T : T extends (...props: any[]) => any ? T : T extends {} ? {
311
+ [P in keyof T]?: P extends "ref" ? T[P] : DeepPartialValue<T[P]>;
312
+ } : T;
255
313
  /** Deep non-nullable utility type */
256
314
  export type DeepNonNullable<T> = T extends {} ? {
257
315
  [K in keyof T]-?: NonNullable<T[K]>;
258
316
  } : never;
259
- /** Lightbox external props */
260
- export type LightboxExternalProps = DeepPartial<Partial<LightboxProps>, "carousel" | "animation" | "controller" | "toolbar">;
261
317
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "2.6.2",
3
+ "version": "3.0.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -8,18 +8,48 @@
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
- ".": "./dist/index.js",
12
- "./core": "./dist/core/index.js",
13
- "./plugins": "./dist/plugins/index.js",
14
- "./plugins/captions": "./dist/plugins/captions/index.js",
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./core": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "default": "./dist/core/index.js"
18
+ },
19
+ "./plugins": {
20
+ "types": "./dist/plugins/index.d.ts",
21
+ "default": "./dist/plugins/index.js"
22
+ },
15
23
  "./plugins/captions.css": "./dist/plugins/captions/captions.css",
16
- "./plugins/fullscreen": "./dist/plugins/fullscreen/index.js",
17
- "./plugins/inline": "./dist/plugins/inline/index.js",
18
- "./plugins/slideshow": "./dist/plugins/slideshow/index.js",
19
- "./plugins/thumbnails": "./dist/plugins/thumbnails/index.js",
24
+ "./plugins/captions": {
25
+ "types": "./dist/plugins/captions/index.d.ts",
26
+ "default": "./dist/plugins/captions/index.js"
27
+ },
28
+ "./plugins/fullscreen": {
29
+ "types": "./dist/plugins/fullscreen/index.d.ts",
30
+ "default": "./dist/plugins/fullscreen/index.js"
31
+ },
32
+ "./plugins/inline": {
33
+ "types": "./dist/plugins/inline/index.d.ts",
34
+ "default": "./dist/plugins/inline/index.js"
35
+ },
36
+ "./plugins/slideshow": {
37
+ "types": "./dist/plugins/slideshow/index.d.ts",
38
+ "default": "./dist/plugins/slideshow/index.js"
39
+ },
20
40
  "./plugins/thumbnails.css": "./dist/plugins/thumbnails/thumbnails.css",
21
- "./plugins/video": "./dist/plugins/video/index.js",
22
- "./plugins/zoom": "./dist/plugins/zoom/index.js",
41
+ "./plugins/thumbnails": {
42
+ "types": "./dist/plugins/thumbnails/index.d.ts",
43
+ "default": "./dist/plugins/thumbnails/index.js"
44
+ },
45
+ "./plugins/video": {
46
+ "types": "./dist/plugins/video/index.d.ts",
47
+ "default": "./dist/plugins/video/index.js"
48
+ },
49
+ "./plugins/zoom": {
50
+ "types": "./dist/plugins/zoom/index.d.ts",
51
+ "default": "./dist/plugins/zoom/index.js"
52
+ },
23
53
  "./styles.css": "./dist/styles.css"
24
54
  },
25
55
  "typesVersions": {
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { ComponentProps } from "../../types.js";
3
- export declare function Core({ slides, index, children }: ComponentProps): JSX.Element;
4
- export declare const CoreModule: import("../../types.js").Module;
@@ -1,10 +0,0 @@
1
- import * as React from "react";
2
- import { createModule } from "../config.js";
3
- import { EventsProvider, LightboxStateProvider, TimeoutsProvider } from "../contexts/index.js";
4
- import { MODULE_CORE } from "../consts.js";
5
- export function Core({ slides, index, children }) {
6
- return (React.createElement(TimeoutsProvider, null,
7
- React.createElement(EventsProvider, null,
8
- React.createElement(LightboxStateProvider, { slidesCount: slides.length, initialIndex: index }, children))));
9
- }
10
- export const CoreModule = createModule(MODULE_CORE, Core);
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- export type CaptionsContextType = {
3
- toolbarWidth?: number;
4
- };
5
- export declare const useCaptions: () => CaptionsContextType;
6
- /** Captions plugin context holder */
7
- export declare function CaptionsContextProvider({ children }: React.PropsWithChildren): JSX.Element;
@@ -1,11 +0,0 @@
1
- import * as React from "react";
2
- import { makeUseContext, useEvents, YARL_EVENT_TOOLBAR_WIDTH } from "../../core/index.js";
3
- const CaptionsContext = React.createContext(null);
4
- export const useCaptions = makeUseContext("useCaptions", "CaptionsContext", CaptionsContext);
5
- export function CaptionsContextProvider({ children }) {
6
- const { subscribe } = useEvents();
7
- const [toolbarWidth, setToolbarWidth] = React.useState();
8
- React.useEffect(() => subscribe(YARL_EVENT_TOOLBAR_WIDTH, (event) => setToolbarWidth(event)), [subscribe]);
9
- const context = React.useMemo(() => ({ toolbarWidth }), [toolbarWidth]);
10
- return React.createElement(CaptionsContext.Provider, { value: context }, children);
11
- }
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { ContainerRect, LightboxProps, Slide } from "../../types.js";
3
- export type ZoomContainerProps = Pick<LightboxProps, "render" | "carousel" | "zoom" | "animation" | "on"> & {
4
- slide: Slide;
5
- offset: number;
6
- rect: ContainerRect;
7
- };
8
- /** Zoom container */
9
- export declare function ZoomContainer({ slide, offset, rect, render, carousel, animation, zoom: originalZoomProps, on, }: ZoomContainerProps): JSX.Element | null;