@progress/kendo-react-pdf-viewer 7.2.4-develop.3 → 7.3.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -1,5 +1,257 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- export * from './index';
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { currentPage } from '@progress/kendo-pdfviewer-common';
9
+ import * as React_2 from 'react';
10
+ import { SaveOptions } from '@progress/kendo-file-saver';
11
+ import { ToolbarProps } from '@progress/kendo-react-buttons';
12
+ import { TypedArray } from '@progress/kendo-pdfviewer-common';
13
+
14
+ export { currentPage }
15
+
16
+ /**
17
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) DownloadEvent object.
18
+ */
19
+ export declare interface DownloadEvent extends PDFViewerEvent {
20
+ /**
21
+ * The Blob object.
22
+ */
23
+ blob: Blob;
24
+ /**
25
+ * The name which will be used for saving the file.
26
+ */
27
+ fileName: string;
28
+ /**
29
+ * The options which will be used for saving the file.
30
+ */
31
+ saveOptions: SaveOptions;
32
+ }
33
+
34
+ /**
35
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) ErrorEvent object.
36
+ */
37
+ declare interface ErrorEvent_2 extends PDFViewerEvent {
38
+ /**
39
+ * The raised error.
40
+ */
41
+ error: Error | {
42
+ message: string;
43
+ };
44
+ }
45
+ export { ErrorEvent_2 as ErrorEvent }
46
+
47
+ /**
48
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) LoadEvent object.
49
+ */
50
+ export declare interface LoadEvent extends PDFViewerEvent {
51
+ }
52
+
53
+ /**
54
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) PageEvent object.
55
+ */
56
+ export declare interface PageEvent extends PDFViewerEvent {
57
+ /**
58
+ * The page number.
59
+ */
60
+ page: number;
61
+ /**
62
+ * A React `SyntheticEvent`.
63
+ */
64
+ syntheticEvent: React_2.SyntheticEvent<any>;
65
+ }
66
+
67
+ /**
68
+ * Represents the [KendoReact PDFViewer component]({% slug api_pdf-viewer_pdfviewerprops %}).
69
+ *
70
+ * @example
71
+ * ```jsx
72
+ * function App() {
73
+ * return <PDFViewer url="sample.pdf" />;
74
+ * }
75
+ * ReactDOM.render(<App />, document.querySelector('my-app'));
76
+ * ```
77
+ */
78
+ export declare const PDFViewer: React_2.ForwardRefExoticComponent<PDFViewerProps & React_2.RefAttributes<PDFViewerHandle | null>>;
79
+
80
+ declare interface PDFViewerEvent {
81
+ /**
82
+ * The event target object.
83
+ */
84
+ target: PDFViewerHandle;
85
+ }
86
+
87
+ /**
88
+ * Represents the object which is passed to the [`ref`](https://reactjs.org/docs/refs-and-the-dom.html)
89
+ * callback of the [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) component.
90
+ */
91
+ export declare interface PDFViewerHandle {
92
+ /**
93
+ * The root DOM element of the PDFViewer component.
94
+ */
95
+ element: HTMLDivElement | null;
96
+ /**
97
+ * The props of the PDFViewer component.
98
+ */
99
+ props: PDFViewerProps;
100
+ /**
101
+ * The `PDF.js` document loaded in the PDFViewer component.
102
+ */
103
+ document: any;
104
+ /**
105
+ * The `PDF.js` pages loaded in the PDFViewer component.
106
+ */
107
+ pages: any[];
108
+ }
109
+
110
+ /**
111
+ * The props of the KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) component.
112
+ */
113
+ export declare interface PDFViewerProps {
114
+ /**
115
+ * Represents the url of the PDF file.
116
+ */
117
+ url?: string;
118
+ /**
119
+ * Represents the data of the PDF file in Base64 format.
120
+ */
121
+ data?: string;
122
+ /**
123
+ * Represents the raw binary data buffer of the PDF file.
124
+ */
125
+ arrayBuffer?: ArrayBuffer;
126
+ /**
127
+ * Represents the data of the PDF file in typed array format.
128
+ */
129
+ typedArray?: TypedArray;
130
+ /**
131
+ * Represents the additional styles which will be added to the PDFViewer component.
132
+ */
133
+ style?: React_2.CSSProperties;
134
+ /**
135
+ * Represents the file name used to save the file when the user clicks the download tool.
136
+ */
137
+ saveFileName?: string;
138
+ /**
139
+ * Represents the options for saving the file when the user clicks the download tool.
140
+ */
141
+ saveOptions?: SaveOptions;
142
+ /**
143
+ * Represents the tools collection rendered in the toolbar.
144
+ *
145
+ * @default - ['pager', 'spacer', 'zoomInOut', 'zoom', 'selection', 'spacer', 'search', 'open', 'download', 'print']
146
+ */
147
+ tools?: PDFViewerTool[];
148
+ /**
149
+ * Represents the zoom levels populated in the ComboBox component.
150
+ */
151
+ zoomLevels?: {
152
+ id: number;
153
+ priority: number;
154
+ value: number;
155
+ text: string;
156
+ type: string;
157
+ locationString?: string;
158
+ }[];
159
+ /**
160
+ * Represents the zoom value of the document.
161
+ */
162
+ zoom?: number;
163
+ /**
164
+ * Represents the default zoom value.
165
+ */
166
+ defaultZoom?: number;
167
+ /**
168
+ * Represents the minimum zoom value.
169
+ */
170
+ minZoom?: number;
171
+ /**
172
+ * Represents the maximum zoom value.
173
+ */
174
+ maxZoom?: number;
175
+ /**
176
+ * Represents the zoom rate value.
177
+ */
178
+ zoomRate?: number;
179
+ /**
180
+ * Fires when an error occurs.
181
+ */
182
+ onError?: (event: ErrorEvent_2) => void;
183
+ /**
184
+ * Fires when a PDF document has been loaded.
185
+ */
186
+ onLoad?: (event: LoadEvent) => void;
187
+ /**
188
+ * Fires when the download tool has been clicked. To prevent the download, return `false`.
189
+ */
190
+ onDownload?: (event: DownloadEvent) => boolean | void;
191
+ /**
192
+ * Fires when the zoom has changed.
193
+ */
194
+ onZoom?: (event: ZoomEvent) => void;
195
+ /**
196
+ * Fires when the page has changed.
197
+ */
198
+ onPageChange?: (event: PageEvent) => void;
199
+ /**
200
+ * Fires when the toolbar component is about to be rendered. Use it to override the default appearance of the toolbar.
201
+ */
202
+ onRenderToolbar?: (defaultRendering: React_2.ReactElement<ToolbarProps>) => React_2.ReactNode;
203
+ /**
204
+ * Fires when the content component is about to be rendered. Use it to override the default appearance of the content.
205
+ */
206
+ onRenderContent?: (defaultRendering: React_2.ReactElement<HTMLDivElement>) => React_2.ReactNode;
207
+ /**
208
+ * Fires when the loading indication component is about to be rendered. Use it to override the default appearance of the loading.
209
+ */
210
+ onRenderLoader?: (defaultRendering: React_2.ReactElement<HTMLDivElement> | null) => React_2.ReactNode;
211
+ }
212
+
213
+ export declare type PDFViewerTool = 'pager' | 'spacer' | 'zoomInOut' | 'zoom' | 'selection' | 'search' | 'open' | 'download' | 'print';
214
+
215
+ /**
216
+ * Scrolls the PDFViewer document to the passed page number.
217
+ *
218
+ * @param rootElement The root HTML element of the PDFViewer component.
219
+ * @param pageNumber The page number.
220
+ *
221
+ * @example
222
+ * ```jsx
223
+ * function App() {
224
+ * const pdfRef = React.useRef(null);
225
+ * const handleClick = () => {
226
+ * scrollToPage(pdfRef.current.element, 3);
227
+ * };
228
+ * return (
229
+ * <div>
230
+ * <Button onClick={handleClick} >
231
+ * Scroll to Page 3
232
+ * </Button>
233
+ * <PDFViewer
234
+ * ref={pdfRef}
235
+ * />
236
+ * </div>
237
+ * )
238
+ * }
239
+ * ```
240
+ */
241
+ export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
242
+
243
+ /**
244
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) ZoomEvent object.
245
+ */
246
+ export declare interface ZoomEvent extends PDFViewerEvent {
247
+ /**
248
+ * The zoom value.
249
+ */
250
+ zoom: number;
251
+ /**
252
+ * A React `SyntheticEvent`.
253
+ */
254
+ syntheticEvent: React_2.SyntheticEvent<any>;
255
+ }
256
+
257
+ export { }
package/index.d.ts CHANGED
@@ -1,33 +1,257 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- export { PDFViewer, type PDFViewerProps, type PDFViewerHandle, type PDFViewerTool, type LoadEvent, type ErrorEvent, type DownloadEvent, type ZoomEvent, type PageEvent } from './PDFViewer';
6
- export { currentPage } from '@progress/kendo-pdfviewer-common';
7
1
  /**
8
- * Scrolls the PDFViewer document to the passed page number.
9
- *
10
- * @param rootElement The root HTML element of the PDFViewer component.
11
- * @param pageNumber The page number.
12
- *
13
- * @example
14
- * ```jsx
15
- * function App() {
16
- * const pdfRef = React.useRef(null);
17
- * const handleClick = () => {
18
- * scrollToPage(pdfRef.current.element, 3);
19
- * };
20
- * return (
21
- * <div>
22
- * <Button onClick={handleClick} >
23
- * Scroll to Page 3
24
- * </Button>
25
- * <PDFViewer
26
- * ref={pdfRef}
27
- * />
28
- * </div>
29
- * )
30
- * }
31
- * ```
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
32
7
  */
