Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@talaikis/pdf-viewer-react

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talaikis/pdf-viewer-react - npm Package Compare versions

Comparing version 2.1.9 to 2.1.10

2

dist/pdf-viewer-reactjs.js

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

"use strict";var e=require("@babel/runtime/helpers/typeof"),t=require("@babel/runtime/helpers/classCallCheck"),a=require("@babel/runtime/helpers/createClass"),n=require("@babel/runtime/helpers/assertThisInitialized"),l=require("@babel/runtime/helpers/inherits"),s=require("@babel/runtime/helpers/possibleConstructorReturn"),r=require("@babel/runtime/helpers/getPrototypeOf"),i=require("@babel/runtime/helpers/taggedTemplateLiteral"),o=require("react"),u=require("prop-types"),d=require("@emotion/react"),c=require("react-spinners/PuffLoader"),f=require("@babel/runtime/regenerator"),m=require("@babel/runtime/helpers/asyncToGenerator"),h=require("@babel/runtime/helpers/slicedToArray"),p=require("pdfjs-dist"),g=require("pdfjs-dist/build/pdf.worker.entry");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var R=b(e),v=b(t),E=b(a),x=b(n),k=b(l),w=b(s),C=b(r),N=b(i),y=b(o),S=b(u),q=b(c),Z=b(f),P=b(m),T=b(h),A=b(p),B=b(g),O=function(e){var t=e.message;return y.default.createElement("div",{className:"columns has-text-danger has-margin-top-5 is-mobile"},y.default.createElement("div",{className:"column is-4 has-text-right has-padding-5"},y.default.createElement("span",{className:"icon"},y.default.createElement("i",{className:"material-icons"},"error_outline"))),y.default.createElement("div",{className:"column is-8 has-text-left has-padding-5"},y.default.createElement("small",null,t)))};O.propTypes={message:S.default.string.isRequired},A.default.GlobalWorkerOptions.workerSrc=B.default;var I=null,L=function(e){var t=e.document,a=e.withCredentials,n=e.password,l=e.pageNum,s=e.scale,r=e.rotation,i=e.pageCount,u=e.changePage,d=e.showThumbnail,c=e.protectContent,f=e.watermark,m=e.alert,h=e.canvasCss,p=o.useState({status:!1,message:""}),g=T.default(p,2),b=g[0],R=g[1],v=o.useRef(null),E=o.useRef(null),x=o.useRef(null),k=o.useRef(!0),w=o.useState([]),C=T.default(w,2),N=C[0],S=C[1],q=o.useState([]),B=T.default(q,2),L=B[0],z=B[1],_=m||O,j=function(){var e=P.default(Z.default.mark((function e(){var l;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,l={withCredentials:a,password:n},null==t.url?l.data=atob(t.base64):l.url=t.url,e.next=5,A.default.getDocument(l).promise;case 5:return I=e.sent,e.next=8,D();case 8:return e.next=10,F();case 10:M(),i(I.numPages),e.next=18;break;case 14:e.prev=14,e.t0=e.catch(0),console.warn("Error while opening the document !\n",e.t0),R({status:!0,message:"Error while opening the document !"});case 18:case"end":return e.stop()}}),e,null,[[0,14]])})));return function(){return e.apply(this,arguments)}}(),D=function(){var e=P.default(Z.default.mark((function e(){var t,a,n,i,o,u,d,c,m,h,p,g,b,E,x;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,I.getPage(l);case 3:return t=e.sent,a=t.getViewport({scale:s,rotation:r}),(n=v.current).height=a.height,n.width=a.width,i=n.getContext("2d"),o={canvasContext:i,viewport:a},u=t.render(o),e.prev=11,e.next=14,u.promise;case 14:0!==Object.entries(f).length&&(d=f.text,c=f.diagonal,m=f.opacity,h=f.font,p=f.size,g=f.color,i.globalAlpha=m,i.font="".concat(p*s,"px ").concat(""!==h?h:"Comic Sans MS"),i.fillStyle=g,b=i.measureText(d),E=b.width,x=p*s,i.translate(a.width/2,a.height/2),c&&i.rotate(-.785),i.fillText(d,-E/2,x/2)),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(11),console.warn("Error occured while rendering !\n",e.t0),R({status:!0,message:"Error occured while rendering !"});case 21:e.next=27;break;case 23:e.prev=23,e.t1=e.catch(0),console.warn("Error while reading the pages !\n",e.t1),R({status:!0,message:"Error while reading the pages !"});case 27:case"end":return e.stop()}}),e,null,[[0,23],[11,17]])})));return function(){return e.apply(this,arguments)}}(),F=function(){var e=P.default(Z.default.mark((function e(){var t,a,n,l,s,r,i,o,u,c,m,h,p,g,b,R,v,x,k;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0===Object.entries(d).length){e.next=26;break}t=[],a=.1,n=0,1<=d.scale&&d.scale<=5&&(a=d.scale/10),-90!==d.rotationAngle&&90!==d.rotationAngle||(n=d.rotationAngle),l=1;case 7:if(!(l<=I.numPages)){e.next=25;break}return e.next=10,I.getPage(l);case 10:return s=e.sent,r=s.getViewport({scale:a,rotation:n}),(i=E.current).height=r.height,i.width=r.width,o=i.getContext("2d"),u={canvasContext:o,viewport:r},c=s.render(u),e.next=20,c.promise;case 20:0!==Object.entries(f).length&&(m=f.text,h=f.diagonal,p=f.opacity,g=f.font,b=f.size,R=f.color,o.globalAlpha=p,o.font="".concat(b*a,"px ").concat(""!==g?g:"Comic Sans MS"),o.fillStyle=R,v=o.measureText(m),x=v.width,k=b*a,o.translate(r.width/2,r.height/2),h&&o.rotate(-.785),o.fillText(m,-x/2,k/2)),t.push({image:i.toDataURL("image/png"),height:r.height,width:r.width});case 22:l++,e.next=7;break;case 25:z(t);case 26:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),M=function(){if(0!==Object.entries(d).length){for(var e=[],t=function(t){var a=L[t-1].image,n=L[t-1].height,s=L[t-1].width;e.push(y.default.createElement("img",{style:l===t?{height:n,width:s,display:"flex",cursor:"pointer",margin:"10px 20px",border:"5px solid rgba(58, 58, 64, 1)",boxShadow:"rgba(0, 0, 0, 0.6) 0 4px 8px 0, rgba(0, 0, 0, 0.58) 0 6px 20px 0"}:{height:n,width:s,display:"flex",cursor:"pointer",margin:"15px 25px",boxShadow:"rgba(0, 0, 0, 0.6) 0px 2px 2px 0px"},onClick:function(){return u(t)},ref:l===t?x:null,key:t,alt:"thumbnail of page ".concat(t),src:a}))},a=1;a<=L.length;a++)t(a);e.push(y.default.createElement("div",{key:0,style:{padding:"0px 10px"}})),S(e)}};return o.useEffect((function(){j()}),[t,n]),o.useEffect((function(){k.current?k.current=!1:(D(),M())}),[l,s,r,i]),o.useEffect((function(){null!==x.current&&0!==Object.entries(d).length&&x.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})),b.status?(i(-1),y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement(_,{message:b.message}))):0!==Object.entries(d).length?y.default.createElement(y.default.Fragment,null,y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement("canvas",{onContextMenu:function(e){return c?e.preventDefault():null},ref:v,width:"undefined"!=typeof window&&window.innerWidth,height:"undefined"!=typeof window&&window.innerHeight})),y.default.createElement("div",{style:{backgroundColor:"#EAE6DA",display:"flex",flexDirection:"row",overflowX:"auto"}},N),y.default.createElement("canvas",{ref:E,style:{display:"None"}})):y.default.createElement(y.default.Fragment,null,y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement("canvas",{onContextMenu:function(e){return c?e.preventDefault():null},ref:v,width:"undefined"!=typeof window&&window.innerWidth,height:"undefined"!=typeof window&&window.innerHeight})))};L.propTypes={document:S.default.any.isRequired,withCredentials:S.default.bool,password:S.default.string,pageNum:S.default.number.isRequired,scale:S.default.number.isRequired,rotation:S.default.number.isRequired,changePage:S.default.func,pageCount:S.default.func,showThumbnail:S.default.shape({scale:S.default.number,rotationAngle:S.default.number}),protectContent:S.default.bool,watermark:S.default.shape({text:S.default.string,diagonal:S.default.bool,opacity:S.default.string,size:S.default.string,color:S.default.string}),canvasCss:S.default.string},L.defaultProps={changePage:function(){},pageCount:function(){},showThumbnail:{},protectContent:!1,watermark:{},canvasCss:""};var z=function(e){var t=e.css,a=e.page,n=e.pages,l=e.handleNextClick,s=t||"button is-black is-marginless";return a===n?y.default.createElement("button",{className:s,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_right"))):y.default.createElement("button",{className:s,onClick:l},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_right")))};z.propTypes={css:S.default.string,page:S.default.number.isRequired,pages:S.default.number.isRequired,handleNextClick:S.default.func.isRequired};var _=function(e){var t=e.css,a=e.page,n=e.pages,l=t||"is-size-7 is-vcentered has-text-centered is-inline-flex has-padding-top-5 button is-black is-marginless has-margin-left-5 has-margin-right-5";return y.default.createElement("span",{className:l},"Page ".concat(a," / ").concat(n))};_.propTypes={css:S.default.string,page:S.default.number.isRequired,pages:S.default.number.isRequired};var j=function(e){var t=e.css,a=e.page,n=e.handlePrevClick,l=t||"button is-black is-marginless";return 1===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_left"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_left")))};j.propTypes={css:S.default.string,page:S.default.number.isRequired,handlePrevClick:S.default.func.isRequired};var D=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.maxScale,s=e.handleZoomIn,r=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5",i=l;return n>l&&(i=n),a.toFixed(2)===i.toFixed(2)?y.default.createElement("button",{className:r,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_in"))):y.default.createElement("button",{className:r,onClick:s},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_in")))};D.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,maxScale:S.default.number.isRequired,handleZoomIn:S.default.func.isRequired};var F=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.minScale,s=e.handleZoomOut,r=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5",i=l;return n<l&&(i=n),a.toFixed(2)===i.toFixed(2)?y.default.createElement("button",{className:r,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_out"))):y.default.createElement("button",{className:r,onClick:s},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_out")))};F.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,minScale:S.default.number.isRequired,handleZoomOut:S.default.func.isRequired};var M=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.handleResetZoom,s=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return a.toFixed(2)===n.toFixed(2)?y.default.createElement("button",{className:s,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh"))):y.default.createElement("button",{className:s,onClick:l},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh")))};M.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,handleResetZoom:S.default.func.isRequired};var W=function(e){var t=e.css,a=e.rotationAngle,n=e.handleRotateLeft,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return-90===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_left"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_left")))};W.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleRotateLeft:S.default.func.isRequired};var V=function(e){var t=e.css,a=e.rotationAngle,n=e.handleResetRotation,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return 0===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh")))};V.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleResetRotation:S.default.func.isRequired};var G=function(e){var t=e.css,a=e.rotationAngle,n=e.handleRotateRight,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return 90===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_right"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_right")))};G.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleRotateRight:S.default.func.isRequired};var H=function(e){var t=e.page,a=e.pages,n=e.scale,l=e.defaultScale,s=e.maxScale,r=e.minScale,i=e.rotationAngle,o=e.hideZoom,u=e.hideRotation,d=e.css,c=e.handlePrevClick,f=e.handleNextClick,m=e.handleZoomIn,h=e.handleResetZoom,p=e.handleZoomOut,g=e.handleRotateLeft,b=e.handleResetRotation,R=e.handleRotateRight;return y.default.createElement("div",{className:"columns is-gapless ".concat(d.navbarWrapper||"box is-mobile has-text-white has-background-black has-margin-top-15 has-margin-bottom-15")},o?y.default.createElement("div",{className:"column is-2"}):y.default.createElement("div",{className:"column is-2 buttons are-small has-addons"},y.default.createElement(F,{scale:n,minScale:r,defaultScale:l,css:d.zoomOutBtn,handleZoomOut:p}),y.default.createElement(M,{scale:n,defaultScale:l,css:d.resetZoomBtn,handleResetZoom:h}),y.default.createElement(D,{scale:n,maxScale:s,defaultScale:l,css:d.zoomInBtn,handleZoomIn:m})),y.default.createElement("div",{className:"column"}),y.default.createElement("div",{className:"column is-3 buttons are-small has-addons is-centered"},y.default.createElement(j,{css:d.previousPageBtn,page:t,pages:a,handlePrevClick:c}),y.default.createElement(_,{css:d.pageIndicator,page:t,pages:a}),y.default.createElement(z,{css:d.nextPageBtn,page:t,pages:a,handleNextClick:f})),y.default.createElement("div",{className:"column"}),u?y.default.createElement("div",{className:"column is-2"}):y.default.createElement("div",{className:"column is-2 buttons are-small has-addons is-right"},y.default.createElement(W,{css:d.rotateLeftBtn,rotationAngle:i,handleRotateLeft:g}),y.default.createElement(V,{css:d.resetRotationBtn,rotationAngle:i,handleResetRotation:b}),y.default.createElement(G,{css:d.rotateRightBtn,rotationAngle:i,handleRotateRight:R})))};function U(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,n=C.default(e);if(t){var l=C.default(this).constructor;a=Reflect.construct(n,arguments,l)}else a=n.apply(this,arguments);return w.default(this,a)}}function X(){var e=N.default(["\n display: block;\n margin: 15% auto;\n border-color: red;\n"]);return X=function(){return e},e}H.propTypes={page:S.default.number.isRequired,pages:S.default.number.isRequired,scale:S.default.number,defaultScale:S.default.number,maxScale:S.default.number,minScale:S.default.number,rotationAngle:S.default.number,hideZoom:S.default.bool,hideRotation:S.default.bool,css:S.default.shape({navbarWrapper:S.default.string,pages:S.default.string,pageIndicator:S.default.string,previousPageBtn:S.default.string,nextPageBtn:S.default.string,zoomOutBtn:S.default.string,resetZoomBtn:S.default.string,zoomInBtn:S.default.string,rotateLeftBtn:S.default.string,resetRotationBtn:S.default.string,rotateRightBtn:S.default.string}),elements:S.default.shape({previousPageBtn:S.default.any,nextPageBtn:S.default.any,pages:S.default.any}),handlePrevClick:S.default.func.isRequired,handleNextClick:S.default.func.isRequired,handleZoomIn:S.default.func.isRequired,handleResetZoom:S.default.func.isRequired,handleZoomOut:S.default.func.isRequired,handleRotateLeft:S.default.func.isRequired,handleResetRotation:S.default.func.isRequired,handleRotateRight:S.default.func.isRequired},H.defaultProps={css:{},elements:{}};var J=d.css(X()),K=function(){return y.default.createElement(q.default,{size:150,css:J,color:"red",loading:!0})},Q=function(e){k.default(a,e);var t=U(a);function a(e){var n;return v.default(this,a),(n=t.call(this,e)).state={page:n.props.page,pages:0,scale:n.props.scale,defaultScale:n.props.scale,rotationAngle:n.props.rotationAngle,isReady:!1},n.getPageCount=n.getPageCount.bind(x.default(n)),n.handleThumbnailClick=n.handleThumbnailClick.bind(x.default(n)),n.handlePrevClick=n.handlePrevClick.bind(x.default(n)),n.handleNextClick=n.handleNextClick.bind(x.default(n)),n.handleZoomIn=n.handleZoomIn.bind(x.default(n)),n.handleResetZoom=n.handleResetZoom.bind(x.default(n)),n.handleZoomOut=n.handleZoomOut.bind(x.default(n)),n.handleRotateLeft=n.handleRotateLeft.bind(x.default(n)),n.handleResetRotation=n.handleResetRotation.bind(x.default(n)),n.handleRotateRight=n.handleRotateRight.bind(x.default(n)),n}return E.default(a,[{key:"getPageCount",value:function(e){this.state.pages!==e&&(this.setState({pages:e,isReady:!0}),this.props.getMaxPageCount&&this.props.getMaxPageCount(e))}},{key:"handleThumbnailClick",value:function(e){this.state.page!==e&&this.setState({page:e})}},{key:"handlePrevClick",value:function(){1!==this.state.page&&(this.setState({page:this.state.page-1}),this.props.onPrevBtnClick&&this.props.onPrevBtnClick(this.state.page-1))}},{key:"handleNextClick",value:function(){this.state.page!==this.pages&&(this.setState({page:this.state.page+1}),this.props.onNextBtnClick&&this.props.onNextBtnClick(this.state.page+1))}},{key:"handleZoomIn",value:function(){var e=this.props.maxScale;this.state.defaultScale>this.props.maxScale&&(e=this.state.defaultScale),this.state.scale<e&&this.setState({scale:this.state.scale+this.props.scaleStep}),this.props.onZoom&&this.props.onZoom(this.state.scale+this.props.scaleStep)}},{key:"handleResetZoom",value:function(){this.setState({scale:this.state.defaultScale}),this.props.onZoom&&this.props.onZoom(this.state.defaultScale)}},{key:"handleZoomOut",value:function(){var e=this.props.minScale;this.state.defaultScale<this.props.minScale&&(e=this.state.defaultScale),this.state.scale>e&&this.setState({scale:this.state.scale-this.props.scaleStep}),this.props.onZoom&&this.props.onZoom(this.state.scale-this.props.scaleStep)}},{key:"handleRotateLeft",value:function(){-90!==this.state.rotationAngle&&this.setState({rotationAngle:-90}),this.props.onRotation&&this.props.onRotation(-90)}},{key:"handleResetRotation",value:function(){0!==this.state.rotationAngle&&this.setState({rotationAngle:0}),this.props.onRotation&&this.props.onRotation(0)}},{key:"handleRotateRight",value:function(){90!==this.state.rotationAngle&&this.setState({rotationAngle:90}),this.props.onRotation&&this.props.onRotation(90)}},{key:"render",value:function(){var e=this,t=this.props,a=t.document,n=t.withCredentials,l=t.password,s=(t.loader,t.maxScale),r=t.minScale,i=t.hideNavbar,o=t.hideZoom,u=t.hideRotation,d=t.navbarOnTop,c=t.navigation,f=t.css,m=t.canvasCss,h=t.onDocumentClick,p=t.showThumbnail,g=t.protectContent,b=t.watermark,v=t.alert,E=this.state,x=E.page,k=E.pages,w=E.scale,C=E.defaultScale,N=E.rotationAngle,S=c,q=y.default.createElement(L,{document:a,withCredentials:n,password:l,pageNum:x,scale:w,rotation:N,changePage:function(t){return e.handleThumbnailClick(t)},pageCount:function(t){return e.getPageCount(t)},showThumbnail:p,protectContent:g,watermark:b,alert:v,canvasCss:m}),Z=null;return!i&&k>0&&(Z=!c||c&&"object"===R.default(c)?y.default.createElement(H,{page:x,pages:k,scale:w,defaultScale:C,maxScale:s,minScale:r,rotationAngle:N,hideZoom:o,hideRotation:u,css:c?c.css:void 0,handleNextClick:this.handleNextClick,handlePrevClick:this.handlePrevClick,handleZoomIn:this.handleZoomIn,handleResetZoom:this.handleResetZoom,handleZoomOut:this.handleZoomOut,handleRotateLeft:this.handleRotateLeft,handleResetRotation:this.handleResetRotation,handleRotateRight:this.handleRotateRight}):y.default.createElement(S,{page:x,pages:k,scale:w,defaultScale:C,maxScale:s,minScale:r,rotationAngle:N,hideZoom:o,hideRotation:u,handleNextClick:this.handleNextClick,handlePrevClick:this.handlePrevClick,handleZoomIn:this.handleZoomIn,handleResetZoom:this.handleResetZoom,handleZoomOut:this.handleZoomOut,handleRotateLeft:this.handleRotateLeft,handleResetRotation:this.handleResetRotation,handleRotateRight:this.handleRotateRight})),y.default.createElement("div",{className:f||"container text-center"},y.default.createElement("div",{style:{display:this.state.isReady?"none":"block"}},y.default.createElement("div",{className:m||"",style:m?{}:{height:"1000px",overflow:"auto"}},y.default.createElement(K,null))),y.default.createElement("div",{style:{display:this.state.isReady?"block":"none"}},d?y.default.createElement("div",null,y.default.createElement("div",null,Z),y.default.createElement("div",{onClick:h},q)):y.default.createElement("div",null,y.default.createElement("div",{onClick:h},q),y.default.createElement("div",null,Z))))}}]),a}(y.default.Component);Q.propTypes={document:S.default.shape({url:S.default.string,base64:S.default.string}).isRequired,withCredentials:S.default.bool,password:S.default.string,loader:S.default.node,page:S.default.number,scale:S.default.number,scaleStep:S.default.number,maxScale:S.default.number,minScale:S.default.number,css:S.default.string,canvasCss:S.default.string,rotationAngle:S.default.number,onDocumentClick:S.default.func,onPrevBtnClick:S.default.func,onNextBtnClick:S.default.func,onZoom:S.default.func,onRotation:S.default.func,getMaxPageCount:S.default.func,hideNavbar:S.default.bool,navbarOnTop:S.default.bool,hideZoom:S.default.bool,hideRotation:S.default.bool,showThumbnail:S.default.shape({scale:S.default.number,rotationAngle:S.default.number}),protectContent:S.default.bool,watermark:S.default.shape({text:S.default.string,diagonal:S.default.bool,opacity:S.default.string,font:S.default.string,size:S.default.string,color:S.default.string}),alert:S.default.any,navigation:S.default.oneOfType([S.default.shape({css:S.default.shape({navbarWrapper:S.default.string,zoomOutBtn:S.default.string,resetZoomBtn:S.default.string,zoomInBtn:S.default.string,previousPageBtn:S.default.string,pageIndicator:S.default.string,nextPageBtn:S.default.string,rotateLeftBtn:S.default.string,resetRotationBtn:S.default.string,rotateRightBtn:S.default.string})}),S.default.any])},Q.defaultProps={page:1,withCredentials:!1,password:"",defaultScale:1,scale:1,scaleStep:1,maxScale:3,minScale:1,rotationAngle:0,hideNavbar:!1,hideZoom:!1,hideRotation:!1,navbarOnTop:!1,canvasCss:""},module.exports=Q;
"use strict";var e=require("@babel/runtime/helpers/typeof"),t=require("@babel/runtime/helpers/classCallCheck"),a=require("@babel/runtime/helpers/createClass"),n=require("@babel/runtime/helpers/assertThisInitialized"),l=require("@babel/runtime/helpers/inherits"),s=require("@babel/runtime/helpers/possibleConstructorReturn"),r=require("@babel/runtime/helpers/getPrototypeOf"),i=require("@babel/runtime/helpers/taggedTemplateLiteral"),o=require("react"),u=require("prop-types"),d=require("@emotion/react"),c=require("react-spinners/PuffLoader"),f=require("@babel/runtime/regenerator"),m=require("@babel/runtime/helpers/asyncToGenerator"),h=require("@babel/runtime/helpers/slicedToArray"),p=require("pdfjs-dist"),g=require("pdfjs-dist/build/pdf.worker.entry");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var R=b(e),v=b(t),E=b(a),x=b(n),k=b(l),w=b(s),C=b(r),N=b(i),y=b(o),S=b(u),q=b(c),Z=b(f),P=b(m),T=b(h),A=b(p),B=b(g),O=function(e){var t=e.message;return y.default.createElement("div",{className:"columns has-text-danger has-margin-top-5 is-mobile"},y.default.createElement("div",{className:"column is-4 has-text-right has-padding-5"},y.default.createElement("span",{className:"icon"},y.default.createElement("i",{className:"material-icons"},"error_outline"))),y.default.createElement("div",{className:"column is-8 has-text-left has-padding-5"},y.default.createElement("small",null,t)))};O.propTypes={message:S.default.string.isRequired},A.default.GlobalWorkerOptions.workerSrc=B.default;var I=null,L=function(e){var t=e.document,a=e.withCredentials,n=e.password,l=e.pageNum,s=e.scale,r=e.rotation,i=e.pageCount,u=e.changePage,d=e.showThumbnail,c=e.protectContent,f=e.watermark,m=e.alert,h=e.canvasCss,p=o.useState({status:!1,message:""}),g=T.default(p,2),b=g[0],R=g[1],v=o.useRef(null),E=o.useRef(null),x=o.useRef(null),k=o.useRef(!0),w=o.useState([]),C=T.default(w,2),N=C[0],S=C[1],q=o.useState([]),B=T.default(q,2),L=B[0],z=B[1],_=m||O,j=function(){var e=P.default(Z.default.mark((function e(){var l;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,l={withCredentials:a,password:n},null==t.url?l.data=atob(t.base64):l.url=t.url,e.next=5,A.default.getDocument(l).promise;case 5:return I=e.sent,e.next=8,D();case 8:return e.next=10,F();case 10:M(),i(I.numPages),e.next=18;break;case 14:e.prev=14,e.t0=e.catch(0),console.warn("Error while opening the document !\n",e.t0),R({status:!0,message:"Error while opening the document !"});case 18:case"end":return e.stop()}}),e,null,[[0,14]])})));return function(){return e.apply(this,arguments)}}(),D=function(){var e=P.default(Z.default.mark((function e(){var t,a,n,i,o,u,d,c,m,h,p,g,b,E,x;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,I.getPage(l);case 3:return t=e.sent,a=t.getViewport({scale:s,rotation:r}),(n=v.current).height=a.height,n.width=a.width,i=n.getContext("2d"),o={canvasContext:i,viewport:a},u=t.render(o),e.prev=11,e.next=14,u.promise;case 14:0!==Object.entries(f).length&&(d=f.text,c=f.diagonal,m=f.opacity,h=f.font,p=f.size,g=f.color,i.globalAlpha=m,i.font="".concat(p*s,"px ").concat(""!==h?h:"Comic Sans MS"),i.fillStyle=g,b=i.measureText(d),E=b.width,x=p*s,i.translate(a.width/2,a.height/2),c&&i.rotate(-.785),i.fillText(d,-E/2,x/2)),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(11),console.warn("Error occured while rendering !\n",e.t0),R({status:!0,message:"Error occured while rendering !"});case 21:e.next=27;break;case 23:e.prev=23,e.t1=e.catch(0),console.warn("Error while reading the pages !\n",e.t1),R({status:!0,message:"Error while reading the pages !"});case 27:case"end":return e.stop()}}),e,null,[[0,23],[11,17]])})));return function(){return e.apply(this,arguments)}}(),F=function(){var e=P.default(Z.default.mark((function e(){var t,a,n,l,s,r,i,o,u,c,m,h,p,g,b,R,v,x,k;return Z.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0===Object.entries(d).length){e.next=26;break}t=[],a=.1,n=0,1<=d.scale&&d.scale<=5&&(a=d.scale/10),-90!==d.rotationAngle&&90!==d.rotationAngle||(n=d.rotationAngle),l=1;case 7:if(!(l<=I.numPages)){e.next=25;break}return e.next=10,I.getPage(l);case 10:return s=e.sent,r=s.getViewport({scale:a,rotation:n}),(i=E.current).height=r.height,i.width=r.width,o=i.getContext("2d"),u={canvasContext:o,viewport:r},c=s.render(u),e.next=20,c.promise;case 20:0!==Object.entries(f).length&&(m=f.text,h=f.diagonal,p=f.opacity,g=f.font,b=f.size,R=f.color,o.globalAlpha=p,o.font="".concat(b*a,"px ").concat(""!==g?g:"Comic Sans MS"),o.fillStyle=R,v=o.measureText(m),x=v.width,k=b*a,o.translate(r.width/2,r.height/2),h&&o.rotate(-.785),o.fillText(m,-x/2,k/2)),t.push({image:i.toDataURL("image/png"),height:r.height,width:r.width});case 22:l++,e.next=7;break;case 25:z(t);case 26:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),M=function(){if(0!==Object.entries(d).length){for(var e=[],t=function(t){var a=L[t-1].image,n=L[t-1].height,s=L[t-1].width;e.push(y.default.createElement("img",{style:l===t?{height:n,width:s,display:"flex",cursor:"pointer",margin:"10px 20px",border:"5px solid rgba(58, 58, 64, 1)",boxShadow:"rgba(0, 0, 0, 0.6) 0 4px 8px 0, rgba(0, 0, 0, 0.58) 0 6px 20px 0"}:{height:n,width:s,display:"flex",cursor:"pointer",margin:"15px 25px",boxShadow:"rgba(0, 0, 0, 0.6) 0px 2px 2px 0px"},onClick:function(){return u(t)},ref:l===t?x:null,key:t,alt:"thumbnail of page ".concat(t),src:a}))},a=1;a<=L.length;a++)t(a);e.push(y.default.createElement("div",{key:0,style:{padding:"0px 10px"}})),S(e)}};return o.useEffect((function(){j()}),[t,n]),o.useEffect((function(){k.current?k.current=!1:(D(),M())}),[l,s,r,i]),o.useEffect((function(){null!==x.current&&0!==Object.entries(d).length&&x.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})),b.status?(i(-1),y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement(_,{message:b.message}))):0!==Object.entries(d).length?y.default.createElement(y.default.Fragment,null,y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement("canvas",{onContextMenu:function(e){return c?e.preventDefault():null},ref:v,width:"undefined"!=typeof window&&window.innerWidth,height:"undefined"!=typeof window&&window.innerHeight})),y.default.createElement("div",{style:{backgroundColor:"#EAE6DA",display:"flex",flexDirection:"row",overflowX:"auto"}},N),y.default.createElement("canvas",{ref:E,style:{display:"None"}})):y.default.createElement(y.default.Fragment,null,y.default.createElement("div",{className:h||"",style:h?{}:{height:"1000px",overflow:"auto"}},y.default.createElement("canvas",{onContextMenu:function(e){return c?e.preventDefault():null},ref:v,width:"undefined"!=typeof window&&window.innerWidth,height:"undefined"!=typeof window&&window.innerHeight})))};L.propTypes={document:S.default.any.isRequired,withCredentials:S.default.bool,password:S.default.string,pageNum:S.default.number.isRequired,scale:S.default.number.isRequired,rotation:S.default.number.isRequired,changePage:S.default.func,pageCount:S.default.func,showThumbnail:S.default.shape({scale:S.default.number,rotationAngle:S.default.number}),protectContent:S.default.bool,watermark:S.default.shape({text:S.default.string,diagonal:S.default.bool,opacity:S.default.string,size:S.default.string,color:S.default.string}),canvasCss:S.default.string},L.defaultProps={changePage:function(){},pageCount:function(){},showThumbnail:{},protectContent:!1,watermark:{},canvasCss:""};var z=function(e){var t=e.css,a=e.page,n=e.pages,l=e.handleNextClick,s=t||"button is-black is-marginless";return a===n?y.default.createElement("button",{className:s,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_right"))):y.default.createElement("button",{className:s,onClick:l},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_right")))};z.propTypes={css:S.default.string,page:S.default.number.isRequired,pages:S.default.number.isRequired,handleNextClick:S.default.func.isRequired};var _=function(e){var t=e.css,a=e.page,n=e.pages,l=t||"is-size-7 is-vcentered has-text-centered is-inline-flex has-padding-top-5 button is-black is-marginless has-margin-left-5 has-margin-right-5";return y.default.createElement("span",{className:l},"Page ".concat(a," / ").concat(n))};_.propTypes={css:S.default.string,page:S.default.number.isRequired,pages:S.default.number.isRequired};var j=function(e){var t=e.css,a=e.page,n=e.handlePrevClick,l=t||"button is-black is-marginless";return 1===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_left"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"keyboard_arrow_left")))};j.propTypes={css:S.default.string,page:S.default.number.isRequired,handlePrevClick:S.default.func.isRequired};var D=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.maxScale,s=e.handleZoomIn,r=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5",i=l;return n>l&&(i=n),a.toFixed(2)===i.toFixed(2)?y.default.createElement("button",{className:r,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_in"))):y.default.createElement("button",{className:r,onClick:s},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_in")))};D.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,maxScale:S.default.number.isRequired,handleZoomIn:S.default.func.isRequired};var F=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.minScale,s=e.handleZoomOut,r=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5",i=l;return n<l&&(i=n),a.toFixed(2)===i.toFixed(2)?y.default.createElement("button",{className:r,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_out"))):y.default.createElement("button",{className:r,onClick:s},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"zoom_out")))};F.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,minScale:S.default.number.isRequired,handleZoomOut:S.default.func.isRequired};var M=function(e){var t=e.css,a=e.scale,n=e.defaultScale,l=e.handleResetZoom,s=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return a.toFixed(2)===n.toFixed(2)?y.default.createElement("button",{className:s,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh"))):y.default.createElement("button",{className:s,onClick:l},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh")))};M.propTypes={css:S.default.string,scale:S.default.number.isRequired,defaultScale:S.default.number.isRequired,handleResetZoom:S.default.func.isRequired};var W=function(e){var t=e.css,a=e.rotationAngle,n=e.handleRotateLeft,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return-90===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_left"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_left")))};W.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleRotateLeft:S.default.func.isRequired};var V=function(e){var t=e.css,a=e.rotationAngle,n=e.handleResetRotation,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return 0===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"refresh")))};V.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleResetRotation:S.default.func.isRequired};var G=function(e){var t=e.css,a=e.rotationAngle,n=e.handleRotateRight,l=t||"button is-black is-marginless has-margin-left-5 has-margin-right-5";return 90===a?y.default.createElement("button",{className:l,disabled:!0},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_right"))):y.default.createElement("button",{className:l,onClick:n},y.default.createElement("span",{className:"icon is-small"},y.default.createElement("i",{className:"material-icons"},"rotate_right")))};G.propTypes={css:S.default.string,rotationAngle:S.default.number.isRequired,handleRotateRight:S.default.func.isRequired};var H=function(e){var t=e.page,a=e.pages,n=e.scale,l=e.defaultScale,s=e.maxScale,r=e.minScale,i=e.rotationAngle,o=e.hideZoom,u=e.hideRotation,d=e.css,c=e.handlePrevClick,f=e.handleNextClick,m=e.handleZoomIn,h=e.handleResetZoom,p=e.handleZoomOut,g=e.handleRotateLeft,b=e.handleResetRotation,R=e.handleRotateRight;return y.default.createElement("div",{className:"columns is-gapless ".concat(d.navbarWrapper||"box is-mobile has-text-white has-background-black has-margin-top-15 has-margin-bottom-15")},o?y.default.createElement("div",{className:"column is-2"}):y.default.createElement("div",{className:"column is-2 buttons are-small has-addons"},y.default.createElement(F,{scale:n,minScale:r,defaultScale:l,css:d.zoomOutBtn,handleZoomOut:p}),y.default.createElement(M,{scale:n,defaultScale:l,css:d.resetZoomBtn,handleResetZoom:h}),y.default.createElement(D,{scale:n,maxScale:s,defaultScale:l,css:d.zoomInBtn,handleZoomIn:m})),y.default.createElement("div",{className:"column"}),y.default.createElement("div",{className:"column is-3 buttons are-small has-addons is-centered"},y.default.createElement(j,{css:d.previousPageBtn,page:t,pages:a,handlePrevClick:c}),y.default.createElement(_,{css:d.pageIndicator,page:t,pages:a}),y.default.createElement(z,{css:d.nextPageBtn,page:t,pages:a,handleNextClick:f})),y.default.createElement("div",{className:"column"}),u?y.default.createElement("div",{className:"column is-2"}):y.default.createElement("div",{className:"column is-2 buttons are-small has-addons is-right"},y.default.createElement(W,{css:d.rotateLeftBtn,rotationAngle:i,handleRotateLeft:g}),y.default.createElement(V,{css:d.resetRotationBtn,rotationAngle:i,handleResetRotation:b}),y.default.createElement(G,{css:d.rotateRightBtn,rotationAngle:i,handleRotateRight:R})))};function U(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,n=C.default(e);if(t){var l=C.default(this).constructor;a=Reflect.construct(n,arguments,l)}else a=n.apply(this,arguments);return w.default(this,a)}}function X(){var e=N.default(["\n display: block;\n margin: 15% auto;\n border-color: red;\n"]);return X=function(){return e},e}H.propTypes={page:S.default.number.isRequired,pages:S.default.number.isRequired,scale:S.default.number,defaultScale:S.default.number,maxScale:S.default.number,minScale:S.default.number,rotationAngle:S.default.number,hideZoom:S.default.bool,hideRotation:S.default.bool,css:S.default.shape({navbarWrapper:S.default.string,pages:S.default.string,pageIndicator:S.default.string,previousPageBtn:S.default.string,nextPageBtn:S.default.string,zoomOutBtn:S.default.string,resetZoomBtn:S.default.string,zoomInBtn:S.default.string,rotateLeftBtn:S.default.string,resetRotationBtn:S.default.string,rotateRightBtn:S.default.string}),elements:S.default.shape({previousPageBtn:S.default.any,nextPageBtn:S.default.any,pages:S.default.any}),handlePrevClick:S.default.func.isRequired,handleNextClick:S.default.func.isRequired,handleZoomIn:S.default.func.isRequired,handleResetZoom:S.default.func.isRequired,handleZoomOut:S.default.func.isRequired,handleRotateLeft:S.default.func.isRequired,handleResetRotation:S.default.func.isRequired,handleRotateRight:S.default.func.isRequired},H.defaultProps={css:{},elements:{}};var J=d.css(X()),K=function(){return y.default.createElement(q.default,{size:150,css:J,color:"red",loading:!0})},Q=function(e){k.default(a,e);var t=U(a);function a(e){var n;return v.default(this,a),(n=t.call(this,e)).state={page:n.props.page,pages:0,scale:n.props.scale,defaultScale:n.props.scale,rotationAngle:n.props.rotationAngle,isReady:!1},n.getPageCount=n.getPageCount.bind(x.default(n)),n.handleThumbnailClick=n.handleThumbnailClick.bind(x.default(n)),n.handlePrevClick=n.handlePrevClick.bind(x.default(n)),n.handleNextClick=n.handleNextClick.bind(x.default(n)),n.handleZoomIn=n.handleZoomIn.bind(x.default(n)),n.handleResetZoom=n.handleResetZoom.bind(x.default(n)),n.handleZoomOut=n.handleZoomOut.bind(x.default(n)),n.handleRotateLeft=n.handleRotateLeft.bind(x.default(n)),n.handleResetRotation=n.handleResetRotation.bind(x.default(n)),n.handleRotateRight=n.handleRotateRight.bind(x.default(n)),n}return E.default(a,[{key:"getPageCount",value:function(e){this.state.pages!==e&&(this.setState({pages:e,isReady:!0}),this.props.getMaxPageCount&&this.props.getMaxPageCount(e))}},{key:"handleThumbnailClick",value:function(e){this.state.page!==e&&this.setState({page:e})}},{key:"handlePrevClick",value:function(){1!==this.state.page&&(this.setState({page:this.state.page-1}),this.props.onPrevBtnClick&&this.props.onPrevBtnClick(this.state.page-1))}},{key:"handleNextClick",value:function(){this.state.page!==this.pages&&(this.setState({page:this.state.page+1}),this.props.onNextBtnClick&&this.props.onNextBtnClick(this.state.page+1))}},{key:"handleZoomIn",value:function(){var e=this.props.maxScale;this.state.defaultScale>this.props.maxScale&&(e=this.state.defaultScale),this.state.scale<e&&this.setState({scale:this.state.scale+this.props.scaleStep}),this.props.onZoom&&this.props.onZoom(this.state.scale+this.props.scaleStep)}},{key:"handleResetZoom",value:function(){this.setState({scale:this.state.defaultScale}),this.props.onZoom&&this.props.onZoom(this.state.defaultScale)}},{key:"handleZoomOut",value:function(){var e=this.props.minScale;this.state.defaultScale<this.props.minScale&&(e=this.state.defaultScale),this.state.scale>e&&this.setState({scale:this.state.scale-this.props.scaleStep}),this.props.onZoom&&this.props.onZoom(this.state.scale-this.props.scaleStep)}},{key:"handleRotateLeft",value:function(){-90!==this.state.rotationAngle&&this.setState({rotationAngle:-90}),this.props.onRotation&&this.props.onRotation(-90)}},{key:"handleResetRotation",value:function(){0!==this.state.rotationAngle&&this.setState({rotationAngle:0}),this.props.onRotation&&this.props.onRotation(0)}},{key:"handleRotateRight",value:function(){90!==this.state.rotationAngle&&this.setState({rotationAngle:90}),this.props.onRotation&&this.props.onRotation(90)}},{key:"render",value:function(){var e=this,t=this.props,a=t.document,n=t.withCredentials,l=t.password;t.loader;var s=t.maxScale,r=t.minScale,i=t.hideNavbar,o=t.hideZoom,u=t.hideRotation,d=t.navbarOnTop,c=t.navigation,f=t.css,m=t.canvasCss,h=t.onDocumentClick,p=t.showThumbnail,g=t.protectContent,b=t.watermark,v=t.alert,E=this.state,x=E.page,k=E.pages,w=E.scale,C=E.defaultScale,N=E.rotationAngle,S=c,q=y.default.createElement(L,{document:a,withCredentials:n,password:l,pageNum:x,scale:w,rotation:N,changePage:function(t){return e.handleThumbnailClick(t)},pageCount:function(t){return e.getPageCount(t)},showThumbnail:p,protectContent:g,watermark:b,alert:v,canvasCss:m}),Z=null;return!i&&k>0&&(Z=!c||c&&"object"===R.default(c)?y.default.createElement(H,{page:x,pages:k,scale:w,defaultScale:C,maxScale:s,minScale:r,rotationAngle:N,hideZoom:o,hideRotation:u,css:c?c.css:void 0,handleNextClick:this.handleNextClick,handlePrevClick:this.handlePrevClick,handleZoomIn:this.handleZoomIn,handleResetZoom:this.handleResetZoom,handleZoomOut:this.handleZoomOut,handleRotateLeft:this.handleRotateLeft,handleResetRotation:this.handleResetRotation,handleRotateRight:this.handleRotateRight}):y.default.createElement(S,{page:x,pages:k,scale:w,defaultScale:C,maxScale:s,minScale:r,rotationAngle:N,hideZoom:o,hideRotation:u,handleNextClick:this.handleNextClick,handlePrevClick:this.handlePrevClick,handleZoomIn:this.handleZoomIn,handleResetZoom:this.handleResetZoom,handleZoomOut:this.handleZoomOut,handleRotateLeft:this.handleRotateLeft,handleResetRotation:this.handleResetRotation,handleRotateRight:this.handleRotateRight})),y.default.createElement("div",{className:f||"container text-center"},y.default.createElement("div",{style:{display:this.state.isReady?"none":"block"}},y.default.createElement("div",{className:m||"",style:m?{}:{height:"1000px",overflow:"auto"}},y.default.createElement(K,null))),y.default.createElement("div",{style:{display:this.state.isReady?"block":"none"}},d?y.default.createElement("div",null,y.default.createElement("div",null,Z),y.default.createElement("div",{onClick:h},q)):y.default.createElement("div",null,y.default.createElement("div",{onClick:h},q),y.default.createElement("div",null,Z))))}}]),a}(y.default.Component);Q.propTypes={document:S.default.shape({url:S.default.string,base64:S.default.string}).isRequired,withCredentials:S.default.bool,password:S.default.string,loader:S.default.node,page:S.default.number,scale:S.default.number,scaleStep:S.default.number,maxScale:S.default.number,minScale:S.default.number,css:S.default.string,canvasCss:S.default.string,rotationAngle:S.default.number,onDocumentClick:S.default.func,onPrevBtnClick:S.default.func,onNextBtnClick:S.default.func,onZoom:S.default.func,onRotation:S.default.func,getMaxPageCount:S.default.func,hideNavbar:S.default.bool,navbarOnTop:S.default.bool,hideZoom:S.default.bool,hideRotation:S.default.bool,showThumbnail:S.default.shape({scale:S.default.number,rotationAngle:S.default.number}),protectContent:S.default.bool,watermark:S.default.shape({text:S.default.string,diagonal:S.default.bool,opacity:S.default.string,font:S.default.string,size:S.default.string,color:S.default.string}),alert:S.default.any,navigation:S.default.oneOfType([S.default.shape({css:S.default.shape({navbarWrapper:S.default.string,zoomOutBtn:S.default.string,resetZoomBtn:S.default.string,zoomInBtn:S.default.string,previousPageBtn:S.default.string,pageIndicator:S.default.string,nextPageBtn:S.default.string,rotateLeftBtn:S.default.string,resetRotationBtn:S.default.string,rotateRightBtn:S.default.string})}),S.default.any])},Q.defaultProps={page:1,withCredentials:!1,password:"",defaultScale:1,scale:1,scaleStep:1,maxScale:3,minScale:1,rotationAngle:0,hideNavbar:!1,hideZoom:!1,hideRotation:!1,navbarOnTop:!1,canvasCss:""},module.exports=Q;
{
"name": "@talaikis/pdf-viewer-react",
"version": "2.1.9",
"version": "2.1.10",
"description": "Simple react PDF viewer component with controls based on PDF.js.",

@@ -61,2 +61,3 @@ "source": "src/index.js",

"dependencies": {
"canvas": "^2.6.1",
"pdfjs-dist": "^2.4.456",

@@ -63,0 +64,0 @@ "prop-types": "^15.7.2",

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