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