@progress/kendo-react-pdf-viewer 6.1.1 → 7.0.0-develop.2

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.
@@ -1,496 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PDFViewer = void 0;
4
- const React = require("react");
5
- const PropTypes = require("prop-types");
6
- const kendo_react_buttons_1 = require("@progress/kendo-react-buttons");
7
- const kendo_react_inputs_1 = require("@progress/kendo-react-inputs");
8
- const kendo_react_data_tools_1 = require("@progress/kendo-react-data-tools");
9
- const kendo_react_upload_1 = require("@progress/kendo-react-upload");
10
- const kendo_react_dropdowns_1 = require("@progress/kendo-react-dropdowns");
11
- const kendo_react_indicators_1 = require("@progress/kendo-react-indicators");
12
- const kendo_react_common_1 = require("@progress/kendo-react-common");
13
- const kendo_react_intl_1 = require("@progress/kendo-react-intl");
14
- const kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
15
- require("pdfjs-dist/build/pdf.worker.entry");
16
- const package_metadata_1 = require("./package-metadata");
17
- const kendo_pdfviewer_common_1 = require("@progress/kendo-pdfviewer-common");
18
- const messages_1 = require("./messages");
19
- const toolNames = [
20
- 'pager', 'spacer', 'zoomInOut', 'zoom', 'selection', 'spacer', 'search', 'open', 'download', 'print'
21
- ];
22
- // Correct declaration but typedoc does not recognize it.
23
- // export type PDFViewerTool = typeof toolNames[number];
24
- const defaultProps = {
25
- minZoom: 0.5,
26
- maxZoom: 4,
27
- tools: [...toolNames],
28
- zoomRate: 0.25,
29
- zoomLevels: [
30
- { id: 1, priority: 1, value: 1, text: 'Actual width', type: 'ActualWidth', locationString: messages_1.actualWidth },
31
- { id: 2, priority: 2, value: 1, text: 'Fit to width', type: 'FitToWidth', locationString: messages_1.fitToWidth },
32
- { id: 3, priority: 3, value: 1, text: 'Fit to page', type: 'FitToPage', locationString: messages_1.fitToPage },
33
- { id: 4, priority: 4, value: 0.5, text: '50%', type: '' },
34
- { id: 5, priority: 5, value: 0.75, text: '75%', type: '' },
35
- { id: 6, priority: 100, value: 1, text: '100%', type: '' },
36
- { id: 7, priority: 7, value: 1.25, text: '125%', type: '' },
37
- { id: 8, priority: 8, value: 1.5, text: '150%', type: '' },
38
- { id: 9, priority: 9, value: 2, text: '200%', type: '' },
39
- { id: 10, priority: 10, value: 3, text: '300%', type: '' },
40
- { id: 11, priority: 11, value: 4, text: '400%', type: '' }
41
- ],
42
- defaultZoom: kendo_pdfviewer_common_1.DEFAULT_ZOOM_LEVEL
43
- };
44
- const navigation = [
45
- '.k-toolbar > button',
46
- '.k-toolbar .k-combobox > input',
47
- '.k-toolbar .k-button-group > button',
48
- '.k-toolbar .k-pager > a',
49
- '.k-toolbar .k-pager input'
50
- ];
51
- const sortByPriority = (a, b) => {
52
- if (a.priority > b.priority) {
53
- return -1;
54
- }
55
- else if (a.priority < b.priority) {
56
- return 1;
57
- }
58
- return 0;
59
- };
60
- /**
61
- * Represents the [KendoReact PDFViewer component]({% slug api_pdf-viewer_pdfviewerprops %}).
62
- *
63
- * @example
64
- * ```jsx
65
- * function App() {
66
- * return <PDFViewer url="sample.pdf" />;
67
- * }
68
- * ReactDOM.render(<App />, document.querySelector('my-app'));
69
- * ```
70
- */
71
- exports.PDFViewer = React.forwardRef((props, ref) => {
72
- (0, kendo_react_common_1.validatePackage)(package_metadata_1.packageMetadata);
73
- const showLicenseWatermark = (0, kendo_react_common_1.shouldShowValidationUI)(package_metadata_1.packageMetadata);
74
- const { zoom, zoomLevels = defaultProps.zoomLevels, defaultZoom = defaultProps.defaultZoom, minZoom = defaultProps.minZoom, maxZoom = defaultProps.maxZoom, zoomRate = defaultProps.zoomRate } = props;
75
- const loc = (0, kendo_react_intl_1.useLocalization)();
76
- const pagesRef = React.useRef(null);
77
- const [stateZoom, setStateZoom] = React.useState(defaultZoom);
78
- const currentZoom = zoom !== undefined ? zoom : stateZoom;
79
- const currentZoomLevel = zoomLevels.slice().sort(sortByPriority).find(z => z.value === currentZoom) ||
80
- { text: (currentZoom * 100) + '%', value: currentZoom, id: currentZoom, locationString: '' };
81
- if (currentZoomLevel.locationString) {
82
- currentZoomLevel.text = loc.toLanguageString(currentZoomLevel.locationString, messages_1.messages[currentZoomLevel.locationString]);
83
- }
84
- const [hasDocument, setHasDocument] = React.useState(false);
85
- const [loading, setLoading] = React.useState(true);
86
- const [skip, setSkip] = React.useState(0);
87
- const [enabledSelection, setEnabledSelection] = React.useState(false);
88
- const [showSearch, setShowSearch] = React.useState(false);
89
- const [matches, setMatches] = React.useState(0);
90
- const [currentMatch, setCurrentMatch] = React.useState(0);
91
- const [matchCase, setMatchCase] = React.useState(false);
92
- const [searchText, setSearchText] = React.useState('');
93
- const refObj = React.useMemo(() => ({}), []);
94
- refObj.currentZoom = currentZoom;
95
- refObj.props = props;
96
- const setScaleFactor = React.useCallback((scaleFactor) => {
97
- if (pagesRef.current) {
98
- pagesRef.current.style.setProperty('--scale-factor', String(scaleFactor));
99
- }
100
- }, []);
101
- const target = React.useRef(null);
102
- const pdfViewerRef = React.useRef(null);
103
- React.useImperativeHandle(target, () => ({
104
- get element() { return pdfViewerRef.current; },
105
- props,
106
- get pages() { return refObj.pages; },
107
- get document() { return refObj.document; }
108
- }), []);
109
- React.useImperativeHandle(ref, () => target.current);
110
- const triggerOnLoad = React.useCallback(() => {
111
- if (refObj.props.onLoad) {
112
- const loadEvent = { target: target.current };
113
- refObj.props.onLoad.call(undefined, loadEvent);
114
- }
115
- }, []);
116
- const triggerOnDownload = React.useCallback((blob, fileName, saveOptions) => {
117
- if (props.onDownload) {
118
- const downloadEvent = {
119
- target: target.current,
120
- blob,
121
- fileName,
122
- saveOptions
123
- };
124
- const result = props.onDownload.call(undefined, downloadEvent);
125
- return result === false ? true : false;
126
- }
127
- return false;
128
- }, [props.onDownload]);
129
- const initScroller = React.useCallback(() => {
130
- var _a;
131
- if (refObj.scroller) {
132
- refObj.scroller.destroy();
133
- }
134
- refObj.scroller = new kendo_pdfviewer_common_1.Scroller((_a = pagesRef.current) === null || _a === void 0 ? void 0 : _a.parentNode, {
135
- filter: '.k-page',
136
- events: {}
137
- });
138
- refObj.scroller.enablePanEventsTracking();
139
- }, []);
140
- const initSearch = React.useCallback((wrapper) => {
141
- const pagesTextLayers = Array.from(wrapper.querySelectorAll('.k-text-layer'));
142
- refObj.search = new kendo_pdfviewer_common_1.SearchService({
143
- textContainers: pagesTextLayers || [],
144
- highlightClass: 'k-search-highlight',
145
- highlightMarkClass: 'k-search-highlight-mark',
146
- charClass: 'k-text-char'
147
- });
148
- }, []);
149
- refObj.done = React.useCallback(({ pdfPages, pdfDoc, zoom: documentZoom }) => {
150
- refObj.document = pdfDoc;
151
- refObj.pages = pdfPages;
152
- refObj.zoom = documentZoom;
153
- initScroller();
154
- setLoading(false);
155
- setHasDocument(true);
156
- triggerOnLoad();
157
- if (pagesRef.current) {
158
- (0, kendo_pdfviewer_common_1.scrollToPage)(pagesRef.current, 0);
159
- }
160
- }, []);
161
- refObj.error = React.useCallback((reason) => {
162
- refObj.document = null;
163
- refObj.pages = [];
164
- setLoading(false);
165
- setHasDocument(false);
166
- if (props.onError) {
167
- const errorEvent = {
168
- error: typeof reason === 'string' ? { message: reason } : reason,
169
- target: target.current
170
- };
171
- props.onError.call(undefined, errorEvent);
172
- }
173
- }, [props.onError]);
174
- React.useEffect(() => {
175
- if (pagesRef.current) {
176
- if (props.url || props.data || props.arrayBuffer) {
177
- setLoading(true);
178
- (0, kendo_pdfviewer_common_1.removeChildren)(pagesRef.current);
179
- (0, kendo_pdfviewer_common_1.loadPDF)({
180
- url: props.url,
181
- data: props.data,
182
- arrayBuffer: props.arrayBuffer,
183
- dom: pagesRef.current,
184
- zoom: refObj.currentZoom,
185
- done: refObj.done,
186
- error: refObj.error
187
- });
188
- setScaleFactor(refObj.currentZoom);
189
- }
190
- else {
191
- refObj.document = null;
192
- refObj.pages = [];
193
- setHasDocument(false);
194
- setLoading(false);
195
- (0, kendo_pdfviewer_common_1.removeChildren)(pagesRef.current);
196
- }
197
- }
198
- }, [props.url, props.data, props.arrayBuffer]);
199
- const reload = React.useCallback((pdfDoc, zoomLev) => {
200
- if (pagesRef.current) {
201
- setLoading(true);
202
- (0, kendo_pdfviewer_common_1.removeChildren)(pagesRef.current);
203
- (0, kendo_pdfviewer_common_1.reloadDocument)({
204
- pdfDoc,
205
- zoom: zoomLev,
206
- dom: pagesRef.current,
207
- done: (pdfPages) => {
208
- refObj.pages = pdfPages;
209
- refObj.zoom = zoomLev;
210
- setLoading(false);
211
- },
212
- error: refObj.error
213
- });
214
- }
215
- }, []);
216
- React.useEffect(() => {
217
- setScaleFactor(currentZoom);
218
- if (pagesRef.current && refObj.document && currentZoom !== refObj.zoom) {
219
- reload(refObj.document, currentZoom);
220
- }
221
- }, [currentZoom, reload]);
222
- React.useEffect(() => {
223
- return () => {
224
- if (refObj.scroller) {
225
- refObj.scroller.destroy();
226
- }
227
- if (refObj.search) {
228
- refObj.search.destroy();
229
- }
230
- refObj.document = null;
231
- refObj.pages = [];
232
- };
233
- }, []);
234
- const onSearch = React.useCallback(() => {
235
- setShowSearch(true);
236
- initSearch(pagesRef.current);
237
- }, []);
238
- const onSearchTextChange = React.useCallback((e) => {
239
- const text = e.value;
240
- const currentMatches = refObj.search.search({ text, matchCase });
241
- setCurrentMatch(currentMatches.length ? 1 : 0);
242
- setMatches(currentMatches.length);
243
- setSearchText(text);
244
- }, [matchCase]);
245
- const onMatchCaseClick = React.useCallback(() => {
246
- const currentMatches = refObj.search.search({ text: searchText, matchCase: !matchCase });
247
- setCurrentMatch(currentMatches.length ? 1 : 0);
248
- setMatches(currentMatches.length);
249
- setMatchCase(!matchCase);
250
- }, [matchCase, searchText]);
251
- const onNextMatch = React.useCallback(() => {
252
- (0, kendo_pdfviewer_common_1.goToNextSearchMatch)(refObj);
253
- setCurrentMatch((currentMatch + 1) > matches ? 1 : (currentMatch + 1));
254
- }, [currentMatch, matches]);
255
- const onPrevMatch = React.useCallback(() => {
256
- (0, kendo_pdfviewer_common_1.goToPreviousSearchMatch)(refObj);
257
- setCurrentMatch((currentMatch - 1) < 1 ? matches : (currentMatch - 1));
258
- }, [currentMatch, matches]);
259
- const onClose = React.useCallback(() => {
260
- refObj.search.destroy();
261
- setCurrentMatch(0);
262
- setMatches(0);
263
- setMatchCase(false);
264
- setSearchText('');
265
- setShowSearch(false);
266
- }, []);
267
- const onTextBoxKeyDown = React.useCallback((e) => {
268
- if (e.key === 'Enter') {
269
- e.preventDefault();
270
- (0, kendo_pdfviewer_common_1.goToNextSearchMatch)(refObj);
271
- setCurrentMatch((currentMatch + 1) > matches ? 1 : (currentMatch + 1));
272
- }
273
- else if (e.key === 'Escape') {
274
- onClose();
275
- }
276
- }, [currentMatch, matches]);
277
- const onPageChange = React.useCallback((e) => {
278
- if (pagesRef.current) {
279
- const nextPage = e.skip;
280
- (0, kendo_pdfviewer_common_1.scrollToPage)(pagesRef.current, nextPage);
281
- const pageEvent = {
282
- page: nextPage + 1,
283
- target: target.current,
284
- syntheticEvent: e.syntheticEvent
285
- };
286
- if (props.onPageChange) {
287
- props.onPageChange.call(undefined, pageEvent);
288
- }
289
- }
290
- setSkip(e.skip);
291
- }, [skip, props.onPageChange]);
292
- const onScroll = React.useCallback((e) => {
293
- if (pdfViewerRef.current) {
294
- const nextPage = (0, kendo_pdfviewer_common_1.currentPage)(pdfViewerRef.current);
295
- if (nextPage !== skip) {
296
- setSkip(nextPage);
297
- const pageEvent = {
298
- page: nextPage + 1,
299
- target: target.current,
300
- syntheticEvent: e
301
- };
302
- if (props.onPageChange) {
303
- props.onPageChange.call(undefined, pageEvent);
304
- }
305
- }
306
- }
307
- }, [skip, props.onPageChange]);
308
- const onZoomIn = React.useCallback((e) => {
309
- const newZoom = Math.min(refObj.currentZoom + zoomRate, maxZoom);
310
- if (newZoom !== refObj.currentZoom && refObj.document) {
311
- setStateZoom(newZoom);
312
- if (props.onZoom) {
313
- const zoomEvent = {
314
- zoom: newZoom,
315
- target: target.current,
316
- syntheticEvent: e
317
- };
318
- props.onZoom.call(undefined, zoomEvent);
319
- }
320
- }
321
- }, [zoomRate, maxZoom, props.onZoom]);
322
- const onZoomOut = React.useCallback((e) => {
323
- const newZoom = Math.max(refObj.currentZoom - zoomRate, minZoom);
324
- if (newZoom !== refObj.currentZoom && refObj.document) {
325
- setStateZoom(newZoom);
326
- if (props.onZoom) {
327
- const zoomEvent = {
328
- zoom: newZoom,
329
- target: target.current,
330
- syntheticEvent: e
331
- };
332
- props.onZoom.call(undefined, zoomEvent);
333
- }
334
- }
335
- }, [zoomRate, minZoom, props.onZoom]);
336
- const onZoomLevelChange = React.useCallback((e) => {
337
- const item = e.value === null ? { text: '100%', value: 1, id: 100 } : Object.assign({}, e.value);
338
- if (item.value === undefined) {
339
- const parsedText = parseFloat(item.text);
340
- if (typeof parsedText === 'number' && !Number.isNaN(parsedText)) {
341
- item.value = parsedText / 100;
342
- }
343
- else {
344
- item.value = 1;
345
- }
346
- }
347
- let newZoom = item ? (0, kendo_pdfviewer_common_1.calculateZoomLevel)(item.value, item.type, refObj.currentZoom, pagesRef.current) : 1;
348
- newZoom = Math.round(newZoom * 100) / 100;
349
- if (refObj.currentZoom !== newZoom && refObj.document) {
350
- setStateZoom(newZoom);
351
- if (props.onZoom) {
352
- const zoomEvent = {
353
- zoom: newZoom,
354
- target: target.current,
355
- syntheticEvent: e.syntheticEvent
356
- };
357
- props.onZoom.call(undefined, zoomEvent);
358
- }
359
- }
360
- }, [props.onZoom]);
361
- const onTextSelection = React.useCallback(() => {
362
- refObj.scroller.disablePanEventsTracking();
363
- setEnabledSelection(true);
364
- }, []);
365
- const onPinning = React.useCallback(() => {
366
- refObj.scroller.enablePanEventsTracking();
367
- setEnabledSelection(false);
368
- }, []);
369
- const onDownload = React.useCallback(() => {
370
- (0, kendo_pdfviewer_common_1.download)({
371
- pdf: refObj.document,
372
- error: refObj.error
373
- }, props.saveFileName, props.saveOptions, triggerOnDownload);
374
- }, [props.url, props.data, props.arrayBuffer, props.saveFileName, props.saveOptions, triggerOnDownload]);
375
- const onPrint = React.useCallback(() => {
376
- setLoading(true);
377
- const onError = (e) => {
378
- refObj.error(typeof (e ? e.message || e : null) === 'string' ? e.message || e : loc.toLanguageString(messages_1.popupBlocked, messages_1.messages[messages_1.popupBlocked]));
379
- };
380
- const onDone = () => {
381
- setLoading(false);
382
- };
383
- (0, kendo_pdfviewer_common_1.print)(refObj.pages, onDone, onError);
384
- }, []);
385
- const onAdd = React.useCallback((e) => {
386
- const st = e.newState;
387
- if (st[0] && st[0].getRawFile) {
388
- const file = st[0].getRawFile();
389
- file.arrayBuffer().then((arrayBuffer) => {
390
- if (pagesRef.current) {
391
- setLoading(true);
392
- (0, kendo_pdfviewer_common_1.removeChildren)(pagesRef.current);
393
- const currentZoomValue = refObj.props.zoom === undefined ? defaultZoom : refObj.props.zoom;
394
- (0, kendo_pdfviewer_common_1.loadPDF)({
395
- arrayBuffer,
396
- dom: pagesRef.current,
397
- zoom: currentZoomValue,
398
- done: refObj.done,
399
- error: refObj.error
400
- });
401
- setStateZoom(currentZoomValue);
402
- }
403
- });
404
- }
405
- }, [defaultZoom]);
406
- const onFileOpen = React.useCallback((e) => {
407
- const targetEl = e.target;
408
- if (targetEl instanceof Element && targetEl.parentNode) {
409
- const toolbarEl = targetEl.closest('.k-toolbar');
410
- const input = toolbarEl && toolbarEl.querySelector('.k-upload input');
411
- if (input) {
412
- input.click();
413
- }
414
- }
415
- }, []);
416
- const loader = (loading && React.createElement("div", { className: "k-loader-container k-loader-container-md k-loader-top" },
417
- React.createElement("div", { className: "k-loader-container-overlay k-overlay-light" }),
418
- React.createElement("div", { className: "k-loader-container-inner " },
419
- React.createElement(kendo_react_indicators_1.Loader, { size: 'large' }))));
420
- const zoomInOut = (React.createElement(kendo_react_buttons_1.ButtonGroup, null,
421
- React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.zoomOut, messages_1.messages[messages_1.zoomOut]), disabled: currentZoom <= minZoom || !hasDocument, onClick: onZoomOut, icon: 'zoom-out', svgIcon: kendo_svg_icons_1.zoomOutIcon }),
422
- React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.zoomIn, messages_1.messages[messages_1.zoomIn]), disabled: currentZoom >= maxZoom || !hasDocument, onClick: onZoomIn, icon: 'zoom-in', svgIcon: kendo_svg_icons_1.zoomInIcon })));
423
- const zoomComboBoxTool = (React.createElement(kendo_react_dropdowns_1.ComboBox, { disabled: !hasDocument, data: (zoomLevels).map(level => (Object.assign(Object.assign({}, level), { text: level.locationString
424
- ? loc.toLanguageString(level.locationString, messages_1.messages[level.locationString])
425
- : level.text }))), dataItemKey: 'id', textField: 'text', value: hasDocument ? currentZoomLevel : null, allowCustom: true, onChange: onZoomLevelChange }));
426
- const pagerTool = (React.createElement(kendo_react_data_tools_1.Pager, { previousNext: true, type: 'input', skip: skip, take: 1, total: refObj.pages ? refObj.pages.length : 0, info: false, onPageChange: onPageChange }));
427
- const spacer = React.createElement(kendo_react_buttons_1.ToolbarSpacer, null);
428
- const selectionTool = (React.createElement(kendo_react_buttons_1.ButtonGroup, null,
429
- React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.enableSelection, messages_1.messages[messages_1.enableSelection]), icon: 'pointer', svgIcon: kendo_svg_icons_1.pointerIcon, disabled: !hasDocument, togglable: true, selected: enabledSelection && hasDocument, onClick: onTextSelection }),
430
- React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.enablePanning, messages_1.messages[messages_1.enablePanning]), icon: 'hand', svgIcon: kendo_svg_icons_1.handIcon, disabled: !hasDocument, togglable: true, selected: !enabledSelection && hasDocument, onClick: onPinning })));
431
- const searchTool = (React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.search, messages_1.messages[messages_1.search]), icon: 'search', svgIcon: kendo_svg_icons_1.searchIcon, disabled: !hasDocument, onClick: onSearch }));
432
- const openTool = (React.createElement(React.Fragment, null,
433
- React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.open, messages_1.messages[messages_1.open]), icon: 'folder-open', svgIcon: kendo_svg_icons_1.folderOpenIcon, onClick: onFileOpen }),
434
- React.createElement("div", { style: { display: 'none' } },
435
- React.createElement(kendo_react_upload_1.Upload, { restrictions: { allowedExtensions: ['.pdf'] }, onAdd: onAdd, autoUpload: false, defaultFiles: [], multiple: false, accept: ".pdf,.PDF", withCredentials: false }))));
436
- const downloadTool = (React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.download, messages_1.messages[messages_1.download]), icon: 'download', svgIcon: kendo_svg_icons_1.downloadIcon, disabled: !hasDocument, onClick: onDownload }));
437
- const printTool = (React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.print, messages_1.messages[messages_1.print]), icon: 'print', svgIcon: kendo_svg_icons_1.printIcon, disabled: !hasDocument, onClick: onPrint }));
438
- const tools = {
439
- pager: pagerTool,
440
- spacer,
441
- zoomInOut,
442
- zoom: zoomComboBoxTool,
443
- selection: selectionTool,
444
- search: searchTool,
445
- open: openTool,
446
- download: downloadTool,
447
- print: printTool
448
- };
449
- const buttons = (props.tools || defaultProps.tools).map((tool) => tools[tool]);
450
- const toolbar = (React.createElement(kendo_react_buttons_1.Toolbar, { buttons: navigation }, ...buttons));
451
- const content = (React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto', {
452
- 'k-enable-text-select': enabledSelection,
453
- 'k-enable-panning': !enabledSelection
454
- }), onScroll: onScroll },
455
- showSearch && (React.createElement("div", { className: 'k-search-panel k-pos-sticky k-top-center' },
456
- React.createElement(kendo_react_inputs_1.TextBox, { value: searchText, onChange: onSearchTextChange, placeholder: loc.toLanguageString(messages_1.search, messages_1.messages[messages_1.search]), autoFocus: true, onKeyDown: onTextBoxKeyDown, suffix: () => (React.createElement(kendo_react_inputs_1.InputSuffix, null,
457
- React.createElement(kendo_react_buttons_1.Button, { icon: "convert-lowercase", svgIcon: kendo_svg_icons_1.convertLowercaseIcon, title: loc.toLanguageString(messages_1.matchCase, messages_1.messages[messages_1.matchCase]), fillMode: "flat", togglable: true, selected: matchCase, onClick: onMatchCaseClick }))) }),
458
- React.createElement("span", { className: "k-search-matches" },
459
- React.createElement("span", null, currentMatch),
460
- " of ",
461
- React.createElement("span", null, matches)),
462
- React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.prevMatch, messages_1.messages[messages_1.prevMatch]), fillMode: 'flat', icon: 'arrow-up', svgIcon: kendo_svg_icons_1.arrowUpIcon, disabled: matches === 0, onClick: onPrevMatch }),
463
- React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.nextMatch, messages_1.messages[messages_1.nextMatch]), fillMode: 'flat', icon: 'arrow-down', svgIcon: kendo_svg_icons_1.arrowDownIcon, disabled: matches === 0, onClick: onNextMatch }),
464
- React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.close, messages_1.messages[messages_1.close]), fillMode: 'flat', icon: 'x', svgIcon: kendo_svg_icons_1.xIcon, onClick: onClose }))),
465
- React.createElement("div", { ref: pagesRef, className: 'k-pdf-viewer-pages' })));
466
- return (React.createElement("div", { className: 'k-pdf-viewer', style: props.style, ref: pdfViewerRef },
467
- props.onRenderLoader ? props.onRenderLoader.call(undefined, loader || null) : loader,
468
- props.onRenderToolbar ? props.onRenderToolbar.call(undefined, toolbar) : toolbar,
469
- props.onRenderContent ? props.onRenderContent.call(undefined, content) : content,
470
- showLicenseWatermark && React.createElement(kendo_react_common_1.WatermarkOverlay, null)));
471
- });
472
- exports.PDFViewer.displayName = 'KendoReactPDFViewer';
473
- exports.PDFViewer.propTypes = {
474
- url: PropTypes.string,
475
- data: PropTypes.string,
476
- arrayBuffer: PropTypes.any,
477
- typedArray: PropTypes.any,
478
- style: PropTypes.object,
479
- saveFileName: PropTypes.string,
480
- saveOptions: PropTypes.object,
481
- tools: PropTypes.arrayOf(PropTypes.oneOf(toolNames).isRequired),
482
- zoomLevels: PropTypes.arrayOf(PropTypes.any),
483
- zoom: PropTypes.number,
484
- defaultZoom: PropTypes.number,
485
- minZoom: PropTypes.number,
486
- maxZoom: PropTypes.number,
487
- zoomRate: PropTypes.number,
488
- onError: PropTypes.func,
489
- onLoad: PropTypes.func,
490
- onDownload: PropTypes.func,
491
- onRenderToolbar: PropTypes.func,
492
- onRenderContent: PropTypes.func,
493
- onRenderLoader: PropTypes.func,
494
- onZoom: PropTypes.func
495
- };
496
- exports.PDFViewer.defaultProps = defaultProps;
@@ -1,29 +0,0 @@
1
- export { PDFViewer, PDFViewerProps, PDFViewerHandle, PDFViewerTool, LoadEvent, ErrorEvent, DownloadEvent, ZoomEvent, PageEvent } from './PDFViewer';
2
- export { currentPage } from '@progress/kendo-pdfviewer-common';
3
- /**
4
- * Scrolls the PDFViewer document to the passed page number.
5
- *
6
- * @param rootElement The root HTML element of the PDFViewer component.
7
- * @param pageNumber The page number.
8
- *
9
- * @example
10
- * ```jsx
11
- * function App() {
12
- * const pdfRef = React.useRef(null);
13
- * const handleClick = () => {
14
- * scrollToPage(pdfRef.current.element, 3);
15
- * };
16
- * return (
17
- * <div>
18
- * <Button onClick={handleClick} >
19
- * Scroll to Page 3
20
- * </Button>
21
- * <PDFViewer
22
- * ref={pdfRef}
23
- * />
24
- * </div>
25
- * )
26
- * }
27
- * ```
28
- */
29
- export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
package/dist/npm/main.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scrollToPage = exports.currentPage = exports.PDFViewer = void 0;
4
- var PDFViewer_1 = require("./PDFViewer");
5
- Object.defineProperty(exports, "PDFViewer", { enumerable: true, get: function () { return PDFViewer_1.PDFViewer; } });
6
- var kendo_pdfviewer_common_1 = require("@progress/kendo-pdfviewer-common");
7
- Object.defineProperty(exports, "currentPage", { enumerable: true, get: function () { return kendo_pdfviewer_common_1.currentPage; } });
8
- const kendo_pdfviewer_common_2 = require("@progress/kendo-pdfviewer-common");
9
- /**
10
- * Scrolls the PDFViewer document to the passed page number.
11
- *
12
- * @param rootElement The root HTML element of the PDFViewer component.
13
- * @param pageNumber The page number.
14
- *
15
- * @example
16
- * ```jsx
17
- * function App() {
18
- * const pdfRef = React.useRef(null);
19
- * const handleClick = () => {
20
- * scrollToPage(pdfRef.current.element, 3);
21
- * };
22
- * return (
23
- * <div>
24
- * <Button onClick={handleClick} >
25
- * Scroll to Page 3
26
- * </Button>
27
- * <PDFViewer
28
- * ref={pdfRef}
29
- * />
30
- * </div>
31
- * )
32
- * }
33
- * ```
34
- */
35
- exports.scrollToPage = kendo_pdfviewer_common_2.scrollToPage;
@@ -1,85 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export declare const zoomIn = "pdfviewer.zoomIn";
5
- /**
6
- * @hidden
7
- */
8
- export declare const zoomOut = "pdfviewer.zoomOut";
9
- /**
10
- * @hidden
11
- */
12
- export declare const enableSelection = "pdfviewer.enableSelection";
13
- /**
14
- * @hidden
15
- */
16
- export declare const enablePanning = "pdfviewer.enablePanning";
17
- /**
18
- * @hidden
19
- */
20
- export declare const search = "pdfviewer.search";
21
- /**
22
- * @hidden
23
- */
24
- export declare const open = "pdfviewer.open";
25
- /**
26
- * @hidden
27
- */
28
- export declare const download = "pdfviewer.download";
29
- /**
30
- * @hidden
31
- */
32
- export declare const print = "pdfviewer.print";
33
- /**
34
- * @hidden
35
- */
36
- export declare const close = "pdfviewer.close";
37
- /**
38
- * @hidden
39
- */
40
- export declare const matchCase = "pdfviewer.matchCase";
41
- /**
42
- * @hidden
43
- */
44
- export declare const prevMatch = "pdfviewer.prevMatch";
45
- /**
46
- * @hidden
47
- */
48
- export declare const nextMatch = "pdfviewer.nextMatch";
49
- /**
50
- * @hidden
51
- */
52
- export declare const actualWidth = "pdfviewer.actualWidth";
53
- /**
54
- * @hidden
55
- */
56
- export declare const fitToWidth = "pdfviewer.fitToWidth";
57
- /**
58
- * @hidden
59
- */
60
- export declare const fitToPage = "pdfviewer.fitToPage";
61
- /**
62
- * @hidden
63
- */
64
- export declare const popupBlocked = "pdfviewer.popupBlocked";
65
- /**
66
- * @hidden
67
- */
68
- export declare const messages: {
69
- "pdfviewer.zoomIn": string;
70
- "pdfviewer.zoomOut": string;
71
- "pdfviewer.enableSelection": string;
72
- "pdfviewer.enablePanning": string;
73
- "pdfviewer.search": string;
74
- "pdfviewer.open": string;
75
- "pdfviewer.download": string;
76
- "pdfviewer.print": string;
77
- "pdfviewer.close": string;
78
- "pdfviewer.matchCase": string;
79
- "pdfviewer.prevMatch": string;
80
- "pdfviewer.nextMatch": string;
81
- "pdfviewer.actualWidth": string;
82
- "pdfviewer.fitToWidth": string;
83
- "pdfviewer.fitToPage": string;
84
- "pdfviewer.popupBlocked": string;
85
- };