@progress/kendo-react-pdf-viewer 10.0.0-develop.5 → 10.0.0
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 +115 -116
- package/README.md +8 -7
- package/dist/cdn/js/kendo-react-pdf-viewer.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De=require("react"),c=require("prop-types"),m=require("@progress/kendo-react-buttons"),q=require("@progress/kendo-react-inputs"),Fe=require("@progress/kendo-react-data-tools"),qe=require("@progress/kendo-react-upload"),je=require("@progress/kendo-react-dropdowns"),Ae=require("@progress/kendo-react-indicators"),j=require("@progress/kendo-react-common"),Ve=require("@progress/kendo-react-intl"),f=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.min.mjs");const We=require("./package-metadata.js"),i=require("@progress/kendo-pdfviewer-common"),a=require("./messages.js");function Ke(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const C in n)if(C!=="default"){const Z=Object.getOwnPropertyDescriptor(n,C);Object.defineProperty(p,C,Z.get?Z:{enumerable:!0,get:()=>n[C]})}}return p.default=n,Object.freeze(p)}const e=Ke(De),oe=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],w={minZoom:.5,maxZoom:4,tools:[...oe],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},Ue=[".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 te=0;function _e(){return te++,te}const He=(n,p)=>n.priority>p.priority?-1:n.priority<p.priority?1:0,A=e.forwardRef((n,p)=>{const C=!j.validatePackage(We.packageMetadata,{component:"PDFViewer"}),{zoom:Z,zoomLevels:V=w.zoomLevels,defaultZoom:N=w.defaultZoom,minZoom:R=w.minZoom,maxZoom:B=w.maxZoom,zoomRate:L=w.zoomRate}=n,u=Ve.useLocalization(),s=e.useRef(null),[ne,P]=e.useState(N),h=Z!==void 0?Z:ne,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[g,O]=e.useState(!1),[ae,b]=e.useState(!0),[I,W]=e.useState(0),[M,K]=e.useState(!0),[re,U]=e.useState(!1),[y,D]=e.useState(0),[k,E]=e.useState(0),[S,_]=e.useState(!1),[F,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),T=e.useRef(null);e.useImperativeHandle(v,()=>({get element(){return T.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(p,()=>v.current);const le=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 d={target:v.current,blob:o,fileName:r,saveOptions:l};return n.onDownload.call(void 0,d)===!1}return!1},[n.onDownload]),ce=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()},[]),se=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,ce(),b(!1),O(!0),le(),s.current&&i.scrollToPage(s.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],b(!1),O(!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=[],O(!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 ie=e.useCallback(()=>{U(!0),se(s.current)},[]),ue=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:S});E(l.length?1:0),D(l.length),H(r)},[S]),me=e.useCallback(()=>{const o=t.search.search({text:F,matchCase:!S});E(o.length?1:0),D(o.length),_(!S)},[S,F]),de=e.useCallback(()=>{i.goToNextSearchMatch(t),E(k+1>y?1:k+1)},[k,y]),ge=e.useCallback(()=>{i.goToPreviousSearchMatch(t),E(k-1<1?y:k-1)},[k,y]),X=e.useCallback(()=>{t.search.destroy(),E(0),D(0),_(!1),H(""),U(!1)},[]),fe=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),E(k+1>y?1:k+1)):o.key==="Escape"&&X()},[k,y]),he=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)}W(o.skip)},[I,n.onPageChange]),ke=e.useCallback(o=>{if(T.current){const r=i.currentPage(T.current);if(r!==I){W(r);const l={page:r+1,target:v.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[I,n.onPageChange]),ve=e.useCallback(o=>{const r=Math.min(t.currentZoom+L,B);if(r!==t.currentZoom&&t.document&&(P(r),n.onZoom)){const l={zoom:r,target:v.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[L,B,n.onZoom]),be=e.useCallback(o=>{const r=Math.max(t.currentZoom-L,R);if(r!==t.currentZoom&&t.document&&(P(r),n.onZoom)){const l={zoom:r,target:v.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[L,R,n.onZoom]),ye=e.useCallback(o=>{const r=o.value===null?{text:"100%",value:1,id:100}:{...o.value};if(r.value===void 0){const d=parseFloat(r.text);typeof d=="number"&&!Number.isNaN(d)?r.value=d/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&&(P(l),n.onZoom)){const d={zoom:l,target:v.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,d)}},[n.onZoom]),pe=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),K(!0)},[]),Ce=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),K(!1)},[]),Ee=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]),Se=e.useCallback(()=>{b(!0);const o=l=>{var d,x;t.error((x=(d=l==null?void 0:l.message)!=null?d:l)!=null?x:u.toLanguageString(a.popupBlocked,a.messages[a.popupBlocked]))},r=()=>{b(!1)};i.print(t.pages,r,o)},[]),xe=e.useCallback(o=>{const r=o.newState;r[0]&&r[0].getRawFile&&r[0].getRawFile().arrayBuffer().then(d=>{if(s.current){b(!0),i.removeChildren(s.current);const x=t.props.zoom===void 0?N:t.props.zoom;i.loadPDF({arrayBuffer:d,dom:s.current,zoom:x,done:t.done,error:t.error}),P(x)}})},[N]),we=e.useCallback(o=>{const r=o.target;if(r instanceof Element&&r.parentNode){const l=r.closest(".k-toolbar"),d=l&&l.querySelector(".k-upload input");d&&d.click()}},[]),Y=ae&&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(Ae.Loader,{size:"large"}))),Ze=e.createElement(m.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(m.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomOut,a.messages[a.zoomOut]),disabled:h<=R||!g,onClick:be,icon:"zoom-out",svgIcon:f.zoomOutIcon}),e.createElement(m.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomIn,a.messages[a.zoomIn]),disabled:h>=B||!g,onClick:ve,icon:"zoom-in",svgIcon:f.zoomInIcon})),ze=e.createElement(je.ComboBox,{className:"k-toolbar-combobox",disabled:!g,data:V.map(o=>({...o,text:o.locationString?u.toLanguageString(o.locationString,a.messages[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:g?z:null,allowCustom:!0,onChange:ye,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Le=e.createElement(Fe.Pager,{disabled:!g,previousNext:!0,type:"input",skip:I,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:he}),Pe=e.createElement(m.ToolbarSpacer,null),Ie=e.createElement(m.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(m.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enableSelection,a.messages[a.enableSelection]),icon:"pointer",svgIcon:f.pointerIcon,disabled:!g,togglable:!0,selected:M&&g,onClick:pe}),e.createElement(m.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enablePanning,a.messages[a.enablePanning]),icon:"hand",svgIcon:f.handIcon,disabled:!g,togglable:!0,selected:!M&&g,onClick:Ce})),Me=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.search,a.messages[a.search]),icon:"search",svgIcon:f.searchIcon,disabled:!g,onClick:ie}),Te=e.createElement(e.Fragment,null,e.createElement(m.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:we}),e.createElement("div",{style:{display:"none"}},e.createElement(qe.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:xe,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Ne=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.download,a.messages[a.download]),icon:"download",svgIcon:f.downloadIcon,disabled:!g,onClick:Ee}),Re=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.print,a.messages[a.print]),icon:"print",svgIcon:f.printIcon,disabled:!g,onClick:Se}),Be={pager:Le,spacer:Pe,zoomInOut:Ze,zoom:ze,selection:Ie,search:Me,open:Te,download:Ne,print:Re},Oe=(n.tools||w.tools).map(o=>({...Be[o],key:"toobar-tool-"+o+_e()})),$=e.createElement(m.Toolbar,{buttons:Ue},...Oe),ee=e.createElement("div",{className:j.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":M,"k-enable-panning":!M}),onScroll:ke},re&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(q.TextBox,{value:F,onChange:ue,placeholder:u.toLanguageString(a.search,a.messages[a.search]),autoFocus:!0,onKeyDown:fe,suffix:()=>e.createElement(e.Fragment,null,e.createElement(q.InputSeparator,null),e.createElement(q.InputSuffix,null,e.createElement(m.Button,{icon:"convert-lowercase",svgIcon:f.convertLowercaseIcon,title:u.toLanguageString(a.matchCase,a.messages[a.matchCase]),fillMode:"flat",togglable:!0,selected:S,onClick:me})))}),e.createElement("span",{className:"k-search-matches"},e.createElement("span",null,k)," ",u.toLanguageString(a.searchOf,a.messages[a.searchOf]),e.createElement("span",null,y)),e.createElement(m.Button,{title:u.toLanguageString(a.prevMatch,a.messages[a.prevMatch]),fillMode:"flat",icon:"arrow-up",svgIcon:f.arrowUpIcon,disabled:y===0,onClick:ge}),e.createElement(m.Button,{title:u.toLanguageString(a.nextMatch,a.messages[a.nextMatch]),fillMode:"flat",icon:"arrow-down",svgIcon:f.arrowDownIcon,disabled:y===0,onClick:de}),e.createElement(m.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:T},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,C&&e.createElement(j.WatermarkOverlay,null))});A.displayName="KendoReactPDFViewer";A.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(oe).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};exports.PDFViewer=A;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De=require("react"),c=require("prop-types"),m=require("@progress/kendo-react-buttons"),q=require("@progress/kendo-react-inputs"),Fe=require("@progress/kendo-react-data-tools"),qe=require("@progress/kendo-react-upload"),je=require("@progress/kendo-react-dropdowns"),Ae=require("@progress/kendo-react-indicators"),j=require("@progress/kendo-react-common"),Ve=require("@progress/kendo-react-intl"),f=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.min.mjs");const We=require("./package-metadata.js"),i=require("@progress/kendo-pdfviewer-common"),a=require("./messages.js");function Ke(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const C in n)if(C!=="default"){const w=Object.getOwnPropertyDescriptor(n,C);Object.defineProperty(p,C,w.get?w:{enumerable:!0,get:()=>n[C]})}}return p.default=n,Object.freeze(p)}const e=Ke(De),oe=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],x={minZoom:.5,maxZoom:4,tools:[...oe],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},Ue=[".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 te=0;function _e(){return te++,te}const He=(n,p)=>n.priority>p.priority?-1:n.priority<p.priority?1:0,A=e.forwardRef((n,p)=>{const C=!j.validatePackage(We.packageMetadata,{component:"PDFViewer"}),{zoom:w,zoomLevels:V=x.zoomLevels,defaultZoom:M=x.defaultZoom,minZoom:N=x.minZoom,maxZoom:R=x.maxZoom,zoomRate:z=x.zoomRate}=n,u=Ve.useLocalization(),s=e.useRef(null),[ne,L]=e.useState(M),h=w!==void 0?w:ne,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[d,B]=e.useState(!1),[ae,k]=e.useState(!0),[P,W]=e.useState(0),[I,K]=e.useState(!0),[re,U]=e.useState(!1),[y,O]=e.useState(0),[v,E]=e.useState(0),[S,_]=e.useState(!1),[D,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))},[]),b=e.useRef(null),T=e.useRef(null);e.useImperativeHandle(b,()=>({get element(){return T.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(p,()=>b.current);const le=e.useCallback(()=>{if(t.props.onLoad){const o={target:b.current};t.props.onLoad.call(void 0,o)}},[]),J=e.useCallback((o,r,l)=>{if(n.onDownload){const g={target:b.current,blob:o,fileName:r,saveOptions:l};return n.onDownload.call(void 0,g)===!1}return!1},[n.onDownload]),ce=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()},[]),se=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,ce(),k(!1),B(!0),le(),s.current&&i.scrollToPage(s.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],k(!1),B(!1),n.onError){const r=typeof o=="string"?{message:o}:o,l={error:r!=null?r:u.toLanguageString(a.popupBlocked,a.messages[a.popupBlocked]),target:b.current};n.onError.call(void 0,l)}},[n.onError]),e.useEffect(()=>{s.current&&(n.url||n.data||n.arrayBuffer?(k(!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=[],B(!1),k(!1),i.removeChildren(s.current)))},[n.url,n.data,n.arrayBuffer]);const Q=e.useCallback((o,r)=>{s.current&&(k(!0),i.removeChildren(s.current),i.reloadDocument({pdfDoc:o,zoom:r,dom:s.current,done:l=>{t.pages=l,t.zoom=r,k(!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 ie=e.useCallback(()=>{U(!0),se(s.current)},[]),ue=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:S});E(l.length?1:0),O(l.length),H(r)},[S]),me=e.useCallback(()=>{const o=t.search.search({text:D,matchCase:!S});E(o.length?1:0),O(o.length),_(!S)},[S,D]),de=e.useCallback(()=>{i.goToNextSearchMatch(t),E(v+1>y?1:v+1)},[v,y]),ge=e.useCallback(()=>{i.goToPreviousSearchMatch(t),E(v-1<1?y:v-1)},[v,y]),X=e.useCallback(()=>{t.search.destroy(),E(0),O(0),_(!1),H(""),U(!1)},[]),fe=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),E(v+1>y?1:v+1)):o.key==="Escape"&&X()},[v,y]),he=e.useCallback(o=>{if(s.current){const r=o.skip;i.scrollToPage(s.current,r);const l={page:r+1,target:b.current,syntheticEvent:o.syntheticEvent};n.onPageChange&&n.onPageChange.call(void 0,l)}W(o.skip)},[P,n.onPageChange]),ke=e.useCallback(o=>{if(T.current){const r=i.currentPage(T.current);if(r!==P){W(r);const l={page:r+1,target:b.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[P,n.onPageChange]),ve=e.useCallback(o=>{const r=Math.min(t.currentZoom+z,R);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,R,n.onZoom]),be=e.useCallback(o=>{const r=Math.max(t.currentZoom-z,N);if(r!==t.currentZoom&&t.document&&(L(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[z,N,n.onZoom]),ye=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:b.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,g)}},[n.onZoom]),pe=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),K(!0)},[]),Ce=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),K(!1)},[]),Ee=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]),Se=e.useCallback(()=>{k(!0);const o=l=>{k(!1),t.error(l)},r=()=>{k(!1)};i.print(t.pages,r,o)},[]),xe=e.useCallback(o=>{const r=o.newState;r[0]&&r[0].getRawFile&&r[0].getRawFile().arrayBuffer().then(g=>{if(s.current){k(!0),i.removeChildren(s.current);const F=t.props.zoom===void 0?M:t.props.zoom;i.loadPDF({arrayBuffer:g,dom:s.current,zoom:F,done:t.done,error:t.error}),L(F)}})},[M]),we=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=ae&&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(Ae.Loader,{size:"large"}))),Ze=e.createElement(m.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(m.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomOut,a.messages[a.zoomOut]),disabled:h<=N||!d,onClick:be,icon:"zoom-out",svgIcon:f.zoomOutIcon}),e.createElement(m.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.zoomIn,a.messages[a.zoomIn]),disabled:h>=R||!d,onClick:ve,icon:"zoom-in",svgIcon:f.zoomInIcon})),ze=e.createElement(je.ComboBox,{className:"k-toolbar-combobox",disabled:!d,data:V.map(o=>({...o,text:o.locationString?u.toLanguageString(o.locationString,a.messages[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:d?Z:null,allowCustom:!0,onChange:ye,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Le=e.createElement(Fe.Pager,{disabled:!d,previousNext:!0,type:"input",skip:P,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:he}),Pe=e.createElement(m.ToolbarSpacer,null),Ie=e.createElement(m.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},e.createElement(m.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enableSelection,a.messages[a.enableSelection]),icon:"pointer",svgIcon:f.pointerIcon,disabled:!d,togglable:!0,selected:I&&d,onClick:pe}),e.createElement(m.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.enablePanning,a.messages[a.enablePanning]),icon:"hand",svgIcon:f.handIcon,disabled:!d,togglable:!0,selected:!I&&d,onClick:Ce})),Te=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.search,a.messages[a.search]),icon:"search",svgIcon:f.searchIcon,disabled:!d,onClick:ie}),Me=e.createElement(e.Fragment,null,e.createElement(m.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:we}),e.createElement("div",{style:{display:"none"}},e.createElement(qe.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:xe,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Ne=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.download,a.messages[a.download]),icon:"download",svgIcon:f.downloadIcon,disabled:!d,onClick:Ee}),Re=e.createElement(m.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:u.toLanguageString(a.print,a.messages[a.print]),icon:"print",svgIcon:f.printIcon,disabled:!d,onClick:Se}),Be={pager:Le,spacer:Pe,zoomInOut:Ze,zoom:ze,selection:Ie,search:Te,open:Me,download:Ne,print:Re},Oe=(n.tools||x.tools).map(o=>({...Be[o],key:"toobar-tool-"+o+_e()})),$=e.createElement(m.Toolbar,{buttons:Ue},...Oe),ee=e.createElement("div",{className:j.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":I,"k-enable-panning":!I}),onScroll:ke},re&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(q.TextBox,{value:D,onChange:ue,placeholder:u.toLanguageString(a.search,a.messages[a.search]),autoFocus:!0,onKeyDown:fe,suffix:()=>e.createElement(e.Fragment,null,e.createElement(q.InputSeparator,null),e.createElement(q.InputSuffix,null,e.createElement(m.Button,{icon:"convert-lowercase",svgIcon:f.convertLowercaseIcon,title:u.toLanguageString(a.matchCase,a.messages[a.matchCase]),fillMode:"flat",togglable:!0,selected:S,onClick:me})))}),e.createElement("span",{className:"k-search-matches"},e.createElement("span",null,v)," ",u.toLanguageString(a.searchOf,a.messages[a.searchOf]),e.createElement("span",null,y)),e.createElement(m.Button,{title:u.toLanguageString(a.prevMatch,a.messages[a.prevMatch]),fillMode:"flat",icon:"arrow-up",svgIcon:f.arrowUpIcon,disabled:y===0,onClick:ge}),e.createElement(m.Button,{title:u.toLanguageString(a.nextMatch,a.messages[a.nextMatch]),fillMode:"flat",icon:"arrow-down",svgIcon:f.arrowDownIcon,disabled:y===0,onClick:de}),e.createElement(m.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:T},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,C&&e.createElement(j.WatermarkOverlay,null))});A.displayName="KendoReactPDFViewer";A.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(oe).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};exports.PDFViewer=A;
|
package/PDFViewer.mjs
CHANGED
|
@@ -18,8 +18,8 @@ import { useLocalization as mt } from "@progress/kendo-react-intl";
|
|
|
18
18
|
import { zoomOutIcon as dt, zoomInIcon as gt, pointerIcon as ft, handIcon as ht, searchIcon as vt, folderOpenIcon as bt, downloadIcon as kt, printIcon as pt, convertLowercaseIcon as yt, arrowUpIcon as Ct, arrowDownIcon as Et, xIcon as St } from "@progress/kendo-svg-icons";
|
|
19
19
|
import "pdfjs-dist/build/pdf.worker.min.mjs";
|
|
20
20
|
import { packageMetadata as xt } from "./package-metadata.mjs";
|
|
21
|
-
import { Scroller as wt, SearchService as Zt, scrollToPage as X, removeChildren as
|
|
22
|
-
import { messages as i,
|
|
21
|
+
import { Scroller as wt, SearchService as Zt, scrollToPage as X, removeChildren as z, loadPDF as Y, reloadDocument as Lt, goToNextSearchMatch as ee, goToPreviousSearchMatch as zt, currentPage as It, calculateZoomLevel as Nt, download as Tt, print as Pt, DEFAULT_ZOOM_LEVEL as Mt } from "@progress/kendo-pdfviewer-common";
|
|
22
|
+
import { messages as i, popupBlocked as te, zoomOut as oe, zoomIn as ae, zoomLevel as ne, enableSelection as re, enablePanning as le, search as I, open as ce, download as se, print as ie, matchCase as ue, searchOf as me, prevMatch as de, nextMatch as ge, close as fe, actualWidth as Rt, fitToWidth as Ft, fitToPage as Dt } from "./messages.mjs";
|
|
23
23
|
const ve = [
|
|
24
24
|
"pager",
|
|
25
25
|
"spacer",
|
|
@@ -31,7 +31,7 @@ const ve = [
|
|
|
31
31
|
"open",
|
|
32
32
|
"download",
|
|
33
33
|
"print"
|
|
34
|
-
],
|
|
34
|
+
], y = {
|
|
35
35
|
minZoom: 0.5,
|
|
36
36
|
maxZoom: 4,
|
|
37
37
|
tools: [...ve],
|
|
@@ -49,7 +49,7 @@ const ve = [
|
|
|
49
49
|
{ id: 10, priority: 10, value: 3, text: "300%", type: "" },
|
|
50
50
|
{ id: 11, priority: 11, value: 4, text: "400%", type: "" }
|
|
51
51
|
],
|
|
52
|
-
defaultZoom:
|
|
52
|
+
defaultZoom: Mt
|
|
53
53
|
}, Ot = [
|
|
54
54
|
".k-toolbar > button",
|
|
55
55
|
".k-toolbar .k-combobox > input",
|
|
@@ -61,34 +61,34 @@ let he = 0;
|
|
|
61
61
|
function Bt() {
|
|
62
62
|
return he++, he;
|
|
63
63
|
}
|
|
64
|
-
const At = (a,
|
|
64
|
+
const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1 : 0, be = e.forwardRef((a, E) => {
|
|
65
65
|
const ke = !st(xt, { component: "PDFViewer" }), {
|
|
66
66
|
zoom: O,
|
|
67
|
-
zoomLevels: B =
|
|
68
|
-
defaultZoom:
|
|
69
|
-
minZoom:
|
|
70
|
-
maxZoom: P =
|
|
71
|
-
zoomRate:
|
|
72
|
-
} = a, s = mt(), c = e.useRef(null), [pe,
|
|
67
|
+
zoomLevels: B = y.zoomLevels,
|
|
68
|
+
defaultZoom: N = y.defaultZoom,
|
|
69
|
+
minZoom: T = y.minZoom,
|
|
70
|
+
maxZoom: P = y.maxZoom,
|
|
71
|
+
zoomRate: S = y.zoomRate
|
|
72
|
+
} = a, s = mt(), c = e.useRef(null), [pe, x] = e.useState(N), g = O !== void 0 ? O : pe, C = B.slice().sort(At).find((o) => o.value === g) || {
|
|
73
73
|
text: g * 100 + "%",
|
|
74
74
|
value: g,
|
|
75
75
|
id: g,
|
|
76
76
|
locationString: ""
|
|
77
77
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
i[
|
|
78
|
+
C.locationString && (C.text = s.toLanguageString(
|
|
79
|
+
C.locationString,
|
|
80
|
+
i[C.locationString]
|
|
81
81
|
));
|
|
82
|
-
const [
|
|
82
|
+
const [u, M] = e.useState(!1), [ye, f] = e.useState(!0), [w, A] = e.useState(0), [Z, V] = e.useState(!0), [Ce, W] = e.useState(!1), [b, R] = e.useState(0), [h, k] = e.useState(0), [p, K] = e.useState(!1), [F, U] = e.useState(""), t = e.useMemo(() => ({}), []);
|
|
83
83
|
t.currentZoom = g, t.props = a;
|
|
84
84
|
const j = e.useCallback((o) => {
|
|
85
85
|
c.current && c.current.style.setProperty("--scale-factor", String(o));
|
|
86
|
-
}, []),
|
|
86
|
+
}, []), v = e.useRef(null), L = e.useRef(null);
|
|
87
87
|
e.useImperativeHandle(
|
|
88
|
-
|
|
88
|
+
v,
|
|
89
89
|
() => ({
|
|
90
90
|
get element() {
|
|
91
|
-
return
|
|
91
|
+
return L.current;
|
|
92
92
|
},
|
|
93
93
|
props: a,
|
|
94
94
|
get pages() {
|
|
@@ -99,22 +99,22 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
99
99
|
}
|
|
100
100
|
}),
|
|
101
101
|
[]
|
|
102
|
-
), e.useImperativeHandle(
|
|
102
|
+
), e.useImperativeHandle(E, () => v.current);
|
|
103
103
|
const Ee = e.useCallback(() => {
|
|
104
104
|
if (t.props.onLoad) {
|
|
105
|
-
const o = { target:
|
|
105
|
+
const o = { target: v.current };
|
|
106
106
|
t.props.onLoad.call(void 0, o);
|
|
107
107
|
}
|
|
108
108
|
}, []), q = e.useCallback(
|
|
109
109
|
(o, n, r) => {
|
|
110
110
|
if (a.onDownload) {
|
|
111
|
-
const
|
|
112
|
-
target:
|
|
111
|
+
const m = {
|
|
112
|
+
target: v.current,
|
|
113
113
|
blob: o,
|
|
114
114
|
fileName: n,
|
|
115
115
|
saveOptions: r
|
|
116
116
|
};
|
|
117
|
-
return a.onDownload.call(void 0,
|
|
117
|
+
return a.onDownload.call(void 0, m) === !1;
|
|
118
118
|
}
|
|
119
119
|
return !1;
|
|
120
120
|
},
|
|
@@ -135,20 +135,20 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
135
135
|
});
|
|
136
136
|
}, []);
|
|
137
137
|
t.done = e.useCallback(({ pdfPages: o, pdfDoc: n, zoom: r }) => {
|
|
138
|
-
t.document = n, t.pages = o, t.zoom = r, Se(),
|
|
138
|
+
t.document = n, t.pages = o, t.zoom = r, Se(), f(!1), M(!0), Ee(), c.current && X(c.current, 0);
|
|
139
139
|
}, []), t.error = e.useCallback(
|
|
140
140
|
(o) => {
|
|
141
|
-
if (t.document = null, t.pages = [],
|
|
142
|
-
const n = {
|
|
143
|
-
error:
|
|
144
|
-
target:
|
|
141
|
+
if (t.document = null, t.pages = [], f(!1), M(!1), a.onError) {
|
|
142
|
+
const n = typeof o == "string" ? { message: o } : o, r = {
|
|
143
|
+
error: n != null ? n : s.toLanguageString(te, i[te]),
|
|
144
|
+
target: v.current
|
|
145
145
|
};
|
|
146
|
-
a.onError.call(void 0,
|
|
146
|
+
a.onError.call(void 0, r);
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
[a.onError]
|
|
150
150
|
), e.useEffect(() => {
|
|
151
|
-
c.current && (a.url || a.data || a.arrayBuffer ? (
|
|
151
|
+
c.current && (a.url || a.data || a.arrayBuffer ? (f(!0), z(c.current), Y({
|
|
152
152
|
url: a.url,
|
|
153
153
|
data: a.data,
|
|
154
154
|
arrayBuffer: a.arrayBuffer,
|
|
@@ -156,15 +156,15 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
156
156
|
zoom: t.currentZoom,
|
|
157
157
|
done: t.done,
|
|
158
158
|
error: t.error
|
|
159
|
-
}), j(t.currentZoom)) : (t.document = null, t.pages = [],
|
|
159
|
+
}), j(t.currentZoom)) : (t.document = null, t.pages = [], M(!1), f(!1), z(c.current)));
|
|
160
160
|
}, [a.url, a.data, a.arrayBuffer]);
|
|
161
161
|
const H = e.useCallback((o, n) => {
|
|
162
|
-
c.current && (
|
|
162
|
+
c.current && (f(!0), z(c.current), Lt({
|
|
163
163
|
pdfDoc: o,
|
|
164
164
|
zoom: n,
|
|
165
165
|
dom: c.current,
|
|
166
166
|
done: (r) => {
|
|
167
|
-
t.pages = r, t.zoom = n,
|
|
167
|
+
t.pages = r, t.zoom = n, f(!1);
|
|
168
168
|
},
|
|
169
169
|
error: t.error
|
|
170
170
|
}));
|
|
@@ -179,23 +179,23 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
179
179
|
}, []), Ze = e.useCallback(
|
|
180
180
|
(o) => {
|
|
181
181
|
const n = o.value, r = t.search.search({ text: n, matchCase: p });
|
|
182
|
-
k(r.length ? 1 : 0),
|
|
182
|
+
k(r.length ? 1 : 0), R(r.length), U(n);
|
|
183
183
|
},
|
|
184
184
|
[p]
|
|
185
185
|
), Le = e.useCallback(() => {
|
|
186
|
-
const o = t.search.search({ text:
|
|
187
|
-
k(o.length ? 1 : 0),
|
|
188
|
-
}, [p,
|
|
189
|
-
ee(t), k(
|
|
190
|
-
}, [
|
|
191
|
-
zt(t), k(
|
|
192
|
-
}, [
|
|
193
|
-
t.search.destroy(), k(0),
|
|
186
|
+
const o = t.search.search({ text: F, matchCase: !p });
|
|
187
|
+
k(o.length ? 1 : 0), R(o.length), K(!p);
|
|
188
|
+
}, [p, F]), ze = e.useCallback(() => {
|
|
189
|
+
ee(t), k(h + 1 > b ? 1 : h + 1);
|
|
190
|
+
}, [h, b]), Ie = e.useCallback(() => {
|
|
191
|
+
zt(t), k(h - 1 < 1 ? b : h - 1);
|
|
192
|
+
}, [h, b]), $ = e.useCallback(() => {
|
|
193
|
+
t.search.destroy(), k(0), R(0), K(!1), U(""), W(!1);
|
|
194
194
|
}, []), Ne = e.useCallback(
|
|
195
195
|
(o) => {
|
|
196
|
-
o.key === "Enter" ? (o.preventDefault(), ee(t), k(
|
|
196
|
+
o.key === "Enter" ? (o.preventDefault(), ee(t), k(h + 1 > b ? 1 : h + 1)) : o.key === "Escape" && $();
|
|
197
197
|
},
|
|
198
|
-
[
|
|
198
|
+
[h, b]
|
|
199
199
|
), Te = e.useCallback(
|
|
200
200
|
(o) => {
|
|
201
201
|
if (c.current) {
|
|
@@ -203,71 +203,71 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
203
203
|
X(c.current, n);
|
|
204
204
|
const r = {
|
|
205
205
|
page: n + 1,
|
|
206
|
-
target:
|
|
206
|
+
target: v.current,
|
|
207
207
|
syntheticEvent: o.syntheticEvent
|
|
208
208
|
};
|
|
209
209
|
a.onPageChange && a.onPageChange.call(void 0, r);
|
|
210
210
|
}
|
|
211
211
|
A(o.skip);
|
|
212
212
|
},
|
|
213
|
-
[
|
|
214
|
-
),
|
|
213
|
+
[w, a.onPageChange]
|
|
214
|
+
), Pe = e.useCallback(
|
|
215
215
|
(o) => {
|
|
216
|
-
if (
|
|
217
|
-
const n = It(
|
|
218
|
-
if (n !==
|
|
216
|
+
if (L.current) {
|
|
217
|
+
const n = It(L.current);
|
|
218
|
+
if (n !== w) {
|
|
219
219
|
A(n);
|
|
220
220
|
const r = {
|
|
221
221
|
page: n + 1,
|
|
222
|
-
target:
|
|
222
|
+
target: v.current,
|
|
223
223
|
syntheticEvent: o
|
|
224
224
|
};
|
|
225
225
|
a.onPageChange && a.onPageChange.call(void 0, r);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
|
-
[
|
|
230
|
-
),
|
|
229
|
+
[w, a.onPageChange]
|
|
230
|
+
), Me = e.useCallback(
|
|
231
231
|
(o) => {
|
|
232
|
-
const n = Math.min(t.currentZoom +
|
|
233
|
-
if (n !== t.currentZoom && t.document && (
|
|
232
|
+
const n = Math.min(t.currentZoom + S, P);
|
|
233
|
+
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
234
234
|
const r = {
|
|
235
235
|
zoom: n,
|
|
236
|
-
target:
|
|
236
|
+
target: v.current,
|
|
237
237
|
syntheticEvent: o
|
|
238
238
|
};
|
|
239
239
|
a.onZoom.call(void 0, r);
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
|
-
[
|
|
242
|
+
[S, P, a.onZoom]
|
|
243
243
|
), Re = e.useCallback(
|
|
244
244
|
(o) => {
|
|
245
|
-
const n = Math.max(t.currentZoom -
|
|
246
|
-
if (n !== t.currentZoom && t.document && (
|
|
245
|
+
const n = Math.max(t.currentZoom - S, T);
|
|
246
|
+
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
247
247
|
const r = {
|
|
248
248
|
zoom: n,
|
|
249
|
-
target:
|
|
249
|
+
target: v.current,
|
|
250
250
|
syntheticEvent: o
|
|
251
251
|
};
|
|
252
252
|
a.onZoom.call(void 0, r);
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
|
-
[
|
|
255
|
+
[S, T, a.onZoom]
|
|
256
256
|
), Fe = e.useCallback(
|
|
257
257
|
(o) => {
|
|
258
258
|
const n = o.value === null ? { text: "100%", value: 1, id: 100 } : { ...o.value };
|
|
259
259
|
if (n.value === void 0) {
|
|
260
|
-
const
|
|
261
|
-
typeof
|
|
260
|
+
const m = parseFloat(n.text);
|
|
261
|
+
typeof m == "number" && !Number.isNaN(m) ? n.value = m / 100 : n.value = 1;
|
|
262
262
|
}
|
|
263
263
|
let r = n ? Nt(n.value, n.type, t.currentZoom, c.current) : 1;
|
|
264
|
-
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (
|
|
265
|
-
const
|
|
264
|
+
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (x(r), a.onZoom)) {
|
|
265
|
+
const m = {
|
|
266
266
|
zoom: r,
|
|
267
|
-
target:
|
|
267
|
+
target: v.current,
|
|
268
268
|
syntheticEvent: o.syntheticEvent
|
|
269
269
|
};
|
|
270
|
-
a.onZoom.call(void 0,
|
|
270
|
+
a.onZoom.call(void 0, m);
|
|
271
271
|
}
|
|
272
272
|
},
|
|
273
273
|
[a.onZoom]
|
|
@@ -286,37 +286,36 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
286
286
|
q
|
|
287
287
|
);
|
|
288
288
|
}, [a.url, a.data, a.arrayBuffer, a.saveFileName, a.saveOptions, q]), Ae = e.useCallback(() => {
|
|
289
|
-
|
|
289
|
+
f(!0);
|
|
290
290
|
const o = (r) => {
|
|
291
|
-
|
|
292
|
-
t.error((y = (u = r == null ? void 0 : r.message) != null ? u : r) != null ? y : s.toLanguageString(fe, i[fe]));
|
|
291
|
+
f(!1), t.error(r);
|
|
293
292
|
}, n = () => {
|
|
294
|
-
|
|
293
|
+
f(!1);
|
|
295
294
|
};
|
|
296
|
-
|
|
295
|
+
Pt(t.pages, n, o);
|
|
297
296
|
}, []), Ve = e.useCallback(
|
|
298
297
|
(o) => {
|
|
299
298
|
const n = o.newState;
|
|
300
|
-
n[0] && n[0].getRawFile && n[0].getRawFile().arrayBuffer().then((
|
|
299
|
+
n[0] && n[0].getRawFile && n[0].getRawFile().arrayBuffer().then((m) => {
|
|
301
300
|
if (c.current) {
|
|
302
|
-
|
|
303
|
-
const
|
|
301
|
+
f(!0), z(c.current);
|
|
302
|
+
const D = t.props.zoom === void 0 ? N : t.props.zoom;
|
|
304
303
|
Y({
|
|
305
|
-
arrayBuffer:
|
|
304
|
+
arrayBuffer: m,
|
|
306
305
|
dom: c.current,
|
|
307
|
-
zoom:
|
|
306
|
+
zoom: D,
|
|
308
307
|
done: t.done,
|
|
309
308
|
error: t.error
|
|
310
|
-
}),
|
|
309
|
+
}), x(D);
|
|
311
310
|
}
|
|
312
311
|
});
|
|
313
312
|
},
|
|
314
|
-
[
|
|
313
|
+
[N]
|
|
315
314
|
), We = e.useCallback((o) => {
|
|
316
315
|
const n = o.target;
|
|
317
316
|
if (n instanceof Element && n.parentNode) {
|
|
318
|
-
const r = n.closest(".k-toolbar"),
|
|
319
|
-
|
|
317
|
+
const r = n.closest(".k-toolbar"), m = r && r.querySelector(".k-upload input");
|
|
318
|
+
m && m.click();
|
|
320
319
|
}
|
|
321
320
|
}, []), _ = 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(Q, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
322
321
|
d,
|
|
@@ -324,8 +323,8 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
324
323
|
className: "k-group-start",
|
|
325
324
|
fillMode: "flat",
|
|
326
325
|
themeColor: "base",
|
|
327
|
-
title: s.toLanguageString(
|
|
328
|
-
disabled: g <=
|
|
326
|
+
title: s.toLanguageString(oe, i[oe]),
|
|
327
|
+
disabled: g <= T || !u,
|
|
329
328
|
onClick: Re,
|
|
330
329
|
icon: "zoom-out",
|
|
331
330
|
svgIcon: dt
|
|
@@ -336,9 +335,9 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
336
335
|
className: "k-group-end",
|
|
337
336
|
fillMode: "flat",
|
|
338
337
|
themeColor: "base",
|
|
339
|
-
title: s.toLanguageString(
|
|
340
|
-
disabled: g >= P || !
|
|
341
|
-
onClick:
|
|
338
|
+
title: s.toLanguageString(ae, i[ae]),
|
|
339
|
+
disabled: g >= P || !u,
|
|
340
|
+
onClick: Me,
|
|
342
341
|
icon: "zoom-in",
|
|
343
342
|
svgIcon: gt
|
|
344
343
|
}
|
|
@@ -346,25 +345,25 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
346
345
|
lt,
|
|
347
346
|
{
|
|
348
347
|
className: "k-toolbar-combobox",
|
|
349
|
-
disabled: !
|
|
348
|
+
disabled: !u,
|
|
350
349
|
data: B.map((o) => ({
|
|
351
350
|
...o,
|
|
352
351
|
text: o.locationString ? s.toLanguageString(o.locationString, i[o.locationString]) : o.text
|
|
353
352
|
})),
|
|
354
353
|
dataItemKey: "id",
|
|
355
354
|
textField: "text",
|
|
356
|
-
value:
|
|
355
|
+
value: u ? C : null,
|
|
357
356
|
allowCustom: !0,
|
|
358
357
|
onChange: Fe,
|
|
359
|
-
placeholder: s.toLanguageString(
|
|
358
|
+
placeholder: s.toLanguageString(ne, i[ne])
|
|
360
359
|
}
|
|
361
360
|
), je = /* @__PURE__ */ e.createElement(
|
|
362
361
|
nt,
|
|
363
362
|
{
|
|
364
|
-
disabled: !
|
|
363
|
+
disabled: !u,
|
|
365
364
|
previousNext: !0,
|
|
366
365
|
type: "input",
|
|
367
|
-
skip:
|
|
366
|
+
skip: w,
|
|
368
367
|
take: 1,
|
|
369
368
|
total: t.pages ? t.pages.length : 0,
|
|
370
369
|
info: !1,
|
|
@@ -376,12 +375,12 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
376
375
|
className: "k-group-start",
|
|
377
376
|
fillMode: "flat",
|
|
378
377
|
themeColor: "base",
|
|
379
|
-
title: s.toLanguageString(
|
|
378
|
+
title: s.toLanguageString(re, i[re]),
|
|
380
379
|
icon: "pointer",
|
|
381
380
|
svgIcon: ft,
|
|
382
|
-
disabled: !
|
|
381
|
+
disabled: !u,
|
|
383
382
|
togglable: !0,
|
|
384
|
-
selected:
|
|
383
|
+
selected: Z && u,
|
|
385
384
|
onClick: De
|
|
386
385
|
}
|
|
387
386
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -390,12 +389,12 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
390
389
|
className: "k-group-end",
|
|
391
390
|
fillMode: "flat",
|
|
392
391
|
themeColor: "base",
|
|
393
|
-
title: s.toLanguageString(
|
|
392
|
+
title: s.toLanguageString(le, i[le]),
|
|
394
393
|
icon: "hand",
|
|
395
394
|
svgIcon: ht,
|
|
396
|
-
disabled: !
|
|
395
|
+
disabled: !u,
|
|
397
396
|
togglable: !0,
|
|
398
|
-
selected: !
|
|
397
|
+
selected: !Z && u,
|
|
399
398
|
onClick: Oe
|
|
400
399
|
}
|
|
401
400
|
)), $e = /* @__PURE__ */ e.createElement(
|
|
@@ -404,10 +403,10 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
404
403
|
className: "k-toolbar-button",
|
|
405
404
|
fillMode: "flat",
|
|
406
405
|
themeColor: "base",
|
|
407
|
-
title: s.toLanguageString(
|
|
406
|
+
title: s.toLanguageString(I, i[I]),
|
|
408
407
|
icon: "search",
|
|
409
408
|
svgIcon: vt,
|
|
410
|
-
disabled: !
|
|
409
|
+
disabled: !u,
|
|
411
410
|
onClick: we
|
|
412
411
|
}
|
|
413
412
|
), _e = /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
@@ -416,7 +415,7 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
416
415
|
className: "k-toolbar-button",
|
|
417
416
|
fillMode: "flat",
|
|
418
417
|
themeColor: "base",
|
|
419
|
-
title: s.toLanguageString(
|
|
418
|
+
title: s.toLanguageString(ce, i[ce]),
|
|
420
419
|
icon: "folder-open",
|
|
421
420
|
svgIcon: bt,
|
|
422
421
|
onClick: We
|
|
@@ -438,10 +437,10 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
438
437
|
className: "k-toolbar-button",
|
|
439
438
|
fillMode: "flat",
|
|
440
439
|
themeColor: "base",
|
|
441
|
-
title: s.toLanguageString(
|
|
440
|
+
title: s.toLanguageString(se, i[se]),
|
|
442
441
|
icon: "download",
|
|
443
442
|
svgIcon: kt,
|
|
444
|
-
disabled: !
|
|
443
|
+
disabled: !u,
|
|
445
444
|
onClick: Be
|
|
446
445
|
}
|
|
447
446
|
), Je = /* @__PURE__ */ e.createElement(
|
|
@@ -450,10 +449,10 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
450
449
|
className: "k-toolbar-button",
|
|
451
450
|
fillMode: "flat",
|
|
452
451
|
themeColor: "base",
|
|
453
|
-
title: s.toLanguageString(
|
|
452
|
+
title: s.toLanguageString(ie, i[ie]),
|
|
454
453
|
icon: "print",
|
|
455
454
|
svgIcon: pt,
|
|
456
|
-
disabled: !
|
|
455
|
+
disabled: !u,
|
|
457
456
|
onClick: Ae
|
|
458
457
|
}
|
|
459
458
|
), Qe = {
|
|
@@ -466,24 +465,24 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
466
465
|
open: _e,
|
|
467
466
|
download: Ge,
|
|
468
467
|
print: Je
|
|
469
|
-
}, Xe = (a.tools ||
|
|
468
|
+
}, Xe = (a.tools || y.tools).map((o) => ({
|
|
470
469
|
...Qe[o],
|
|
471
470
|
key: "toobar-tool-" + o + Bt()
|
|
472
471
|
})), G = /* @__PURE__ */ e.createElement(Ye, { buttons: Ot }, ...Xe), J = /* @__PURE__ */ e.createElement(
|
|
473
472
|
"div",
|
|
474
473
|
{
|
|
475
474
|
className: it("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto", {
|
|
476
|
-
"k-enable-text-select":
|
|
477
|
-
"k-enable-panning": !
|
|
475
|
+
"k-enable-text-select": Z,
|
|
476
|
+
"k-enable-panning": !Z
|
|
478
477
|
}),
|
|
479
|
-
onScroll:
|
|
478
|
+
onScroll: Pe
|
|
480
479
|
},
|
|
481
480
|
Ce && /* @__PURE__ */ e.createElement("div", { className: "k-search-panel k-pos-sticky k-top-center" }, /* @__PURE__ */ e.createElement(
|
|
482
481
|
tt,
|
|
483
482
|
{
|
|
484
|
-
value:
|
|
483
|
+
value: F,
|
|
485
484
|
onChange: Ze,
|
|
486
|
-
placeholder: s.toLanguageString(
|
|
485
|
+
placeholder: s.toLanguageString(I, i[I]),
|
|
487
486
|
autoFocus: !0,
|
|
488
487
|
onKeyDown: Ne,
|
|
489
488
|
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(ot, null), /* @__PURE__ */ e.createElement(at, null, /* @__PURE__ */ e.createElement(
|
|
@@ -491,7 +490,7 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
491
490
|
{
|
|
492
491
|
icon: "convert-lowercase",
|
|
493
492
|
svgIcon: yt,
|
|
494
|
-
title: s.toLanguageString(
|
|
493
|
+
title: s.toLanguageString(ue, i[ue]),
|
|
495
494
|
fillMode: "flat",
|
|
496
495
|
togglable: !0,
|
|
497
496
|
selected: p,
|
|
@@ -499,10 +498,10 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
499
498
|
}
|
|
500
499
|
)))
|
|
501
500
|
}
|
|
502
|
-
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null,
|
|
501
|
+
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, h), " ", s.toLanguageString(me, i[me]), /* @__PURE__ */ e.createElement("span", null, b)), /* @__PURE__ */ e.createElement(
|
|
503
502
|
d,
|
|
504
503
|
{
|
|
505
|
-
title: s.toLanguageString(
|
|
504
|
+
title: s.toLanguageString(de, i[de]),
|
|
506
505
|
fillMode: "flat",
|
|
507
506
|
icon: "arrow-up",
|
|
508
507
|
svgIcon: Ct,
|
|
@@ -512,7 +511,7 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
512
511
|
), /* @__PURE__ */ e.createElement(
|
|
513
512
|
d,
|
|
514
513
|
{
|
|
515
|
-
title: s.toLanguageString(
|
|
514
|
+
title: s.toLanguageString(ge, i[ge]),
|
|
516
515
|
fillMode: "flat",
|
|
517
516
|
icon: "arrow-down",
|
|
518
517
|
svgIcon: Et,
|
|
@@ -522,7 +521,7 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
522
521
|
), /* @__PURE__ */ e.createElement(
|
|
523
522
|
d,
|
|
524
523
|
{
|
|
525
|
-
title: s.toLanguageString(
|
|
524
|
+
title: s.toLanguageString(fe, i[fe]),
|
|
526
525
|
fillMode: "flat",
|
|
527
526
|
icon: "x",
|
|
528
527
|
svgIcon: St,
|
|
@@ -531,7 +530,7 @@ const At = (a, S) => a.priority > S.priority ? -1 : a.priority < S.priority ? 1
|
|
|
531
530
|
)),
|
|
532
531
|
/* @__PURE__ */ e.createElement("div", { ref: c, className: "k-pdf-viewer-pages" })
|
|
533
532
|
);
|
|
534
|
-
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style: a.style, ref:
|
|
533
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style: a.style, ref: L }, a.onRenderLoader ? a.onRenderLoader.call(void 0, _ || null) : _, a.onRenderToolbar ? a.onRenderToolbar.call(void 0, G) : G, a.onRenderContent ? a.onRenderContent.call(void 0, J) : J, ke && /* @__PURE__ */ e.createElement(ut, null));
|
|
535
534
|
});
|
|
536
535
|
be.displayName = "KendoReactPDFViewer";
|
|
537
536
|
be.propTypes = {
|
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://www.telerik.com/kendo-react-ui/components/npm-banner.svg"/>
|
|
3
|
-
</a>
|
|
1
|
+
[](https://www.telerik.com/kendo-react-ui/components/free?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer&utm_content=banner)
|
|
4
2
|
|
|
5
3
|
# KendoReact PDF Viewer Library for React
|
|
6
4
|
|
|
7
5
|
> **Important**
|
|
8
6
|
>
|
|
9
|
-
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)—
|
|
10
|
-
> - You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer).
|
|
7
|
+
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)—an enterprise-grade UI library with 120+ free and premium components.
|
|
8
|
+
> - It provides a premium KendoReact component. You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer).
|
|
11
9
|
> - To receive a license key, you need to either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer) or register for a [free trial](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer). Doing so indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer).
|
|
12
|
-
> - The 30-day free trial gives you access to all
|
|
10
|
+
> - The 30-day free trial gives you access to all KendoReact components and their full functionality. Additionally, for the period of your trial, you can use our legendary technical support provided directly by the KendoReact dev team!
|
|
13
11
|
>
|
|
14
12
|
> [Start using KendoReact](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer) and speed up your development process!
|
|
13
|
+
>
|
|
14
|
+
> If you're looking for free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free).
|
|
15
15
|
|
|
16
16
|
The [React PDF Viewer library](https://www.telerik.com/kendo-react-ui/pdfviewer), part of KendoReact, allows users to view and interact with PDF files directly in the browser, without needing to download the file or use third-party tools or browser extensions.
|
|
17
17
|
|
|
@@ -31,13 +31,14 @@ Among the features which the KendoReact PDF Viewer component delivers are:
|
|
|
31
31
|
|
|
32
32
|
For any issues you might encounter while working with the KendoReact PDF Viewer, use any of the available support channels:
|
|
33
33
|
|
|
34
|
-
- Industry-leading technical support—KendoReact paid license holders and users with an active (free) trial license can take advantage of our outstanding customer support. To submit a ticket, use [the dedicated KendoReact support system](https://www.telerik.com/account/support-
|
|
34
|
+
- Industry-leading technical support—KendoReact paid license holders and users with an active (free) trial license can take advantage of our outstanding customer support. To submit a ticket, use [the dedicated KendoReact support system](https://www.telerik.com/account/support-center/contact-us/technical-support?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-listview).
|
|
35
35
|
- Product forums—The [KendoReact forums](https://www.telerik.com/forums/kendo-ui-react?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-listview) are part of the free support you can get from the community and from the KendoReact team.
|
|
36
36
|
- Feedback portal—The [KendoReact feedback portal](https://feedback.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer) is where you can request and vote for new features to be added.
|
|
37
37
|
|
|
38
38
|
## Resources
|
|
39
39
|
|
|
40
40
|
- [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)
|
|
41
|
+
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free)
|
|
41
42
|
- [Get Started with the KendoReact PDF Viewer](https://www.telerik.com/kendo-react-ui/components/pdfviewer/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)
|
|
42
43
|
- [API Reference of the KendoReact PDF Viewer](https://www.telerik.com/kendo-react-ui/components/pdfviewer/api/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)
|
|
43
44
|
- [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-pdfviewer)
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!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.min.mjs")):"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.min.mjs"],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",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:1673300081,version:"$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",I="pdfviewer.matchCase",P="pdfviewer.prevMatch",N="pdfviewer.nextMatch",z="pdfviewer.actualWidth",L="pdfviewer.fitToWidth",R="pdfviewer.fitToPage",Z="pdfviewer.popupBlocked",T="pdfviewer.searchOf",O={[v]:"Zoom in",[k]:"Zoom out",[b]:"Choose zoom level",[h]:"Enable selection",[y]:"Enable panning",[C]:"Search",[w]:"Open",[E]:"Download",[T]:"of",[S]:"Print",[x]:"Close",[I]:"Match case",[P]:"Previous match",[N]:"Next match",[z]:"Actual width",[L]:"Fit to width",[R]:"Fit to page",[Z]:"Popup is blocked."},B=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],D={minZoom:.5,maxZoom:4,tools:[...B],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:z},{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:R},{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},F=[".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 M=0;const K=(e,o)=>e.priority>o.priority?-1:e.priority<o.priority?1:0,q=g.forwardRef(((e,t)=>{const r=!u.validatePackage(f,{component:"PDFViewer"}),{zoom:m,zoomLevels:z=D.zoomLevels,defaultZoom:L=D.defaultZoom,minZoom:R=D.minZoom,maxZoom:B=D.maxZoom,zoomRate:q=D.zoomRate}=e,j=d.useLocalization(),A=g.useRef(null),[U,V]=g.useState(L),W=void 0!==m?m:U,_=z.slice().sort(K).find((e=>e.value===W))||{text:100*W+"%",value:W,id:W,locationString:""};_.locationString&&(_.text=j.toLanguageString(_.locationString,O[_.locationString]));const[G,H]=g.useState(!1),[$,J]=g.useState(!0),[Q,X]=g.useState(0),[Y,ee]=g.useState(!0),[oe,te]=g.useState(!1),[re,ae]=g.useState(0),[ne,le]=g.useState(0),[ce,se]=g.useState(!1),[ie,ue]=g.useState(""),de=g.useMemo((()=>({})),[]);de.currentZoom=W,de.props=e;const pe=g.useCallback((e=>{A.current&&A.current.style.setProperty("--scale-factor",String(e))}),[]),me=g.useRef(null),ge=g.useRef(null);g.useImperativeHandle(me,(()=>({get element(){return ge.current},props:e,get pages(){return de.pages},get document(){return de.document}})),[]),g.useImperativeHandle(t,(()=>me.current));const fe=g.useCallback((()=>{if(de.props.onLoad){const e={target:me.current};de.props.onLoad.call(void 0,e)}}),[]),ve=g.useCallback(((o,t,r)=>{if(e.onDownload){const a={target:me.current,blob:o,fileName:t,saveOptions:r};return!1===e.onDownload.call(void 0,a)}return!1}),[e.onDownload]),ke=g.useCallback((()=>{var e;de.scroller&&de.scroller.destroy(),de.scroller=new o.Scroller(null==(e=A.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),de.scroller.disablePanEventsTracking()}),[]),be=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));de.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);de.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{de.document=t,de.pages=e,de.zoom=r,ke(),J(!1),H(!0),fe(),A.current&&o.scrollToPage(A.current,0)}),[]),de.error=g.useCallback((o=>{if(de.document=null,de.pages=[],J(!1),H(!1),e.onError){const t={error:"string"==typeof o?{message:o}:o,target:me.current};e.onError.call(void 0,t)}}),[e.onError]),g.useEffect((()=>{A.current&&(e.url||e.data||e.arrayBuffer?(J(!0),o.removeChildren(A.current),o.loadPDF({url:e.url,data:e.data,arrayBuffer:e.arrayBuffer,dom:A.current,zoom:de.currentZoom,done:de.done,error:de.error}),pe(de.currentZoom)):(de.document=null,de.pages=[],H(!1),J(!1),o.removeChildren(A.current)))}),[e.url,e.data,e.arrayBuffer]);const he=g.useCallback(((e,t)=>{A.current&&(J(!0),o.removeChildren(A.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:A.current,done:e=>{de.pages=e,de.zoom=t,J(!1)},error:de.error}))}),[]);g.useEffect((()=>{pe(W),A.current&&de.document&&W!==de.zoom&&he(de.document,W)}),[W,he]),g.useEffect((()=>()=>{de.scroller&&de.scroller.destroy(),de.search&&de.search.destroy(),de.document=null,de.pages=[]}),[]);const ye=g.useCallback((()=>{te(!0),be(A.current)}),[]),Ce=g.useCallback((e=>{const o=e.value,t=de.search.search({text:o,matchCase:ce});le(t.length?1:0),ae(t.length),ue(o)}),[ce]),we=g.useCallback((()=>{const e=de.search.search({text:ie,matchCase:!ce});le(e.length?1:0),ae(e.length),se(!ce)}),[ce,ie]),Ee=g.useCallback((()=>{o.goToNextSearchMatch(de),le(ne+1>re?1:ne+1)}),[ne,re]),Se=g.useCallback((()=>{o.goToPreviousSearchMatch(de),le(ne-1<1?re:ne-1)}),[ne,re]),xe=g.useCallback((()=>{de.search.destroy(),le(0),ae(0),se(!1),ue(""),te(!1)}),[]),Ie=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(de),le(ne+1>re?1:ne+1)):"Escape"===e.key&&xe()}),[ne,re]),Pe=g.useCallback((t=>{if(A.current){const r=t.skip;o.scrollToPage(A.current,r);const a={page:r+1,target:me.current,syntheticEvent:t.syntheticEvent};e.onPageChange&&e.onPageChange.call(void 0,a)}X(t.skip)}),[Q,e.onPageChange]),Ne=g.useCallback((t=>{if(ge.current){const r=o.currentPage(ge.current);if(r!==Q){X(r);const o={page:r+1,target:me.current,syntheticEvent:t};e.onPageChange&&e.onPageChange.call(void 0,o)}}}),[Q,e.onPageChange]),ze=g.useCallback((o=>{const t=Math.min(de.currentZoom+q,B);if(t!==de.currentZoom&&de.document&&(V(t),e.onZoom)){const r={zoom:t,target:me.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[q,B,e.onZoom]),Le=g.useCallback((o=>{const t=Math.max(de.currentZoom-q,R);if(t!==de.currentZoom&&de.document&&(V(t),e.onZoom)){const r={zoom:t,target:me.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[q,R,e.onZoom]),Re=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,de.currentZoom,A.current):1;if(a=Math.round(100*a)/100,de.currentZoom!==a&&de.document&&(V(a),e.onZoom)){const o={zoom:a,target:me.current,syntheticEvent:t.syntheticEvent};e.onZoom.call(void 0,o)}}),[e.onZoom]),Ze=g.useCallback((()=>{de.scroller.disablePanEventsTracking(),ee(!0)}),[]),Te=g.useCallback((()=>{de.scroller.enablePanEventsTracking(),ee(!1)}),[]),Oe=g.useCallback((()=>{o.download({pdf:de.document,error:de.error},e.saveFileName,e.saveOptions,ve)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,ve]),Be=g.useCallback((()=>{J(!0);o.print(de.pages,(()=>{J(!1)}),(e=>{var o,t;de.error(null!=(t=null!=(o=null==e?void 0:e.message)?o:e)?t:j.toLanguageString(Z,O[Z]))}))}),[]),De=g.useCallback((e=>{const t=e.newState;t[0]&&t[0].getRawFile&&t[0].getRawFile().arrayBuffer().then((e=>{if(A.current){J(!0),o.removeChildren(A.current);const t=void 0===de.props.zoom?L:de.props.zoom;o.loadPDF({arrayBuffer:e,dom:A.current,zoom:t,done:de.done,error:de.error}),V(t)}}))}),[L]),Fe=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()}}),[]),Me=$&&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(a.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},g.createElement(a.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:j.toLanguageString(k,O[k]),disabled:W<=R||!G,onClick:Le,icon:"zoom-out",svgIcon:p.zoomOutIcon}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:j.toLanguageString(v,O[v]),disabled:W>=B||!G,onClick:ze,icon:"zoom-in",svgIcon:p.zoomInIcon})),qe=g.createElement(s.ComboBox,{className:"k-toolbar-combobox",disabled:!G,data:z.map((e=>({...e,text:e.locationString?j.toLanguageString(e.locationString,O[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:G?_:null,allowCustom:!0,onChange:Re,placeholder:j.toLanguageString(b,O[b])}),je={pager:g.createElement(l.Pager,{disabled:!G,previousNext:!0,type:"input",skip:Q,take:1,total:de.pages?de.pages.length:0,info:!1,onPageChange:Pe}),spacer:g.createElement(a.ToolbarSpacer,null),zoomInOut:Ke,zoom:qe,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:j.toLanguageString(h,O[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!G,togglable:!0,selected:Y&&G,onClick:Ze}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:j.toLanguageString(y,O[y]),icon:"hand",svgIcon:p.handIcon,disabled:!G,togglable:!0,selected:!Y&&G,onClick:Te})),search:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(C,O[C]),icon:"search",svgIcon:p.searchIcon,disabled:!G,onClick:ye}),open:g.createElement(g.Fragment,null,g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(w,O[w]),icon:"folder-open",svgIcon:p.folderOpenIcon,onClick:Fe}),g.createElement("div",{style:{display:"none"}},g.createElement(c.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:De,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),download:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(E,O[E]),icon:"download",svgIcon:p.downloadIcon,disabled:!G,onClick:Oe}),print:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(S,O[S]),icon:"print",svgIcon:p.printIcon,disabled:!G,onClick:Be})},Ae=(e.tools||D.tools).map((e=>({...je[e],key:"toobar-tool-"+e+(M++,M)}))),Ue=g.createElement(a.Toolbar,{buttons:F},...Ae),Ve=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:Ne},oe&&g.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},g.createElement(n.TextBox,{value:ie,onChange:Ce,placeholder:j.toLanguageString(C,O[C]),autoFocus:!0,onKeyDown:Ie,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:j.toLanguageString(I,O[I]),fillMode:"flat",togglable:!0,selected:ce,onClick:we})))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,ne)," ",j.toLanguageString(T,O[T]),g.createElement("span",null,re)),g.createElement(a.Button,{title:j.toLanguageString(P,O[P]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===re,onClick:Se}),g.createElement(a.Button,{title:j.toLanguageString(N,O[N]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===re,onClick:Ee}),g.createElement(a.Button,{title:j.toLanguageString(x,O[x]),fillMode:"flat",icon:"x",svgIcon:p.xIcon,onClick:xe})),g.createElement("div",{ref:A,className:"k-pdf-viewer-pages"}));return g.createElement("div",{className:"k-pdf-viewer",style:e.style,ref:ge},e.onRenderLoader?e.onRenderLoader.call(void 0,Me||null):Me,e.onRenderToolbar?e.onRenderToolbar.call(void 0,Ue):Ue,e.onRenderContent?e.onRenderContent.call(void 0,Ve):Ve,r&&g.createElement(u.WatermarkOverlay,null))}));q.displayName="KendoReactPDFViewer",q.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};const j=o.scrollToPage;Object.defineProperty(e,"currentPage",{enumerable:!0,get:function(){return o.currentPage}}),e.PDFViewer=q,e.scrollToPage=j}));
|
|
15
|
+
!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.min.mjs")):"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.min.mjs"],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",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:1673300081,version:"$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",I="pdfviewer.matchCase",P="pdfviewer.prevMatch",N="pdfviewer.nextMatch",z="pdfviewer.actualWidth",L="pdfviewer.fitToWidth",R="pdfviewer.fitToPage",Z="pdfviewer.popupBlocked",T="pdfviewer.searchOf",O={[v]:"Zoom in",[k]:"Zoom out",[b]:"Choose zoom level",[h]:"Enable selection",[y]:"Enable panning",[C]:"Search",[w]:"Open",[E]:"Download",[T]:"of",[S]:"Print",[x]:"Close",[I]:"Match case",[P]:"Previous match",[N]:"Next match",[z]:"Actual width",[L]:"Fit to width",[R]:"Fit to page",[Z]:"Popup is blocked."},B=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],D={minZoom:.5,maxZoom:4,tools:[...B],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:z},{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:R},{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},F=[".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 M=0;const K=(e,o)=>e.priority>o.priority?-1:e.priority<o.priority?1:0,q=g.forwardRef(((e,t)=>{const r=!u.validatePackage(f,{component:"PDFViewer"}),{zoom:m,zoomLevels:z=D.zoomLevels,defaultZoom:L=D.defaultZoom,minZoom:R=D.minZoom,maxZoom:B=D.maxZoom,zoomRate:q=D.zoomRate}=e,j=d.useLocalization(),A=g.useRef(null),[U,V]=g.useState(L),W=void 0!==m?m:U,_=z.slice().sort(K).find((e=>e.value===W))||{text:100*W+"%",value:W,id:W,locationString:""};_.locationString&&(_.text=j.toLanguageString(_.locationString,O[_.locationString]));const[G,H]=g.useState(!1),[$,J]=g.useState(!0),[Q,X]=g.useState(0),[Y,ee]=g.useState(!0),[oe,te]=g.useState(!1),[re,ae]=g.useState(0),[ne,le]=g.useState(0),[ce,se]=g.useState(!1),[ie,ue]=g.useState(""),de=g.useMemo((()=>({})),[]);de.currentZoom=W,de.props=e;const pe=g.useCallback((e=>{A.current&&A.current.style.setProperty("--scale-factor",String(e))}),[]),me=g.useRef(null),ge=g.useRef(null);g.useImperativeHandle(me,(()=>({get element(){return ge.current},props:e,get pages(){return de.pages},get document(){return de.document}})),[]),g.useImperativeHandle(t,(()=>me.current));const fe=g.useCallback((()=>{if(de.props.onLoad){const e={target:me.current};de.props.onLoad.call(void 0,e)}}),[]),ve=g.useCallback(((o,t,r)=>{if(e.onDownload){const a={target:me.current,blob:o,fileName:t,saveOptions:r};return!1===e.onDownload.call(void 0,a)}return!1}),[e.onDownload]),ke=g.useCallback((()=>{var e;de.scroller&&de.scroller.destroy(),de.scroller=new o.Scroller(null==(e=A.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),de.scroller.disablePanEventsTracking()}),[]),be=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));de.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);de.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{de.document=t,de.pages=e,de.zoom=r,ke(),J(!1),H(!0),fe(),A.current&&o.scrollToPage(A.current,0)}),[]),de.error=g.useCallback((o=>{if(de.document=null,de.pages=[],J(!1),H(!1),e.onError){const t="string"==typeof o?{message:o}:o,r={error:null!=t?t:j.toLanguageString(Z,O[Z]),target:me.current};e.onError.call(void 0,r)}}),[e.onError]),g.useEffect((()=>{A.current&&(e.url||e.data||e.arrayBuffer?(J(!0),o.removeChildren(A.current),o.loadPDF({url:e.url,data:e.data,arrayBuffer:e.arrayBuffer,dom:A.current,zoom:de.currentZoom,done:de.done,error:de.error}),pe(de.currentZoom)):(de.document=null,de.pages=[],H(!1),J(!1),o.removeChildren(A.current)))}),[e.url,e.data,e.arrayBuffer]);const he=g.useCallback(((e,t)=>{A.current&&(J(!0),o.removeChildren(A.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:A.current,done:e=>{de.pages=e,de.zoom=t,J(!1)},error:de.error}))}),[]);g.useEffect((()=>{pe(W),A.current&&de.document&&W!==de.zoom&&he(de.document,W)}),[W,he]),g.useEffect((()=>()=>{de.scroller&&de.scroller.destroy(),de.search&&de.search.destroy(),de.document=null,de.pages=[]}),[]);const ye=g.useCallback((()=>{te(!0),be(A.current)}),[]),Ce=g.useCallback((e=>{const o=e.value,t=de.search.search({text:o,matchCase:ce});le(t.length?1:0),ae(t.length),ue(o)}),[ce]),we=g.useCallback((()=>{const e=de.search.search({text:ie,matchCase:!ce});le(e.length?1:0),ae(e.length),se(!ce)}),[ce,ie]),Ee=g.useCallback((()=>{o.goToNextSearchMatch(de),le(ne+1>re?1:ne+1)}),[ne,re]),Se=g.useCallback((()=>{o.goToPreviousSearchMatch(de),le(ne-1<1?re:ne-1)}),[ne,re]),xe=g.useCallback((()=>{de.search.destroy(),le(0),ae(0),se(!1),ue(""),te(!1)}),[]),Ie=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(de),le(ne+1>re?1:ne+1)):"Escape"===e.key&&xe()}),[ne,re]),Pe=g.useCallback((t=>{if(A.current){const r=t.skip;o.scrollToPage(A.current,r);const a={page:r+1,target:me.current,syntheticEvent:t.syntheticEvent};e.onPageChange&&e.onPageChange.call(void 0,a)}X(t.skip)}),[Q,e.onPageChange]),Ne=g.useCallback((t=>{if(ge.current){const r=o.currentPage(ge.current);if(r!==Q){X(r);const o={page:r+1,target:me.current,syntheticEvent:t};e.onPageChange&&e.onPageChange.call(void 0,o)}}}),[Q,e.onPageChange]),ze=g.useCallback((o=>{const t=Math.min(de.currentZoom+q,B);if(t!==de.currentZoom&&de.document&&(V(t),e.onZoom)){const r={zoom:t,target:me.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[q,B,e.onZoom]),Le=g.useCallback((o=>{const t=Math.max(de.currentZoom-q,R);if(t!==de.currentZoom&&de.document&&(V(t),e.onZoom)){const r={zoom:t,target:me.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[q,R,e.onZoom]),Re=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,de.currentZoom,A.current):1;if(a=Math.round(100*a)/100,de.currentZoom!==a&&de.document&&(V(a),e.onZoom)){const o={zoom:a,target:me.current,syntheticEvent:t.syntheticEvent};e.onZoom.call(void 0,o)}}),[e.onZoom]),Ze=g.useCallback((()=>{de.scroller.disablePanEventsTracking(),ee(!0)}),[]),Te=g.useCallback((()=>{de.scroller.enablePanEventsTracking(),ee(!1)}),[]),Oe=g.useCallback((()=>{o.download({pdf:de.document,error:de.error},e.saveFileName,e.saveOptions,ve)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,ve]),Be=g.useCallback((()=>{J(!0);o.print(de.pages,(()=>{J(!1)}),(e=>{J(!1),de.error(e)}))}),[]),De=g.useCallback((e=>{const t=e.newState;t[0]&&t[0].getRawFile&&t[0].getRawFile().arrayBuffer().then((e=>{if(A.current){J(!0),o.removeChildren(A.current);const t=void 0===de.props.zoom?L:de.props.zoom;o.loadPDF({arrayBuffer:e,dom:A.current,zoom:t,done:de.done,error:de.error}),V(t)}}))}),[L]),Fe=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()}}),[]),Me=$&&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(a.ButtonGroup,{className:"k-toolbar-button-group k-button-group-solid"},g.createElement(a.Button,{className:"k-group-start",fillMode:"flat",themeColor:"base",title:j.toLanguageString(k,O[k]),disabled:W<=R||!G,onClick:Le,icon:"zoom-out",svgIcon:p.zoomOutIcon}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:j.toLanguageString(v,O[v]),disabled:W>=B||!G,onClick:ze,icon:"zoom-in",svgIcon:p.zoomInIcon})),qe=g.createElement(s.ComboBox,{className:"k-toolbar-combobox",disabled:!G,data:z.map((e=>({...e,text:e.locationString?j.toLanguageString(e.locationString,O[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:G?_:null,allowCustom:!0,onChange:Re,placeholder:j.toLanguageString(b,O[b])}),je={pager:g.createElement(l.Pager,{disabled:!G,previousNext:!0,type:"input",skip:Q,take:1,total:de.pages?de.pages.length:0,info:!1,onPageChange:Pe}),spacer:g.createElement(a.ToolbarSpacer,null),zoomInOut:Ke,zoom:qe,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:j.toLanguageString(h,O[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!G,togglable:!0,selected:Y&&G,onClick:Ze}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:j.toLanguageString(y,O[y]),icon:"hand",svgIcon:p.handIcon,disabled:!G,togglable:!0,selected:!Y&&G,onClick:Te})),search:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(C,O[C]),icon:"search",svgIcon:p.searchIcon,disabled:!G,onClick:ye}),open:g.createElement(g.Fragment,null,g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(w,O[w]),icon:"folder-open",svgIcon:p.folderOpenIcon,onClick:Fe}),g.createElement("div",{style:{display:"none"}},g.createElement(c.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:De,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),download:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(E,O[E]),icon:"download",svgIcon:p.downloadIcon,disabled:!G,onClick:Oe}),print:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:j.toLanguageString(S,O[S]),icon:"print",svgIcon:p.printIcon,disabled:!G,onClick:Be})},Ae=(e.tools||D.tools).map((e=>({...je[e],key:"toobar-tool-"+e+(M++,M)}))),Ue=g.createElement(a.Toolbar,{buttons:F},...Ae),Ve=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:Ne},oe&&g.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},g.createElement(n.TextBox,{value:ie,onChange:Ce,placeholder:j.toLanguageString(C,O[C]),autoFocus:!0,onKeyDown:Ie,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:j.toLanguageString(I,O[I]),fillMode:"flat",togglable:!0,selected:ce,onClick:we})))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,ne)," ",j.toLanguageString(T,O[T]),g.createElement("span",null,re)),g.createElement(a.Button,{title:j.toLanguageString(P,O[P]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===re,onClick:Se}),g.createElement(a.Button,{title:j.toLanguageString(N,O[N]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===re,onClick:Ee}),g.createElement(a.Button,{title:j.toLanguageString(x,O[x]),fillMode:"flat",icon:"x",svgIcon:p.xIcon,onClick:xe})),g.createElement("div",{ref:A,className:"k-pdf-viewer-pages"}));return g.createElement("div",{className:"k-pdf-viewer",style:e.style,ref:ge},e.onRenderLoader?e.onRenderLoader.call(void 0,Me||null):Me,e.onRenderToolbar?e.onRenderToolbar.call(void 0,Ue):Ue,e.onRenderContent?e.onRenderContent.call(void 0,Ve):Ve,r&&g.createElement(u.WatermarkOverlay,null))}));q.displayName="KendoReactPDFViewer",q.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};const j=o.scrollToPage;Object.defineProperty(e,"currentPage",{enumerable:!0,get:function(){return o.currentPage}}),e.PDFViewer=q,e.scrollToPage=j}));
|
package/package-metadata.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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1741695946,version:"10.0.0",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"};exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -10,8 +10,8 @@ const e = {
|
|
|
10
10
|
productName: "KendoReact",
|
|
11
11
|
productCode: "KENDOUIREACT",
|
|
12
12
|
productCodes: ["KENDOUIREACT"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "10.0.0
|
|
13
|
+
publishDate: 1741695946,
|
|
14
|
+
version: "10.0.0",
|
|
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
|
};
|
|
17
17
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-pdf-viewer",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "KendoReact PDFViewer package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-file-saver": "^1.1.1",
|
|
29
|
-
"@progress/kendo-licensing": "^1.5.
|
|
30
|
-
"@progress/kendo-react-buttons": "10.0.0
|
|
31
|
-
"@progress/kendo-react-common": "10.0.0
|
|
32
|
-
"@progress/kendo-react-data-tools": "10.0.0
|
|
33
|
-
"@progress/kendo-react-dropdowns": "10.0.0
|
|
34
|
-
"@progress/kendo-react-indicators": "10.0.0
|
|
35
|
-
"@progress/kendo-react-inputs": "10.0.0
|
|
36
|
-
"@progress/kendo-react-intl": "10.0.0
|
|
37
|
-
"@progress/kendo-react-upload": "10.0.0
|
|
29
|
+
"@progress/kendo-licensing": "^1.5.1",
|
|
30
|
+
"@progress/kendo-react-buttons": "10.0.0",
|
|
31
|
+
"@progress/kendo-react-common": "10.0.0",
|
|
32
|
+
"@progress/kendo-react-data-tools": "10.0.0",
|
|
33
|
+
"@progress/kendo-react-dropdowns": "10.0.0",
|
|
34
|
+
"@progress/kendo-react-indicators": "10.0.0",
|
|
35
|
+
"@progress/kendo-react-inputs": "10.0.0",
|
|
36
|
+
"@progress/kendo-react-intl": "10.0.0",
|
|
37
|
+
"@progress/kendo-react-upload": "10.0.0",
|
|
38
38
|
"@progress/kendo-svg-icons": "^4.0.0",
|
|
39
39
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
40
40
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"package": {
|
|
62
62
|
"productName": "KendoReact",
|
|
63
63
|
"productCode": "KENDOUIREACT",
|
|
64
|
-
"publishDate":
|
|
64
|
+
"publishDate": 1741695946,
|
|
65
65
|
"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"
|
|
66
66
|
}
|
|
67
67
|
},
|