yet-another-react-lightbox 2.6.0 → 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 (94) 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 +2 -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 +1 -1
  15. package/dist/core/hooks/useAnimation.js +4 -4
  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 +2 -2
  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 +6 -4
  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 +7 -5
  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.js +2 -6
  55. package/dist/plugins/captions/CaptionsContext.d.ts +2 -3
  56. package/dist/plugins/captions/CaptionsContext.js +2 -2
  57. package/dist/plugins/captions/Description.d.ts +3 -4
  58. package/dist/plugins/captions/Description.js +17 -13
  59. package/dist/plugins/captions/Title.d.ts +3 -4
  60. package/dist/plugins/captions/Title.js +2 -2
  61. package/dist/plugins/captions/utils.d.ts +1 -1
  62. package/dist/plugins/captions/utils.js +3 -1
  63. package/dist/plugins/fullscreen/FullscreenButton.d.ts +2 -2
  64. package/dist/plugins/fullscreen/FullscreenButton.js +2 -2
  65. package/dist/plugins/fullscreen/FullscreenContext.d.ts +4 -4
  66. package/dist/plugins/fullscreen/FullscreenContext.js +2 -2
  67. package/dist/plugins/fullscreen/index.d.ts +9 -8
  68. package/dist/plugins/inline/Inline.js +3 -1
  69. package/dist/plugins/slideshow/SlideshowButton.d.ts +2 -2
  70. package/dist/plugins/slideshow/SlideshowButton.js +2 -2
  71. package/dist/plugins/slideshow/SlideshowContext.d.ts +4 -4
  72. package/dist/plugins/slideshow/SlideshowContext.js +2 -2
  73. package/dist/plugins/slideshow/index.d.ts +12 -11
  74. package/dist/plugins/thumbnails/Thumbnail.d.ts +3 -4
  75. package/dist/plugins/thumbnails/Thumbnail.js +19 -17
  76. package/dist/plugins/thumbnails/ThumbnailsContainer.d.ts +3 -2
  77. package/dist/plugins/thumbnails/ThumbnailsContainer.js +2 -2
  78. package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +3 -4
  79. package/dist/plugins/thumbnails/ThumbnailsTrack.js +8 -4
  80. package/dist/plugins/thumbnails/index.d.ts +9 -7
  81. package/dist/plugins/video/VideoSlide.d.ts +3 -4
  82. package/dist/plugins/video/VideoSlide.js +2 -2
  83. package/dist/plugins/zoom/ResponsiveImage.d.ts +5 -6
  84. package/dist/plugins/zoom/ResponsiveImage.js +6 -3
  85. package/dist/plugins/zoom/ZoomButtonsGroup.d.ts +2 -2
  86. package/dist/plugins/zoom/ZoomButtonsGroup.js +2 -2
  87. package/dist/plugins/zoom/ZoomContainer.d.ts +5 -4
  88. package/dist/plugins/zoom/ZoomContainer.js +7 -5
  89. package/dist/plugins/zoom/ZoomContext.d.ts +4 -4
  90. package/dist/plugins/zoom/ZoomContext.js +2 -2
  91. package/dist/plugins/zoom/index.d.ts +12 -13
  92. package/dist/styles.css +1 -0
  93. package/dist/types.d.ts +31 -20
  94. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
- import { Component } from "../../types.js";
2
- export declare const NoScroll: Component;
1
+ /// <reference types="react" />
2
+ import { ComponentProps } from "../../types.js";
3
+ export declare function NoScroll({ children }: ComponentProps): JSX.Element;
3
4
  export declare const NoScrollModule: import("../../types.js").Module;
@@ -5,8 +5,10 @@ import { useLayoutEffect, useRTL } from "../hooks/index.js";
5
5
  import { CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, MODULE_NO_SCROLL } from "../consts.js";
6
6
  const noScroll = cssClass(CLASS_NO_SCROLL);
7
7
  const noScrollPadding = cssClass(CLASS_NO_SCROLL_PADDING);
8
- const isHTMLElement = (element) => "style" in element;
9
- const padScrollbar = (element, padding, rtl) => {
8
+ function isHTMLElement(element) {
9
+ return "style" in element;
10
+ }
11
+ function padScrollbar(element, padding, rtl) {
10
12
  const styles = window.getComputedStyle(element);
11
13
  const property = rtl ? "padding-left" : "padding-right";
12
14
  const computedValue = rtl ? styles.paddingLeft : styles.paddingRight;
@@ -20,8 +22,8 @@ const padScrollbar = (element, padding, rtl) => {
20
22
  element.style.removeProperty(property);
21
23
  }
22
24
  };
23
- };
24
- export const NoScroll = ({ children }) => {
25
+ }
26
+ export function NoScroll({ children }) {
25
27
  const rtl = useRTL();
26
28
  useLayoutEffect(() => {
27
29
  const cleanup = [];
@@ -46,5 +48,5 @@ export const NoScroll = ({ children }) => {
46
48
  };
47
49
  }, [rtl]);
48
50
  return React.createElement(React.Fragment, null, children);
49
- };
51
+ }
50
52
  export const NoScrollModule = createModule(MODULE_NO_SCROLL, NoScroll);
