Socket
Socket
Sign inDemoInstall

yet-another-react-lightbox

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yet-another-react-lightbox - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

dist/core/components/ImageSlide.js

@@ -7,2 +7,3 @@ import * as React from "react";

export const ImageSlide = ({ slide: image }) => {
var _a, _b, _c;
const [state, setState] = React.useState("loading");

@@ -27,3 +28,3 @@ const latestState = useLatest(state);

imageRef.current = img;
if (img?.complete) {
if (img === null || img === void 0 ? void 0 : img.complete) {
handleLoading(img);

@@ -53,5 +54,5 @@ }

: {
style: (imageRef.current?.naturalWidth ?? 0) > 0
style: ((_b = (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) !== null && _b !== void 0 ? _b : 0) > 0
? {
maxWidth: `${imageRef.current?.naturalWidth}px`,
maxWidth: `${(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalWidth}px`,
}

@@ -58,0 +59,0 @@ : undefined,

@@ -15,3 +15,3 @@ export const createModule = (name, component) => ({

return [
createNode(node.module, node.children.flatMap((n) => traverseNode(n, target, apply) ?? [])),
createNode(node.module, node.children.flatMap((n) => { var _a; return (_a = traverseNode(n, target, apply)) !== null && _a !== void 0 ? _a : []; })),
];

@@ -21,3 +21,3 @@ }

};
const traverse = (nodes, target, apply) => nodes.flatMap((node) => traverseNode(node, target, apply) ?? []);
const traverse = (nodes, target, apply) => nodes.flatMap((node) => { var _a; return (_a = traverseNode(node, target, apply)) !== null && _a !== void 0 ? _a : []; });
export const withPlugins = (root, plugins) => {

@@ -34,9 +34,12 @@ let config = root;

const addChild = (target, module, precede) => {
config = traverse(config, target, (node) => [
createNode(node.module, [
...(precede ? [createNode(module)] : []),
...(node.children ?? []),
...(!precede ? [createNode(module)] : []),
]),
]);
config = traverse(config, target, (node) => {
var _a;
return [
createNode(node.module, [
...(precede ? [createNode(module)] : []),
...((_a = node.children) !== null && _a !== void 0 ? _a : []),
...(!precede ? [createNode(module)] : []),
]),
];
});
};

@@ -59,3 +62,3 @@ const addSibling = (target, module, precede) => {

};
plugins?.forEach((plugin) => {
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => {
plugin({

@@ -62,0 +65,0 @@ addParent,

@@ -20,3 +20,4 @@ import * as React from "react";

const publish = (topic, event) => {
subscriptions.current[topic]?.forEach((callback) => callback(topic, event));
var _a;
(_a = subscriptions.current[topic]) === null || _a === void 0 ? void 0 : _a.forEach((callback) => callback(topic, event));
};

@@ -23,0 +24,0 @@ React.useEffect(() => () => {

@@ -13,4 +13,4 @@ import * as React from "react";

const updateContainerRect = () => {
const width = node?.clientWidth;
const height = node?.clientHeight;
const width = node === null || node === void 0 ? void 0 : node.clientWidth;
const height = node === null || node === void 0 ? void 0 : node.clientHeight;
setContainerRect(width !== undefined && height !== undefined

@@ -17,0 +17,0 @@ ? {

@@ -6,3 +6,4 @@ import * as React from "react";

const notifySubscribers = (type, event) => {
subscribers[type]?.forEach((listener) => listener(event));
var _a;
(_a = subscribers[type]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
};

@@ -25,6 +26,7 @@ return {

subscribeSensors: (type, callback) => {
var _a;
if (!subscribers[type]) {
subscribers[type] = [];
}
subscribers[type]?.push(callback);
(_a = subscribers[type]) === null || _a === void 0 ? void 0 : _a.push(callback);
return () => {

@@ -31,0 +33,0 @@ const listeners = subscribers[type];

@@ -12,3 +12,3 @@ import * as React from "react";

const items = [];
if (slides?.length > 0) {
if ((slides === null || slides === void 0 ? void 0 : slides.length) > 0) {
for (let i = currentIndex - preload; i < currentIndex; i += 1) {

@@ -15,0 +15,0 @@ if (!finite || i >= 0) {

@@ -44,3 +44,4 @@ import * as React from "react";

React.useEffect(() => {
containerRef.current?.focus();
var _a;
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
}, [containerRef]);

@@ -51,8 +52,9 @@ React.useEffect(() => subscribe("close", () => {

const updateSwipeOffset = React.useCallback(() => {
var _a, _b;
const offsetVar = cssVar("swipe_offset");
if (refs.current.swipeOffset !== 0) {
containerRef.current?.style.setProperty(offsetVar, `${Math.round(refs.current.swipeOffset)}px`);
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.style.setProperty(offsetVar, `${Math.round(refs.current.swipeOffset)}px`);
}
else {
containerRef.current?.style.removeProperty(offsetVar);
(_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.style.removeProperty(offsetVar);
}

@@ -82,2 +84,3 @@ }, [containerRef]);

const swipe = React.useCallback((direction) => {
var _a;
const { current } = refs;

@@ -91,3 +94,3 @@ const slidesCount = current.props.slides.length;

if (!direction) {
const containerWidth = current.containerRect?.width;
const containerWidth = (_a = current.containerRect) === null || _a === void 0 ? void 0 : _a.width;
const elapsedTime = current.swipeStartTime ? Date.now() - current.swipeStartTime : 0;

@@ -201,2 +204,3 @@ const expectedTime = containerWidth

const onWheel = React.useCallback((event) => {
var _a;
if (event.ctrlKey) {

@@ -231,3 +235,3 @@ return;

else if (current.swipeState === "swipe") {
const containerWidth = current.containerRect?.width;
const containerWidth = (_a = current.containerRect) === null || _a === void 0 ? void 0 : _a.width;
if (containerWidth) {

@@ -234,0 +238,0 @@ current.swipeOffset -= event.deltaX;

@@ -8,4 +8,4 @@ import * as React from "react";

const { publish } = useEvents();
return (React.createElement("div", { className: cssClass("toolbar") }, buttons?.map((button) => button === "close" ? (React.createElement(IconButton, { key: "close", label: label(labels, "Close"), icon: CloseIcon, onClick: () => publish("close") })) : (button))));
return (React.createElement("div", { className: cssClass("toolbar") }, buttons === null || buttons === void 0 ? void 0 : buttons.map((button) => button === "close" ? (React.createElement(IconButton, { key: "close", label: label(labels, "Close"), icon: CloseIcon, onClick: () => publish("close") })) : (button))));
};
export const ToolbarModule = createModule("toolbar", Toolbar);
import * as React from "react";
import { LightboxDefaultProps, LightboxPropTypes } from "./types.js";
import { CarouselModule, ControllerModule, CoreModule, createNode, NavigationModule, NoScrollModule, PortalModule, ToolbarModule, withPlugins, } from "./core/index.js";
const renderNode = (node, props) => React.createElement(node.module.component, { key: node.module.name, ...props }, node.children?.map((child) => renderNode(child, props)));
const renderNode = (node, props) => {
var _a;
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)));
};
const LightboxComponent = (props) => {

@@ -6,0 +9,0 @@ const { plugins } = props;

@@ -9,12 +9,9 @@ import * as React from "react";

const isFullscreenEnabled = () => {
return (document.fullscreenEnabled ??
document.webkitFullscreenEnabled ??
document.mozFullScreenEnabled ??
document.msFullscreenEnabled ??
false);
var _a, _b, _c, _d;
return ((_d = (_c = (_b = (_a = document.fullscreenEnabled) !== null && _a !== void 0 ? _a : document.webkitFullscreenEnabled) !== null && _b !== void 0 ? _b : document.mozFullScreenEnabled) !== null && _c !== void 0 ? _c : document.msFullscreenEnabled) !== null && _d !== void 0 ? _d : false);
};
const getFullscreenElement = React.useCallback(() => document.fullscreenElement ??
document.webkitFullscreenElement ??
document.mozFullScreenElement ??
document.msFullscreenElement, []);
const getFullscreenElement = React.useCallback(() => {
var _a, _b, _c;
return (_c = (_b = (_a = document.fullscreenElement) !== null && _a !== void 0 ? _a : document.webkitFullscreenElement) !== null && _b !== void 0 ? _b : document.mozFullScreenElement) !== null && _c !== void 0 ? _c : document.msFullscreenElement;
}, []);
const requestFullscreen = React.useCallback(() => {

@@ -21,0 +18,0 @@ const container = containerRef.current;

{
"name": "yet-another-react-lightbox",
"version": "1.0.0",
"version": "1.0.1",
"description": "Modern lightbox component for React",

@@ -5,0 +5,0 @@ "author": "Igor Danchenko",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc