yet-another-react-lightbox 3.0.0 → 3.1.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.
- package/README.md +1 -0
- package/dist/core/consts.d.ts +1 -0
- package/dist/core/consts.js +1 -0
- package/dist/core/modules/Controller.d.ts +5 -1
- package/dist/core/modules/Controller.js +1 -1
- package/dist/plugins/counter/Counter.d.ts +5 -0
- package/dist/plugins/counter/Counter.js +14 -0
- package/dist/plugins/counter/counter.css +16 -0
- package/dist/plugins/counter/index.d.ts +9 -0
- package/dist/plugins/counter/index.js +2 -0
- package/dist/plugins/fullscreen/FullscreenButton.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/slideshow/SlideshowButton.js +1 -1
- package/dist/plugins/video/index.d.ts +0 -9
- package/dist/plugins/video/index.js +0 -1
- package/dist/plugins/zoom/ZoomButton.js +1 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ The following plugins come bundled in the package:
|
|
|
129
129
|
|
|
130
130
|
- [Captions](https://yet-another-react-lightbox.com/plugins/captions) - adds support for slide title and
|
|
131
131
|
description
|
|
132
|
+
- [Counter](https://yet-another-react-lightbox.com/plugins/counter) - adds slides counter
|
|
132
133
|
- [Fullscreen](https://yet-another-react-lightbox.com/plugins/fullscreen) - adds support for fullscreen mode
|
|
133
134
|
- [Inline](https://yet-another-react-lightbox.com/plugins/inline) - adds support for inline rendering mode
|
|
134
135
|
- [Slideshow](https://yet-another-react-lightbox.com/plugins/slideshow) - adds slideshow autoplay feature
|
package/dist/core/consts.d.ts
CHANGED
|
@@ -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_COUNTER = "counter";
|
|
8
9
|
export declare const PLUGIN_FULLSCREEN = "fullscreen";
|
|
9
10
|
export declare const PLUGIN_INLINE = "inline";
|
|
10
11
|
export declare const PLUGIN_SLIDESHOW = "slideshow";
|
package/dist/core/consts.js
CHANGED
|
@@ -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_COUNTER = "counter";
|
|
8
9
|
export const PLUGIN_FULLSCREEN = "fullscreen";
|
|
9
10
|
export const PLUGIN_INLINE = "inline";
|
|
10
11
|
export const PLUGIN_SLIDESHOW = "slideshow";
|
|
@@ -2,13 +2,17 @@ import * as React from "react";
|
|
|
2
2
|
import { Callback, ComponentProps, ContainerRect, ControllerRef, NavigationAction } from "../../types.js";
|
|
3
3
|
import { SubscribeSensors } from "../hooks/index.js";
|
|
4
4
|
import { LightboxStateSwipeAction } from "../contexts/index.js";
|
|
5
|
-
import { ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE } from "../consts.js";
|
|
5
|
+
import { ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_ERROR, ACTIVE_SLIDE_LOADING, ACTIVE_SLIDE_PLAYING } from "../consts.js";
|
|
6
6
|
declare module "../index.js" {
|
|
7
7
|
interface EventTypes {
|
|
8
8
|
[ACTION_PREV]: NavigationAction | void;
|
|
9
9
|
[ACTION_NEXT]: NavigationAction | void;
|
|
10
10
|
[ACTION_SWIPE]: LightboxStateSwipeAction;
|
|
11
11
|
[ACTION_CLOSE]: void;
|
|
12
|
+
[ACTIVE_SLIDE_LOADING]: void;
|
|
13
|
+
[ACTIVE_SLIDE_PLAYING]: void;
|
|
14
|
+
[ACTIVE_SLIDE_COMPLETE]: void;
|
|
15
|
+
[ACTIVE_SLIDE_ERROR]: void;
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
export type ControllerContextType = Pick<ControllerRef, "prev" | "next" | "close"> & {
|
|
@@ -4,7 +4,7 @@ import { cleanup, clsx, computeSlideRect, cssClass, cssVar, makeComposePrefix, m
|
|
|
4
4
|
import { useAnimation, useContainerRect, useDelay, useEventCallback, useForkRef, useRTL, useSensors, } from "../hooks/index.js";
|
|
5
5
|
import { useEvents, useLightboxState } from "../contexts/index.js";
|
|
6
6
|
import { SwipeState, usePointerSwipe, usePreventSwipeNavigation, useWheelSwipe } from "./controller/index.js";
|
|
7
|
-
import { ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, CLASS_FLEX_CENTER, EVENT_ON_KEY_UP, MODULE_CONTROLLER, VK_ESCAPE, } from "../consts.js";
|
|
7
|
+
import { ACTION_CLOSE, ACTION_NEXT, ACTION_PREV, ACTION_SWIPE, ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_ERROR, ACTIVE_SLIDE_LOADING, ACTIVE_SLIDE_PLAYING, CLASS_FLEX_CENTER, EVENT_ON_KEY_UP, MODULE_CONTROLLER, VK_ESCAPE, } from "../consts.js";
|
|
8
8
|
const cssContainerPrefix = makeComposePrefix("container");
|
|
9
9
|
export const ControllerContext = React.createContext(null);
|
|
10
10
|
export const useController = makeUseContext("useController", "ControllerContext", ControllerContext);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps, PluginProps } from "../../types.js";
|
|
3
|
+
export declare function CounterComponent({ counter: { className, ...rest } }: ComponentProps): JSX.Element | null;
|
|
4
|
+
/** Counter plugin */
|
|
5
|
+
export declare function Counter({ addChild }: PluginProps): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { clsx, createModule, cssClass, MODULE_CONTROLLER, PLUGIN_COUNTER, useLightboxState } from "../../core/index.js";
|
|
3
|
+
export function CounterComponent({ counter: { className, ...rest } = {} }) {
|
|
4
|
+
const { slides, currentIndex } = useLightboxState().state;
|
|
5
|
+
if (slides.length === 0)
|
|
6
|
+
return null;
|
|
7
|
+
return (React.createElement("div", { className: clsx(cssClass("counter"), className), ...rest },
|
|
8
|
+
currentIndex + 1,
|
|
9
|
+
" / ",
|
|
10
|
+
slides.length));
|
|
11
|
+
}
|
|
12
|
+
export function Counter({ addChild }) {
|
|
13
|
+
addChild(MODULE_CONTROLLER, createModule(PLUGIN_COUNTER, CounterComponent));
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.yarl__counter {
|
|
2
|
+
position: var(--yarl__counter_position, absolute);
|
|
3
|
+
top: var(--yarl__counter_top, 0);
|
|
4
|
+
left: var(--yarl__counter_left, 0);
|
|
5
|
+
bottom: var(--yarl__counter_bottom, unset);
|
|
6
|
+
right: var(--yarl__counter_right, unset);
|
|
7
|
+
color: var(--yarl__counter_color, var(--yarl__color_button, rgba(255, 255, 255, 0.8)));
|
|
8
|
+
-webkit-filter: var(--yarl__counter_filter, drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8)));
|
|
9
|
+
filter: var(--yarl__counter_filter, drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8)));
|
|
10
|
+
margin: var(--yarl__counter_margin, var(--yarl__toolbar_padding, 8px));
|
|
11
|
+
padding: var(--yarl__counter_padding, var(--yarl__button_padding, 8px));
|
|
12
|
+
line-height: var(--yarl__counter_line_height, var(--yarl__icon_size, 32px));
|
|
13
|
+
-webkit-user-select: var(--yarl__counter_user_select, none);
|
|
14
|
+
-moz-user-select: var(--yarl__counter_user_select, none);
|
|
15
|
+
user-select: var(--yarl__counter_user_select, none);
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Counter } from "./Counter.js";
|
|
3
|
+
declare module "../../types.js" {
|
|
4
|
+
interface LightboxProps {
|
|
5
|
+
/** HTML div element attributes to be passed to the Counter plugin container */
|
|
6
|
+
counter?: React.HTMLAttributes<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export default Counter;
|
|
@@ -12,5 +12,5 @@ export function FullscreenButton() {
|
|
|
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:
|
|
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 }));
|
|
16
16
|
}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Captions } from "./captions/index.js";
|
|
2
|
+
export { default as Counter } from "./counter/index.js";
|
|
2
3
|
export { default as Fullscreen } from "./fullscreen/index.js";
|
|
3
4
|
export { default as Inline } from "./inline/index.js";
|
|
4
5
|
export { default as Slideshow } from "./slideshow/index.js";
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Captions } from "./captions/index.js";
|
|
2
|
+
export { default as Counter } from "./counter/index.js";
|
|
2
3
|
export { default as Fullscreen } from "./fullscreen/index.js";
|
|
3
4
|
export { default as Inline } from "./inline/index.js";
|
|
4
5
|
export { default as Slideshow } from "./slideshow/index.js";
|
|
@@ -10,5 +10,5 @@ export function SlideshowButton() {
|
|
|
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:
|
|
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 }));
|
|
14
14
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Video } from "./Video.js";
|
|
2
|
-
import { ACTIVE_SLIDE_COMPLETE, ACTIVE_SLIDE_ERROR, ACTIVE_SLIDE_LOADING, ACTIVE_SLIDE_PLAYING } from "../../core/consts.js";
|
|
3
2
|
declare module "../../types.js" {
|
|
4
3
|
interface SlideTypes {
|
|
5
4
|
/** video slide type */
|
|
@@ -46,12 +45,4 @@ declare module "../../types.js" {
|
|
|
46
45
|
video?: Pick<SlideVideo, "autoPlay" | "controls" | "controlsList" | "crossOrigin" | "preload" | "loop" | "muted" | "playsInline" | "disablePictureInPicture" | "disableRemotePlayback">;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
declare module "../../core/index.js" {
|
|
50
|
-
interface EventTypes {
|
|
51
|
-
[ACTIVE_SLIDE_LOADING]: void;
|
|
52
|
-
[ACTIVE_SLIDE_PLAYING]: void;
|
|
53
|
-
[ACTIVE_SLIDE_COMPLETE]: void;
|
|
54
|
-
[ACTIVE_SLIDE_ERROR]: void;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
48
|
export default Video;
|
|
@@ -19,7 +19,7 @@ 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:
|
|
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: () => {
|
|
23
23
|
wasFocused.current = true;
|
|
24
24
|
}, onBlur: () => {
|
|
25
25
|
wasFocused.current = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yet-another-react-lightbox",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Modern React lightbox component",
|
|
5
5
|
"author": "Igor Danchenko",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"types": "./dist/plugins/captions/index.d.ts",
|
|
26
26
|
"default": "./dist/plugins/captions/index.js"
|
|
27
27
|
},
|
|
28
|
+
"./plugins/counter.css": "./dist/plugins/counter/counter.css",
|
|
29
|
+
"./plugins/counter": {
|
|
30
|
+
"types": "./dist/plugins/counter/index.d.ts",
|
|
31
|
+
"default": "./dist/plugins/counter/index.js"
|
|
32
|
+
},
|
|
28
33
|
"./plugins/fullscreen": {
|
|
29
34
|
"types": "./dist/plugins/fullscreen/index.d.ts",
|
|
30
35
|
"default": "./dist/plugins/fullscreen/index.js"
|
|
@@ -66,6 +71,9 @@
|
|
|
66
71
|
"plugins/captions": [
|
|
67
72
|
"dist/plugins/captions/index.d.ts"
|
|
68
73
|
],
|
|
74
|
+
"plugins/counter": [
|
|
75
|
+
"dist/plugins/counter/index.d.ts"
|
|
76
|
+
],
|
|
69
77
|
"plugins/fullscreen": [
|
|
70
78
|
"dist/plugins/fullscreen/index.d.ts"
|
|
71
79
|
],
|