@@ -1,3 +1,4 @@
1
- import { Component } from "../../types.js";
2
- export declare const Portal: Component;
1
+ import * as React from "react";
2
+ import { ComponentProps } from "../../types.js";
3
+ export declare function Portal({ children, animation, styles, className, on, close }: ComponentProps): React.ReactPortal | null;
3
4
  export declare const PortalModule: import("../../types.js").Module;
@@ -6,8 +6,10 @@ import { clsx, composePrefix, cssClass, cssVar, getAnimationEasing, getFadeAnima
6
6
  import { useEventCallback, useMotionPreference } from "../hooks/index.js";
7
7
  import { useEvents, useTimeouts } from "../contexts/index.js";
8
8
  import { ACTION_CLOSE, CLASS_NO_SCROLL_PADDING, MODULE_PORTAL } from "../consts.js";
9
- const cssPrefix = (value) => composePrefix(MODULE_PORTAL, value);
10
- const setAttribute = (element, attribute, value) => {
9
+ function cssPrefix(value) {
10
+ return composePrefix(MODULE_PORTAL, value);
11
+ }
12
+ function setAttribute(element, attribute, value) {
11
13
  const previousValue = element.getAttribute(attribute);
12
14
  element.setAttribute(attribute, value);
13
15
  return () => {
@@ -18,8 +20,8 @@ const setAttribute = (element, attribute, value) => {
18
20
  element.removeAttribute(attribute);
19
21
  }
20
22
  };
21
- };
22
- export const Portal = ({ children, animation, styles, className, on, close }) => {
23
+ }
24
+ export function Portal({ children, animation, styles, className, on, close }) {
23
25
  const [mounted, setMounted] = React.useState(false);
24
26
  const [visible, setVisible] = React.useState(false);
25
27
  const cleanup = React.useRef([]);
@@ -85,5 +87,5 @@ export const Portal = ({ children, animation, styles, className, on, close }) =>
85
87
  ...styles.root,
86
88
  } }, children), document.body)
87
89
  : null;
88
- };
90
+ }
89
91
  export const PortalModule = createModule(MODULE_PORTAL, Portal);
@@ -1,9 +1,10 @@
1
- import { Component } from "../../types.js";
1
+ /// <reference types="react" />
2
+ import { ComponentProps } from "../../types.js";
2
3
  import { YARL_EVENT_TOOLBAR_WIDTH } from "../consts.js";
3
4
  declare module "../" {
4
5
  interface EventTypes {
5
6
  [YARL_EVENT_TOOLBAR_WIDTH]: number;
6
7
  }
7
8
  }
8
- export declare const Toolbar: Component;
9
+ export declare function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }: ComponentProps): JSX.Element;
9
10
  export declare const ToolbarModule: import("../../types.js").Module;
@@ -5,8 +5,10 @@ import { useEvents } from "../contexts/index.js";
5
5
  import { CloseIcon, IconButton } from "../components/index.js";
6
6
  import { useContainerRect } from "../hooks/useContainerRect.js";
7
7
  import { ACTION_CLOSE, MODULE_TOOLBAR, YARL_EVENT_TOOLBAR_WIDTH } from "../consts.js";
