Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-image

Package Overview
Dependencies
Maintainers
5
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-image - npm Package Compare versions

Comparing version 7.7.0 to 7.7.1

2

es/hooks/usePreviewItems.d.ts

@@ -7,2 +7,2 @@ import type { GroupConsumerProps } from '../PreviewGroup';

*/
export default function usePreviewItems(items?: GroupConsumerProps['items']): [items: Items, registerImage: RegisterImage];
export default function usePreviewItems(items?: GroupConsumerProps['items']): [items: Items, registerImage: RegisterImage, fromItems: boolean];

@@ -31,2 +31,3 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

var mergedItems = React.useMemo(function () {
// use `items` first
if (items) {

@@ -52,2 +53,4 @@ return items.map(function (item) {

}
// use registered images secondly
return Object.keys(images).reduce(function (total, id) {

@@ -66,3 +69,3 @@ var _images$id = images[id],

}, [items, images]);
return [mergedItems, registerImage];
return [mergedItems, registerImage, !!items];
}

@@ -117,3 +117,3 @@ import _extends from "@babel/runtime/helpers/esm/extends";

if (groupContext) {
groupContext.onPreview(imageId, left, top);
groupContext.onPreview(imageId, src, left, top);
} else {

@@ -120,0 +120,0 @@ setMousePosition({

@@ -14,2 +14,2 @@ /// <reference types="react" />

export type RegisterImage = (id: string, data: PreviewImageElementProps) => VoidFunction;
export type OnGroupPreview = (id: string, mouseX: number, mouseY: number) => void;
export type OnGroupPreview = (id: string, imageSrc: string, mouseX: number, mouseY: number) => void;

@@ -91,2 +91,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

var toolsNode = tools.map(function (_ref) {
var _classnames;
var icon = _ref.icon,

@@ -97,3 +98,3 @@ onClick = _ref.onClick,

return /*#__PURE__*/React.createElement("div", {
className: classnames(toolClassName, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-operations-operation-").concat(type), true), "".concat(prefixCls, "-operations-operation-disabled"), !!disabled)),
className: classnames(toolClassName, (_classnames = {}, _defineProperty(_classnames, "".concat(prefixCls, "-operations-operation-").concat(type), true), _defineProperty(_classnames, "".concat(prefixCls, "-operations-operation-disabled"), !!disabled), _classnames)),
onClick: onClick,

@@ -100,0 +101,0 @@ key: type

@@ -41,5 +41,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";

var _usePreviewItems = usePreviewItems(items),
_usePreviewItems2 = _slicedToArray(_usePreviewItems, 2),
_usePreviewItems2 = _slicedToArray(_usePreviewItems, 3),
mergedItems = _usePreviewItems2[0],
register = _usePreviewItems2[1];
register = _usePreviewItems2[1],
fromItems = _usePreviewItems2[2];

@@ -79,6 +80,9 @@ // ========================= Preview ==========================

setMousePosition = _useState4[1];
var onPreviewFromImage = React.useCallback(function (id, mouseX, mouseY) {
var index = mergedItems.findIndex(function (item) {
var onPreviewFromImage = React.useCallback(function (id, imageSrc, mouseX, mouseY) {
var index = fromItems ? mergedItems.findIndex(function (item) {
return item.data.src === imageSrc;
}) : mergedItems.findIndex(function (item) {
return item.id === id;
});
setCurrent(index < 0 ? 0 : index);
setShowPreview(true);

@@ -89,5 +93,4 @@ setMousePosition({

});
setCurrent(index < 0 ? 0 : index);
setKeepOpenIndex(true);
}, [mergedItems]);
}, [mergedItems, fromItems]);

@@ -94,0 +97,0 @@ // Reset current when reopen

@@ -7,2 +7,2 @@ import type { GroupConsumerProps } from '../PreviewGroup';

*/
export default function usePreviewItems(items?: GroupConsumerProps['items']): [items: Items, registerImage: RegisterImage];
export default function usePreviewItems(items?: GroupConsumerProps['items']): [items: Items, registerImage: RegisterImage, fromItems: boolean];

@@ -41,2 +41,3 @@ "use strict";

var mergedItems = React.useMemo(function () {
// use `items` first
if (items) {

@@ -62,2 +63,4 @@ return items.map(function (item) {

}
// use registered images secondly
return Object.keys(images).reduce(function (total, id) {

@@ -76,3 +79,3 @@ var _images$id = images[id],

}, [items, images]);
return [mergedItems, registerImage];
return [mergedItems, registerImage, !!items];
}

@@ -127,3 +127,3 @@ "use strict";

if (groupContext) {
groupContext.onPreview(imageId, left, top);
groupContext.onPreview(imageId, src, left, top);
} else {

@@ -130,0 +130,0 @@ setMousePosition({

@@ -14,2 +14,2 @@ /// <reference types="react" />

export type RegisterImage = (id: string, data: PreviewImageElementProps) => VoidFunction;
export type OnGroupPreview = (id: string, mouseX: number, mouseY: number) => void;
export type OnGroupPreview = (id: string, imageSrc: string, mouseX: number, mouseY: number) => void;

@@ -101,2 +101,3 @@ "use strict";

var toolsNode = tools.map(function (_ref) {
var _classnames;
var icon = _ref.icon,

@@ -107,3 +108,3 @@ onClick = _ref.onClick,

return /*#__PURE__*/React.createElement("div", {
className: (0, _classnames4.default)(toolClassName, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(prefixCls, "-operations-operation-").concat(type), true), "".concat(prefixCls, "-operations-operation-disabled"), !!disabled)),
className: (0, _classnames4.default)(toolClassName, (_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(prefixCls, "-operations-operation-").concat(type), true), (0, _defineProperty2.default)(_classnames, "".concat(prefixCls, "-operations-operation-disabled"), !!disabled), _classnames)),
onClick: onClick,

@@ -110,0 +111,0 @@ key: type

@@ -51,5 +51,6 @@ "use strict";

var _usePreviewItems = (0, _usePreviewItems3.default)(items),
_usePreviewItems2 = (0, _slicedToArray2.default)(_usePreviewItems, 2),
_usePreviewItems2 = (0, _slicedToArray2.default)(_usePreviewItems, 3),
mergedItems = _usePreviewItems2[0],
register = _usePreviewItems2[1];
register = _usePreviewItems2[1],
fromItems = _usePreviewItems2[2];

@@ -89,6 +90,9 @@ // ========================= Preview ==========================

setMousePosition = _useState4[1];
var onPreviewFromImage = React.useCallback(function (id, mouseX, mouseY) {
var index = mergedItems.findIndex(function (item) {
var onPreviewFromImage = React.useCallback(function (id, imageSrc, mouseX, mouseY) {
var index = fromItems ? mergedItems.findIndex(function (item) {
return item.data.src === imageSrc;
}) : mergedItems.findIndex(function (item) {
return item.id === id;
});
setCurrent(index < 0 ? 0 : index);
setShowPreview(true);

@@ -99,5 +103,4 @@ setMousePosition({

});
setCurrent(index < 0 ? 0 : index);
setKeepOpenIndex(true);
}, [mergedItems]);
}, [mergedItems, fromItems]);

@@ -104,0 +107,0 @@ // Reset current when reopen

{
"name": "rc-image",
"version": "7.7.0",
"version": "7.7.1",
"description": "React easy to use image component",

@@ -5,0 +5,0 @@ "keywords": [

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