@progress/kendo-react-pdf-viewer 7.5.0-develop.7 → 7.5.0-develop.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PDFViewer.js +1 -1
- package/PDFViewer.mjs +211 -193
- package/dist/cdn/js/kendo-react-pdf-viewer.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +9 -9
package/PDFViewer.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("react"),c=require("prop-types"),d=require("@progress/kendo-react-buttons"),ee=require("@progress/kendo-react-inputs"),qe=require("@progress/kendo-react-data-tools"),je=require("@progress/kendo-react-upload"),Ae=require("@progress/kendo-react-dropdowns"),Ve=require("@progress/kendo-react-indicators"),R=require("@progress/kendo-react-common"),Ue=require("@progress/kendo-react-intl"),g=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.entry.js");const te=require("./package-metadata.js"),i=require("@progress/kendo-pdfviewer-common"),a=require("./messages.js");function We(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const S in n)if(S!=="default"){const w=Object.getOwnPropertyDescriptor(n,S);Object.defineProperty(p,S,w.get?w:{enumerable:!0,get:()=>n[S]})}}return p.default=n,Object.freeze(p)}const e=We(Fe),ne=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],C={minZoom:.5,maxZoom:4,tools:[...ne],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:a.actualWidth},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:a.fitToWidth},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:a.fitToPage},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:i.DEFAULT_ZOOM_LEVEL},Ke=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let oe=0;function _e(){return oe++,oe}const He=(n,p)=>n.priority>p.priority?-1:n.priority<p.priority?1:0,N=e.forwardRef((n,p)=>{R.validatePackage(te.packageMetadata);const S=R.shouldShowValidationUI(te.packageMetadata),{zoom:w,zoomLevels:A=C.zoomLevels,defaultZoom:M=C.defaultZoom,minZoom:B=C.minZoom,maxZoom:O=C.maxZoom,zoomRate:z=C.zoomRate}=n,u=Ue.useLocalization(),s=e.useRef(null),[ae,L]=e.useState(M),f=w!==void 0?w:ae,Z=A.slice().sort(He).find(o=>o.value===f)||{text:f*100+"%",value:f,id:f,locationString:""};Z.locationString&&(Z.text=u.toLanguageString(Z.locationString,a.messages[Z.locationString]));const[h,D]=e.useState(!1),[re,b]=e.useState(!0),[P,V]=e.useState(0),[I,U]=e.useState(!1),[le,W]=e.useState(!1),[y,F]=e.useState(0),[v,E]=e.useState(0),[x,K]=e.useState(!1),[q,_]=e.useState(""),t=e.useMemo(()=>({}),[]);t.currentZoom=f,t.props=n;const H=e.useCallback(o=>{s.current&&s.current.style.setProperty("--scale-factor",String(o))},[]),k=e.useRef(null),T=e.useRef(null);e.useImperativeHandle(k,()=>({get element(){return T.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(p,()=>k.current);const ce=e.useCallback(()=>{if(t.props.onLoad){const o={target:k.current};t.props.onLoad.call(void 0,o)}},[]),G=e.useCallback((o,r,l)=>{if(n.onDownload){const m={target:k.current,blob:o,fileName:r,saveOptions:l};return n.onDownload.call(void 0,m)===!1}return!1},[n.onDownload]),se=e.useCallback(()=>{var o;t.scroller&&t.scroller.destroy(),t.scroller=new i.Scroller((o=s.current)==null?void 0:o.parentNode,{filter:".k-page",events:{}}),t.scroller.enablePanEventsTracking()},[]),ie=e.useCallback(o=>{const r=Array.from(o.querySelectorAll(".k-text-layer"));t.search=new i.SearchService({textContainers:r||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})},[]);t.done=e.useCallback(({pdfPages:o,pdfDoc:r,zoom:l})=>{t.document=r,t.pages=o,t.zoom=l,se(),b(!1),D(!0),ce(),s.current&&i.scrollToPage(s.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],b(!1),D(!1),n.onError){const r={error:typeof o=="string"?{message:o}:o,target:k.current};n.onError.call(void 0,r)}},[n.onError]),e.useEffect(()=>{s.current&&(n.url||n.data||n.arrayBuffer?(b(!0),i.removeChildren(s.current),i.loadPDF({url:n.url,data:n.data,arrayBuffer:n.arrayBuffer,dom:s.current,zoom:t.currentZoom,done:t.done,error:t.error}),H(t.currentZoom)):(t.document=null,t.pages=[],D(!1),b(!1),i.removeChildren(s.current)))},[n.url,n.data,n.arrayBuffer]);const J=e.useCallback((o,r)=>{s.current&&(b(!0),i.removeChildren(s.current),i.reloadDocument({pdfDoc:o,zoom:r,dom:s.current,done:l=>{t.pages=l,t.zoom=r,b(!1)},error:t.error}))},[]);e.useEffect(()=>{H(f),s.current&&t.document&&f!==t.zoom&&J(t.document,f)},[f,J]),e.useEffect(()=>()=>{t.scroller&&t.scroller.destroy(),t.search&&t.search.destroy(),t.document=null,t.pages=[]},[]);const ue=e.useCallback(()=>{W(!0),ie(s.current)},[]),de=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:x});E(l.length?1:0),F(l.length),_(r)},[x]),me=e.useCallback(()=>{const o=t.search.search({text:q,matchCase:!x});E(o.length?1:0),F(o.length),K(!x)},[x,q]),ge=e.useCallback(()=>{i.goToNextSearchMatch(t),E(v+1>y?1:v+1)},[v,y]),fe=e.useCallback(()=>{i.goToPreviousSearchMatch(t),E(v-1<1?y:v-1)},[v,y]),Q=e.useCallback(()=>{t.search.destroy(),E(0),F(0),K(!1),_(""),W(!1)},[]),he=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),E(v+1>y?1:v+1)):o.key==="Escape"&&Q()},[v,y]),ve=e.useCallback(o=>{if(s.current){const r=o.skip;i.scrollToPage(s.current,r);const l={page:r+1,target:k.current,syntheticEvent:o.syntheticEvent};n.onPageChange&&n.onPageChange.call(void 0,l)}V(o.skip)},[P,n.onPageChange]),ke=e.useCallback(o=>{if(T.current){const r=i.currentPage(T.current);if(r!==P){V(r);const l={page:r+1,target:k.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[P,n.onPageChange]),be=e.useCallback(o=>{const r=Math.min(t.currentZoom+z,O);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:k.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,O,n.onZoom]),ye=e.useCallback(o=>{const r=Math.max(t.currentZoom-z,B);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:k.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,B,n.onZoom]),pe=e.useCallback(o=>{const r=o.value===null?{text:"100%",value:1,id:100}:{...o.value};if(r.value===void 0){const m=parseFloat(r.text);typeof m=="number"&&!Number.isNaN(m)?r.value=m/100:r.value=1}let l=r?i.calculateZoomLevel(r.value,r.type,t.currentZoom,s.current):1;if(l=Math.round(l*100)/100,t.currentZoom!==l&&t.document&&(L(l),n.onZoom)){const m={zoom:l,target:k.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,m)}},[n.onZoom]),Ce=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),U(!0)},[]),Se=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),U(!1)},[]),Ee=e.useCallback(()=>{i.download({pdf:t.document,error:t.error},n.saveFileName,n.saveOptions,G)},[n.url,n.data,n.arrayBuffer,n.saveFileName,n.saveOptions,G]),xe=e.useCallback(()=>{b(!0);const o=l=>{t.error(typeof(l?l.message||l:null)=="string"?l.message||l:u.toLanguageString(a.popupBlocked,a.messages[a.popupBlocked]))},r=()=>{b(!1)};i.print(t.pages,r,o)},[]),we=e.useCallback(o=>{const r=o.newState;r[0]&&r[0].getRawFile&&r[0].getRawFile().arrayBuffer().then(m=>{if(s.current){b(!0),i.removeChildren(s.current);const j=t.props.zoom===void 0?M:t.props.zoom;i.loadPDF({arrayBuffer:m,dom:s.current,zoom:j,done:t.done,error:t.error}),L(j)}})},[M]),Ze=e.useCallback(o=>{const r=o.target;if(r instanceof Element&&r.parentNode){const l=r.closest(".k-toolbar"),m=l&&l.querySelector(".k-upload input");m&&m.click()}},[]),X=re&&e.createElement("div",{className:"k-loader-container k-loader-container-md k-loader-top"},e.createElement("div",{className:"k-loader-container-overlay k-overlay-light"}),e.createElement("div",{className:"k-loader-container-inner "},e.createElement(Ve.Loader,{size:"large"}))),ze=e.createElement(d.ButtonGroup,null,e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.zoomOut,a.messages[a.zoomOut]),disabled:f<=B||!h,onClick:ye,icon:"zoom-out",svgIcon:g.zoomOutIcon}),e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.zoomIn,a.messages[a.zoomIn]),disabled:f>=O||!h,onClick:be,icon:"zoom-in",svgIcon:g.zoomInIcon})),Le=e.createElement(Ae.ComboBox,{disabled:!h,data:A.map(o=>({...o,text:o.locationString?u.toLanguageString(o.locationString,a.messages[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:h?Z:null,allowCustom:!0,onChange:pe,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Pe=e.createElement(qe.Pager,{previousNext:!0,type:"input",skip:P,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:ve}),Ie=e.createElement(d.ToolbarSpacer,null),Te=e.createElement(d.ButtonGroup,null,e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.enableSelection,a.messages[a.enableSelection]),icon:"pointer",svgIcon:g.pointerIcon,disabled:!h,togglable:!0,selected:I&&h,onClick:Ce}),e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.enablePanning,a.messages[a.enablePanning]),icon:"hand",svgIcon:g.handIcon,disabled:!h,togglable:!0,selected:!I&&h,onClick:Se})),Re=e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.search,a.messages[a.search]),icon:"search",svgIcon:g.searchIcon,disabled:!h,onClick:ue}),Ne=e.createElement(e.Fragment,null,e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.open,a.messages[a.open]),icon:"folder-open",svgIcon:g.folderOpenIcon,onClick:Ze}),e.createElement("div",{style:{display:"none"}},e.createElement(je.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:we,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Me=e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.download,a.messages[a.download]),icon:"download",svgIcon:g.downloadIcon,disabled:!h,onClick:Ee}),Be=e.createElement(d.Button,{className:"k-toolbar-button",title:u.toLanguageString(a.print,a.messages[a.print]),icon:"print",svgIcon:g.printIcon,disabled:!h,onClick:xe}),Oe={pager:Pe,spacer:Ie,zoomInOut:ze,zoom:Le,selection:Te,search:Re,open:Ne,download:Me,print:Be},De=(n.tools||C.tools).map(o=>({...Oe[o],key:"toobar-tool-"+o+_e()})),Y=e.createElement(d.Toolbar,{buttons:Ke},...De),$=e.createElement("div",{className:R.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":I,"k-enable-panning":!I}),onScroll:ke},le&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(ee.TextBox,{value:q,onChange:de,placeholder:u.toLanguageString(a.search,a.messages[a.search]),autoFocus:!0,onKeyDown:he,suffix:()=>e.createElement(ee.InputSuffix,null,e.createElement(d.Button,{icon:"convert-lowercase",svgIcon:g.convertLowercaseIcon,title:u.toLanguageString(a.matchCase,a.messages[a.matchCase]),fillMode:"flat",togglable:!0,selected:x,onClick:me}))}),e.createElement("span",{className:"k-search-matches"},e.createElement("span",null,v)," of ",e.createElement("span",null,y)),e.createElement(d.Button,{title:u.toLanguageString(a.prevMatch,a.messages[a.prevMatch]),fillMode:"flat",icon:"arrow-up",svgIcon:g.arrowUpIcon,disabled:y===0,onClick:fe}),e.createElement(d.Button,{title:u.toLanguageString(a.nextMatch,a.messages[a.nextMatch]),fillMode:"flat",icon:"arrow-down",svgIcon:g.arrowDownIcon,disabled:y===0,onClick:ge}),e.createElement(d.Button,{title:u.toLanguageString(a.close,a.messages[a.close]),fillMode:"flat",icon:"x",svgIcon:g.xIcon,onClick:Q})),e.createElement("div",{ref:s,className:"k-pdf-viewer-pages"}));return e.createElement("div",{className:"k-pdf-viewer",style:n.style,ref:T},n.onRenderLoader?n.onRenderLoader.call(void 0,X||null):X,n.onRenderToolbar?n.onRenderToolbar.call(void 0,Y):Y,n.onRenderContent?n.onRenderContent.call(void 0,$):$,S&&e.createElement(R.WatermarkOverlay,null))});N.displayName="KendoReactPDFViewer";N.propTypes={url:c.string,data:c.string,arrayBuffer:c.any,typedArray:c.any,style:c.object,saveFileName:c.string,saveOptions:c.object,tools:c.arrayOf(c.oneOf(ne).isRequired),zoomLevels:c.arrayOf(c.any),zoom:c.number,defaultZoom:c.number,minZoom:c.number,maxZoom:c.number,zoomRate:c.number,onError:c.func,onLoad:c.func,onDownload:c.func,onRenderToolbar:c.func,onRenderContent:c.func,onRenderLoader:c.func,onZoom:c.func};N.defaultProps=C;exports.PDFViewer=N;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("react"),c=require("prop-types"),d=require("@progress/kendo-react-buttons"),A=require("@progress/kendo-react-inputs"),qe=require("@progress/kendo-react-data-tools"),je=require("@progress/kendo-react-upload"),Ae=require("@progress/kendo-react-dropdowns"),Ve=require("@progress/kendo-react-indicators"),T=require("@progress/kendo-react-common"),Ue=require("@progress/kendo-react-intl"),f=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.entry.js");const te=require("./package-metadata.js"),i=require("@progress/kendo-pdfviewer-common"),a=require("./messages.js");function We(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const E in n)if(E!=="default"){const w=Object.getOwnPropertyDescriptor(n,E);Object.defineProperty(p,E,w.get?w:{enumerable:!0,get:()=>n[E]})}}return p.default=n,Object.freeze(p)}const e=We(Fe),ne=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],C={minZoom:.5,maxZoom:4,tools:[...ne],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:a.actualWidth},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:a.fitToWidth},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:a.fitToPage},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:i.DEFAULT_ZOOM_LEVEL},Ke=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let oe=0;function _e(){return oe++,oe}const He=(n,p)=>n.priority>p.priority?-1:n.priority<p.priority?1:0,N=e.forwardRef((n,p)=>{T.validatePackage(te.packageMetadata);const E=T.shouldShowValidationUI(te.packageMetadata),{zoom:w,zoomLevels:V=C.zoomLevels,defaultZoom:R=C.defaultZoom,minZoom:B=C.minZoom,maxZoom:O=C.maxZoom,zoomRate:z=C.zoomRate}=n,u=Ue.useLocalization(),s=e.useRef(null),[ae,L]=e.useState(R),h=w!==void 0?w:ae,Z=V.slice().sort(He).find(o=>o.value===h)||{text:h*100+"%",value:h,id:h,locationString:""};Z.locationString&&(Z.text=u.toLanguageString(Z.locationString,a.messages[Z.locationString]));const[m,D]=e.useState(!1),[re,b]=e.useState(!0),[I,U]=e.useState(0),[P,W]=e.useState(!0),[le,K]=e.useState(!1),[y,F]=e.useState(0),[k,S]=e.useState(0),[x,_]=e.useState(!1),[q,H]=e.useState(""),t=e.useMemo(()=>({}),[]);t.currentZoom=h,t.props=n;const G=e.useCallback(o=>{s.current&&s.current.style.setProperty("--scale-factor",String(o))},[]),v=e.useRef(null),M=e.useRef(null);e.useImperativeHandle(v,()=>({get element(){return M.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(p,()=>v.current);const ce=e.useCallback(()=>{if(t.props.onLoad){const o={target:v.current};t.props.onLoad.call(void 0,o)}},[]),J=e.useCallback((o,r,l)=>{if(n.onDownload){const g={target:v.current,blob:o,fileName:r,saveOptions:l};return n.onDownload.call(void 0,g)===!1}return!1},[n.onDownload]),se=e.useCallback(()=>{var o;t.scroller&&t.scroller.destroy(),t.scroller=new i.Scroller((o=s.current)==null?void 0:o.parentNode,{filter:".k-page",events:{}}),t.scroller.disablePanEventsTracking()},[]),ie=e.useCallback(o=>{const r=Array.from(o.querySelectorAll(".k-text-layer"));t.search=new i.SearchService({textContainers:r||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})},[]);t.done=e.useCallback(({pdfPages:o,pdfDoc:r,zoom:l})=>{t.document=r,t.pages=o,t.zoom=l,se(),b(!1),D(!0),ce(),s.current&&i.scrollToPage(s.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],b(!1),D(!1),n.onError){const r={error:typeof o=="string"?{message:o}:o,target:v.current};n.onError.call(void 0,r)}},[n.onError]),e.useEffect(()=>{s.current&&(n.url||n.data||n.arrayBuffer?(b(!0),i.removeChildren(s.current),i.loadPDF({url:n.url,data:n.data,arrayBuffer:n.arrayBuffer,dom:s.current,zoom:t.currentZoom,done:t.done,error:t.error}),G(t.currentZoom)):(t.document=null,t.pages=[],D(!1),b(!1),i.removeChildren(s.current)))},[n.url,n.data,n.arrayBuffer]);const Q=e.useCallback((o,r)=>{s.current&&(b(!0),i.removeChildren(s.current),i.reloadDocument({pdfDoc:o,zoom:r,dom:s.current,done:l=>{t.pages=l,t.zoom=r,b(!1)},error:t.error}))},[]);e.useEffect(()=>{G(h),s.current&&t.document&&h!==t.zoom&&Q(t.document,h)},[h,Q]),e.useEffect(()=>()=>{t.scroller&&t.scroller.destroy(),t.search&&t.search.destroy(),t.document=null,t.pages=[]},[]);const ue=e.useCallback(()=>{K(!0),ie(s.current)},[]),de=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:x});S(l.length?1:0),F(l.length),H(r)},[x]),me=e.useCallback(()=>{const o=t.search.search({text:q,matchCase:!x});S(o.length?1:0),F(o.length),_(!x)},[x,q]),ge=e.useCallback(()=>{i.goToNextSearchMatch(t),S(k+1>y?1:k+1)},[k,y]),fe=e.useCallback(()=>{i.goToPreviousSearchMatch(t),S(k-1<1?y:k-1)},[k,y]),X=e.useCallback(()=>{t.search.destroy(),S(0),F(0),_(!1),H(""),K(!1)},[]),he=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),S(k+1>y?1:k+1)):o.key==="Escape"&&X()},[k,y]),ke=e.useCallback(o=>{if(s.current){const r=o.skip;i.scrollToPage(s.current,r);const l={page:r+1,target:v.current,syntheticEvent:o.syntheticEvent};n.onPageChange&&n.onPageChange.call(void 0,l)}U(o.skip)},[I,n.onPageChange]),ve=e.useCallback(o=>{if(M.current){const r=i.currentPage(M.current);if(r!==I){U(r);const l={page:r+1,target:v.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[I,n.onPageChange]),be=e.useCallback(o=>{const r=Math.min(t.currentZoom+z,O);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:v.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,O,n.onZoom]),ye=e.useCallback(o=>{const r=Math.max(t.currentZoom-z,B);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:v.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,B,n.onZoom]),pe=e.useCallback(o=>{const r=o.value===null?{text:"100%",value:1,id:100}:{...o.value};if(r.value===void 0){const g=parseFloat(r.text);typeof g=="number"&&!Number.isNaN(g)?r.value=g/100:r.value=1}let l=r?i.calculateZoomLevel(r.value,r.type,t.currentZoom,s.current):1;if(l=Math.round(l*100)/100,t.currentZoom!==l&&t.document&&(L(l),n.onZoom)){const g={zoom:l,target:v.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,g)}},[n.onZoom]),Ce=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),W(!0)},[]),Ee=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),W(!1)},[]),Se=e.useCallback(()=>{i.download({pdf:t.document,error:t.error},n.saveFileName,n.saveOptions,J)},[n.url,n.data,n.arrayBuffer,n.saveFileName,n.saveOptions,J]),xe=e.useCallback(()=>{b(!0);const o=l=>{t.error(typeof(l?l.message||l:null)=="string"?l.message||l:u.toLanguageString(a.popupBlocked,a.messages[a.popupBlocked]))},r=()=>{b(!1)};i.print(t.pages,r,o)},[]),we=e.useCallback(o=>{const r=o.newState;r[0]&&r[0].getRawFile&&r[0].getRawFile().arrayBuffer().then(g=>{if(s.current){b(!0),i.removeChildren(s.current);const j=t.props.zoom===void 0?R:t.props.zoom;i.loadPDF({arrayBuffer:g,dom:s.current,zoom:j,done:t.done,error:t.error}),L(j)}})},[R]),Ze=e.useCallback(o=>{const r=o.target;if(r instanceof Element&&r.parentNode){const l=r.closest(".k-toolbar"),g=l&&l.querySelector(".k-upload input");g&&g.click()}},[]),Y=re&&e.createElement("div",{className:"k-loader-container k-loader-container-md k-loader-top"},e.createElement("div",{className:"k-loader-container-overlay k-overlay-light"}),e.createElement("div",{className:"k-loader-container-inner "},e.createElement(Ve.Loader,{size:"large"}))),ze=e.createElement(d.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(d.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomOut,a.messages[a.zoomOut]),disabled:h<=B||!m,onClick:ye,icon:"zoom-out",svgIcon:f.zoomOutIcon}),e.createElement(d.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomIn,a.messages[a.zoomIn]),disabled:h>=O||!m,onClick:be,icon:"zoom-in",svgIcon:f.zoomInIcon})),Le=e.createElement(Ae.ComboBox,{className:"k-toolbar-combobox",disabled:!m,data:V.map(o=>({...o,text:o.locationString?u.toLanguageString(o.locationString,a.messages[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:m?Z:null,allowCustom:!0,onChange:pe,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Ie=e.createElement(qe.Pager,{disabled:!m,previousNext:!0,type:"input",skip:I,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:ke}),Pe=e.createElement(d.ToolbarSpacer,null),Me=e.createElement(d.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(d.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enableSelection,a.messages[a.enableSelection]),icon:"pointer",svgIcon:f.pointerIcon,disabled:!m,togglable:!0,selected:P&&m,onClick:Ce}),e.createElement(d.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enablePanning,a.messages[a.enablePanning]),icon:"hand",svgIcon:f.handIcon,disabled:!m,togglable:!0,selected:!P&&m,onClick:Ee})),Te=e.createElement(d.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.search,a.messages[a.search]),icon:"search",svgIcon:f.searchIcon,disabled:!m,onClick:ue}),Ne=e.createElement(e.Fragment,null,e.createElement(d.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.open,a.messages[a.open]),icon:"folder-open",svgIcon:f.folderOpenIcon,onClick:Ze}),e.createElement("div",{style:{display:"none"}},e.createElement(je.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:we,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Re=e.createElement(d.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.download,a.messages[a.download]),icon:"download",svgIcon:f.downloadIcon,disabled:!m,onClick:Se}),Be=e.createElement(d.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.print,a.messages[a.print]),icon:"print",svgIcon:f.printIcon,disabled:!m,onClick:xe}),Oe={pager:Ie,spacer:Pe,zoomInOut:ze,zoom:Le,selection:Me,search:Te,open:Ne,download:Re,print:Be},De=(n.tools||C.tools).map(o=>({...Oe[o],key:"toobar-tool-"+o+_e()})),$=e.createElement(d.Toolbar,{buttons:Ke},...De),ee=e.createElement("div",{className:T.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":P,"k-enable-panning":!P}),onScroll:ve},le&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(A.TextBox,{value:q,onChange:de,placeholder:u.toLanguageString(a.search,a.messages[a.search]),autoFocus:!0,onKeyDown:he,suffix:()=>e.createElement(e.Fragment,null,e.createElement(A.InputSeparator,null),e.createElement(A.InputSuffix,null,e.createElement(d.Button,{icon:"convert-lowercase",svgIcon:f.convertLowercaseIcon,title:u.toLanguageString(a.matchCase,a.messages[a.matchCase]),fillMode:"flat",togglable:!0,selected:x,onClick:me})))}),e.createElement("span",{className:"k-search-matches"},e.createElement("span",null,k)," of ",e.createElement("span",null,y)),e.createElement(d.Button,{title:u.toLanguageString(a.prevMatch,a.messages[a.prevMatch]),fillMode:"flat",icon:"arrow-up",svgIcon:f.arrowUpIcon,disabled:y===0,onClick:fe}),e.createElement(d.Button,{title:u.toLanguageString(a.nextMatch,a.messages[a.nextMatch]),fillMode:"flat",icon:"arrow-down",svgIcon:f.arrowDownIcon,disabled:y===0,onClick:ge}),e.createElement(d.Button,{title:u.toLanguageString(a.close,a.messages[a.close]),fillMode:"flat",icon:"x",svgIcon:f.xIcon,onClick:X})),e.createElement("div",{ref:s,className:"k-pdf-viewer-pages"}));return e.createElement("div",{className:"k-pdf-viewer",style:n.style,ref:M},n.onRenderLoader?n.onRenderLoader.call(void 0,Y||null):Y,n.onRenderToolbar?n.onRenderToolbar.call(void 0,$):$,n.onRenderContent?n.onRenderContent.call(void 0,ee):ee,E&&e.createElement(T.WatermarkOverlay,null))});N.displayName="KendoReactPDFViewer";N.propTypes={url:c.string,data:c.string,arrayBuffer:c.any,typedArray:c.any,style:c.object,saveFileName:c.string,saveOptions:c.object,tools:c.arrayOf(c.oneOf(ne).isRequired),zoomLevels:c.arrayOf(c.any),zoom:c.number,defaultZoom:c.number,minZoom:c.number,maxZoom:c.number,zoomRate:c.number,onError:c.func,onLoad:c.func,onDownload:c.func,onRenderToolbar:c.func,onRenderContent:c.func,onRenderLoader:c.func,onZoom:c.func};N.defaultProps=C;exports.PDFViewer=N;
|
package/PDFViewer.mjs
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as e from "react";
|
|
10
10
|
import l from "prop-types";
|
|
11
|
-
import { ButtonGroup as X, Button as
|
|
12
|
-
import { TextBox as tt,
|
|
11
|
+
import { ButtonGroup as X, Button as d, Toolbar as Ye, ToolbarSpacer as et } from "@progress/kendo-react-buttons";
|
|
12
|
+
import { TextBox as tt, InputSeparator as ot, InputSuffix as at } from "@progress/kendo-react-inputs";
|
|
13
13
|
import { Pager as nt } from "@progress/kendo-react-data-tools";
|
|
14
|
-
import { Upload as
|
|
15
|
-
import { ComboBox as
|
|
16
|
-
import { Loader as
|
|
17
|
-
import { validatePackage as
|
|
18
|
-
import { useLocalization as
|
|
19
|
-
import { zoomOutIcon as
|
|
14
|
+
import { Upload as rt } from "@progress/kendo-react-upload";
|
|
15
|
+
import { ComboBox as lt } from "@progress/kendo-react-dropdowns";
|
|
16
|
+
import { Loader as ct } from "@progress/kendo-react-indicators";
|
|
17
|
+
import { validatePackage as st, shouldShowValidationUI as it, classNames as ut, WatermarkOverlay as mt } from "@progress/kendo-react-common";
|
|
18
|
+
import { useLocalization as dt } from "@progress/kendo-react-intl";
|
|
19
|
+
import { zoomOutIcon as gt, zoomInIcon as ft, pointerIcon as ht, handIcon as vt, searchIcon as bt, folderOpenIcon as kt, downloadIcon as pt, printIcon as yt, convertLowercaseIcon as Ct, arrowUpIcon as Et, arrowDownIcon as St, xIcon as xt } from "@progress/kendo-svg-icons";
|
|
20
20
|
import "pdfjs-dist/build/pdf.worker.entry.js";
|
|
21
21
|
import { packageMetadata as Y } from "./package-metadata.mjs";
|
|
22
|
-
import { Scroller as
|
|
23
|
-
import { messages as i, zoomOut as
|
|
24
|
-
const
|
|
22
|
+
import { Scroller as wt, SearchService as Zt, scrollToPage as ee, removeChildren as z, loadPDF as te, reloadDocument as Lt, goToNextSearchMatch as oe, goToPreviousSearchMatch as zt, currentPage as It, calculateZoomLevel as Nt, download as Tt, print as Mt, DEFAULT_ZOOM_LEVEL as Pt } from "@progress/kendo-pdfviewer-common";
|
|
23
|
+
import { messages as i, zoomOut as ae, zoomIn as ne, zoomLevel as re, enableSelection as le, enablePanning as ce, search as I, open as se, download as ie, print as ue, matchCase as me, prevMatch as de, nextMatch as ge, close as fe, actualWidth as Rt, fitToWidth as Ft, fitToPage as Dt, popupBlocked as he } from "./messages.mjs";
|
|
24
|
+
const be = [
|
|
25
25
|
"pager",
|
|
26
26
|
"spacer",
|
|
27
27
|
"zoomInOut",
|
|
@@ -32,15 +32,15 @@ const ke = [
|
|
|
32
32
|
"open",
|
|
33
33
|
"download",
|
|
34
34
|
"print"
|
|
35
|
-
],
|
|
35
|
+
], k = {
|
|
36
36
|
minZoom: 0.5,
|
|
37
37
|
maxZoom: 4,
|
|
38
|
-
tools: [...
|
|
38
|
+
tools: [...be],
|
|
39
39
|
zoomRate: 0.25,
|
|
40
40
|
zoomLevels: [
|
|
41
|
-
{ id: 1, priority: 1, value: 1, text: "Actual width", type: "ActualWidth", locationString:
|
|
42
|
-
{ id: 2, priority: 2, value: 1, text: "Fit to width", type: "FitToWidth", locationString:
|
|
43
|
-
{ id: 3, priority: 3, value: 1, text: "Fit to page", type: "FitToPage", locationString:
|
|
41
|
+
{ id: 1, priority: 1, value: 1, text: "Actual width", type: "ActualWidth", locationString: Rt },
|
|
42
|
+
{ id: 2, priority: 2, value: 1, text: "Fit to width", type: "FitToWidth", locationString: Ft },
|
|
43
|
+
{ id: 3, priority: 3, value: 1, text: "Fit to page", type: "FitToPage", locationString: Dt },
|
|
44
44
|
{ id: 4, priority: 4, value: 0.5, text: "50%", type: "" },
|
|
45
45
|
{ id: 5, priority: 5, value: 0.75, text: "75%", type: "" },
|
|
46
46
|
{ id: 6, priority: 100, value: 1, text: "100%", type: "" },
|
|
@@ -50,191 +50,191 @@ const ke = [
|
|
|
50
50
|
{ id: 10, priority: 10, value: 3, text: "300%", type: "" },
|
|
51
51
|
{ id: 11, priority: 11, value: 4, text: "400%", type: "" }
|
|
52
52
|
],
|
|
53
|
-
defaultZoom:
|
|
54
|
-
},
|
|
53
|
+
defaultZoom: Pt
|
|
54
|
+
}, Ot = [
|
|
55
55
|
".k-toolbar > button",
|
|
56
56
|
".k-toolbar .k-combobox > input",
|
|
57
57
|
".k-toolbar .k-button-group > button",
|
|
58
58
|
".k-toolbar .k-pager > a",
|
|
59
59
|
".k-toolbar .k-pager input"
|
|
60
60
|
];
|
|
61
|
-
let
|
|
62
|
-
function
|
|
63
|
-
return
|
|
61
|
+
let ve = 0;
|
|
62
|
+
function Bt() {
|
|
63
|
+
return ve++, ve;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
65
|
+
const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1 : 0, O = e.forwardRef((a, E) => {
|
|
66
|
+
st(Y);
|
|
67
|
+
const ke = it(Y), {
|
|
68
68
|
zoom: B,
|
|
69
|
-
zoomLevels: A =
|
|
70
|
-
defaultZoom:
|
|
71
|
-
minZoom:
|
|
72
|
-
maxZoom:
|
|
73
|
-
zoomRate: S =
|
|
74
|
-
} =
|
|
75
|
-
|
|
76
|
-
const [
|
|
77
|
-
t.currentZoom =
|
|
69
|
+
zoomLevels: A = k.zoomLevels,
|
|
70
|
+
defaultZoom: N = k.defaultZoom,
|
|
71
|
+
minZoom: T = k.minZoom,
|
|
72
|
+
maxZoom: M = k.maxZoom,
|
|
73
|
+
zoomRate: S = k.zoomRate
|
|
74
|
+
} = a, s = dt(), c = e.useRef(null), [pe, x] = e.useState(N), g = B !== void 0 ? B : pe, C = A.slice().sort(At).find((o) => o.value === g) || { text: g * 100 + "%", value: g, id: g, locationString: "" };
|
|
75
|
+
C.locationString && (C.text = s.toLanguageString(C.locationString, i[C.locationString]));
|
|
76
|
+
const [u, P] = e.useState(!1), [ye, v] = e.useState(!0), [w, V] = e.useState(0), [Z, W] = e.useState(!0), [Ce, K] = e.useState(!1), [b, R] = e.useState(0), [f, p] = e.useState(0), [y, U] = e.useState(!1), [F, j] = e.useState(""), t = e.useMemo(() => ({}), []);
|
|
77
|
+
t.currentZoom = g, t.props = a;
|
|
78
78
|
const q = e.useCallback((o) => {
|
|
79
79
|
c.current && c.current.style.setProperty("--scale-factor", String(o));
|
|
80
|
-
}, []),
|
|
81
|
-
e.useImperativeHandle(
|
|
80
|
+
}, []), h = e.useRef(null), L = e.useRef(null);
|
|
81
|
+
e.useImperativeHandle(h, () => ({
|
|
82
82
|
get element() {
|
|
83
83
|
return L.current;
|
|
84
84
|
},
|
|
85
|
-
props:
|
|
85
|
+
props: a,
|
|
86
86
|
get pages() {
|
|
87
87
|
return t.pages;
|
|
88
88
|
},
|
|
89
89
|
get document() {
|
|
90
90
|
return t.document;
|
|
91
91
|
}
|
|
92
|
-
}), []), e.useImperativeHandle(
|
|
93
|
-
const
|
|
92
|
+
}), []), e.useImperativeHandle(E, () => h.current);
|
|
93
|
+
const Ee = e.useCallback(() => {
|
|
94
94
|
if (t.props.onLoad) {
|
|
95
|
-
const o = { target:
|
|
95
|
+
const o = { target: h.current };
|
|
96
96
|
t.props.onLoad.call(void 0, o);
|
|
97
97
|
}
|
|
98
|
-
}, []), H = e.useCallback((o,
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
target:
|
|
98
|
+
}, []), H = e.useCallback((o, n, r) => {
|
|
99
|
+
if (a.onDownload) {
|
|
100
|
+
const m = {
|
|
101
|
+
target: h.current,
|
|
102
102
|
blob: o,
|
|
103
|
-
fileName:
|
|
103
|
+
fileName: n,
|
|
104
104
|
saveOptions: r
|
|
105
105
|
};
|
|
106
|
-
return
|
|
106
|
+
return a.onDownload.call(void 0, m) === !1;
|
|
107
107
|
}
|
|
108
108
|
return !1;
|
|
109
|
-
}, [
|
|
109
|
+
}, [a.onDownload]), Se = e.useCallback(() => {
|
|
110
110
|
var o;
|
|
111
|
-
t.scroller && t.scroller.destroy(), t.scroller = new
|
|
111
|
+
t.scroller && t.scroller.destroy(), t.scroller = new wt((o = c.current) == null ? void 0 : o.parentNode, {
|
|
112
112
|
filter: ".k-page",
|
|
113
113
|
events: {}
|
|
114
|
-
}), t.scroller.
|
|
114
|
+
}), t.scroller.disablePanEventsTracking();
|
|
115
115
|
}, []), xe = e.useCallback((o) => {
|
|
116
|
-
const
|
|
117
|
-
t.search = new
|
|
118
|
-
textContainers:
|
|
116
|
+
const n = Array.from(o.querySelectorAll(".k-text-layer"));
|
|
117
|
+
t.search = new Zt({
|
|
118
|
+
textContainers: n || [],
|
|
119
119
|
highlightClass: "k-search-highlight",
|
|
120
120
|
highlightMarkClass: "k-search-highlight-mark",
|
|
121
121
|
charClass: "k-text-char"
|
|
122
122
|
});
|
|
123
123
|
}, []);
|
|
124
|
-
t.done = e.useCallback(({ pdfPages: o, pdfDoc:
|
|
125
|
-
t.document =
|
|
124
|
+
t.done = e.useCallback(({ pdfPages: o, pdfDoc: n, zoom: r }) => {
|
|
125
|
+
t.document = n, t.pages = o, t.zoom = r, Se(), v(!1), P(!0), Ee(), c.current && ee(c.current, 0);
|
|
126
126
|
}, []), t.error = e.useCallback((o) => {
|
|
127
|
-
if (t.document = null, t.pages = [],
|
|
128
|
-
const
|
|
127
|
+
if (t.document = null, t.pages = [], v(!1), P(!1), a.onError) {
|
|
128
|
+
const n = {
|
|
129
129
|
error: typeof o == "string" ? { message: o } : o,
|
|
130
|
-
target:
|
|
130
|
+
target: h.current
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
a.onError.call(void 0, n);
|
|
133
133
|
}
|
|
134
|
-
}, [
|
|
135
|
-
c.current && (
|
|
136
|
-
url:
|
|
137
|
-
data:
|
|
138
|
-
arrayBuffer:
|
|
134
|
+
}, [a.onError]), e.useEffect(() => {
|
|
135
|
+
c.current && (a.url || a.data || a.arrayBuffer ? (v(!0), z(c.current), te({
|
|
136
|
+
url: a.url,
|
|
137
|
+
data: a.data,
|
|
138
|
+
arrayBuffer: a.arrayBuffer,
|
|
139
139
|
dom: c.current,
|
|
140
140
|
zoom: t.currentZoom,
|
|
141
141
|
done: t.done,
|
|
142
142
|
error: t.error
|
|
143
|
-
}), q(t.currentZoom)) : (t.document = null, t.pages = [],
|
|
144
|
-
}, [
|
|
145
|
-
const $ = e.useCallback((o,
|
|
146
|
-
c.current && (
|
|
143
|
+
}), q(t.currentZoom)) : (t.document = null, t.pages = [], P(!1), v(!1), z(c.current)));
|
|
144
|
+
}, [a.url, a.data, a.arrayBuffer]);
|
|
145
|
+
const $ = e.useCallback((o, n) => {
|
|
146
|
+
c.current && (v(!0), z(c.current), Lt({
|
|
147
147
|
pdfDoc: o,
|
|
148
|
-
zoom:
|
|
148
|
+
zoom: n,
|
|
149
149
|
dom: c.current,
|
|
150
150
|
done: (r) => {
|
|
151
|
-
t.pages = r, t.zoom =
|
|
151
|
+
t.pages = r, t.zoom = n, v(!1);
|
|
152
152
|
},
|
|
153
153
|
error: t.error
|
|
154
154
|
}));
|
|
155
155
|
}, []);
|
|
156
156
|
e.useEffect(() => {
|
|
157
|
-
q(
|
|
158
|
-
}, [
|
|
157
|
+
q(g), c.current && t.document && g !== t.zoom && $(t.document, g);
|
|
158
|
+
}, [g, $]), e.useEffect(() => () => {
|
|
159
159
|
t.scroller && t.scroller.destroy(), t.search && t.search.destroy(), t.document = null, t.pages = [];
|
|
160
160
|
}, []);
|
|
161
161
|
const we = e.useCallback(() => {
|
|
162
162
|
K(!0), xe(c.current);
|
|
163
163
|
}, []), Ze = e.useCallback((o) => {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
const o = t.search.search({ text: F, matchCase: !
|
|
168
|
-
|
|
169
|
-
}, [
|
|
170
|
-
oe(t),
|
|
171
|
-
}, [f,
|
|
172
|
-
|
|
173
|
-
}, [f,
|
|
174
|
-
t.search.destroy(),
|
|
175
|
-
}, []),
|
|
176
|
-
o.key === "Enter" ? (o.preventDefault(), oe(t),
|
|
177
|
-
}, [f,
|
|
164
|
+
const n = o.value, r = t.search.search({ text: n, matchCase: y });
|
|
165
|
+
p(r.length ? 1 : 0), R(r.length), j(n);
|
|
166
|
+
}, [y]), Le = e.useCallback(() => {
|
|
167
|
+
const o = t.search.search({ text: F, matchCase: !y });
|
|
168
|
+
p(o.length ? 1 : 0), R(o.length), U(!y);
|
|
169
|
+
}, [y, F]), ze = e.useCallback(() => {
|
|
170
|
+
oe(t), p(f + 1 > b ? 1 : f + 1);
|
|
171
|
+
}, [f, b]), Ie = e.useCallback(() => {
|
|
172
|
+
zt(t), p(f - 1 < 1 ? b : f - 1);
|
|
173
|
+
}, [f, b]), _ = e.useCallback(() => {
|
|
174
|
+
t.search.destroy(), p(0), R(0), U(!1), j(""), K(!1);
|
|
175
|
+
}, []), Ne = e.useCallback((o) => {
|
|
176
|
+
o.key === "Enter" ? (o.preventDefault(), oe(t), p(f + 1 > b ? 1 : f + 1)) : o.key === "Escape" && _();
|
|
177
|
+
}, [f, b]), Te = e.useCallback((o) => {
|
|
178
178
|
if (c.current) {
|
|
179
|
-
const
|
|
180
|
-
ee(c.current,
|
|
179
|
+
const n = o.skip;
|
|
180
|
+
ee(c.current, n);
|
|
181
181
|
const r = {
|
|
182
|
-
page:
|
|
183
|
-
target:
|
|
182
|
+
page: n + 1,
|
|
183
|
+
target: h.current,
|
|
184
184
|
syntheticEvent: o.syntheticEvent
|
|
185
185
|
};
|
|
186
|
-
|
|
186
|
+
a.onPageChange && a.onPageChange.call(void 0, r);
|
|
187
187
|
}
|
|
188
188
|
V(o.skip);
|
|
189
|
-
}, [w,
|
|
189
|
+
}, [w, a.onPageChange]), Me = e.useCallback((o) => {
|
|
190
190
|
if (L.current) {
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
V(
|
|
191
|
+
const n = It(L.current);
|
|
192
|
+
if (n !== w) {
|
|
193
|
+
V(n);
|
|
194
194
|
const r = {
|
|
195
|
-
page:
|
|
196
|
-
target:
|
|
195
|
+
page: n + 1,
|
|
196
|
+
target: h.current,
|
|
197
197
|
syntheticEvent: o
|
|
198
198
|
};
|
|
199
|
-
|
|
199
|
+
a.onPageChange && a.onPageChange.call(void 0, r);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
}, [w,
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
202
|
+
}, [w, a.onPageChange]), Pe = e.useCallback((o) => {
|
|
203
|
+
const n = Math.min(t.currentZoom + S, M);
|
|
204
|
+
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
205
205
|
const r = {
|
|
206
|
-
zoom:
|
|
207
|
-
target:
|
|
206
|
+
zoom: n,
|
|
207
|
+
target: h.current,
|
|
208
208
|
syntheticEvent: o
|
|
209
209
|
};
|
|
210
|
-
|
|
210
|
+
a.onZoom.call(void 0, r);
|
|
211
211
|
}
|
|
212
|
-
}, [S,
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
212
|
+
}, [S, M, a.onZoom]), Re = e.useCallback((o) => {
|
|
213
|
+
const n = Math.max(t.currentZoom - S, T);
|
|
214
|
+
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
215
215
|
const r = {
|
|
216
|
-
zoom:
|
|
217
|
-
target:
|
|
216
|
+
zoom: n,
|
|
217
|
+
target: h.current,
|
|
218
218
|
syntheticEvent: o
|
|
219
219
|
};
|
|
220
|
-
|
|
220
|
+
a.onZoom.call(void 0, r);
|
|
221
221
|
}
|
|
222
|
-
}, [S,
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
typeof
|
|
222
|
+
}, [S, T, a.onZoom]), Fe = e.useCallback((o) => {
|
|
223
|
+
const n = o.value === null ? { text: "100%", value: 1, id: 100 } : { ...o.value };
|
|
224
|
+
if (n.value === void 0) {
|
|
225
|
+
const m = parseFloat(n.text);
|
|
226
|
+
typeof m == "number" && !Number.isNaN(m) ? n.value = m / 100 : n.value = 1;
|
|
227
227
|
}
|
|
228
|
-
let r =
|
|
229
|
-
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (x(r),
|
|
230
|
-
const
|
|
228
|
+
let r = n ? Nt(n.value, n.type, t.currentZoom, c.current) : 1;
|
|
229
|
+
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (x(r), a.onZoom)) {
|
|
230
|
+
const m = {
|
|
231
231
|
zoom: r,
|
|
232
|
-
target:
|
|
232
|
+
target: h.current,
|
|
233
233
|
syntheticEvent: o.syntheticEvent
|
|
234
234
|
};
|
|
235
|
-
|
|
235
|
+
a.onZoom.call(void 0, m);
|
|
236
236
|
}
|
|
237
|
-
}, [
|
|
237
|
+
}, [a.onZoom]), De = e.useCallback(() => {
|
|
238
238
|
t.scroller.disablePanEventsTracking(), W(!0);
|
|
239
239
|
}, []), Oe = e.useCallback(() => {
|
|
240
240
|
t.scroller.enablePanEventsTracking(), W(!1);
|
|
@@ -242,23 +242,23 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
242
242
|
Tt({
|
|
243
243
|
pdf: t.document,
|
|
244
244
|
error: t.error
|
|
245
|
-
},
|
|
246
|
-
}, [
|
|
247
|
-
|
|
245
|
+
}, a.saveFileName, a.saveOptions, H);
|
|
246
|
+
}, [a.url, a.data, a.arrayBuffer, a.saveFileName, a.saveOptions, H]), Ae = e.useCallback(() => {
|
|
247
|
+
v(!0);
|
|
248
248
|
const o = (r) => {
|
|
249
|
-
t.error(typeof (r ? r.message || r : null) == "string" ? r.message || r : s.toLanguageString(
|
|
250
|
-
},
|
|
251
|
-
|
|
249
|
+
t.error(typeof (r ? r.message || r : null) == "string" ? r.message || r : s.toLanguageString(he, i[he]));
|
|
250
|
+
}, n = () => {
|
|
251
|
+
v(!1);
|
|
252
252
|
};
|
|
253
|
-
|
|
253
|
+
Mt(t.pages, n, o);
|
|
254
254
|
}, []), Ve = e.useCallback((o) => {
|
|
255
|
-
const
|
|
256
|
-
|
|
255
|
+
const n = o.newState;
|
|
256
|
+
n[0] && n[0].getRawFile && n[0].getRawFile().arrayBuffer().then((m) => {
|
|
257
257
|
if (c.current) {
|
|
258
|
-
|
|
259
|
-
const D = t.props.zoom === void 0 ?
|
|
258
|
+
v(!0), z(c.current);
|
|
259
|
+
const D = t.props.zoom === void 0 ? N : t.props.zoom;
|
|
260
260
|
te({
|
|
261
|
-
arrayBuffer:
|
|
261
|
+
arrayBuffer: m,
|
|
262
262
|
dom: c.current,
|
|
263
263
|
zoom: D,
|
|
264
264
|
done: t.done,
|
|
@@ -266,36 +266,41 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
266
266
|
}), x(D);
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
|
-
}, [
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const r =
|
|
273
|
-
|
|
269
|
+
}, [N]), We = e.useCallback((o) => {
|
|
270
|
+
const n = o.target;
|
|
271
|
+
if (n instanceof Element && n.parentNode) {
|
|
272
|
+
const r = n.closest(".k-toolbar"), m = r && r.querySelector(".k-upload input");
|
|
273
|
+
m && m.click();
|
|
274
274
|
}
|
|
275
|
-
}, []), G =
|
|
276
|
-
|
|
275
|
+
}, []), G = ye && /* @__PURE__ */ e.createElement("div", { className: "k-loader-container k-loader-container-md k-loader-top" }, /* @__PURE__ */ e.createElement("div", { className: "k-loader-container-overlay k-overlay-light" }), /* @__PURE__ */ e.createElement("div", { className: "k-loader-container-inner " }, /* @__PURE__ */ e.createElement(ct, { size: "large" }))), Ke = /* @__PURE__ */ e.createElement(X, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
276
|
+
d,
|
|
277
277
|
{
|
|
278
|
-
className: "k-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
className: "k-group-start",
|
|
279
|
+
fillMode: "flat",
|
|
280
|
+
themeColor: "base",
|
|
281
|
+
title: s.toLanguageString(ae, i[ae]),
|
|
282
|
+
disabled: g <= T || !u,
|
|
281
283
|
onClick: Re,
|
|
282
284
|
icon: "zoom-out",
|
|
283
|
-
svgIcon:
|
|
285
|
+
svgIcon: gt
|
|
284
286
|
}
|
|
285
287
|
), /* @__PURE__ */ e.createElement(
|
|
286
|
-
|
|
288
|
+
d,
|
|
287
289
|
{
|
|
288
|
-
className: "k-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
className: "k-group-end",
|
|
291
|
+
fillMode: "flat",
|
|
292
|
+
themeColor: "base",
|
|
293
|
+
title: s.toLanguageString(ne, i[ne]),
|
|
294
|
+
disabled: g >= M || !u,
|
|
295
|
+
onClick: Pe,
|
|
292
296
|
icon: "zoom-in",
|
|
293
|
-
svgIcon:
|
|
297
|
+
svgIcon: ft
|
|
294
298
|
}
|
|
295
299
|
)), Ue = /* @__PURE__ */ e.createElement(
|
|
296
|
-
|
|
300
|
+
lt,
|
|
297
301
|
{
|
|
298
|
-
|
|
302
|
+
className: "k-toolbar-combobox",
|
|
303
|
+
disabled: !u,
|
|
299
304
|
data: A.map(
|
|
300
305
|
(o) => ({
|
|
301
306
|
...o,
|
|
@@ -304,7 +309,7 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
304
309
|
),
|
|
305
310
|
dataItemKey: "id",
|
|
306
311
|
textField: "text",
|
|
307
|
-
value:
|
|
312
|
+
value: u ? C : null,
|
|
308
313
|
allowCustom: !0,
|
|
309
314
|
onChange: Fe,
|
|
310
315
|
placeholder: s.toLanguageString(re, i[re])
|
|
@@ -312,59 +317,68 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
312
317
|
), je = /* @__PURE__ */ e.createElement(
|
|
313
318
|
nt,
|
|
314
319
|
{
|
|
320
|
+
disabled: !u,
|
|
315
321
|
previousNext: !0,
|
|
316
322
|
type: "input",
|
|
317
323
|
skip: w,
|
|
318
324
|
take: 1,
|
|
319
325
|
total: t.pages ? t.pages.length : 0,
|
|
320
326
|
info: !1,
|
|
321
|
-
onPageChange:
|
|
327
|
+
onPageChange: Te
|
|
322
328
|
}
|
|
323
|
-
), qe = /* @__PURE__ */ e.createElement(et, null), He = /* @__PURE__ */ e.createElement(X,
|
|
324
|
-
|
|
329
|
+
), qe = /* @__PURE__ */ e.createElement(et, null), He = /* @__PURE__ */ e.createElement(X, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
330
|
+
d,
|
|
325
331
|
{
|
|
326
|
-
className: "k-
|
|
332
|
+
className: "k-group-start",
|
|
333
|
+
fillMode: "flat",
|
|
334
|
+
themeColor: "base",
|
|
327
335
|
title: s.toLanguageString(le, i[le]),
|
|
328
336
|
icon: "pointer",
|
|
329
|
-
svgIcon:
|
|
330
|
-
disabled: !
|
|
337
|
+
svgIcon: ht,
|
|
338
|
+
disabled: !u,
|
|
331
339
|
togglable: !0,
|
|
332
|
-
selected: Z &&
|
|
340
|
+
selected: Z && u,
|
|
333
341
|
onClick: De
|
|
334
342
|
}
|
|
335
343
|
), /* @__PURE__ */ e.createElement(
|
|
336
|
-
|
|
344
|
+
d,
|
|
337
345
|
{
|
|
338
|
-
className: "k-
|
|
346
|
+
className: "k-group-end",
|
|
347
|
+
fillMode: "flat",
|
|
348
|
+
themeColor: "base",
|
|
339
349
|
title: s.toLanguageString(ce, i[ce]),
|
|
340
350
|
icon: "hand",
|
|
341
351
|
svgIcon: vt,
|
|
342
|
-
disabled: !
|
|
352
|
+
disabled: !u,
|
|
343
353
|
togglable: !0,
|
|
344
|
-
selected: !Z &&
|
|
354
|
+
selected: !Z && u,
|
|
345
355
|
onClick: Oe
|
|
346
356
|
}
|
|
347
357
|
)), $e = /* @__PURE__ */ e.createElement(
|
|
348
|
-
|
|
358
|
+
d,
|
|
349
359
|
{
|
|
350
360
|
className: "k-toolbar-button",
|
|
361
|
+
fillMode: "flat",
|
|
362
|
+
themeColor: "base",
|
|
351
363
|
title: s.toLanguageString(I, i[I]),
|
|
352
364
|
icon: "search",
|
|
353
|
-
svgIcon:
|
|
354
|
-
disabled: !
|
|
365
|
+
svgIcon: bt,
|
|
366
|
+
disabled: !u,
|
|
355
367
|
onClick: we
|
|
356
368
|
}
|
|
357
369
|
), _e = /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
358
|
-
|
|
370
|
+
d,
|
|
359
371
|
{
|
|
360
372
|
className: "k-toolbar-button",
|
|
373
|
+
fillMode: "flat",
|
|
374
|
+
themeColor: "base",
|
|
361
375
|
title: s.toLanguageString(se, i[se]),
|
|
362
376
|
icon: "folder-open",
|
|
363
377
|
svgIcon: kt,
|
|
364
378
|
onClick: We
|
|
365
379
|
}
|
|
366
380
|
), /* @__PURE__ */ e.createElement("div", { style: { display: "none" } }, /* @__PURE__ */ e.createElement(
|
|
367
|
-
|
|
381
|
+
rt,
|
|
368
382
|
{
|
|
369
383
|
restrictions: { allowedExtensions: [".pdf"] },
|
|
370
384
|
onAdd: Ve,
|
|
@@ -375,23 +389,27 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
375
389
|
withCredentials: !1
|
|
376
390
|
}
|
|
377
391
|
))), Ge = /* @__PURE__ */ e.createElement(
|
|
378
|
-
|
|
392
|
+
d,
|
|
379
393
|
{
|
|
380
394
|
className: "k-toolbar-button",
|
|
395
|
+
fillMode: "flat",
|
|
396
|
+
themeColor: "base",
|
|
381
397
|
title: s.toLanguageString(ie, i[ie]),
|
|
382
398
|
icon: "download",
|
|
383
|
-
svgIcon:
|
|
384
|
-
disabled: !
|
|
399
|
+
svgIcon: pt,
|
|
400
|
+
disabled: !u,
|
|
385
401
|
onClick: Be
|
|
386
402
|
}
|
|
387
403
|
), Je = /* @__PURE__ */ e.createElement(
|
|
388
|
-
|
|
404
|
+
d,
|
|
389
405
|
{
|
|
390
406
|
className: "k-toolbar-button",
|
|
407
|
+
fillMode: "flat",
|
|
408
|
+
themeColor: "base",
|
|
391
409
|
title: s.toLanguageString(ue, i[ue]),
|
|
392
410
|
icon: "print",
|
|
393
411
|
svgIcon: yt,
|
|
394
|
-
disabled: !
|
|
412
|
+
disabled: !u,
|
|
395
413
|
onClick: Ae
|
|
396
414
|
}
|
|
397
415
|
), Qe = {
|
|
@@ -404,69 +422,69 @@ const Bt = (n, C) => n.priority > C.priority ? -1 : n.priority < C.priority ? 1
|
|
|
404
422
|
open: _e,
|
|
405
423
|
download: Ge,
|
|
406
424
|
print: Je
|
|
407
|
-
}, Xe = (
|
|
425
|
+
}, Xe = (a.tools || k.tools).map((o) => ({ ...Qe[o], key: "toobar-tool-" + o + Bt() })), J = /* @__PURE__ */ e.createElement(Ye, { buttons: Ot }, ...Xe), Q = /* @__PURE__ */ e.createElement(
|
|
408
426
|
"div",
|
|
409
427
|
{
|
|
410
|
-
className:
|
|
428
|
+
className: ut("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto", {
|
|
411
429
|
"k-enable-text-select": Z,
|
|
412
430
|
"k-enable-panning": !Z
|
|
413
431
|
}),
|
|
414
|
-
onScroll:
|
|
432
|
+
onScroll: Me
|
|
415
433
|
},
|
|
416
|
-
|
|
434
|
+
Ce && /* @__PURE__ */ e.createElement("div", { className: "k-search-panel k-pos-sticky k-top-center" }, /* @__PURE__ */ e.createElement(
|
|
417
435
|
tt,
|
|
418
436
|
{
|
|
419
437
|
value: F,
|
|
420
438
|
onChange: Ze,
|
|
421
439
|
placeholder: s.toLanguageString(I, i[I]),
|
|
422
440
|
autoFocus: !0,
|
|
423
|
-
onKeyDown:
|
|
424
|
-
suffix: () => /* @__PURE__ */ e.createElement(ot, null, /* @__PURE__ */ e.createElement(
|
|
425
|
-
|
|
441
|
+
onKeyDown: Ne,
|
|
442
|
+
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(ot, null), /* @__PURE__ */ e.createElement(at, null, /* @__PURE__ */ e.createElement(
|
|
443
|
+
d,
|
|
426
444
|
{
|
|
427
445
|
icon: "convert-lowercase",
|
|
428
|
-
svgIcon:
|
|
446
|
+
svgIcon: Ct,
|
|
429
447
|
title: s.toLanguageString(me, i[me]),
|
|
430
448
|
fillMode: "flat",
|
|
431
449
|
togglable: !0,
|
|
432
|
-
selected:
|
|
450
|
+
selected: y,
|
|
433
451
|
onClick: Le
|
|
434
452
|
}
|
|
435
|
-
))
|
|
453
|
+
)))
|
|
436
454
|
}
|
|
437
|
-
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, f), " of ", /* @__PURE__ */ e.createElement("span", null,
|
|
438
|
-
|
|
455
|
+
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, f), " of ", /* @__PURE__ */ e.createElement("span", null, b)), /* @__PURE__ */ e.createElement(
|
|
456
|
+
d,
|
|
439
457
|
{
|
|
440
458
|
title: s.toLanguageString(de, i[de]),
|
|
441
459
|
fillMode: "flat",
|
|
442
460
|
icon: "arrow-up",
|
|
443
461
|
svgIcon: Et,
|
|
444
|
-
disabled:
|
|
462
|
+
disabled: b === 0,
|
|
445
463
|
onClick: Ie
|
|
446
464
|
}
|
|
447
465
|
), /* @__PURE__ */ e.createElement(
|
|
448
|
-
|
|
466
|
+
d,
|
|
449
467
|
{
|
|
450
468
|
title: s.toLanguageString(ge, i[ge]),
|
|
451
469
|
fillMode: "flat",
|
|
452
470
|
icon: "arrow-down",
|
|
453
|
-
svgIcon:
|
|
454
|
-
disabled:
|
|
471
|
+
svgIcon: St,
|
|
472
|
+
disabled: b === 0,
|
|
455
473
|
onClick: ze
|
|
456
474
|
}
|
|
457
475
|
), /* @__PURE__ */ e.createElement(
|
|
458
|
-
|
|
476
|
+
d,
|
|
459
477
|
{
|
|
460
478
|
title: s.toLanguageString(fe, i[fe]),
|
|
461
479
|
fillMode: "flat",
|
|
462
480
|
icon: "x",
|
|
463
|
-
svgIcon:
|
|
481
|
+
svgIcon: xt,
|
|
464
482
|
onClick: _
|
|
465
483
|
}
|
|
466
484
|
)),
|
|
467
485
|
/* @__PURE__ */ e.createElement("div", { ref: c, className: "k-pdf-viewer-pages" })
|
|
468
486
|
);
|
|
469
|
-
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style:
|
|
487
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style: a.style, ref: L }, a.onRenderLoader ? a.onRenderLoader.call(void 0, G || null) : G, a.onRenderToolbar ? a.onRenderToolbar.call(void 0, J) : J, a.onRenderContent ? a.onRenderContent.call(void 0, Q) : Q, ke && /* @__PURE__ */ e.createElement(mt, null));
|
|
470
488
|
});
|
|
471
489
|
O.displayName = "KendoReactPDFViewer";
|
|
472
490
|
O.propTypes = {
|
|
@@ -477,7 +495,7 @@ O.propTypes = {
|
|
|
477
495
|
style: l.object,
|
|
478
496
|
saveFileName: l.string,
|
|
479
497
|
saveOptions: l.object,
|
|
480
|
-
tools: l.arrayOf(l.oneOf(
|
|
498
|
+
tools: l.arrayOf(l.oneOf(be).isRequired),
|
|
481
499
|
zoomLevels: l.arrayOf(l.any),
|
|
482
500
|
zoom: l.number,
|
|
483
501
|
defaultZoom: l.number,
|
|
@@ -492,7 +510,7 @@ O.propTypes = {
|
|
|
492
510
|
onRenderLoader: l.func,
|
|
493
511
|
onZoom: l.func
|
|
494
512
|
};
|
|
495
|
-
O.defaultProps =
|
|
513
|
+
O.defaultProps = k;
|
|
496
514
|
export {
|
|
497
515
|
O as PDFViewer
|
|
498
516
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@progress/kendo-pdfviewer-common"),require("react"),require("prop-types"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-data-tools"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-dropdowns"),require("@progress/kendo-react-indicators"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("@progress/kendo-svg-icons"),require("pdfjs-dist/build/pdf.worker.entry.js")):"function"==typeof define&&define.amd?define(["exports","@progress/kendo-pdfviewer-common","react","prop-types","@progress/kendo-react-buttons","@progress/kendo-react-inputs","@progress/kendo-react-data-tools","@progress/kendo-react-upload","@progress/kendo-react-dropdowns","@progress/kendo-react-indicators","@progress/kendo-react-common","@progress/kendo-react-intl","@progress/kendo-svg-icons","pdfjs-dist/build/pdf.worker.entry.js"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactPdfViewer={},e.KendoPdfviewerCommon,e.React,e.PropTypes,e.KendoReactButtons,e.KendoReactInputs,e.KendoReactDataTools,e.KendoReactUpload,e.KendoReactDropdowns,e.KendoReactIndicators,e.KendoReactCommon,e.KendoReactIntl,e.KendoSvgIcons)}(this,(function(e,o,t,r,n,a,l,c,s,i,u,d,p){"use strict";function m(e){var o=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),o.default=e,Object.freeze(o)}var g=m(t);const f={name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:1673300081,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"},v="pdfviewer.zoomIn",k="pdfviewer.zoomOut",b="pdfviewer.zoomLevel",h="pdfviewer.enableSelection",y="pdfviewer.enablePanning",w="pdfviewer.search",C="pdfviewer.open",E="pdfviewer.download",S="pdfviewer.print",x="pdfviewer.close",P="pdfviewer.matchCase",I="pdfviewer.prevMatch",z="pdfviewer.nextMatch",L="pdfviewer.actualWidth",Z="pdfviewer.fitToWidth",N="pdfviewer.fitToPage",R="pdfviewer.popupBlocked",T={[v]:"Zoom in",[k]:"Zoom out",[b]:"Choose zoom level",[h]:"Enable selection",[y]:"Enable panning",[w]:"Search",[C]:"Open",[E]:"Download",[S]:"Print",[x]:"Close",[P]:"Match case",[I]:"Previous match",[z]:"Next match",[L]:"Actual width",[Z]:"Fit to width",[N]:"Fit to page",[R]:"Popup is blocked."},B=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],O={minZoom:.5,maxZoom:4,tools:[...B],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:L},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:Z},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:N},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:o.DEFAULT_ZOOM_LEVEL},D=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let F=0;const K=(e,o)=>e.priority>o.priority?-1:e.priority<o.priority?1:0,M=g.forwardRef(((e,t)=>{u.validatePackage(f);const r=u.shouldShowValidationUI(f),{zoom:m,zoomLevels:L=O.zoomLevels,defaultZoom:Z=O.defaultZoom,minZoom:N=O.minZoom,maxZoom:B=O.maxZoom,zoomRate:M=O.zoomRate}=e,q=d.useLocalization(),j=g.useRef(null),[A,U]=g.useState(Z),V=void 0!==m?m:A,W=L.slice().sort(K).find((e=>e.value===V))||{text:100*V+"%",value:V,id:V,locationString:""};W.locationString&&(W.text=q.toLanguageString(W.locationString,T[W.locationString]));const[_,G]=g.useState(!1),[H,J]=g.useState(!0),[Q,X]=g.useState(0),[Y,$]=g.useState(!1),[ee,oe]=g.useState(!1),[te,re]=g.useState(0),[ne,ae]=g.useState(0),[le,ce]=g.useState(!1),[se,ie]=g.useState(""),ue=g.useMemo((()=>({})),[]);ue.currentZoom=V,ue.props=e;const de=g.useCallback((e=>{j.current&&j.current.style.setProperty("--scale-factor",String(e))}),[]),pe=g.useRef(null),me=g.useRef(null);g.useImperativeHandle(pe,(()=>({get element(){return me.current},props:e,get pages(){return ue.pages},get document(){return ue.document}})),[]),g.useImperativeHandle(t,(()=>pe.current));const ge=g.useCallback((()=>{if(ue.props.onLoad){const e={target:pe.current};ue.props.onLoad.call(void 0,e)}}),[]),fe=g.useCallback(((o,t,r)=>{if(e.onDownload){const n={target:pe.current,blob:o,fileName:t,saveOptions:r};return!1===e.onDownload.call(void 0,n)}return!1}),[e.onDownload]),ve=g.useCallback((()=>{var e;ue.scroller&&ue.scroller.destroy(),ue.scroller=new o.Scroller(null==(e=j.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),ue.scroller.enablePanEventsTracking()}),[]),ke=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));ue.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);ue.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{ue.document=t,ue.pages=e,ue.zoom=r,ve(),J(!1),G(!0),ge(),j.current&&o.scrollToPage(j.current,0)}),[]),ue.error=g.useCallback((o=>{if(ue.document=null,ue.pages=[],J(!1),G(!1),e.onError){const t={error:"string"==typeof o?{message:o}:o,target:pe.current};e.onError.call(void 0,t)}}),[e.onError]),g.useEffect((()=>{j.current&&(e.url||e.data||e.arrayBuffer?(J(!0),o.removeChildren(j.current),o.loadPDF({url:e.url,data:e.data,arrayBuffer:e.arrayBuffer,dom:j.current,zoom:ue.currentZoom,done:ue.done,error:ue.error}),de(ue.currentZoom)):(ue.document=null,ue.pages=[],G(!1),J(!1),o.removeChildren(j.current)))}),[e.url,e.data,e.arrayBuffer]);const be=g.useCallback(((e,t)=>{j.current&&(J(!0),o.removeChildren(j.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:j.current,done:e=>{ue.pages=e,ue.zoom=t,J(!1)},error:ue.error}))}),[]);g.useEffect((()=>{de(V),j.current&&ue.document&&V!==ue.zoom&&be(ue.document,V)}),[V,be]),g.useEffect((()=>()=>{ue.scroller&&ue.scroller.destroy(),ue.search&&ue.search.destroy(),ue.document=null,ue.pages=[]}),[]);const he=g.useCallback((()=>{oe(!0),ke(j.current)}),[]),ye=g.useCallback((e=>{const o=e.value,t=ue.search.search({text:o,matchCase:le});ae(t.length?1:0),re(t.length),ie(o)}),[le]),we=g.useCallback((()=>{const e=ue.search.search({text:se,matchCase:!le});ae(e.length?1:0),re(e.length),ce(!le)}),[le,se]),Ce=g.useCallback((()=>{o.goToNextSearchMatch(ue),ae(ne+1>te?1:ne+1)}),[ne,te]),Ee=g.useCallback((()=>{o.goToPreviousSearchMatch(ue),ae(ne-1<1?te:ne-1)}),[ne,te]),Se=g.useCallback((()=>{ue.search.destroy(),ae(0),re(0),ce(!1),ie(""),oe(!1)}),[]),xe=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(ue),ae(ne+1>te?1:ne+1)):"Escape"===e.key&&Se()}),[ne,te]),Pe=g.useCallback((t=>{if(j.current){const r=t.skip;o.scrollToPage(j.current,r);const n={page:r+1,target:pe.current,syntheticEvent:t.syntheticEvent};e.onPageChange&&e.onPageChange.call(void 0,n)}X(t.skip)}),[Q,e.onPageChange]),Ie=g.useCallback((t=>{if(me.current){const r=o.currentPage(me.current);if(r!==Q){X(r);const o={page:r+1,target:pe.current,syntheticEvent:t};e.onPageChange&&e.onPageChange.call(void 0,o)}}}),[Q,e.onPageChange]),ze=g.useCallback((o=>{const t=Math.min(ue.currentZoom+M,B);if(t!==ue.currentZoom&&ue.document&&(U(t),e.onZoom)){const r={zoom:t,target:pe.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[M,B,e.onZoom]),Le=g.useCallback((o=>{const t=Math.max(ue.currentZoom-M,N);if(t!==ue.currentZoom&&ue.document&&(U(t),e.onZoom)){const r={zoom:t,target:pe.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[M,N,e.onZoom]),Ze=g.useCallback((t=>{const r=null===t.value?{text:"100%",value:1,id:100}:{...t.value};if(void 0===r.value){const e=parseFloat(r.text);"number"!=typeof e||Number.isNaN(e)?r.value=1:r.value=e/100}let n=r?o.calculateZoomLevel(r.value,r.type,ue.currentZoom,j.current):1;if(n=Math.round(100*n)/100,ue.currentZoom!==n&&ue.document&&(U(n),e.onZoom)){const o={zoom:n,target:pe.current,syntheticEvent:t.syntheticEvent};e.onZoom.call(void 0,o)}}),[e.onZoom]),Ne=g.useCallback((()=>{ue.scroller.disablePanEventsTracking(),$(!0)}),[]),Re=g.useCallback((()=>{ue.scroller.enablePanEventsTracking(),$(!1)}),[]),Te=g.useCallback((()=>{o.download({pdf:ue.document,error:ue.error},e.saveFileName,e.saveOptions,fe)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,fe]),Be=g.useCallback((()=>{J(!0);o.print(ue.pages,(()=>{J(!1)}),(e=>{ue.error("string"==typeof(e?e.message||e:null)?e.message||e:q.toLanguageString(R,T[R]))}))}),[]),Oe=g.useCallback((e=>{const t=e.newState;t[0]&&t[0].getRawFile&&t[0].getRawFile().arrayBuffer().then((e=>{if(j.current){J(!0),o.removeChildren(j.current);const t=void 0===ue.props.zoom?Z:ue.props.zoom;o.loadPDF({arrayBuffer:e,dom:j.current,zoom:t,done:ue.done,error:ue.error}),U(t)}}))}),[Z]),De=g.useCallback((e=>{const o=e.target;if(o instanceof Element&&o.parentNode){const e=o.closest(".k-toolbar"),t=e&&e.querySelector(".k-upload input");t&&t.click()}}),[]),Fe=H&&g.createElement("div",{className:"k-loader-container k-loader-container-md k-loader-top"},g.createElement("div",{className:"k-loader-container-overlay k-overlay-light"}),g.createElement("div",{className:"k-loader-container-inner "},g.createElement(i.Loader,{size:"large"}))),Ke=g.createElement(n.ButtonGroup,null,g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(k,T[k]),disabled:V<=N||!_,onClick:Le,icon:"zoom-out",svgIcon:p.zoomOutIcon}),g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(v,T[v]),disabled:V>=B||!_,onClick:ze,icon:"zoom-in",svgIcon:p.zoomInIcon})),Me=g.createElement(s.ComboBox,{disabled:!_,data:L.map((e=>({...e,text:e.locationString?q.toLanguageString(e.locationString,T[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:_?W:null,allowCustom:!0,onChange:Ze,placeholder:q.toLanguageString(b,T[b])}),qe={pager:g.createElement(l.Pager,{previousNext:!0,type:"input",skip:Q,take:1,total:ue.pages?ue.pages.length:0,info:!1,onPageChange:Pe}),spacer:g.createElement(n.ToolbarSpacer,null),zoomInOut:Ke,zoom:Me,selection:g.createElement(n.ButtonGroup,null,g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(h,T[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!_,togglable:!0,selected:Y&&_,onClick:Ne}),g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(y,T[y]),icon:"hand",svgIcon:p.handIcon,disabled:!_,togglable:!0,selected:!Y&&_,onClick:Re})),search:g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(w,T[w]),icon:"search",svgIcon:p.searchIcon,disabled:!_,onClick:he}),open:g.createElement(g.Fragment,null,g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(C,T[C]),icon:"folder-open",svgIcon:p.folderOpenIcon,onClick:De}),g.createElement("div",{style:{display:"none"}},g.createElement(c.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:Oe,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),download:g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(E,T[E]),icon:"download",svgIcon:p.downloadIcon,disabled:!_,onClick:Te}),print:g.createElement(n.Button,{className:"k-toolbar-button",title:q.toLanguageString(S,T[S]),icon:"print",svgIcon:p.printIcon,disabled:!_,onClick:Be})},je=(e.tools||O.tools).map((e=>({...qe[e],key:"toobar-tool-"+e+(F++,F)}))),Ae=g.createElement(n.Toolbar,{buttons:D},...je),Ue=g.createElement("div",{className:u.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":Y,"k-enable-panning":!Y}),onScroll:Ie},ee&&g.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},g.createElement(a.TextBox,{value:se,onChange:ye,placeholder:q.toLanguageString(w,T[w]),autoFocus:!0,onKeyDown:xe,suffix:()=>g.createElement(a.InputSuffix,null,g.createElement(n.Button,{icon:"convert-lowercase",svgIcon:p.convertLowercaseIcon,title:q.toLanguageString(P,T[P]),fillMode:"flat",togglable:!0,selected:le,onClick:we}))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,ne)," of ",g.createElement("span",null,te)),g.createElement(n.Button,{title:q.toLanguageString(I,T[I]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===te,onClick:Ee}),g.createElement(n.Button,{title:q.toLanguageString(z,T[z]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===te,onClick:Ce}),g.createElement(n.Button,{title:q.toLanguageString(x,T[x]),fillMode:"flat",icon:"x",svgIcon:p.xIcon,onClick:Se})),g.createElement("div",{ref:j,className:"k-pdf-viewer-pages"}));return g.createElement("div",{className:"k-pdf-viewer",style:e.style,ref:me},e.onRenderLoader?e.onRenderLoader.call(void 0,Fe||null):Fe,e.onRenderToolbar?e.onRenderToolbar.call(void 0,Ae):Ae,e.onRenderContent?e.onRenderContent.call(void 0,Ue):Ue,r&&g.createElement(u.WatermarkOverlay,null))}));M.displayName="KendoReactPDFViewer",M.propTypes={url:r.string,data:r.string,arrayBuffer:r.any,typedArray:r.any,style:r.object,saveFileName:r.string,saveOptions:r.object,tools:r.arrayOf(r.oneOf(B).isRequired),zoomLevels:r.arrayOf(r.any),zoom:r.number,defaultZoom:r.number,minZoom:r.number,maxZoom:r.number,zoomRate:r.number,onError:r.func,onLoad:r.func,onDownload:r.func,onRenderToolbar:r.func,onRenderContent:r.func,onRenderLoader:r.func,onZoom:r.func},M.defaultProps=O;const q=o.scrollToPage;Object.defineProperty(e,"currentPage",{enumerable:!0,get:function(){return o.currentPage}}),e.PDFViewer=M,e.scrollToPage=q}));
|
|
8
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@progress/kendo-pdfviewer-common"),require("react"),require("prop-types"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-data-tools"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-dropdowns"),require("@progress/kendo-react-indicators"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("@progress/kendo-svg-icons"),require("pdfjs-dist/build/pdf.worker.entry.js")):"function"==typeof define&&define.amd?define(["exports","@progress/kendo-pdfviewer-common","react","prop-types","@progress/kendo-react-buttons","@progress/kendo-react-inputs","@progress/kendo-react-data-tools","@progress/kendo-react-upload","@progress/kendo-react-dropdowns","@progress/kendo-react-indicators","@progress/kendo-react-common","@progress/kendo-react-intl","@progress/kendo-svg-icons","pdfjs-dist/build/pdf.worker.entry.js"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactPdfViewer={},e.KendoPdfviewerCommon,e.React,e.PropTypes,e.KendoReactButtons,e.KendoReactInputs,e.KendoReactDataTools,e.KendoReactUpload,e.KendoReactDropdowns,e.KendoReactIndicators,e.KendoReactCommon,e.KendoReactIntl,e.KendoSvgIcons)}(this,(function(e,o,t,r,a,n,l,c,s,i,u,d,p){"use strict";function m(e){var o=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),o.default=e,Object.freeze(o)}var g=m(t);const f={name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:1673300081,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"},v="pdfviewer.zoomIn",k="pdfviewer.zoomOut",b="pdfviewer.zoomLevel",h="pdfviewer.enableSelection",y="pdfviewer.enablePanning",C="pdfviewer.search",w="pdfviewer.open",E="pdfviewer.download",S="pdfviewer.print",x="pdfviewer.close",P="pdfviewer.matchCase",I="pdfviewer.prevMatch",z="pdfviewer.nextMatch",N="pdfviewer.actualWidth",L="pdfviewer.fitToWidth",Z="pdfviewer.fitToPage",R="pdfviewer.popupBlocked",T={[v]:"Zoom in",[k]:"Zoom out",[b]:"Choose zoom level",[h]:"Enable selection",[y]:"Enable panning",[C]:"Search",[w]:"Open",[E]:"Download",[S]:"Print",[x]:"Close",[P]:"Match case",[I]:"Previous match",[z]:"Next match",[N]:"Actual width",[L]:"Fit to width",[Z]:"Fit to page",[R]:"Popup is blocked."},B=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],O={minZoom:.5,maxZoom:4,tools:[...B],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:N},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:L},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:Z},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:o.DEFAULT_ZOOM_LEVEL},M=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let D=0;const F=(e,o)=>e.priority>o.priority?-1:e.priority<o.priority?1:0,K=g.forwardRef(((e,t)=>{u.validatePackage(f);const r=u.shouldShowValidationUI(f),{zoom:m,zoomLevels:N=O.zoomLevels,defaultZoom:L=O.defaultZoom,minZoom:Z=O.minZoom,maxZoom:B=O.maxZoom,zoomRate:K=O.zoomRate}=e,q=d.useLocalization(),j=g.useRef(null),[A,U]=g.useState(L),V=void 0!==m?m:A,W=N.slice().sort(F).find((e=>e.value===V))||{text:100*V+"%",value:V,id:V,locationString:""};W.locationString&&(W.text=q.toLanguageString(W.locationString,T[W.locationString]));const[_,G]=g.useState(!1),[H,J]=g.useState(!0),[Q,X]=g.useState(0),[Y,$]=g.useState(!0),[ee,oe]=g.useState(!1),[te,re]=g.useState(0),[ae,ne]=g.useState(0),[le,ce]=g.useState(!1),[se,ie]=g.useState(""),ue=g.useMemo((()=>({})),[]);ue.currentZoom=V,ue.props=e;const de=g.useCallback((e=>{j.current&&j.current.style.setProperty("--scale-factor",String(e))}),[]),pe=g.useRef(null),me=g.useRef(null);g.useImperativeHandle(pe,(()=>({get element(){return me.current},props:e,get pages(){return ue.pages},get document(){return ue.document}})),[]),g.useImperativeHandle(t,(()=>pe.current));const ge=g.useCallback((()=>{if(ue.props.onLoad){const e={target:pe.current};ue.props.onLoad.call(void 0,e)}}),[]),fe=g.useCallback(((o,t,r)=>{if(e.onDownload){const a={target:pe.current,blob:o,fileName:t,saveOptions:r};return!1===e.onDownload.call(void 0,a)}return!1}),[e.onDownload]),ve=g.useCallback((()=>{var e;ue.scroller&&ue.scroller.destroy(),ue.scroller=new o.Scroller(null==(e=j.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),ue.scroller.disablePanEventsTracking()}),[]),ke=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));ue.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);ue.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{ue.document=t,ue.pages=e,ue.zoom=r,ve(),J(!1),G(!0),ge(),j.current&&o.scrollToPage(j.current,0)}),[]),ue.error=g.useCallback((o=>{if(ue.document=null,ue.pages=[],J(!1),G(!1),e.onError){const t={error:"string"==typeof o?{message:o}:o,target:pe.current};e.onError.call(void 0,t)}}),[e.onError]),g.useEffect((()=>{j.current&&(e.url||e.data||e.arrayBuffer?(J(!0),o.removeChildren(j.current),o.loadPDF({url:e.url,data:e.data,arrayBuffer:e.arrayBuffer,dom:j.current,zoom:ue.currentZoom,done:ue.done,error:ue.error}),de(ue.currentZoom)):(ue.document=null,ue.pages=[],G(!1),J(!1),o.removeChildren(j.current)))}),[e.url,e.data,e.arrayBuffer]);const be=g.useCallback(((e,t)=>{j.current&&(J(!0),o.removeChildren(j.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:j.current,done:e=>{ue.pages=e,ue.zoom=t,J(!1)},error:ue.error}))}),[]);g.useEffect((()=>{de(V),j.current&&ue.document&&V!==ue.zoom&&be(ue.document,V)}),[V,be]),g.useEffect((()=>()=>{ue.scroller&&ue.scroller.destroy(),ue.search&&ue.search.destroy(),ue.document=null,ue.pages=[]}),[]);const he=g.useCallback((()=>{oe(!0),ke(j.current)}),[]),ye=g.useCallback((e=>{const o=e.value,t=ue.search.search({text:o,matchCase:le});ne(t.length?1:0),re(t.length),ie(o)}),[le]),Ce=g.useCallback((()=>{const e=ue.search.search({text:se,matchCase:!le});ne(e.length?1:0),re(e.length),ce(!le)}),[le,se]),we=g.useCallback((()=>{o.goToNextSearchMatch(ue),ne(ae+1>te?1:ae+1)}),[ae,te]),Ee=g.useCallback((()=>{o.goToPreviousSearchMatch(ue),ne(ae-1<1?te:ae-1)}),[ae,te]),Se=g.useCallback((()=>{ue.search.destroy(),ne(0),re(0),ce(!1),ie(""),oe(!1)}),[]),xe=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(ue),ne(ae+1>te?1:ae+1)):"Escape"===e.key&&Se()}),[ae,te]),Pe=g.useCallback((t=>{if(j.current){const r=t.skip;o.scrollToPage(j.current,r);const a={page:r+1,target:pe.current,syntheticEvent:t.syntheticEvent};e.onPageChange&&e.onPageChange.call(void 0,a)}X(t.skip)}),[Q,e.onPageChange]),Ie=g.useCallback((t=>{if(me.current){const r=o.currentPage(me.current);if(r!==Q){X(r);const o={page:r+1,target:pe.current,syntheticEvent:t};e.onPageChange&&e.onPageChange.call(void 0,o)}}}),[Q,e.onPageChange]),ze=g.useCallback((o=>{const t=Math.min(ue.currentZoom+K,B);if(t!==ue.currentZoom&&ue.document&&(U(t),e.onZoom)){const r={zoom:t,target:pe.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[K,B,e.onZoom]),Ne=g.useCallback((o=>{const t=Math.max(ue.currentZoom-K,Z);if(t!==ue.currentZoom&&ue.document&&(U(t),e.onZoom)){const r={zoom:t,target:pe.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[K,Z,e.onZoom]),Le=g.useCallback((t=>{const r=null===t.value?{text:"100%",value:1,id:100}:{...t.value};if(void 0===r.value){const e=parseFloat(r.text);"number"!=typeof e||Number.isNaN(e)?r.value=1:r.value=e/100}let a=r?o.calculateZoomLevel(r.value,r.type,ue.currentZoom,j.current):1;if(a=Math.round(100*a)/100,ue.currentZoom!==a&&ue.document&&(U(a),e.onZoom)){const o={zoom:a,target:pe.current,syntheticEvent:t.syntheticEvent};e.onZoom.call(void 0,o)}}),[e.onZoom]),Ze=g.useCallback((()=>{ue.scroller.disablePanEventsTracking(),$(!0)}),[]),Re=g.useCallback((()=>{ue.scroller.enablePanEventsTracking(),$(!1)}),[]),Te=g.useCallback((()=>{o.download({pdf:ue.document,error:ue.error},e.saveFileName,e.saveOptions,fe)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,fe]),Be=g.useCallback((()=>{J(!0);o.print(ue.pages,(()=>{J(!1)}),(e=>{ue.error("string"==typeof(e?e.message||e:null)?e.message||e:q.toLanguageString(R,T[R]))}))}),[]),Oe=g.useCallback((e=>{const t=e.newState;t[0]&&t[0].getRawFile&&t[0].getRawFile().arrayBuffer().then((e=>{if(j.current){J(!0),o.removeChildren(j.current);const t=void 0===ue.props.zoom?L:ue.props.zoom;o.loadPDF({arrayBuffer:e,dom:j.current,zoom:t,done:ue.done,error:ue.error}),U(t)}}))}),[L]),Me=g.useCallback((e=>{const o=e.target;if(o instanceof Element&&o.parentNode){const e=o.closest(".k-toolbar"),t=e&&e.querySelector(".k-upload input");t&&t.click()}}),[]),De=H&&g.createElement("div",{className:"k-loader-container k-loader-container-md k-loader-top"},g.createElement("div",{className:"k-loader-container-overlay k-overlay-light"}),g.createElement("div",{className:"k-loader-container-inner "},g.createElement(i.Loader,{size:"large"}))),Fe=g.createElement(a.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},g.createElement(a.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:q.toLanguageString(k,T[k]),disabled:V<=Z||!_,onClick:Ne,icon:"zoom-out",svgIcon:p.zoomOutIcon}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:q.toLanguageString(v,T[v]),disabled:V>=B||!_,onClick:ze,icon:"zoom-in",svgIcon:p.zoomInIcon})),Ke=g.createElement(s.ComboBox,{className:"k-toolbar-combobox",disabled:!_,data:N.map((e=>({...e,text:e.locationString?q.toLanguageString(e.locationString,T[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:_?W:null,allowCustom:!0,onChange:Le,placeholder:q.toLanguageString(b,T[b])}),qe={pager:g.createElement(l.Pager,{disabled:!_,previousNext:!0,type:"input",skip:Q,take:1,total:ue.pages?ue.pages.length:0,info:!1,onPageChange:Pe}),spacer:g.createElement(a.ToolbarSpacer,null),zoomInOut:Fe,zoom:Ke,selection:g.createElement(a.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},g.createElement(a.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:q.toLanguageString(h,T[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!_,togglable:!0,selected:Y&&_,onClick:Ze}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:q.toLanguageString(y,T[y]),icon:"hand",svgIcon:p.handIcon,disabled:!_,togglable:!0,selected:!Y&&_,onClick:Re})),search:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:q.toLanguageString(C,T[C]),icon:"search",svgIcon:p.searchIcon,disabled:!_,onClick:he}),open:g.createElement(g.Fragment,null,g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:q.toLanguageString(w,T[w]),icon:"folder-open",svgIcon:p.folderOpenIcon,onClick:Me}),g.createElement("div",{style:{display:"none"}},g.createElement(c.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:Oe,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),download:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:q.toLanguageString(E,T[E]),icon:"download",svgIcon:p.downloadIcon,disabled:!_,onClick:Te}),print:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:q.toLanguageString(S,T[S]),icon:"print",svgIcon:p.printIcon,disabled:!_,onClick:Be})},je=(e.tools||O.tools).map((e=>({...qe[e],key:"toobar-tool-"+e+(D++,D)}))),Ae=g.createElement(a.Toolbar,{buttons:M},...je),Ue=g.createElement("div",{className:u.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":Y,"k-enable-panning":!Y}),onScroll:Ie},ee&&g.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},g.createElement(n.TextBox,{value:se,onChange:ye,placeholder:q.toLanguageString(C,T[C]),autoFocus:!0,onKeyDown:xe,suffix:()=>g.createElement(g.Fragment,null,g.createElement(n.InputSeparator,null),g.createElement(n.InputSuffix,null,g.createElement(a.Button,{icon:"convert-lowercase",svgIcon:p.convertLowercaseIcon,title:q.toLanguageString(P,T[P]),fillMode:"flat",togglable:!0,selected:le,onClick:Ce})))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,ae)," of ",g.createElement("span",null,te)),g.createElement(a.Button,{title:q.toLanguageString(I,T[I]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===te,onClick:Ee}),g.createElement(a.Button,{title:q.toLanguageString(z,T[z]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===te,onClick:we}),g.createElement(a.Button,{title:q.toLanguageString(x,T[x]),fillMode:"flat",icon:"x",svgIcon:p.xIcon,onClick:Se})),g.createElement("div",{ref:j,className:"k-pdf-viewer-pages"}));return g.createElement("div",{className:"k-pdf-viewer",style:e.style,ref:me},e.onRenderLoader?e.onRenderLoader.call(void 0,De||null):De,e.onRenderToolbar?e.onRenderToolbar.call(void 0,Ae):Ae,e.onRenderContent?e.onRenderContent.call(void 0,Ue):Ue,r&&g.createElement(u.WatermarkOverlay,null))}));K.displayName="KendoReactPDFViewer",K.propTypes={url:r.string,data:r.string,arrayBuffer:r.any,typedArray:r.any,style:r.object,saveFileName:r.string,saveOptions:r.object,tools:r.arrayOf(r.oneOf(B).isRequired),zoomLevels:r.arrayOf(r.any),zoom:r.number,defaultZoom:r.number,minZoom:r.number,maxZoom:r.number,zoomRate:r.number,onError:r.func,onLoad:r.func,onDownload:r.func,onRenderToolbar:r.func,onRenderContent:r.func,onRenderLoader:r.func,onZoom:r.func},K.defaultProps=O;const q=o.scrollToPage;Object.defineProperty(e,"currentPage",{enumerable:!0,get:function(){return o.currentPage}}),e.PDFViewer=K,e.scrollToPage=q}));
|
package/package-metadata.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const e = {
|
|
|
10
10
|
name: "@progress/kendo-react-pdf-viewer",
|
|
11
11
|
productName: "KendoReact",
|
|
12
12
|
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
13
|
-
publishDate:
|
|
13
|
+
publishDate: 1714143910,
|
|
14
14
|
version: "",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-pdf-viewer",
|
|
3
|
-
"version": "7.5.0-develop.
|
|
3
|
+
"version": "7.5.0-develop.9",
|
|
4
4
|
"description": "KendoReact PDFViewer package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"@progress/kendo-file-saver": "^1.1.1",
|
|
26
26
|
"@progress/kendo-licensing": "^1.3.4",
|
|
27
27
|
"@progress/kendo-pdfviewer-common": "0.2.9",
|
|
28
|
-
"@progress/kendo-react-buttons": "7.5.0-develop.
|
|
29
|
-
"@progress/kendo-react-common": "7.5.0-develop.
|
|
30
|
-
"@progress/kendo-react-data-tools": "7.5.0-develop.
|
|
31
|
-
"@progress/kendo-react-dropdowns": "7.5.0-develop.
|
|
32
|
-
"@progress/kendo-react-indicators": "7.5.0-develop.
|
|
33
|
-
"@progress/kendo-react-inputs": "7.5.0-develop.
|
|
34
|
-
"@progress/kendo-react-intl": "7.5.0-develop.
|
|
35
|
-
"@progress/kendo-react-upload": "7.5.0-develop.
|
|
28
|
+
"@progress/kendo-react-buttons": "7.5.0-develop.9",
|
|
29
|
+
"@progress/kendo-react-common": "7.5.0-develop.9",
|
|
30
|
+
"@progress/kendo-react-data-tools": "7.5.0-develop.9",
|
|
31
|
+
"@progress/kendo-react-dropdowns": "7.5.0-develop.9",
|
|
32
|
+
"@progress/kendo-react-indicators": "7.5.0-develop.9",
|
|
33
|
+
"@progress/kendo-react-inputs": "7.5.0-develop.9",
|
|
34
|
+
"@progress/kendo-react-intl": "7.5.0-develop.9",
|
|
35
|
+
"@progress/kendo-react-upload": "7.5.0-develop.9",
|
|
36
36
|
"@progress/kendo-svg-icons": "^2.1.0",
|
|
37
37
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
38
38
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|