8
- const cssPrefix = (value) => composePrefix(MODULE_TOOLBAR, value);
9
- export const Toolbar = ({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }) => {
8
+ function cssPrefix(value) {
9
+ return composePrefix(MODULE_TOOLBAR, value);
10
+ }
11
+ export function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }) {
10
12
  const { publish } = useEvents();
11
13
  const { setContainerRef, containerRect } = useContainerRect();
12
14
  React.useEffect(() => {
@@ -16,5 +18,5 @@ export const Toolbar = ({ toolbar: { buttons }, labels, render: { buttonClose, i
16
18
  }, [publish, containerRect === null || containerRect === void 0 ? void 0 : containerRect.width]);
17
19
  const renderCloseButton = () => buttonClose ? (buttonClose()) : (React.createElement(IconButton, { key: ACTION_CLOSE, label: label(labels, "Close"), icon: CloseIcon, renderIcon: iconClose, onClick: () => publish(ACTION_CLOSE) }));
18
20
  return (React.createElement("div", { ref: setContainerRef, className: cssClass(cssPrefix()) }, buttons === null || buttons === void 0 ? void 0 : buttons.map((button) => (button === ACTION_CLOSE ? renderCloseButton() : button))));
19
- };
21
+ }
20
22
  export const ToolbarModule = createModule(MODULE_TOOLBAR, Toolbar);
@@ -1,2 +1,2 @@
1
1
  import { UseSensors } from "../../hooks/useSensors.js";
2
- export declare const usePointerSwipe: <T extends Element = Element>(subscribeSensors: import("../../hooks/useSensors.js").SubscribeSensors<T>, isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void) => void;
2
+ export declare function usePointerSwipe<T extends Element = Element>(subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void): void;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { cleanup } from "../../utils.js";
3
3
  import { useEventCallback } from "../../hooks/useEventCallback.js";
4
4
  import { EVENT_ON_POINTER_CANCEL, EVENT_ON_POINTER_DOWN, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_UP, } from "../../consts.js";
5
- export const usePointerSwipe = (subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) => {
5
+ export function usePointerSwipe(subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) {
6
6
  const offset = React.useRef(0);
7
7
  const pointers = React.useRef([]);
8
8
  const activePointer = React.useRef();
@@ -69,4 +69,4 @@ export const usePointerSwipe = (subscribeSensors, isSwipeValid, containerWidth,
69
69
  }
70
70
  });
71
71
  React.useEffect(() => cleanup(subscribeSensors(EVENT_ON_POINTER_DOWN, onPointerDown), subscribeSensors(EVENT_ON_POINTER_MOVE, onPointerMove), subscribeSensors(EVENT_ON_POINTER_UP, onPointerUp), subscribeSensors(EVENT_ON_POINTER_LEAVE, onPointerUp), subscribeSensors(EVENT_ON_POINTER_CANCEL, onPointerUp)), [subscribeSensors, onPointerDown, onPointerMove, onPointerUp]);
72
- };
72
+ }
@@ -1,3 +1,3 @@
1
1
  /** prevent browser back/forward navigation on touchpad left/right swipe (especially noticeable in Safari)
2
2
  * this has to be done via non-passive native event handler */
3
- export declare const usePreventSwipeNavigation: <T extends HTMLElement = HTMLElement>() => (node: T | null) => void;
3
+ export declare function usePreventSwipeNavigation<T extends HTMLElement = HTMLElement>(): (node: T | null) => void;
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  const WHEEL = "wheel";
3
- const preventDefault = (event) => {
3
+ function preventDefault(event) {
4
4
  if (Math.abs(event.deltaX) > Math.abs(event.deltaY) || event.ctrlKey) {
5
5
  event.preventDefault();
6
6
  }
7
- };
8
- export const usePreventSwipeNavigation = () => {
7
+ }
8
+ export function usePreventSwipeNavigation() {
9
9
  const ref = React.useRef(null);
10
10
  return React.useCallback((node) => {
11
11
  var _a;
@@ -17,4 +17,4 @@ export const usePreventSwipeNavigation = () => {
17
17
  }
18
18
  ref.current = node;
19
19
  }, []);
20
- };
20
+ }
@@ -1,3 +1,3 @@
1
1
  import { UseSensors } from "../../hooks/index.js";
2
2
  import { SwipeState } from "./index.js";
3
- export declare const useWheelSwipe: <T extends Element = Element>(swipeState: SwipeState, subscribeSensors: import("../../hooks/useSensors.js").SubscribeSensors<T>, isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void) => void;
3
+ export declare function useWheelSwipe<T extends Element = Element>(swipeState: SwipeState, subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void): void;
@@ -3,7 +3,7 @@ import { useEventCallback } from "../../hooks/index.js";
3
3
  import { useTimeouts } from "../../contexts/index.js";
4
4
  import { SwipeState } from "./index.js";
5
5
  import { EVENT_ON_WHEEL } from "../../consts.js";
6
- export const useWheelSwipe = (swipeState, subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) => {
6
+ export function useWheelSwipe(swipeState, subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) {
7
7
  const offset = React.useRef(0);
8
8
  const intent = React.useRef(0);
9
9
  const intentCleanup = React.useRef();
@@ -89,4 +89,4 @@ export const useWheelSwipe = (swipeState, subscribeSensors, isSwipeValid, contai
89
89
  }
90
90
  });
91
91
  React.useEffect(() => subscribeSensors(EVENT_ON_WHEEL, onWheel), [subscribeSensors, onWheel]);
92
- };
92
+ }
@@ -37,15 +37,11 @@ export const parseLengthPercentage = (input) => {
37
37
  }
38
38
  return { pixel: 0 };
39
39
  };
40
- export const devicePixelRatio = () => {
41
- return (typeof window !== "undefined" ? window === null || window === void 0 ? void 0 : window.devicePixelRatio : undefined) || 1;
42
- };
40
+ export const devicePixelRatio = () => (typeof window !== "undefined" ? window === null || window === void 0 ? void 0 : window.devicePixelRatio : undefined) || 1;
43
41
  export const getSlideIndex = (index, slidesCount) => ((index % slidesCount) + slidesCount) % slidesCount;
44
42
  export const getSlide = (slides, index) => slides[getSlideIndex(index, slides.length)];
45
43
  export const getAnimationEasing = (animationSpec) => typeof animationSpec === "object" ? animationSpec.easing : undefined;
