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