@react-pdf-viewer/zoom
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -5,4 +5,4 @@ 'use strict'; | ||
var core = require('@react-pdf-viewer/core'); | ||
var React = require('react'); | ||
var core = require('@react-pdf-viewer/core'); | ||
@@ -29,2 +29,8 @@ function _interopNamespace(e) { | ||
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" }))); }; | ||
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" }))); }; | ||
/****************************************************************************** | ||
@@ -213,5 +219,2 @@ Copyright (c) Microsoft Corporation. | ||
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" }))); }; | ||
var TOOLTIP_OFFSET$1 = { left: 0, top: 8 }; | ||
@@ -244,4 +247,8 @@ var ZoomInButton = function (_a) { | ||
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" }))); }; | ||
var ZoomInMenuItem = function (_a) { | ||
var onClick = _a.onClick; | ||
var l10n = React__namespace.useContext(core.LocalizationContext).l10n; | ||
var label = l10n && l10n.zoom ? l10n.zoom.zoomIn : 'Zoom in'; | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomInIcon, null), testId: "zoom__in-menu", onClick: onClick }, label)); | ||
}; | ||
@@ -275,9 +282,2 @@ var TOOLTIP_OFFSET = { left: 0, top: 8 }; | ||
var ZoomInMenuItem = function (_a) { | ||
var onClick = _a.onClick; | ||
var l10n = React__namespace.useContext(core.LocalizationContext).l10n; | ||
var label = l10n && l10n.zoom ? l10n.zoom.zoomIn : 'Zoom in'; | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(ZoomInIcon, null), testId: "zoom__in-menu", onClick: onClick }, label)); | ||
}; | ||
var ZoomOutMenuItem = function (_a) { | ||
@@ -284,0 +284,0 @@ var onClick = _a.onClick; |
@@ -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 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)};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(p,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(e){return o.createElement(l,null,(function(t){return o.createElement(v,r({levels:null==e?void 0:e.levels},t))}))}}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@react-pdf-viewer/core");function t(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 n=t(require("react")),o=function(){return n.createElement(e.Icon,{ignoreDirection:!0,size:16},n.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"}))},r=function(){return n.createElement(e.Icon,{ignoreDirection:!0,size:16},n.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"}))},c=function(){return c=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},c.apply(this,arguments)},a=function(e){var t=n.useState(e.get("scale")||0),o=t[0],r=t[1],c=function(e){r(e)};return n.useEffect((function(){return e.subscribe("scale",c),function(){e.unsubscribe("scale",c)}}),[]),{scale:o}},u=function(e){var t=e.children,o=e.store;return(t||function(e){return n.createElement(n.Fragment,null,"".concat(Math.round(100*e.scale),"%"))})({scale:a(o).scale})},i=[.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],l=function(e){return i.find((function(t){return t>e}))||e},m=function(e){var t=i.findIndex((function(t){return t>=e}));return-1===t||0===t?e:i[t-1]},s=function(t){var o=t.containerRef,r=t.store,c=function(t){if(!t.shiftKey&&!t.altKey&&(e.isMac()?t.metaKey:t.ctrlKey)){var n=o.current;if(n&&document.activeElement&&n.contains(document.activeElement)){var c=r.get("zoom");if(c){var a=r.get("scale")||1,u=1;switch(t.key){case"-":u=m(a);break;case"=":u=l(a);break;case"0":u=1;break;default:u=a}u!==a&&(t.preventDefault(),c(u))}}}};return n.useEffect((function(){if(o.current)return document.addEventListener("keydown",c),function(){document.removeEventListener("keydown",c)}}),[o.current]),n.createElement(n.Fragment,null)},f=[.5,.75,1,1.25,1.5,2,3,4],v={left:0,top:8},p=function(t){var o=t.levels,r=void 0===o?f:o,c=t.scale,a=t.onZoom,u=n.useContext(e.LocalizationContext).l10n,i=n.useContext(e.ThemeContext).direction===e.TextDirection.RightToLeft,l=u&&u.zoom?u.zoom.zoomDocument:"Zoom document";return n.createElement(e.Popover,{ariaControlsSuffix:"zoom",ariaHasPopup:"menu",position:e.Position.BottomCenter,target:function(t){return n.createElement(e.MinimalButton,{ariaLabel:l,testId:"zoom__popover-target",onClick:function(){t()}},n.createElement("span",{className:"rpv-zoom__popover-target"},n.createElement("span",{"data-testid":"zoom__popover-target-scale",className:e.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),"%"),n.createElement("span",{className:"rpv-zoom__popover-target-arrow"})))},content:function(t){return n.createElement(e.Menu,null,Object.keys(e.SpecialZoomLevel).map((function(o){var r=o;return n.createElement(e.MenuItem,{key:r,onClick:function(){t(),a(r)}},function(t){switch(t){case e.SpecialZoomLevel.ActualSize:return u&&u.zoom?u.zoom.actualSize:"Actual size";case e.SpecialZoomLevel.PageFit:return u&&u.zoom?u.zoom.pageFit:"Page fit";case e.SpecialZoomLevel.PageWidth:return u&&u.zoom?u.zoom.pageWidth:"Page width"}}(r))})),n.createElement(e.MenuDivider,null),r.map((function(o){return n.createElement(e.MenuItem,{key:o,onClick:function(){t(),a(o)}},"".concat(Math.round(100*o),"%"))})))},offset:v,closeOnClickOutside:!0,closeOnEscape:!0})},z=function(e){var t=e.children,o=e.levels,r=e.store;return(t||function(e){return n.createElement(p,{levels:o,scale:e.scale,onZoom:e.onZoom})})({scale:a(r).scale,onZoom:function(e){var t=r.get("zoom");t&&t(e)}})},E={left:0,top:8},d=function(t){var r=t.enableShortcuts,c=t.onClick,a=n.useContext(e.LocalizationContext).l10n,u=a&&a.zoom?a.zoom.zoomIn:"Zoom in",i=r?e.isMac()?"Meta+=":"Ctrl+=":"";return n.createElement(e.Tooltip,{ariaControlsSuffix:"zoom-in",position:e.Position.BottomCenter,target:n.createElement(e.MinimalButton,{ariaKeyShortcuts:i,ariaLabel:u,testId:"zoom__in-button",onClick:c},n.createElement(o,null)),content:function(){return u},offset:E})},C=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=a(o).scale;return(t||d)({enableShortcuts:n,onClick:function(){var e=o.get("zoom");e&&e(l(r))}})},h=function(t){var r=t.onClick,c=n.useContext(e.LocalizationContext).l10n,a=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return n.createElement(e.MenuItem,{icon:n.createElement(o,null),testId:"zoom__in-menu",onClick:r},a)},g={left:0,top:8},b=function(t){var o=t.enableShortcuts,c=t.onClick,a=n.useContext(e.LocalizationContext).l10n,u=a&&a.zoom?a.zoom.zoomOut:"Zoom out",i=o?e.isMac()?"Meta+-":"Ctrl+-":"";return n.createElement(e.Tooltip,{ariaControlsSuffix:"zoom-out",position:e.Position.BottomCenter,target:n.createElement(e.MinimalButton,{ariaKeyShortcuts:i,ariaLabel:u,testId:"zoom__out-button",onClick:c},n.createElement(r,null)),content:function(){return u},offset:g})},k=function(e){var t=e.children,n=e.enableShortcuts,o=e.store,r=a(o).scale;return(t||b)({enableShortcuts:n,onClick:function(){var e=o.get("zoom");e&&e(m(r))}})},M=function(t){var o=t.onClick,c=n.useContext(e.LocalizationContext).l10n,a=c&&c.zoom?c.zoom.zoomOut:"Zoom out";return n.createElement(e.MenuItem,{icon:n.createElement(r,null),testId:"zoom__out-menu",onClick:o},a)};exports.ZoomInIcon=o,exports.ZoomOutIcon=r,exports.zoomPlugin=function(t){var o=n.useMemo((function(){return Object.assign({},{enableShortcuts:!0},t)}),[]),r=n.useMemo((function(){return e.createStore({})}),[]),a=function(e){return n.createElement(C,c({enableShortcuts:o.enableShortcuts},e,{store:r}))},i=function(e){return n.createElement(k,c({enableShortcuts:o.enableShortcuts},e,{store:r}))},l=function(e){return n.createElement(z,c({},e,{store:r}))};return{renderViewer:function(e){var t=e.slot;if(!o.enableShortcuts)return t;var a={children:n.createElement(n.Fragment,null,n.createElement(s,{containerRef:e.containerRef,store:r}),t.children)};return c(c({},t),a)},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 n.createElement(u,c({},e,{store:r}))},ZoomIn:a,ZoomInButton:function(){return n.createElement(a,null,(function(e){return n.createElement(d,c({},e))}))},ZoomInMenuItem:function(e){return n.createElement(a,null,(function(t){return n.createElement(h,{onClick:function(){t.onClick(),e.onClick()}})}))},ZoomOut:i,ZoomOutButton:function(){return n.createElement(i,null,(function(e){return n.createElement(b,c({},e))}))},ZoomOutMenuItem:function(e){return n.createElement(i,null,(function(t){return n.createElement(M,{onClick:function(){t.onClick(),e.onClick()}})}))},Zoom:l,ZoomPopover:function(e){return n.createElement(l,null,(function(t){return n.createElement(p,c({levels:null==e?void 0:e.levels},t))}))}}}; |
@@ -9,5 +9,5 @@ /** | ||
import type { Plugin } from '@react-pdf-viewer/core'; | ||
import { SpecialZoomLevel } from '@react-pdf-viewer/core'; | ||
import * as React from 'react'; | ||
import { SpecialZoomLevel } from '@react-pdf-viewer/core'; | ||
import type { Plugin } from '@react-pdf-viewer/core'; | ||
@@ -14,0 +14,0 @@ // Types |
{ | ||
"name": "@react-pdf-viewer/zoom", | ||
"version": "3.3.1", | ||
"version": "3.3.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": "3.3.1" | ||
"@react-pdf-viewer/core": "3.3.2" | ||
}, | ||
@@ -53,3 +53,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "3cffac5b07d0745738913f28797527363c0b0594" | ||
"gitHead": "9da7355cc710985d46ac3a0e70c8d6ada994c1a9" | ||
} |
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
28465
+ Added@react-pdf-viewer/core@3.3.2(transitive)
- Removed@react-pdf-viewer/core@3.3.1(transitive)
Updated@react-pdf-viewer/core@3.3.2