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.
- 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 +2 -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 +1 -1
- package/dist/core/hooks/useAnimation.js +4 -4
- 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 +2 -2
- 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 +6 -4
- 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 +7 -5
- 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.js +2 -6
- 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 +8 -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 +7 -5
- 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/styles.css +1 -0
- package/dist/types.d.ts +31 -20
- package/package.json +1 -1
|
@@ -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();
|
|
@@ -129,4 +133,4 @@ export const ThumbnailsTrack = ({ container, slides, carousel, render, thumbnail
|
|
|
129
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 }));
|
|
130
134
|
})),
|
|
131
135
|
vignette && React.createElement("div", { className: cssClass(cssPrefix("vignette")) })));
|
|
132
|
-
}
|
|
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;
|
|
@@ -317,4 +319,4 @@ export const ZoomContainer = ({ slide, offset, rect, render, carousel, animation
|
|
|
317
319
|
return rendered ? (React.createElement("div", { ref: setContainerRef, className: clsx(cssClass(CLASS_FULLSIZE), cssClass(CLASS_FLEX_CENTER)), ...(offset === 0
|
|
318
320
|
? { style: { transform: `scale(${zoom}) translateX(${offsetX}px) translateY(${offsetY}px)` } }
|
|
319
321
|
: null) }, rendered)) : null;
|
|
320
|
-
}
|
|
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/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 {
|
package/dist/types.d.ts
CHANGED
|
@@ -105,38 +105,49 @@ export interface ControllerSettings {
|
|
|
105
105
|
/** if `true`, close the lightbox when the backdrop is clicked */
|
|
106
106
|
closeOnBackdropClick: boolean;
|
|
107
107
|
}
|
|
108
|
-
/**
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
/** Render function */
|
|
109
|
+
export type RenderFunction<T = void> = (props: T) => React.ReactNode;
|
|
110
|
+
/** `render.slide` render function props */
|
|
111
|
+
export type RenderSlideProps = [
|
|
112
112
|
/** slide */
|
|
113
|
-
slide: Slide,
|
|
113
|
+
slide: Slide,
|
|
114
114
|
/** slide offset (`0` - current slide, `1` - next slide, `-1` - previous slide, etc.) */
|
|
115
|
-
offset: number,
|
|
115
|
+
offset: number,
|
|
116
116
|
/** container rect */
|
|
117
|
-
rect: ContainerRect
|
|
117
|
+
rect: ContainerRect
|
|
118
|
+
];
|
|
119
|
+
/** `render.slideHeader` render function props */
|
|
120
|
+
export type RenderSlideHeaderProps = [slide: Slide];
|
|
121
|
+
/** `render.slideFooter` render function props */
|
|
122
|
+
export type RenderSlideFooterProps = [slide: Slide];
|
|
123
|
+
/** `render.slideContainer` render function props */
|
|
124
|
+
export type RenderSlideContainerProps = [slide: Slide, children: React.ReactNode];
|
|
125
|
+
/** Custom render functions. */
|
|
126
|
+
export interface Render {
|
|
127
|
+
/** render custom slide type, or override the default image slide */
|
|
128
|
+
slide?: (...props: RenderSlideProps) => React.ReactNode;
|
|
118
129
|
/** render custom slide header */
|
|
119
|
-
slideHeader?: (
|
|
130
|
+
slideHeader?: (...props: RenderSlideHeaderProps) => React.ReactNode;
|
|
120
131
|
/** render custom slide footer */
|
|
121
|
-
slideFooter?: (
|
|
132
|
+
slideFooter?: (...props: RenderSlideFooterProps) => React.ReactNode;
|
|
122
133
|
/** render custom slide container */
|
|
123
|
-
slideContainer?: (
|
|
134
|
+
slideContainer?: (...props: RenderSlideContainerProps) => React.ReactNode;
|
|
124
135
|
/** render custom Prev icon */
|
|
125
|
-
iconPrev?:
|
|
136
|
+
iconPrev?: RenderFunction;
|
|
126
137
|
/** render custom Next icon */
|
|
127
|
-
iconNext?:
|
|
138
|
+
iconNext?: RenderFunction;
|
|
128
139
|
/** render custom Close icon */
|
|
129
|
-
iconClose?:
|
|
140
|
+
iconClose?: RenderFunction;
|
|
130
141
|
/** render custom Loading icon */
|
|
131
|
-
iconLoading?:
|
|
142
|
+
iconLoading?: RenderFunction;
|
|
132
143
|
/** render custom Error icon */
|
|
133
|
-
iconError?:
|
|
144
|
+
iconError?: RenderFunction;
|
|
134
145
|
/** render custom Prev button */
|
|
135
|
-
buttonPrev?:
|
|
146
|
+
buttonPrev?: RenderFunction;
|
|
136
147
|
/** render custom Next button */
|
|
137
|
-
buttonNext?:
|
|
148
|
+
buttonNext?: RenderFunction;
|
|
138
149
|
/** render custom Close button */
|
|
139
|
-
buttonClose?:
|
|
150
|
+
buttonClose?: RenderFunction;
|
|
140
151
|
}
|
|
141
152
|
/** Lifecycle callbacks */
|
|
142
153
|
export interface Callbacks {
|
|
@@ -197,9 +208,9 @@ export interface ToolbarSettings {
|
|
|
197
208
|
buttons: ("close" | React.ReactNode)[];
|
|
198
209
|
}
|
|
199
210
|
/** Lightbox component properties */
|
|
200
|
-
export type ComponentProps = Omit<LightboxProps, "plugins"
|
|
211
|
+
export type ComponentProps = React.PropsWithChildren<Omit<LightboxProps, "plugins">>;
|
|
201
212
|
/** Lightbox component */
|
|
202
|
-
export type Component = React.ComponentType<
|
|
213
|
+
export type Component = React.ComponentType<ComponentProps>;
|
|
203
214
|
/** Lightbox module */
|
|
204
215
|
export type Module = {
|
|
205
216
|
/** module name */
|