yet-another-react-lightbox 1.0.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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/Lightbox.d.ts +49 -0
- package/dist/Lightbox.js +29 -0
- package/dist/core/components/IconButton.d.ts +6 -0
- package/dist/core/components/IconButton.js +4 -0
- package/dist/core/components/Icons.d.ts +25 -0
- package/dist/core/components/Icons.js +14 -0
- package/dist/core/components/ImageSlide.d.ts +5 -0
- package/dist/core/components/ImageSlide.js +60 -0
- package/dist/core/components/index.d.ts +3 -0
- package/dist/core/components/index.js +3 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.js +70 -0
- package/dist/core/contexts/Events.d.ts +16 -0
- package/dist/core/contexts/Events.js +31 -0
- package/dist/core/contexts/Timeouts.d.ts +8 -0
- package/dist/core/contexts/Timeouts.js +35 -0
- package/dist/core/contexts/index.d.ts +2 -0
- package/dist/core/contexts/index.js +2 -0
- package/dist/core/hooks/index.d.ts +4 -0
- package/dist/core/hooks/index.js +4 -0
- package/dist/core/hooks/useContainerRect.d.ts +10 -0
- package/dist/core/hooks/useContainerRect.js +33 -0
- package/dist/core/hooks/useEnhancedEffect.d.ts +2 -0
- package/dist/core/hooks/useEnhancedEffect.js +2 -0
- package/dist/core/hooks/useLatest.d.ts +2 -0
- package/dist/core/hooks/useLatest.js +6 -0
- package/dist/core/hooks/useSensors.d.ts +15 -0
- package/dist/core/hooks/useSensors.js +37 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +6 -0
- package/dist/core/modules/Carousel.d.ts +3 -0
- package/dist/core/modules/Carousel.js +34 -0
- package/dist/core/modules/Controller.d.ts +13 -0
- package/dist/core/modules/Controller.js +267 -0
- package/dist/core/modules/Core.d.ts +3 -0
- package/dist/core/modules/Core.js +6 -0
- package/dist/core/modules/Navigation.d.ts +14 -0
- package/dist/core/modules/Navigation.js +25 -0
- package/dist/core/modules/NoScroll.d.ts +3 -0
- package/dist/core/modules/NoScroll.js +22 -0
- package/dist/core/modules/Portal.d.ts +3 -0
- package/dist/core/modules/Portal.js +34 -0
- package/dist/core/modules/Toolbar.d.ts +3 -0
- package/dist/core/modules/Toolbar.js +10 -0
- package/dist/core/modules/index.d.ts +7 -0
- package/dist/core/modules/index.js +7 -0
- package/dist/core/utils.d.ts +8 -0
- package/dist/core/utils.js +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/plugins/Fullscreen.d.ts +30 -0
- package/dist/plugins/Fullscreen.js +108 -0
- package/dist/plugins/Inline.d.ts +10 -0
- package/dist/plugins/Inline.js +17 -0
- package/dist/plugins/Video.d.ts +21 -0
- package/dist/plugins/Video.js +44 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +3 -0
- package/dist/styles.css +237 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.js +61 -0
- package/package.json +105 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createModule } from "../core/index.js";
|
|
3
|
+
export const InlineContainer = ({ inline, children }) => React.createElement("div", { ...inline }, children);
|
|
4
|
+
export const InlineModule = createModule("inline", InlineContainer);
|
|
5
|
+
export const Inline = ({ augment, replace, remove }) => {
|
|
6
|
+
augment(({ toolbar: { buttons, ...restToolbar }, open, close, ...restProps }) => ({
|
|
7
|
+
open: true,
|
|
8
|
+
close: () => { },
|
|
9
|
+
toolbar: {
|
|
10
|
+
buttons: buttons.filter((button) => button !== "close"),
|
|
11
|
+
...restToolbar,
|
|
12
|
+
},
|
|
13
|
+
...restProps,
|
|
14
|
+
}));
|
|
15
|
+
remove("no-scroll");
|
|
16
|
+
replace("portal", InlineModule);
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Plugin } from "../types.js";
|
|
3
|
+
export interface SlideVideo {
|
|
4
|
+
type: "video";
|
|
5
|
+
poster?: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
sources?: {
|
|
9
|
+
src: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
declare module "../types.js" {
|
|
14
|
+
interface SlideTypes {
|
|
15
|
+
SlideVideo: SlideVideo;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare const VideoSlide: ({ slide: { sources, poster, width, height } }: {
|
|
19
|
+
slide: SlideVideo;
|
|
20
|
+
}) => JSX.Element;
|
|
21
|
+
export declare const Video: Plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { SlideTypesPropTypes } from "../types.js";
|
|
4
|
+
import { clsx, cssClass, useContainerRect } from "../core/index.js";
|
|
5
|
+
SlideTypesPropTypes.push(PropTypes.shape({
|
|
6
|
+
type: PropTypes.oneOf(["video"]).isRequired,
|
|
7
|
+
poster: PropTypes.string,
|
|
8
|
+
width: PropTypes.number,
|
|
9
|
+
height: PropTypes.number,
|
|
10
|
+
sources: PropTypes.arrayOf(PropTypes.shape({
|
|
11
|
+
src: PropTypes.string.isRequired,
|
|
12
|
+
type: PropTypes.string.isRequired,
|
|
13
|
+
}).isRequired),
|
|
14
|
+
}));
|
|
15
|
+
export const VideoSlide = ({ slide: { sources, poster, width, height } }) => {
|
|
16
|
+
const { setContainerRef, containerRect } = useContainerRect();
|
|
17
|
+
const scaleWidthAndHeight = () => {
|
|
18
|
+
if (!width || !height || !containerRect)
|
|
19
|
+
return null;
|
|
20
|
+
const widthBound = width / height > containerRect.width / containerRect.height;
|
|
21
|
+
return {
|
|
22
|
+
width: widthBound ? containerRect.width : Math.round((containerRect.height / height) * width),
|
|
23
|
+
height: !widthBound ? containerRect.height : Math.round((containerRect.width / width) * height),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(React.Fragment, null, sources && (React.createElement("div", { ref: setContainerRef, style: {
|
|
27
|
+
width: "100%",
|
|
28
|
+
height: "100%",
|
|
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
|
+
};
|
|
31
|
+
export const Video = ({ augment }) => {
|
|
32
|
+
augment(({ render: { slide: renderSlide, ...restRender }, ...restProps }) => ({
|
|
33
|
+
render: {
|
|
34
|
+
slide: (slide) => {
|
|
35
|
+
if ("type" in slide && slide.type === "video") {
|
|
36
|
+
return React.createElement(VideoSlide, { slide: slide });
|
|
37
|
+
}
|
|
38
|
+
return renderSlide(slide);
|
|
39
|
+
},
|
|
40
|
+
...restRender,
|
|
41
|
+
},
|
|
42
|
+
...restProps,
|
|
43
|
+
}));
|
|
44
|
+
};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
.yarl__portal {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
z-index: 1000;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
opacity: 0;
|
|
7
|
+
transition: opacity var(--yarl__fade_animation_duration, 250ms) ease;
|
|
8
|
+
}
|
|
9
|
+
.yarl__portal_open {
|
|
10
|
+
opacity: 1;
|
|
11
|
+
}
|
|
12
|
+
.yarl__container, .yarl__carousel, .yarl__slide {
|
|
13
|
+
-webkit-user-select: none;
|
|
14
|
+
-moz-user-select: none;
|
|
15
|
+
-ms-user-select: none;
|
|
16
|
+
user-select: none;
|
|
17
|
+
touch-action: none;
|
|
18
|
+
}
|
|
19
|
+
.yarl__container {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
position: relative;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
color: #fff;
|
|
25
|
+
background-color: #000;
|
|
26
|
+
outline: 0;
|
|
27
|
+
}
|
|
28
|
+
.yarl__carousel {
|
|
29
|
+
position: absolute;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
inset: 0;
|
|
32
|
+
}
|
|
33
|
+
.yarl__flex_center {
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
align-content: center;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
.yarl__slide {
|
|
40
|
+
position: absolute;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
inset: 0;
|
|
43
|
+
padding: var(--yarl__carousel_padding, 16px);
|
|
44
|
+
-webkit-transform: translate3d(calc(var(--yarl__slide_offset, 0) * (100% + var(--yarl__carousel_spacing, 30%))), 0, 0);
|
|
45
|
+
transform: translate3d(calc(var(--yarl__slide_offset, 0) * (100% + var(--yarl__carousel_spacing, 30%))), 0, 0);
|
|
46
|
+
transition: -webkit-transform var(--yarl__swipe_animation_duration, 500ms) ease-out;
|
|
47
|
+
transition: transform var(--yarl__swipe_animation_duration, 500ms) ease-out;
|
|
48
|
+
transition: transform var(--yarl__swipe_animation_duration, 500ms) ease-out, -webkit-transform var(--yarl__swipe_animation_duration, 500ms) ease-out;
|
|
49
|
+
}
|
|
50
|
+
.yarl__container_swipe .yarl__slide {
|
|
51
|
+
-webkit-transform: translate3d(calc(var(--yarl__slide_offset, 0) * (100% + var(--yarl__carousel_spacing, 30%))), 0, 0) translate3d(var(--yarl__swipe_offset, 0px), 0, 0);
|
|
52
|
+
transform: translate3d(calc(var(--yarl__slide_offset, 0) * (100% + var(--yarl__carousel_spacing, 30%))), 0, 0) translate3d(var(--yarl__swipe_offset, 0px), 0, 0);
|
|
53
|
+
transition: unset;
|
|
54
|
+
}
|
|
55
|
+
.yarl__slide_image {
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
-o-object-fit: contain;
|
|
59
|
+
object-fit: contain;
|
|
60
|
+
-moz-user-select: none;
|
|
61
|
+
-ms-user-select: none;
|
|
62
|
+
user-select: none;
|
|
63
|
+
-webkit-user-select: none;
|
|
64
|
+
-webkit-touch-callout: none;
|
|
65
|
+
}
|
|
66
|
+
.yarl__slide_image_loading {
|
|
67
|
+
opacity: 0;
|
|
68
|
+
}
|
|
69
|
+
.yarl__slide_placeholder {
|
|
70
|
+
position: absolute;
|
|
71
|
+
top: 50%;
|
|
72
|
+
left: 50%;
|
|
73
|
+
-webkit-transform: translate3d(-50%, -50%, 0);
|
|
74
|
+
transform: translate3d(-50%, -50%, 0);
|
|
75
|
+
line-height: 0;
|
|
76
|
+
}
|
|
77
|
+
.yarl__slide_loading {
|
|
78
|
+
color: rgba(255, 255, 255, 0.8);
|
|
79
|
+
-webkit-animation: yarl__delayed_fadein 1s linear;
|
|
80
|
+
animation: yarl__delayed_fadein 1s linear;
|
|
81
|
+
}
|
|
82
|
+
.yarl__slide_loading line {
|
|
83
|
+
-webkit-animation: yarl__stroke_opacity 1s linear infinite;
|
|
84
|
+
animation: yarl__stroke_opacity 1s linear infinite;
|
|
85
|
+
}
|
|
86
|
+
.yarl__slide_loading line:nth-of-type(1) {
|
|
87
|
+
-webkit-animation-delay: -1.875s;
|
|
88
|
+
animation-delay: -1.875s;
|
|
89
|
+
}
|
|
90
|
+
.yarl__slide_loading line:nth-of-type(2) {
|
|
91
|
+
-webkit-animation-delay: -1.75s;
|
|
92
|
+
animation-delay: -1.75s;
|
|
93
|
+
}
|
|
94
|
+
.yarl__slide_loading line:nth-of-type(3) {
|
|
95
|
+
-webkit-animation-delay: -1.625s;
|
|
96
|
+
animation-delay: -1.625s;
|
|
97
|
+
}
|
|
98
|
+
.yarl__slide_loading line:nth-of-type(4) {
|
|
99
|
+
-webkit-animation-delay: -1.5s;
|
|
100
|
+
animation-delay: -1.5s;
|
|
101
|
+
}
|
|
102
|
+
.yarl__slide_loading line:nth-of-type(5) {
|
|
103
|
+
-webkit-animation-delay: -1.375s;
|
|
104
|
+
animation-delay: -1.375s;
|
|
105
|
+
}
|
|
106
|
+
.yarl__slide_loading line:nth-of-type(6) {
|
|
107
|
+
-webkit-animation-delay: -1.25s;
|
|
108
|
+
animation-delay: -1.25s;
|
|
109
|
+
}
|
|
110
|
+
.yarl__slide_loading line:nth-of-type(7) {
|
|
111
|
+
-webkit-animation-delay: -1.125s;
|
|
112
|
+
animation-delay: -1.125s;
|
|
113
|
+
}
|
|
114
|
+
.yarl__slide_loading line:nth-of-type(8) {
|
|
115
|
+
-webkit-animation-delay: -1s;
|
|
116
|
+
animation-delay: -1s;
|
|
117
|
+
}
|
|
118
|
+
.yarl__slide_error {
|
|
119
|
+
width: 48px;
|
|
120
|
+
height: 48px;
|
|
121
|
+
color: red;
|
|
122
|
+
}
|
|
123
|
+
@media (prefers-reduced-motion) {
|
|
124
|
+
.yarl__portal, .yarl__slide {
|
|
125
|
+
transition: unset;
|
|
126
|
+
}
|
|
127
|
+
.yarl__slide_loading, .yarl__slide_loading line {
|
|
128
|
+
-webkit-animation: unset;
|
|
129
|
+
animation: unset;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
.yarl__toolbar {
|
|
133
|
+
position: absolute;
|
|
134
|
+
inset: 0 0 auto 0;
|
|
135
|
+
display: flex;
|
|
136
|
+
justify-content: flex-end;
|
|
137
|
+
padding: 8px;
|
|
138
|
+
gap: 8px;
|
|
139
|
+
}
|
|
140
|
+
.yarl__icon {
|
|
141
|
+
width: 32px;
|
|
142
|
+
height: 32px;
|
|
143
|
+
}
|
|
144
|
+
.yarl__button {
|
|
145
|
+
-webkit-appearance: none;
|
|
146
|
+
-moz-appearance: none;
|
|
147
|
+
appearance: none;
|
|
148
|
+
background-color: transparent;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
border: 0;
|
|
151
|
+
margin: 0;
|
|
152
|
+
outline: none;
|
|
153
|
+
line-height: 0;
|
|
154
|
+
padding: 8px;
|
|
155
|
+
color: rgba(255, 255, 255, 0.8);
|
|
156
|
+
-webkit-filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8));
|
|
157
|
+
filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8));
|
|
158
|
+
-webkit-tap-highlight-color: transparent;
|
|
159
|
+
}
|
|
160
|
+
.yarl__button:focus {
|
|
161
|
+
color: #fff;
|
|
162
|
+
}
|
|
163
|
+
.yarl__button:focus:not(:focus-visible) {
|
|
164
|
+
color: rgba(255, 255, 255, 0.8);
|
|
165
|
+
}
|
|
166
|
+
.yarl__button:focus-visible {
|
|
167
|
+
color: #fff;
|
|
168
|
+
}
|
|
169
|
+
@media (hover: hover) {
|
|
170
|
+
.yarl__button:hover, .yarl__button:focus:hover, .yarl__button:focus-visible:hover {
|
|
171
|
+
color: #fff;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
.yarl__button:disabled {
|
|
175
|
+
color: rgba(255, 255, 255, 0.4);
|
|
176
|
+
cursor: default;
|
|
177
|
+
}
|
|
178
|
+
.yarl__navigation_prev, .yarl__navigation_next {
|
|
179
|
+
position: absolute;
|
|
180
|
+
top: 50%;
|
|
181
|
+
-webkit-transform: translateY(-50%);
|
|
182
|
+
transform: translateY(-50%);
|
|
183
|
+
padding: 24px 16px;
|
|
184
|
+
}
|
|
185
|
+
.yarl__navigation_prev {
|
|
186
|
+
left: 0;
|
|
187
|
+
}
|
|
188
|
+
.yarl__navigation_next {
|
|
189
|
+
right: 0;
|
|
190
|
+
}
|
|
191
|
+
.yarl__no_scroll {
|
|
192
|
+
height: 100%;
|
|
193
|
+
overflow: hidden;
|
|
194
|
+
}
|
|
195
|
+
.yarl__pad_scrollbar {
|
|
196
|
+
padding-right: var(--yarl__scrollbar_padding, 17px);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@-webkit-keyframes yarl__delayed_fadein {
|
|
200
|
+
0% {
|
|
201
|
+
opacity: 0;
|
|
202
|
+
}
|
|
203
|
+
80% {
|
|
204
|
+
opacity: 0;
|
|
205
|
+
}
|
|
206
|
+
100% {
|
|
207
|
+
opacity: 1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@keyframes yarl__delayed_fadein {
|
|
212
|
+
0% {
|
|
213
|
+
opacity: 0;
|
|
214
|
+
}
|
|
215
|
+
80% {
|
|
216
|
+
opacity: 0;
|
|
217
|
+
}
|
|
218
|
+
100% {
|
|
219
|
+
opacity: 1;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
@-webkit-keyframes yarl__stroke_opacity {
|
|
223
|
+
from {
|
|
224
|
+
stroke-opacity: 1;
|
|
225
|
+
}
|
|
226
|
+
to {
|
|
227
|
+
stroke-opacity: 0.125;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
@keyframes yarl__stroke_opacity {
|
|
231
|
+
from {
|
|
232
|
+
stroke-opacity: 1;
|
|
233
|
+
}
|
|
234
|
+
to {
|
|
235
|
+
stroke-opacity: 0.125;
|
|
236
|
+
}
|
|
237
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
export interface SlideImage {
|
|
4
|
+
src?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
aspectRatio?: number;
|
|
7
|
+
srcSet?: {
|
|
8
|
+
src: string;
|
|
9
|
+
width: number;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export interface SlideTypes {
|
|
13
|
+
SlideImage: SlideImage;
|
|
14
|
+
}
|
|
15
|
+
export declare type Slide = SlideTypes[keyof SlideTypes];
|
|
16
|
+
export interface Carousel {
|
|
17
|
+
finite: boolean;
|
|
18
|
+
preload: number;
|
|
19
|
+
padding: string | number;
|
|
20
|
+
spacing: string | number;
|
|
21
|
+
}
|
|
22
|
+
export interface Animation {
|
|
23
|
+
fade: number;
|
|
24
|
+
swipe: number;
|
|
25
|
+
}
|
|
26
|
+
export interface Render {
|
|
27
|
+
slide: (slide: Slide) => React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export interface LightboxProps {
|
|
30
|
+
open: boolean;
|
|
31
|
+
close: () => void;
|
|
32
|
+
index: number;
|
|
33
|
+
slides: Slide[];
|
|
34
|
+
render: Render;
|
|
35
|
+
labels: Labels;
|
|
36
|
+
plugins: Plugin[];
|
|
37
|
+
toolbar: Toolbar;
|
|
38
|
+
carousel: Carousel;
|
|
39
|
+
animation: Animation;
|
|
40
|
+
}
|
|
41
|
+
export declare const SlideTypesPropTypes: PropTypes.Validator<any>[];
|
|
42
|
+
export declare const LightboxPropTypes: {
|
|
43
|
+
open: PropTypes.Validator<boolean>;
|
|
44
|
+
close: PropTypes.Validator<(...args: any[]) => any>;
|
|
45
|
+
index: PropTypes.Validator<number>;
|
|
46
|
+
slides: PropTypes.Validator<any[]>;
|
|
47
|
+
render: PropTypes.Validator<PropTypes.InferProps<{
|
|
48
|
+
slide: PropTypes.Validator<(...args: any[]) => any>;
|
|
49
|
+
}>>;
|
|
50
|
+
plugins: PropTypes.Validator<((...args: any[]) => any)[]>;
|
|
51
|
+
toolbar: PropTypes.Validator<PropTypes.InferProps<{
|
|
52
|
+
buttons: PropTypes.Validator<(string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray | null | undefined)[]>;
|
|
53
|
+
}>>;
|
|
54
|
+
labels: PropTypes.Validator<PropTypes.InferProps<{}>>;
|
|
55
|
+
carousel: PropTypes.Validator<PropTypes.InferProps<{
|
|
56
|
+
finite: PropTypes.Validator<boolean>;
|
|
57
|
+
preload: PropTypes.Validator<number>;
|
|
58
|
+
padding: PropTypes.Validator<string | number>;
|
|
59
|
+
spacing: PropTypes.Validator<string | number>;
|
|
60
|
+
}>>;
|
|
61
|
+
animation: PropTypes.Validator<PropTypes.InferProps<{
|
|
62
|
+
fade: PropTypes.Validator<number>;
|
|
63
|
+
swipe: PropTypes.Validator<number>;
|
|
64
|
+
}>>;
|
|
65
|
+
};
|
|
66
|
+
export declare const LightboxDefaultProps: {
|
|
67
|
+
open: boolean;
|
|
68
|
+
close: () => void;
|
|
69
|
+
index: number;
|
|
70
|
+
slides: Slide[];
|
|
71
|
+
render: Render;
|
|
72
|
+
plugins: Plugin[];
|
|
73
|
+
toolbar: Toolbar;
|
|
74
|
+
labels: {};
|
|
75
|
+
animation: Animation;
|
|
76
|
+
carousel: Carousel;
|
|
77
|
+
};
|
|
78
|
+
export declare type Labels = {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
};
|
|
81
|
+
export interface Toolbar {
|
|
82
|
+
buttons: ("close" | React.ReactNode)[];
|
|
83
|
+
}
|
|
84
|
+
export declare type ComponentProps = Omit<LightboxProps, "plugins">;
|
|
85
|
+
export declare type Component = React.ComponentType<React.PropsWithChildren<ComponentProps>>;
|
|
86
|
+
export declare type Module = {
|
|
87
|
+
name: string;
|
|
88
|
+
component: Component;
|
|
89
|
+
};
|
|
90
|
+
export declare type Node = {
|
|
91
|
+
module: Module;
|
|
92
|
+
children?: Node[];
|
|
93
|
+
};
|
|
94
|
+
export declare type Augmentation = (props: LightboxProps) => LightboxProps;
|
|
95
|
+
export declare type Plugin = ({ addParent, addChild, addSibling, replace, remove, }: {
|
|
96
|
+
addParent: (target: string, module: Module) => void;
|
|
97
|
+
addChild: (target: string, module: Module, precede?: boolean) => void;
|
|
98
|
+
addSibling: (target: string, module: Module, precede?: boolean) => void;
|
|
99
|
+
replace: (target: string, module: Module) => void;
|
|
100
|
+
remove: (target: string) => void;
|
|
101
|
+
augment: (augmentation: Augmentation) => void;
|
|
102
|
+
}) => void;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
export const SlideTypesPropTypes = [
|
|
3
|
+
PropTypes.shape({
|
|
4
|
+
src: PropTypes.string.isRequired,
|
|
5
|
+
title: PropTypes.string,
|
|
6
|
+
aspectRatio: PropTypes.number,
|
|
7
|
+
srcSet: PropTypes.oneOfType([
|
|
8
|
+
PropTypes.string.isRequired,
|
|
9
|
+
PropTypes.arrayOf(PropTypes.shape({
|
|
10
|
+
src: PropTypes.string.isRequired,
|
|
11
|
+
width: PropTypes.number.isRequired,
|
|
12
|
+
}).isRequired).isRequired,
|
|
13
|
+
]),
|
|
14
|
+
}),
|
|
15
|
+
];
|
|
16
|
+
export const LightboxPropTypes = {
|
|
17
|
+
open: PropTypes.bool.isRequired,
|
|
18
|
+
close: PropTypes.func.isRequired,
|
|
19
|
+
index: PropTypes.number.isRequired,
|
|
20
|
+
slides: PropTypes.arrayOf(PropTypes.oneOfType(SlideTypesPropTypes).isRequired).isRequired,
|
|
21
|
+
render: PropTypes.shape({
|
|
22
|
+
slide: PropTypes.func.isRequired,
|
|
23
|
+
}).isRequired,
|
|
24
|
+
plugins: PropTypes.arrayOf(PropTypes.func.isRequired).isRequired,
|
|
25
|
+
toolbar: PropTypes.shape({
|
|
26
|
+
buttons: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["close"]), PropTypes.node])).isRequired,
|
|
27
|
+
}).isRequired,
|
|
28
|
+
labels: PropTypes.shape({}).isRequired,
|
|
29
|
+
carousel: PropTypes.shape({
|
|
30
|
+
finite: PropTypes.bool.isRequired,
|
|
31
|
+
preload: PropTypes.number.isRequired,
|
|
32
|
+
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
33
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
34
|
+
}).isRequired,
|
|
35
|
+
animation: PropTypes.shape({
|
|
36
|
+
fade: PropTypes.number.isRequired,
|
|
37
|
+
swipe: PropTypes.number.isRequired,
|
|
38
|
+
}).isRequired,
|
|
39
|
+
};
|
|
40
|
+
export const LightboxDefaultProps = {
|
|
41
|
+
open: false,
|
|
42
|
+
close: () => { },
|
|
43
|
+
index: 0,
|
|
44
|
+
slides: [],
|
|
45
|
+
render: {
|
|
46
|
+
slide: () => null,
|
|
47
|
+
},
|
|
48
|
+
plugins: [],
|
|
49
|
+
toolbar: { buttons: ["close"] },
|
|
50
|
+
labels: {},
|
|
51
|
+
animation: {
|
|
52
|
+
fade: 330,
|
|
53
|
+
swipe: 500,
|
|
54
|
+
},
|
|
55
|
+
carousel: {
|
|
56
|
+
finite: false,
|
|
57
|
+
preload: 2,
|
|
58
|
+
padding: "16px",
|
|
59
|
+
spacing: "30%",
|
|
60
|
+
},
|
|
61
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yet-another-react-lightbox",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Modern lightbox component for React",
|
|
5
|
+
"author": "Igor Danchenko",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./styles.css": "./dist/styles.css",
|
|
13
|
+
"./core": "./dist/core/index.js",
|
|
14
|
+
"./plugins": "./dist/plugins/index.js"
|
|
15
|
+
},
|
|
16
|
+
"typesVersions": {
|
|
17
|
+
"*": {
|
|
18
|
+
"*": [
|
|
19
|
+
"dist/index.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"core": [
|
|
22
|
+
"dist/core/index.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"plugins": [
|
|
25
|
+
"dist/plugins/index.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"homepage": "https://github.com/igordanchenko/yet-another-react-lightbox#readme",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/igordanchenko/yet-another-react-lightbox.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/igordanchenko/yet-another-react-lightbox/issues"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=14"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prepare": "husky install",
|
|
46
|
+
"clean": "rimraf dist",
|
|
47
|
+
"build": "npm-run-all clean build:scss build:css build:js",
|
|
48
|
+
"build:js": "tsc -p tsconfig.build.json",
|
|
49
|
+
"build:css": "postcss src/styles.css -u autoprefixer --no-map -d dist",
|
|
50
|
+
"build:scss": "sass src/styles.scss src/styles.css --no-source-map ",
|
|
51
|
+
"start": "npm-run-all clean --parallel \"build:* -- -w\"",
|
|
52
|
+
"lint": "eslint .",
|
|
53
|
+
"test": "jest"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"prop-types": "^15.8.1"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"react": ">=16.14.0",
|
|
60
|
+
"react-dom": ">=16.14.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@commitlint/cli": "^17.0.0",
|
|
64
|
+
"@commitlint/config-conventional": "^17.0.0",
|
|
65
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
66
|
+
"@semantic-release/github": "^8.0.4",
|
|
67
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
68
|
+
"@testing-library/react": "^13.2.0",
|
|
69
|
+
"@testing-library/user-event": "^14.2.0",
|
|
70
|
+
"@types/jest": "^27.5.1",
|
|
71
|
+
"@types/react": "^18.0.9",
|
|
72
|
+
"@types/react-dom": "^18.0.4",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
|
74
|
+
"@typescript-eslint/parser": "^5.25.0",
|
|
75
|
+
"autoprefixer": "^10.4.7",
|
|
76
|
+
"eslint": "^8.15.0",
|
|
77
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
78
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
79
|
+
"eslint-config-prettier": "^8.5.0",
|
|
80
|
+
"eslint-plugin-import": "^2.26.0",
|
|
81
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
82
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
83
|
+
"eslint-plugin-react": "^7.29.4",
|
|
84
|
+
"eslint-plugin-react-hooks": "^4.5.0",
|
|
85
|
+
"husky": "^8.0.1",
|
|
86
|
+
"jest": "^28.1.0",
|
|
87
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
88
|
+
"lint-staged": "^12.4.1",
|
|
89
|
+
"npm-run-all": "^4.1.5",
|
|
90
|
+
"postcss": "^8.4.14",
|
|
91
|
+
"postcss-cli": "^9.1.0",
|
|
92
|
+
"prettier": "^2.6.2",
|
|
93
|
+
"react": "^18.1.0",
|
|
94
|
+
"react-dom": "^18.1.0",
|
|
95
|
+
"rimraf": "^3.0.2",
|
|
96
|
+
"sass": "^1.51.0",
|
|
97
|
+
"ts-jest": "^28.0.2",
|
|
98
|
+
"typescript": "^4.6.4"
|
|
99
|
+
},
|
|
100
|
+
"keywords": [
|
|
101
|
+
"react",
|
|
102
|
+
"lightbox",
|
|
103
|
+
"react lightbox"
|
|
104
|
+
]
|
|
105
|
+
}
|