@react-pdf-viewer/zoom
Advanced tools
Comparing version 2.11.0 to 3.0.0
@@ -71,3 +71,3 @@ 'use strict'; | ||
var scale = useZoom(store).scale; | ||
var defaultChildren = function (props) { return React__namespace.createElement(React__namespace.Fragment, null, Math.round(props.scale * 100) + "%"); }; | ||
var defaultChildren = function (props) { return React__namespace.createElement(React__namespace.Fragment, null, "".concat(Math.round(props.scale * 100), "%")); }; | ||
var render = children || defaultChildren; | ||
@@ -164,3 +164,3 @@ return render({ scale: scale }); | ||
}; | ||
return (React__namespace.createElement(core.MinimalButton, { ariaLabel: zoomDocumentLabel, onClick: click }, | ||
return (React__namespace.createElement(core.MinimalButton, { ariaLabel: zoomDocumentLabel, testId: "zoom__popover-target", onClick: click }, | ||
React__namespace.createElement("span", { className: "rpv-zoom__popover-target" }, | ||
@@ -191,3 +191,3 @@ React__namespace.createElement("span", { "data-testid": "zoom__popover-target-scale", className: core.classNames({ | ||
}; | ||
return (React__namespace.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, Math.round(level * 100) + "%")); | ||
return (React__namespace.createElement(core.MenuItem, { key: level, onClick: clickMenuItem }, "".concat(Math.round(level * 100), "%"))); | ||
}))); }; | ||
@@ -223,3 +223,3 @@ 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 })); | ||
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 }, | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "zoom-in", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, testId: "zoom__in-button", onClick: onClick }, | ||
React__namespace.createElement(ZoomInIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 })); | ||
@@ -254,3 +254,3 @@ }; | ||
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 }, | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "zoom-out", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, testId: "zoom__out-button", onClick: onClick }, | ||
React__namespace.createElement(ZoomOutIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET })); | ||
@@ -280,3 +280,3 @@ }; | ||
var label = l10n && l10n.zoom ? l10n.zoom.zoomIn : 'Zoom in'; | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomInIcon, null), onClick: onClick }, label)); | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomInIcon, null), testId: "zoom__in-menu", onClick: onClick }, label)); | ||
}; | ||
@@ -288,3 +288,3 @@ | ||
var label = l10n && l10n.zoom ? l10n.zoom.zoomOut : 'Zoom out'; | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomOutIcon, null), onClick: onClick }, label)); | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomOutIcon, null), testId: "zoom__out-menu", onClick: onClick }, label)); | ||
}; | ||
@@ -291,0 +291,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},r.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},v=function(e){var n=e.levels,r=void 0===n?s:n,c=e.scale,a=e.onZoom,u=o.useContext(t.LocalizationContext).l10n,i=o.useContext(t.ThemeContext).direction===t.TextDirection.RightToLeft,l=u&&u.zoom?u.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:l,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":!i,"rpv-zoom__popover-target-scale--rtl":i})},Math.round(100*c),"%"),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 r=n;return o.createElement(t.MenuItem,{key:r,onClick:function(){e(),a(r)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return u&&u.zoom?u.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return u&&u.zoom?u.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return u&&u.zoom?u.zoom.pageWidth:"Page width"}}(r))})),o.createElement(t.MenuDivider,null),r.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),a(n)}},Math.round(100*n)+"%")})))},offset:f,closeOnClickOutside:!0,closeOnEscape:!0})},p=function(e){var t=e.children,n=e.levels,r=e.store;return(t||function(e){return o.createElement(v,{levels:n,scale:e.scale,onZoom:e.onZoom})})({scale:c(r).scale,onZoom:function(e){var t=r.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)}; | ||
"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},r.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,"".concat(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},v=function(e){var n=e.levels,r=void 0===n?s:n,c=e.scale,a=e.onZoom,u=o.useContext(t.LocalizationContext).l10n,i=o.useContext(t.ThemeContext).direction===t.TextDirection.RightToLeft,l=u&&u.zoom?u.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:l,testId:"zoom__popover-target",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":!i,"rpv-zoom__popover-target-scale--rtl":i})},Math.round(100*c),"%"),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 r=n;return o.createElement(t.MenuItem,{key:r,onClick:function(){e(),a(r)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return u&&u.zoom?u.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return u&&u.zoom?u.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return u&&u.zoom?u.zoom.pageWidth:"Page width"}}(r))})),o.createElement(t.MenuDivider,null),r.map((function(n){return o.createElement(t.MenuItem,{key:n,onClick:function(){e(),a(n)}},"".concat(Math.round(100*n),"%"))})))},offset:f,closeOnClickOutside:!0,closeOnEscape:!0})},p=function(e){var t=e.children,n=e.levels,r=e.store;return(t||function(e){return o.createElement(v,{levels:n,scale:e.scale,onZoom:e.onZoom})})({scale:c(r).scale,onZoom:function(e){var t=r.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,testId:"zoom__in-button",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,testId:"zoom__out-button",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),testId:"zoom__in-menu",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),testId:"zoom__out-menu",onClick:n},c)}; | ||
/*! ***************************************************************************** | ||
@@ -3,0 +3,0 @@ Copyright (c) Microsoft Corporation. |
{ | ||
"name": "@react-pdf-viewer/zoom", | ||
"version": "2.11.0", | ||
"version": "3.0.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.11.0" | ||
"@react-pdf-viewer/core": "3.0.0" | ||
}, | ||
@@ -53,3 +53,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "5e4074055f48210e89c1fdf5b1cc53d78d56be44" | ||
"gitHead": "db24bf8b47a1ef4ee9da726af7f66268468c3420" | ||
} |
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
29347
442
+ Added@react-pdf-viewer/core@3.0.0(transitive)
- Removed@react-pdf-viewer/core@2.11.0(transitive)
Updated@react-pdf-viewer/core@3.0.0