@progress/kendo-react-pdf-viewer 11.4.0-develop.6 → 11.4.0-develop.8
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 +151 -151
- 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 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;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qe=require("react"),c=require("prop-types"),m=require("@progress/kendo-react-buttons"),j=require("@progress/kendo-react-inputs"),je=require("@progress/kendo-react-data-tools"),Ae=require("@progress/kendo-react-upload"),Ve=require("@progress/kendo-react-dropdowns"),We=require("@progress/kendo-react-indicators"),T=require("@progress/kendo-react-common"),Ke=require("@progress/kendo-react-intl"),f=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.min.mjs");const oe=require("./package-metadata.js"),i=require("@progress/kendo-pdfviewer-common"),a=require("./messages.js");function Ue(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=Ue(qe),ae=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],x={minZoom:.5,maxZoom:4,tools:[...ae],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},_e=[".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 ne=0;function He(){return ne++,ne}const Ge=(n,p)=>n.priority>p.priority?-1:n.priority<p.priority?1:0,A=e.forwardRef((n,p)=>{const C=!T.validatePackage(oe.packageMetadata,{component:"PDFViewer"}),Z=T.getLicenseMessage(oe.packageMetadata),{zoom:V,zoomLevels:W=x.zoomLevels,defaultZoom:N=x.defaultZoom,minZoom:R=x.minZoom,maxZoom:B=x.maxZoom,zoomRate:L=x.zoomRate}=n,u=Ke.useLocalization(),s=e.useRef(null),[re,z]=e.useState(N),h=V!==void 0?V:re,w=W.slice().sort(Ge).find(o=>o.value===h)||{text:h*100+"%",value:h,id:h,locationString:""};w.locationString&&(w.text=u.toLanguageString(w.locationString,a.messages[w.locationString]));const[d,O]=e.useState(!1),[le,k]=e.useState(!0),[M,K]=e.useState(0),[P,U]=e.useState(!0),[ce,_]=e.useState(!1),[y,D]=e.useState(0),[v,E]=e.useState(0),[S,H]=e.useState(!1),[F,G]=e.useState(""),t=e.useMemo(()=>({}),[]);t.currentZoom=h,t.props=n;const J=e.useCallback(o=>{s.current&&s.current.style.setProperty("--scale-factor",String(o))},[]),b=e.useRef(null),I=e.useRef(null);e.useImperativeHandle(b,()=>({get element(){return I.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(p,()=>b.current);const se=e.useCallback(()=>{if(t.props.onLoad){const o={target:b.current};t.props.onLoad.call(void 0,o)}},[]),Q=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]),ie=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()},[]),ue=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,ie(),k(!1),O(!0),se(),s.current&&i.scrollToPage(s.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],k(!1),O(!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}),J(t.currentZoom)):(t.document=null,t.pages=[],O(!1),k(!1),i.removeChildren(s.current)))},[n.url,n.data,n.arrayBuffer]);const X=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(()=>{J(h),s.current&&t.document&&h!==t.zoom&&X(t.document,h)},[h,X]),e.useEffect(()=>()=>{t.scroller&&t.scroller.destroy(),t.search&&t.search.destroy(),t.document=null,t.pages=[]},[]);const me=e.useCallback(()=>{_(!0),ue(s.current)},[]),de=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:S});E(l.length?1:0),D(l.length),G(r)},[S]),ge=e.useCallback(()=>{const o=t.search.search({text:F,matchCase:!S});E(o.length?1:0),D(o.length),H(!S)},[S,F]),fe=e.useCallback(()=>{i.goToNextSearchMatch(t),E(v+1>y?1:v+1)},[v,y]),he=e.useCallback(()=>{i.goToPreviousSearchMatch(t),E(v-1<1?y:v-1)},[v,y]),Y=e.useCallback(()=>{t.search.destroy(),E(0),D(0),H(!1),G(""),_(!1)},[]),ke=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),E(v+1>y?1:v+1)):o.key==="Escape"&&Y()},[v,y]),ve=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)}K(o.skip)},[M,n.onPageChange]),be=e.useCallback(o=>{if(I.current){const r=i.currentPage(I.current);if(r!==M){K(r);const l={page:r+1,target:b.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[M,n.onPageChange]),ye=e.useCallback(o=>{const r=Math.min(t.currentZoom+L,B);if(r!==t.currentZoom&&t.document&&(z(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[L,B,n.onZoom]),pe=e.useCallback(o=>{const r=Math.max(t.currentZoom-L,R);if(r!==t.currentZoom&&t.document&&(z(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[L,R,n.onZoom]),Ce=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&&(z(l),n.onZoom)){const g={zoom:l,target:b.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,g)}},[n.onZoom]),Ee=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),U(!0)},[]),Se=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),U(!1)},[]),xe=e.useCallback(()=>{i.download({pdf:t.document,error:t.error},n.saveFileName,n.saveOptions,Q)},[n.url,n.data,n.arrayBuffer,n.saveFileName,n.saveOptions,Q]),we=e.useCallback(()=>{k(!0);const o=l=>{k(!1),t.error(l)},r=()=>{k(!1)};i.print(t.pages,r,o)},[]),Ze=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 q=t.props.zoom===void 0?N:t.props.zoom;i.loadPDF({arrayBuffer:g,dom:s.current,zoom:q,done:t.done,error:t.error}),z(q)}})},[N]),Le=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()}},[]),$=le&&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(We.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||!d,onClick:pe,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||!d,onClick:ye,icon:"zoom-in",svgIcon:f.zoomInIcon})),Me=e.createElement(Ve.ComboBox,{className:"k-toolbar-combobox",disabled:!d,data:W.map(o=>({...o,text:o.locationString?u.toLanguageString(o.locationString,a.messages[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:d?w:null,allowCustom:!0,onChange:Ce,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Pe=e.createElement(je.Pager,{disabled:!d,previousNext:!0,type:"input",skip:M,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:ve}),Ie=e.createElement(m.ToolbarSpacer,null),Te=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:P&&d,onClick:Ee}),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:!P&&d,onClick:Se})),Ne=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:me}),Re=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:Le}),e.createElement("div",{style:{display:"none"}},e.createElement(Ae.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:Ze,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Be=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:xe}),Oe=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:we}),De={pager:Pe,spacer:Ie,zoomInOut:ze,zoom:Me,selection:Te,search:Ne,open:Re,download:Be,print:Oe},Fe=(n.tools||x.tools).map(o=>({...De[o],key:"toobar-tool-"+o+He()})),ee=e.createElement(m.Toolbar,{buttons:_e},...Fe),te=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:be},ce&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(j.TextBox,{value:F,onChange:de,placeholder:u.toLanguageString(a.search,a.messages[a.search]),autoFocus:!0,onKeyDown:ke,suffix:()=>e.createElement(e.Fragment,null,e.createElement(j.InputSeparator,null),e.createElement(j.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:ge})))}),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:he}),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:fe}),e.createElement(m.Button,{title:u.toLanguageString(a.close,a.messages[a.close]),fillMode:"flat",icon:"x",svgIcon:f.xIcon,onClick:Y})),e.createElement("div",{ref:s,className:"k-pdf-viewer-pages"}));return e.createElement("div",{className:"k-pdf-viewer",style:n.style,ref:I},n.onRenderLoader?n.onRenderLoader.call(void 0,$||null):$,n.onRenderToolbar?n.onRenderToolbar.call(void 0,ee):ee,n.onRenderContent?n.onRenderContent.call(void 0,te):te,C&&e.createElement(T.WatermarkOverlay,{message:Z}))});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(ae).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
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
9
|
import l from "prop-types";
|
|
10
|
-
import { ButtonGroup as Q, Button as d, Toolbar as
|
|
11
|
-
import { TextBox as
|
|
12
|
-
import { Pager as
|
|
13
|
-
import { Upload as
|
|
14
|
-
import { ComboBox as
|
|
15
|
-
import { Loader as
|
|
16
|
-
import { validatePackage as
|
|
17
|
-
import { useLocalization as
|
|
18
|
-
import { zoomOutIcon as
|
|
10
|
+
import { ButtonGroup as Q, Button as d, Toolbar as tt, ToolbarSpacer as ot } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { TextBox as at, InputSeparator as nt, InputSuffix as rt } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { Pager as lt } from "@progress/kendo-react-data-tools";
|
|
13
|
+
import { Upload as ct } from "@progress/kendo-react-upload";
|
|
14
|
+
import { ComboBox as st } from "@progress/kendo-react-dropdowns";
|
|
15
|
+
import { Loader as it } from "@progress/kendo-react-indicators";
|
|
16
|
+
import { validatePackage as ut, getLicenseMessage as mt, classNames as dt, WatermarkOverlay as gt } from "@progress/kendo-react-common";
|
|
17
|
+
import { useLocalization as ft } from "@progress/kendo-react-intl";
|
|
18
|
+
import { zoomOutIcon as ht, zoomInIcon as vt, pointerIcon as bt, handIcon as kt, searchIcon as pt, folderOpenIcon as yt, downloadIcon as Ct, printIcon as Et, convertLowercaseIcon as St, arrowUpIcon as xt, arrowDownIcon as wt, xIcon as Zt } from "@progress/kendo-svg-icons";
|
|
19
19
|
import "pdfjs-dist/build/pdf.worker.min.mjs";
|
|
20
|
-
import { packageMetadata as
|
|
21
|
-
import { Scroller as
|
|
22
|
-
import { messages as i, popupBlocked as
|
|
23
|
-
const
|
|
20
|
+
import { packageMetadata as X } from "./package-metadata.mjs";
|
|
21
|
+
import { Scroller as Lt, SearchService as zt, scrollToPage as Y, removeChildren as z, loadPDF as ee, reloadDocument as It, goToNextSearchMatch as te, goToPreviousSearchMatch as Mt, currentPage as Nt, calculateZoomLevel as Tt, download as Pt, print as Rt, DEFAULT_ZOOM_LEVEL as Ft } from "@progress/kendo-pdfviewer-common";
|
|
22
|
+
import { messages as i, popupBlocked as oe, 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, searchOf as de, prevMatch as ge, nextMatch as fe, close as he, actualWidth as Dt, fitToWidth as Ot, fitToPage as Bt } from "./messages.mjs";
|
|
23
|
+
const be = [
|
|
24
24
|
"pager",
|
|
25
25
|
"spacer",
|
|
26
26
|
"zoomInOut",
|
|
@@ -34,12 +34,12 @@ const ve = [
|
|
|
34
34
|
], y = {
|
|
35
35
|
minZoom: 0.5,
|
|
36
36
|
maxZoom: 4,
|
|
37
|
-
tools: [...
|
|
37
|
+
tools: [...be],
|
|
38
38
|
zoomRate: 0.25,
|
|
39
39
|
zoomLevels: [
|
|
40
|
-
{ id: 1, priority: 1, value: 1, text: "Actual width", type: "ActualWidth", locationString:
|
|
41
|
-
{ id: 2, priority: 2, value: 1, text: "Fit to width", type: "FitToWidth", locationString:
|
|
42
|
-
{ id: 3, priority: 3, value: 1, text: "Fit to page", type: "FitToPage", locationString:
|
|
40
|
+
{ id: 1, priority: 1, value: 1, text: "Actual width", type: "ActualWidth", locationString: Dt },
|
|
41
|
+
{ id: 2, priority: 2, value: 1, text: "Fit to width", type: "FitToWidth", locationString: Ot },
|
|
42
|
+
{ id: 3, priority: 3, value: 1, text: "Fit to page", type: "FitToPage", locationString: Bt },
|
|
43
43
|
{ id: 4, priority: 4, value: 0.5, text: "50%", type: "" },
|
|
44
44
|
{ id: 5, priority: 5, value: 0.75, text: "75%", type: "" },
|
|
45
45
|
{ id: 6, priority: 100, value: 1, text: "100%", type: "" },
|
|
@@ -49,27 +49,27 @@ 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:
|
|
53
|
-
},
|
|
52
|
+
defaultZoom: Ft
|
|
53
|
+
}, At = [
|
|
54
54
|
".k-toolbar > button",
|
|
55
55
|
".k-toolbar .k-combobox > input",
|
|
56
56
|
".k-toolbar .k-button-group > button",
|
|
57
57
|
".k-toolbar .k-pager > a",
|
|
58
58
|
".k-toolbar .k-pager input"
|
|
59
59
|
];
|
|
60
|
-
let
|
|
61
|
-
function
|
|
62
|
-
return
|
|
60
|
+
let ve = 0;
|
|
61
|
+
function Vt() {
|
|
62
|
+
return ve++, ve;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
const
|
|
64
|
+
const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1 : 0, ke = e.forwardRef((a, E) => {
|
|
65
|
+
const pe = !ut(X, { component: "PDFViewer" }), ye = mt(X), {
|
|
66
66
|
zoom: O,
|
|
67
67
|
zoomLevels: B = y.zoomLevels,
|
|
68
|
-
defaultZoom:
|
|
69
|
-
minZoom:
|
|
70
|
-
maxZoom:
|
|
68
|
+
defaultZoom: M = y.defaultZoom,
|
|
69
|
+
minZoom: N = y.minZoom,
|
|
70
|
+
maxZoom: T = y.maxZoom,
|
|
71
71
|
zoomRate: S = y.zoomRate
|
|
72
|
-
} = a, s =
|
|
72
|
+
} = a, s = ft(), c = e.useRef(null), [Ce, x] = e.useState(M), g = O !== void 0 ? O : Ce, C = B.slice().sort(Wt).find((o) => o.value === g) || {
|
|
73
73
|
text: g * 100 + "%",
|
|
74
74
|
value: g,
|
|
75
75
|
id: g,
|
|
@@ -79,7 +79,7 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
79
79
|
C.locationString,
|
|
80
80
|
i[C.locationString]
|
|
81
81
|
));
|
|
82
|
-
const [u,
|
|
82
|
+
const [u, P] = e.useState(!1), [Ee, f] = e.useState(!0), [w, A] = e.useState(0), [Z, V] = e.useState(!0), [Se, 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));
|
|
@@ -100,7 +100,7 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
100
100
|
}),
|
|
101
101
|
[]
|
|
102
102
|
), e.useImperativeHandle(E, () => v.current);
|
|
103
|
-
const
|
|
103
|
+
const xe = e.useCallback(() => {
|
|
104
104
|
if (t.props.onLoad) {
|
|
105
105
|
const o = { target: v.current };
|
|
106
106
|
t.props.onLoad.call(void 0, o);
|
|
@@ -119,15 +119,15 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
119
119
|
return !1;
|
|
120
120
|
},
|
|
121
121
|
[a.onDownload]
|
|
122
|
-
),
|
|
122
|
+
), we = e.useCallback(() => {
|
|
123
123
|
var o;
|
|
124
|
-
t.scroller && t.scroller.destroy(), t.scroller = new
|
|
124
|
+
t.scroller && t.scroller.destroy(), t.scroller = new Lt((o = c.current) == null ? void 0 : o.parentNode, {
|
|
125
125
|
filter: ".k-page",
|
|
126
126
|
events: {}
|
|
127
127
|
}), t.scroller.disablePanEventsTracking();
|
|
128
|
-
}, []),
|
|
128
|
+
}, []), Ze = e.useCallback((o) => {
|
|
129
129
|
const n = Array.from(o.querySelectorAll(".k-text-layer"));
|
|
130
|
-
t.search = new
|
|
130
|
+
t.search = new zt({
|
|
131
131
|
textContainers: n || [],
|
|
132
132
|
highlightClass: "k-search-highlight",
|
|
133
133
|
highlightMarkClass: "k-search-highlight-mark",
|
|
@@ -135,12 +135,12 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.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,
|
|
138
|
+
t.document = n, t.pages = o, t.zoom = r, we(), f(!1), P(!0), xe(), c.current && Y(c.current, 0);
|
|
139
139
|
}, []), t.error = e.useCallback(
|
|
140
140
|
(o) => {
|
|
141
|
-
if (t.document = null, t.pages = [], f(!1),
|
|
141
|
+
if (t.document = null, t.pages = [], f(!1), P(!1), a.onError) {
|
|
142
142
|
const n = typeof o == "string" ? { message: o } : o, r = {
|
|
143
|
-
error: n != null ? n : s.toLanguageString(
|
|
143
|
+
error: n != null ? n : s.toLanguageString(oe, i[oe]),
|
|
144
144
|
target: v.current
|
|
145
145
|
};
|
|
146
146
|
a.onError.call(void 0, r);
|
|
@@ -148,7 +148,7 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
148
148
|
},
|
|
149
149
|
[a.onError]
|
|
150
150
|
), e.useEffect(() => {
|
|
151
|
-
c.current && (a.url || a.data || a.arrayBuffer ? (f(!0), z(c.current),
|
|
151
|
+
c.current && (a.url || a.data || a.arrayBuffer ? (f(!0), z(c.current), ee({
|
|
152
152
|
url: a.url,
|
|
153
153
|
data: a.data,
|
|
154
154
|
arrayBuffer: a.arrayBuffer,
|
|
@@ -156,10 +156,10 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.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 = [], P(!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 && (f(!0), z(c.current),
|
|
162
|
+
c.current && (f(!0), z(c.current), It({
|
|
163
163
|
pdfDoc: o,
|
|
164
164
|
zoom: n,
|
|
165
165
|
dom: c.current,
|
|
@@ -174,33 +174,33 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
174
174
|
}, [g, H]), e.useEffect(() => () => {
|
|
175
175
|
t.scroller && t.scroller.destroy(), t.search && t.search.destroy(), t.document = null, t.pages = [];
|
|
176
176
|
}, []);
|
|
177
|
-
const
|
|
178
|
-
W(!0),
|
|
179
|
-
}, []),
|
|
177
|
+
const Le = e.useCallback(() => {
|
|
178
|
+
W(!0), Ze(c.current);
|
|
179
|
+
}, []), ze = e.useCallback(
|
|
180
180
|
(o) => {
|
|
181
181
|
const n = o.value, r = t.search.search({ text: n, matchCase: p });
|
|
182
182
|
k(r.length ? 1 : 0), R(r.length), U(n);
|
|
183
183
|
},
|
|
184
184
|
[p]
|
|
185
|
-
),
|
|
185
|
+
), Ie = e.useCallback(() => {
|
|
186
186
|
const o = t.search.search({ text: F, matchCase: !p });
|
|
187
187
|
k(o.length ? 1 : 0), R(o.length), K(!p);
|
|
188
|
-
}, [p, F]),
|
|
189
|
-
|
|
190
|
-
}, [h, b]),
|
|
191
|
-
|
|
188
|
+
}, [p, F]), Me = e.useCallback(() => {
|
|
189
|
+
te(t), k(h + 1 > b ? 1 : h + 1);
|
|
190
|
+
}, [h, b]), Ne = e.useCallback(() => {
|
|
191
|
+
Mt(t), k(h - 1 < 1 ? b : h - 1);
|
|
192
192
|
}, [h, b]), $ = e.useCallback(() => {
|
|
193
193
|
t.search.destroy(), k(0), R(0), K(!1), U(""), W(!1);
|
|
194
|
-
}, []),
|
|
194
|
+
}, []), Te = e.useCallback(
|
|
195
195
|
(o) => {
|
|
196
|
-
o.key === "Enter" ? (o.preventDefault(),
|
|
196
|
+
o.key === "Enter" ? (o.preventDefault(), te(t), k(h + 1 > b ? 1 : h + 1)) : o.key === "Escape" && $();
|
|
197
197
|
},
|
|
198
198
|
[h, b]
|
|
199
|
-
),
|
|
199
|
+
), Pe = e.useCallback(
|
|
200
200
|
(o) => {
|
|
201
201
|
if (c.current) {
|
|
202
202
|
const n = o.skip;
|
|
203
|
-
|
|
203
|
+
Y(c.current, n);
|
|
204
204
|
const r = {
|
|
205
205
|
page: n + 1,
|
|
206
206
|
target: v.current,
|
|
@@ -211,10 +211,10 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
211
211
|
A(o.skip);
|
|
212
212
|
},
|
|
213
213
|
[w, a.onPageChange]
|
|
214
|
-
),
|
|
214
|
+
), Re = e.useCallback(
|
|
215
215
|
(o) => {
|
|
216
216
|
if (L.current) {
|
|
217
|
-
const n =
|
|
217
|
+
const n = Nt(L.current);
|
|
218
218
|
if (n !== w) {
|
|
219
219
|
A(n);
|
|
220
220
|
const r = {
|
|
@@ -227,9 +227,9 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
229
|
[w, a.onPageChange]
|
|
230
|
-
),
|
|
230
|
+
), Fe = e.useCallback(
|
|
231
231
|
(o) => {
|
|
232
|
-
const n = Math.min(t.currentZoom + S,
|
|
232
|
+
const n = Math.min(t.currentZoom + S, T);
|
|
233
233
|
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
234
234
|
const r = {
|
|
235
235
|
zoom: n,
|
|
@@ -239,10 +239,10 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
239
239
|
a.onZoom.call(void 0, r);
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
|
-
[S,
|
|
243
|
-
),
|
|
242
|
+
[S, T, a.onZoom]
|
|
243
|
+
), De = e.useCallback(
|
|
244
244
|
(o) => {
|
|
245
|
-
const n = Math.max(t.currentZoom - S,
|
|
245
|
+
const n = Math.max(t.currentZoom - S, N);
|
|
246
246
|
if (n !== t.currentZoom && t.document && (x(n), a.onZoom)) {
|
|
247
247
|
const r = {
|
|
248
248
|
zoom: n,
|
|
@@ -252,15 +252,15 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
252
252
|
a.onZoom.call(void 0, r);
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
|
-
[S,
|
|
256
|
-
),
|
|
255
|
+
[S, N, a.onZoom]
|
|
256
|
+
), Oe = 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
260
|
const m = parseFloat(n.text);
|
|
261
261
|
typeof m == "number" && !Number.isNaN(m) ? n.value = m / 100 : n.value = 1;
|
|
262
262
|
}
|
|
263
|
-
let r = n ?
|
|
263
|
+
let r = n ? Tt(n.value, n.type, t.currentZoom, c.current) : 1;
|
|
264
264
|
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (x(r), a.onZoom)) {
|
|
265
265
|
const m = {
|
|
266
266
|
zoom: r,
|
|
@@ -271,12 +271,12 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
271
271
|
}
|
|
272
272
|
},
|
|
273
273
|
[a.onZoom]
|
|
274
|
-
),
|
|
274
|
+
), Be = e.useCallback(() => {
|
|
275
275
|
t.scroller.disablePanEventsTracking(), V(!0);
|
|
276
|
-
}, []),
|
|
276
|
+
}, []), Ae = e.useCallback(() => {
|
|
277
277
|
t.scroller.enablePanEventsTracking(), V(!1);
|
|
278
|
-
}, []),
|
|
279
|
-
|
|
278
|
+
}, []), Ve = e.useCallback(() => {
|
|
279
|
+
Pt(
|
|
280
280
|
{
|
|
281
281
|
pdf: t.document,
|
|
282
282
|
error: t.error
|
|
@@ -285,22 +285,22 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
285
285
|
a.saveOptions,
|
|
286
286
|
q
|
|
287
287
|
);
|
|
288
|
-
}, [a.url, a.data, a.arrayBuffer, a.saveFileName, a.saveOptions, q]),
|
|
288
|
+
}, [a.url, a.data, a.arrayBuffer, a.saveFileName, a.saveOptions, q]), We = e.useCallback(() => {
|
|
289
289
|
f(!0);
|
|
290
290
|
const o = (r) => {
|
|
291
291
|
f(!1), t.error(r);
|
|
292
292
|
}, n = () => {
|
|
293
293
|
f(!1);
|
|
294
294
|
};
|
|
295
|
-
|
|
296
|
-
}, []),
|
|
295
|
+
Rt(t.pages, n, o);
|
|
296
|
+
}, []), Ke = e.useCallback(
|
|
297
297
|
(o) => {
|
|
298
298
|
const n = o.newState;
|
|
299
299
|
n[0] && n[0].getRawFile && n[0].getRawFile().arrayBuffer().then((m) => {
|
|
300
300
|
if (c.current) {
|
|
301
301
|
f(!0), z(c.current);
|
|
302
|
-
const D = t.props.zoom === void 0 ?
|
|
303
|
-
|
|
302
|
+
const D = t.props.zoom === void 0 ? M : t.props.zoom;
|
|
303
|
+
ee({
|
|
304
304
|
arrayBuffer: m,
|
|
305
305
|
dom: c.current,
|
|
306
306
|
zoom: D,
|
|
@@ -310,24 +310,24 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
},
|
|
313
|
-
[
|
|
314
|
-
),
|
|
313
|
+
[M]
|
|
314
|
+
), Ue = e.useCallback((o) => {
|
|
315
315
|
const n = o.target;
|
|
316
316
|
if (n instanceof Element && n.parentNode) {
|
|
317
317
|
const r = n.closest(".k-toolbar"), m = r && r.querySelector(".k-upload input");
|
|
318
318
|
m && m.click();
|
|
319
319
|
}
|
|
320
|
-
}, []), _ =
|
|
320
|
+
}, []), _ = Ee && /* @__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(it, { size: "large" }))), je = /* @__PURE__ */ e.createElement(Q, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
321
321
|
d,
|
|
322
322
|
{
|
|
323
323
|
className: "k-group-start",
|
|
324
324
|
fillMode: "flat",
|
|
325
325
|
themeColor: "base",
|
|
326
|
-
title: s.toLanguageString(
|
|
327
|
-
disabled: g <=
|
|
328
|
-
onClick:
|
|
326
|
+
title: s.toLanguageString(ae, i[ae]),
|
|
327
|
+
disabled: g <= N || !u,
|
|
328
|
+
onClick: De,
|
|
329
329
|
icon: "zoom-out",
|
|
330
|
-
svgIcon:
|
|
330
|
+
svgIcon: ht
|
|
331
331
|
}
|
|
332
332
|
), /* @__PURE__ */ e.createElement(
|
|
333
333
|
d,
|
|
@@ -335,14 +335,14 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
335
335
|
className: "k-group-end",
|
|
336
336
|
fillMode: "flat",
|
|
337
337
|
themeColor: "base",
|
|
338
|
-
title: s.toLanguageString(
|
|
339
|
-
disabled: g >=
|
|
340
|
-
onClick:
|
|
338
|
+
title: s.toLanguageString(ne, i[ne]),
|
|
339
|
+
disabled: g >= T || !u,
|
|
340
|
+
onClick: Fe,
|
|
341
341
|
icon: "zoom-in",
|
|
342
|
-
svgIcon:
|
|
342
|
+
svgIcon: vt
|
|
343
343
|
}
|
|
344
|
-
)),
|
|
345
|
-
|
|
344
|
+
)), qe = /* @__PURE__ */ e.createElement(
|
|
345
|
+
st,
|
|
346
346
|
{
|
|
347
347
|
className: "k-toolbar-combobox",
|
|
348
348
|
disabled: !u,
|
|
@@ -354,11 +354,11 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
354
354
|
textField: "text",
|
|
355
355
|
value: u ? C : null,
|
|
356
356
|
allowCustom: !0,
|
|
357
|
-
onChange:
|
|
358
|
-
placeholder: s.toLanguageString(
|
|
357
|
+
onChange: Oe,
|
|
358
|
+
placeholder: s.toLanguageString(re, i[re])
|
|
359
359
|
}
|
|
360
|
-
),
|
|
361
|
-
|
|
360
|
+
), He = /* @__PURE__ */ e.createElement(
|
|
361
|
+
lt,
|
|
362
362
|
{
|
|
363
363
|
disabled: !u,
|
|
364
364
|
previousNext: !0,
|
|
@@ -367,21 +367,21 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
367
367
|
take: 1,
|
|
368
368
|
total: t.pages ? t.pages.length : 0,
|
|
369
369
|
info: !1,
|
|
370
|
-
onPageChange:
|
|
370
|
+
onPageChange: Pe
|
|
371
371
|
}
|
|
372
|
-
),
|
|
372
|
+
), $e = /* @__PURE__ */ e.createElement(ot, null), _e = /* @__PURE__ */ e.createElement(Q, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
373
373
|
d,
|
|
374
374
|
{
|
|
375
375
|
className: "k-group-start",
|
|
376
376
|
fillMode: "flat",
|
|
377
377
|
themeColor: "base",
|
|
378
|
-
title: s.toLanguageString(
|
|
378
|
+
title: s.toLanguageString(le, i[le]),
|
|
379
379
|
icon: "pointer",
|
|
380
|
-
svgIcon:
|
|
380
|
+
svgIcon: bt,
|
|
381
381
|
disabled: !u,
|
|
382
382
|
togglable: !0,
|
|
383
383
|
selected: Z && u,
|
|
384
|
-
onClick:
|
|
384
|
+
onClick: Be
|
|
385
385
|
}
|
|
386
386
|
), /* @__PURE__ */ e.createElement(
|
|
387
387
|
d,
|
|
@@ -389,15 +389,15 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
389
389
|
className: "k-group-end",
|
|
390
390
|
fillMode: "flat",
|
|
391
391
|
themeColor: "base",
|
|
392
|
-
title: s.toLanguageString(
|
|
392
|
+
title: s.toLanguageString(ce, i[ce]),
|
|
393
393
|
icon: "hand",
|
|
394
|
-
svgIcon:
|
|
394
|
+
svgIcon: kt,
|
|
395
395
|
disabled: !u,
|
|
396
396
|
togglable: !0,
|
|
397
397
|
selected: !Z && u,
|
|
398
|
-
onClick:
|
|
398
|
+
onClick: Ae
|
|
399
399
|
}
|
|
400
|
-
)),
|
|
400
|
+
)), Ge = /* @__PURE__ */ e.createElement(
|
|
401
401
|
d,
|
|
402
402
|
{
|
|
403
403
|
className: "k-toolbar-button",
|
|
@@ -405,135 +405,135 @@ const At = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
405
405
|
themeColor: "base",
|
|
406
406
|
title: s.toLanguageString(I, i[I]),
|
|
407
407
|
icon: "search",
|
|
408
|
-
svgIcon:
|
|
408
|
+
svgIcon: pt,
|
|
409
409
|
disabled: !u,
|
|
410
|
-
onClick:
|
|
410
|
+
onClick: Le
|
|
411
411
|
}
|
|
412
|
-
),
|
|
412
|
+
), Je = /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
413
413
|
d,
|
|
414
414
|
{
|
|
415
415
|
className: "k-toolbar-button",
|
|
416
416
|
fillMode: "flat",
|
|
417
417
|
themeColor: "base",
|
|
418
|
-
title: s.toLanguageString(
|
|
418
|
+
title: s.toLanguageString(se, i[se]),
|
|
419
419
|
icon: "folder-open",
|
|
420
|
-
svgIcon:
|
|
421
|
-
onClick:
|
|
420
|
+
svgIcon: yt,
|
|
421
|
+
onClick: Ue
|
|
422
422
|
}
|
|
423
423
|
), /* @__PURE__ */ e.createElement("div", { style: { display: "none" } }, /* @__PURE__ */ e.createElement(
|
|
424
|
-
|
|
424
|
+
ct,
|
|
425
425
|
{
|
|
426
426
|
restrictions: { allowedExtensions: [".pdf"] },
|
|
427
|
-
onAdd:
|
|
427
|
+
onAdd: Ke,
|
|
428
428
|
autoUpload: !1,
|
|
429
429
|
defaultFiles: [],
|
|
430
430
|
multiple: !1,
|
|
431
431
|
accept: ".pdf,.PDF",
|
|
432
432
|
withCredentials: !1
|
|
433
433
|
}
|
|
434
|
-
))),
|
|
434
|
+
))), Qe = /* @__PURE__ */ e.createElement(
|
|
435
435
|
d,
|
|
436
436
|
{
|
|
437
437
|
className: "k-toolbar-button",
|
|
438
438
|
fillMode: "flat",
|
|
439
439
|
themeColor: "base",
|
|
440
|
-
title: s.toLanguageString(
|
|
440
|
+
title: s.toLanguageString(ie, i[ie]),
|
|
441
441
|
icon: "download",
|
|
442
|
-
svgIcon:
|
|
442
|
+
svgIcon: Ct,
|
|
443
443
|
disabled: !u,
|
|
444
|
-
onClick:
|
|
444
|
+
onClick: Ve
|
|
445
445
|
}
|
|
446
|
-
),
|
|
446
|
+
), Xe = /* @__PURE__ */ e.createElement(
|
|
447
447
|
d,
|
|
448
448
|
{
|
|
449
449
|
className: "k-toolbar-button",
|
|
450
450
|
fillMode: "flat",
|
|
451
451
|
themeColor: "base",
|
|
452
|
-
title: s.toLanguageString(
|
|
452
|
+
title: s.toLanguageString(ue, i[ue]),
|
|
453
453
|
icon: "print",
|
|
454
|
-
svgIcon:
|
|
454
|
+
svgIcon: Et,
|
|
455
455
|
disabled: !u,
|
|
456
|
-
onClick:
|
|
456
|
+
onClick: We
|
|
457
457
|
}
|
|
458
|
-
),
|
|
459
|
-
pager:
|
|
460
|
-
spacer:
|
|
461
|
-
zoomInOut:
|
|
462
|
-
zoom:
|
|
463
|
-
selection:
|
|
464
|
-
search:
|
|
465
|
-
open:
|
|
466
|
-
download:
|
|
467
|
-
print:
|
|
468
|
-
},
|
|
469
|
-
...
|
|
470
|
-
key: "toobar-tool-" + o +
|
|
471
|
-
})), G = /* @__PURE__ */ e.createElement(
|
|
458
|
+
), Ye = {
|
|
459
|
+
pager: He,
|
|
460
|
+
spacer: $e,
|
|
461
|
+
zoomInOut: je,
|
|
462
|
+
zoom: qe,
|
|
463
|
+
selection: _e,
|
|
464
|
+
search: Ge,
|
|
465
|
+
open: Je,
|
|
466
|
+
download: Qe,
|
|
467
|
+
print: Xe
|
|
468
|
+
}, et = (a.tools || y.tools).map((o) => ({
|
|
469
|
+
...Ye[o],
|
|
470
|
+
key: "toobar-tool-" + o + Vt()
|
|
471
|
+
})), G = /* @__PURE__ */ e.createElement(tt, { buttons: At }, ...et), J = /* @__PURE__ */ e.createElement(
|
|
472
472
|
"div",
|
|
473
473
|
{
|
|
474
|
-
className:
|
|
474
|
+
className: dt("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto", {
|
|
475
475
|
"k-enable-text-select": Z,
|
|
476
476
|
"k-enable-panning": !Z
|
|
477
477
|
}),
|
|
478
|
-
onScroll:
|
|
478
|
+
onScroll: Re
|
|
479
479
|
},
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
Se && /* @__PURE__ */ e.createElement("div", { className: "k-search-panel k-pos-sticky k-top-center" }, /* @__PURE__ */ e.createElement(
|
|
481
|
+
at,
|
|
482
482
|
{
|
|
483
483
|
value: F,
|
|
484
|
-
onChange:
|
|
484
|
+
onChange: ze,
|
|
485
485
|
placeholder: s.toLanguageString(I, i[I]),
|
|
486
486
|
autoFocus: !0,
|
|
487
|
-
onKeyDown:
|
|
488
|
-
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
487
|
+
onKeyDown: Te,
|
|
488
|
+
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(nt, null), /* @__PURE__ */ e.createElement(rt, null, /* @__PURE__ */ e.createElement(
|
|
489
489
|
d,
|
|
490
490
|
{
|
|
491
491
|
icon: "convert-lowercase",
|
|
492
|
-
svgIcon:
|
|
493
|
-
title: s.toLanguageString(
|
|
492
|
+
svgIcon: St,
|
|
493
|
+
title: s.toLanguageString(me, i[me]),
|
|
494
494
|
fillMode: "flat",
|
|
495
495
|
togglable: !0,
|
|
496
496
|
selected: p,
|
|
497
|
-
onClick:
|
|
497
|
+
onClick: Ie
|
|
498
498
|
}
|
|
499
499
|
)))
|
|
500
500
|
}
|
|
501
|
-
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, h), " ", s.toLanguageString(
|
|
501
|
+
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, h), " ", s.toLanguageString(de, i[de]), /* @__PURE__ */ e.createElement("span", null, b)), /* @__PURE__ */ e.createElement(
|
|
502
502
|
d,
|
|
503
503
|
{
|
|
504
|
-
title: s.toLanguageString(
|
|
504
|
+
title: s.toLanguageString(ge, i[ge]),
|
|
505
505
|
fillMode: "flat",
|
|
506
506
|
icon: "arrow-up",
|
|
507
|
-
svgIcon:
|
|
507
|
+
svgIcon: xt,
|
|
508
508
|
disabled: b === 0,
|
|
509
|
-
onClick:
|
|
509
|
+
onClick: Ne
|
|
510
510
|
}
|
|
511
511
|
), /* @__PURE__ */ e.createElement(
|
|
512
512
|
d,
|
|
513
513
|
{
|
|
514
|
-
title: s.toLanguageString(
|
|
514
|
+
title: s.toLanguageString(fe, i[fe]),
|
|
515
515
|
fillMode: "flat",
|
|
516
516
|
icon: "arrow-down",
|
|
517
|
-
svgIcon:
|
|
517
|
+
svgIcon: wt,
|
|
518
518
|
disabled: b === 0,
|
|
519
|
-
onClick:
|
|
519
|
+
onClick: Me
|
|
520
520
|
}
|
|
521
521
|
), /* @__PURE__ */ e.createElement(
|
|
522
522
|
d,
|
|
523
523
|
{
|
|
524
|
-
title: s.toLanguageString(
|
|
524
|
+
title: s.toLanguageString(he, i[he]),
|
|
525
525
|
fillMode: "flat",
|
|
526
526
|
icon: "x",
|
|
527
|
-
svgIcon:
|
|
527
|
+
svgIcon: Zt,
|
|
528
528
|
onClick: $
|
|
529
529
|
}
|
|
530
530
|
)),
|
|
531
531
|
/* @__PURE__ */ e.createElement("div", { ref: c, className: "k-pdf-viewer-pages" })
|
|
532
532
|
);
|
|
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,
|
|
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, pe && /* @__PURE__ */ e.createElement(gt, { message: ye }));
|
|
534
534
|
});
|
|
535
|
-
|
|
536
|
-
|
|
535
|
+
ke.displayName = "KendoReactPDFViewer";
|
|
536
|
+
ke.propTypes = {
|
|
537
537
|
url: l.string,
|
|
538
538
|
data: l.string,
|
|
539
539
|
arrayBuffer: l.any,
|
|
@@ -541,7 +541,7 @@ be.propTypes = {
|
|
|
541
541
|
style: l.object,
|
|
542
542
|
saveFileName: l.string,
|
|
543
543
|
saveOptions: l.object,
|
|
544
|
-
tools: l.arrayOf(l.oneOf(
|
|
544
|
+
tools: l.arrayOf(l.oneOf(be).isRequired),
|
|
545
545
|
zoomLevels: l.arrayOf(l.any),
|
|
546
546
|
zoom: l.number,
|
|
547
547
|
defaultZoom: l.number,
|
|
@@ -557,5 +557,5 @@ be.propTypes = {
|
|
|
557
557
|
onZoom: l.func
|
|
558
558
|
};
|
|
559
559
|
export {
|
|
560
|
-
|
|
560
|
+
ke as PDFViewer
|
|
561
561
|
};
|
|
@@ -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:"11.4.0-develop.6",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}));
|
|
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:"11.4.0-develop.8",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},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 F=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"}),m=u.getLicenseMessage(f),{zoom:z,zoomLevels:L=D.zoomLevels,defaultZoom:R=D.defaultZoom,minZoom:B=D.minZoom,maxZoom:q=D.maxZoom,zoomRate:j=D.zoomRate}=e,A=d.useLocalization(),U=g.useRef(null),[V,W]=g.useState(R),_=void 0!==z?z:V,G=L.slice().sort(K).find((e=>e.value===_))||{text:100*_+"%",value:_,id:_,locationString:""};G.locationString&&(G.text=A.toLanguageString(G.locationString,O[G.locationString]));const[H,$]=g.useState(!1),[J,Q]=g.useState(!0),[X,Y]=g.useState(0),[ee,oe]=g.useState(!0),[te,re]=g.useState(!1),[ae,ne]=g.useState(0),[le,ce]=g.useState(0),[se,ie]=g.useState(!1),[ue,de]=g.useState(""),pe=g.useMemo((()=>({})),[]);pe.currentZoom=_,pe.props=e;const me=g.useCallback((e=>{U.current&&U.current.style.setProperty("--scale-factor",String(e))}),[]),ge=g.useRef(null),fe=g.useRef(null);g.useImperativeHandle(ge,(()=>({get element(){return fe.current},props:e,get pages(){return pe.pages},get document(){return pe.document}})),[]),g.useImperativeHandle(t,(()=>ge.current));const ve=g.useCallback((()=>{if(pe.props.onLoad){const e={target:ge.current};pe.props.onLoad.call(void 0,e)}}),[]),ke=g.useCallback(((o,t,r)=>{if(e.onDownload){const a={target:ge.current,blob:o,fileName:t,saveOptions:r};return!1===e.onDownload.call(void 0,a)}return!1}),[e.onDownload]),be=g.useCallback((()=>{var e;pe.scroller&&pe.scroller.destroy(),pe.scroller=new o.Scroller(null==(e=U.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),pe.scroller.disablePanEventsTracking()}),[]),he=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));pe.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);pe.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{pe.document=t,pe.pages=e,pe.zoom=r,be(),Q(!1),$(!0),ve(),U.current&&o.scrollToPage(U.current,0)}),[]),pe.error=g.useCallback((o=>{if(pe.document=null,pe.pages=[],Q(!1),$(!1),e.onError){const t="string"==typeof o?{message:o}:o,r={error:null!=t?t:A.toLanguageString(Z,O[Z]),target:ge.current};e.onError.call(void 0,r)}}),[e.onError]),g.useEffect((()=>{U.current&&(e.url||e.data||e.arrayBuffer?(Q(!0),o.removeChildren(U.current),o.loadPDF({url:e.url,data:e.data,arrayBuffer:e.arrayBuffer,dom:U.current,zoom:pe.currentZoom,done:pe.done,error:pe.error}),me(pe.currentZoom)):(pe.document=null,pe.pages=[],$(!1),Q(!1),o.removeChildren(U.current)))}),[e.url,e.data,e.arrayBuffer]);const ye=g.useCallback(((e,t)=>{U.current&&(Q(!0),o.removeChildren(U.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:U.current,done:e=>{pe.pages=e,pe.zoom=t,Q(!1)},error:pe.error}))}),[]);g.useEffect((()=>{me(_),U.current&&pe.document&&_!==pe.zoom&&ye(pe.document,_)}),[_,ye]),g.useEffect((()=>()=>{pe.scroller&&pe.scroller.destroy(),pe.search&&pe.search.destroy(),pe.document=null,pe.pages=[]}),[]);const Ce=g.useCallback((()=>{re(!0),he(U.current)}),[]),we=g.useCallback((e=>{const o=e.value,t=pe.search.search({text:o,matchCase:se});ce(t.length?1:0),ne(t.length),de(o)}),[se]),Ee=g.useCallback((()=>{const e=pe.search.search({text:ue,matchCase:!se});ce(e.length?1:0),ne(e.length),ie(!se)}),[se,ue]),Se=g.useCallback((()=>{o.goToNextSearchMatch(pe),ce(le+1>ae?1:le+1)}),[le,ae]),xe=g.useCallback((()=>{o.goToPreviousSearchMatch(pe),ce(le-1<1?ae:le-1)}),[le,ae]),Ie=g.useCallback((()=>{pe.search.destroy(),ce(0),ne(0),ie(!1),de(""),re(!1)}),[]),Pe=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(pe),ce(le+1>ae?1:le+1)):"Escape"===e.key&&Ie()}),[le,ae]),Ne=g.useCallback((t=>{if(U.current){const r=t.skip;o.scrollToPage(U.current,r);const a={page:r+1,target:ge.current,syntheticEvent:t.syntheticEvent};e.onPageChange&&e.onPageChange.call(void 0,a)}Y(t.skip)}),[X,e.onPageChange]),ze=g.useCallback((t=>{if(fe.current){const r=o.currentPage(fe.current);if(r!==X){Y(r);const o={page:r+1,target:ge.current,syntheticEvent:t};e.onPageChange&&e.onPageChange.call(void 0,o)}}}),[X,e.onPageChange]),Le=g.useCallback((o=>{const t=Math.min(pe.currentZoom+j,q);if(t!==pe.currentZoom&&pe.document&&(W(t),e.onZoom)){const r={zoom:t,target:ge.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[j,q,e.onZoom]),Re=g.useCallback((o=>{const t=Math.max(pe.currentZoom-j,B);if(t!==pe.currentZoom&&pe.document&&(W(t),e.onZoom)){const r={zoom:t,target:ge.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[j,B,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 a=r?o.calculateZoomLevel(r.value,r.type,pe.currentZoom,U.current):1;if(a=Math.round(100*a)/100,pe.currentZoom!==a&&pe.document&&(W(a),e.onZoom)){const o={zoom:a,target:ge.current,syntheticEvent:t.syntheticEvent};e.onZoom.call(void 0,o)}}),[e.onZoom]),Te=g.useCallback((()=>{pe.scroller.disablePanEventsTracking(),oe(!0)}),[]),Oe=g.useCallback((()=>{pe.scroller.enablePanEventsTracking(),oe(!1)}),[]),Be=g.useCallback((()=>{o.download({pdf:pe.document,error:pe.error},e.saveFileName,e.saveOptions,ke)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,ke]),De=g.useCallback((()=>{Q(!0);o.print(pe.pages,(()=>{Q(!1)}),(e=>{Q(!1),pe.error(e)}))}),[]),Me=g.useCallback((e=>{const t=e.newState;t[0]&&t[0].getRawFile&&t[0].getRawFile().arrayBuffer().then((e=>{if(U.current){Q(!0),o.removeChildren(U.current);const t=void 0===pe.props.zoom?R:pe.props.zoom;o.loadPDF({arrayBuffer:e,dom:U.current,zoom:t,done:pe.done,error:pe.error}),W(t)}}))}),[R]),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()}}),[]),Ke=J&&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"}))),qe=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:A.toLanguageString(k,O[k]),disabled:_<=B||!H,onClick:Re,icon:"zoom-out",svgIcon:p.zoomOutIcon}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:A.toLanguageString(v,O[v]),disabled:_>=q||!H,onClick:Le,icon:"zoom-in",svgIcon:p.zoomInIcon})),je=g.createElement(s.ComboBox,{className:"k-toolbar-combobox",disabled:!H,data:L.map((e=>({...e,text:e.locationString?A.toLanguageString(e.locationString,O[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:H?G:null,allowCustom:!0,onChange:Ze,placeholder:A.toLanguageString(b,O[b])}),Ae={pager:g.createElement(l.Pager,{disabled:!H,previousNext:!0,type:"input",skip:X,take:1,total:pe.pages?pe.pages.length:0,info:!1,onPageChange:Ne}),spacer:g.createElement(a.ToolbarSpacer,null),zoomInOut:qe,zoom:je,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:A.toLanguageString(h,O[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!H,togglable:!0,selected:ee&&H,onClick:Te}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:A.toLanguageString(y,O[y]),icon:"hand",svgIcon:p.handIcon,disabled:!H,togglable:!0,selected:!ee&&H,onClick:Oe})),search:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:A.toLanguageString(C,O[C]),icon:"search",svgIcon:p.searchIcon,disabled:!H,onClick:Ce}),open:g.createElement(g.Fragment,null,g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:A.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:Me,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),download:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:A.toLanguageString(E,O[E]),icon:"download",svgIcon:p.downloadIcon,disabled:!H,onClick:Be}),print:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:A.toLanguageString(S,O[S]),icon:"print",svgIcon:p.printIcon,disabled:!H,onClick:De})},Ue=(e.tools||D.tools).map((e=>({...Ae[e],key:"toobar-tool-"+e+(F++,F)}))),Ve=g.createElement(a.Toolbar,{buttons:M},...Ue),We=g.createElement("div",{className:u.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":ee,"k-enable-panning":!ee}),onScroll:ze},te&&g.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},g.createElement(n.TextBox,{value:ue,onChange:we,placeholder:A.toLanguageString(C,O[C]),autoFocus:!0,onKeyDown:Pe,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:A.toLanguageString(I,O[I]),fillMode:"flat",togglable:!0,selected:se,onClick:Ee})))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,le)," ",A.toLanguageString(T,O[T]),g.createElement("span",null,ae)),g.createElement(a.Button,{title:A.toLanguageString(P,O[P]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===ae,onClick:xe}),g.createElement(a.Button,{title:A.toLanguageString(N,O[N]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===ae,onClick:Se}),g.createElement(a.Button,{title:A.toLanguageString(x,O[x]),fillMode:"flat",icon:"x",svgIcon:p.xIcon,onClick:Ie})),g.createElement("div",{ref:U,className:"k-pdf-viewer-pages"}));return g.createElement("div",{className:"k-pdf-viewer",style:e.style,ref:fe},e.onRenderLoader?e.onRenderLoader.call(void 0,Ke||null):Ke,e.onRenderToolbar?e.onRenderToolbar.call(void 0,Ve):Ve,e.onRenderContent?e.onRenderContent.call(void 0,We):We,r&&g.createElement(u.WatermarkOverlay,{message:m}))}));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: 1754643174,version:"11.4.0-develop.8",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: "11.4.0-develop.
|
|
13
|
+
publishDate: 1754643174,
|
|
14
|
+
version: "11.4.0-develop.8",
|
|
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": "11.4.0-develop.
|
|
3
|
+
"version": "11.4.0-develop.8",
|
|
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.
|
|
30
|
-
"@progress/kendo-react-buttons": "11.4.0-develop.
|
|
31
|
-
"@progress/kendo-react-common": "11.4.0-develop.
|
|
32
|
-
"@progress/kendo-react-data-tools": "11.4.0-develop.
|
|
33
|
-
"@progress/kendo-react-dropdowns": "11.4.0-develop.
|
|
34
|
-
"@progress/kendo-react-indicators": "11.4.0-develop.
|
|
35
|
-
"@progress/kendo-react-inputs": "11.4.0-develop.
|
|
36
|
-
"@progress/kendo-react-intl": "11.4.0-develop.
|
|
37
|
-
"@progress/kendo-react-upload": "11.4.0-develop.
|
|
29
|
+
"@progress/kendo-licensing": "^1.7.0",
|
|
30
|
+
"@progress/kendo-react-buttons": "11.4.0-develop.8",
|
|
31
|
+
"@progress/kendo-react-common": "11.4.0-develop.8",
|
|
32
|
+
"@progress/kendo-react-data-tools": "11.4.0-develop.8",
|
|
33
|
+
"@progress/kendo-react-dropdowns": "11.4.0-develop.8",
|
|
34
|
+
"@progress/kendo-react-indicators": "11.4.0-develop.8",
|
|
35
|
+
"@progress/kendo-react-inputs": "11.4.0-develop.8",
|
|
36
|
+
"@progress/kendo-react-intl": "11.4.0-develop.8",
|
|
37
|
+
"@progress/kendo-react-upload": "11.4.0-develop.8",
|
|
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": 1754643174,
|
|
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
|
},
|