@react-pdf-viewer/zoom
Advanced tools
Comparing version 2.7.2 to 2.8.0
@@ -148,2 +148,4 @@ 'use strict'; | ||
var l10n = React__namespace.useContext(core.LocalizationContext).l10n; | ||
var direction = React__namespace.useContext(core.ThemeContext).direction; | ||
var isRtl = direction === core.TextDirection.RightToLeft; | ||
var getSpcialLevelLabel = function (level) { | ||
@@ -166,3 +168,7 @@ switch (level) { | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target" }, | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target-scale", "data-testid": "zoom__popover-target-scale" }, | ||
React__namespace.createElement("span", { "data-testid": "zoom__popover-target-scale", className: core.classNames({ | ||
'rpv-zoom__popover-target-scale': true, | ||
'rpv-zoom__popover-target-scale--ltr': !isRtl, | ||
'rpv-zoom__popover-target-scale--rtl': isRtl, | ||
}) }, | ||
Math.round(scale * 100), | ||
@@ -209,3 +215,3 @@ "%"), | ||
var ZoomInIcon = function () { return (React__namespace.createElement(core.Icon, { size: 16 }, | ||
var ZoomInIcon = function () { return (React__namespace.createElement(core.Icon, { ignoreDirection: true, 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" }))); }; | ||
@@ -240,3 +246,3 @@ | ||
var ZoomOutIcon = function () { return (React__namespace.createElement(core.Icon, { size: 16 }, | ||
var ZoomOutIcon = function () { return (React__namespace.createElement(core.Icon, { ignoreDirection: true, 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" }))); }; | ||
@@ -243,0 +249,0 @@ |
@@ -1,2 +0,2 @@ | ||
"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).l10n,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","data-testid":"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)}})},z=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"}))},E={left:0,top:8},d=function(e){var n=e.enableShortcuts,r=e.onClick,c=o.useContext(t.LocalizationContext).l10n,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(z,null)),content:function(){return a},offset:E})},C=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=c(o).scale;return(t||d)({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).l10n,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).l10n,c=r&&r.zoom?r.zoom.zoomIn:"Zoom in";return o.createElement(t.MenuItem,{icon:o.createElement(z,null),onClick:n},c)},S=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext).l10n,c=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.MenuItem,{icon:o.createElement(h,null),onClick:n},c)}; | ||
"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).l10n,a=o.useContext(t.ThemeContext).direction===t.TextDirection.RightToLeft,u=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:u,onClick:function(){e()}},o.createElement("span",{className:"rpv-zoom__popover-target"},o.createElement("span",{"data-testid":"zoom__popover-target-scale",className:t.classNames({"rpv-zoom__popover-target-scale":!0,"rpv-zoom__popover-target-scale--ltr":!a,"rpv-zoom__popover-target-scale--rtl":a})},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)}})},z=function(){return o.createElement(t.Icon,{ignoreDirection:!0,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"}))},E={left:0,top:8},d=function(e){var n=e.enableShortcuts,r=e.onClick,c=o.useContext(t.LocalizationContext).l10n,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(z,null)),content:function(){return a},offset:E})},C=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=c(o).scale;return(t||d)({enableShortcuts:n,onClick:function(){var e=o.get("zoom");e&&e(i(r))}})},h=function(){return o.createElement(t.Icon,{ignoreDirection:!0,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"}))},g={left:0,top:8},b=function(e){var n=e.enableShortcuts,r=e.onClick,c=o.useContext(t.LocalizationContext).l10n,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:g})},k=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=c(o).scale;return(t||b)({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).l10n,c=r&&r.zoom?r.zoom.zoomIn:"Zoom in";return o.createElement(t.MenuItem,{icon:o.createElement(z,null),onClick:n},c)},S=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext).l10n,c=r&&r.zoom?r.zoom.zoomOut:"Zoom out";return o.createElement(t.MenuItem,{icon:o.createElement(h,null),onClick:n},c)}; | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */exports.ZoomInIcon=z,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(C,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(d,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))}))}}}; | ||
***************************************************************************** */exports.ZoomInIcon=z,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(C,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(d,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(b,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))}))}}}; |
{ | ||
"name": "@react-pdf-viewer/zoom", | ||
"version": "2.7.2", | ||
"version": "2.8.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.7.2" | ||
"@react-pdf-viewer/core": "2.8.0" | ||
}, | ||
@@ -53,3 +53,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "156fdaa17d841cc90ce4e9bf6ec9e5a9e23bb014" | ||
"gitHead": "5a7ff547bbdcf8b51c10907ad706e4edc397fc4f" | ||
} |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
28665
7
436
80
+ Added@react-pdf-viewer/core@2.8.0(transitive)
- Removed@react-pdf-viewer/core@2.7.2(transitive)
Updated@react-pdf-viewer/core@2.8.0