46
44
  export const getAnimationDuration = (animationSpec, defaultDuration) => { var _a; return (_a = (typeof animationSpec === "object" ? animationSpec.duration : animationSpec)) !== null && _a !== void 0 ? _a : defaultDuration; };
47
45
  export const getFadeAnimationDuration = (animation) => getAnimationDuration(animation.fade, AnimationDefaultProps.fade);
48
46
  export const getSwipeAnimationDuration = (animation) => getAnimationDuration(animation.swipe, AnimationDefaultProps.swipe);
49
- export const getNavigationAnimationDuration = (animation) => {
50
- return getAnimationDuration(animation.navigation, getSwipeAnimationDuration(animation));
51
- };
47
+ export const getNavigationAnimationDuration = (animation) => getAnimationDuration(animation.navigation, getSwipeAnimationDuration(animation));
@@ -1,8 +1,7 @@
1
1
  import * as React from "react";
2
- type CaptionsContextType = {
2
+ export type CaptionsContextType = {
3
3
  toolbarWidth?: number;
4
4
  };
5
5
  export declare const useCaptions: () => CaptionsContextType;
6
6
  /** Captions plugin context holder */
7
- export declare const CaptionsContextProvider: React.FC<React.PropsWithChildren>;
8
- export {};
7
+ export declare function CaptionsContextProvider({ children }: React.PropsWithChildren): JSX.Element;
@@ -2,10 +2,10 @@ import * as React from "react";
2
2
  import { makeUseContext, useEvents, YARL_EVENT_TOOLBAR_WIDTH } from "../../core/index.js";
3
3
  const CaptionsContext = React.createContext(null);
4
4
  export const useCaptions = makeUseContext("useCaptions", "CaptionsContext", CaptionsContext);
5
- export const CaptionsContextProvider = ({ children }) => {
5
+ export function CaptionsContextProvider({ children }) {
6
6
  const { subscribe } = useEvents();
7
7
  const [toolbarWidth, setToolbarWidth] = React.useState();
8
8
  React.useEffect(() => subscribe(YARL_EVENT_TOOLBAR_WIDTH, (event) => setToolbarWidth(event)), [subscribe]);
9
9
  const context = React.useMemo(() => ({ toolbarWidth }), [toolbarWidth]);
10
10
  return React.createElement(CaptionsContext.Provider, { value: context }, children);
11
- };
11
+ }
@@ -1,5 +1,4 @@
1
- import * as React from "react";
1
+ /// <reference types="react" />
2
2
  import { LightboxProps, Slide } from "../../types.js";
3
- type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
4
- export declare const Description: React.FC<DescriptionProps>;
5
- export {};
3
+ export type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
4
+ export declare function Description({ description, descriptionTextAlign, descriptionMaxLines, styles }: DescriptionProps): JSX.Element;
@@ -2,16 +2,20 @@ import * as React from "react";
2
2
  import { clsx, cssVar } from "../../core/index.js";
3
3
  import { defaultCaptionsProps } from "./Captions.js";
4
4
  import { cssPrefix } from "./utils.js";
5
- export const Description = ({ description, descriptionTextAlign, descriptionMaxLines, styles, }) => (React.createElement("div", { style: styles.captionsDescriptionContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("description_container")) },
6
- React.createElement("div", { className: cssPrefix("description"), style: {
7
- ...(descriptionTextAlign !== defaultCaptionsProps.descriptionTextAlign ||
8
- descriptionMaxLines !== defaultCaptionsProps.descriptionMaxLines
9
- ? {
10
- [cssVar("slide_description_text_align")]: descriptionTextAlign,
11
- [cssVar("slide_description_max_lines")]: descriptionMaxLines,
12
- }
13
- : null),
14
- ...styles.captionsDescription,
15
- } }, typeof description === "string"
16
- ? description.split("\n").flatMap((line, index) => [...(index > 0 ? [React.createElement("br", { key: index })] : []), line])
17
- : description)));
5
+ export function Description({ description, descriptionTextAlign, descriptionMaxLines, styles }) {
6
+ return (React.createElement("div", { style: styles.captionsDescriptionContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("description_container")) },
7
+ React.createElement("div", { className: cssPrefix("description"), style: {
8
+ ...(descriptionTextAlign !== defaultCaptionsProps.descriptionTextAlign ||
9
+ descriptionMaxLines !== defaultCaptionsProps.descriptionMaxLines
10
+ ? {
11
+ [cssVar("slide_description_text_align")]: descriptionTextAlign,
12
+ [cssVar("slide_description_max_lines")]: descriptionMaxLines,
13
+ }
14
+ : null),
15
+ ...styles.captionsDescription,
16
+ } }, typeof description === "string"
17
+ ? description
18
+ .split("\n")
19
+ .flatMap((line, index) => [...(index > 0 ? [React.createElement("br", { key: index })] : []), line])
20
+ : description)));
21
+ }
@@ -1,5 +1,4 @@
1
- import * as React from "react";
1
+ /// <reference types="react" />
2
2
  import { LightboxProps, Slide } from "../../types.js";
