yet-another-react-lightbox 2.6.0 → 2.6.2
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 +5 -5
- 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.d.ts +2 -1
- package/dist/core/utils.js +4 -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 +8 -5
- 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 +11 -15
- 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,13 +1,15 @@
|
|
|
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
|
|
4
|
+
import { cssClass, getNavigationAnimationDuration, label as translateLabel } from "../utils.js";
|
|
5
5
|
import { IconButton, NextIcon, PreviousIcon } from "../components/index.js";
|
|
6
6
|
import { useEvents, 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
|
-
export
|
|
10
|
-
|
|
9
|
+
export function NavigationButton({ labels, label, icon, renderIcon, action, onClick, disabled, }) {
|
|
10
|
+
return (React.createElement(IconButton, { label: translateLabel(labels, label), icon: icon, renderIcon: renderIcon, className: cssClass(`navigation_${action}`), disabled: disabled, onClick: onClick, ...useLoseFocus(disabled) }));
|
|
11
|
+
}
|
|
12
|
+
export function Navigation({ slides, carousel: { finite }, animation, labels, render: { buttonPrev, buttonNext, iconPrev, iconNext }, }) {
|
|
11
13
|
const { currentIndex } = useLightboxState().state;
|
|
12
14
|
const { subscribeSensors } = useController();
|
|
13
15
|
const { publish } = useEvents();
|
|
@@ -27,5 +29,5 @@ export const Navigation = ({ slides, carousel: { finite }, animation, labels, re
|
|
|
27
29
|
return (React.createElement(React.Fragment, null,
|
|
28
30
|
buttonPrev ? (buttonPrev()) : (React.createElement(NavigationButton, { label: "Previous", action: ACTION_PREV, icon: PreviousIcon, renderIcon: iconPrev, disabled: prevDisabled, labels: labels, onClick: () => publish(ACTION_PREV) })),
|
|
29
31
|
buttonNext ? (buttonNext()) : (React.createElement(NavigationButton, { label: "Next", action: ACTION_NEXT, icon: NextIcon, renderIcon: iconNext, disabled: nextDisabled, labels: labels, onClick: () => publish(ACTION_NEXT) }))));
|
|
30
|
-
}
|
|
32
|
+
}
|
|
31
33
|
export const NavigationModule = createModule(MODULE_NAVIGATION, Navigation);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
3
|
+
export declare function NoScroll({ children }: ComponentProps): JSX.Element;
|
|
3
4
|
export declare const NoScrollModule: import("../../types.js").Module;
|
|
@@ -5,8 +5,10 @@ import { useLayoutEffect, useRTL } from "../hooks/index.js";
|
|
|
5
5
|
import { CLASS_NO_SCROLL, CLASS_NO_SCROLL_PADDING, MODULE_NO_SCROLL } from "../consts.js";
|
|
6
6
|
const noScroll = cssClass(CLASS_NO_SCROLL);
|
|
7
7
|
const noScrollPadding = cssClass(CLASS_NO_SCROLL_PADDING);
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
function isHTMLElement(element) {
|
|
9
|
+
return "style" in element;
|
|
10
|
+
}
|
|
11
|
+
function padScrollbar(element, padding, rtl) {
|
|
10
12
|
const styles = window.getComputedStyle(element);
|
|
11
13
|
const property = rtl ? "padding-left" : "padding-right";
|
|
12
14
|
const computedValue = rtl ? styles.paddingLeft : styles.paddingRight;
|
|
@@ -20,8 +22,8 @@ const padScrollbar = (element, padding, rtl) => {
|
|
|
20
22
|
element.style.removeProperty(property);
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
|
-
}
|
|
24
|
-
export
|
|
25
|
+
}
|
|
26
|
+
export function NoScroll({ children }) {
|
|
25
27
|
const rtl = useRTL();
|
|
26
28
|
useLayoutEffect(() => {
|
|
27
29
|
const cleanup = [];
|
|
@@ -46,5 +48,5 @@ export const NoScroll = ({ children }) => {
|
|
|
46
48
|
};
|
|
47
49
|
}, [rtl]);
|
|
48
50
|
return React.createElement(React.Fragment, null, children);
|
|
49
|
-
}
|
|
51
|
+
}
|
|
50
52
|
export const NoScrollModule = createModule(MODULE_NO_SCROLL, NoScroll);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
3
|
+
export declare function Portal({ children, animation, styles, className, on, close }: ComponentProps): React.ReactPortal | null;
|
|
3
4
|
export declare const PortalModule: import("../../types.js").Module;
|
|
@@ -6,8 +6,10 @@ import { clsx, composePrefix, cssClass, cssVar, getAnimationEasing, getFadeAnima
|
|
|
6
6
|
import { useEventCallback, useMotionPreference } from "../hooks/index.js";
|
|
7
7
|
import { useEvents, useTimeouts } from "../contexts/index.js";
|
|
8
8
|
import { ACTION_CLOSE, CLASS_NO_SCROLL_PADDING, MODULE_PORTAL } from "../consts.js";
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function cssPrefix(value) {
|
|
10
|
+
return composePrefix(MODULE_PORTAL, value);
|
|
11
|
+
}
|
|
12
|
+
function setAttribute(element, attribute, value) {
|
|
11
13
|
const previousValue = element.getAttribute(attribute);
|
|
12
14
|
element.setAttribute(attribute, value);
|
|
13
15
|
return () => {
|
|
@@ -18,8 +20,8 @@ const setAttribute = (element, attribute, value) => {
|
|
|
18
20
|
element.removeAttribute(attribute);
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
|
-
}
|
|
22
|
-
export
|
|
23
|
+
}
|
|
24
|
+
export function Portal({ children, animation, styles, className, on, close }) {
|
|
23
25
|
const [mounted, setMounted] = React.useState(false);
|
|
24
26
|
const [visible, setVisible] = React.useState(false);
|
|
25
27
|
const cleanup = React.useRef([]);
|
|
@@ -85,5 +87,5 @@ export const Portal = ({ children, animation, styles, className, on, close }) =>
|
|
|
85
87
|
...styles.root,
|
|
86
88
|
} }, children), document.body)
|
|
87
89
|
: null;
|
|
88
|
-
}
|
|
90
|
+
}
|
|
89
91
|
export const PortalModule = createModule(MODULE_PORTAL, Portal);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
2
3
|
import { YARL_EVENT_TOOLBAR_WIDTH } from "../consts.js";
|
|
3
4
|
declare module "../" {
|
|
4
5
|
interface EventTypes {
|
|
5
6
|
[YARL_EVENT_TOOLBAR_WIDTH]: number;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
export declare
|
|
9
|
+
export declare function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }: ComponentProps): JSX.Element;
|
|
9
10
|
export declare const ToolbarModule: import("../../types.js").Module;
|
|
@@ -5,8 +5,10 @@ import { useEvents } from "../contexts/index.js";
|
|
|
5
5
|
import { CloseIcon, IconButton } from "../components/index.js";
|
|
6
6
|
import { useContainerRect } from "../hooks/useContainerRect.js";
|
|
7
7
|
import { ACTION_CLOSE, MODULE_TOOLBAR, YARL_EVENT_TOOLBAR_WIDTH } from "../consts.js";
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
function cssPrefix(value) {
|
|
9
|
+
return composePrefix(MODULE_TOOLBAR, value);
|
|
10
|
+
}
|
|
11
|
+
export function Toolbar({ toolbar: { buttons }, labels, render: { buttonClose, iconClose } }) {
|
|
10
12
|
const { publish } = useEvents();
|
|
11
13
|
const { setContainerRef, containerRect } = useContainerRect();
|
|
12
14
|
React.useEffect(() => {
|
|
@@ -16,5 +18,5 @@ export const Toolbar = ({ toolbar: { buttons }, labels, render: { buttonClose, i
|
|
|
16
18
|
}, [publish, containerRect === null || containerRect === void 0 ? void 0 : containerRect.width]);
|
|
17
19
|
const renderCloseButton = () => buttonClose ? (buttonClose()) : (React.createElement(IconButton, { key: ACTION_CLOSE, label: label(labels, "Close"), icon: CloseIcon, renderIcon: iconClose, onClick: () => publish(ACTION_CLOSE) }));
|
|
18
20
|
return (React.createElement("div", { ref: setContainerRef, className: cssClass(cssPrefix()) }, buttons === null || buttons === void 0 ? void 0 : buttons.map((button) => (button === ACTION_CLOSE ? renderCloseButton() : button))));
|
|
19
|
-
}
|
|
21
|
+
}
|
|
20
22
|
export const ToolbarModule = createModule(MODULE_TOOLBAR, Toolbar);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UseSensors } from "../../hooks/useSensors.js";
|
|
2
|
-
export declare
|
|
2
|
+
export declare function usePointerSwipe<T extends Element = Element>(subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void): void;
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { cleanup } from "../../utils.js";
|
|
3
3
|
import { useEventCallback } from "../../hooks/useEventCallback.js";
|
|
4
4
|
import { EVENT_ON_POINTER_CANCEL, EVENT_ON_POINTER_DOWN, EVENT_ON_POINTER_LEAVE, EVENT_ON_POINTER_MOVE, EVENT_ON_POINTER_UP, } from "../../consts.js";
|
|
5
|
-
export
|
|
5
|
+
export function usePointerSwipe(subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) {
|
|
6
6
|
const offset = React.useRef(0);
|
|
7
7
|
const pointers = React.useRef([]);
|
|
8
8
|
const activePointer = React.useRef();
|
|
@@ -69,4 +69,4 @@ export const usePointerSwipe = (subscribeSensors, isSwipeValid, containerWidth,
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
React.useEffect(() => cleanup(subscribeSensors(EVENT_ON_POINTER_DOWN, onPointerDown), subscribeSensors(EVENT_ON_POINTER_MOVE, onPointerMove), subscribeSensors(EVENT_ON_POINTER_UP, onPointerUp), subscribeSensors(EVENT_ON_POINTER_LEAVE, onPointerUp), subscribeSensors(EVENT_ON_POINTER_CANCEL, onPointerUp)), [subscribeSensors, onPointerDown, onPointerMove, onPointerUp]);
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** prevent browser back/forward navigation on touchpad left/right swipe (especially noticeable in Safari)
|
|
2
2
|
* this has to be done via non-passive native event handler */
|
|
3
|
-
export declare
|
|
3
|
+
export declare function usePreventSwipeNavigation<T extends HTMLElement = HTMLElement>(): (node: T | null) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
const WHEEL = "wheel";
|
|
3
|
-
|
|
3
|
+
function preventDefault(event) {
|
|
4
4
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY) || event.ctrlKey) {
|
|
5
5
|
event.preventDefault();
|
|
6
6
|
}
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export function usePreventSwipeNavigation() {
|
|
9
9
|
const ref = React.useRef(null);
|
|
10
10
|
return React.useCallback((node) => {
|
|
11
11
|
var _a;
|
|
@@ -17,4 +17,4 @@ export const usePreventSwipeNavigation = () => {
|
|
|
17
17
|
}
|
|
18
18
|
ref.current = node;
|
|
19
19
|
}, []);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { UseSensors } from "../../hooks/index.js";
|
|
2
2
|
import { SwipeState } from "./index.js";
|
|
3
|
-
export declare
|
|
3
|
+
export declare function useWheelSwipe<T extends Element = Element>(swipeState: SwipeState, subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void): void;
|
|
@@ -3,7 +3,7 @@ import { useEventCallback } from "../../hooks/index.js";
|
|
|
3
3
|
import { useTimeouts } from "../../contexts/index.js";
|
|
4
4
|
import { SwipeState } from "./index.js";
|
|
5
5
|
import { EVENT_ON_WHEEL } from "../../consts.js";
|
|
6
|
-
export
|
|
6
|
+
export function useWheelSwipe(swipeState, subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel) {
|
|
7
7
|
const offset = React.useRef(0);
|
|
8
8
|
const intent = React.useRef(0);
|
|
9
9
|
const intentCleanup = React.useRef();
|
|
@@ -89,4 +89,4 @@ export const useWheelSwipe = (swipeState, subscribeSensors, isSwipeValid, contai
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
React.useEffect(() => subscribeSensors(EVENT_ON_WHEEL, onWheel), [subscribeSensors, onWheel]);
|
|
92
|
-
}
|
|
92
|
+
}
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { AnimationSettings, AnimationSpec, Labels, Slide, SlideImage } from "../types.js";
|
|
2
|
+
import { AnimationSettings, AnimationSpec, Labels, LightboxProps, Slide, SlideImage } 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;
|
|
@@ -13,6 +13,7 @@ export declare const isDefined: <T = any>(x: T | undefined) => x is T;
|
|
|
13
13
|
export declare const isNumber: (value: any) => value is number;
|
|
14
14
|
export declare const round: (value: number, decimals?: number) => number;
|
|
15
15
|
export declare const isImageSlide: (slide: Slide) => slide is SlideImage;
|
|
16
|
+
export declare const isImageFitCover: (image: SlideImage, imageFit?: LightboxProps["carousel"]["imageFit"]) => boolean;
|
|
16
17
|
export declare const parseLengthPercentage: (input: unknown) => {
|
|
17
18
|
pixel: number;
|
|
18
19
|
percent?: undefined;
|
package/dist/core/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { AnimationDefaultProps } from "../props.js";
|
|
3
|
+
import { IMAGE_FIT_CONTAIN, IMAGE_FIT_COVER } from "./consts.js";
|
|
3
4
|
export const clsx = (...classes) => [...classes].filter((cls) => Boolean(cls)).join(" ");
|
|
4
5
|
const cssPrefix = "yarl__";
|
|
5
6
|
export const cssClass = (name) => `${cssPrefix}${name}`;
|
|
@@ -27,6 +28,7 @@ export const round = (value, decimals = 0) => {
|
|
|
27
28
|
return Math.round((value + Number.EPSILON) * factor) / factor;
|
|
28
29
|
};
|
|
29
30
|
export const isImageSlide = (slide) => !isDefined(slide.type) || slide.type === "image";
|
|
31
|
+
export const isImageFitCover = (image, imageFit) => image.imageFit === IMAGE_FIT_COVER || (image.imageFit !== IMAGE_FIT_CONTAIN && imageFit === IMAGE_FIT_COVER);
|
|
30
32
|
export const parseLengthPercentage = (input) => {
|
|
31
33
|
if (typeof input === "number") {
|
|
32
34
|
return { pixel: input };
|
|
@@ -37,15 +39,11 @@ export const parseLengthPercentage = (input) => {
|
|
|
37
39
|
}
|
|
38
40
|
return { pixel: 0 };
|
|
39
41
|
};
|
|
40
|
-
export const devicePixelRatio = () =>
|
|
41
|
-
return (typeof window !== "undefined" ? window === null || window === void 0 ? void 0 : window.devicePixelRatio : undefined) || 1;
|
|
42
|
-
};
|
|
42
|
+
export const devicePixelRatio = () => (typeof window !== "undefined" ? window === null || window === void 0 ? void 0 : window.devicePixelRatio : undefined) || 1;
|
|
43
43
|
export const getSlideIndex = (index, slidesCount) => ((index % slidesCount) + slidesCount) % slidesCount;
|
|
44
44
|
export const getSlide = (slides, index) => slides[getSlideIndex(index, slides.length)];
|
|
45
45
|
export const getAnimationEasing = (animationSpec) => typeof animationSpec === "object" ? animationSpec.easing : undefined;
|
|
46
46
|
export const getAnimationDuration = (animationSpec, defaultDuration) => { var _a; return (_a = (typeof animationSpec === "object" ? animationSpec.duration : animationSpec)) !== null && _a !== void 0 ? _a : defaultDuration; };
|
|
47
47
|
export const getFadeAnimationDuration = (animation) => getAnimationDuration(animation.fade, AnimationDefaultProps.fade);
|
|
48
48
|
export const getSwipeAnimationDuration = (animation) => getAnimationDuration(animation.swipe, AnimationDefaultProps.swipe);
|
|
49
|
-
export const getNavigationAnimationDuration = (animation) =>
|
|
50
|
-
return getAnimationDuration(animation.navigation, getSwipeAnimationDuration(animation));
|
|
51
|
-
};
|
|
49
|
+
export const getNavigationAnimationDuration = (animation) => getAnimationDuration(animation.navigation, getSwipeAnimationDuration(animation));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
type CaptionsContextType = {
|
|
2
|
+
export type CaptionsContextType = {
|
|
3
3
|
toolbarWidth?: number;
|
|
4
4
|
};
|
|
5
5
|
export declare const useCaptions: () => CaptionsContextType;
|
|
6
6
|
/** Captions plugin context holder */
|
|
7
|
-
export declare
|
|
8
|
-
export {};
|
|
7
|
+
export declare function CaptionsContextProvider({ children }: React.PropsWithChildren): JSX.Element;
|
|
@@ -2,10 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import { makeUseContext, useEvents, YARL_EVENT_TOOLBAR_WIDTH } from "../../core/index.js";
|
|
3
3
|
const CaptionsContext = React.createContext(null);
|
|
4
4
|
export const useCaptions = makeUseContext("useCaptions", "CaptionsContext", CaptionsContext);
|
|
5
|
-
export
|
|
5
|
+
export function CaptionsContextProvider({ children }) {
|
|
6
6
|
const { subscribe } = useEvents();
|
|
7
7
|
const [toolbarWidth, setToolbarWidth] = React.useState();
|
|
8
8
|
React.useEffect(() => subscribe(YARL_EVENT_TOOLBAR_WIDTH, (event) => setToolbarWidth(event)), [subscribe]);
|
|
9
9
|
const context = React.useMemo(() => ({ toolbarWidth }), [toolbarWidth]);
|
|
10
10
|
return React.createElement(CaptionsContext.Provider, { value: context }, children);
|
|
11
|
-
}
|
|
11
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LightboxProps, Slide } from "../../types.js";
|
|
3
|
-
type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
|
|
4
|
-
export declare
|
|
5
|
-
export {};
|
|
3
|
+
export type DescriptionProps = Pick<LightboxProps, "styles"> & Required<Pick<Slide, "description">> & Required<LightboxProps["captions"]>;
|
|
4
|
+
export declare function Description({ description, descriptionTextAlign, descriptionMaxLines, styles }: DescriptionProps): JSX.Element;
|
|
@@ -2,16 +2,20 @@ import * as React from "react";
|
|
|
2
2
|
import { clsx, cssVar } from "../../core/index.js";
|
|
3
3
|
import { defaultCaptionsProps } from "./Captions.js";
|
|
4
4
|
import { cssPrefix } from "./utils.js";
|
|
5
|
-
export
|
|
6
|
-
React.createElement("div", { className: cssPrefix("
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
export function Description({ description, descriptionTextAlign, descriptionMaxLines, styles }) {
|
|
6
|
+
return (React.createElement("div", { style: styles.captionsDescriptionContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("description_container")) },
|
|
7
|
+
React.createElement("div", { className: cssPrefix("description"), style: {
|
|
8
|
+
...(descriptionTextAlign !== defaultCaptionsProps.descriptionTextAlign ||
|
|
9
|
+
descriptionMaxLines !== defaultCaptionsProps.descriptionMaxLines
|
|
10
|
+
? {
|
|
11
|
+
[cssVar("slide_description_text_align")]: descriptionTextAlign,
|
|
12
|
+
[cssVar("slide_description_max_lines")]: descriptionMaxLines,
|
|
13
|
+
}
|
|
14
|
+
: null),
|
|
15
|
+
...styles.captionsDescription,
|
|
16
|
+
} }, typeof description === "string"
|
|
17
|
+
? description
|
|
18
|
+
.split("\n")
|
|
19
|
+
.flatMap((line, index) => [...(index > 0 ? [React.createElement("br", { key: index })] : []), line])
|
|
20
|
+
: description)));
|
|
21
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LightboxProps, Slide } from "../../types.js";
|
|
3
|
-
type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
|
|
4
|
-
export declare
|
|
5
|
-
export {};
|
|
3
|
+
export type TitleProps = Pick<LightboxProps, "styles"> & Pick<Slide, "title">;
|
|
4
|
+
export declare function Title({ title, styles }: TitleProps): JSX.Element;
|
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { clsx, cssVar } from "../../core/index.js";
|
|
3
3
|
import { useCaptions } from "./CaptionsContext.js";
|
|
4
4
|
import { cssPrefix } from "./utils.js";
|
|
5
|
-
export
|
|
5
|
+
export function Title({ title, styles }) {
|
|
6
6
|
const { toolbarWidth } = useCaptions();
|
|
7
7
|
return (React.createElement("div", { style: styles.captionsTitleContainer, className: clsx(cssPrefix("captions_container"), cssPrefix("title_container")) },
|
|
8
8
|
React.createElement("div", { style: styles.captionsTitle, className: cssPrefix("title"), ...(toolbarWidth ? { style: { [cssVar("toolbar_width")]: `${toolbarWidth}px` } } : null) }, title)));
|
|
9
|
-
}
|
|
9
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function cssPrefix(className: string): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
/** Fullscreen button */
|
|
3
|
-
export declare
|
|
3
|
+
export declare function FullscreenButton(): JSX.Element | null;
|
|
@@ -3,11 +3,11 @@ import { createIcon, IconButton, label, useController } from "../../core/index.j
|
|
|
3
3
|
import { useFullscreen } from "./FullscreenContext.js";
|
|
4
4
|
const EnterFullscreenIcon = createIcon("EnterFullscreen", React.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }));
|
|
5
5
|
const ExitFullscreenIcon = createIcon("ExitFullscreen", React.createElement("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }));
|
|
6
|
-
export
|
|
6
|
+
export function FullscreenButton() {
|
|
7
7
|
var _a;
|
|
8
8
|
const { labels, render } = useController().getLightboxProps();
|
|
9
9
|
const { fullscreen, fullscreenEnabled, toggleFullscreen } = useFullscreen();
|
|
10
10
|
if (!fullscreenEnabled)
|
|
11
11
|
return null;
|
|
12
12
|
return render.buttonFullscreen ? (React.createElement(React.Fragment, null, (_a = render.buttonFullscreen) === null || _a === void 0 ? void 0 : _a.call(render, { fullscreen, fullscreenEnabled, toggleFullscreen }))) : (React.createElement(IconButton, { disabled: !fullscreenEnabled, label: fullscreen ? label(labels, "Exit Fullscreen") : label(labels, "Enter Fullscreen"), icon: fullscreen ? ExitFullscreenIcon : EnterFullscreenIcon, renderIcon: fullscreen ? render.iconExitFullscreen : render.iconEnterFullscreen, onClick: toggleFullscreen }));
|
|
13
|
-
}
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from "../../types.js";
|
|
3
|
+
export type FullscreenContextType = {
|
|
3
4
|
fullscreen: boolean;
|
|
4
5
|
fullscreenEnabled?: boolean;
|
|
5
6
|
toggleFullscreen: () => void;
|
|
6
7
|
};
|
|
7
8
|
export declare const useFullscreen: () => FullscreenContextType;
|
|
8
|
-
export declare
|
|
9
|
-
export {};
|
|
9
|
+
export declare function FullscreenContextProvider({ fullscreen: auto, children }: ComponentProps): JSX.Element;
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { CLASS_FULLSIZE, clsx, cssClass, makeUseContext, PLUGIN_FULLSCREEN, useEventCallback, useLayoutEffect, } from "../../core/index.js";
|
|
3
3
|
const FullscreenContext = React.createContext(null);
|
|
4
4
|
export const useFullscreen = makeUseContext("useFullscreen", "FullscreenContext", FullscreenContext);
|
|
5
|
-
export
|
|
5
|
+
export function FullscreenContextProvider({ fullscreen: auto, children }) {
|
|
6
6
|
const containerRef = React.useRef(null);
|
|
7
7
|
const [fullscreen, setFullscreen] = React.useState(false);
|
|
8
8
|
const [fullscreenEnabled, setFullscreenEnabled] = React.useState();
|
|
@@ -100,4 +100,4 @@ export const FullscreenContextProvider = ({ fullscreen: auto, children }) => {
|
|
|
100
100
|
}), [fullscreen, fullscreenEnabled, toggleFullscreen]);
|
|
101
101
|
return (React.createElement("div", { ref: containerRef, className: clsx(cssClass(PLUGIN_FULLSCREEN), cssClass(CLASS_FULLSIZE)) },
|
|
102
102
|
React.createElement(FullscreenContext.Provider, { value: context }, children)));
|
|
103
|
-
}
|
|
103
|
+
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { Fullscreen } from "./Fullscreen.js";
|
|
3
2
|
declare module "../../types" {
|
|
4
3
|
interface LightboxProps {
|
|
5
4
|
/** if `true`, enter fullscreen mode automatically when the lightbox opens */
|
|
6
5
|
fullscreen?: boolean;
|
|
7
6
|
}
|
|
7
|
+
/** `render.buttonFullscreen` render function props */
|
|
8
|
+
type RenderFullscreenButtonProps = {
|
|
9
|
+
fullscreen: boolean;
|
|
10
|
+
fullscreenEnabled: boolean | undefined;
|
|
11
|
+
toggleFullscreen: () => void;
|
|
12
|
+
};
|
|
8
13
|
interface Render {
|
|
9
14
|
/** render custom Enter/Exit Fullscreen button */
|
|
10
|
-
buttonFullscreen?:
|
|
11
|
-
fullscreen: boolean;
|
|
12
|
-
fullscreenEnabled: boolean | undefined;
|
|
13
|
-
toggleFullscreen: () => void;
|
|
14
|
-
}) => React.ReactNode;
|
|
15
|
+
buttonFullscreen?: RenderFunction<RenderFullscreenButtonProps>;
|
|
15
16
|
/** render custom Enter Fullscreen icon */
|
|
16
|
-
iconEnterFullscreen?:
|
|
17
|
+
iconEnterFullscreen?: RenderFunction;
|
|
17
18
|
/** render custom Exit Fullscreen icon */
|
|
18
|
-
iconExitFullscreen?:
|
|
19
|
+
iconExitFullscreen?: RenderFunction;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
declare global {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ACTION_CLOSE, clsx, createModule, cssClass, MODULE_NO_SCROLL, MODULE_PORTAL, PLUGIN_INLINE, } from "../../core/index.js";
|
|
3
|
-
|
|
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;
|