yet-another-react-lightbox 1.2.2 → 1.3.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 +5 -7
- package/dist/Lightbox.d.ts +5 -47
- package/dist/Lightbox.js +3 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/plugins/Fullscreen.d.ts +6 -3
- package/dist/plugins/Fullscreen.js +4 -2
- package/dist/plugins/Inline.d.ts +5 -3
- package/dist/plugins/Inline.js +5 -3
- package/dist/plugins/Video.d.ts +4 -2
- package/dist/plugins/Video.js +4 -2
- package/dist/types.d.ts +18 -2
- package/dist/types.js +18 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Yet Another React Lightbox
|
|
2
2
|
|
|
3
|
-
Modern lightbox component
|
|
3
|
+
Modern React lightbox component.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -8,11 +8,9 @@ Modern lightbox component for React.
|
|
|
8
8
|
[](https://bundlephobia.com/package/yet-another-react-lightbox)
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
|
|
11
|
-
Coming soon...
|
|
12
|
-
|
|
13
11
|
## Documentation
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
[https://yet-another-react-lightbox.vercel.app/](https://yet-another-react-lightbox.vercel.app/)
|
|
16
14
|
|
|
17
15
|
## Installation
|
|
18
16
|
|
|
@@ -30,10 +28,10 @@ yarn add yet-another-react-lightbox
|
|
|
30
28
|
|
|
31
29
|
```javascript
|
|
32
30
|
import * as React from "react";
|
|
33
|
-
import
|
|
31
|
+
import Lightbox from "yet-another-react-lightbox";
|
|
34
32
|
import "yet-another-react-lightbox/styles.css";
|
|
35
33
|
|
|
36
|
-
const
|
|
34
|
+
const App = () => {
|
|
37
35
|
const [open, setOpen] = React.useState(false);
|
|
38
36
|
|
|
39
37
|
return (
|
|
@@ -55,7 +53,7 @@ const Page = () => {
|
|
|
55
53
|
);
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
export default
|
|
56
|
+
export default App;
|
|
59
57
|
```
|
|
60
58
|
|
|
61
59
|
## License
|
package/dist/Lightbox.d.ts
CHANGED
|
@@ -1,49 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
propTypes: {
|
|
6
|
-
open: import("prop-types").Validator<boolean>;
|
|
7
|
-
close: import("prop-types").Validator<(...args: any[]) => any>;
|
|
8
|
-
index: import("prop-types").Validator<number>;
|
|
9
|
-
slides: import("prop-types").Validator<any[]>;
|
|
10
|
-
render: import("prop-types").Validator<import("prop-types").InferProps<{}>>;
|
|
11
|
-
plugins: import("prop-types").Validator<((...args: any[]) => any)[]>;
|
|
12
|
-
toolbar: import("prop-types").Validator<import("prop-types").InferProps<{
|
|
13
|
-
buttons: import("prop-types").Validator<(string | number | boolean | import("prop-types").ReactElementLike | import("prop-types").ReactNodeArray | null | undefined)[]>;
|
|
14
|
-
}>>;
|
|
15
|
-
labels: import("prop-types").Validator<import("prop-types").InferProps<{}>>;
|
|
16
|
-
carousel: import("prop-types").Validator<import("prop-types").InferProps<{
|
|
17
|
-
finite: import("prop-types").Validator<boolean>;
|
|
18
|
-
preload: import("prop-types").Validator<number>;
|
|
19
|
-
padding: import("prop-types").Validator<string | number>;
|
|
20
|
-
spacing: import("prop-types").Validator<string | number>;
|
|
21
|
-
}>>;
|
|
22
|
-
animation: import("prop-types").Validator<import("prop-types").InferProps<{
|
|
23
|
-
fade: import("prop-types").Validator<number>;
|
|
24
|
-
swipe: import("prop-types").Validator<number>;
|
|
25
|
-
}>>;
|
|
26
|
-
on: import("prop-types").Validator<import("prop-types").InferProps<{}>>;
|
|
27
|
-
};
|
|
28
|
-
defaultProps: {
|
|
29
|
-
open: boolean;
|
|
30
|
-
close: () => void;
|
|
31
|
-
index: number;
|
|
32
|
-
slides: import("./types.js").Slide[];
|
|
33
|
-
render: import("./types.js").Render;
|
|
34
|
-
plugins: import("./types.js").Plugin[];
|
|
35
|
-
toolbar: import("./types.js").Toolbar;
|
|
36
|
-
labels: import("./types.js").Labels;
|
|
37
|
-
animation: import("./types.js").Animation;
|
|
38
|
-
carousel: import("./types.js").Carousel;
|
|
39
|
-
on: import("./types.js").Callbacks;
|
|
40
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LightboxProps } from "./types.js";
|
|
3
|
+
declare type DeepPartial<T, K extends keyof T> = Omit<T, K> & {
|
|
4
|
+
[P in keyof Pick<T, K>]?: Partial<Pick<T, K>[P]>;
|
|
41
5
|
};
|
|
42
|
-
declare
|
|
43
|
-
declare type MakePartial<T> = T extends object ? Partial<T> : T;
|
|
44
|
-
declare type NestedPartial<T extends object> = {
|
|
45
|
-
[P in keyof T]?: MakePartial<T[P]>;
|
|
46
|
-
};
|
|
47
|
-
declare type NestedOptional<T, K extends keyof T> = Omit<T, K> & NestedPartial<Pick<T, K>>;
|
|
48
|
-
export declare const Lightbox: (props: NestedOptional<LightboxComponentProps<typeof LightboxComponent>, "carousel" | "animation">) => JSX.Element;
|
|
6
|
+
export declare const Lightbox: (props: DeepPartial<Partial<LightboxProps>, "carousel" | "animation" | "render" | "toolbar" | "on">) => JSX.Element;
|
|
49
7
|
export {};
|
package/dist/Lightbox.js
CHANGED
|
@@ -24,9 +24,8 @@ const LightboxComponent = (props) => {
|
|
|
24
24
|
return React.createElement(React.Fragment, null, renderNode(createNode(CoreModule, config), augmentedProps));
|
|
25
25
|
};
|
|
26
26
|
LightboxComponent.propTypes = LightboxPropTypes;
|
|
27
|
-
LightboxComponent.defaultProps = LightboxDefaultProps;
|
|
28
27
|
export const Lightbox = (props) => {
|
|
29
|
-
const { carousel, animation, ...restProps } = props;
|
|
30
|
-
const { carousel: defaultCarousel, animation: defaultAnimation, ...restDefaultProps } = LightboxDefaultProps;
|
|
31
|
-
return (React.createElement(LightboxComponent, { carousel: { ...defaultCarousel, ...carousel }, animation: { ...defaultAnimation, ...animation }, ...restDefaultProps, ...restProps }));
|
|
28
|
+
const { carousel, animation, render, toolbar, on, ...restProps } = props;
|
|
29
|
+
const { carousel: defaultCarousel, animation: defaultAnimation, render: defaultRender, toolbar: defaultToolbar, on: defaultOn, ...restDefaultProps } = LightboxDefaultProps;
|
|
30
|
+
return (React.createElement(LightboxComponent, { carousel: { ...defaultCarousel, ...carousel }, animation: { ...defaultAnimation, ...animation }, render: { ...defaultRender, ...render }, toolbar: { ...defaultToolbar, ...toolbar }, on: { ...defaultOn, ...on }, ...restDefaultProps, ...restProps }));
|
|
32
31
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,9 +31,12 @@ declare global {
|
|
|
31
31
|
msRequestFullscreen?: () => void;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
declare type FullscreenButtonProps = Pick<LightboxProps, "labels"> & {
|
|
35
35
|
auto: boolean;
|
|
36
36
|
render: Render;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
declare const FullscreenButton: ({ auto, labels, render }: FullscreenButtonProps) => JSX.Element | null;
|
|
39
|
+
declare const Fullscreen: Plugin;
|
|
40
|
+
export type { FullscreenButtonProps };
|
|
41
|
+
export { Fullscreen, FullscreenButton };
|
|
42
|
+
export default Fullscreen;
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { createIcon, IconButton, label, useController, useLatest } from "../core/index.js";
|
|
3
3
|
const EnterFullscreenIcon = createIcon("EnterFullscreen", React.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }));
|
|
4
4
|
const ExitFullscreenIcon = createIcon("ExitFullscreen", React.createElement("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }));
|
|
5
|
-
|
|
5
|
+
const FullscreenButton = ({ auto, labels, render }) => {
|
|
6
6
|
const [fullscreen, setFullscreen] = React.useState(false);
|
|
7
7
|
const latestAuto = useLatest(auto);
|
|
8
8
|
const { containerRef } = useController();
|
|
@@ -92,7 +92,7 @@ export const FullscreenButton = ({ auto, labels, render }) => {
|
|
|
92
92
|
return null;
|
|
93
93
|
return render.buttonFullscreen ? (React.createElement(React.Fragment, null, render.buttonFullscreen({ fullscreen, toggleFullscreen }))) : (React.createElement(IconButton, { label: fullscreen ? label(labels, "Exit Fullscreen") : label(labels, "Enter Fullscreen"), icon: fullscreen ? ExitFullscreenIcon : EnterFullscreenIcon, renderIcon: fullscreen ? render.iconExitFullscreen : render.iconEnterFullscreen, onClick: toggleFullscreen }));
|
|
94
94
|
};
|
|
95
|
-
|
|
95
|
+
const Fullscreen = ({ augment }) => {
|
|
96
96
|
augment(({ toolbar: { buttons, ...restToolbar }, ...restProps }) => ({
|
|
97
97
|
toolbar: {
|
|
98
98
|
buttons: [
|
|
@@ -104,3 +104,5 @@ export const Fullscreen = ({ augment }) => {
|
|
|
104
104
|
...restProps,
|
|
105
105
|
}));
|
|
106
106
|
};
|
|
107
|
+
export { Fullscreen, FullscreenButton };
|
|
108
|
+
export default Fullscreen;
|
package/dist/plugins/Inline.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare module "../types.js" {
|
|
|
5
5
|
inline?: React.HTMLAttributes<HTMLDivElement>;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare const InlineContainer: Component;
|
|
9
|
+
declare const InlineModule: import("../types.js").Module;
|
|
10
|
+
declare const Inline: Plugin;
|
|
11
|
+
export { Inline, InlineModule, InlineContainer };
|
|
12
|
+
export default Inline;
|
package/dist/plugins/Inline.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { createModule } from "../core/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const InlineContainer = ({ inline, children }) => React.createElement("div", { ...inline }, children);
|
|
4
|
+
const InlineModule = createModule("inline", InlineContainer);
|
|
5
|
+
const Inline = ({ augment, replace, remove }) => {
|
|
6
6
|
augment(({ toolbar: { buttons, ...restToolbar }, open, close, ...restProps }) => ({
|
|
7
7
|
open: true,
|
|
8
8
|
close: () => { },
|
|
@@ -16,3 +16,5 @@ export const Inline = ({ augment, replace, remove }) => {
|
|
|
16
16
|
remove("no-scroll");
|
|
17
17
|
replace("portal", InlineModule);
|
|
18
18
|
};
|
|
19
|
+
export { Inline, InlineModule, InlineContainer };
|
|
20
|
+
export default Inline;
|
package/dist/plugins/Video.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ declare module "../types.js" {
|
|
|
15
15
|
SlideVideo: SlideVideo;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
declare const VideoSlide: ({ slide: { sources, poster, width, height } }: {
|
|
19
19
|
slide: SlideVideo;
|
|
20
20
|
}) => JSX.Element;
|
|
21
|
-
|
|
21
|
+
declare const Video: Plugin;
|
|
22
|
+
export { Video, VideoSlide };
|
|
23
|
+
export default Video;
|
package/dist/plugins/Video.js
CHANGED
|
@@ -12,7 +12,7 @@ SlideTypesPropTypes.push(PropTypes.shape({
|
|
|
12
12
|
type: PropTypes.string.isRequired,
|
|
13
13
|
}).isRequired),
|
|
14
14
|
}));
|
|
15
|
-
|
|
15
|
+
const VideoSlide = ({ slide: { sources, poster, width, height } }) => {
|
|
16
16
|
const { setContainerRef, containerRect } = useContainerRect();
|
|
17
17
|
const scaleWidthAndHeight = () => {
|
|
18
18
|
if (!width || !height || !containerRect)
|
|
@@ -28,7 +28,7 @@ export const VideoSlide = ({ slide: { sources, poster, width, height } }) => {
|
|
|
28
28
|
height: "100%",
|
|
29
29
|
}, className: clsx(cssClass("video_container"), cssClass("flex_center")) }, containerRect && (React.createElement("video", { controls: true, playsInline: true, poster: poster, ...scaleWidthAndHeight() }, sources.map(({ src, type }, index) => (React.createElement("source", { key: index, src: src, type: type })))))))));
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
const Video = ({ augment }) => {
|
|
32
32
|
augment(({ render: { slide: renderSlide, ...restRender }, ...restProps }) => ({
|
|
33
33
|
render: {
|
|
34
34
|
slide: (slide) => {
|
|
@@ -42,3 +42,5 @@ export const Video = ({ augment }) => {
|
|
|
42
42
|
...restProps,
|
|
43
43
|
}));
|
|
44
44
|
};
|
|
45
|
+
export { Video, VideoSlide };
|
|
46
|
+
export default Video;
|
package/dist/types.d.ts
CHANGED
|
@@ -60,7 +60,17 @@ export declare const LightboxPropTypes: {
|
|
|
60
60
|
close: PropTypes.Validator<(...args: any[]) => any>;
|
|
61
61
|
index: PropTypes.Validator<number>;
|
|
62
62
|
slides: PropTypes.Validator<any[]>;
|
|
63
|
-
render: PropTypes.Validator<PropTypes.InferProps<{
|
|
63
|
+
render: PropTypes.Validator<PropTypes.InferProps<{
|
|
64
|
+
slide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
|
+
iconPrev: PropTypes.Requireable<(...args: any[]) => any>;
|
|
66
|
+
iconNext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
67
|
+
iconClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
68
|
+
iconLoading: PropTypes.Requireable<(...args: any[]) => any>;
|
|
69
|
+
iconError: PropTypes.Requireable<(...args: any[]) => any>;
|
|
70
|
+
buttonPrev: PropTypes.Requireable<(...args: any[]) => any>;
|
|
71
|
+
buttonNext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
|
+
buttonClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
73
|
+
}>>;
|
|
64
74
|
plugins: PropTypes.Validator<((...args: any[]) => any)[]>;
|
|
65
75
|
toolbar: PropTypes.Validator<PropTypes.InferProps<{
|
|
66
76
|
buttons: PropTypes.Validator<(string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray | null | undefined)[]>;
|
|
@@ -76,7 +86,13 @@ export declare const LightboxPropTypes: {
|
|
|
76
86
|
fade: PropTypes.Validator<number>;
|
|
77
87
|
swipe: PropTypes.Validator<number>;
|
|
78
88
|
}>>;
|
|
79
|
-
on: PropTypes.Validator<PropTypes.InferProps<{
|
|
89
|
+
on: PropTypes.Validator<PropTypes.InferProps<{
|
|
90
|
+
view: PropTypes.Requireable<(...args: any[]) => any>;
|
|
91
|
+
entering: PropTypes.Requireable<(...args: any[]) => any>;
|
|
92
|
+
entered: PropTypes.Requireable<(...args: any[]) => any>;
|
|
93
|
+
exiting: PropTypes.Requireable<(...args: any[]) => any>;
|
|
94
|
+
exited: PropTypes.Requireable<(...args: any[]) => any>;
|
|
95
|
+
}>>;
|
|
80
96
|
};
|
|
81
97
|
export declare const LightboxDefaultProps: {
|
|
82
98
|
open: boolean;
|
package/dist/types.js
CHANGED
|
@@ -18,7 +18,17 @@ export const LightboxPropTypes = {
|
|
|
18
18
|
close: PropTypes.func.isRequired,
|
|
19
19
|
index: PropTypes.number.isRequired,
|
|
20
20
|
slides: PropTypes.arrayOf(PropTypes.oneOfType(SlideTypesPropTypes).isRequired).isRequired,
|
|
21
|
-
render: PropTypes.shape({
|
|
21
|
+
render: PropTypes.shape({
|
|
22
|
+
slide: PropTypes.func,
|
|
23
|
+
iconPrev: PropTypes.func,
|
|
24
|
+
iconNext: PropTypes.func,
|
|
25
|
+
iconClose: PropTypes.func,
|
|
26
|
+
iconLoading: PropTypes.func,
|
|
27
|
+
iconError: PropTypes.func,
|
|
28
|
+
buttonPrev: PropTypes.func,
|
|
29
|
+
buttonNext: PropTypes.func,
|
|
30
|
+
buttonClose: PropTypes.func,
|
|
31
|
+
}).isRequired,
|
|
22
32
|
plugins: PropTypes.arrayOf(PropTypes.func.isRequired).isRequired,
|
|
23
33
|
toolbar: PropTypes.shape({
|
|
24
34
|
buttons: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["close"]), PropTypes.node])).isRequired,
|
|
@@ -34,7 +44,13 @@ export const LightboxPropTypes = {
|
|
|
34
44
|
fade: PropTypes.number.isRequired,
|
|
35
45
|
swipe: PropTypes.number.isRequired,
|
|
36
46
|
}).isRequired,
|
|
37
|
-
on: PropTypes.shape({
|
|
47
|
+
on: PropTypes.shape({
|
|
48
|
+
view: PropTypes.func,
|
|
49
|
+
entering: PropTypes.func,
|
|
50
|
+
entered: PropTypes.func,
|
|
51
|
+
exiting: PropTypes.func,
|
|
52
|
+
exited: PropTypes.func,
|
|
53
|
+
}).isRequired,
|
|
38
54
|
};
|
|
39
55
|
export const LightboxDefaultProps = {
|
|
40
56
|
open: false,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yet-another-react-lightbox",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Modern lightbox component
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Modern React lightbox component",
|
|
5
5
|
"author": "Igor Danchenko",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/jest": "^27.5.1",
|
|
83
83
|
"@types/react": "^18.0.9",
|
|
84
84
|
"@types/react-dom": "^18.0.5",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
86
|
-
"@typescript-eslint/parser": "^5.
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
86
|
+
"@typescript-eslint/parser": "^5.27.0",
|
|
87
87
|
"autoprefixer": "^10.4.7",
|
|
88
88
|
"eslint": "^8.16.0",
|
|
89
89
|
"eslint-config-airbnb": "^19.0.4",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"husky": "^8.0.1",
|
|
98
98
|
"jest": "^28.1.0",
|
|
99
99
|
"jest-environment-jsdom": "^28.1.0",
|
|
100
|
-
"lint-staged": "^12.4.
|
|
100
|
+
"lint-staged": "^12.4.3",
|
|
101
101
|
"npm-run-all": "^4.1.5",
|
|
102
102
|
"postcss": "^8.4.14",
|
|
103
103
|
"postcss-cli": "^9.1.0",
|