@react-pdf-viewer/zoom
Advanced tools
Comparing version 2.6.1 to 2.7.0
@@ -30,12 +30,2 @@ 'use strict'; | ||
var ZoomInIcon = function () { | ||
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__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" }))); | ||
}; | ||
/*! ***************************************************************************** | ||
@@ -102,3 +92,2 @@ Copyright (c) Microsoft Corporation. | ||
var isMac = function () { return (typeof window !== 'undefined' ? /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) : false); }; | ||
var ShortcutHandler = function (_a) { | ||
@@ -110,3 +99,3 @@ var containerRef = _a.containerRef, store = _a.store; | ||
} | ||
var isCommandPressed = isMac() ? e.metaKey : e.ctrlKey; | ||
var isCommandPressed = core.isMac() ? e.metaKey : e.ctrlKey; | ||
if (!isCommandPressed) { | ||
@@ -116,3 +105,3 @@ return; | ||
var containerEle = containerRef.current; | ||
if (!containerEle || !document.activeElement || !document.activeElement.contains(containerEle)) { | ||
if (!containerEle || !document.activeElement || !containerEle.contains(document.activeElement)) { | ||
return; | ||
@@ -173,2 +162,3 @@ } | ||
}; | ||
var zoomDocumentLabel = l10n && l10n.zoom ? l10n.zoom.zoomDocument : 'Zoom document'; | ||
var renderTarget = function (toggle) { | ||
@@ -178,7 +168,8 @@ var click = function () { | ||
}; | ||
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" }))); | ||
return (React__namespace.createElement(core.MinimalButton, { ariaLabel: zoomDocumentLabel, onClick: click }, | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target" }, | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target-scale" }, | ||
Math.round(scale * 100), | ||
"%"), | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target-arrow" })))); | ||
}; | ||
@@ -202,3 +193,3 @@ var renderContent = function (toggle) { return (React__namespace.createElement(core.Menu, null, | ||
}))); }; | ||
return (React__namespace.createElement(core.Popover, { position: core.Position.BottomCenter, target: renderTarget, content: renderContent, offset: PORTAL_OFFSET, closeOnClickOutside: true, closeOnEscape: true })); | ||
return (React__namespace.createElement(core.Popover, { ariaControlsSuffix: "zoom", ariaHasPopup: "menu", position: core.Position.BottomCenter, target: renderTarget, content: renderContent, offset: PORTAL_OFFSET, closeOnClickOutside: true, closeOnEscape: true })); | ||
}; | ||
@@ -223,8 +214,12 @@ | ||
var ZoomInIcon = function () { 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 TOOLTIP_OFFSET$1 = { left: 0, top: 8 }; | ||
var ZoomInButton = function (_a) { | ||
var onClick = _a.onClick; | ||
var enableShortcuts = _a.enableShortcuts, onClick = _a.onClick; | ||
var l10n = React__namespace.useContext(core.LocalizationContext); | ||
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.MinimalButton, { onClick: onClick }, | ||
var ariaKeyShortcuts = enableShortcuts ? (core.isMac() ? 'Meta+=' : 'Ctrl+=') : ''; | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "zoom-in", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, onClick: onClick }, | ||
React__namespace.createElement(ZoomInIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 })); | ||
@@ -234,3 +229,3 @@ }; | ||
var ZoomIn = function (_a) { | ||
var children = _a.children, store = _a.store; | ||
var children = _a.children, enableShortcuts = _a.enableShortcuts, store = _a.store; | ||
var scale = useZoom(store).scale; | ||
@@ -244,5 +239,5 @@ var zoomIn = function () { | ||
}; | ||
var defaultChildren = function (props) { return React__namespace.createElement(ZoomInButton, { onClick: props.onClick }); }; | ||
var render = children || defaultChildren; | ||
var render = children || ZoomInButton; | ||
return render({ | ||
enableShortcuts: enableShortcuts, | ||
onClick: zoomIn, | ||
@@ -252,8 +247,12 @@ }); | ||
var ZoomOutIcon = function () { 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" }))); }; | ||
var TOOLTIP_OFFSET = { left: 0, top: 8 }; | ||
var ZoomOutButton = function (_a) { | ||
var onClick = _a.onClick; | ||
var enableShortcuts = _a.enableShortcuts, onClick = _a.onClick; | ||
var l10n = React__namespace.useContext(core.LocalizationContext); | ||
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.MinimalButton, { onClick: onClick }, | ||
var ariaKeyShortcuts = enableShortcuts ? (core.isMac() ? 'Meta+-' : 'Ctrl+-') : ''; | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "zoom-out", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, onClick: onClick }, | ||
React__namespace.createElement(ZoomOutIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET })); | ||
@@ -263,3 +262,3 @@ }; | ||
var ZoomOut = function (_a) { | ||
var children = _a.children, store = _a.store; | ||
var children = _a.children, enableShortcuts = _a.enableShortcuts, store = _a.store; | ||
var scale = useZoom(store).scale; | ||
@@ -273,5 +272,5 @@ var zoomIn = function () { | ||
}; | ||
var defaultChildren = function (props) { return React__namespace.createElement(ZoomOutButton, { onClick: props.onClick }); }; | ||
var render = children || defaultChildren; | ||
var render = children || ZoomOutButton; | ||
return render({ | ||
enableShortcuts: enableShortcuts, | ||
onClick: zoomIn, | ||
@@ -299,3 +298,3 @@ }); | ||
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 ZoomInDecorator = function (props) { return (React__namespace.createElement(ZoomIn, __assign({ enableShortcuts: zoomPluginProps.enableShortcuts }, props, { store: store }))); }; | ||
var ZoomInButtonDecorator = function () { return React__namespace.createElement(ZoomInDecorator, null, function (props) { return React__namespace.createElement(ZoomInButton, __assign({}, props)); }); }; | ||
@@ -306,3 +305,3 @@ var ZoomInMenuItemDecorator = function (props) { return (React__namespace.createElement(ZoomInDecorator, null, function (p) { return (React__namespace.createElement(ZoomInMenuItem, { onClick: function () { | ||
} })); })); }; | ||
var ZoomOutDecorator = function (props) { return React__namespace.createElement(ZoomOut, __assign({}, props, { store: store })); }; | ||
var ZoomOutDecorator = function (props) { return (React__namespace.createElement(ZoomOut, __assign({ enableShortcuts: zoomPluginProps.enableShortcuts }, props, { store: store }))); }; | ||
var ZoomOutButtonDecorator = function () { return React__namespace.createElement(ZoomOutDecorator, null, function (props) { return React__namespace.createElement(ZoomOutButton, __assign({}, props)); }); }; | ||
@@ -309,0 +308,0 @@ var ZoomOutMenuItemDecorator = function (props) { return (React__namespace.createElement(ZoomOutDecorator, null, function (p) { return (React__namespace.createElement(ZoomOutMenuItem, { onClick: function () { |
@@ -1,1 +0,15 @@ | ||
"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))}))}}}; | ||
"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(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(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:c(n).scale})},u=[.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],i=function(e){return u.find((function(t){return t>e}))||e},l=function(e){var t=u.findIndex((function(t){return t>=e}));return-1===t||0===t?e:u[t-1]},m=function(e){var n=e.containerRef,r=e.store,c=function(e){if(!e.shiftKey&&!e.altKey&&(t.isMac()?e.metaKey:e.ctrlKey)){var o=n.current;if(o&&document.activeElement&&o.contains(document.activeElement)){var c=r.get("zoom");if(c){var a=r.get("scale")||1,u=1;switch(e.key){case"-":u=l(a);break;case"=":u=i(a);break;case"0":u=1;break;default:u=a}u!==a&&(e.preventDefault(),c(u))}}}};return o.useEffect((function(){if(n.current)return document.addEventListener("keydown",c),function(){document.removeEventListener("keydown",c)}}),[n.current]),o.createElement(o.Fragment,null)},s=[.5,.75,1,1.25,1.5,2,3,4],f={left:0,top:8},p=function(e){var n=e.scale,r=e.onZoom,c=o.useContext(t.LocalizationContext),a=c&&c.zoom?c.zoom.zoomDocument:"Zoom document";return o.createElement(t.Popover,{ariaControlsSuffix:"zoom",ariaHasPopup:"menu",position:t.Position.BottomCenter,target:function(e){return o.createElement(t.MinimalButton,{ariaLabel:a,onClick:function(){e()}},o.createElement("span",{className:"rpv-zoom__popover-target"},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),s.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),r(n)}},Math.round(100*n)+"%")})))},offset:f,closeOnClickOutside:!0,closeOnEscape:!0})},v=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(p,{scale:e.scale,onZoom:e.onZoom})})({scale:c(n).scale,onZoom:function(e){var t=n.get("zoom");t&&t(e)}})},E=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"}))},z={left:0,top:8},C=function(e){var n=e.enableShortcuts,r=e.onClick,c=o.useContext(t.LocalizationContext),a=c&&c.zoom?c.zoom.zoomIn:"Zoom in",u=n?t.isMac()?"Meta+=":"Ctrl+=":"";return o.createElement(t.Tooltip,{ariaControlsSuffix:"zoom-in",position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{ariaKeyShortcuts:u,ariaLabel:a,onClick:r},o.createElement(E,null)),content:function(){return a},offset:z})},d=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=c(o).scale;return(t||C)({enableShortcuts:n,onClick:function(){var e=o.get("zoom");e&&e(i(r))}})},h=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"}))},b={left:0,top:8},g=function(e){var n=e.enableShortcuts,r=e.onClick,c=o.useContext(t.LocalizationContext),a=c&&c.zoom?c.zoom.zoomOut:"Zoom out",u=n?t.isMac()?"Meta+-":"Ctrl+-":"";return o.createElement(t.Tooltip,{ariaControlsSuffix:"zoom-out",position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{ariaKeyShortcuts:u,ariaLabel:a,onClick:r},o.createElement(h,null)),content:function(){return a},offset:b})},k=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=c(o).scale;return(t||g)({enableShortcuts:n,onClick:function(){var e=o.get("zoom");e&&e(l(r))}})},M=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),c=r&&r.zoom?r.zoom.zoomIn:"Zoom in";return o.createElement(t.MenuItem,{icon:o.createElement(E,null),onClick:n},c)},S=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),c=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.MenuItem,{icon:o.createElement(h,null),onClick:n},c)}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */exports.ZoomInIcon=E,exports.ZoomOutIcon=h,exports.zoomPlugin=function(e){var n=o.useMemo((function(){return Object.assign({},{enableShortcuts:!0},e)}),[]),c=o.useMemo((function(){return t.createStore({})}),[]),u=function(e){return o.createElement(d,r({enableShortcuts:n.enableShortcuts},e,{store:c}))},i=function(e){return o.createElement(k,r({enableShortcuts:n.enableShortcuts},e,{store:c}))},l=function(e){return o.createElement(v,r({},e,{store:c}))};return{renderViewer:function(e){var t=e.slot;if(!n.enableShortcuts)return t;var a={children:o.createElement(o.Fragment,null,o.createElement(m,{containerRef:e.containerRef,store:c}),t.children)};return r(r({},t),a)},install:function(e){c.update("zoom",e.zoom)},onViewerStateChange:function(e){return c.update("scale",e.scale),e},zoomTo:function(e){var t=c.get("zoom");t&&t(e)},CurrentScale:function(e){return o.createElement(a,r({},e,{store:c}))},ZoomIn:u,ZoomInButton:function(){return o.createElement(u,null,(function(e){return o.createElement(C,r({},e))}))},ZoomInMenuItem:function(e){return o.createElement(u,null,(function(t){return o.createElement(M,{onClick:function(){t.onClick(),e.onClick()}})}))},ZoomOut:i,ZoomOutButton:function(){return o.createElement(i,null,(function(e){return o.createElement(g,r({},e))}))},ZoomOutMenuItem:function(e){return o.createElement(i,null,(function(t){return o.createElement(S,{onClick:function(){t.onClick(),e.onClick()}})}))},Zoom:l,ZoomPopover:function(){return o.createElement(l,null,(function(e){return o.createElement(p,r({},e))}))}}}; |
@@ -10,14 +10,12 @@ /** | ||
import * as React from 'react'; | ||
import { Plugin, SpecialZoomLevel } from '@react-pdf-viewer/core'; | ||
import { SpecialZoomLevel } from '@react-pdf-viewer/core'; | ||
import type { Plugin } from '@react-pdf-viewer/core'; | ||
export interface ZoomMenuItemProps { | ||
onClick: () => void; | ||
// Types | ||
export interface CurrentScaleProps { | ||
children?: (props: RenderCurrentScaleProps) => React.ReactElement; | ||
} | ||
// ------------------------ | ||
// Render zooming in button | ||
// ------------------------ | ||
export interface RenderZoomInProps { | ||
onClick: () => void; | ||
export interface RenderCurrentScaleProps { | ||
scale: number; | ||
} | ||
@@ -29,10 +27,2 @@ | ||
// ------------------------- | ||
// Render zooming out button | ||
// ------------------------- | ||
export interface RenderZoomOutProps { | ||
onClick: () => void; | ||
} | ||
export interface ZoomOutProps { | ||
@@ -42,18 +32,16 @@ children?: (props: RenderZoomOutProps) => React.ReactNode; | ||
// ------------- | ||
// Current scale | ||
// ------------- | ||
export interface ZoomProps { | ||
children?: (props: RenderZoomProps) => React.ReactElement; | ||
} | ||
export interface RenderCurrentScaleProps { | ||
scale: number; | ||
export interface RenderZoomInProps { | ||
enableShortcuts: boolean; | ||
onClick: () => void; | ||
} | ||
export interface CurrentScaleProps { | ||
children?: (props: RenderCurrentScaleProps) => React.ReactElement; | ||
export interface RenderZoomOutProps { | ||
enableShortcuts: boolean; | ||
onClick: () => void; | ||
} | ||
// ------------------- | ||
// Zoom to given scale | ||
// ------------------- | ||
export interface RenderZoomProps { | ||
@@ -64,10 +52,7 @@ scale: number; | ||
export interface ZoomProps { | ||
children?: (props: RenderZoomProps) => React.ReactElement; | ||
export interface ZoomMenuItemProps { | ||
onClick: () => void; | ||
} | ||
// ------ | ||
// Plugin | ||
// ------ | ||
export interface ZoomPluginProps { | ||
@@ -91,3 +76,5 @@ enableShortcuts?: boolean; | ||
export function zoomPlugin(props?: ZoomPluginProps): ZoomPlugin; | ||
// Components | ||
export class ZoomInIcon extends React.Component {} | ||
export class ZoomOutIcon extends React.Component {} |
{ | ||
"name": "@react-pdf-viewer/zoom", | ||
"version": "2.6.1", | ||
"version": "2.7.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.6.1" | ||
"@react-pdf-viewer/core": "2.7.0" | ||
}, | ||
@@ -53,3 +53,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "500247f24514da033bf92266f6903decaffebb68" | ||
"gitHead": "331789d286847ac1c8a272c9df82bdab63ba4406" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27858
429
+ Added@react-pdf-viewer/core@2.7.0(transitive)
- Removed@react-pdf-viewer/core@2.6.1(transitive)
Updated@react-pdf-viewer/core@2.7.0