yet-another-react-lightbox 3.1.0 → 3.3.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 (51) hide show
  1. package/dist/core/components/IconButton.js +4 -5
  2. package/dist/core/components/Icons.d.ts +4 -0
  3. package/dist/core/components/Icons.js +17 -4
  4. package/dist/core/consts.d.ts +1 -0
  5. package/dist/core/consts.js +1 -0
  6. package/dist/core/modules/Navigation.js +3 -4
  7. package/dist/core/modules/Toolbar.d.ts +1 -1
  8. package/dist/core/modules/Toolbar.js +9 -4
  9. package/dist/core/utils.d.ts +2 -1
  10. package/dist/core/utils.js +13 -0
  11. package/dist/plugins/captions/Captions.d.ts +1 -1
  12. package/dist/plugins/captions/Captions.js +13 -8
  13. package/dist/plugins/captions/CaptionsButton.d.ts +2 -0
  14. package/dist/plugins/captions/CaptionsButton.js +16 -0
  15. package/dist/plugins/captions/CaptionsContext.d.ts +5 -0
  16. package/dist/plugins/captions/CaptionsContext.js +16 -0
  17. package/dist/plugins/captions/Description.d.ts +3 -3
  18. package/dist/plugins/captions/Description.js +8 -4
  19. package/dist/plugins/captions/Title.d.ts +3 -3
  20. package/dist/plugins/captions/Title.js +11 -3
  21. package/dist/plugins/captions/index.d.ts +25 -0
  22. package/dist/plugins/captions/index.js +1 -0
  23. package/dist/plugins/captions/props.d.ts +10 -0
  24. package/dist/plugins/captions/props.js +6 -0
  25. package/dist/plugins/fullscreen/Fullscreen.js +3 -3
  26. package/dist/plugins/fullscreen/FullscreenButton.js +3 -3
  27. package/dist/plugins/fullscreen/index.d.ts +4 -0
  28. package/dist/plugins/fullscreen/index.js +1 -0
  29. package/dist/plugins/slideshow/Slideshow.js +3 -3
  30. package/dist/plugins/slideshow/SlideshowButton.js +3 -3
  31. package/dist/plugins/slideshow/index.d.ts +4 -0
  32. package/dist/plugins/slideshow/index.js +1 -0
  33. package/dist/plugins/thumbnails/Thumbnails.js +13 -7
  34. package/dist/plugins/thumbnails/ThumbnailsButton.d.ts +2 -0
  35. package/dist/plugins/thumbnails/ThumbnailsButton.js +16 -0
  36. package/dist/plugins/thumbnails/ThumbnailsContext.d.ts +6 -0
  37. package/dist/plugins/thumbnails/ThumbnailsContext.js +24 -0
  38. package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +0 -2
  39. package/dist/plugins/thumbnails/ThumbnailsTrack.js +3 -0
  40. package/dist/plugins/thumbnails/index.d.ts +25 -1
  41. package/dist/plugins/thumbnails/index.js +1 -0
  42. package/dist/plugins/thumbnails/props.d.ts +6 -0
  43. package/dist/plugins/thumbnails/props.js +1 -0
  44. package/dist/plugins/zoom/Zoom.js +3 -3
  45. package/dist/plugins/zoom/ZoomButton.js +4 -5
  46. package/dist/plugins/zoom/index.d.ts +4 -0
  47. package/dist/plugins/zoom/index.js +1 -0
  48. package/dist/types.d.ts +5 -1
  49. package/package.json +1 -1
  50. package/dist/plugins/thumbnails/ThumbnailsContainer.d.ts +0 -4
  51. package/dist/plugins/thumbnails/ThumbnailsContainer.js +0 -14
@@ -1,9 +1,8 @@
1
1
  import * as React from "react";
2
- import { clsx, cssClass } from "../utils.js";
2
+ import { clsx, cssClass, label as translateLabel } from "../utils.js";
3
3
  import { useLightboxProps } from "../contexts/index.js";
4
4
  import { ELEMENT_BUTTON, ELEMENT_ICON } from "../consts.js";
