@progress/kendo-react-pdf-viewer 7.0.3-develop.4 → 7.0.3-develop.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -8,4 +8,4 @@ This is commercial software. To use it, you need to agree to the [**End User Lic
8
8
 
9
9
  All available KendoReact commercial licenses may be obtained at the [KendoReact website](https://www.telerik.com/kendo-react-ui/pricing).
10
10
 
11
- *Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.*
11
+ *Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.*
package/NOTICE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Progress KendoReact 2023
1
+ Progress KendoReact 2024
2
2
 
3
3
  Copyright © 2018-2023 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
4
4
 
package/PDFViewer.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  import * as React from 'react';
package/README.md CHANGED
@@ -49,6 +49,6 @@ High-level component overview pages
49
49
 
50
50
  * [React PDFViewer Component](https://www.telerik.com/kendo-react-ui/pdfviewer)
51
51
 
52
- *Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.*
52
+ *Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.*
53
53
 
54
54
  *Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries.*
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
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.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<"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,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"})});
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  export * from './index';
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  export { PDFViewer, type PDFViewerProps, type PDFViewerHandle, type PDFViewerTool, type LoadEvent, type ErrorEvent, type DownloadEvent, type ZoomEvent, type PageEvent } from './PDFViewer';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
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;
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  "use client";
@@ -21,7 +21,7 @@ const fe = {
21
21
  name: "@progress/kendo-react-pdf-viewer",
22
22
  productName: "KendoReact",
23
23
  productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
24
- publishDate: 1703228014,
24
+ publishDate: 1704296212,
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
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 = {
package/messages.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2023 Progress Software Corporation. All rights reserved.
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
5
  import { PackageMetadata } from '@progress/kendo-licensing';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-pdf-viewer",
3
- "version": "7.0.3-develop.4",
3
+ "version": "7.0.3-develop.5",
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.6",
28
- "@progress/kendo-react-buttons": "7.0.3-develop.4",
29
- "@progress/kendo-react-common": "7.0.3-develop.4",
30
- "@progress/kendo-react-data-tools": "7.0.3-develop.4",
31
- "@progress/kendo-react-dropdowns": "7.0.3-develop.4",
32
- "@progress/kendo-react-indicators": "7.0.3-develop.4",
33
- "@progress/kendo-react-inputs": "7.0.3-develop.4",
34
- "@progress/kendo-react-intl": "7.0.3-develop.4",
35
- "@progress/kendo-react-upload": "7.0.3-develop.4",
28
+ "@progress/kendo-react-buttons": "7.0.3-develop.5",
29
+ "@progress/kendo-react-common": "7.0.3-develop.5",
30
+ "@progress/kendo-react-data-tools": "7.0.3-develop.5",
31
+ "@progress/kendo-react-dropdowns": "7.0.3-develop.5",
32
+ "@progress/kendo-react-indicators": "7.0.3-develop.5",
33
+ "@progress/kendo-react-inputs": "7.0.3-develop.5",
34
+ "@progress/kendo-react-intl": "7.0.3-develop.5",
35
+ "@progress/kendo-react-upload": "7.0.3-develop.5",
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"