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

@react-pdf-viewer/zoom

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf-viewer/zoom - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

239

lib/cjs/zoom.js

@@ -8,10 +8,32 @@ 'use strict';

function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespace(React);
var ZoomInIcon = function () {
return (React.createElement(core.Icon, { size: 16 },
React.createElement("path", { d: "M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10" })));
return (React__namespace.createElement(core.Icon, { size: 16 },
React__namespace.createElement("path", { d: "M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10" })));
};
var ZoomOutIcon = function () {
return (React.createElement(core.Icon, { size: 16 },
React.createElement("path", { d: "M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10" })));
return (React__namespace.createElement(core.Icon, { size: 16 },
React__namespace.createElement("path", { d: "M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10" })));
};

@@ -46,7 +68,7 @@

var useZoom = function (store) {
var _a = React.useState(store.get('scale') || 0), scale = _a[0], setScale = _a[1];
var _a = React__namespace.useState(store.get('scale') || 0), scale = _a[0], setScale = _a[1];
var handleScaleChanged = function (currentScale) {
setScale(currentScale);
};
React.useEffect(function () {
React__namespace.useEffect(function () {
store.subscribe('scale', handleScaleChanged);

@@ -63,3 +85,3 @@ return function () {

var scale = useZoom(store).scale;
var defaultChildren = function (props) { return React.createElement(React.Fragment, null, Math.round(props.scale * 100) + "%"); };
var defaultChildren = function (props) { return React__namespace.createElement(React__namespace.Fragment, null, Math.round(props.scale * 100) + "%"); };
var render = children || defaultChildren;

@@ -69,2 +91,97 @@ return render({ scale: scale });

var LEVELS$1 = [
0.1,
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8,
0.9,
1,
1.1,
1.3,
1.5,
1.7,
1.9,
2.1,
2.4,
2.7,
3.0,
3.3,
3.7,
4.1,
4.6,
5.1,
5.7,
6.3,
7.0,
7.7,
8.5,
9.4,
10,
];
var increase = function (currentLevel) {
var found = LEVELS$1.find(function (item) { return item > currentLevel; });
return found || currentLevel;
};
var decrease = function (currentLevel) {
var found = LEVELS$1.findIndex(function (item) { return item >= currentLevel; });
return found === -1 || found === 0 ? currentLevel : LEVELS$1[found - 1];
};
var isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
var ShortcutHandler = function (_a) {
var containerRef = _a.containerRef, store = _a.store;
var keydownHandler = function (e) {
if (e.shiftKey || e.altKey) {
return;
}
var isCommandPressed = isMac ? e.metaKey : e.ctrlKey;
if (!isCommandPressed) {
return;
}
var containerEle = containerRef.current;
if (!containerEle || !document.activeElement || !document.activeElement.contains(containerEle)) {
return;
}
var zoom = store.get('zoom');
if (!zoom) {
return;
}
var scale = store.get('scale') || 1;
var newScale = 1;
switch (e.key) {
case '-':
newScale = decrease(scale);
break;
case '=':
newScale = increase(scale);
break;
case '0':
newScale = 1;
break;
default:
newScale = scale;
break;
}
if (newScale !== scale) {
e.preventDefault();
zoom(newScale);
}
};
React__namespace.useEffect(function () {
var containerEle = containerRef.current;
if (!containerEle) {
return;
}
document.addEventListener('keydown', keydownHandler);
return function () {
document.removeEventListener('keydown', keydownHandler);
};
}, [containerRef.current]);
return (React__namespace.createElement(React__namespace.Fragment, null));
};
var LEVELS = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4];

@@ -74,3 +191,3 @@ var PORTAL_OFFSET = { left: 0, top: 8 };

var scale = _a.scale, onZoom = _a.onZoom;
var l10n = React.useContext(core.LocalizationContext);
var l10n = React__namespace.useContext(core.LocalizationContext);
var getSpcialLevelLabel = function (level) {

@@ -88,20 +205,20 @@ switch (level) {

var click = function () { toggle(); };
return (React.createElement("span", { className: 'rpv-zoom-popover-target', onClick: click },
React.createElement("span", { className: 'rpv-zoom-popover-target-scale' },
return (React__namespace.createElement("span", { className: 'rpv-zoom-popover-target', onClick: click },
React__namespace.createElement("span", { className: 'rpv-zoom-popover-target-scale' },
Math.round(scale * 100),
"%"),
React.createElement("span", { className: 'rpv-zoom-popover-target-arrow' })));
React__namespace.createElement("span", { className: 'rpv-zoom-popover-target-arrow' })));
};
var renderContent = function (toggle) { return (React.createElement(core.Menu, null,
var renderContent = function (toggle) { return (React__namespace.createElement(core.Menu, null,
Object.keys(core.SpecialZoomLevel).map(function (k) {
var level = k;
var clickMenuItem = function () { toggle(); onZoom(level); };
return (React.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, getSpcialLevelLabel(level)));
return (React__namespace.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, getSpcialLevelLabel(level)));
}),
React.createElement(core.MenuDivider, null),
React__namespace.createElement(core.MenuDivider, null),
LEVELS.map(function (level) {
var clickMenuItem = function () { toggle(); onZoom(level); };
return (React.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, Math.round(level * 100) + "%"));
return (React__namespace.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, Math.round(level * 100) + "%"));
}))); };
return (React.createElement(core.Popover, { position: core.Position.BottomCenter, target: renderTarget, content: renderContent, offset: PORTAL_OFFSET, closeOnClickOutside: true, closeOnEscape: true }));
return (React__namespace.createElement(core.Popover, { position: core.Position.BottomCenter, target: renderTarget, content: renderContent, offset: PORTAL_OFFSET, closeOnClickOutside: true, closeOnEscape: true }));
};

@@ -118,3 +235,3 @@

};
var defaultChildren = function (props) { return React.createElement(ZoomPopover, { scale: props.scale, onZoom: props.onZoom }); };
var defaultChildren = function (props) { return React__namespace.createElement(ZoomPopover, { scale: props.scale, onZoom: props.onZoom }); };
var render = children || defaultChildren;

@@ -127,53 +244,11 @@ return render({

var TOOLTIP_OFFSET = { left: 0, top: 8 };
var TOOLTIP_OFFSET$1 = { left: 0, top: 8 };
var ZoomInButton = function (_a) {
var onClick = _a.onClick;
var l10n = React.useContext(core.LocalizationContext);
var l10n = React__namespace.useContext(core.LocalizationContext);
var label = l10n && l10n.zoom ? l10n.zoom.zoomIn : 'Zoom in';
return (React.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React.createElement(core.Button, { onClick: onClick },
React.createElement(ZoomInIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET }));
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.Button, { onClick: onClick },
React__namespace.createElement(ZoomInIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 }));
};
var LEVELS$1 = [
0.1,
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8,
0.9,
1,
1.1,
1.3,
1.5,
1.7,
1.9,
2.1,
2.4,
2.7,
3.0,
3.3,
3.7,
4.1,
4.6,
5.1,
5.7,
6.3,
7.0,
7.7,
8.5,
9.4,
10,
];
var increase = function (currentLevel) {
var found = LEVELS$1.find(function (item) { return item > currentLevel; });
return found || currentLevel;
};
var decrease = function (currentLevel) {
var found = LEVELS$1.findIndex(function (item) { return item >= currentLevel; });
return found === -1 || found === 0 ? currentLevel : LEVELS$1[found - 1];
};
var ZoomIn = function (_a) {

@@ -189,3 +264,3 @@ var children = _a.children, store = _a.store;

};
var defaultChildren = function (props) { return React.createElement(ZoomInButton, { onClick: props.onClick }); };
var defaultChildren = function (props) { return React__namespace.createElement(ZoomInButton, { onClick: props.onClick }); };
var render = children || defaultChildren;

@@ -197,9 +272,9 @@ return render({

var TOOLTIP_OFFSET$1 = { left: 0, top: 8 };
var TOOLTIP_OFFSET = { left: 0, top: 8 };
var ZoomOutButton = function (_a) {
var onClick = _a.onClick;
var l10n = React.useContext(core.LocalizationContext);
var l10n = React__namespace.useContext(core.LocalizationContext);
var label = l10n && l10n.zoom ? l10n.zoom.zoomOut : 'Zoom out';
return (React.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React.createElement(core.Button, { onClick: onClick },
React.createElement(ZoomOutIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 }));
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.Button, { onClick: onClick },
React__namespace.createElement(ZoomOutIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET }));
};

@@ -217,3 +292,3 @@

};
var defaultChildren = function (props) { return React.createElement(ZoomOutButton, { onClick: props.onClick }); };
var defaultChildren = function (props) { return React__namespace.createElement(ZoomOutButton, { onClick: props.onClick }); };
var render = children || defaultChildren;

@@ -226,11 +301,21 @@ return render({

var zoomPlugin = function () {
var store = React.useMemo(function () { return core.createStore({}); }, []);
var CurrentScaleDecorator = function (props) { return (React.createElement(CurrentScale, __assign({}, props, { store: store }))); };
var ZoomInDecorator = function (props) { return (React.createElement(ZoomIn, __assign({}, props, { store: store }))); };
var ZoomInButtonDecorator = function () { return (React.createElement(ZoomInDecorator, null, function (props) { return React.createElement(ZoomInButton, __assign({}, props)); })); };
var ZoomOutDecorator = function (props) { return (React.createElement(ZoomOut, __assign({}, props, { store: store }))); };
var ZoomOutButtonDecorator = function () { return (React.createElement(ZoomOutDecorator, null, function (props) { return React.createElement(ZoomOutButton, __assign({}, props)); })); };
var ZoomDecorator = function (props) { return React.createElement(Zoom, __assign({}, props, { store: store })); };
var ZoomPopoverDecorator = function () { return (React.createElement(ZoomDecorator, null, function (props) { return React.createElement(ZoomPopover, __assign({}, props)); })); };
var store = React__namespace.useMemo(function () { return core.createStore({}); }, []);
var CurrentScaleDecorator = function (props) { return (React__namespace.createElement(CurrentScale, __assign({}, props, { store: store }))); };
var ZoomInDecorator = function (props) { return (React__namespace.createElement(ZoomIn, __assign({}, props, { store: store }))); };
var ZoomInButtonDecorator = function () { return (React__namespace.createElement(ZoomInDecorator, null, function (props) { return React__namespace.createElement(ZoomInButton, __assign({}, props)); })); };
var ZoomOutDecorator = function (props) { return (React__namespace.createElement(ZoomOut, __assign({}, props, { store: store }))); };
var ZoomOutButtonDecorator = function () { return (React__namespace.createElement(ZoomOutDecorator, null, function (props) { return React__namespace.createElement(ZoomOutButton, __assign({}, props)); })); };
var ZoomDecorator = function (props) { return React__namespace.createElement(Zoom, __assign({}, props, { store: store })); };
var ZoomPopoverDecorator = function () { return (React__namespace.createElement(ZoomDecorator, null, function (props) { return React__namespace.createElement(ZoomPopover, __assign({}, props)); })); };
var renderViewer = function (props) {
var slot = props.slot;
var updateSlot = {
children: (React__namespace.createElement(React__namespace.Fragment, null,
React__namespace.createElement(ShortcutHandler, { containerRef: props.containerRef, store: store }),
slot.children))
};
return __assign(__assign({}, slot), updateSlot);
};
return {
renderViewer: renderViewer,
install: function (pluginFunctions) {

@@ -237,0 +322,0 @@ store.update('zoom', pluginFunctions.zoom);

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core"),n=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10"}))},o=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10"}))},r=function(){return(r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},c=function(t){var n=e.useState(t.get("scale")||0),o=n[0],r=n[1],c=function(e){r(e)};return e.useEffect((function(){return t.subscribe("scale",c),function(){t.unsubscribe("scale",c)}}),[]),{scale:o}},u=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(e.Fragment,null,Math.round(100*t.scale)+"%")})({scale:c(o).scale})},a=[.5,.75,1,1.25,1.5,2,3,4],i={left:0,top:8},l=function(n){var o=n.scale,r=n.onZoom,c=e.useContext(t.LocalizationContext);return e.createElement(t.Popover,{position:t.Position.BottomCenter,target:function(t){return e.createElement("span",{className:"rpv-zoom-popover-target",onClick:function(){t()}},e.createElement("span",{className:"rpv-zoom-popover-target-scale"},Math.round(100*o),"%"),e.createElement("span",{className:"rpv-zoom-popover-target-arrow"}))},content:function(n){return e.createElement(t.Menu,null,Object.keys(t.SpecialZoomLevel).map((function(o){var u=o;return e.createElement(t.MenuItem,{key:u,onClick:function(){n(),r(u)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return c&&c.zoom?c.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return c&&c.zoom?c.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return c&&c.zoom?c.zoom.pageWidth:"Page width"}}(u))})),e.createElement(t.MenuDivider,null),a.map((function(o){return e.createElement(t.MenuItem,{key:o,onClick:function(){n(),r(o)}},Math.round(100*o)+"%")})))},offset:i,closeOnClickOutside:!0,closeOnEscape:!0})},m=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(l,{scale:t.scale,onZoom:t.onZoom})})({scale:c(o).scale,onZoom:function(e){var t=o.get("zoom");t&&t(e)}})},s={left:0,top:8},f=function(o){var r=o.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(n,null)),content:function(){return u},offset:s})},p=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.3,1.5,1.7,1.9,2.1,2.4,2.7,3,3.3,3.7,4.1,4.6,5.1,5.7,6.3,7,7.7,8.5,9.4,10],E=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(f,{onClick:t.onClick})})({onClick:function(){var e,t=o.get("zoom");t&&t((e=r,p.find((function(t){return t>e}))||e))}})},v={left:0,top:8},z=function(n){var r=n.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomOut:"Zoom out";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(o,null)),content:function(){return u},offset:v})},C=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(z,{onClick:t.onClick})})({onClick:function(){var e,t,n=o.get("zoom");n&&n((e=r,-1===(t=p.findIndex((function(t){return t>=e})))||0===t?e:p[t-1]))}})};exports.ZoomInIcon=n,exports.ZoomOutIcon=o,exports.zoomPlugin=function(){var n=e.useMemo((function(){return t.createStore({})}),[]),o=function(t){return e.createElement(E,r({},t,{store:n}))},c=function(t){return e.createElement(C,r({},t,{store:n}))},a=function(t){return e.createElement(m,r({},t,{store:n}))};return{install:function(e){n.update("zoom",e.zoom)},onViewerStateChange:function(e){return n.update("scale",e.scale),e},zoomTo:function(e){var t=n.get("zoom");t&&t(e)},CurrentScale:function(t){return e.createElement(u,r({},t,{store:n}))},ZoomIn:o,ZoomInButton:function(){return e.createElement(o,null,(function(t){return e.createElement(f,r({},t))}))},ZoomOut:c,ZoomOutButton:function(){return e.createElement(c,null,(function(t){return e.createElement(z,r({},t))}))},Zoom:a,ZoomPopover:function(){return e.createElement(a,null,(function(t){return e.createElement(l,r({},t))}))}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=n(e),r=function(){return o.createElement(t.Icon,{size:16},o.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10"}))},c=function(){return o.createElement(t.Icon,{size:16},o.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10"}))},a=function(){return(a=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},u=function(e){var t=o.useState(e.get("scale")||0),n=t[0],r=t[1],c=function(e){r(e)};return o.useEffect((function(){return e.subscribe("scale",c),function(){e.unsubscribe("scale",c)}}),[]),{scale:n}},i=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(o.Fragment,null,Math.round(100*e.scale)+"%")})({scale:u(n).scale})},l=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.3,1.5,1.7,1.9,2.1,2.4,2.7,3,3.3,3.7,4.1,4.6,5.1,5.7,6.3,7,7.7,8.5,9.4,10],m=function(e){return l.find((function(t){return t>e}))||e},s=function(e){var t=l.findIndex((function(t){return t>=e}));return-1===t||0===t?e:l[t-1]},f=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),p=function(e){var t=e.containerRef,n=e.store,r=function(e){if(!e.shiftKey&&!e.altKey&&(f?e.metaKey:e.ctrlKey)){var o=t.current;if(o&&document.activeElement&&document.activeElement.contains(o)){var r=n.get("zoom");if(r){var c=n.get("scale")||1,a=1;switch(e.key){case"-":a=s(c);break;case"=":a=m(c);break;case"0":a=1;break;default:a=c}a!==c&&(e.preventDefault(),r(a))}}}};return o.useEffect((function(){if(t.current)return document.addEventListener("keydown",r),function(){document.removeEventListener("keydown",r)}}),[t.current]),o.createElement(o.Fragment,null)},v=[.5,.75,1,1.25,1.5,2,3,4],E={left:0,top:8},d=function(e){var n=e.scale,r=e.onZoom,c=o.useContext(t.LocalizationContext);return o.createElement(t.Popover,{position:t.Position.BottomCenter,target:function(e){return o.createElement("span",{className:"rpv-zoom-popover-target",onClick:function(){e()}},o.createElement("span",{className:"rpv-zoom-popover-target-scale"},Math.round(100*n),"%"),o.createElement("span",{className:"rpv-zoom-popover-target-arrow"}))},content:function(e){return o.createElement(t.Menu,null,Object.keys(t.SpecialZoomLevel).map((function(n){var a=n;return o.createElement(t.MenuItem,{key:a,onClick:function(){e(),r(a)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return c&&c.zoom?c.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return c&&c.zoom?c.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return c&&c.zoom?c.zoom.pageWidth:"Page width"}}(a))})),o.createElement(t.MenuDivider,null),v.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),r(n)}},Math.round(100*n)+"%")})))},offset:E,closeOnClickOutside:!0,closeOnEscape:!0})},z=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(d,{scale:e.scale,onZoom:e.onZoom})})({scale:u(n).scale,onZoom:function(e){var t=n.get("zoom");t&&t(e)}})},g={left:0,top:8},h=function(e){var n=e.onClick,c=o.useContext(t.LocalizationContext),a=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return o.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:o.createElement(t.Button,{onClick:n},o.createElement(r,null)),content:function(){return a},offset:g})},C=function(e){var t=e.children,n=e.store,r=u(n).scale;return(t||function(e){return o.createElement(h,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(m(r))}})},k={left:0,top:8},M=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),a=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:o.createElement(t.Button,{onClick:n},o.createElement(c,null)),content:function(){return a},offset:k})},O=function(e){var t=e.children,n=e.store,r=u(n).scale;return(t||function(e){return o.createElement(M,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(s(r))}})};exports.ZoomInIcon=r,exports.ZoomOutIcon=c,exports.zoomPlugin=function(){var e=o.useMemo((function(){return t.createStore({})}),[]),n=function(t){return o.createElement(C,a({},t,{store:e}))},r=function(t){return o.createElement(O,a({},t,{store:e}))},c=function(t){return o.createElement(z,a({},t,{store:e}))};return{renderViewer:function(t){var n=t.slot,r={children:o.createElement(o.Fragment,null,o.createElement(p,{containerRef:t.containerRef,store:e}),n.children)};return a(a({},n),r)},install:function(t){e.update("zoom",t.zoom)},onViewerStateChange:function(t){return e.update("scale",t.scale),t},zoomTo:function(t){var n=e.get("zoom");n&&n(t)},CurrentScale:function(t){return o.createElement(i,a({},t,{store:e}))},ZoomIn:n,ZoomInButton:function(){return o.createElement(n,null,(function(e){return o.createElement(h,a({},e))}))},ZoomOut:r,ZoomOutButton:function(){return o.createElement(r,null,(function(e){return o.createElement(M,a({},e))}))},Zoom:c,ZoomPopover:function(){return o.createElement(c,null,(function(e){return o.createElement(d,a({},e))}))}}};
{
"name": "@react-pdf-viewer/zoom",
"version": "2.4.1",
"version": "2.4.2",
"description": "A React component to view a PDF document",

@@ -36,3 +36,3 @@ "license": "https://react-pdf-viewer.dev/license",

"dependencies": {
"@react-pdf-viewer/core": "2.4.1"
"@react-pdf-viewer/core": "2.4.2"
},

@@ -53,3 +53,3 @@ "peerDependencies": {

},
"gitHead": "ecc13b17c4b2ce670b4faca550ec036ead8425da"
"gitHead": "cdcbd1484baab181f5a5c9ee2e0b82bd6481cdc6"
}
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