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.5.0 to 2.6.0

48

lib/cjs/zoom.js

@@ -89,32 +89,4 @@ 'use strict';

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,
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,

@@ -201,7 +173,7 @@ ];

var click = function () { toggle(); };
return (React__namespace.createElement("span", { className: 'rpv-zoom-popover-target', onClick: click },
React__namespace.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__namespace.createElement("span", { className: 'rpv-zoom-popover-target-arrow' })));
React__namespace.createElement("span", { className: 'rpv-zoom__popover-target-arrow' })));
};

@@ -244,3 +216,3 @@ var renderContent = function (toggle) { return (React__namespace.createElement(core.Menu, null,

var label = l10n && l10n.zoom ? l10n.zoom.zoomIn : 'Zoom in';
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.Button, { onClick: onClick },
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { onClick: onClick },
React__namespace.createElement(ZoomInIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 }));

@@ -271,3 +243,3 @@ };

var label = l10n && l10n.zoom ? l10n.zoom.zoomOut : 'Zoom out';
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.Button, { onClick: onClick },
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { onClick: onClick },
React__namespace.createElement(ZoomOutIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET }));

@@ -307,3 +279,4 @@ };

var zoomPlugin = function () {
var zoomPlugin = function (props) {
var zoomPluginProps = React__namespace.useMemo(function () { return Object.assign({}, { enableShortcuts: true }, props); }, []);
var store = React__namespace.useMemo(function () { return core.createStore({}); }, []);

@@ -321,2 +294,5 @@ var CurrentScaleDecorator = function (props) { return (React__namespace.createElement(CurrentScale, __assign({}, props, { store: store }))); };

var slot = props.slot;
if (!zoomPluginProps.enableShortcuts) {
return slot;
}
var updateSlot = {

@@ -323,0 +299,0 @@ children: (React__namespace.createElement(React__namespace.Fragment, null,

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

"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"}))},u=function(){return(u=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)},a=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:a(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},f=function(e){var t=l.findIndex((function(t){return t>=e}));return-1===t||0===t?e:l[t-1]},s=function(e){var t=e.containerRef,n=e.store,r=function(e){if(!e.shiftKey&&!e.altKey&&("undefined"!=typeof window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?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,u=1;switch(e.key){case"-":u=f(c);break;case"=":u=m(c);break;case"0":u=1;break;default:u=c}u!==c&&(e.preventDefault(),r(u))}}}};return o.useEffect((function(){if(t.current)return document.addEventListener("keydown",r),function(){document.removeEventListener("keydown",r)}}),[t.current]),o.createElement(o.Fragment,null)},p=[.5,.75,1,1.25,1.5,2,3,4],v={left:0,top:8},E=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 u=n;return o.createElement(t.MenuItem,{key:u,onClick:function(){e(),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))})),o.createElement(t.MenuDivider,null),p.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),r(n)}},Math.round(100*n)+"%")})))},offset:v,closeOnClickOutside:!0,closeOnEscape:!0})},d=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(E,{scale:e.scale,onZoom:e.onZoom})})({scale:a(n).scale,onZoom:function(e){var t=n.get("zoom");t&&t(e)}})},z={left:0,top:8},C=function(e){var n=e.onClick,c=o.useContext(t.LocalizationContext),u=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 u},offset:z})},k=function(e){var t=e.children,n=e.store,r=a(n).scale;return(t||function(e){return o.createElement(C,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(m(r))}})},g={left:0,top:8},h=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),u=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 u},offset:g})},M=function(e){var t=e.children,n=e.store,r=a(n).scale;return(t||function(e){return o.createElement(h,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(f(r))}})},Z=function(e){var n=e.onClick,c=o.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return o.createElement(t.MenuItem,{icon:o.createElement(r,null),onClick:n},u)},O=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),u=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.MenuItem,{icon:o.createElement(c,null),onClick:n},u)};exports.ZoomInIcon=r,exports.ZoomOutIcon=c,exports.zoomPlugin=function(){var e=o.useMemo((function(){return t.createStore({})}),[]),n=function(t){return o.createElement(k,u({},t,{store:e}))},r=function(t){return o.createElement(M,u({},t,{store:e}))},c=function(t){return o.createElement(d,u({},t,{store:e}))};return{renderViewer:function(t){var n=t.slot,r={children:o.createElement(o.Fragment,null,o.createElement(s,{containerRef:t.containerRef,store:e}),n.children)};return u(u({},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,u({},t,{store:e}))},ZoomIn:n,ZoomInButton:function(){return o.createElement(n,null,(function(e){return o.createElement(C,u({},e))}))},ZoomInMenuItem:function(e){return o.createElement(n,null,(function(t){return o.createElement(Z,{onClick:function(){t.onClick(),e.onClick()}})}))},ZoomOut:r,ZoomOutButton:function(){return o.createElement(r,null,(function(e){return o.createElement(h,u({},e))}))},ZoomOutMenuItem:function(e){return o.createElement(r,null,(function(t){return o.createElement(O,{onClick:function(){t.onClick(),e.onClick()}})}))},Zoom:c,ZoomPopover:function(){return o.createElement(c,null,(function(e){return o.createElement(E,u({},e))}))}}};
"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"}))},u=function(){return(u=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)},i=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}},a=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:i(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},f=function(e){var t=l.findIndex((function(t){return t>=e}));return-1===t||0===t?e:l[t-1]},s=function(e){var t=e.containerRef,n=e.store,r=function(e){if(!e.shiftKey&&!e.altKey&&("undefined"!=typeof window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?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,u=1;switch(e.key){case"-":u=f(c);break;case"=":u=m(c);break;case"0":u=1;break;default:u=c}u!==c&&(e.preventDefault(),r(u))}}}};return o.useEffect((function(){if(t.current)return document.addEventListener("keydown",r),function(){document.removeEventListener("keydown",r)}}),[t.current]),o.createElement(o.Fragment,null)},p=[.5,.75,1,1.25,1.5,2,3,4],v={left:0,top:8},E=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 u=n;return o.createElement(t.MenuItem,{key:u,onClick:function(){e(),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))})),o.createElement(t.MenuDivider,null),p.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),r(n)}},Math.round(100*n)+"%")})))},offset:v,closeOnClickOutside:!0,closeOnEscape:!0})},d=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(E,{scale:e.scale,onZoom:e.onZoom})})({scale:i(n).scale,onZoom:function(e){var t=n.get("zoom");t&&t(e)}})},z={left:0,top:8},C=function(e){var n=e.onClick,c=o.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return o.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{onClick:n},o.createElement(r,null)),content:function(){return u},offset:z})},k=function(e){var t=e.children,n=e.store,r=i(n).scale;return(t||function(e){return o.createElement(C,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(m(r))}})},g={left:0,top:8},h=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),u=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{onClick:n},o.createElement(c,null)),content:function(){return u},offset:g})},M=function(e){var t=e.children,n=e.store,r=i(n).scale;return(t||function(e){return o.createElement(h,{onClick:e.onClick})})({onClick:function(){var e=n.get("zoom");e&&e(f(r))}})},Z=function(e){var n=e.onClick,c=o.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return o.createElement(t.MenuItem,{icon:o.createElement(r,null),onClick:n},u)},O=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),u=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.MenuItem,{icon:o.createElement(c,null),onClick:n},u)};exports.ZoomInIcon=r,exports.ZoomOutIcon=c,exports.zoomPlugin=function(e){var n=o.useMemo((function(){return Object.assign({},{enableShortcuts:!0},e)}),[]),r=o.useMemo((function(){return t.createStore({})}),[]),c=function(e){return o.createElement(k,u({},e,{store:r}))},i=function(e){return o.createElement(M,u({},e,{store:r}))},l=function(e){return o.createElement(d,u({},e,{store:r}))};return{renderViewer:function(e){var t=e.slot;if(!n.enableShortcuts)return t;var c={children:o.createElement(o.Fragment,null,o.createElement(s,{containerRef:e.containerRef,store:r}),t.children)};return u(u({},t),c)},install:function(e){r.update("zoom",e.zoom)},onViewerStateChange:function(e){return r.update("scale",e.scale),e},zoomTo:function(e){var t=r.get("zoom");t&&t(e)},CurrentScale:function(e){return o.createElement(a,u({},e,{store:r}))},ZoomIn:c,ZoomInButton:function(){return o.createElement(c,null,(function(e){return o.createElement(C,u({},e))}))},ZoomInMenuItem:function(e){return o.createElement(c,null,(function(t){return o.createElement(Z,{onClick:function(){t.onClick(),e.onClick()}})}))},ZoomOut:i,ZoomOutButton:function(){return o.createElement(i,null,(function(e){return o.createElement(h,u({},e))}))},ZoomOutMenuItem:function(e){return o.createElement(i,null,(function(t){return o.createElement(O,{onClick:function(){t.onClick(),e.onClick()}})}))},Zoom:l,ZoomPopover:function(){return o.createElement(l,null,(function(e){return o.createElement(E,u({},e))}))}}};

@@ -69,2 +69,6 @@ /**

export interface ZoomPluginProps {
enableShortcuts?: boolean;
}
export interface ZoomPlugin extends Plugin {

@@ -83,4 +87,4 @@ zoomTo: (scale: number | SpecialZoomLevel) => void;

export function zoomPlugin(): ZoomPlugin;
export function zoomPlugin(props?: ZoomPluginProps): ZoomPlugin;
export class ZoomInIcon extends React.Component {}
export class ZoomOutIcon extends React.Component {}
{
"name": "@react-pdf-viewer/zoom",
"version": "2.5.0",
"version": "2.6.0",
"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.5.0"
"@react-pdf-viewer/core": "2.6.0"
},

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

},
"gitHead": "3c7ba1ea082607670f4e2bf69d5312a14baf7057"
"gitHead": "91d6279570bd3d4672b131100392afd6e8658892"
}

Sorry, the diff of this file is not supported yet

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