yet-another-react-lightbox 3.21.7 → 3.21.8

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/dist/index.d.ts CHANGED
@@ -45,7 +45,7 @@ declare function stopNavigationEventsPropagation(): {
45
45
  };
46
46
  declare function calculatePreload(carousel: CarouselSettings, slides: Slide[], minimum?: number): number;
47
47
  declare function makeInertWhen(condition: boolean): {
48
- inert: string | boolean | undefined;
48
+ inert: boolean;
49
49
  };
50
50
 
51
51
  declare function createModule(name: string, component: Component): Module;
@@ -72,7 +72,7 @@ declare function useAnimation<T>(nodeRef: React.RefObject<HTMLElement | null>, c
72
72
 
73
73
  declare function useContainerRect<T extends HTMLElement = HTMLElement>(): {
74
74
  setContainerRef: (node: T | null) => void;
75
- containerRef: React.MutableRefObject<T | null>;
75
+ containerRef: React.RefObject<T | null>;
76
76
  containerRect: ContainerRect | undefined;
77
77
  };
78
78
 
@@ -108,7 +108,7 @@ type UseSensors<T extends Element> = {
108
108
  };
109
109
  declare function useSensors<T extends Element>(): UseSensors<T>;
110
110
 
111
- declare function useThrottle(callback: (...args: any[]) => void, delay: number): (...args: any[]) => void;
111
+ declare function useThrottle(callback: (...args: unknown[]) => void, delay: number): (...args: unknown[]) => void;
112
112
 
113
113
  type DocumentContextType = {
114
114
  getOwnerDocument: (node?: Node | null) => Document;
@@ -117,7 +117,7 @@ type DocumentContextType = {
117
117
  declare const DocumentContext: React.Context<DocumentContextType | null>;
118
118
  declare const useDocumentContext: () => DocumentContextType;
119
119
  type DocumentContextProviderProps = React.PropsWithChildren & {
120
- nodeRef: React.RefObject<Node>;
120
+ nodeRef: React.RefObject<Node | null>;
121
121
  };
122
122
  declare function DocumentContextProvider({ nodeRef, children }: DocumentContextProviderProps): React.JSX.Element;
123
123
 
@@ -241,7 +241,7 @@ type ControllerContextType = Pick<ControllerRef, "prev" | "next" | "close"> & {
241
241
  slideRect: ContainerRect;
242
242
  containerRect: ContainerRect;
243
243
  subscribeSensors: SubscribeSensors<HTMLDivElement>;
244
- containerRef: React.RefObject<HTMLDivElement>;
244
+ containerRef: React.RefObject<HTMLDivElement | null>;
245
245
  setCarouselRef: React.Ref<HTMLDivElement>;
246
246
  toolbarWidth: number | undefined;
247
247
  setToolbarWidth: (width: number | undefined) => void;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as React from 'react';
3
- import { IMAGE_FIT_COVER, IMAGE_FIT_CONTAIN, ACTION_CLOSE, MODULE_CONTROLLER, UNKNOWN_ACTION_TYPE, ELEMENT_BUTTON, ELEMENT_ICON, EVENT_ON_POINTER_DOWN, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_UP, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_CANCEL, EVENT_ON_KEY_DOWN, EVENT_ON_KEY_UP, EVENT_ON_WHEEL, SLIDE_STATUS_LOADING, activeSlideStatus, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_PLACEHOLDER, ACTION_PREV, ACTION_NEXT, ACTION_SWIPE, MODULE_PORTAL, CLASS_FLEX_CENTER, MODULE_CAROUSEL, CLASS_SLIDE_WRAPPER, VK_ARROW_RIGHT, VK_ARROW_LEFT, VK_ESCAPE, MODULE_NAVIGATION, CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, MODULE_NO_SCROLL, MODULE_ROOT, MODULE_TOOLBAR } from './types.js';
3
+ import { IMAGE_FIT_COVER, IMAGE_FIT_CONTAIN, ACTION_CLOSE, MODULE_CONTROLLER, UNKNOWN_ACTION_TYPE, ELEMENT_BUTTON, ELEMENT_ICON, EVENT_ON_WHEEL, EVENT_ON_KEY_UP, EVENT_ON_KEY_DOWN, EVENT_ON_POINTER_CANCEL, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_UP, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_DOWN, SLIDE_STATUS_LOADING, activeSlideStatus, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_PLACEHOLDER, ACTION_PREV, ACTION_NEXT, ACTION_SWIPE, MODULE_PORTAL, CLASS_FLEX_CENTER, MODULE_CAROUSEL, CLASS_SLIDE_WRAPPER, VK_ARROW_RIGHT, VK_ARROW_LEFT, VK_ESCAPE, MODULE_NAVIGATION, CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, MODULE_NO_SCROLL, MODULE_ROOT, MODULE_TOOLBAR } from './types.js';
4
4
  import { createPortal } from 'react-dom';
5
5
  export { ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_ERROR, ACTIVE_SLIDE_LOADING, ACTIVE_SLIDE_PLAYING, CLASS_FULLSIZE, CLASS_SLIDE_WRAPPER_INTERACTIVE, PLUGIN_CAPTIONS, PLUGIN_COUNTER, PLUGIN_DOWNLOAD, PLUGIN_FULLSCREEN, PLUGIN_INLINE, PLUGIN_SHARE, PLUGIN_SLIDESHOW, PLUGIN_THUMBNAILS, PLUGIN_ZOOM, SLIDE_STATUS_PLAYING } from './types.js';
6
6
 
@@ -454,8 +454,8 @@ function currentTransformation(node) {
454
454
  return { x, y, z };
455
455
  }
456
456
  function useAnimation(nodeRef, computeAnimation) {
457
- const snapshot = React.useRef();
458
- const animation = React.useRef();
457
+ const snapshot = React.useRef(undefined);
458
+ const animation = React.useRef(undefined);
459
459
  const reduceMotion = useMotionPreference();
460
460
  useLayoutEffect(() => {
461
461
  var _a, _b, _c;
@@ -490,7 +490,7 @@ function useAnimation(nodeRef, computeAnimation) {
490
490
 
491
491
  function useContainerRect() {
492
492
  const containerRef = React.useRef(null);
493
- const observerRef = React.useRef();
493
+ const observerRef = React.useRef(undefined);
494
494
  const [containerRect, setContainerRect] = React.useState();
495
495
  const setContainerRef = React.useCallback((node) => {
496
496
  containerRef.current = node;
@@ -521,7 +521,7 @@ function useContainerRect() {
521
521
  }
522
522
 
523
523
  function useDelay() {
524
- const timeoutId = React.useRef();
524
+ const timeoutId = React.useRef(undefined);
525
525
  const { setTimeout, clearTimeout } = useTimeouts();
526
526
  return React.useCallback((callback, delay) => {
527
527
  clearTimeout(timeoutId.current);
@@ -555,7 +555,7 @@ function useForkRef(refA, refB) {
555
555
  }
556
556
 
557
557
  function useLoseFocus(focus, disabled = false) {
558
- const focused = React.useRef();
558
+ const focused = React.useRef(false);
559
559
  useLayoutEffect(() => {
560
560
  if (disabled && focused.current) {
561
561
  focused.current = false;
@@ -722,7 +722,7 @@ const SWIPE_THRESHOLD = 30;
722
722
  function usePointerSwipe(subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel, pullUpEnabled, pullDownEnabled, onPullStart, onPullProgress, onPullFinish, onPullCancel) {
723
723
  const offset = React.useRef(0);
724
724
  const pointers = React.useRef([]);
725
- const activePointer = React.useRef();
725
+ const activePointer = React.useRef(undefined);
726
726
  const startTime = React.useRef(0);
727
727
  const gesture = React.useRef(Gesture.NONE);
728
728
  const clearPointer = React.useCallback((event) => {
@@ -837,10 +837,10 @@ function usePreventWheelDefaults({ preventDefaultWheelX, preventDefaultWheelY, }
837
837
  function useWheelSwipe(swipeState, subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) {
838
838
  const offset = React.useRef(0);
839
839
  const intent = React.useRef(0);
840
- const intentCleanup = React.useRef();
841
- const resetCleanup = React.useRef();
840
+ const intentCleanup = React.useRef(undefined);
841
+ const resetCleanup = React.useRef(undefined);
842
842
  const wheelInertia = React.useRef(0);
843
- const wheelInertiaCleanup = React.useRef();
843
+ const wheelInertiaCleanup = React.useRef(undefined);
844
844
  const startTime = React.useRef(0);
845
845
  const { setTimeout, clearTimeout } = useTimeouts();
846
846
  const cancelSwipeIntentCleanup = React.useCallback(() => {
@@ -63,9 +63,7 @@ function Description({ description }) {
63
63
  : null),
64
64
  ...styles.captionsDescription,
65
65
  } }, typeof description === "string"
66
- ? description
67
- .split("\n")
68
- .flatMap((line, index) => [...(index > 0 ? [React.createElement("br", { key: index })] : []), line])
66
+ ? description.split("\n").flatMap((line, index) => [...(index > 0 ? [React.createElement("br", { key: index })] : []), line])
69
67
  : description)));
70
68
  }
71
69
 
@@ -28,7 +28,7 @@ function corsEnabled(url) {
28
28
  try {
29
29
  xhr.send();
30
30
  }
31
- catch (e) {
31
+ catch (_) {
32
32
  }
33
33
  return xhr.status >= 200 && xhr.status <= 299;
34
34
  }
@@ -36,7 +36,7 @@ function click(link) {
36
36
  try {
37
37
  link.dispatchEvent(new MouseEvent("click"));
38
38
  }
39
- catch (e) {
39
+ catch (_) {
40
40
  const event = document.createEvent("MouseEvents");
41
41
  event.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
42
42
  link.dispatchEvent(event);
@@ -50,7 +50,7 @@ function FullscreenContextProvider({ fullscreen: fullscreenProps, on, children }
50
50
  container.msRequestFullscreen();
51
51
  }
52
52
  }
53
- catch (err) {
53
+ catch (_) {
54
54
  }
55
55
  }, []);
56
56
  const exit = React.useCallback(() => {
@@ -71,7 +71,7 @@ function FullscreenContextProvider({ fullscreen: fullscreenProps, on, children }
71
71
  ownerDocument.msExitFullscreen();
72
72
  }
73
73
  }
74
- catch (err) {
74
+ catch (_) {
75
75
  }
76
76
  }, [getFullscreenElement, getOwnerDocument]);
77
77
  React.useEffect(() => {
@@ -1,4 +1,4 @@
1
- import { LightboxRoot, clsx, cssClass, cssVar, createModule } from '../../index.js';
1
+ import { LightboxRoot, cssVar, clsx, cssClass, createModule } from '../../index.js';
2
2
  import * as React from 'react';
3
3
  import { ACTION_CLOSE, MODULE_NO_SCROLL, MODULE_PORTAL, PLUGIN_INLINE } from '../../types.js';
4
4
 
@@ -18,8 +18,8 @@ function SlideshowContextProvider({ slideshow, carousel: { finite }, on, childre
18
18
  const { autoplay, delay, ref } = resolveSlideshowProps(slideshow);
19
19
  const wasPlaying = React.useRef(autoplay);
20
20
  const [playing, setPlaying] = React.useState(autoplay);
21
- const scheduler = React.useRef();
22
- const slideStatus = React.useRef();
21
+ const scheduler = React.useRef(undefined);
22
+ const slideStatus = React.useRef(undefined);
23
23
  const { slides, currentIndex } = useLightboxState();
24
24
  const { setTimeout, clearTimeout } = useTimeouts();
25
25
  const { subscribe } = useEvents();
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useLightboxProps, composePrefix, createIcon, ImageSlide, isImageSlide, cssClass, makeComposePrefix, useDocumentContext, useEventCallback, clsx, cssVar, getSlideKey, useRTL, useEvents, useLightboxState, useSensors, useKeyboardNavigation, useAnimation, cleanup, calculatePreload, hasSlides, getSlide, makeUseContext, LightboxPropsProvider, createIconDisabled, IconButton, addToolbarButton, createModule } from '../../index.js';
2
+ import { useLightboxProps, composePrefix, createIcon, ImageSlide, isImageSlide, cssClass, makeComposePrefix, useDocumentContext, useEventCallback, cssVar, clsx, getSlideKey, useRTL, useEvents, useLightboxState, useSensors, useKeyboardNavigation, useAnimation, cleanup, calculatePreload, hasSlides, getSlide, makeUseContext, LightboxPropsProvider, createIconDisabled, IconButton, addToolbarButton, createModule } from '../../index.js';
3
3
  import { PLUGIN_THUMBNAILS, ELEMENT_ICON, CLASS_FLEX_CENTER, ACTION_SWIPE, ACTION_NEXT, ACTION_PREV, PLUGIN_FULLSCREEN, MODULE_CONTROLLER } from '../../types.js';
4
4
 
5
5
  const defaultThumbnailsProps = {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useLightboxProps, useEvents, useContainerRect, useEventCallback, clsx, cssClass } from '../../index.js';
3
- import { ACTIVE_SLIDE_LOADING, CLASS_FLEX_CENTER, CLASS_SLIDE_WRAPPER, ACTIVE_SLIDE_PLAYING, ACTIVE_SLIDE_COMPLETE } from '../../types.js';
3
+ import { ACTIVE_SLIDE_LOADING, CLASS_FLEX_CENTER, CLASS_SLIDE_WRAPPER, ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_PLAYING } from '../../types.js';
4
4
 
5
5
  const defaultVideoProps = {
6
6
  controls: true,
@@ -19,8 +19,8 @@ const resolveZoomProps = (zoom) => ({
19
19
  });
20
20
 
21
21
  function useZoomAnimation(zoom, offsetX, offsetY, zoomWrapperRef) {
22
- const zoomAnimation = React.useRef();
23
- const zoomAnimationStart = React.useRef();
22
+ const zoomAnimation = React.useRef(undefined);
23
+ const zoomAnimationStart = React.useRef(undefined);
24
24
  const { zoom: zoomAnimationDuration } = useLightboxProps().animation;
25
25
  const reduceMotion = useMotionPreference();
26
26
  const playZoomAnimation = useEventCallback(() => {
@@ -121,7 +121,7 @@ function scaleZoom(value, delta, factor = 100, clamp = 2) {
121
121
  function useZoomSensors(zoom, maxZoom, disabled, changeZoom, changeOffsets, zoomWrapperRef) {
122
122
  const activePointers = React.useRef([]);
123
123
  const lastPointerDown = React.useRef(0);
124
- const pinchZoomDistance = React.useRef();
124
+ const pinchZoomDistance = React.useRef(undefined);
125
125
  const { globalIndex } = useLightboxState();
126
126
  const { getOwnerWindow } = useDocumentContext();
127
127
  const { containerRef, subscribeSensors } = useController();
@@ -434,7 +434,7 @@ function ResponsiveImage(props) {
434
434
  Object.assign(style, rect.width / rect.height < width / height ? { width: "100%", height: "auto" } : { width: "auto", height: "100%" });
435
435
  }
436
436
  return (React.createElement(React.Fragment, null,
437
- preload && preload !== current && (React.createElement(ImageSlide, { key: "preload", ...props, slide: { ...image, src: preload, srcSet: undefined }, style: { position: "absolute", visibility: "hidden", ...style }, onLoad: () => handlePreload(preload), render: {
437
+ preload && preload !== current && (React.createElement(ImageSlide, { key: "preload", ...props, offset: undefined, slide: { ...image, src: preload, srcSet: undefined }, style: { position: "absolute", visibility: "hidden", ...style }, onLoad: () => handlePreload(preload), render: {
438
438
  ...render,
439
439
  iconLoading: () => null,
440
440
  iconError: () => null,
package/dist/types.d.ts CHANGED
@@ -425,10 +425,10 @@ interface PluginProps {
425
425
  /** Lightbox plugin */
426
426
  type Plugin = (props: PluginProps) => void;
427
427
  /** Deep partial utility type */
428
- type DeepPartial<T extends {}, K extends keyof T = keyof T, E extends string = never> = Omit<Partial<T>, K> & {
428
+ type DeepPartial<T extends object, K extends keyof T = keyof T, E extends string = never> = Omit<Partial<T>, K> & {
429
429
  [P in K]?: DeepPartialValue<T[P], E>;
430
430
  };
431
- type DeepPartialValue<T, E extends string = never> = T extends any[] ? T : T extends (...props: any[]) => any ? T : T extends {} ? {
431
+ type DeepPartialValue<T, E extends string = never> = T extends any[] ? T : T extends (...props: any[]) => any ? T : T extends object ? {
432
432
  [P in keyof T]?: P extends E ? T[P] : DeepPartialValue<T[P], E>;
433
433
  } : T;
434
434
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.21.7",
3
+ "version": "3.21.8",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -154,8 +154,18 @@
154
154
  "provenance": true
155
155
  },
156
156
  "peerDependencies": {
157
- "react": ">=16.8.0",
158
- "react-dom": ">=16.8.0"
157
+ "@types/react": "^16 || ^17 || ^18 || ^19",
158
+ "@types/react-dom": "^16 || ^17 || ^18 || ^19",
159
+ "react": "^16.8.0 || ^17 || ^18 || ^19",
160
+ "react-dom": "^16.8.0 || ^17 || ^18 || ^19"
161
+ },
162
+ "peerDependenciesMeta": {
163
+ "@types/react": {
164
+ "optional": true
165
+ },
166
+ "@types/react-dom": {
167
+ "optional": true
168
+ }
159
169
  },
160
170
  "keywords": [
161
171
  "react",