33
- export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
8
+ import { currentPage } from '@progress/kendo-pdfviewer-common';
9
+ import * as React_2 from 'react';
10
+ import { SaveOptions } from '@progress/kendo-file-saver';
11
+ import { ToolbarProps } from '@progress/kendo-react-buttons';
12
+ import { TypedArray } from '@progress/kendo-pdfviewer-common';
13
+
14
+ export { currentPage }
15
+
16
+ /**
17
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) DownloadEvent object.
18
+ */
19
+ export declare interface DownloadEvent extends PDFViewerEvent {
20
+ /**
21
+ * The Blob object.
22
+ */
23
+ blob: Blob;
24
+ /**
25
+ * The name which will be used for saving the file.
26
+ */
27
+ fileName: string;
28
+ /**
29
+ * The options which will be used for saving the file.
30
+ */
31
+ saveOptions: SaveOptions;
32
+ }
33
+
34
+ /**
35
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) ErrorEvent object.
36
+ */
37
+ declare interface ErrorEvent_2 extends PDFViewerEvent {
38
+ /**
39
+ * The raised error.
40
+ */
41
+ error: Error | {
42
+ message: string;
43
+ };
44
+ }
45
+ export { ErrorEvent_2 as ErrorEvent }
46
+
47
+ /**
48
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) LoadEvent object.
49
+ */
50
+ export declare interface LoadEvent extends PDFViewerEvent {
51
+ }
52
+
53
+ /**
54
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) PageEvent object.
55
+ */
56
+ export declare interface PageEvent extends PDFViewerEvent {
57
+ /**
58
+ * The page number.
59
+ */
60
+ page: number;
61
+ /**
62
+ * A React `SyntheticEvent`.
63
+ */
64
+ syntheticEvent: React_2.SyntheticEvent<any>;
65
+ }
66
+
67
+ /**
68
+ * Represents the [KendoReact PDFViewer component]({% slug api_pdf-viewer_pdfviewerprops %}).
69
+ *
70
+ * @example
71
+ * ```jsx
72
+ * function App() {
73
+ * return <PDFViewer url="sample.pdf" />;
74
+ * }
75
+ * ReactDOM.render(<App />, document.querySelector('my-app'));
76
+ * ```
77
+ */
78
+ export declare const PDFViewer: React_2.ForwardRefExoticComponent<PDFViewerProps & React_2.RefAttributes<PDFViewerHandle | null>>;
79
+
80
+ declare interface PDFViewerEvent {
81
+ /**
82
+ * The event target object.
83
+ */
84
+ target: PDFViewerHandle;
85
+ }
86
+
87
+ /**
88
+ * Represents the object which is passed to the [`ref`](https://reactjs.org/docs/refs-and-the-dom.html)
89
+ * callback of the [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) component.
90
+ */
91
+ export declare interface PDFViewerHandle {
92
+ /**
93
+ * The root DOM element of the PDFViewer component.
94
+ */
95
+ element: HTMLDivElement | null;
96
+ /**
97
+ * The props of the PDFViewer component.
98
+ */
99
+ props: PDFViewerProps;
100
+ /**
101
+ * The `PDF.js` document loaded in the PDFViewer component.
102
+ */
103
+ document: any;
104
+ /**
105
+ * The `PDF.js` pages loaded in the PDFViewer component.
106
+ */
107
+ pages: any[];
108
+ }
109
+
110
+ /**
111
+ * The props of the KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) component.
112
+ */
113
+ export declare interface PDFViewerProps {
114
+ /**
115
+ * Represents the url of the PDF file.
116
+ */
117
+ url?: string;
118
+ /**
119
+ * Represents the data of the PDF file in Base64 format.
120
+ */
121
+ data?: string;
122
+ /**
123
+ * Represents the raw binary data buffer of the PDF file.
124
+ */
125
+ arrayBuffer?: ArrayBuffer;
126
+ /**
127
+ * Represents the data of the PDF file in typed array format.
128
+ */
129
+ typedArray?: TypedArray;
130
+ /**
131
+ * Represents the additional styles which will be added to the PDFViewer component.
132
+ */
133
+ style?: React_2.CSSProperties;
134
+ /**
135
+ * Represents the file name used to save the file when the user clicks the download tool.
136
+ */
137
+ saveFileName?: string;
138
+ /**
139
+ * Represents the options for saving the file when the user clicks the download tool.
140
+ */
141
+ saveOptions?: SaveOptions;
142
+ /**
143
+ * Represents the tools collection rendered in the toolbar.
144
+ *
145
+ * @default - ['pager', 'spacer', 'zoomInOut', 'zoom', 'selection', 'spacer', 'search', 'open', 'download', 'print']
146
+ */
147
+ tools?: PDFViewerTool[];
148
+ /**
149
+ * Represents the zoom levels populated in the ComboBox component.
150
+ */
151
+ zoomLevels?: {
152
+ id: number;
153
+ priority: number;
154
+ value: number;
155
+ text: string;
156
+ type: string;
157
+ locationString?: string;
158
+ }[];
159
+ /**
160
+ * Represents the zoom value of the document.
161
+ */
162
+ zoom?: number;
163
+ /**
164
+ * Represents the default zoom value.
165
+ */
166
+ defaultZoom?: number;
167
+ /**
168
+ * Represents the minimum zoom value.
169
+ */
170
+ minZoom?: number;
171
+ /**
172
+ * Represents the maximum zoom value.
173
+ */
174
+ maxZoom?: number;
175
+ /**
176
+ * Represents the zoom rate value.
177
+ */
178
+ zoomRate?: number;
179
+ /**
180
+ * Fires when an error occurs.
181
+ */
182
+ onError?: (event: ErrorEvent_2) => void;
183
+ /**
184
+ * Fires when a PDF document has been loaded.
185
+ */
186
+ onLoad?: (event: LoadEvent) => void;
187
+ /**
188
+ * Fires when the download tool has been clicked. To prevent the download, return `false`.
189
+ */
190
+ onDownload?: (event: DownloadEvent) => boolean | void;
191
+ /**
192
+ * Fires when the zoom has changed.
193
+ */
194
+ onZoom?: (event: ZoomEvent) => void;
195
+ /**
196
+ * Fires when the page has changed.
197
+ */
198
+ onPageChange?: (event: PageEvent) => void;
199
+ /**
200
+ * Fires when the toolbar component is about to be rendered. Use it to override the default appearance of the toolbar.
201
+ */
202
+ onRenderToolbar?: (defaultRendering: React_2.ReactElement<ToolbarProps>) => React_2.ReactNode;
203
+ /**
204
+ * Fires when the content component is about to be rendered. Use it to override the default appearance of the content.
205
+ */
206
+ onRenderContent?: (defaultRendering: React_2.ReactElement<HTMLDivElement>) => React_2.ReactNode;
207
+ /**
208
+ * Fires when the loading indication component is about to be rendered. Use it to override the default appearance of the loading.
209
+ */
210
+ onRenderLoader?: (defaultRendering: React_2.ReactElement<HTMLDivElement> | null) => React_2.ReactNode;
211
+ }
212
+
213
+ export declare type PDFViewerTool = 'pager' | 'spacer' | 'zoomInOut' | 'zoom' | 'selection' | 'search' | 'open' | 'download' | 'print';
214
+
215
+ /**
216
+ * Scrolls the PDFViewer document to the passed page number.
217
+ *
218
+ * @param rootElement The root HTML element of the PDFViewer component.
219
+ * @param pageNumber The page number.
220
+ *
221
+ * @example
222
+ * ```jsx
223
+ * function App() {
224
+ * const pdfRef = React.useRef(null);
225
+ * const handleClick = () => {
226
+ * scrollToPage(pdfRef.current.element, 3);
227
+ * };
228
+ * return (
229
+ * <div>
230
+ * <Button onClick={handleClick} >
231
+ * Scroll to Page 3
232
+ * </Button>
233
+ * <PDFViewer
234
+ * ref={pdfRef}
235
+ * />
236
+ * </div>
237
+ * )
238
+ * }
239
+ * ```
240
+ */
241
+ export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
242
+
243
+ /**
244
+ * The KendoReact [PDFViewer]({% slug api_pdf-viewer_pdfviewer %}) ZoomEvent object.
245
+ */
246
+ export declare interface ZoomEvent extends PDFViewerEvent {
247
+ /**
248
+ * The zoom value.
249
+ */
250
+ zoom: number;
251
+ /**
252
+ * A React `SyntheticEvent`.
253
+ */
254
+ syntheticEvent: React_2.SyntheticEvent<any>;
255
+ }
256
+
257
+ export { }
package/index.js CHANGED
@@ -1,5 +1,8 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@progress/kendo-pdfviewer-common"),tt=require("react"),c=require("prop-types"),d=require("@progress/kendo-react-buttons"),fe=require("@progress/kendo-react-inputs"),ot=require("@progress/kendo-react-data-tools"),nt=require("@progress/kendo-react-upload"),at=require("@progress/kendo-react-dropdowns"),rt=require("@progress/kendo-react-indicators"),R=require("@progress/kendo-react-common"),ct=require("@progress/kendo-react-intl"),g=require("@progress/kendo-svg-icons");require("pdfjs-dist/build/pdf.worker.entry.js");function lt(n){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const w in n)if(w!=="default"){const x=Object.getOwnPropertyDescriptor(n,w);Object.defineProperty(y,w,x.get?x:{enumerable:!0,get:()=>n[w]})}}return y.default=n,Object.freeze(y)}const e=lt(tt),ve={name:"@progress/kendo-react-pdf-viewer",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:1673300081,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"},U="pdfviewer.zoomIn",K="pdfviewer.zoomOut",W="pdfviewer.zoomLevel",_="pdfviewer.enableSelection",V="pdfviewer.enablePanning",Z="pdfviewer.search",H="pdfviewer.open",G="pdfviewer.download",$="pdfviewer.print",J="pdfviewer.close",Q="pdfviewer.matchCase",X="pdfviewer.prevMatch",Y="pdfviewer.nextMatch",ke="pdfviewer.actualWidth",be="pdfviewer.fitToWidth",pe="pdfviewer.fitToPage",ee="pdfviewer.popupBlocked",u={[U]:"Zoom in",[K]:"Zoom out",[W]:"Choose zoom level",[_]:"Enable selection",[V]:"Enable panning",[Z]:"Search",[H]:"Open",[G]:"Download",[$]:"Print",[J]:"Close",[Q]:"Match case",[X]:"Previous match",[Y]:"Next match",[ke]:"Actual width",[be]:"Fit to width",[pe]:"Fit to page",[ee]:"Popup is blocked."},ye=["pager","spacer","zoomInOut","zoom","selection","spacer","search","open","download","print"],C={minZoom:.5,maxZoom:4,tools:[...ye],zoomRate:.25,zoomLevels:[{id:1,priority:1,value:1,text:"Actual width",type:"ActualWidth",locationString:ke},{id:2,priority:2,value:1,text:"Fit to width",type:"FitToWidth",locationString:be},{id:3,priority:3,value:1,text:"Fit to page",type:"FitToPage",locationString:pe},{id:4,priority:4,value:.5,text:"50%",type:""},{id:5,priority:5,value:.75,text:"75%",type:""},{id:6,priority:100,value:1,text:"100%",type:""},{id:7,priority:7,value:1.25,text:"125%",type:""},{id:8,priority:8,value:1.5,text:"150%",type:""},{id:9,priority:9,value:2,text:"200%",type:""},{id:10,priority:10,value:3,text:"300%",type:""},{id:11,priority:11,value:4,text:"400%",type:""}],defaultZoom:s.DEFAULT_ZOOM_LEVEL},st=[".k-toolbar > button",".k-toolbar .k-combobox > input",".k-toolbar .k-button-group > button",".k-toolbar .k-pager > a",".k-toolbar .k-pager input"];let he=0;function it(){return he++,he}const ut=(n,y)=>n.priority>y.priority?-1:n.priority<y.priority?1:0,M=e.forwardRef((n,y)=>{R.validatePackage(ve);const w=R.shouldShowValidationUI(ve),{zoom:x,zoomLevels:te=C.zoomLevels,defaultZoom:O=C.defaultZoom,minZoom:D=C.minZoom,maxZoom:B=C.maxZoom,zoomRate:T=C.zoomRate}=n,i=ct.useLocalization(),l=e.useRef(null),[Ce,z]=e.useState(O),f=x!==void 0?x:Ce,P=te.slice().sort(ut).find(o=>o.value===f)||{text:f*100+"%",value:f,id:f,locationString:""};P.locationString&&(P.text=i.toLanguageString(P.locationString,u[P.locationString]));const[v,F]=e.useState(!1),[we,b]=e.useState(!0),[L,oe]=e.useState(0),[I,ne]=e.useState(!1),[Ee,ae]=e.useState(!1),[p,q]=e.useState(0),[h,E]=e.useState(0),[S,re]=e.useState(!1),[j,ce]=e.useState(""),t=e.useMemo(()=>({}),[]);t.currentZoom=f,t.props=n;const le=e.useCallback(o=>{l.current&&l.current.style.setProperty("--scale-factor",String(o))},[]),k=e.useRef(null),N=e.useRef(null);e.useImperativeHandle(k,()=>({get element(){return N.current},props:n,get pages(){return t.pages},get document(){return t.document}}),[]),e.useImperativeHandle(y,()=>k.current);const Se=e.useCallback(()=>{if(t.props.onLoad){const o={target:k.current};t.props.onLoad.call(void 0,o)}},[]),se=e.useCallback((o,a,r)=>{if(n.onDownload){const m={target:k.current,blob:o,fileName:a,saveOptions:r};return n.onDownload.call(void 0,m)===!1}return!1},[n.onDownload]),xe=e.useCallback(()=>{var o;t.scroller&&t.scroller.destroy(),t.scroller=new s.Scroller((o=l.current)==null?void 0:o.parentNode,{filter:".k-page",events:{}}),t.scroller.enablePanEventsTracking()},[]),Pe=e.useCallback(o=>{const a=Array.from(o.querySelectorAll(".k-text-layer"));t.search=new s.SearchService({textContainers:a||[],highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char"})},[]);t.done=e.useCallback(({pdfPages:o,pdfDoc:a,zoom:r})=>{t.document=a,t.pages=o,t.zoom=r,xe(),b(!1),F(!0),Se(),l.current&&s.scrollToPage(l.current,0)},[]),t.error=e.useCallback(o=>{if(t.document=null,t.pages=[],b(!1),F(!1),n.onError){const a={error:typeof o=="string"?{message:o}:o,target:k.current};n.onError.call(void 0,a)}},[n.onError]),e.useEffect(()=>{l.current&&(n.url||n.data||n.arrayBuffer?(b(!0),s.removeChildren(l.current),s.loadPDF({url:n.url,data:n.data,arrayBuffer:n.arrayBuffer,dom:l.current,zoom:t.currentZoom,done:t.done,error:t.error}),le(t.currentZoom)):(t.document=null,t.pages=[],F(!1),b(!1),s.removeChildren(l.current)))},[n.url,n.data,n.arrayBuffer]);const ie=e.useCallback((o,a)=>{l.current&&(b(!0),s.removeChildren(l.current),s.reloadDocument({pdfDoc:o,zoom:a,dom:l.current,done:r=>{t.pages=r,t.zoom=a,b(!1)},error:t.error}))},[]);e.useEffect(()=>{le(f),l.current&&t.document&&f!==t.zoom&&ie(t.document,f)},[f,ie]),e.useEffect(()=>()=>{t.scroller&&t.scroller.destroy(),t.search&&t.search.destroy(),t.document=null,t.pages=[]},[]);const Ze=e.useCallback(()=>{ae(!0),Pe(l.current)},[]),Te=e.useCallback(o=>{const a=o.value,r=t.search.search({text:a,matchCase:S});E(r.length?1:0),q(r.length),ce(a)},[S]),ze=e.useCallback(()=>{const o=t.search.search({text:j,matchCase:!S});E(o.length?1:0),q(o.length),re(!S)},[S,j]),Le=e.useCallback(()=>{s.goToNextSearchMatch(t),E(h+1>p?1:h+1)},[h,p]),Ie=e.useCallback(()=>{s.goToPreviousSearchMatch(t),E(h-1<1?p:h-1)},[h,p]),ue=e.useCallback(()=>{t.search.destroy(),E(0),q(0),re(!1),ce(""),ae(!1)},[]),Ne=e.useCallback(o=>{o.key==="Enter"?(o.preventDefault(),s.goToNextSearchMatch(t),E(h+1>p?1:h+1)):o.key==="Escape"&&ue()},[h,p]),Re=e.useCallback(o=>{if(l.current){const a=o.skip;s.scrollToPage(l.current,a);const r={page:a+1,target:k.current,syntheticEvent:o.syntheticEvent};n.onPageChange&&n.onPageChange.call(void 0,r)}oe(o.skip)},[L,n.onPageChange]),Me=e.useCallback(o=>{if(N.current){const a=s.currentPage(N.current);if(a!==L){oe(a);const r={page:a+1,target:k.current,syntheticEvent:o};n.onPageChange&&n.onPageChange.call(void 0,r)}}},[L,n.onPageChange]),Oe=e.useCallback(o=>{const a=Math.min(t.currentZoom+T,B);if(a!==t.currentZoom&&t.document&&(z(a),n.onZoom)){const r={zoom:a,target:k.current,syntheticEvent:o};n.onZoom.call(void 0,r)}},[T,B,n.onZoom]),De=e.useCallback(o=>{const a=Math.max(t.currentZoom-T,D);if(a!==t.currentZoom&&t.document&&(z(a),n.onZoom)){const r={zoom:a,target:k.current,syntheticEvent:o};n.onZoom.call(void 0,r)}},[T,D,n.onZoom]),Be=e.useCallback(o=>{const a=o.value===null?{text:"100%",value:1,id:100}:{...o.value};if(a.value===void 0){const m=parseFloat(a.text);typeof m=="number"&&!Number.isNaN(m)?a.value=m/100:a.value=1}let r=a?s.calculateZoomLevel(a.value,a.type,t.currentZoom,l.current):1;if(r=Math.round(r*100)/100,t.currentZoom!==r&&t.document&&(z(r),n.onZoom)){const m={zoom:r,target:k.current,syntheticEvent:o.syntheticEvent};n.onZoom.call(void 0,m)}},[n.onZoom]),Fe=e.useCallback(()=>{t.scroller.disablePanEventsTracking(),ne(!0)},[]),qe=e.useCallback(()=>{t.scroller.enablePanEventsTracking(),ne(!1)},[]),je=e.useCallback(()=>{s.download({pdf:t.document,error:t.error},n.saveFileName,n.saveOptions,se)},[n.url,n.data,n.arrayBuffer,n.saveFileName,n.saveOptions,se]),Ae=e.useCallback(()=>{b(!0);const o=r=>{t.error(typeof(r?r.message||r:null)=="string"?r.message||r:i.toLanguageString(ee,u[ee]))},a=()=>{b(!1)};s.print(t.pages,a,o)},[]),Ue=e.useCallback(o=>{const a=o.newState;a[0]&&a[0].getRawFile&&a[0].getRawFile().arrayBuffer().then(m=>{if(l.current){b(!0),s.removeChildren(l.current);const A=t.props.zoom===void 0?O:t.props.zoom;s.loadPDF({arrayBuffer:m,dom:l.current,zoom:A,done:t.done,error:t.error}),z(A)}})},[O]),Ke=e.useCallback(o=>{const a=o.target;if(a instanceof Element&&a.parentNode){const r=a.closest(".k-toolbar"),m=r&&r.querySelector(".k-upload input");m&&m.click()}},[]),de=we&&e.createElement("div",{className:"k-loader-container k-loader-container-md k-loader-top"},e.createElement("div",{className:"k-loader-container-overlay k-overlay-light"}),e.createElement("div",{className:"k-loader-container-inner "},e.createElement(rt.Loader,{size:"large"}))),We=e.createElement(d.ButtonGroup,null,e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(K,u[K]),disabled:f<=D||!v,onClick:De,icon:"zoom-out",svgIcon:g.zoomOutIcon}),e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(U,u[U]),disabled:f>=B||!v,onClick:Oe,icon:"zoom-in",svgIcon:g.zoomInIcon})),_e=e.createElement(at.ComboBox,{disabled:!v,data:te.map(o=>({...o,text:o.locationString?i.toLanguageString(o.locationString,u[o.locationString]):o.text})),dataItemKey:"id",textField:"text",value:v?P:null,allowCustom:!0,onChange:Be,placeholder:i.toLanguageString(W,u[W])}),Ve=e.createElement(ot.Pager,{previousNext:!0,type:"input",skip:L,take:1,total:t.pages?t.pages.length:0,info:!1,onPageChange:Re}),He=e.createElement(d.ToolbarSpacer,null),Ge=e.createElement(d.ButtonGroup,null,e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(_,u[_]),icon:"pointer",svgIcon:g.pointerIcon,disabled:!v,togglable:!0,selected:I&&v,onClick:Fe}),e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(V,u[V]),icon:"hand",svgIcon:g.handIcon,disabled:!v,togglable:!0,selected:!I&&v,onClick:qe})),$e=e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(Z,u[Z]),icon:"search",svgIcon:g.searchIcon,disabled:!v,onClick:Ze}),Je=e.createElement(e.Fragment,null,e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(H,u[H]),icon:"folder-open",svgIcon:g.folderOpenIcon,onClick:Ke}),e.createElement("div",{style:{display:"none"}},e.createElement(nt.Upload,{restrictions:{allowedExtensions:[".pdf"]},onAdd:Ue,autoUpload:!1,defaultFiles:[],multiple:!1,accept:".pdf,.PDF",withCredentials:!1}))),Qe=e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString(G,u[G]),icon:"download",svgIcon:g.downloadIcon,disabled:!v,onClick:je}),Xe=e.createElement(d.Button,{className:"k-toolbar-button",title:i.toLanguageString($,u[$]),icon:"print",svgIcon:g.printIcon,disabled:!v,onClick:Ae}),Ye={pager:Ve,spacer:He,zoomInOut:We,zoom:_e,selection:Ge,search:$e,open:Je,download:Qe,print:Xe},et=(n.tools||C.tools).map(o=>({...Ye[o],key:"toobar-tool-"+o+it()})),me=e.createElement(d.Toolbar,{buttons:st},...et),ge=e.createElement("div",{className:R.classNames("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto",{"k-enable-text-select":I,"k-enable-panning":!I}),onScroll:Me},Ee&&e.createElement("div",{className:"k-search-panel k-pos-sticky k-top-center"},e.createElement(fe.TextBox,{value:j,onChange:Te,placeholder:i.toLanguageString(Z,u[Z]),autoFocus:!0,onKeyDown:Ne,suffix:()=>e.createElement(fe.InputSuffix,null,e.createElement(d.Button,{icon:"convert-lowercase",svgIcon:g.convertLowercaseIcon,title:i.toLanguageString(Q,u[Q]),fillMode:"flat",togglable:!0,selected:S,onClick:ze}))}),e.createElement("span",{className:"k-search-matches"},e.createElement("span",null,h)," of ",e.createElement("span",null,p)),e.createElement(d.Button,{title:i.toLanguageString(X,u[X]),fillMode:"flat",icon:"arrow-up",svgIcon:g.arrowUpIcon,disabled:p===0,onClick:Ie}),e.createElement(d.Button,{title:i.toLanguageString(Y,u[Y]),fillMode:"flat",icon:"arrow-down",svgIcon:g.arrowDownIcon,disabled:p===0,onClick:Le}),e.createElement(d.Button,{title:i.toLanguageString(J,u[J]),fillMode:"flat",icon:"x",svgIcon:g.xIcon,onClick:ue})),e.createElement("div",{ref:l,className:"k-pdf-viewer-pages"}));return e.createElement("div",{className:"k-pdf-viewer",style:n.style,ref:N},n.onRenderLoader?n.onRenderLoader.call(void 0,de||null):de,n.onRenderToolbar?n.onRenderToolbar.call(void 0,me):me,n.onRenderContent?n.onRenderContent.call(void 0,ge):ge,w&&e.createElement(R.WatermarkOverlay,null))});M.displayName="KendoReactPDFViewer";M.propTypes={url:c.string,data:c.string,arrayBuffer:c.any,typedArray:c.any,style:c.object,saveFileName:c.string,saveOptions:c.object,tools:c.arrayOf(c.oneOf(ye).isRequired),zoomLevels:c.arrayOf(c.any),zoom:c.number,defaultZoom:c.number,minZoom:c.number,maxZoom:c.number,zoomRate:c.number,onError:c.func,onLoad:c.func,onDownload:c.func,onRenderToolbar:c.func,onRenderContent:c.func,onRenderLoader:c.func,onZoom:c.func};M.defaultProps=C;const dt=s.scrollToPage;Object.defineProperty(exports,"currentPage",{enumerable:!0,get:()=>s.currentPage});exports.PDFViewer=M;exports.scrollToPage=dt;
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@progress/kendo-pdfviewer-common"),r=require("./PDFViewer.js"),o=e.scrollToPage;Object.defineProperty(exports,"currentPage",{enumerable:!0,get:()=>e.currentPage});exports.PDFViewer=r.PDFViewer;exports.scrollToPage=o;