@progress/kendo-react-pdf-viewer 12.3.0-develop.3 → 12.3.0-develop.5
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 +198 -195
- 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 +10 -10
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 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;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qe=require("react"),s=require("prop-types"),m=require("@progress/kendo-react-buttons"),A=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 L=Object.getOwnPropertyDescriptor(n,C);Object.defineProperty(p,C,L.get?L:{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"],w={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,V=e.forwardRef((n,p)=>{const C=!T.validatePackage(oe.packageMetadata,{component:"PDFViewer"}),L=T.getLicenseMessage(oe.packageMetadata),{zoom:W,zoomLevels:K=w.zoomLevels,defaultZoom:N=w.defaultZoom,minZoom:R=w.minZoom,maxZoom:B=w.maxZoom,zoomRate:M=w.zoomRate}=n,u=Ke.useLocalization(),c=e.useRef(null),[re,P]=e.useState(N),h=W!==void 0?W:re,Z=K.slice().sort(Ge).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),[le,k]=e.useState(!0),[E,U]=e.useState(0),[I,_]=e.useState(!0),[ce,H]=e.useState(!1),[y,D]=e.useState(0),[v,S]=e.useState(0),[x,G]=e.useState(!1),[F,J]=e.useState(""),t=e.useMemo(()=>({}),[]);t.currentZoom=h,t.props=n;const q=e.useCallback(o=>{c.current&&c.current.style.setProperty("--scale-factor",String(o))},[]),b=e.useRef(null),z=e.useRef(null);e.useImperativeHandle(b,()=>({get element(){return z.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 d={target:b.current,blob:o,fileName:r,saveOptions:l};return n.onDownload.call(void 0,d)===!1}return!1},[n.onDownload]),ie=e.useCallback(()=>{var o;t.scroller&&t.scroller.destroy(),t.scroller=new i.Scroller((o=c.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(),c.current&&i.scrollToPage(c.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(()=>{c.current&&(n.url||n.data||n.arrayBuffer?(k(!0),i.removeChildren(c.current),i.loadPDF({url:n.url,data:n.data,arrayBuffer:n.arrayBuffer,dom:c.current,zoom:t.currentZoom,done:t.done,error:t.error}),q(t.currentZoom)):(t.document=null,t.pages=[],O(!1),k(!1),i.removeChildren(c.current)))},[n.url,n.data,n.arrayBuffer]);const X=e.useCallback((o,r,l)=>{c.current&&z.current&&(k(!0),i.removeChildren(c.current),i.reloadDocument({pdfDoc:o,zoom:r,dom:c.current,done:d=>{t.pages=d,t.zoom=r,k(!1),c.current&&l>0&&i.scrollToPage(c.current,l)},error:t.error}))},[t]);e.useEffect(()=>{q(h),c.current&&t.document&&h!==t.zoom&&X(t.document,h,E)},[h,t.document,t.zoom,X,q,E]),e.useEffect(()=>()=>{t.scroller&&t.scroller.destroy(),t.search&&t.search.destroy(),t.document=null,t.pages=[]},[]);const me=e.useCallback(()=>{H(!0),ue(c.current)},[]),de=e.useCallback(o=>{const r=o.value,l=t.search.search({text:r,matchCase:x});S(l.length?1:0),D(l.length),J(r)},[x]),ge=e.useCallback(()=>{const o=t.search.search({text:F,matchCase:!x});S(o.length?1:0),D(o.length),G(!x)},[x,F]),fe=e.useCallback(()=>{i.goToNextSearchMatch(t),S(v+1>y?1:v+1)},[v,y]),he=e.useCallback(()=>{i.goToPreviousSearchMatch(t),S(v-1<1?y:v-1)},[v,y]),Y=e.useCallback(()=>{t.search.destroy(),S(0),D(0),G(!1),J(""),H(!1)},[]),ke=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),i.goToNextSearchMatch(t),S(v+1>y?1:v+1)):o.key==="Escape"&&Y()},[v,y]),ve=e.useCallback(o=>{if(c.current){const r=o.skip;i.scrollToPage(c.current,r);const l={page:r+1,target:b.current,syntheticEvent:o.syntheticEvent};n.onPageChange&&n.onPageChange.call(void 0,l)}U(o.skip)},[E,n.onPageChange]),be=e.useCallback(o=>{if(z.current){const r=i.currentPage(z.current);if(r!==E){U(r);const l={page:r+1,target:b.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,l)}}},[E,n.onPageChange]),ye=e.useCallback(o=>{const r=Math.min(t.currentZoom+M,B);if(r!==t.currentZoom&&t.document&&(P(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[t.currentZoom,t.document,M,B,n.onZoom]),pe=e.useCallback(o=>{const r=Math.max(t.currentZoom-M,R);if(r!==t.currentZoom&&t.document&&(P(r),n.onZoom)){const l={zoom:r,target:b.current,syntheticEvent:o};n.onZoom.call(void 0,l)}},[t.currentZoom,t.document,M,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 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,c.current):1;if(l=Math.round(l*100)/100,t.currentZoom!==l&&t.document&&(P(l),n.onZoom)){const d={zoom:l,target:b.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,d)}},[n.onZoom]),Ee=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),_(!0)},[]),Se=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),_(!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(d=>{if(c.current){k(!0),i.removeChildren(c.current);const j=t.props.zoom===void 0?N:t.props.zoom;i.loadPDF({arrayBuffer:d,dom:c.current,zoom:j,done:t.done,error:t.error}),P(j)}})},[N]),ze=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()}},[]),$=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"}))),Le=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: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||!g,onClick:ye,icon:"zoom-in",svgIcon:f.zoomInIcon})),Me=e.createElement(Ve.ComboBox,{className:"k-toolbar-combobox",disabled:!g,data:K.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:Ce,placeholder:u.toLanguageString(a.zoomLevel,a.messages[a.zoomLevel])}),Pe=e.createElement(je.Pager,{disabled:!g,previousNext:!0,type:"input",skip:E,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:!g,togglable:!0,selected:I&&g,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:!g,togglable:!0,selected:!I&&g,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:!g,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:ze}),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:!g,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:!g,onClick:we}),De={pager:Pe,spacer:Ie,zoomInOut:Le,zoom:Me,selection:Te,search:Ne,open:Re,download:Be,print:Oe},Fe=(n.tools||w.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":I,"k-enable-panning":!I}),onScroll:be},ce&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(A.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(A.InputSeparator,null),e.createElement(A.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:x,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:c,className:"k-pdf-viewer-pages"}));return e.createElement("div",{className:"k-pdf-viewer",style:n.style,ref:z},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:L}))});V.displayName="KendoReactPDFViewer";V.propTypes={url:s.string,data:s.string,arrayBuffer:s.any,typedArray:s.any,style:s.object,saveFileName:s.string,saveOptions:s.object,tools:s.arrayOf(s.oneOf(ae).isRequired),zoomLevels:s.arrayOf(s.any),zoom:s.number,defaultZoom:s.number,minZoom:s.number,maxZoom:s.number,zoomRate:s.number,onError:s.func,onLoad:s.func,onDownload:s.func,onRenderToolbar:s.func,onRenderContent:s.func,onRenderLoader:s.func,onZoom:s.func};exports.PDFViewer=V;
|
package/PDFViewer.mjs
CHANGED
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
|
-
import
|
|
10
|
-
import { ButtonGroup as
|
|
11
|
-
import { TextBox as
|
|
9
|
+
import c from "prop-types";
|
|
10
|
+
import { ButtonGroup as X, Button as d, Toolbar as tt, ToolbarSpacer as ot } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { TextBox as nt, InputSeparator as at, InputSuffix as rt } from "@progress/kendo-react-inputs";
|
|
12
12
|
import { Pager as lt } from "@progress/kendo-react-data-tools";
|
|
13
13
|
import { Upload as ct } from "@progress/kendo-react-upload";
|
|
14
14
|
import { ComboBox as st } from "@progress/kendo-react-dropdowns";
|
|
15
15
|
import { Loader as it } from "@progress/kendo-react-indicators";
|
|
16
16
|
import { validatePackage as ut, getLicenseMessage as mt, classNames as dt, WatermarkOverlay as gt } from "@progress/kendo-react-common";
|
|
17
17
|
import { useLocalization as ft } from "@progress/kendo-react-intl";
|
|
18
|
-
import { zoomOutIcon as ht, zoomInIcon as vt, pointerIcon as
|
|
18
|
+
import { zoomOutIcon as ht, zoomInIcon as vt, pointerIcon as kt, handIcon as bt, 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 Lt, SearchService as zt, scrollToPage as
|
|
22
|
-
import { messages as i, popupBlocked as oe, zoomOut as
|
|
23
|
-
const
|
|
20
|
+
import { packageMetadata as Y } from "./package-metadata.mjs";
|
|
21
|
+
import { Scroller as Lt, SearchService as zt, scrollToPage as B, removeChildren as z, loadPDF as ee, reloadDocument as It, goToNextSearchMatch as te, goToPreviousSearchMatch as Mt, currentPage as Tt, calculateZoomLevel as Nt, 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 ne, zoomIn as ae, 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 ke = [
|
|
24
24
|
"pager",
|
|
25
25
|
"spacer",
|
|
26
26
|
"zoomInOut",
|
|
@@ -31,10 +31,10 @@ const be = [
|
|
|
31
31
|
"open",
|
|
32
32
|
"download",
|
|
33
33
|
"print"
|
|
34
|
-
],
|
|
34
|
+
], C = {
|
|
35
35
|
minZoom: 0.5,
|
|
36
36
|
maxZoom: 4,
|
|
37
|
-
tools: [...
|
|
37
|
+
tools: [...ke],
|
|
38
38
|
zoomRate: 0.25,
|
|
39
39
|
zoomLevels: [
|
|
40
40
|
{ id: 1, priority: 1, value: 1, text: "Actual width", type: "ActualWidth", locationString: Dt },
|
|
@@ -61,36 +61,36 @@ let ve = 0;
|
|
|
61
61
|
function Vt() {
|
|
62
62
|
return ve++, ve;
|
|
63
63
|
}
|
|
64
|
-
const Wt = (
|
|
65
|
-
const pe = !ut(
|
|
66
|
-
zoom:
|
|
67
|
-
zoomLevels:
|
|
68
|
-
defaultZoom: M =
|
|
69
|
-
minZoom:
|
|
70
|
-
maxZoom:
|
|
71
|
-
zoomRate:
|
|
72
|
-
} =
|
|
64
|
+
const Wt = (n, x) => n.priority > x.priority ? -1 : n.priority < x.priority ? 1 : 0, be = e.forwardRef((n, x) => {
|
|
65
|
+
const pe = !ut(Y, { component: "PDFViewer" }), ye = mt(Y), {
|
|
66
|
+
zoom: A,
|
|
67
|
+
zoomLevels: V = C.zoomLevels,
|
|
68
|
+
defaultZoom: M = C.defaultZoom,
|
|
69
|
+
minZoom: T = C.minZoom,
|
|
70
|
+
maxZoom: N = C.maxZoom,
|
|
71
|
+
zoomRate: w = C.zoomRate
|
|
72
|
+
} = n, s = ft(), l = e.useRef(null), [Ce, Z] = e.useState(M), g = A !== void 0 ? A : Ce, E = V.slice().sort(Wt).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
|
+
E.locationString && (E.text = s.toLanguageString(
|
|
79
|
+
E.locationString,
|
|
80
|
+
i[E.locationString]
|
|
81
81
|
));
|
|
82
|
-
const [
|
|
83
|
-
t.currentZoom = g, t.props =
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
}, []), v = e.useRef(null),
|
|
82
|
+
const [m, P] = e.useState(!1), [Ee, f] = e.useState(!0), [b, W] = e.useState(0), [L, K] = e.useState(!0), [Se, U] = e.useState(!1), [k, R] = e.useState(0), [h, p] = e.useState(0), [y, j] = e.useState(!1), [F, q] = e.useState(""), t = e.useMemo(() => ({}), []);
|
|
83
|
+
t.currentZoom = g, t.props = n;
|
|
84
|
+
const D = e.useCallback((o) => {
|
|
85
|
+
l.current && l.current.style.setProperty("--scale-factor", String(o));
|
|
86
|
+
}, []), v = e.useRef(null), S = e.useRef(null);
|
|
87
87
|
e.useImperativeHandle(
|
|
88
88
|
v,
|
|
89
89
|
() => ({
|
|
90
90
|
get element() {
|
|
91
|
-
return
|
|
91
|
+
return S.current;
|
|
92
92
|
},
|
|
93
|
-
props:
|
|
93
|
+
props: n,
|
|
94
94
|
get pages() {
|
|
95
95
|
return t.pages;
|
|
96
96
|
},
|
|
@@ -99,232 +99,235 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
99
99
|
}
|
|
100
100
|
}),
|
|
101
101
|
[]
|
|
102
|
-
), e.useImperativeHandle(
|
|
102
|
+
), e.useImperativeHandle(x, () => v.current);
|
|
103
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);
|
|
107
107
|
}
|
|
108
|
-
}, []),
|
|
109
|
-
(o,
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
108
|
+
}, []), H = e.useCallback(
|
|
109
|
+
(o, a, r) => {
|
|
110
|
+
if (n.onDownload) {
|
|
111
|
+
const u = {
|
|
112
112
|
target: v.current,
|
|
113
113
|
blob: o,
|
|
114
|
-
fileName:
|
|
114
|
+
fileName: a,
|
|
115
115
|
saveOptions: r
|
|
116
116
|
};
|
|
117
|
-
return
|
|
117
|
+
return n.onDownload.call(void 0, u) === !1;
|
|
118
118
|
}
|
|
119
119
|
return !1;
|
|
120
120
|
},
|
|
121
|
-
[
|
|
121
|
+
[n.onDownload]
|
|
122
122
|
), we = e.useCallback(() => {
|
|
123
123
|
var o;
|
|
124
|
-
t.scroller && t.scroller.destroy(), t.scroller = new Lt((o =
|
|
124
|
+
t.scroller && t.scroller.destroy(), t.scroller = new Lt((o = l.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
|
-
const
|
|
129
|
+
const a = Array.from(o.querySelectorAll(".k-text-layer"));
|
|
130
130
|
t.search = new zt({
|
|
131
|
-
textContainers:
|
|
131
|
+
textContainers: a || [],
|
|
132
132
|
highlightClass: "k-search-highlight",
|
|
133
133
|
highlightMarkClass: "k-search-highlight-mark",
|
|
134
134
|
charClass: "k-text-char"
|
|
135
135
|
});
|
|
136
136
|
}, []);
|
|
137
|
-
t.done = e.useCallback(({ pdfPages: o, pdfDoc:
|
|
138
|
-
t.document =
|
|
137
|
+
t.done = e.useCallback(({ pdfPages: o, pdfDoc: a, zoom: r }) => {
|
|
138
|
+
t.document = a, t.pages = o, t.zoom = r, we(), f(!1), P(!0), xe(), l.current && B(l.current, 0);
|
|
139
139
|
}, []), t.error = e.useCallback(
|
|
140
140
|
(o) => {
|
|
141
|
-
if (t.document = null, t.pages = [], f(!1), P(!1),
|
|
142
|
-
const
|
|
143
|
-
error:
|
|
141
|
+
if (t.document = null, t.pages = [], f(!1), P(!1), n.onError) {
|
|
142
|
+
const a = typeof o == "string" ? { message: o } : o, r = {
|
|
143
|
+
error: a != null ? a : s.toLanguageString(oe, i[oe]),
|
|
144
144
|
target: v.current
|
|
145
145
|
};
|
|
146
|
-
|
|
146
|
+
n.onError.call(void 0, r);
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
|
-
[
|
|
149
|
+
[n.onError]
|
|
150
150
|
), e.useEffect(() => {
|
|
151
|
-
|
|
152
|
-
url:
|
|
153
|
-
data:
|
|
154
|
-
arrayBuffer:
|
|
155
|
-
dom:
|
|
151
|
+
l.current && (n.url || n.data || n.arrayBuffer ? (f(!0), z(l.current), ee({
|
|
152
|
+
url: n.url,
|
|
153
|
+
data: n.data,
|
|
154
|
+
arrayBuffer: n.arrayBuffer,
|
|
155
|
+
dom: l.current,
|
|
156
156
|
zoom: t.currentZoom,
|
|
157
157
|
done: t.done,
|
|
158
158
|
error: t.error
|
|
159
|
-
}),
|
|
160
|
-
}, [
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
159
|
+
}), D(t.currentZoom)) : (t.document = null, t.pages = [], P(!1), f(!1), z(l.current)));
|
|
160
|
+
}, [n.url, n.data, n.arrayBuffer]);
|
|
161
|
+
const $ = e.useCallback(
|
|
162
|
+
(o, a, r) => {
|
|
163
|
+
l.current && S.current && (f(!0), z(l.current), It({
|
|
164
|
+
pdfDoc: o,
|
|
165
|
+
zoom: a,
|
|
166
|
+
dom: l.current,
|
|
167
|
+
done: (u) => {
|
|
168
|
+
t.pages = u, t.zoom = a, f(!1), l.current && r > 0 && B(l.current, r);
|
|
169
|
+
},
|
|
170
|
+
error: t.error
|
|
171
|
+
}));
|
|
172
|
+
},
|
|
173
|
+
[t]
|
|
174
|
+
);
|
|
172
175
|
e.useEffect(() => {
|
|
173
|
-
|
|
174
|
-
}, [g,
|
|
176
|
+
D(g), l.current && t.document && g !== t.zoom && $(t.document, g, b);
|
|
177
|
+
}, [g, t.document, t.zoom, $, D, b]), e.useEffect(() => () => {
|
|
175
178
|
t.scroller && t.scroller.destroy(), t.search && t.search.destroy(), t.document = null, t.pages = [];
|
|
176
179
|
}, []);
|
|
177
180
|
const Le = e.useCallback(() => {
|
|
178
|
-
|
|
181
|
+
U(!0), Ze(l.current);
|
|
179
182
|
}, []), ze = e.useCallback(
|
|
180
183
|
(o) => {
|
|
181
|
-
const
|
|
182
|
-
|
|
184
|
+
const a = o.value, r = t.search.search({ text: a, matchCase: y });
|
|
185
|
+
p(r.length ? 1 : 0), R(r.length), q(a);
|
|
183
186
|
},
|
|
184
|
-
[
|
|
187
|
+
[y]
|
|
185
188
|
), Ie = e.useCallback(() => {
|
|
186
|
-
const o = t.search.search({ text: F, matchCase: !
|
|
187
|
-
|
|
188
|
-
}, [
|
|
189
|
-
te(t),
|
|
190
|
-
}, [h,
|
|
191
|
-
Mt(t),
|
|
192
|
-
}, [h,
|
|
193
|
-
t.search.destroy(),
|
|
194
|
-
}, []),
|
|
189
|
+
const o = t.search.search({ text: F, matchCase: !y });
|
|
190
|
+
p(o.length ? 1 : 0), R(o.length), j(!y);
|
|
191
|
+
}, [y, F]), Me = e.useCallback(() => {
|
|
192
|
+
te(t), p(h + 1 > k ? 1 : h + 1);
|
|
193
|
+
}, [h, k]), Te = e.useCallback(() => {
|
|
194
|
+
Mt(t), p(h - 1 < 1 ? k : h - 1);
|
|
195
|
+
}, [h, k]), _ = e.useCallback(() => {
|
|
196
|
+
t.search.destroy(), p(0), R(0), j(!1), q(""), U(!1);
|
|
197
|
+
}, []), Ne = e.useCallback(
|
|
195
198
|
(o) => {
|
|
196
|
-
o.key === "Enter" ? (o.preventDefault(), te(t),
|
|
199
|
+
o.key === "Enter" ? (o.preventDefault(), te(t), p(h + 1 > k ? 1 : h + 1)) : o.key === "Escape" && _();
|
|
197
200
|
},
|
|
198
|
-
[h,
|
|
201
|
+
[h, k]
|
|
199
202
|
), Pe = e.useCallback(
|
|
200
203
|
(o) => {
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
+
if (l.current) {
|
|
205
|
+
const a = o.skip;
|
|
206
|
+
B(l.current, a);
|
|
204
207
|
const r = {
|
|
205
|
-
page:
|
|
208
|
+
page: a + 1,
|
|
206
209
|
target: v.current,
|
|
207
210
|
syntheticEvent: o.syntheticEvent
|
|
208
211
|
};
|
|
209
|
-
|
|
212
|
+
n.onPageChange && n.onPageChange.call(void 0, r);
|
|
210
213
|
}
|
|
211
|
-
|
|
214
|
+
W(o.skip);
|
|
212
215
|
},
|
|
213
|
-
[
|
|
216
|
+
[b, n.onPageChange]
|
|
214
217
|
), Re = e.useCallback(
|
|
215
218
|
(o) => {
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
-
|
|
219
|
+
if (S.current) {
|
|
220
|
+
const a = Tt(S.current);
|
|
221
|
+
if (a !== b) {
|
|
222
|
+
W(a);
|
|
220
223
|
const r = {
|
|
221
|
-
page:
|
|
224
|
+
page: a + 1,
|
|
222
225
|
target: v.current,
|
|
223
226
|
syntheticEvent: o
|
|
224
227
|
};
|
|
225
|
-
|
|
228
|
+
n.onPageChange && n.onPageChange.call(void 0, r);
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
},
|
|
229
|
-
[
|
|
232
|
+
[b, n.onPageChange]
|
|
230
233
|
), Fe = e.useCallback(
|
|
231
234
|
(o) => {
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
235
|
+
const a = Math.min(t.currentZoom + w, N);
|
|
236
|
+
if (a !== t.currentZoom && t.document && (Z(a), n.onZoom)) {
|
|
234
237
|
const r = {
|
|
235
|
-
zoom:
|
|
238
|
+
zoom: a,
|
|
236
239
|
target: v.current,
|
|
237
240
|
syntheticEvent: o
|
|
238
241
|
};
|
|
239
|
-
|
|
242
|
+
n.onZoom.call(void 0, r);
|
|
240
243
|
}
|
|
241
244
|
},
|
|
242
|
-
[
|
|
245
|
+
[t.currentZoom, t.document, w, N, n.onZoom]
|
|
243
246
|
), De = e.useCallback(
|
|
244
247
|
(o) => {
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
248
|
+
const a = Math.max(t.currentZoom - w, T);
|
|
249
|
+
if (a !== t.currentZoom && t.document && (Z(a), n.onZoom)) {
|
|
247
250
|
const r = {
|
|
248
|
-
zoom:
|
|
251
|
+
zoom: a,
|
|
249
252
|
target: v.current,
|
|
250
253
|
syntheticEvent: o
|
|
251
254
|
};
|
|
252
|
-
|
|
255
|
+
n.onZoom.call(void 0, r);
|
|
253
256
|
}
|
|
254
257
|
},
|
|
255
|
-
[
|
|
258
|
+
[t.currentZoom, t.document, w, T, n.onZoom]
|
|
256
259
|
), Oe = e.useCallback(
|
|
257
260
|
(o) => {
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
typeof
|
|
261
|
+
const a = o.value === null ? { text: "100%", value: 1, id: 100 } : { ...o.value };
|
|
262
|
+
if (a.value === void 0) {
|
|
263
|
+
const u = parseFloat(a.text);
|
|
264
|
+
typeof u == "number" && !Number.isNaN(u) ? a.value = u / 100 : a.value = 1;
|
|
262
265
|
}
|
|
263
|
-
let r =
|
|
264
|
-
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (
|
|
265
|
-
const
|
|
266
|
+
let r = a ? Nt(a.value, a.type, t.currentZoom, l.current) : 1;
|
|
267
|
+
if (r = Math.round(r * 100) / 100, t.currentZoom !== r && t.document && (Z(r), n.onZoom)) {
|
|
268
|
+
const u = {
|
|
266
269
|
zoom: r,
|
|
267
270
|
target: v.current,
|
|
268
271
|
syntheticEvent: o.syntheticEvent
|
|
269
272
|
};
|
|
270
|
-
|
|
273
|
+
n.onZoom.call(void 0, u);
|
|
271
274
|
}
|
|
272
275
|
},
|
|
273
|
-
[
|
|
276
|
+
[n.onZoom]
|
|
274
277
|
), Be = e.useCallback(() => {
|
|
275
|
-
t.scroller.disablePanEventsTracking(),
|
|
278
|
+
t.scroller.disablePanEventsTracking(), K(!0);
|
|
276
279
|
}, []), Ae = e.useCallback(() => {
|
|
277
|
-
t.scroller.enablePanEventsTracking(),
|
|
280
|
+
t.scroller.enablePanEventsTracking(), K(!1);
|
|
278
281
|
}, []), Ve = e.useCallback(() => {
|
|
279
282
|
Pt(
|
|
280
283
|
{
|
|
281
284
|
pdf: t.document,
|
|
282
285
|
error: t.error
|
|
283
286
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
n.saveFileName,
|
|
288
|
+
n.saveOptions,
|
|
289
|
+
H
|
|
287
290
|
);
|
|
288
|
-
}, [
|
|
291
|
+
}, [n.url, n.data, n.arrayBuffer, n.saveFileName, n.saveOptions, H]), We = e.useCallback(() => {
|
|
289
292
|
f(!0);
|
|
290
293
|
const o = (r) => {
|
|
291
294
|
f(!1), t.error(r);
|
|
292
|
-
},
|
|
295
|
+
}, a = () => {
|
|
293
296
|
f(!1);
|
|
294
297
|
};
|
|
295
|
-
Rt(t.pages,
|
|
298
|
+
Rt(t.pages, a, o);
|
|
296
299
|
}, []), Ke = e.useCallback(
|
|
297
300
|
(o) => {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
f(!0), z(
|
|
302
|
-
const
|
|
301
|
+
const a = o.newState;
|
|
302
|
+
a[0] && a[0].getRawFile && a[0].getRawFile().arrayBuffer().then((u) => {
|
|
303
|
+
if (l.current) {
|
|
304
|
+
f(!0), z(l.current);
|
|
305
|
+
const O = t.props.zoom === void 0 ? M : t.props.zoom;
|
|
303
306
|
ee({
|
|
304
|
-
arrayBuffer:
|
|
305
|
-
dom:
|
|
306
|
-
zoom:
|
|
307
|
+
arrayBuffer: u,
|
|
308
|
+
dom: l.current,
|
|
309
|
+
zoom: O,
|
|
307
310
|
done: t.done,
|
|
308
311
|
error: t.error
|
|
309
|
-
}),
|
|
312
|
+
}), Z(O);
|
|
310
313
|
}
|
|
311
314
|
});
|
|
312
315
|
},
|
|
313
316
|
[M]
|
|
314
317
|
), Ue = e.useCallback((o) => {
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
317
|
-
const r =
|
|
318
|
-
|
|
318
|
+
const a = o.target;
|
|
319
|
+
if (a instanceof Element && a.parentNode) {
|
|
320
|
+
const r = a.closest(".k-toolbar"), u = r && r.querySelector(".k-upload input");
|
|
321
|
+
u && u.click();
|
|
319
322
|
}
|
|
320
|
-
}, []),
|
|
323
|
+
}, []), G = 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(X, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
321
324
|
d,
|
|
322
325
|
{
|
|
323
326
|
className: "k-group-start",
|
|
324
327
|
fillMode: "flat",
|
|
325
328
|
themeColor: "base",
|
|
326
|
-
title: s.toLanguageString(
|
|
327
|
-
disabled: g <=
|
|
329
|
+
title: s.toLanguageString(ne, i[ne]),
|
|
330
|
+
disabled: g <= T || !m,
|
|
328
331
|
onClick: De,
|
|
329
332
|
icon: "zoom-out",
|
|
330
333
|
svgIcon: ht
|
|
@@ -335,8 +338,8 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
335
338
|
className: "k-group-end",
|
|
336
339
|
fillMode: "flat",
|
|
337
340
|
themeColor: "base",
|
|
338
|
-
title: s.toLanguageString(
|
|
339
|
-
disabled: g >=
|
|
341
|
+
title: s.toLanguageString(ae, i[ae]),
|
|
342
|
+
disabled: g >= N || !m,
|
|
340
343
|
onClick: Fe,
|
|
341
344
|
icon: "zoom-in",
|
|
342
345
|
svgIcon: vt
|
|
@@ -345,14 +348,14 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
345
348
|
st,
|
|
346
349
|
{
|
|
347
350
|
className: "k-toolbar-combobox",
|
|
348
|
-
disabled: !
|
|
349
|
-
data:
|
|
351
|
+
disabled: !m,
|
|
352
|
+
data: V.map((o) => ({
|
|
350
353
|
...o,
|
|
351
354
|
text: o.locationString ? s.toLanguageString(o.locationString, i[o.locationString]) : o.text
|
|
352
355
|
})),
|
|
353
356
|
dataItemKey: "id",
|
|
354
357
|
textField: "text",
|
|
355
|
-
value:
|
|
358
|
+
value: m ? E : null,
|
|
356
359
|
allowCustom: !0,
|
|
357
360
|
onChange: Oe,
|
|
358
361
|
placeholder: s.toLanguageString(re, i[re])
|
|
@@ -360,16 +363,16 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
360
363
|
), He = /* @__PURE__ */ e.createElement(
|
|
361
364
|
lt,
|
|
362
365
|
{
|
|
363
|
-
disabled: !
|
|
366
|
+
disabled: !m,
|
|
364
367
|
previousNext: !0,
|
|
365
368
|
type: "input",
|
|
366
|
-
skip:
|
|
369
|
+
skip: b,
|
|
367
370
|
take: 1,
|
|
368
371
|
total: t.pages ? t.pages.length : 0,
|
|
369
372
|
info: !1,
|
|
370
373
|
onPageChange: Pe
|
|
371
374
|
}
|
|
372
|
-
), $e = /* @__PURE__ */ e.createElement(ot, null), _e = /* @__PURE__ */ e.createElement(
|
|
375
|
+
), $e = /* @__PURE__ */ e.createElement(ot, null), _e = /* @__PURE__ */ e.createElement(X, { className: "k-toolbar-button-group k-button-group-solid" }, /* @__PURE__ */ e.createElement(
|
|
373
376
|
d,
|
|
374
377
|
{
|
|
375
378
|
className: "k-group-start",
|
|
@@ -377,10 +380,10 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
377
380
|
themeColor: "base",
|
|
378
381
|
title: s.toLanguageString(le, i[le]),
|
|
379
382
|
icon: "pointer",
|
|
380
|
-
svgIcon:
|
|
381
|
-
disabled: !
|
|
383
|
+
svgIcon: kt,
|
|
384
|
+
disabled: !m,
|
|
382
385
|
togglable: !0,
|
|
383
|
-
selected:
|
|
386
|
+
selected: L && m,
|
|
384
387
|
onClick: Be
|
|
385
388
|
}
|
|
386
389
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -391,10 +394,10 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
391
394
|
themeColor: "base",
|
|
392
395
|
title: s.toLanguageString(ce, i[ce]),
|
|
393
396
|
icon: "hand",
|
|
394
|
-
svgIcon:
|
|
395
|
-
disabled: !
|
|
397
|
+
svgIcon: bt,
|
|
398
|
+
disabled: !m,
|
|
396
399
|
togglable: !0,
|
|
397
|
-
selected: !
|
|
400
|
+
selected: !L && m,
|
|
398
401
|
onClick: Ae
|
|
399
402
|
}
|
|
400
403
|
)), Ge = /* @__PURE__ */ e.createElement(
|
|
@@ -406,7 +409,7 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
406
409
|
title: s.toLanguageString(I, i[I]),
|
|
407
410
|
icon: "search",
|
|
408
411
|
svgIcon: pt,
|
|
409
|
-
disabled: !
|
|
412
|
+
disabled: !m,
|
|
410
413
|
onClick: Le
|
|
411
414
|
}
|
|
412
415
|
), Je = /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
@@ -440,7 +443,7 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
440
443
|
title: s.toLanguageString(ie, i[ie]),
|
|
441
444
|
icon: "download",
|
|
442
445
|
svgIcon: Ct,
|
|
443
|
-
disabled: !
|
|
446
|
+
disabled: !m,
|
|
444
447
|
onClick: Ve
|
|
445
448
|
}
|
|
446
449
|
), Xe = /* @__PURE__ */ e.createElement(
|
|
@@ -452,7 +455,7 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
452
455
|
title: s.toLanguageString(ue, i[ue]),
|
|
453
456
|
icon: "print",
|
|
454
457
|
svgIcon: Et,
|
|
455
|
-
disabled: !
|
|
458
|
+
disabled: !m,
|
|
456
459
|
onClick: We
|
|
457
460
|
}
|
|
458
461
|
), Ye = {
|
|
@@ -465,27 +468,27 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
465
468
|
open: Je,
|
|
466
469
|
download: Qe,
|
|
467
470
|
print: Xe
|
|
468
|
-
}, et = (
|
|
471
|
+
}, et = (n.tools || C.tools).map((o) => ({
|
|
469
472
|
...Ye[o],
|
|
470
473
|
key: "toobar-tool-" + o + Vt()
|
|
471
|
-
})),
|
|
474
|
+
})), J = /* @__PURE__ */ e.createElement(tt, { buttons: At }, ...et), Q = /* @__PURE__ */ e.createElement(
|
|
472
475
|
"div",
|
|
473
476
|
{
|
|
474
477
|
className: dt("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto", {
|
|
475
|
-
"k-enable-text-select":
|
|
476
|
-
"k-enable-panning": !
|
|
478
|
+
"k-enable-text-select": L,
|
|
479
|
+
"k-enable-panning": !L
|
|
477
480
|
}),
|
|
478
481
|
onScroll: Re
|
|
479
482
|
},
|
|
480
483
|
Se && /* @__PURE__ */ e.createElement("div", { className: "k-search-panel k-pos-sticky k-top-center" }, /* @__PURE__ */ e.createElement(
|
|
481
|
-
|
|
484
|
+
nt,
|
|
482
485
|
{
|
|
483
486
|
value: F,
|
|
484
487
|
onChange: ze,
|
|
485
488
|
placeholder: s.toLanguageString(I, i[I]),
|
|
486
489
|
autoFocus: !0,
|
|
487
|
-
onKeyDown:
|
|
488
|
-
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
490
|
+
onKeyDown: Ne,
|
|
491
|
+
suffix: () => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(at, null), /* @__PURE__ */ e.createElement(rt, null, /* @__PURE__ */ e.createElement(
|
|
489
492
|
d,
|
|
490
493
|
{
|
|
491
494
|
icon: "convert-lowercase",
|
|
@@ -493,20 +496,20 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
493
496
|
title: s.toLanguageString(me, i[me]),
|
|
494
497
|
fillMode: "flat",
|
|
495
498
|
togglable: !0,
|
|
496
|
-
selected:
|
|
499
|
+
selected: y,
|
|
497
500
|
onClick: Ie
|
|
498
501
|
}
|
|
499
502
|
)))
|
|
500
503
|
}
|
|
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,
|
|
504
|
+
), /* @__PURE__ */ e.createElement("span", { className: "k-search-matches" }, /* @__PURE__ */ e.createElement("span", null, h), " ", s.toLanguageString(de, i[de]), /* @__PURE__ */ e.createElement("span", null, k)), /* @__PURE__ */ e.createElement(
|
|
502
505
|
d,
|
|
503
506
|
{
|
|
504
507
|
title: s.toLanguageString(ge, i[ge]),
|
|
505
508
|
fillMode: "flat",
|
|
506
509
|
icon: "arrow-up",
|
|
507
510
|
svgIcon: xt,
|
|
508
|
-
disabled:
|
|
509
|
-
onClick:
|
|
511
|
+
disabled: k === 0,
|
|
512
|
+
onClick: Te
|
|
510
513
|
}
|
|
511
514
|
), /* @__PURE__ */ e.createElement(
|
|
512
515
|
d,
|
|
@@ -515,7 +518,7 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
515
518
|
fillMode: "flat",
|
|
516
519
|
icon: "arrow-down",
|
|
517
520
|
svgIcon: wt,
|
|
518
|
-
disabled:
|
|
521
|
+
disabled: k === 0,
|
|
519
522
|
onClick: Me
|
|
520
523
|
}
|
|
521
524
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -525,37 +528,37 @@ const Wt = (a, E) => a.priority > E.priority ? -1 : a.priority < E.priority ? 1
|
|
|
525
528
|
fillMode: "flat",
|
|
526
529
|
icon: "x",
|
|
527
530
|
svgIcon: Zt,
|
|
528
|
-
onClick:
|
|
531
|
+
onClick: _
|
|
529
532
|
}
|
|
530
533
|
)),
|
|
531
|
-
/* @__PURE__ */ e.createElement("div", { ref:
|
|
534
|
+
/* @__PURE__ */ e.createElement("div", { ref: l, className: "k-pdf-viewer-pages" })
|
|
532
535
|
);
|
|
533
|
-
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style:
|
|
536
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-pdf-viewer", style: n.style, ref: S }, n.onRenderLoader ? n.onRenderLoader.call(void 0, G || null) : G, n.onRenderToolbar ? n.onRenderToolbar.call(void 0, J) : J, n.onRenderContent ? n.onRenderContent.call(void 0, Q) : Q, pe && /* @__PURE__ */ e.createElement(gt, { message: ye }));
|
|
534
537
|
});
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
url:
|
|
538
|
-
data:
|
|
539
|
-
arrayBuffer:
|
|
540
|
-
typedArray:
|
|
541
|
-
style:
|
|
542
|
-
saveFileName:
|
|
543
|
-
saveOptions:
|
|
544
|
-
tools:
|
|
545
|
-
zoomLevels:
|
|
546
|
-
zoom:
|
|
547
|
-
defaultZoom:
|
|
548
|
-
minZoom:
|
|
549
|
-
maxZoom:
|
|
550
|
-
zoomRate:
|
|
551
|
-
onError:
|
|
552
|
-
onLoad:
|
|
553
|
-
onDownload:
|
|
554
|
-
onRenderToolbar:
|
|
555
|
-
onRenderContent:
|
|
556
|
-
onRenderLoader:
|
|
557
|
-
onZoom:
|
|
538
|
+
be.displayName = "KendoReactPDFViewer";
|
|
539
|
+
be.propTypes = {
|
|
540
|
+
url: c.string,
|
|
541
|
+
data: c.string,
|
|
542
|
+
arrayBuffer: c.any,
|
|
543
|
+
typedArray: c.any,
|
|
544
|
+
style: c.object,
|
|
545
|
+
saveFileName: c.string,
|
|
546
|
+
saveOptions: c.object,
|
|
547
|
+
tools: c.arrayOf(c.oneOf(ke).isRequired),
|
|
548
|
+
zoomLevels: c.arrayOf(c.any),
|
|
549
|
+
zoom: c.number,
|
|
550
|
+
defaultZoom: c.number,
|
|
551
|
+
minZoom: c.number,
|
|
552
|
+
maxZoom: c.number,
|
|
553
|
+
zoomRate: c.number,
|
|
554
|
+
onError: c.func,
|
|
555
|
+
onLoad: c.func,
|
|
556
|
+
onDownload: c.func,
|
|
557
|
+
onRenderToolbar: c.func,
|
|
558
|
+
onRenderContent: c.func,
|
|
559
|
+
onRenderLoader: c.func,
|
|
560
|
+
onZoom: c.func
|
|
558
561
|
};
|
|
559
562
|
export {
|
|
560
|
-
|
|
563
|
+
be as PDFViewer
|
|
561
564
|
};
|
|
@@ -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=Object.freeze({name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:1673300081,version:"12.3.0-develop.3",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",z="pdfviewer.nextMatch",N="pdfviewer.actualWidth",L="pdfviewer.fitToWidth",R="pdfviewer.fitToPage",Z="pdfviewer.popupBlocked",O="pdfviewer.searchOf",T={[v]:"Zoom in",[k]:"Zoom out",[b]:"Choose zoom level",[h]:"Enable selection",[y]:"Enable panning",[C]:"Search",[w]:"Open",[E]:"Download",[O]:"of",[S]:"Print",[x]:"Close",[I]:"Match case",[P]:"Previous match",[z]:"Next match",[N]:"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:N},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:L},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString: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:N,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!==N?N:V,G=L.slice().sort(K).find((e=>e.value===_))||{text:100*_+"%",value:_,id:_,locationString:""};G.locationString&&(G.text=A.toLanguageString(G.locationString,T[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,T[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]),ze=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]),Ne=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]),Oe=g.useCallback((()=>{pe.scroller.disablePanEventsTracking(),oe(!0)}),[]),Te=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,T[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,T[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,T[e.locationString]):e.text}))),dataItemKey:"id",textField:"text",value:H?G:null,allowCustom:!0,onChange:Ze,placeholder:A.toLanguageString(b,T[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:ze}),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,T[h]),icon:"pointer",svgIcon:p.pointerIcon,disabled:!H,togglable:!0,selected:ee&&H,onClick:Oe}),g.createElement(a.Button,{className:"k-group-end",fillMode:"flat",themeColor:"base",title:A.toLanguageString(y,T[y]),icon:"hand",svgIcon:p.handIcon,disabled:!H,togglable:!0,selected:!ee&&H,onClick:Te})),search:g.createElement(a.Button,{className:"k-toolbar-button",fillMode:"flat",themeColor:"base",title:A.toLanguageString(C,T[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,T[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,T[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,T[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:Ne},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,T[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,T[I]),fillMode:"flat",togglable:!0,selected:se,onClick:Ee})))}),g.createElement("span",{className:"k-search-matches"},g.createElement("span",null,le)," ",A.toLanguageString(O,T[O]),g.createElement("span",null,ae)),g.createElement(a.Button,{title:A.toLanguageString(P,T[P]),fillMode:"flat",icon:"arrow-up",svgIcon:p.arrowUpIcon,disabled:0===ae,onClick:xe}),g.createElement(a.Button,{title:A.toLanguageString(z,T[z]),fillMode:"flat",icon:"arrow-down",svgIcon:p.arrowDownIcon,disabled:0===ae,onClick:Se}),g.createElement(a.Button,{title:A.toLanguageString(x,T[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}));
|
|
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,m){"use strict";function p(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=p(t);const f=Object.freeze({name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:1673300081,version:"12.3.0-develop.5",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"}),v="pdfviewer.zoomIn",k="pdfviewer.zoomOut",b="pdfviewer.zoomLevel",h="pdfviewer.enableSelection",y="pdfviewer.enablePanning",C="pdfviewer.search",w="pdfviewer.open",E="pdfviewer.download",S="pdfviewer.print",x="pdfviewer.close",P="pdfviewer.matchCase",I="pdfviewer.prevMatch",z="pdfviewer.nextMatch",N="pdfviewer.actualWidth",L="pdfviewer.fitToWidth",Z="pdfviewer.fitToPage",R="pdfviewer.popupBlocked",T="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",[P]:"Match case",[I]:"Previous match",[z]:"Next match",[N]:"Actual width",[L]:"Fit to width",[Z]:"Fit to page",[R]:"Popup is blocked."},B=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],D={minZoom:.5,maxZoom:4,tools:[...B],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:N},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:L},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:Z},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:o.DEFAULT_ZOOM_LEVEL},M=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let 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"}),p=u.getLicenseMessage(f),{zoom:N,zoomLevels:L=D.zoomLevels,defaultZoom:Z=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(Z),_=void 0!==N?N: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(""),me=g.useMemo((()=>({})),[]);me.currentZoom=_,me.props=e;const pe=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 me.pages},get document(){return me.document}})),[]),g.useImperativeHandle(t,(()=>ge.current));const ve=g.useCallback((()=>{if(me.props.onLoad){const e={target:ge.current};me.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;me.scroller&&me.scroller.destroy(),me.scroller=new o.Scroller(null==(e=U.current)?void 0:e.parentNode,{filter:".k-page",events:{}}),me.scroller.disablePanEventsTracking()}),[]),he=g.useCallback((e=>{const t=Array.from(e.querySelectorAll(".k-text-layer"));me.search=new o.SearchService({textContainers:t||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})}),[]);me.done=g.useCallback((({pdfPages:e,pdfDoc:t,zoom:r})=>{me.document=t,me.pages=e,me.zoom=r,be(),Q(!1),$(!0),ve(),U.current&&o.scrollToPage(U.current,0)}),[]),me.error=g.useCallback((o=>{if(me.document=null,me.pages=[],Q(!1),$(!1),e.onError){const t="string"==typeof o?{message:o}:o,r={error:null!=t?t:A.toLanguageString(R,O[R]),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:me.currentZoom,done:me.done,error:me.error}),pe(me.currentZoom)):(me.document=null,me.pages=[],$(!1),Q(!1),o.removeChildren(U.current)))}),[e.url,e.data,e.arrayBuffer]);const ye=g.useCallback(((e,t,r)=>{U.current&&fe.current&&(Q(!0),o.removeChildren(U.current),o.reloadDocument({pdfDoc:e,zoom:t,dom:U.current,done:e=>{me.pages=e,me.zoom=t,Q(!1),U.current&&r>0&&o.scrollToPage(U.current,r)},error:me.error}))}),[me]);g.useEffect((()=>{pe(_),U.current&&me.document&&_!==me.zoom&&ye(me.document,_,X)}),[_,me.document,me.zoom,ye,pe,X]),g.useEffect((()=>()=>{me.scroller&&me.scroller.destroy(),me.search&&me.search.destroy(),me.document=null,me.pages=[]}),[]);const Ce=g.useCallback((()=>{re(!0),he(U.current)}),[]),we=g.useCallback((e=>{const o=e.value,t=me.search.search({text:o,matchCase:se});ce(t.length?1:0),ne(t.length),de(o)}),[se]),Ee=g.useCallback((()=>{const e=me.search.search({text:ue,matchCase:!se});ce(e.length?1:0),ne(e.length),ie(!se)}),[se,ue]),Se=g.useCallback((()=>{o.goToNextSearchMatch(me),ce(le+1>ae?1:le+1)}),[le,ae]),xe=g.useCallback((()=>{o.goToPreviousSearchMatch(me),ce(le-1<1?ae:le-1)}),[le,ae]),Pe=g.useCallback((()=>{me.search.destroy(),ce(0),ne(0),ie(!1),de(""),re(!1)}),[]),Ie=g.useCallback((e=>{"Enter"===e.key?(e.preventDefault(),o.goToNextSearchMatch(me),ce(le+1>ae?1:le+1)):"Escape"===e.key&&Pe()}),[le,ae]),ze=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]),Ne=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(me.currentZoom+j,q);if(t!==me.currentZoom&&me.document&&(W(t),e.onZoom)){const r={zoom:t,target:ge.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[me.currentZoom,me.document,j,q,e.onZoom]),Ze=g.useCallback((o=>{const t=Math.max(me.currentZoom-j,B);if(t!==me.currentZoom&&me.document&&(W(t),e.onZoom)){const r={zoom:t,target:ge.current,syntheticEvent:o};e.onZoom.call(void 0,r)}}),[me.currentZoom,me.document,j,B,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,me.currentZoom,U.current):1;if(a=Math.round(100*a)/100,me.currentZoom!==a&&me.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((()=>{me.scroller.disablePanEventsTracking(),oe(!0)}),[]),Oe=g.useCallback((()=>{me.scroller.enablePanEventsTracking(),oe(!1)}),[]),Be=g.useCallback((()=>{o.download({pdf:me.document,error:me.error},e.saveFileName,e.saveOptions,ke)}),[e.url,e.data,e.arrayBuffer,e.saveFileName,e.saveOptions,ke]),De=g.useCallback((()=>{Q(!0);o.print(me.pages,(()=>{Q(!1)}),(e=>{Q(!1),me.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===me.props.zoom?Z:me.props.zoom;o.loadPDF({arrayBuffer:e,dom:U.current,zoom:t,done:me.done,error:me.error}),W(t)}}))}),[Z]),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:Ze,icon:"zoom-out",svgIcon:m.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:m.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:Re,placeholder:A.toLanguageString(b,O[b])}),Ae={pager:g.createElement(l.Pager,{disabled:!H,previousNext:!0,type:"input",skip:X,take:1,total:me.pages?me.pages.length:0,info:!1,onPageChange:ze}),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:m.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:m.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:m.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:m.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:m.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:m.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:Ne},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: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:m.convertLowercaseIcon,title:A.toLanguageString(P,O[P]),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(I,O[I]),fillMode:"flat",icon:"arrow-up",svgIcon:m.arrowUpIcon,disabled:0===ae,onClick:xe}),g.createElement(a.Button,{title:A.toLanguageString(z,O[z]),fillMode:"flat",icon:"arrow-down",svgIcon:m.arrowDownIcon,disabled:0===ae,onClick:Se}),g.createElement(a.Button,{title:A.toLanguageString(x,O[x]),fillMode:"flat",icon:"x",svgIcon:m.xIcon,onClick:Pe})),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:p}))}));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=Object.freeze({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=Object.freeze({name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1762333178,version:"12.3.0-develop.5",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 = Object.freeze({
|
|
|
10
10
|
productName: "KendoReact",
|
|
11
11
|
productCode: "KENDOUIREACT",
|
|
12
12
|
productCodes: ["KENDOUIREACT"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "12.3.0-develop.
|
|
13
|
+
publishDate: 1762333178,
|
|
14
|
+
version: "12.3.0-develop.5",
|
|
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": "12.3.0-develop.
|
|
3
|
+
"version": "12.3.0-develop.5",
|
|
4
4
|
"description": "KendoReact PDFViewer package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-file-saver": "^1.1.1",
|
|
29
29
|
"@progress/kendo-licensing": "^1.7.0",
|
|
30
|
-
"@progress/kendo-react-buttons": "12.3.0-develop.
|
|
31
|
-
"@progress/kendo-react-common": "12.3.0-develop.
|
|
32
|
-
"@progress/kendo-react-data-tools": "12.3.0-develop.
|
|
33
|
-
"@progress/kendo-react-dropdowns": "12.3.0-develop.
|
|
34
|
-
"@progress/kendo-react-indicators": "12.3.0-develop.
|
|
35
|
-
"@progress/kendo-react-inputs": "12.3.0-develop.
|
|
36
|
-
"@progress/kendo-react-intl": "12.3.0-develop.
|
|
37
|
-
"@progress/kendo-react-upload": "12.3.0-develop.
|
|
30
|
+
"@progress/kendo-react-buttons": "12.3.0-develop.5",
|
|
31
|
+
"@progress/kendo-react-common": "12.3.0-develop.5",
|
|
32
|
+
"@progress/kendo-react-data-tools": "12.3.0-develop.5",
|
|
33
|
+
"@progress/kendo-react-dropdowns": "12.3.0-develop.5",
|
|
34
|
+
"@progress/kendo-react-indicators": "12.3.0-develop.5",
|
|
35
|
+
"@progress/kendo-react-inputs": "12.3.0-develop.5",
|
|
36
|
+
"@progress/kendo-react-intl": "12.3.0-develop.5",
|
|
37
|
+
"@progress/kendo-react-upload": "12.3.0-develop.5",
|
|
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": 1762333178,
|
|
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
|
},
|