3
- type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
4
- export declare const Title: React.FC<TitleProps>;
5
- export {};
3
+ export type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
4
+ export declare function Title({ title, styles }: TitleProps): JSX.Element;
@@ -2,8 +2,8 @@ import * as React from "react";
2
2
  import { clsx, cssVar } from "../../core/index.js";
3
3
  import { useCaptions } from "./CaptionsContext.js";
4
4
  import { cssPrefix } from "./utils.js";
5
- export const Title = ({ title, styles }) => {
5
+ export function Title({ title, styles }) {
6
6
  const { toolbarWidth } = useCaptions();
7
7
  return (React.createElement("div", { style: styles.captionsTitleContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("title_container")) },
8
8
  React.createElement("div", { style: styles.captionsTitle, className: cssPrefix("title"), ...(toolbarWidth ? { style: { [cssVar("toolbar_width")]: `${toolbarWidth}px` } } : null) }, title)));
9
- };
9
+ }
@@ -1 +1 @@
1
- export declare const cssPrefix: (className: string) => string;
1
+ export declare function cssPrefix(className: string): string;
@@ -1,2 +1,4 @@
1
1
  import { cssClass } from "../../core/index.js";
2
- export const cssPrefix = (className) => cssClass(`slide_${className}`);
2
+ export function cssPrefix(className) {
3
+ return cssClass(`slide_${className}`);
4
+ }
@@ -1,3 +1,3 @@
1
- import * as React from "react";
1
+ /// <reference types="react" />
2
2
  /** Fullscreen button */
3
- export declare const FullscreenButton: React.FC;
3
+ export declare function FullscreenButton(): JSX.Element | null;
@@ -3,11 +3,11 @@ import { createIcon, IconButton, label, useController } from "../../core/index.j
3
3
  import { useFullscreen } from "./FullscreenContext.js";
4
4
  const EnterFullscreenIcon = createIcon("EnterFullscreen", React.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }));
