yet-another-react-lightbox 1.7.0 → 1.7.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/dist/Lightbox.js +13 -8
- package/dist/core/modules/Carousel.js +3 -2
- package/dist/core/modules/Controller.js +12 -5
- package/dist/plugins/Inline.js +2 -2
- package/dist/styles.css +2 -2
- package/dist/types.d.ts +5 -3
- package/dist/types.js +1 -0
- package/package.json +4 -4
package/dist/Lightbox.js
CHANGED
|
@@ -5,8 +5,9 @@ const renderNode = (node, props) => {
|
|
|
5
5
|
var _a;
|
|
6
6
|
return React.createElement(node.module.component, { key: node.module.name, ...props }, (_a = node.children) === null || _a === void 0 ? void 0 : _a.map((child) => renderNode(child, props)));
|
|
7
7
|
};
|
|
8
|
-
const
|
|
9
|
-
const { plugins } = props;
|
|
8
|
+
export const Lightbox = (props) => {
|
|
9
|
+
const { carousel, animation, render, toolbar, controller, on, plugins, ...restProps } = props;
|
|
10
|
+
const { carousel: defaultCarousel, animation: defaultAnimation, render: defaultRender, toolbar: defaultToolbar, controller: defaultController, on: defaultOn, ...restDefaultProps } = LightboxDefaultProps;
|
|
10
11
|
const { config, augmentation } = withPlugins([
|
|
11
12
|
createNode(PortalModule, [
|
|
12
13
|
createNode(NoScrollModule, [
|
|
@@ -18,13 +19,17 @@ const LightboxComponent = (props) => {
|
|
|
18
19
|
]),
|
|
19
20
|
]),
|
|
20
21
|
], plugins);
|
|
21
|
-
const augmentedProps = augmentation(
|
|
22
|
+
const augmentedProps = augmentation({
|
|
23
|
+
carousel: { ...defaultCarousel, ...carousel },
|
|
24
|
+
animation: { ...defaultAnimation, ...animation },
|
|
25
|
+
render: { ...defaultRender, ...render },
|
|
26
|
+
toolbar: { ...defaultToolbar, ...toolbar },
|
|
27
|
+
controller: { ...defaultController, ...controller },
|
|
28
|
+
on: { ...defaultOn, ...on },
|
|
29
|
+
...restDefaultProps,
|
|
30
|
+
...restProps,
|
|
31
|
+
});
|
|
22
32
|
if (!augmentedProps.open)
|
|
23
33
|
return null;
|
|
24
34
|
return React.createElement(React.Fragment, null, renderNode(createNode(CoreModule, config), augmentedProps));
|
|
25
35
|
};
|
|
26
|
-
export const Lightbox = (props) => {
|
|
27
|
-
const { carousel, animation, render, toolbar, controller, on, ...restProps } = props;
|
|
28
|
-
const { carousel: defaultCarousel, animation: defaultAnimation, render: defaultRender, toolbar: defaultToolbar, controller: defaultController, on: defaultOn, ...restDefaultProps } = LightboxDefaultProps;
|
|
29
|
-
return (React.createElement(LightboxComponent, { carousel: { ...defaultCarousel, ...carousel }, animation: { ...defaultAnimation, ...animation }, render: { ...defaultRender, ...render }, toolbar: { ...defaultToolbar, ...toolbar }, controller: { ...defaultController, ...controller }, on: { ...defaultOn, ...on }, ...restDefaultProps, ...restProps }));
|
|
30
|
-
};
|
|
@@ -38,12 +38,13 @@ export const Carousel = ({ slides, carousel: { finite, preload, padding, spacing
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
const sanitize = (value) => value === 0 || value.trim() === "" || value.trim() === "0" ? "0px" : value;
|
|
41
42
|
return (React.createElement("div", { className: cssClass("carousel"), style: {
|
|
42
43
|
...(padding !== LightboxDefaultProps.carousel.padding
|
|
43
|
-
? { [cssVar("carousel_padding")]: padding }
|
|
44
|
+
? { [cssVar("carousel_padding")]: sanitize(padding) }
|
|
44
45
|
: null),
|
|
45
46
|
...(spacing !== LightboxDefaultProps.carousel.spacing
|
|
46
|
-
? { [cssVar("carousel_spacing")]: spacing
|
|
47
|
+
? { [cssVar("carousel_spacing")]: sanitize(spacing) }
|
|
47
48
|
: null),
|
|
48
49
|
} }, items));
|
|
49
50
|
};
|
|
@@ -281,11 +281,18 @@ export const Controller = ({ children, ...props }) => {
|
|
|
281
281
|
isRTL: state.isRTL,
|
|
282
282
|
subscribeSensors,
|
|
283
283
|
}), [latestProps, containerRef, state.currentIndex, state.globalIndex, state.isRTL, subscribeSensors]);
|
|
284
|
-
return (React.createElement("div", { ref: setContainerRef, className: clsx(cssClass("container"), refs.current.swipeState === "swipe" && cssClass("container_swipe")), style:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
284
|
+
return (React.createElement("div", { ref: setContainerRef, className: clsx(cssClass("container"), refs.current.swipeState === "swipe" && cssClass("container_swipe")), style: {
|
|
285
|
+
...(refs.current.swipeAnimationDuration !== LightboxDefaultProps.animation.swipe
|
|
286
|
+
? {
|
|
287
|
+
[cssVar("swipe_animation_duration")]: `${Math.round(refs.current.swipeAnimationDuration)}ms`,
|
|
288
|
+
}
|
|
289
|
+
: null),
|
|
290
|
+
...(props.controller.touchAction !== "none"
|
|
291
|
+
? {
|
|
292
|
+
[cssVar("controller_touch_action")]: props.controller.touchAction,
|
|
293
|
+
}
|
|
294
|
+
: null),
|
|
295
|
+
}, role: "presentation", "aria-live": "polite", tabIndex: -1, ...registerSensors },
|
|
289
296
|
React.createElement(ControllerContext.Provider, { value: context }, children)));
|
|
290
297
|
};
|
|
291
298
|
export const ControllerModule = createModule("controller", Controller);
|
package/dist/plugins/Inline.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createModule } from "../core/index.js";
|
|
|
3
3
|
export const InlineContainer = ({ inline, children }) => React.createElement("div", { ...inline }, children);
|
|
4
4
|
export const InlineModule = createModule("inline", InlineContainer);
|
|
5
5
|
export const Inline = ({ augment, replace, remove }) => {
|
|
6
|
-
augment(({ toolbar: { buttons, ...restToolbar }, open, close, controller: { focus, ...restController }, ...restProps }) => ({
|
|
6
|
+
augment(({ toolbar: { buttons, ...restToolbar }, open, close, controller: { focus, touchAction, ...restController }, ...restProps }) => ({
|
|
7
7
|
open: true,
|
|
8
8
|
close: () => { },
|
|
9
9
|
toolbar: {
|
|
@@ -11,7 +11,7 @@ export const Inline = ({ augment, replace, remove }) => {
|
|
|
11
11
|
...restToolbar,
|
|
12
12
|
},
|
|
13
13
|
inline: { style: { width: "100%", height: "100%" } },
|
|
14
|
-
controller: { focus: false, ...restController },
|
|
14
|
+
controller: { focus: false, touchAction: "pan-y", ...restController },
|
|
15
15
|
...restProps,
|
|
16
16
|
}));
|
|
17
17
|
remove("no-scroll");
|
package/dist/styles.css
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
.yarl__portal_open {
|
|
10
10
|
opacity: 1;
|
|
11
11
|
}
|
|
12
|
-
.yarl__container
|
|
12
|
+
.yarl__container {
|
|
13
13
|
-webkit-user-select: none;
|
|
14
14
|
-moz-user-select: none;
|
|
15
15
|
-ms-user-select: none;
|
|
16
16
|
user-select: none;
|
|
17
|
-
touch-action:
|
|
17
|
+
touch-action: var(--yarl__controller_touch_action, none);
|
|
18
18
|
}
|
|
19
19
|
.yarl__container {
|
|
20
20
|
width: 100%;
|
package/dist/types.d.ts
CHANGED
|
@@ -33,10 +33,10 @@ export interface CarouselSettings {
|
|
|
33
33
|
finite: boolean;
|
|
34
34
|
/** the lightbox preloads (2 * preload + 1) slides */
|
|
35
35
|
preload: number;
|
|
36
|
-
/** padding around each slide */
|
|
37
|
-
padding: string |
|
|
36
|
+
/** padding around each slide (e.g., "16px", "10px 20px" or 0) */
|
|
37
|
+
padding: string | 0;
|
|
38
38
|
/** spacing between slides (e.g., "100px", "50%" or 0) */
|
|
39
|
-
spacing: string |
|
|
39
|
+
spacing: string | 0;
|
|
40
40
|
/** `object-fit` setting for image slides */
|
|
41
41
|
imageFit: ImageFit;
|
|
42
42
|
}
|
|
@@ -51,6 +51,8 @@ export interface AnimationSettings {
|
|
|
51
51
|
export interface ControllerSettings {
|
|
52
52
|
/** if true, the lightbox captures focus when it opens */
|
|
53
53
|
focus: boolean;
|
|
54
|
+
/** controller `touch-action` */
|
|
55
|
+
touchAction: "none" | "pan-y";
|
|
54
56
|
}
|
|
55
57
|
/** Custom render functions. */
|
|
56
58
|
export interface Render {
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yet-another-react-lightbox",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Modern React lightbox component",
|
|
5
5
|
"author": "Igor Danchenko",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@testing-library/react": "^13.3.0",
|
|
88
88
|
"@testing-library/user-event": "^14.2.0",
|
|
89
89
|
"@types/jest": "^28.1.1",
|
|
90
|
-
"@types/react": "^18.0.
|
|
90
|
+
"@types/react": "^18.0.13",
|
|
91
91
|
"@types/react-dom": "^18.0.5",
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
93
93
|
"@typescript-eslint/parser": "^5.28.0",
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
"husky": "^8.0.1",
|
|
105
105
|
"jest": "^28.1.1",
|
|
106
106
|
"jest-environment-jsdom": "^28.1.1",
|
|
107
|
-
"lint-staged": "^13.0.
|
|
107
|
+
"lint-staged": "^13.0.2",
|
|
108
108
|
"npm-run-all": "^4.1.5",
|
|
109
109
|
"postcss": "^8.4.14",
|
|
110
110
|
"postcss-cli": "^9.1.0",
|
|
111
|
-
"prettier": "^2.7.
|
|
111
|
+
"prettier": "^2.7.1",
|
|
112
112
|
"react": "^18.2.0",
|
|
113
113
|
"react-dom": "^18.2.0",
|
|
114
114
|
"rimraf": "^3.0.2",
|