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