yet-another-react-lightbox 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- package/dist/Lightbox.d.ts +2 -2
- package/dist/Lightbox.js +11 -9
- package/dist/core/components/Icons.d.ts +1 -1
- package/dist/core/components/Icons.js +2 -2
- package/dist/core/components/ImageSlide.d.ts +1 -1
- package/dist/core/components/ImageSlide.js +2 -2
- package/dist/core/contexts/Events.d.ts +1 -1
- package/dist/core/contexts/Events.js +2 -2
- package/dist/core/contexts/LightboxState.d.ts +3 -3
- package/dist/core/contexts/LightboxState.js +2 -2
- package/dist/core/contexts/Timeouts.d.ts +1 -1
- package/dist/core/contexts/Timeouts.js +2 -2
- package/dist/core/hooks/useAnimation.d.ts +4 -2
- package/dist/core/hooks/useAnimation.js +6 -6
- package/dist/core/hooks/useContainerRect.d.ts +1 -1
- package/dist/core/hooks/useContainerRect.js +2 -2
- package/dist/core/hooks/useDelay.d.ts +1 -1
- package/dist/core/hooks/useDelay.js +2 -2
- package/dist/core/hooks/useEventCallback.d.ts +1 -1
- package/dist/core/hooks/useEventCallback.js +2 -2
- package/dist/core/hooks/useForkRef.d.ts +2 -2
- package/dist/core/hooks/useForkRef.js +10 -8
- package/dist/core/hooks/useLoseFocus.d.ts +1 -1
- package/dist/core/hooks/useLoseFocus.js +2 -2
- package/dist/core/hooks/useMotionPreference.d.ts +1 -1
- package/dist/core/hooks/useMotionPreference.js +2 -2
- package/dist/core/hooks/useRTL.d.ts +1 -1
- package/dist/core/hooks/useRTL.js +2 -2
- package/dist/core/hooks/useSensors.d.ts +1 -1
- package/dist/core/hooks/useSensors.js +2 -2
- package/dist/core/hooks/useThrottle.d.ts +1 -1
- package/dist/core/hooks/useThrottle.js +2 -2
- package/dist/core/modules/Carousel.d.ts +3 -2
- package/dist/core/modules/Carousel.js +25 -15
- package/dist/core/modules/Controller.d.ts +2 -2
- package/dist/core/modules/Controller.js +13 -11
- package/dist/core/modules/Core.d.ts +3 -2
- package/dist/core/modules/Core.js +5 -3
- package/dist/core/modules/Navigation.d.ts +3 -3
- package/dist/core/modules/Navigation.js +7 -5
- package/dist/core/modules/NoScroll.d.ts +3 -2
- package/dist/core/modules/NoScroll.js +7 -5
- package/dist/core/modules/Portal.d.ts +3 -2
- package/dist/core/modules/Portal.js +15 -12
- package/dist/core/modules/Toolbar.d.ts +3 -2
- package/dist/core/modules/Toolbar.js +5 -3
- package/dist/core/modules/controller/usePointerSwipe.d.ts +1 -1
- package/dist/core/modules/controller/usePointerSwipe.js +2 -2
- package/dist/core/modules/controller/usePreventSwipeNavigation.d.ts +1 -1
- package/dist/core/modules/controller/usePreventSwipeNavigation.js +4 -4
- package/dist/core/modules/controller/useWheelSwipe.d.ts +1 -1
- package/dist/core/modules/controller/useWheelSwipe.js +2 -2
- package/dist/core/utils.d.ts +6 -1
- package/dist/core/utils.js +7 -3
- package/dist/plugins/captions/CaptionsContext.d.ts +2 -3
- package/dist/plugins/captions/CaptionsContext.js +2 -2
- package/dist/plugins/captions/Description.d.ts +3 -4
- package/dist/plugins/captions/Description.js +17 -13
- package/dist/plugins/captions/Title.d.ts +3 -4
- package/dist/plugins/captions/Title.js +2 -2
- package/dist/plugins/captions/utils.d.ts +1 -1
- package/dist/plugins/captions/utils.js +3 -1
- package/dist/plugins/fullscreen/FullscreenButton.d.ts +2 -2
- package/dist/plugins/fullscreen/FullscreenButton.js +2 -2
- package/dist/plugins/fullscreen/FullscreenContext.d.ts +4 -4
- package/dist/plugins/fullscreen/FullscreenContext.js +2 -2
- package/dist/plugins/fullscreen/index.d.ts +9 -8
- package/dist/plugins/inline/Inline.js +3 -1
- package/dist/plugins/slideshow/SlideshowButton.d.ts +2 -2
- package/dist/plugins/slideshow/SlideshowButton.js +2 -2
- package/dist/plugins/slideshow/SlideshowContext.d.ts +4 -4
- package/dist/plugins/slideshow/SlideshowContext.js +2 -2
- package/dist/plugins/slideshow/index.d.ts +12 -11
- package/dist/plugins/thumbnails/Thumbnail.d.ts +3 -4
- package/dist/plugins/thumbnails/Thumbnail.js +19 -17
- package/dist/plugins/thumbnails/ThumbnailsContainer.d.ts +3 -2
- package/dist/plugins/thumbnails/ThumbnailsContainer.js +2 -2
- package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +3 -4
- package/dist/plugins/thumbnails/ThumbnailsTrack.js +9 -4
- package/dist/plugins/thumbnails/index.d.ts +9 -7
- package/dist/plugins/video/VideoSlide.d.ts +3 -4
- package/dist/plugins/video/VideoSlide.js +2 -2
- package/dist/plugins/zoom/ResponsiveImage.d.ts +5 -6
- package/dist/plugins/zoom/ResponsiveImage.js +6 -3
- package/dist/plugins/zoom/ZoomButtonsGroup.d.ts +2 -2
- package/dist/plugins/zoom/ZoomButtonsGroup.js +2 -2
- package/dist/plugins/zoom/ZoomContainer.d.ts +5 -4
- package/dist/plugins/zoom/ZoomContainer.js +10 -10
- package/dist/plugins/zoom/ZoomContext.d.ts +4 -4
- package/dist/plugins/zoom/ZoomContext.js +2 -2
- package/dist/plugins/zoom/index.d.ts +12 -13
- package/dist/props.d.ts +4 -0
- package/dist/props.js +5 -4
- package/dist/styles.css +1 -0
- package/dist/types.d.ts +46 -26
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
2
|
-
export declare
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
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
|
|
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?:
|
|
23
|
+
iconSlideshowPlay?: RenderFunction;
|
|
16
24
|
/** render custom Slideshow Pause icon */
|
|
17
|
-
iconSlideshowPause?:
|
|
25
|
+
iconSlideshowPause?: RenderFunction;
|
|
18
26
|
/** render custom Slideshow button */
|
|
19
|
-
buttonSlideshow?:
|
|
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
|
|
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
|
-
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
2
3
|
/** Thumbnails plugin component */
|
|
3
|
-
export declare
|
|
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
|
|
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
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ContainerRect, DeepNonNullable, LightboxProps } from "../../types.js";
|
|
3
|
-
type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
|
|
4
|
-
type ThumbnailsTrackProps = Pick<LightboxProps, "slides" | "carousel" | "animation" | "render" | "styles"> & {
|
|
3
|
+
export type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
|
|
4
|
+
export type ThumbnailsTrackProps = Pick<LightboxProps, "slides" | "carousel" | "animation" | "render" | "styles"> & {
|
|
5
5
|
container: React.RefObject<HTMLDivElement>;
|
|
6
6
|
thumbnails: ThumbnailsInternal;
|
|
7
7
|
thumbnailRect: ContainerRect;
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
10
|
-
export {};
|
|
9
|
+
export declare function ThumbnailsTrack({ container, slides, carousel, render, thumbnails, thumbnailRect, styles, }: ThumbnailsTrackProps): JSX.Element;
|
|
@@ -3,9 +3,13 @@ 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 } from "./Thumbnails.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function isHorizontal(position) {
|
|
7
|
+
return ["top", "bottom"].includes(position);
|
|
8
|
+
}
|
|
9
|
+
function boxSize(thumbnails, dimension, includeGap) {
|
|
10
|
+
return dimension + 2 * (thumbnails.border + thumbnails.padding) + (includeGap ? thumbnails.gap : 0);
|
|
11
|
+
}
|
|
12
|
+
export function ThumbnailsTrack({ container, slides, carousel, render, thumbnails, thumbnailRect, styles, }) {
|
|
9
13
|
const track = React.useRef(null);
|
|
10
14
|
const { globalIndex, animation } = useLightboxState().state;
|
|
11
15
|
const { publish, subscribe } = useEvents();
|
|
@@ -28,6 +32,7 @@ export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnail
|
|
|
28
32
|
{ transform: "translateY(0)" },
|
|
29
33
|
],
|
|
30
34
|
duration: animationDuration,
|
|
35
|
+
easing: animation === null || animation === void 0 ? void 0 : animation.easing,
|
|
31
36
|
}));
|
|
32
37
|
const handleControllerSwipe = useEventCallback(() => {
|
|
33
38
|
let animationOffset;
|
|
@@ -128,4 +133,4 @@ export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnail
|
|
|
128
133
|
return (React.createElement(Thumbnail, { key: slideIndex, rect: thumbnailRect, slide: slide, imageFit: imageFit, render: render, active: slideIndex === index, fadeIn: fadeIn, fadeOut: fadeOut, placeholder: Boolean(placeholder), onClick: handleClick(slideIndex), style: styles.thumbnail }));
|
|
129
134
|
})),
|
|
130
135
|
vignette && React.createElement("div", { className: cssClass(cssPrefix("vignette")) })));
|
|
131
|
-
}
|
|
136
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { Thumbnails } from "./Thumbnails.js";
|
|
3
2
|
type Position = "top" | "bottom" | "start" | "end";
|
|
4
3
|
declare module "../../types" {
|
|
@@ -25,13 +24,16 @@ declare module "../../types" {
|
|
|
25
24
|
vignette?: boolean;
|
|
26
25
|
};
|
|
27
26
|
}
|
|
27
|
+
/** `render.thumbnail` render function props */
|
|
28
|
+
type RenderThumbnailProps = {
|
|
29
|
+
slide: Slide;
|
|
30
|
+
rect: ContainerRect;
|
|
31
|
+
render: Render;
|
|
32
|
+
imageFit: ImageFit;
|
|
33
|
+
};
|
|
28
34
|
interface Render {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
rect: ContainerRect;
|
|
32
|
-
render: Render;
|
|
33
|
-
imageFit: ImageFit;
|
|
34
|
-
}) => React.ReactNode;
|
|
35
|
+
/** render custom thumbnail */
|
|
36
|
+
thumbnail?: RenderFunction<RenderThumbnailProps>;
|
|
35
37
|
}
|
|
36
38
|
interface SlotType {
|
|
37
39
|
/** thumbnail customization slot */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { SlideVideo } from "./index.js";
|
|
3
|
-
type VideoSlideProps = {
|
|
3
|
+
export type VideoSlideProps = {
|
|
4
4
|
slide: SlideVideo;
|
|
5
5
|
offset: number;
|
|
6
6
|
};
|
|
7
7
|
/** Video slide */
|
|
8
|
-
export declare
|
|
9
|
-
export {};
|
|
8
|
+
export declare function VideoSlide({ slide, offset }: VideoSlideProps): JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_LOADING, ACTIVE_SLIDE_PLAYING, CLASS_FLEX_CENTER, clsx, cssClass, useContainerRect, useController, useEventCallback, useEvents, } from "../../core/index.js";
|
|
3
3
|
import { defaultVideoProps } from "./Video.js";
|
|
4
|
-
export
|
|
4
|
+
export function VideoSlide({ slide, offset }) {
|
|
5
5
|
const { publish } = useEvents();
|
|
6
6
|
const { setContainerRef, containerRect } = useContainerRect();
|
|
7
7
|
const videoRef = React.useRef(null);
|
|
@@ -67,4 +67,4 @@ export const VideoSlide = ({ slide, offset }) => {
|
|
|
67
67
|
}, onEnded: () => {
|
|
68
68
|
publish(ACTIVE_SLIDE_COMPLETE);
|
|
69
69
|
} }, sources.map(({ src, type }, index) => (React.createElement("source", { key: index, src: src, type: type })))))))));
|
|
70
|
-
}
|
|
70
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ImageSlideProps } from "../../core/index.js";
|
|
3
3
|
import { ImageSource, SlideImage } from "../../types.js";
|
|
4
|
-
type ResponsiveImageSlide = Omit<SlideImage, "srcSet"> & {
|
|
4
|
+
export type ResponsiveImageSlide = Omit<SlideImage, "srcSet"> & {
|
|
5
5
|
srcSet: [ImageSource, ...ImageSource[]];
|
|
6
6
|
};
|
|
7
|
-
export declare
|
|
8
|
-
type ResponsiveImageProps = Omit<ImageSlideProps, "slide" | "rect"> & Required<Pick<ImageSlideProps, "rect">> & {
|
|
7
|
+
export declare function isResponsiveImageSlide(slide: SlideImage): slide is ResponsiveImageSlide;
|
|
8
|
+
export type ResponsiveImageProps = Omit<ImageSlideProps, "slide" | "rect"> & Required<Pick<ImageSlideProps, "rect">> & {
|
|
9
9
|
slide: ResponsiveImageSlide;
|
|
10
10
|
};
|
|
11
|
-
export declare
|
|
12
|
-
export {};
|
|
11
|
+
export declare function ResponsiveImage(props: ResponsiveImageProps): JSX.Element;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { devicePixelRatio, IMAGE_FIT_CONTAIN, IMAGE_FIT_COVER, ImageSlide, useEventCallback, useLayoutEffect, } from "../../core/index.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export function isResponsiveImageSlide(slide) {
|
|
4
|
+
var _a;
|
|
5
|
+
return (((_a = slide.srcSet) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0;
|
|
6
|
+
}
|
|
7
|
+
export function ResponsiveImage(props) {
|
|
5
8
|
var _a, _b;
|
|
6
9
|
const [state, setState] = React.useState({});
|
|
7
10
|
const { current, preload } = state;
|
|
@@ -44,4 +47,4 @@ export const ResponsiveImage = (props) => {
|
|
|
44
47
|
iconError: () => null,
|
|
45
48
|
} })),
|
|
46
49
|
current && (React.createElement(ImageSlide, { key: "current", ...props, slide: { ...image, src: current, srcSet: undefined }, style: style }))));
|
|
47
|
-
}
|
|
50
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LightboxProps } from "../../types.js";
|
|
3
3
|
type ZoomButtonsGroupProps = Pick<LightboxProps, "labels" | "render">;
|
|
4
|
-
export declare
|
|
4
|
+
export declare function ZoomButtonsGroup({ labels, render }: ZoomButtonsGroupProps): JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { useController } from "../../core/index.js";
|
|
3
3
|
import { ZoomButton } from "./ZoomButton.js";
|
|
4
4
|
import { ACTION_ZOOM_IN, ACTION_ZOOM_OUT } from "./index.js";
|
|
5
|
-
export
|
|
5
|
+
export function ZoomButtonsGroup({ labels, render }) {
|
|
6
6
|
const zoomInRef = React.useRef(null);
|
|
7
7
|
const zoomOutRef = React.useRef(null);
|
|
8
8
|
const { transferFocus } = useController();
|
|
@@ -20,4 +20,4 @@ export const ZoomButtonsGroup = ({ labels, render }) => {
|
|
|
20
20
|
return (React.createElement(React.Fragment, null,
|
|
21
21
|
React.createElement(ZoomButton, { ref: zoomInRef, key: ACTION_ZOOM_IN, zoomIn: true, labels: labels, render: render, onLoseFocus: focusZoomOut }),
|
|
22
22
|
React.createElement(ZoomButton, { ref: zoomOutRef, key: ACTION_ZOOM_OUT, labels: labels, render: render, onLoseFocus: focusZoomIn })));
|
|
23
|
-
}
|
|
23
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ContainerRect, LightboxProps, Slide } from "../../types.js";
|
|
3
|
-
|
|
4
|
-
export declare const ZoomContainer: React.FC<Pick<LightboxProps, "render" | "carousel" | "zoom" | "animation" | "on"> & {
|
|
3
|
+
export type ZoomContainerProps = Pick<LightboxProps, "render" | "carousel" | "zoom" | "animation" | "on"> & {
|
|
5
4
|
slide: Slide;
|
|
6
5
|
offset: number;
|
|
7
6
|
rect: ContainerRect;
|
|
8
|
-
}
|
|
7
|
+
};
|
|
8
|
+
/** Zoom container */
|
|
9
|
+
export declare function ZoomContainer({ slide, offset, rect, render, carousel, animation, zoom: originalZoomProps, on, }: ZoomContainerProps): JSX.Element | null;
|
|
@@ -4,7 +4,7 @@ import { useZoom } from "./ZoomContext.js";
|
|
|
4
4
|
import { defaultZoomProps } from "./Zoom.js";
|
|
5
5
|
import { ACTION_ZOOM_IN, ACTION_ZOOM_OUT } from "./index.js";
|
|
6
6
|
import { isResponsiveImageSlide, ResponsiveImage } from "./ResponsiveImage.js";
|
|
7
|
-
|
|
7
|
+
function getSlideRects(slide, cover, maxZoomPixelRatio, rect) {
|
|
8
8
|
var _a, _b;
|
|
9
9
|
let slideRect = { width: 0, height: 0 };
|
|
10
10
|
let maxSlideRect = { width: 0, height: 0 };
|
|
@@ -34,9 +34,11 @@ const getSlideRects = (slide, cover, maxZoomPixelRatio, rect) => {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
return { slideRect, maxSlideRect };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
}
|
|
38
|
+
function distance(pointerA, pointerB) {
|
|
39
|
+
return ((pointerA.clientX - pointerB.clientX) ** 2 + (pointerA.clientY - pointerB.clientY) ** 2) ** 0.5;
|
|
40
|
+
}
|
|
41
|
+
export function ZoomContainer({ slide, offset, rect, render, carousel, animation, zoom: originalZoomProps, on, }) {
|
|
40
42
|
var _a;
|
|
41
43
|
const zoomProps = { ...defaultZoomProps, ...originalZoomProps };
|
|
42
44
|
const { currentIndex } = useLightboxState().state;
|
|
@@ -96,12 +98,10 @@ export const ZoomContainer = ({ slide, offset, rect, render, carousel, animation
|
|
|
96
98
|
if (zoomAnimationStart.current && containerRef.current) {
|
|
97
99
|
zoomAnimation.current = (_c = (_b = containerRef.current).animate) === null || _c === void 0 ? void 0 : _c.call(_b, [
|
|
98
100
|
{ transform: zoomAnimationStart.current },
|
|
99
|
-
{
|
|
100
|
-
transform: `scale(${zoom}) translateX(${offsetX}px) translateY(${offsetY}px)`,
|
|
101
|
-
},
|
|
101
|
+
{ transform: `scale(${zoom}) translateX(${offsetX}px) translateY(${offsetY}px)` },
|
|
102
102
|
], {
|
|
103
|
-
duration: reduceMotion ?
|
|
104
|
-
easing: zoomAnimation ? "ease-out" : "ease-in-out",
|
|
103
|
+
duration: !reduceMotion ? (_d = animation.zoom) !== null && _d !== void 0 ? _d : 500 : 0,
|
|
104
|
+
easing: zoomAnimation.current ? "ease-out" : "ease-in-out",
|
|
105
105
|
});
|
|
106
106
|
zoomAnimationStart.current = undefined;
|
|
107
107
|
if (zoomAnimation.current) {
|
|
@@ -319,4 +319,4 @@ export const ZoomContainer = ({ slide, offset, rect, render, carousel, animation
|
|
|
319
319
|
return rendered ? (React.createElement("div", { ref: setContainerRef, className: clsx(cssClass(CLASS_FULLSIZE), cssClass(CLASS_FLEX_CENTER)), ...(offset === 0
|
|
320
320
|
? { style: { transform: `scale(${zoom}) translateX(${offsetX}px) translateY(${offsetY}px)` } }
|
|
321
321
|
: null) }, rendered)) : null;
|
|
322
|
-
}
|
|
322
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
3
|
+
export type ZoomContextType = {
|
|
3
4
|
isMinZoom: boolean;
|
|
4
5
|
isMaxZoom: boolean;
|
|
5
6
|
isZoomSupported: boolean;
|
|
@@ -7,5 +8,4 @@ type ZoomContextType = {
|
|
|
7
8
|
setIsMaxZoom: (value: boolean) => void;
|
|
8
9
|
};
|
|
9
10
|
export declare const useZoom: () => ZoomContextType;
|
|
10
|
-
export declare
|
|
11
|
-
export {};
|
|
11
|
+
export declare function ZoomContextProvider({ slides, children }: ComponentProps): JSX.Element;
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { isImageSlide, makeUseContext, useEventCallback, useLayoutEffect, useLightboxState } from "../../core/index.js";
|
|
3
3
|
const ZoomContext = React.createContext(null);
|
|
4
4
|
export const useZoom = makeUseContext("useZoom", "ZoomContext", ZoomContext);
|
|
5
|
-
export
|
|
5
|
+
export function ZoomContextProvider({ slides, children }) {
|
|
6
6
|
const [isMinZoom, setIsMinZoom] = React.useState(false);
|
|
7
7
|
const [isMaxZoom, setIsMaxZoom] = React.useState(false);
|
|
8
8
|
const [isZoomSupported, setIsZoomSupported] = React.useState(false);
|
|
@@ -17,4 +17,4 @@ export const ZoomContextProvider = ({ slides, children }) => {
|
|
|
17
17
|
setIsMaxZoom,
|
|
18
18
|
}), [isMinZoom, isMaxZoom, isZoomSupported]);
|
|
19
19
|
return React.createElement(ZoomContext.Provider, { value: context }, children);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { LightboxProps } from "../../types.js";
|
|
3
2
|
import { Zoom } from "./Zoom.js";
|
|
4
3
|
export declare const ACTION_ZOOM_IN = "zoom-in";
|
|
5
4
|
export declare const ACTION_ZOOM_OUT = "zoom-out";
|
|
6
|
-
/** Custom zoom button render function */
|
|
7
|
-
type RenderZoomButton = ({ ref, labels, disabled, onClick, onFocus, onBlur, }: Pick<LightboxProps, "labels"> & {
|
|
8
|
-
ref: React.ForwardedRef<HTMLButtonElement>;
|
|
9
|
-
disabled: boolean;
|
|
10
|
-
onClick: () => void;
|
|
11
|
-
onFocus: () => void;
|
|
12
|
-
onBlur: () => void;
|
|
13
|
-
}) => React.ReactNode;
|
|
14
5
|
declare module "../../types" {
|
|
15
6
|
interface LightboxProps {
|
|
16
7
|
/** Zoom plugin settings */
|
|
@@ -39,15 +30,23 @@ declare module "../../types" {
|
|
|
39
30
|
/** zoom animation duration */
|
|
40
31
|
zoom?: number;
|
|
41
32
|
}
|
|
33
|
+
/** `render.buttonZoomIn` and `render.buttonZoomOut` render function props */
|
|
34
|
+
type RenderZoomButtonProps = Pick<LightboxProps, "labels"> & {
|
|
35
|
+
ref: React.ForwardedRef<HTMLButtonElement>;
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
onClick: () => void;
|
|
38
|
+
onFocus: () => void;
|
|
39
|
+
onBlur: () => void;
|
|
40
|
+
};
|
|
42
41
|
interface Render {
|
|
43
42
|
/** render custom Zoom in button */
|
|
44
|
-
buttonZoomIn?:
|
|
43
|
+
buttonZoomIn?: RenderFunction<RenderZoomButtonProps>;
|
|
45
44
|
/** render custom Zoom in button */
|
|
46
|
-
buttonZoomOut?:
|
|
45
|
+
buttonZoomOut?: RenderFunction<RenderZoomButtonProps>;
|
|
47
46
|
/** render custom Zoom in icon */
|
|
48
|
-
iconZoomIn?:
|
|
47
|
+
iconZoomIn?: RenderFunction;
|
|
49
48
|
/** render custom Zoom out icon */
|
|
50
|
-
iconZoomOut?:
|
|
49
|
+
iconZoomOut?: RenderFunction;
|
|
51
50
|
}
|
|
52
51
|
interface Callbacks {
|
|
53
52
|
zoom?: (level: number) => void;
|
package/dist/props.d.ts
CHANGED
package/dist/props.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ACTION_CLOSE, IMAGE_FIT_CONTAIN } from "./core/consts.js";
|
|
2
|
+
export const AnimationDefaultProps = {
|
|
3
|
+
fade: 330,
|
|
4
|
+
swipe: 500,
|
|
5
|
+
};
|
|
2
6
|
export const LightboxDefaultProps = {
|
|
3
7
|
open: false,
|
|
4
8
|
close: () => { },
|
|
@@ -8,10 +12,7 @@ export const LightboxDefaultProps = {
|
|
|
8
12
|
plugins: [],
|
|
9
13
|
toolbar: { buttons: [ACTION_CLOSE] },
|
|
10
14
|
labels: {},
|
|
11
|
-
animation:
|
|
12
|
-
fade: 330,
|
|
13
|
-
swipe: 500,
|
|
14
|
-
},
|
|
15
|
+
animation: AnimationDefaultProps,
|
|
15
16
|
carousel: {
|
|
16
17
|
finite: false,
|
|
17
18
|
preload: 2,
|
package/dist/styles.css
CHANGED
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
.yarl__slide {
|
|
60
60
|
flex: 1;
|
|
61
61
|
position: relative;
|
|
62
|
+
overflow: hidden;
|
|
62
63
|
padding: calc(var(--yarl__carousel_padding_px, 0) * 1px + 100 / (100 * var(--yarl__carousel_slides_count) + (var(--yarl__carousel_slides_count) - 1) * var(--yarl__carousel_spacing_percent, 0)) * var(--yarl__carousel_padding_percent, 0) * 1%);
|
|
63
64
|
}
|
|
64
65
|
[dir=rtl] .yarl__slide {
|