5
5
  const ExitFullscreenIcon = createIcon("ExitFullscreen", React.createElement("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }));
6
- export const FullscreenButton = () => {
6
+ export function FullscreenButton() {
7
7
  var _a;
8
8
  const { labels, render } = useController().getLightboxProps();
9
9
  const { fullscreen, fullscreenEnabled, toggleFullscreen } = useFullscreen();
10
10
  if (!fullscreenEnabled)
11
11
  return null;
12
12
  return render.buttonFullscreen ? (React.createElement(React.Fragment, null, (_a = render.buttonFullscreen) === null || _a === void 0 ? void 0 : _a.call(render, { fullscreen, fullscreenEnabled, toggleFullscreen }))) : (React.createElement(IconButton, { disabled: !fullscreenEnabled, label: fullscreen ? label(labels, "Exit Fullscreen") : label(labels, "Enter Fullscreen"), icon: fullscreen ? ExitFullscreenIcon : EnterFullscreenIcon, renderIcon: fullscreen ? render.iconExitFullscreen : render.iconEnterFullscreen, onClick: toggleFullscreen }));
13
- };
13
+ }
@@ -1,9 +1,9 @@
1
- import { Component } from "../../types.js";
2
- type FullscreenContextType = {
1
+ /// <reference types="react" />
2
+ import { ComponentProps } from "../../types.js";
3
+ export type FullscreenContextType = {
3
4
  fullscreen: boolean;
4
5
  fullscreenEnabled?: boolean;
5
6
  toggleFullscreen: () => void;
6
7
  };
7
8
  export declare const useFullscreen: () => FullscreenContextType;
8
- export declare const FullscreenContextProvider: Component;
9
- export {};
9
+ export declare function FullscreenContextProvider({ fullscreen: auto, children }: ComponentProps): JSX.Element;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { CLASS_FULLSIZE, clsx, cssClass, makeUseContext, PLUGIN_FULLSCREEN, useEventCallback, useLayoutEffect, } from "../../core/index.js";
3
3
  const FullscreenContext = React.createContext(null);
4
4
  export const useFullscreen = makeUseContext("useFullscreen", "FullscreenContext", FullscreenContext);
5
- export const FullscreenContextProvider = ({ fullscreen: auto, children }) => {
5
+ export function FullscreenContextProvider({ fullscreen: auto, children }) {
6
6
  const containerRef = React.useRef(null);
7
7
  const [fullscreen, setFullscreen] = React.useState(false);
8
8
  const [fullscreenEnabled, setFullscreenEnabled] = React.useState();
@@ -100,4 +100,4 @@ export const FullscreenContextProvider = ({ fullscreen: auto, children }) => {
100
100
  }), [fullscreen, fullscreenEnabled, toggleFullscreen]);
101
101
  return (React.createElement("div", { ref: containerRef, className: clsx(cssClass(PLUGIN_FULLSCREEN), cssClass(CLASS_FULLSIZE)) },
102
102
  React.createElement(FullscreenContext.Provider, { value: context }, children)));
103
- };
103
+ }
@@ -1,21 +1,22 @@
1
- import * as React from "react";
2
1
  import { Fullscreen } from "./Fullscreen.js";
3
2
  declare module "../../types" {
4
3
  interface LightboxProps {
5
4
  /** if `true`, enter fullscreen mode automatically when the lightbox opens */
6
5
  fullscreen?: boolean;
7
6
  }
7
+ /** `render.buttonFullscreen` render function props */
8
+ type RenderFullscreenButtonProps = {
9
+ fullscreen: boolean;
10
+ fullscreenEnabled: boolean | undefined;
11
+ toggleFullscreen: () => void;
12
+ };
8
13
  interface Render {
9
14
  /** render custom Enter/Exit Fullscreen button */
10
- buttonFullscreen?: ({ fullscreen, fullscreenEnabled, toggleFullscreen, }: {
11
- fullscreen: boolean;
12
- fullscreenEnabled: boolean | undefined;
13
- toggleFullscreen: () => void;
14
- }) => React.ReactNode;
15
+ buttonFullscreen?: RenderFunction<RenderFullscreenButtonProps>;
15
16
  /** render custom Enter Fullscreen icon */
16
- iconEnterFullscreen?: () => React.ReactNode;
17
+ iconEnterFullscreen?: RenderFunction;
17
18
  /** render custom Exit Fullscreen icon */
18
- iconExitFullscreen?: () => React.ReactNode;
19
+ iconExitFullscreen?: RenderFunction;
19
20
  }
20
21
  }
21
22
  declare global {
@@ -1,6 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { ACTION_CLOSE, clsx, createModule, cssClass, MODULE_NO_SCROLL, MODULE_PORTAL, PLUGIN_INLINE, } from "../../core/index.js";
3
- const InlineContainer = ({ inline: { className, ...rest } = {}, children }) => (React.createElement("div", { className: clsx(cssClass("root"), cssClass("relative"), className), ...rest }, children));
3
+ function InlineContainer({ inline: { className, ...rest } = {}, children }) {
4
+ return (React.createElement("div", { className: clsx(cssClass("root"), cssClass("relative"), className), ...rest }, children));
5
+ }
4
6
  export const Inline = ({ augment, replace, remove }) => {
5
7
  augment(({ toolbar: { buttons, ...restToolbar }, open, close, controller: { focus, aria, touchAction, ...restController }, className, ...restProps }) => ({
6
8
  open: true,
@@ -1,2 +1,2 @@
1
- import * as React from "react";
2
- export declare const SlideshowButton: React.FC;
1
+ /// <reference types="react" />
2
+ export declare function SlideshowButton(): JSX.Element;
@@ -3,10 +3,10 @@ import { createIcon, IconButton, label, useController, useLoseFocus } from "../.
3
3
  import { useSlideshow } from "./SlideshowContext.js";
4
4
  const PlayIcon = createIcon("Play", React.createElement("path", { d: "M8 5v14l11-7z" }));
5
5
  const PauseIcon = createIcon("Pause", React.createElement("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }));
6
- export const SlideshowButton = () => {
6
+ export function SlideshowButton() {
7
7
  const { playing, disabled, togglePlaying } = useSlideshow();
8
8
  const { getLightboxProps } = useController();
9
9
  const { render, labels } = getLightboxProps();
10
10
  const focusListeners = useLoseFocus(disabled);
11
11
  return render.buttonSlideshow ? (React.createElement(React.Fragment, null, render.buttonSlideshow({ playing, togglePlaying, disabled }))) : (React.createElement(IconButton, { label: playing ? label(labels, "Pause") : label(labels, "Play"), icon: playing ? PauseIcon : PlayIcon, renderIcon: playing ? render.iconSlideshowPause : render.iconSlideshowPlay, onClick: togglePlaying, disabled: disabled, ...focusListeners }));
12
- };
12
+ }
@@ -1,9 +1,9 @@
1
- import { Component } from "../../types.js";
2
- type SlideshowContextType = {
1
+ /// <reference types="react" />
2
+ import { ComponentProps } from "../../types.js";
3
+ export type SlideshowContextType = {
3
4
  playing: boolean;
4
5
  disabled: boolean;
5
6
  togglePlaying: () => void;
6
7
  };
7
8
  export declare const useSlideshow: () => SlideshowContextType;
8
- export declare const SlideshowContextProvider: Component;
9
- export {};
9
+ export declare function SlideshowContextProvider({ slides, slideshow, carousel: { finite }, children }: ComponentProps): JSX.Element;
@@ -3,7 +3,7 @@ import { ACTION_NEXT, ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_ERROR, ACTIVE_SLIDE_LO
3
3
  import { defaultSlideshowProps } from "./Slideshow.js";
4
4
  const SlideshowContext = React.createContext(null);
5
5
  export const useSlideshow = makeUseContext("useSlideshow", "SlideshowContext", SlideshowContext);
6
- export const SlideshowContextProvider = ({ slides, slideshow, carousel: { finite }, children }) => {
6
+ export function SlideshowContextProvider({ slides, slideshow, carousel: { finite }, children }) {
7
7
  const { autoplay, delay } = { ...defaultSlideshowProps, ...slideshow };
8
8
  const [playing, setPlaying] = React.useState(autoplay);
9
9
  const scheduler = React.useRef();
@@ -55,4 +55,4 @@ export const SlideshowContextProvider = ({ slides, slideshow, carousel: { finite
55
55
  })), [subscribe, cancelScheduler, scheduleNextSlide]);
56
56
  const context = React.useMemo(() => ({ playing, disabled, togglePlaying }), [playing, disabled, togglePlaying]);
57
57
  return React.createElement(SlideshowContext.Provider, { value: context }, children);
58
- };
58
+ }
@@ -1,4 +1,3 @@
1
- import * as React from "react";
2
1
  import { Slideshow } from "./Slideshow.js";
3
2
  declare module "../../types" {
4
3
  interface LightboxProps {
@@ -10,20 +9,22 @@ declare module "../../types" {
10
9
  delay?: number;
11
10
  };
12
11
  }
12
+ /** `render.buttonSlideshow` render function props */
13
+ type RenderSlideshowButtonProps = {
14
+ /** current slideshow autoplay status */
15
+ playing: boolean;
16
+ /** toggle slideshow autoplay status */
17
+ togglePlaying: () => void;
18
+ /** if `true`, the button is disabled */
19
+ disabled: boolean;
20
+ };
13
21
  interface Render {
14
22
  /** render custom Slideshow Play icon */
15
- iconSlideshowPlay?: () => React.ReactNode;
23
+ iconSlideshowPlay?: RenderFunction;
16
24
  /** render custom Slideshow Pause icon */
17
- iconSlideshowPause?: () => React.ReactNode;
25
+ iconSlideshowPause?: RenderFunction;
18
26
  /** render custom Slideshow button */
19
- buttonSlideshow?: ({ playing, togglePlaying, disabled, }: {
20
- /** current slideshow autoplay status */
21
- playing: boolean;
22
- /** toggle slideshow autoplay status */
23
- togglePlaying: () => void;
24
- /** if `true`, the button is disabled */
25
- disabled: boolean;
26
- }) => React.ReactNode;
27
+ buttonSlideshow?: RenderFunction<RenderSlideshowButtonProps>;
27
28
  }
28
29
  }
29
30
  export default Slideshow;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { ContainerRect, ImageFit, LightboxProps, Slide } from "../../types.js";
3
- type FadeSettings = {
3
+ export type FadeSettings = {
4
4
  duration: number;
5
5
  delay: number;
6
6
  };
7
- type ThumbnailProps = {
7
+ export type ThumbnailProps = {
8
8
  rect: ContainerRect;
9
9
  slide: Slide | null;
10
10
  onClick: () => void;
@@ -16,5 +16,4 @@ type ThumbnailProps = {
16
16
  imageFit: ImageFit;
17
17
  style?: React.CSSProperties;
18
18
  };
19
- export declare const Thumbnail: React.FC<ThumbnailProps>;
20
- export {};
19
+ export declare function Thumbnail({ rect, slide, onClick, active, fadeIn, fadeOut, placeholder, render, imageFit, style, }: ThumbnailProps): JSX.Element;
@@ -3,7 +3,7 @@ import { CLASS_FLEX_CENTER, CLASS_FULLSIZE, clsx, createIcon, cssClass, cssVar,
3
3
  import { cssPrefix, cssThumbnailPrefix } from "./utils.js";
4
4
  const VideoThumbnailIcon = createIcon("VideoThumbnail", React.createElement("path", { d: "M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" }));
5
5
  const UnknownThumbnailIcon = createIcon("UnknownThumbnail", React.createElement("path", { d: "M23 18V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zM8.5 12.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z" }));
6
- const renderThumbnail = ({ slide, render, rect, imageFit }) => {
6
+ function renderThumbnail({ slide, render, rect, imageFit }) {
7
7
  var _a;
8
8
  const customThumbnail = (_a = render.thumbnail) === null || _a === void 0 ? void 0 : _a.call(render, { slide, render, rect, imageFit });
9
9
  if (customThumbnail) {
@@ -21,25 +21,27 @@ const renderThumbnail = ({ slide, render, rect, imageFit }) => {
21
21
  return React.createElement(ImageSlide, { slide: slide, render: render, rect: rect, imageFit: imageFit });
22
22
  }
23
23
  return React.createElement(UnknownThumbnailIcon, { className: thumbnailIconClass });
24
- };
24
+ }
25
25
  const activePrefix = makeComposePrefix("active");
26
26
  const fadeInPrefix = makeComposePrefix("fadein");
27
27
  const fadeOutPrefix = makeComposePrefix("fadeout");
28
28
  const placeholderPrefix = makeComposePrefix("placeholder");
29
29
  const DELAY = "delay";
30
30
  const DURATION = "duration";
31
- export const Thumbnail = ({ rect, slide, onClick, active, fadeIn, fadeOut, placeholder, render, imageFit, style, }) => (React.createElement("button", { type: "button", className: clsx(cssClass(CLASS_FLEX_CENTER), cssClass(cssThumbnailPrefix()), active && cssClass(cssThumbnailPrefix(activePrefix())), fadeIn && cssClass(cssThumbnailPrefix(fadeInPrefix())), fadeOut && cssClass(cssThumbnailPrefix(fadeOutPrefix())), placeholder && cssClass(cssThumbnailPrefix(placeholderPrefix()))), style: {
32
- ...(fadeIn
33
- ? {
34
- [cssVar(cssThumbnailPrefix(fadeInPrefix(DURATION)))]: `${fadeIn.duration}ms`,
35
- [cssVar(cssThumbnailPrefix(fadeInPrefix(DELAY)))]: `${fadeIn.delay}ms`,
36
- }
37
- : null),
38
- ...(fadeOut
39
- ? {
40
- [cssVar(cssThumbnailPrefix(fadeOutPrefix(DURATION)))]: `${fadeOut.duration}ms`,
41
- [cssVar(cssThumbnailPrefix(fadeOutPrefix(DELAY)))]: `${fadeOut.delay}ms`,
42
- }
43
- : null),
44
- ...style,
45
- }, onClick: onClick }, slide && renderThumbnail({ slide, render, rect, imageFit })));
31
+ export function Thumbnail({ rect, slide, onClick, active, fadeIn, fadeOut, placeholder, render, imageFit, style, }) {
32
+ return (React.createElement("button", { type: "button", className: clsx(cssClass(CLASS_FLEX_CENTER), cssClass(cssThumbnailPrefix()), active && cssClass(cssThumbnailPrefix(activePrefix())), fadeIn && cssClass(cssThumbnailPrefix(fadeInPrefix())), fadeOut && cssClass(cssThumbnailPrefix(fadeOutPrefix())), placeholder && cssClass(cssThumbnailPrefix(placeholderPrefix()))), style: {
33
+ ...(fadeIn
34
+ ? {
35
+ [cssVar(cssThumbnailPrefix(fadeInPrefix(DURATION)))]: `${fadeIn.duration}ms`,
36
+ [cssVar(cssThumbnailPrefix(fadeInPrefix(DELAY)))]: `${fadeIn.delay}ms`,
37
+ }
38
+ : null),
39
+ ...(fadeOut
40
+ ? {
41
+ [cssVar(cssThumbnailPrefix(fadeOutPrefix(DURATION)))]: `${fadeOut.duration}ms`,
42
+ [cssVar(cssThumbnailPrefix(fadeOutPrefix(DELAY)))]: `${fadeOut.delay}ms`,
43
+ }
44
+ : null),
45
+ ...style,
46
+ }, onClick: onClick }, slide && renderThumbnail({ slide, render, rect, imageFit })));
47
+ }
@@ -1,3 +1,4 @@
1
- import { Component } from "../../types.js";
1
+ /// <reference types="react" />
2
+ import { ComponentProps } from "../../types.js";
2
3
  /** Thumbnails plugin component */
3
- export declare const ThumbnailsComponent: Component;
4
+ export declare function ThumbnailsComponent({ thumbnails: thumbnailsProps, slides, carousel, animation, render, styles, children, }: ComponentProps): JSX.Element;
@@ -3,7 +3,7 @@ import { clsx, cssClass } from "../../core/index.js";
3
3
  import { cssPrefix } from "./utils.js";
4
4
  import { ThumbnailsTrack } from "./ThumbnailsTrack.js";
5
5
  import { defaultThumbnailsProps } from "./Thumbnails.js";
6
- export const ThumbnailsComponent = ({ thumbnails: thumbnailsProps, slides, carousel, animation, render, styles, children, }) => {
6
+ export function ThumbnailsComponent({ thumbnails: thumbnailsProps, slides, carousel, animation, render, styles, children, }) {
7
7
  const thumbnails = { ...defaultThumbnailsProps, ...thumbnailsProps };
8
8
  const ref = React.useRef(null);
9
9
  const track = (React.createElement(ThumbnailsTrack, { container: ref, slides: slides, thumbnails: thumbnails, carousel: carousel, animation: animation, render: render, thumbnailRect: { width: thumbnails.width, height: thumbnails.height }, styles: styles }));
@@ -11,4 +11,4 @@ export const ThumbnailsComponent = ({ thumbnails: thumbnailsProps, slides, carou
11
11
  (thumbnails.position === "start" || thumbnails.position === "top") && track,
12
12
  React.createElement("div", { className: cssClass(cssPrefix("wrapper")) }, children),
13
13
  (thumbnails.position === "end" || thumbnails.position === "bottom") && track));
14
- };
14
+ }