yet-another-react-lightbox 2.5.1 → 2.6.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.
Files changed (97) hide show
  1. package/README.md +4 -8
  2. package/dist/Lightbox.d.ts +2 -2
  3. package/dist/Lightbox.js +11 -9
  4. package/dist/core/components/Icons.d.ts +1 -1
  5. package/dist/core/components/Icons.js +2 -2
  6. package/dist/core/components/ImageSlide.d.ts +1 -1
  7. package/dist/core/components/ImageSlide.js +2 -2
  8. package/dist/core/contexts/Events.d.ts +1 -1
  9. package/dist/core/contexts/Events.js +2 -2
  10. package/dist/core/contexts/LightboxState.d.ts +3 -3
  11. package/dist/core/contexts/LightboxState.js +2 -2
  12. package/dist/core/contexts/Timeouts.d.ts +1 -1
  13. package/dist/core/contexts/Timeouts.js +2 -2
  14. package/dist/core/hooks/useAnimation.d.ts +4 -2
  15. package/dist/core/hooks/useAnimation.js +6 -6
  16. package/dist/core/hooks/useContainerRect.d.ts +1 -1
  17. package/dist/core/hooks/useContainerRect.js +2 -2
  18. package/dist/core/hooks/useDelay.d.ts +1 -1
  19. package/dist/core/hooks/useDelay.js +2 -2
  20. package/dist/core/hooks/useEventCallback.d.ts +1 -1
  21. package/dist/core/hooks/useEventCallback.js +2 -2
  22. package/dist/core/hooks/useForkRef.d.ts +2 -2
  23. package/dist/core/hooks/useForkRef.js +10 -8
  24. package/dist/core/hooks/useLoseFocus.d.ts +1 -1
  25. package/dist/core/hooks/useLoseFocus.js +2 -2
  26. package/dist/core/hooks/useMotionPreference.d.ts +1 -1
  27. package/dist/core/hooks/useMotionPreference.js +2 -2
  28. package/dist/core/hooks/useRTL.d.ts +1 -1
  29. package/dist/core/hooks/useRTL.js +2 -2
  30. package/dist/core/hooks/useSensors.d.ts +1 -1
  31. package/dist/core/hooks/useSensors.js +2 -2
  32. package/dist/core/hooks/useThrottle.d.ts +1 -1
  33. package/dist/core/hooks/useThrottle.js +2 -2
  34. package/dist/core/modules/Carousel.d.ts +3 -2
  35. package/dist/core/modules/Carousel.js +25 -15
  36. package/dist/core/modules/Controller.d.ts +2 -2
  37. package/dist/core/modules/Controller.js +13 -11
  38. package/dist/core/modules/Core.d.ts +3 -2
  39. package/dist/core/modules/Core.js +5 -3
  40. package/dist/core/modules/Navigation.d.ts +3 -3
  41. package/dist/core/modules/Navigation.js +7 -5
  42. package/dist/core/modules/NoScroll.d.ts +3 -2
  43. package/dist/core/modules/NoScroll.js +7 -5
  44. package/dist/core/modules/Portal.d.ts +3 -2
  45. package/dist/core/modules/Portal.js +15 -12
  46. package/dist/core/modules/Toolbar.d.ts +3 -2
  47. package/dist/core/modules/Toolbar.js +5 -3
  48. package/dist/core/modules/controller/usePointerSwipe.d.ts +1 -1
  49. package/dist/core/modules/controller/usePointerSwipe.js +2 -2
  50. package/dist/core/modules/controller/usePreventSwipeNavigation.d.ts +1 -1
  51. package/dist/core/modules/controller/usePreventSwipeNavigation.js +4 -4
  52. package/dist/core/modules/controller/useWheelSwipe.d.ts +1 -1
  53. package/dist/core/modules/controller/useWheelSwipe.js +2 -2
  54. package/dist/core/utils.d.ts +6 -1
  55. package/dist/core/utils.js +7 -3
  56. package/dist/plugins/captions/CaptionsContext.d.ts +2 -3
  57. package/dist/plugins/captions/CaptionsContext.js +2 -2
  58. package/dist/plugins/captions/Description.d.ts +3 -4
  59. package/dist/plugins/captions/Description.js +17 -13
  60. package/dist/plugins/captions/Title.d.ts +3 -4
  61. package/dist/plugins/captions/Title.js +2 -2
  62. package/dist/plugins/captions/utils.d.ts +1 -1
  63. package/dist/plugins/captions/utils.js +3 -1
  64. package/dist/plugins/fullscreen/FullscreenButton.d.ts +2 -2
  65. package/dist/plugins/fullscreen/FullscreenButton.js +2 -2
  66. package/dist/plugins/fullscreen/FullscreenContext.d.ts +4 -4
  67. package/dist/plugins/fullscreen/FullscreenContext.js +2 -2
  68. package/dist/plugins/fullscreen/index.d.ts +9 -8
  69. package/dist/plugins/inline/Inline.js +3 -1
  70. package/dist/plugins/slideshow/SlideshowButton.d.ts +2 -2
  71. package/dist/plugins/slideshow/SlideshowButton.js +2 -2
  72. package/dist/plugins/slideshow/SlideshowContext.d.ts +4 -4
  73. package/dist/plugins/slideshow/SlideshowContext.js +2 -2
  74. package/dist/plugins/slideshow/index.d.ts +12 -11
  75. package/dist/plugins/thumbnails/Thumbnail.d.ts +3 -4
  76. package/dist/plugins/thumbnails/Thumbnail.js +19 -17
  77. package/dist/plugins/thumbnails/ThumbnailsContainer.d.ts +3 -2
  78. package/dist/plugins/thumbnails/ThumbnailsContainer.js +2 -2
  79. package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +3 -4
  80. package/dist/plugins/thumbnails/ThumbnailsTrack.js +9 -4
  81. package/dist/plugins/thumbnails/index.d.ts +9 -7
  82. package/dist/plugins/video/VideoSlide.d.ts +3 -4
  83. package/dist/plugins/video/VideoSlide.js +2 -2
  84. package/dist/plugins/zoom/ResponsiveImage.d.ts +5 -6
  85. package/dist/plugins/zoom/ResponsiveImage.js +6 -3
  86. package/dist/plugins/zoom/ZoomButtonsGroup.d.ts +2 -2
  87. package/dist/plugins/zoom/ZoomButtonsGroup.js +2 -2
  88. package/dist/plugins/zoom/ZoomContainer.d.ts +5 -4
  89. package/dist/plugins/zoom/ZoomContainer.js +10 -10
  90. package/dist/plugins/zoom/ZoomContext.d.ts +4 -4
  91. package/dist/plugins/zoom/ZoomContext.js +2 -2
  92. package/dist/plugins/zoom/index.d.ts +12 -13
  93. package/dist/props.d.ts +4 -0
  94. package/dist/props.js +5 -4
  95. package/dist/styles.css +1 -0
  96. package/dist/types.d.ts +46 -26
  97. package/package.json +1 -1