5
- export const IconButton = React.forwardRef(({ label, className, icon: Icon, renderIcon, onClick, style, ...rest }, ref) => {
6
- const { styles } = useLightboxProps();
7
- return (React.createElement("button", { ref: ref, type: "button", "aria-label": label, className: clsx(cssClass(ELEMENT_BUTTON), className), onClick: onClick, style: { ...style, ...styles.button }, ...rest }, renderIcon ? renderIcon() : React.createElement(Icon, { className: cssClass(ELEMENT_ICON), style: styles.icon })));
5
+ export const IconButton = React.forwardRef(function IconButton({ label, className, icon: Icon, renderIcon, onClick, style, ...rest }, ref) {
6
+ const { styles, labels } = useLightboxProps();
7
+ return (React.createElement("button", { ref: ref, type: "button", "aria-label": translateLabel(labels, label), className: clsx(cssClass(ELEMENT_BUTTON), className), onClick: onClick, style: { ...style, ...styles.button }, ...rest }, renderIcon ? renderIcon() : React.createElement(Icon, { className: cssClass(ELEMENT_ICON), style: styles.icon })));
8
8
  });
9
- IconButton.displayName = "IconButton";
@@ -3,6 +3,10 @@ export declare function createIcon(name: string, glyph: React.ReactNode): {
3
3
  (props: React.SVGProps<SVGSVGElement>): JSX.Element;
4
4
  displayName: string;
5
5
  };
6
+ export declare function createIconDisabled(name: string, glyph: React.ReactNode): {
7
+ (props: React.SVGProps<SVGSVGElement>): JSX.Element;
8
+ displayName: string;
9
+ };
6
10
  export declare const CloseIcon: {
7
11
  (props: React.SVGProps<SVGSVGElement>): JSX.Element;
8
12
  displayName: string;
@@ -1,11 +1,24 @@
1
1
  import * as React from "react";
2
+ function svgIcon(name, children) {
3
+ const icon = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", "aria-hidden": "true", focusable: "false", ...props }, children));
4
+ icon.displayName = name;
5
+ return icon;
6
+ }
2
7
  export function createIcon(name, glyph) {
3
- const icon = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", "aria-hidden": "true", focusable: "false", ...props },
4
- React.createElement("g", { fill: "currentColor" },
8
+ return svgIcon(name, React.createElement("g", { fill: "currentColor" },
9
+ React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
10
+ glyph));
11
+ }
12
+ export function createIconDisabled(name, glyph) {
13
+ return svgIcon(name, React.createElement(React.Fragment, null,
14
+ React.createElement("defs", null,
15
+ React.createElement("mask", { id: "strike" },
16
+ React.createElement("path", { d: "M0 0h24v24H0z", fill: "white" }),
17
+ React.createElement("path", { d: "M0 0L24 24", stroke: "black", strokeWidth: 4 }))),
18
+ React.createElement("path", { d: "M0.70707 2.121320L21.878680 23.292883", stroke: "currentColor", strokeWidth: 2 }),
19
+ React.createElement("g", { fill: "currentColor", mask: "url(#strike)" },
5
20
  React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
6
21
  glyph)));
7
- icon.displayName = name;
8
- return icon;
9
22
  }
10
23
  export const CloseIcon = createIcon("Close", React.createElement("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }));
11
24
  export const PreviousIcon = createIcon("Previous", React.createElement("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }));
@@ -5,6 +5,7 @@ export declare const MODULE_NO_SCROLL = "no-scroll";
5
5
  export declare const MODULE_PORTAL = "portal";
6
6
  export declare const MODULE_ROOT = "root";
7
7
  export declare const MODULE_TOOLBAR = "toolbar";
8
+ export declare const PLUGIN_CAPTIONS = "captions";
8
9
  export declare const PLUGIN_COUNTER = "counter";
9
10
  export declare const PLUGIN_FULLSCREEN = "fullscreen";
10
11
  export declare const PLUGIN_INLINE = "inline";
@@ -5,6 +5,7 @@ export const MODULE_NO_SCROLL = "no-scroll";
5
5
  export const MODULE_PORTAL = "portal";
6
6
  export const MODULE_ROOT = "root";
7
7
  export const MODULE_TOOLBAR = "toolbar";
8
+ export const PLUGIN_CAPTIONS = "captions";
8
9
  export const PLUGIN_COUNTER = "counter";
9
10
  export const PLUGIN_FULLSCREEN = "fullscreen";
10
11
  export const PLUGIN_INLINE = "inline";
@@ -1,14 +1,13 @@
1
1
  import * as React from "react";
2
2
  import { createModule } from "../config.js";
3
3
  import { useEventCallback, useLoseFocus, useRTL, useThrottle } from "../hooks/index.js";
4
- import { cssClass, label as translateLabel } from "../utils.js";
4
+ import { cssClass } from "../utils.js";
5
5
  import { IconButton, NextIcon, PreviousIcon } from "../components/index.js";
6
- import { useLightboxProps, useLightboxState } from "../contexts/index.js";
6
+ import { useLightboxState } from "../contexts/index.js";
7
7
  import { useController } from "./Controller.js";
8
8
  import { ACTION_NEXT, ACTION_PREV, EVENT_ON_KEY_DOWN, MODULE_NAVIGATION, VK_ARROW_LEFT, VK_ARROW_RIGHT, } from "../consts.js";
9
9
  export function NavigationButton({ label, icon, renderIcon, action, onClick, disabled }) {
10
- const { labels } = useLightboxProps();
11
- return (React.createElement(IconButton, { label: translateLabel(labels, label), icon: icon, renderIcon: renderIcon, className: cssClass(`navigation_${action}`), disabled: disabled, onClick: onClick, ...useLoseFocus(disabled) }));
10
+ return (React.createElement(IconButton, { label: label, icon: icon, renderIcon: renderIcon, className: cssClass(`navigation_${action}`), disabled: disabled, onClick: onClick, ...useLoseFocus(disabled) }));
12
11
  }
13
12
  export function Navigation({ carousel: { finite }, animation, render: { buttonPrev, buttonNext, iconPrev, iconNext }, }) {
14
13
  var _a;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ComponentProps } from "../../types.js";
3
- export declare function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }: ComponentProps): JSX.Element;
3
+ export declare function Toolbar({ toolbar: { buttons }, render: { buttonClose, iconClose } }: ComponentProps): JSX.Element;
4
4
  export declare const ToolbarModule: import("../../types.js").Module;
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { createModule } from "../config.js";
3
- import { composePrefix, cssClass, label } from "../utils.js";
3
+ import { useLayoutEffect } from "../hooks/index.js";
4
+ import { composePrefix, cssClass } from "../utils.js";
4
5
  import { CloseIcon, IconButton } from "../components/index.js";
5
6
  import { useContainerRect } from "../hooks/useContainerRect.js";
6
7
  import { useController } from "./Controller.js";
@@ -8,13 +9,17 @@ import { ACTION_CLOSE, MODULE_TOOLBAR } from "../consts.js";
8
9
  function cssPrefix(value) {
9
10
  return composePrefix(MODULE_TOOLBAR, value);
10
11
  }
11
- export function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }) {
12
+ export function Toolbar({ toolbar: { buttons }, render: { buttonClose, iconClose } }) {
12
13
  const { close, setToolbarWidth } = useController();
13
14
  const { setContainerRef, containerRect } = useContainerRect();
14
- React.useEffect(() => {
15
+ useLayoutEffect(() => {
15
16
  setToolbarWidth(containerRect === null || containerRect === void 0 ? void 0 : containerRect.width);
16
17
  }, [setToolbarWidth, containerRect === null || containerRect === void 0 ? void 0 : containerRect.width]);
17
- const renderCloseButton = () => buttonClose ? (buttonClose()) : (React.createElement(IconButton, { key: ACTION_CLOSE, label: label(labels, "Close"), icon: CloseIcon, renderIcon: iconClose, onClick: () => close() }));
18
+ const renderCloseButton = () => {
19
+ if (buttonClose)
20
+ return buttonClose();
21
+ return React.createElement(IconButton, { key: ACTION_CLOSE, label: "Close", icon: CloseIcon, renderIcon: iconClose, onClick: close });
22
+ };
18
23
  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
24
  }
20
25
  export const ToolbarModule = createModule(MODULE_TOOLBAR, Toolbar);
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ContainerRect, Labels, LengthOrPercentage, LightboxProps, Slide, SlideImage } from "../types.js";
2
+ import { ContainerRect, Labels, LengthOrPercentage, LightboxProps, Slide, SlideImage, ToolbarSettings } from "../types.js";
3
3
  export declare const clsx: (...classes: (string | boolean | undefined)[]) => string;
4
4
  export declare const cssClass: (name: string) => string;
5
5
  export declare const cssVar: (name: string) => string;
@@ -26,3 +26,4 @@ export declare function computeSlideRect(containerRect: ContainerRect, padding:
26
26
  export declare const devicePixelRatio: () => number;
27
27
  export declare const getSlideIndex: (index: number, slidesCount: number) => number;
28
28
  export declare const getSlide: (slides: Slide[], index: number) => Slide;
29
+ export declare function addToolbarButton(toolbar: ToolbarSettings, key: string, button: React.ReactNode): ToolbarSettings;
@@ -47,3 +47,16 @@ export function computeSlideRect(containerRect, padding) {
47
47
  export const devicePixelRatio = () => (hasWindow() ? window === null || window === void 0 ? void 0 : window.devicePixelRatio : undefined) || 1;
48
48
  export const getSlideIndex = (index, slidesCount) => ((index % slidesCount) + slidesCount) % slidesCount;
49
49
  export const getSlide = (slides, index) => slides[getSlideIndex(index, slides.length)];
50
+ export function addToolbarButton(toolbar, key, button) {
51
+ if (!button)
52
+ return toolbar;
53
+ const { buttons, ...restToolbar } = toolbar;
54
+ const index = buttons.findIndex((item) => item === key);
55
+ const buttonWithKey = React.isValidElement(button) ? React.cloneElement(button, { key }, null) : button;
56
+ if (index >= 0) {
57
+ const result = [...buttons];
58
+ result.splice(index, 1, buttonWithKey);
59
+ return { buttons: result, ...restToolbar };
60
+ }
61
+ return { buttons: [buttonWithKey, ...buttons], ...restToolbar };
62
+ }
@@ -1,3 +1,3 @@
1
1
  import { PluginProps } from "../../types.js";
2
2
  /** Captions plugin */
3
- export declare function Captions({ augment }: PluginProps): void;
3
+ export declare function Captions({ augment, addModule }: PluginProps): void;
@@ -1,20 +1,25 @@
1
1
  import * as React from "react";
2
- import { resolveCaptionsProps } from "./props.js";
3
- import { Description } from "./Description.js";
2
+ import { addToolbarButton, createModule, PLUGIN_CAPTIONS } from "../../core/index.js";
4
3
  import { Title } from "./Title.js";
5
- export function Captions({ augment }) {
6
- augment(({ render: { slideFooter: renderFooter, ...restRender }, captions, styles, ...restProps }) => {
4
+ import { Description } from "./Description.js";
5
+ import { CaptionsButton } from "./CaptionsButton.js";
6
+ import { CaptionsContextProvider } from "./CaptionsContext.js";
7
+ import { resolveCaptionsProps } from "./props.js";
8
+ export function Captions({ augment, addModule }) {
9
+ augment(({ captions: captionsProps, render: { slideFooter: renderFooter, ...restRender }, toolbar, ...restProps }) => {
10
+ const captions = resolveCaptionsProps(captionsProps);
7
11
  return {
8
12
  render: {
9
13
  slideFooter: ({ slide }) => (React.createElement(React.Fragment, null, renderFooter === null || renderFooter === void 0 ? void 0 :
10
14
  renderFooter({ slide }),
11
- slide.title && React.createElement(Title, { styles: styles, title: slide.title }),
12
- slide.description && React.createElement(Description, { styles: styles, description: slide.description }))),
15
+ slide.title && React.createElement(Title, { title: slide.title }),
16
+ slide.description && React.createElement(Description, { description: slide.description }))),
13
17
  ...restRender,
14
18
  },
15
- captions: resolveCaptionsProps(captions),
16
- styles,
19
+ toolbar: addToolbarButton(toolbar, PLUGIN_CAPTIONS, captions.showToggle ? React.createElement(CaptionsButton, null) : null),
20
+ captions,
17
21
  ...restProps,
18
22
  };
19
23
  });
24
+ addModule(createModule(PLUGIN_CAPTIONS, CaptionsContextProvider));
20
25
  }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function CaptionsButton(): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import { createIcon, createIconDisabled, IconButton, useLightboxProps } from "../../core/index.js";
3
+ import { useCaptions } from "./CaptionsContext.js";
4
+ const captionsIcon = () => (React.createElement(React.Fragment, null,
5
+ React.createElement("path", { strokeWidth: 2, stroke: "currentColor", strokeLinejoin: "round", fill: "none", d: "M3 5l18 0l0 14l-18 0l0-14z" }),
6
+ React.createElement("path", { d: "M7 15h3c.55 0 1-.45 1-1v-1H9.5v.5h-2v-3h2v.5H11v-1c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm7 0h3c.55 0 1-.45 1-1v-1h-1.5v.5h-2v-3h2v.5H18v-1c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1z" })));
7
+ const CaptionsVisible = createIcon("CaptionsVisible", captionsIcon());
8
+ const CaptionsHidden = createIconDisabled("CaptionsVisible", captionsIcon());
9
+ export function CaptionsButton() {
10
+ const { visible, show, hide } = useCaptions();
11
+ const { render } = useLightboxProps();
12
+ if (render.buttonCaptions) {
13
+ return React.createElement(React.Fragment, null, render.buttonCaptions({ visible, show, hide }));
14
+ }
15
+ return (React.createElement(IconButton, { label: visible ? "Hide captions" : "Show captions", icon: visible ? CaptionsVisible : CaptionsHidden, renderIcon: visible ? render.iconCaptionsVisible : render.iconCaptionsHidden, onClick: visible ? hide : show }));
16
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { CaptionsRef, ComponentProps } from "../../types.js";
3
+ export declare const CaptionsContext: React.Context<CaptionsRef | null>;
4
+ export declare const useCaptions: () => CaptionsRef;
5
+ export declare function CaptionsContextProvider({ captions, children }: ComponentProps): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import { makeUseContext } from "../../core/index.js";
3
+ import { resolveCaptionsProps } from "./props.js";
4
+ export const CaptionsContext = React.createContext(null);
5
+ export const useCaptions = makeUseContext("useCaptions", "CaptionsContext", CaptionsContext);
6
+ export function CaptionsContextProvider({ captions, children }) {
7
+ const { ref } = resolveCaptionsProps(captions);
8
+ const [visible, setVisible] = React.useState(true);
9
+ const context = React.useMemo(() => ({
10
+ visible,
11
+ show: () => setVisible(true),
12
+ hide: () => setVisible(false),
13
+ }), [visible]);
14
+ React.useImperativeHandle(ref, () => context, [context]);
15
+ return React.createElement(CaptionsContext.Provider, { value: context }, children);
16
+ }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { LightboxProps, Slide } from "../../types.js";
3
- export type DescriptionProps = Required<Pick<Slide, "description">> & Pick<LightboxProps, "styles">;
4
- export declare function Description({ description, styles }: DescriptionProps): JSX.Element;
2
+ import { Slide } from "../../types.js";
3
+ export type DescriptionProps = Pick<Slide, "description">;
4
+ export declare function Description({ description }: DescriptionProps): JSX.Element | null;
@@ -1,10 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { clsx, cssVar, useLightboxProps } from "../../core/index.js";
3
- import { defaultCaptionsProps, resolveCaptionsProps } from "./props.js";
4
3
  import { cssPrefix } from "./utils.js";
5
- export function Description({ description, styles }) {
6
- const { captions } = useLightboxProps();
7
- const { descriptionTextAlign, descriptionMaxLines } = resolveCaptionsProps(captions);
4
+ import { defaultCaptionsProps, useCaptionsProps } from "./props.js";
5
+ import { useCaptions } from "./CaptionsContext.js";
6
+ export function Description({ description }) {
7
+ const { descriptionTextAlign, descriptionMaxLines } = useCaptionsProps();
8
+ const { styles } = useLightboxProps();
9
+ const { visible } = useCaptions();
10
+ if (!visible)
11
+ return null;
8
12
  return (React.createElement("div", { style: styles.captionsDescriptionContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("description_container")) },
9
13
  React.createElement("div", { className: cssPrefix("description"), style: {
10
14
  ...(descriptionTextAlign !== defaultCaptionsProps.descriptionTextAlign ||
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { LightboxProps, Slide } from "../../types.js";
3
- export type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
4
- export declare function Title({ title, styles }: TitleProps): JSX.Element;
2
+ import { Slide } from "../../types.js";
3
+ export type TitleProps = Pick<Slide, "title">;
4
+ export declare function Title({ title }: TitleProps): JSX.Element | null;
@@ -1,8 +1,16 @@
1
1
  import * as React from "react";
2
- import { clsx, cssVar, useController } from "../../core/index.js";
2
+ import { clsx, cssVar, useController, useLightboxProps } from "../../core/index.js";
3
3
  import { cssPrefix } from "./utils.js";
4
- export function Title({ title, styles }) {
4
+ import { useCaptions } from "./CaptionsContext.js";
5
+ export function Title({ title }) {
5
6
  const { toolbarWidth } = useController();
7
+ const { styles } = useLightboxProps();
8
+ const { visible } = useCaptions();
9
+ if (!visible)
10
+ return null;
6
11
  return (React.createElement("div", { style: styles.captionsTitleContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("title_container")) },
7
- React.createElement("div", { style: styles.captionsTitle, className: cssPrefix("title"), ...(toolbarWidth ? { style: { [cssVar("toolbar_width")]: `${toolbarWidth}px` } } : null) }, title)));
12
+ React.createElement("div", { className: cssPrefix("title"), style: {
13
+ ...(toolbarWidth ? { [cssVar("toolbar_width")]: `${toolbarWidth}px` } : null),
14
+ ...styles.captionsTitle,
15
+ } }, title)));
8
16
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { PLUGIN_CAPTIONS } from "../../core/index.js";
2
3
  import { Captions } from "./Captions.js";
3
4
  declare module "../../types.js" {
4
5
  type TextAlignment = "start" | "end" | "center";
@@ -8,9 +9,16 @@ declare module "../../types.js" {
8
9
  /** slide description */
9
10
  description?: React.ReactNode;
10
11
  }
12
+ interface ToolbarButtonKeys {
13
+ [PLUGIN_CAPTIONS]: null;
14
+ }
11
15
  interface LightboxProps {
12
16
  /** Captions plugin settings */
13
17
  captions?: {
18
+ /** Captions plugin ref */
19
+ ref?: React.ForwardedRef<CaptionsRef>;
20
+ /** if `true`, show Captions Toggle button in the toolbar */
21
+ showToggle?: boolean;
14
22
  /** description text alignment */
15
23
  descriptionTextAlign?: TextAlignment;
16
24
  /** maximum number of lines to display in the description section */
@@ -27,5 +35,22 @@ declare module "../../types.js" {
27
35
  /** captions description container customization slot */
28
36
  captionsDescriptionContainer: "captionsDescriptionContainer";
29
37
  }
38
+ interface Render {
39
+ /** render custom Captions Visible icon */
40
+ iconCaptionsVisible?: RenderFunction;
41
+ /** render custom Captions Hidden icon */
42
+ iconCaptionsHidden?: RenderFunction;
43
+ /** render custom Captions button */
44
+ buttonCaptions?: RenderFunction<CaptionsRef>;
45
+ }
46
+ /** Captions plugin ref */
47
+ interface CaptionsRef {
48
+ /** if `true`, captions are visible */
49
+ visible: boolean;
50
+ /** show captions */
51
+ show: Callback;
52
+ /** hide captions */
53
+ hide: Callback;
54
+ }
30
55
  }
31
56
  export default Captions;
@@ -1,2 +1,3 @@
1
+ import { PLUGIN_CAPTIONS } from "../../core/index.js";
1
2
  import { Captions } from "./Captions.js";
2
3
  export default Captions;
@@ -1,9 +1,19 @@
1
+ /// <reference types="react" />
1
2
  import { LightboxProps } from "../../types.js";
2
3
  export declare const defaultCaptionsProps: {
3
4
  descriptionTextAlign: "start";
4
5
  descriptionMaxLines: number;
6
+ showToggle: boolean;
5
7
  };
6
8
  export declare const resolveCaptionsProps: (captions: LightboxProps["captions"]) => {
9
+ ref?: import("react").ForwardedRef<import("../../types.js").CaptionsRef> | undefined;
10
+ showToggle: boolean;
11
+ descriptionTextAlign: import("../../types.js").TextAlignment;
12
+ descriptionMaxLines: number;
13
+ };
14
+ export declare function useCaptionsProps(): {
15
+ ref?: import("react").ForwardedRef<import("../../types.js").CaptionsRef> | undefined;
16
+ showToggle: boolean;
7
17
  descriptionTextAlign: import("../../types.js").TextAlignment;
8
18
  descriptionMaxLines: number;
9
19
  };
@@ -1,8 +1,14 @@
1
+ import { useLightboxProps } from "../../core/index.js";
1
2
  export const defaultCaptionsProps = {
2
3
  descriptionTextAlign: "start",
3
4
  descriptionMaxLines: 3,
5
+ showToggle: false,
4
6
  };
5
7
  export const resolveCaptionsProps = (captions) => ({
6
8
  ...defaultCaptionsProps,
7
9
  ...captions,
8
10
  });
11
+ export function useCaptionsProps() {
12
+ const { captions } = useLightboxProps();
13
+ return resolveCaptionsProps(captions);
14
+ }
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
- import { createModule, MODULE_CONTROLLER, PLUGIN_FULLSCREEN, PLUGIN_THUMBNAILS } from "../../core/index.js";
2
+ import { addToolbarButton, createModule, MODULE_CONTROLLER, PLUGIN_FULLSCREEN, PLUGIN_THUMBNAILS, } from "../../core/index.js";
3
3
  import { resolveFullscreenProps } from "./props.js";
4
4
  import { FullscreenButton } from "./FullscreenButton.js";
5
5
  import { FullscreenContextProvider } from "./FullscreenContext.js";
6
6
  export function Fullscreen({ augment, contains, addParent }) {
7
- augment(({ fullscreen, toolbar: { buttons, ...restToolbar }, ...restProps }) => ({
8
- toolbar: { buttons: [React.createElement(FullscreenButton, { key: PLUGIN_FULLSCREEN }), ...buttons], ...restToolbar },
7
+ augment(({ fullscreen, toolbar, ...restProps }) => ({
8
+ toolbar: addToolbarButton(toolbar, PLUGIN_FULLSCREEN, React.createElement(FullscreenButton, null)),
9
9
  fullscreen: resolveFullscreenProps(fullscreen),
10
10
  ...restProps,
11
11
  }));
@@ -1,16 +1,16 @@
1
1
  import * as React from "react";
2
- import { createIcon, IconButton, label, useLightboxProps } from "../../core/index.js";
2
+ import { createIcon, IconButton, useLightboxProps } from "../../core/index.js";
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
6
  export function FullscreenButton() {
7
7
  var _a;
8
8
  const { fullscreen, disabled, enter, exit } = useFullscreen();
9
- const { labels, render } = useLightboxProps();
9
+ const { render } = useLightboxProps();
10
10
  if (disabled)
11
11
  return null;
12
12
  if (render.buttonFullscreen) {
13
13
  return React.createElement(React.Fragment, null, (_a = render.buttonFullscreen) === null || _a === void 0 ? void 0 : _a.call(render, { fullscreen, disabled, enter, exit }));
14
14
  }
15
- return (React.createElement(IconButton, { disabled: disabled, label: label(labels, fullscreen ? "Exit Fullscreen" : "Enter Fullscreen"), icon: fullscreen ? ExitFullscreenIcon : EnterFullscreenIcon, renderIcon: fullscreen ? render.iconExitFullscreen : render.iconEnterFullscreen, onClick: fullscreen ? exit : enter }));
15
+ return (React.createElement(IconButton, { disabled: disabled, label: fullscreen ? "Exit Fullscreen" : "Enter Fullscreen", icon: fullscreen ? ExitFullscreenIcon : EnterFullscreenIcon, renderIcon: fullscreen ? render.iconExitFullscreen : render.iconEnterFullscreen, onClick: fullscreen ? exit : enter }));
16
16
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { PLUGIN_FULLSCREEN } from "../../core/index.js";
2
3
  import { Fullscreen } from "./Fullscreen.js";
3
4
  declare module "../../types.js" {
4
5
  interface LightboxProps {
@@ -18,6 +19,9 @@ declare module "../../types.js" {
18
19
  /** render custom Exit Fullscreen icon */
19
20
  iconExitFullscreen?: RenderFunction;
20
21
  }
22
+ interface ToolbarButtonKeys {
23
+ [PLUGIN_FULLSCREEN]: null;
24
+ }
21
25
  /** Fullscreen plugin ref */
22
26
  interface FullscreenRef {
23
27
  /** current fullscreen status */
@@ -1,2 +1,3 @@
1
+ import { PLUGIN_FULLSCREEN } from "../../core/index.js";
1
2
  import { Fullscreen } from "./Fullscreen.js";
2
3
  export default Fullscreen;
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
- import { createModule, PLUGIN_SLIDESHOW } from "../../core/index.js";
2
+ import { addToolbarButton, createModule, PLUGIN_SLIDESHOW } from "../../core/index.js";
3
3
  import { resolveSlideshowProps } from "./props.js";
4
4
  import { SlideshowContextProvider } from "./SlideshowContext.js";
5
5
  import { SlideshowButton } from "./SlideshowButton.js";
6
6
  export function Slideshow({ augment, addModule }) {
7
- augment(({ slideshow, toolbar: { buttons, ...restToolbar }, ...restProps }) => ({
8
- toolbar: { buttons: [React.createElement(SlideshowButton, { key: PLUGIN_SLIDESHOW }), ...buttons], ...restToolbar },
7
+ augment(({ slideshow, toolbar, ...restProps }) => ({
8
+ toolbar: addToolbarButton(toolbar, PLUGIN_SLIDESHOW, React.createElement(SlideshowButton, null)),
9
9
  slideshow: resolveSlideshowProps(slideshow),
10
10
  ...restProps,
11
11
  }));
@@ -1,14 +1,14 @@
1
1
  import * as React from "react";
2
- import { createIcon, IconButton, label, useLightboxProps, useLoseFocus } from "../../core/index.js";
2
+ import { createIcon, IconButton, useLightboxProps, useLoseFocus } from "../../core/index.js";
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
6
  export function SlideshowButton() {
7
7
  const { playing, disabled, play, pause } = useSlideshow();
8
- const { render, labels } = useLightboxProps();
8
+ const { render } = useLightboxProps();
9
9
  const focusListeners = useLoseFocus(disabled);
10
10
  if (render.buttonSlideshow) {
11
11
  return React.createElement(React.Fragment, null, render.buttonSlideshow({ playing, disabled, play, pause }));
12
12
  }
13
- return (React.createElement(IconButton, { label: label(labels, playing ? "Pause" : "Play"), icon: playing ? PauseIcon : PlayIcon, renderIcon: playing ? render.iconSlideshowPause : render.iconSlideshowPlay, onClick: playing ? pause : play, disabled: disabled, ...focusListeners }));
13
+ return (React.createElement(IconButton, { label: playing ? "Pause" : "Play", icon: playing ? PauseIcon : PlayIcon, renderIcon: playing ? render.iconSlideshowPause : render.iconSlideshowPlay, onClick: playing ? pause : play, disabled: disabled, ...focusListeners }));
14
14
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { PLUGIN_SLIDESHOW } from "../../core/index.js";
2
3
  import { Slideshow } from "./Slideshow.js";
3
4
  declare module "../../types.js" {
4
5
  interface LightboxProps {
@@ -20,6 +21,9 @@ declare module "../../types.js" {
20
21
  /** render custom Slideshow button */
21
22
  buttonSlideshow?: RenderFunction<SlideshowRef>;
22
23
  }
24
+ interface ToolbarButtonKeys {
25
+ [PLUGIN_SLIDESHOW]: null;
26
+ }
23
27
  /** Slideshow plugin ref */
24
28
  interface SlideshowRef {
25
29
  /** current slideshow playback status */
@@ -1,2 +1,3 @@
1
+ import { PLUGIN_SLIDESHOW } from "../../core/index.js";
1
2
  import { Slideshow } from "./Slideshow.js";
2
3
  export default Slideshow;
@@ -1,12 +1,18 @@
1
- import { createModule, MODULE_CONTROLLER, PLUGIN_FULLSCREEN, PLUGIN_THUMBNAILS } from "../../core/index.js";
1
+ import * as React from "react";
2
+ import { addToolbarButton, createModule, MODULE_CONTROLLER, PLUGIN_FULLSCREEN, PLUGIN_THUMBNAILS, } from "../../core/index.js";
2
3
  import { resolveThumbnailsProps } from "./props.js";
3
- import { ThumbnailsContainer } from "./ThumbnailsContainer.js";
4
+ import { ThumbnailsContextProvider } from "./ThumbnailsContext.js";
5
+ import { ThumbnailsButton } from "./ThumbnailsButton.js";
4
6
  export function Thumbnails({ augment, contains, append, addParent }) {
5
- augment(({ thumbnails, ...restProps }) => ({
6
- thumbnails: resolveThumbnailsProps(thumbnails),
7
- ...restProps,
8
- }));
9
- const module = createModule(PLUGIN_THUMBNAILS, ThumbnailsContainer);
7
+ augment(({ thumbnails: thumbnailsProps, toolbar, ...restProps }) => {
8
+ const thumbnails = resolveThumbnailsProps(thumbnailsProps);
9
+ return {
10
+ toolbar: addToolbarButton(toolbar, PLUGIN_THUMBNAILS, thumbnails.showToggle ? React.createElement(ThumbnailsButton, null) : null),
11
+ thumbnails,
12
+ ...restProps,
13
+ };
14
+ });
15
+ const module = createModule(PLUGIN_THUMBNAILS, ThumbnailsContextProvider);
10
16
  if (contains(PLUGIN_FULLSCREEN)) {
11
17
  append(PLUGIN_FULLSCREEN, module);
12
18
  }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function ThumbnailsButton(): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import { createIcon, createIconDisabled, IconButton, useLightboxProps } from "../../core/index.js";
3
+ import { useThumbnails } from "./ThumbnailsContext.js";
4
+ const thumbnailsIcon = () => (React.createElement(React.Fragment, null,
5
+ React.createElement("path", { strokeWidth: 2, stroke: "currentColor", strokeLinejoin: "round", fill: "none", d: "M3 5l18 0l0 14l-18 0l0-14z" }),
6
+ React.createElement("path", { d: "M5 14h4v3h-4zM10 14h4v3h-4zM15 14h4v3h-4z" })));
7
+ const ThumbnailsVisible = createIcon("ThumbnailsVisible", thumbnailsIcon());
8
+ const ThumbnailsHidden = createIconDisabled("ThumbnailsHidden", thumbnailsIcon());
9
+ export function ThumbnailsButton() {
10
+ const { visible, show, hide } = useThumbnails();
11
+ const { render } = useLightboxProps();
12
+ if (render.buttonThumbnails) {
13
+ return React.createElement(React.Fragment, null, render.buttonThumbnails({ visible, show, hide }));
14
+ }
15
+ return (React.createElement(IconButton, { label: visible ? "Hide thumbnails" : "Show thumbnails", icon: visible ? ThumbnailsVisible : ThumbnailsHidden, renderIcon: visible ? render.iconThumbnailsVisible : render.iconThumbnailsHidden, onClick: visible ? hide : show }));
16
+ }
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import { ComponentProps, ThumbnailsRef } from "../../types.js";
3
+ export declare const ThumbnailsContext: React.Context<ThumbnailsRef | null>;
4
+ export declare const useThumbnails: () => ThumbnailsRef;
5
+ /** Thumbnails plugin component */
6
+ export declare function ThumbnailsContextProvider({ children, ...props }: ComponentProps): JSX.Element;
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import { clsx, cssClass, LightboxPropsProvider, makeUseContext } from "../../core/index.js";
3
+ import { cssPrefix } from "./utils.js";
4
+ import { ThumbnailsTrack } from "./ThumbnailsTrack.js";
5
+ import { resolveThumbnailsProps } from "./props.js";
6
+ export const ThumbnailsContext = React.createContext(null);
7
+ export const useThumbnails = makeUseContext("useThumbnails", "ThumbnailsContext", ThumbnailsContext);
8
+ export function ThumbnailsContextProvider({ children, ...props }) {
9
+ const [visible, setVisible] = React.useState(true);
10
+ const containerRef = React.useRef(null);
11
+ const { ref, position } = resolveThumbnailsProps(props.thumbnails);
12
+ const context = React.useMemo(() => ({
13
+ visible,
14
+ show: () => setVisible(true),
15
+ hide: () => setVisible(false),
16
+ }), [visible]);
17
+ React.useImperativeHandle(ref, () => context, [context]);
18
+ return (React.createElement(LightboxPropsProvider, { ...props },
19
+ React.createElement(ThumbnailsContext.Provider, { value: context },
20
+ React.createElement("div", { ref: containerRef, className: clsx(cssClass(cssPrefix()), cssClass(cssPrefix(`${position}`))) },
21
+ ["start", "top"].includes(position) && React.createElement(ThumbnailsTrack, { containerRef: containerRef }),
22
+ React.createElement("div", { className: cssClass(cssPrefix("wrapper")) }, children),
23
+ ["end", "bottom"].includes(position) && React.createElement(ThumbnailsTrack, { containerRef: containerRef })))));
24
+ }
@@ -1,6 +1,4 @@
1
1
  import * as React from "react";
2
- import { DeepNonNullable, LightboxProps } from "../../types.js";
3
- export type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
4
2
  export type ThumbnailsTrackProps = {
5
3
  containerRef: React.RefObject<HTMLDivElement>;
6
4
  };
@@ -3,6 +3,7 @@ import { ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, CLASS_FLEX_CENTER, cleanup, cls
3
3
  import { cssPrefix, cssThumbnailPrefix } from "./utils.js";
4
4
  import { Thumbnail } from "./Thumbnail.js";
5
5
  import { defaultThumbnailsProps, useThumbnailsProps } from "./props.js";
6
+ import { useThumbnails } from "./ThumbnailsContext.js";
6
7
  function isHorizontal(position) {
7
8
  return ["top", "bottom"].includes(position);
8
9
  }
@@ -11,6 +12,7 @@ function boxSize(thumbnails, dimension, includeGap) {
11
12
  }
12
13
  export function ThumbnailsTrack({ containerRef }) {
13
14
  const track = React.useRef(null);
15
+ const { visible } = useThumbnails();
14
16
  const { carousel, styles } = useLightboxProps();
15
17
  const { slides, globalIndex, animation } = useLightboxState().state;
16
18
  const { publish, subscribe } = useEvents();
@@ -93,6 +95,7 @@ export function ThumbnailsTrack({ containerRef }) {
93
95
  }
94
96
  };
95
97
  return (React.createElement("div", { className: clsx(cssClass(cssPrefix("container")), cssClass(CLASS_FLEX_CENTER)), style: {
98
+ ...(!visible ? { display: "none" } : null),
96
99
  ...(width !== defaultThumbnailsProps.width
97
100
  ? { [cssVar(cssThumbnailPrefix("width"))]: `${boxSize(thumbnails, width)}px` }
98
101
  : null),
@@ -1,9 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { PLUGIN_THUMBNAILS } from "../../core/index.js";
1
3
  import { Thumbnails } from "./Thumbnails.js";
2
4
  type Position = "top" | "bottom" | "start" | "end";
3
5
  declare module "../../types.js" {
4
6
  interface LightboxProps {
5
7
  /** Thumbnails plugin settings */
6
8
  thumbnails?: {
9
+ /** Thumbnails plugin ref */
10
+ ref?: React.ForwardedRef<ThumbnailsRef>;
7
11
  /** thumbnails position */
8
12
  position?: Position;
9
13
  /** thumbnail width */
@@ -20,13 +24,21 @@ declare module "../../types.js" {
20
24
  gap?: number;
21
25
  /** `object-fit` setting */
22
26
  imageFit?: ImageFit;
23
- /** vignette effect on the edges of the thumbnails track */
27
+ /** if `true`, show the vignette effect on the edges of the thumbnails track */
24
28
  vignette?: boolean;
29
+ /** if `true`, show the Toggle Thumbnails button in the toolbar */
30
+ showToggle?: boolean;
25
31
  };
26
32
  }
27
33
  interface Render {
28
34
  /** render custom thumbnail */
29
35
  thumbnail?: RenderFunction<RenderThumbnailProps>;
36
+ /** render custom Thumbnails Visible icon */
37
+ iconThumbnailsVisible?: RenderFunction;
38
+ /** render custom Thumbnails Hidden icon */
39
+ iconThumbnailsHidden?: RenderFunction;
40
+ /** render custom Thumbnails button */
41
+ buttonThumbnails?: RenderFunction<ThumbnailsRef>;
30
42
  }
31
43
  /** `render.thumbnail` render function props */
32
44
  type RenderThumbnailProps = {
@@ -43,5 +55,17 @@ declare module "../../types.js" {
43
55
  /** thumbnails container customization slot */
44
56
  thumbnailsContainer: "thumbnailsContainer";
45
57
  }
58
+ interface ToolbarButtonKeys {
59
+ [PLUGIN_THUMBNAILS]: null;
60
+ }
61
+ /** Thumbnails plugin ref */
62
+ interface ThumbnailsRef {
63
+ /** if `true`, thumbnails are visible */
64
+ visible: boolean;
65
+ /** show thumbnails */
66
+ show: Callback;
67
+ /** hide thuumbnails */
68
+ hide: Callback;
69
+ }
46
70
  }
47
71
  export default Thumbnails;
@@ -1,2 +1,3 @@
1
+ import { PLUGIN_THUMBNAILS } from "../../core/index.js";
1
2
  import { Thumbnails } from "./Thumbnails.js";
2
3
  export default Thumbnails;
@@ -1,5 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { LightboxProps } from "../../types.js";
2
3
  export declare const defaultThumbnailsProps: {
4
+ ref: null;
3
5
  position: "bottom";
4
6
  width: number;
5
7
  height: number;
@@ -11,6 +13,7 @@ export declare const defaultThumbnailsProps: {
11
13
  vignette: boolean;
12
14
  };
13
15
  export declare const resolveThumbnailsProps: (thumbnails: LightboxProps["thumbnails"]) => {
16
+ ref: import("react").ForwardedRef<import("../../types.js").ThumbnailsRef>;
14
17
  position: "end" | "start" | "bottom" | "top";
15
18
  width: number;
16
19
  height: number;
@@ -20,8 +23,10 @@ export declare const resolveThumbnailsProps: (thumbnails: LightboxProps["thumbna
20
23
  gap: number;
21
24
  imageFit: import("../../types.js").ImageFit;
22
25
  vignette: boolean;
26
+ showToggle?: boolean | undefined;
23
27
  };
24
28
  export declare function useThumbnailsProps(): {
29
+ ref: import("react").ForwardedRef<import("../../types.js").ThumbnailsRef>;
25
30
  position: "end" | "start" | "bottom" | "top";
26
31
  width: number;
27
32
  height: number;
@@ -31,4 +36,5 @@ export declare function useThumbnailsProps(): {
31
36
  gap: number;
32
37
  imageFit: import("../../types.js").ImageFit;
33
38
  vignette: boolean;
39
+ showToggle?: boolean | undefined;
34
40
  };
@@ -1,5 +1,6 @@
1
1
  import { useLightboxProps } from "../../core/index.js";
2
2
  export const defaultThumbnailsProps = {
3
+ ref: null,
3
4
  position: "bottom",
4
5
  width: 120,
5
6
  height: 80,
@@ -1,13 +1,13 @@
1
1
  import * as React from "react";
2
- import { createModule, isImageSlide, PLUGIN_ZOOM } from "../../core/index.js";
2
+ import { addToolbarButton, createModule, isImageSlide, PLUGIN_ZOOM } from "../../core/index.js";
3
3
  import { resolveZoomProps } from "./props.js";
4
4
  import { ZoomContextProvider } from "./ZoomController.js";
5
5
  import { ZoomToolbarControl } from "./ZoomToolbarControl.js";
6
6
  import { ZoomWrapper } from "./ZoomWrapper.js";
7
7
  export const Zoom = ({ augment, addModule }) => {
8
- augment(({ toolbar: { buttons, ...restToolbar }, render, zoom, ...restProps }) => ({
8
+ augment(({ toolbar, render, zoom, ...restProps }) => ({
9
9
  zoom: resolveZoomProps(zoom),
10
- toolbar: { buttons: [React.createElement(ZoomToolbarControl, { key: PLUGIN_ZOOM }), ...buttons], ...restToolbar },
10
+ toolbar: addToolbarButton(toolbar, PLUGIN_ZOOM, React.createElement(ZoomToolbarControl, null)),
11
11
  render: {
12
12
  ...render,
13
13
  slide: (props) => { var _a; return isImageSlide(props.slide) ? React.createElement(ZoomWrapper, { render: render, ...props }) : (_a = render.slide) === null || _a === void 0 ? void 0 : _a.call(render, props); },
@@ -1,15 +1,15 @@
1
1
  import * as React from "react";
2
- import { createIcon, IconButton, label, useLightboxProps } from "../../core/index.js";
2
+ import { createIcon, IconButton, useLightboxProps } from "../../core/index.js";
3
3
  import { useZoom } from "./ZoomController.js";
4
4
  const ZoomInIcon = createIcon("ZoomIn", React.createElement(React.Fragment, null,
5
5
  React.createElement("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }),
6
6
  React.createElement("path", { d: "M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z" })));
7
7
  const ZoomOutIcon = createIcon("ZoomOut", React.createElement("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z" }));
8
- export const ZoomButton = React.forwardRef(({ zoomIn, onLoseFocus }, ref) => {
8
+ export const ZoomButton = React.forwardRef(function ZoomButton({ zoomIn, onLoseFocus }, ref) {
9
9
  const wasEnabled = React.useRef(false);
10
10
  const wasFocused = React.useRef(false);
11
11
  const { zoom, maxZoom, zoomIn: zoomInCallback, zoomOut: zoomOutCallback, disabled: zoomDisabled } = useZoom();
12
- const { render, labels } = useLightboxProps();
12
+ const { render } = useLightboxProps();
13
13
  const disabled = zoomDisabled || (zoomIn ? zoom >= maxZoom : zoom <= 1);
14
14
  React.useEffect(() => {
15
15
  if (disabled && wasEnabled.current && wasFocused.current) {
@@ -19,10 +19,9 @@ export const ZoomButton = React.forwardRef(({ zoomIn, onLoseFocus }, ref) => {
19
19
  wasEnabled.current = true;
20
20
  }
21
21
  }, [disabled, onLoseFocus]);
22
- return (React.createElement(IconButton, { ref: ref, disabled: disabled, label: label(labels, zoomIn ? "Zoom in" : "Zoom out"), icon: zoomIn ? ZoomInIcon : ZoomOutIcon, renderIcon: zoomIn ? render.iconZoomIn : render.iconZoomOut, onClick: zoomIn ? zoomInCallback : zoomOutCallback, onFocus: () => {
22
+ return (React.createElement(IconButton, { ref: ref, disabled: disabled, label: zoomIn ? "Zoom in" : "Zoom out", icon: zoomIn ? ZoomInIcon : ZoomOutIcon, renderIcon: zoomIn ? render.iconZoomIn : render.iconZoomOut, onClick: zoomIn ? zoomInCallback : zoomOutCallback, onFocus: () => {
23
23
  wasFocused.current = true;
24
24
  }, onBlur: () => {
25
25
  wasFocused.current = false;
26
26
  } }));
27
27
  });
28
- ZoomButton.displayName = "ZoomButton";
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { PLUGIN_ZOOM } from "../../core/index.js";
2
3
  import { Zoom } from "./Zoom.js";
3
4
  declare module "../../types.js" {
4
5
  interface LightboxProps {
@@ -53,6 +54,9 @@ declare module "../../types.js" {
53
54
  /** current zoom level */
54
55
  zoom: number;
55
56
  }
57
+ interface ToolbarButtonKeys {
58
+ [PLUGIN_ZOOM]: null;
59
+ }
56
60
  /** Zoom plugin ref */
57
61
  interface ZoomRef {
58
62
  /** current zoom level */
@@ -1,2 +1,3 @@
1
+ import { PLUGIN_ZOOM } from "../../core/index.js";
1
2
  import { Zoom } from "./Zoom.js";
2
3
  export default Zoom;
package/dist/types.d.ts CHANGED
@@ -278,7 +278,11 @@ export type Labels = {
278
278
  /** Toolbar settings */
279
279
  export interface ToolbarSettings {
280
280
  /** buttons to render in the toolbar */
281
- buttons: ("close" | React.ReactNode)[];
281
+ buttons: (ToolbarButtonKey | React.ReactNode)[];
282
+ }
283
+ export type ToolbarButtonKey = keyof ToolbarButtonKeys;
284
+ export interface ToolbarButtonKeys {
285
+ close: null;
282
286
  }
283
287
  /** Plugin methods */
284
288
  export interface PluginProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { ComponentProps } from "../../types.js";
3
- /** Thumbnails plugin component */
4
- export declare function ThumbnailsContainer({ children, ...props }: ComponentProps): JSX.Element;
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- import { clsx, cssClass, LightboxPropsProvider } from "../../core/index.js";
3
- import { cssPrefix } from "./utils.js";
4
- import { ThumbnailsTrack } from "./ThumbnailsTrack.js";
5
- import { resolveThumbnailsProps } from "./props.js";
6
- export function ThumbnailsContainer({ children, ...props }) {
7
- const containerRef = React.useRef(null);
8
- const { position } = resolveThumbnailsProps(props.thumbnails);
9
- return (React.createElement(LightboxPropsProvider, { ...props },
10
- React.createElement("div", { ref: containerRef, className: clsx(cssClass(cssPrefix()), cssClass(cssPrefix(`${position}`))) },
11
- ["start", "top"].includes(position) && React.createElement(ThumbnailsTrack, { containerRef: containerRef }),
12
- React.createElement("div", { className: cssClass(cssPrefix("wrapper")) }, children),
13
- ["end", "bottom"].includes(position) && React.createElement(ThumbnailsTrack, { containerRef: containerRef }))));
14
- }