package/dist/types.d.ts CHANGED
@@ -78,13 +78,22 @@ export interface CarouselSettings {
78
78
  }
79
79
  /** Animation settings */
80
80
  export interface AnimationSettings {
81
- /** fade-in / fade-out animation duration */
82
- fade: number;
83
- /** swipe animation duration */
84
- swipe: number;
85
- /** override for `swipe` animation duration when using keyboard navigation or navigation buttons */
86
- navigation?: number;
81
+ /** fade-in / fade-out animation settings */
82
+ fade: AnimationSpec;
83
+ /** swipe animation settings */
84
+ swipe: AnimationSpec;
85
+ /** override for `swipe` animation settings when using keyboard navigation or navigation buttons */
86
+ navigation?: AnimationSpec;
87
87
  }
88
+ /** Animation duration or animation settings */
89
+ export type AnimationSpec = {
90
+ /** animation duration */
91
+ duration?: number;
92
+ /** animation easing function */
93
+ easing?: string;
94
+ }
95
+ /** animation duration */
96
+ | number;
88
97
  /** Controller settings */
89
98
  export interface ControllerSettings {
90
99
  /** if true, the lightbox captures focus when it opens */
@@ -96,38 +105,49 @@ export interface ControllerSettings {
96
105
  /** if `true`, close the lightbox when the backdrop is clicked */
97
106
  closeOnBackdropClick: boolean;
98
107
  }
99
- /** Custom render functions. */
100
- export interface Render {
101
- /** render custom slide type, or override the default image slide */
102
- slide?: (
108
+ /** Render function */
109
+ export type RenderFunction<T = void> = (props: T) => React.ReactNode;
110
+ /** `render.slide` render function props */
111
+ export type RenderSlideProps = [
103
112
  /** slide */
104
- slide: Slide,
113
+ slide: Slide,
105
114
  /** slide offset (`0` - current slide, `1` - next slide, `-1` - previous slide, etc.) */
106
- offset: number,
115
+ offset: number,
107
116
  /** container rect */
108
- rect: ContainerRect) => React.ReactNode;
117
+ rect: ContainerRect
118
+ ];
119
+ /** `render.slideHeader` render function props */
120
+ export type RenderSlideHeaderProps = [slide: Slide];
121
+ /** `render.slideFooter` render function props */
122
+ export type RenderSlideFooterProps = [slide: Slide];
123
+ /** `render.slideContainer` render function props */
124
+ export type RenderSlideContainerProps = [slide: Slide, children: React.ReactNode];
125
+ /** Custom render functions. */
126
+ export interface Render {
127
+ /** render custom slide type, or override the default image slide */
128
+ slide?: (...props: RenderSlideProps) => React.ReactNode;
109
129
  /** render custom slide header */
110
- slideHeader?: (slide: Slide) => React.ReactNode;
130
+ slideHeader?: (...props: RenderSlideHeaderProps) => React.ReactNode;
111
131
  /** render custom slide footer */
112
- slideFooter?: (slide: Slide) => React.ReactNode;
132
+ slideFooter?: (...props: RenderSlideFooterProps) => React.ReactNode;
113
133
  /** render custom slide container */
114
- slideContainer?: (slide: Slide, children: React.ReactNode) => React.ReactNode;
134
+ slideContainer?: (...props: RenderSlideContainerProps) => React.ReactNode;
115
135
  /** render custom Prev icon */
116
- iconPrev?: () => React.ReactNode;
136
+ iconPrev?: RenderFunction;
117
137
  /** render custom Next icon */
118
- iconNext?: () => React.ReactNode;
138
+ iconNext?: RenderFunction;
119
139
  /** render custom Close icon */
120
- iconClose?: () => React.ReactNode;
140
+ iconClose?: RenderFunction;
121
141
  /** render custom Loading icon */
122
- iconLoading?: () => React.ReactNode;
142
+ iconLoading?: RenderFunction;
123
143
  /** render custom Error icon */
124
- iconError?: () => React.ReactNode;
144
+ iconError?: RenderFunction;
125
145
  /** render custom Prev button */
126
- buttonPrev?: () => React.ReactNode;
146
+ buttonPrev?: RenderFunction;
127
147
  /** render custom Next button */
128
- buttonNext?: () => React.ReactNode;
148
+ buttonNext?: RenderFunction;
129
149
  /** render custom Close button */
130
- buttonClose?: () => React.ReactNode;
150
+ buttonClose?: RenderFunction;
131
151
  }
132
152
  /** Lifecycle callbacks */
133
153
  export interface Callbacks {
@@ -188,9 +208,9 @@ export interface ToolbarSettings {
188
208
  buttons: ("close" | React.ReactNode)[];
189
209
  }
190
210
  /** Lightbox component properties */
191
- export type ComponentProps = Omit<LightboxProps, "plugins">;
211
+ export type ComponentProps = React.PropsWithChildren<Omit<LightboxProps, "plugins">>;
192
212
  /** Lightbox component */
193
- export type Component = React.ComponentType<React.PropsWithChildren<ComponentProps>>;
213
+ export type Component = React.ComponentType<ComponentProps>;
194
214
  /** Lightbox module */
195
215
  export type Module = {
196
216
  /** module name */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",