@progress/kendo-react-pdf-viewer 5.10.0-dev.202211241147
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 +11 -0
- package/NOTICE.txt +111 -0
- package/README.md +54 -0
- package/about.md +3 -0
- package/dist/cdn/js/kendo-react-pdf-viewer.js +2 -0
- package/dist/cdn/js/kendo-react-pdf-viewer.js.LICENSE.txt +21 -0
- package/dist/es/PDFViewer.d.ts +138 -0
- package/dist/es/PDFViewer.js +365 -0
- package/dist/es/main.d.ts +1 -0
- package/dist/es/main.js +1 -0
- package/dist/es/messages.d.ts +85 -0
- package/dist/es/messages.js +85 -0
- package/dist/es/package-metadata.d.ts +5 -0
- package/dist/es/package-metadata.js +11 -0
- package/dist/es/scroller.d.ts +34 -0
- package/dist/es/scroller.js +226 -0
- package/dist/es/search.d.ts +42 -0
- package/dist/es/search.js +249 -0
- package/dist/es/utils.d.ts +78 -0
- package/dist/es/utils.js +240 -0
- package/dist/npm/PDFViewer.d.ts +138 -0
- package/dist/npm/PDFViewer.js +368 -0
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +5 -0
- package/dist/npm/messages.d.ts +85 -0
- package/dist/npm/messages.js +88 -0
- package/dist/npm/package-metadata.d.ts +5 -0
- package/dist/npm/package-metadata.js +14 -0
- package/dist/npm/scroller.d.ts +34 -0
- package/dist/npm/scroller.js +230 -0
- package/dist/npm/search.d.ts +42 -0
- package/dist/npm/search.js +253 -0
- package/dist/npm/utils.d.ts +78 -0
- package/dist/npm/utils.js +251 -0
- package/dist/systemjs/kendo-react-pdf-viewer.js +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,368 @@
|
|
|
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
|
+
require("pdfjs-dist/build/pdf.worker.entry");
|
|
15
|
+
const package_metadata_1 = require("./package-metadata");
|
|
16
|
+
const scroller_1 = require("./scroller");
|
|
17
|
+
const search_1 = require("./search");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
const messages_1 = require("./messages");
|
|
20
|
+
const zoomMin = 0.5;
|
|
21
|
+
const zoomMax = 4;
|
|
22
|
+
const zoomStep = 0.25;
|
|
23
|
+
const zoomLevels = [
|
|
24
|
+
{ id: 1, value: 1, text: 'ActualWidth', type: 'ActualWidth', locationString: messages_1.actualWidth },
|
|
25
|
+
{ id: 2, value: 1, text: 'FitToWidth', type: 'FitToWidth', locationString: messages_1.fitToWidth },
|
|
26
|
+
{ id: 3, value: 1, text: 'FitToPage', type: 'FitToPage', locationString: messages_1.fitToPage },
|
|
27
|
+
{ id: 4, value: 0.5, text: '50%', type: '' },
|
|
28
|
+
{ id: 5, value: 0.75, text: '75%', type: '' },
|
|
29
|
+
{ id: 6, value: 1, text: '100%', type: '' },
|
|
30
|
+
{ id: 7, value: 1.25, text: '125%', type: '' },
|
|
31
|
+
{ id: 8, value: 1.5, text: '150%', type: '' },
|
|
32
|
+
{ id: 9, value: 2, text: '200%', type: '' },
|
|
33
|
+
{ id: 10, value: 3, text: '300%', type: '' },
|
|
34
|
+
{ id: 11, value: 4, text: '400%', type: '' }
|
|
35
|
+
];
|
|
36
|
+
const navigation = [
|
|
37
|
+
'.k-toolbar > button',
|
|
38
|
+
'.k-toolbar .k-combobox > input',
|
|
39
|
+
'.k-toolbar .k-button-group > button',
|
|
40
|
+
'.k-toolbar .k-pager > a',
|
|
41
|
+
'.k-toolbar .k-pager input'
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Represents the [KendoReact PDFViewer component]({% slug api_pdf-viewer_pdfviewerprops %}).
|
|
45
|
+
*/
|
|
46
|
+
exports.PDFViewer = React.forwardRef((props, ref) => {
|
|
47
|
+
(0, kendo_react_common_1.validatePackage)(package_metadata_1.packageMetadata);
|
|
48
|
+
const loc = (0, kendo_react_intl_1.useLocalization)();
|
|
49
|
+
const pagesRef = React.useRef(null);
|
|
50
|
+
const [zoom, setZoom] = React.useState(utils_1.DEFAULT_ZOOM_LEVEL);
|
|
51
|
+
const [zoomLevel, setZoomLevel] = React.useState(zoomLevels.find(z => z.value === utils_1.DEFAULT_ZOOM_LEVEL));
|
|
52
|
+
const [loading, setLoading] = React.useState(true);
|
|
53
|
+
const [skip, setSkip] = React.useState(0);
|
|
54
|
+
const [pages, setPages] = React.useState([]);
|
|
55
|
+
const [doc, setDoc] = React.useState(null);
|
|
56
|
+
const [enabledSelection, setEnabledSelection] = React.useState(false);
|
|
57
|
+
const [showSearch, setShowSearch] = React.useState(false);
|
|
58
|
+
const [matches, setMatches] = React.useState(0);
|
|
59
|
+
const [currentMatch, setCurrentMatch] = React.useState(0);
|
|
60
|
+
const [matchCase, setMatchCase] = React.useState(false);
|
|
61
|
+
const [searchText, setSearchText] = React.useState('');
|
|
62
|
+
const refObj = React.useMemo(() => ({}), []);
|
|
63
|
+
const target = React.useRef(null);
|
|
64
|
+
const pdfViewerRef = React.useRef(null);
|
|
65
|
+
React.useImperativeHandle(target, () => ({
|
|
66
|
+
element: pdfViewerRef.current,
|
|
67
|
+
props,
|
|
68
|
+
pages,
|
|
69
|
+
document: doc
|
|
70
|
+
}), [pages, doc]);
|
|
71
|
+
React.useImperativeHandle(ref, () => target.current);
|
|
72
|
+
const triggerOnLoad = React.useCallback(() => {
|
|
73
|
+
if (props.onLoad) {
|
|
74
|
+
const loadEvent = { target: target.current };
|
|
75
|
+
props.onLoad.call(undefined, loadEvent);
|
|
76
|
+
}
|
|
77
|
+
}, [props.onLoad]);
|
|
78
|
+
const triggerOnDownload = React.useCallback((blob, fileName, saveOptions) => {
|
|
79
|
+
let handled = false;
|
|
80
|
+
if (props.onDownload) {
|
|
81
|
+
const downloadEvent = {
|
|
82
|
+
target: target.current,
|
|
83
|
+
blob,
|
|
84
|
+
fileName,
|
|
85
|
+
saveOptions
|
|
86
|
+
};
|
|
87
|
+
handled = props.onDownload.call(undefined, downloadEvent) || false;
|
|
88
|
+
}
|
|
89
|
+
return handled;
|
|
90
|
+
}, [props.onDownload]);
|
|
91
|
+
const initScroller = React.useCallback(() => {
|
|
92
|
+
var _a;
|
|
93
|
+
if (refObj.scroller) {
|
|
94
|
+
refObj.scroller.destroy();
|
|
95
|
+
}
|
|
96
|
+
refObj.scroller = new scroller_1.Scroller((_a = pagesRef.current) === null || _a === void 0 ? void 0 : _a.parentNode, {
|
|
97
|
+
filter: '.k-page',
|
|
98
|
+
events: {}
|
|
99
|
+
});
|
|
100
|
+
refObj.scroller.enablePanEventsTracking();
|
|
101
|
+
}, []);
|
|
102
|
+
const initSearch = React.useCallback((wrapper) => {
|
|
103
|
+
const pagesTextLayers = Array.from(wrapper.querySelectorAll('.k-text-layer'));
|
|
104
|
+
refObj.search = new search_1.SearchService({
|
|
105
|
+
textContainers: pagesTextLayers || [],
|
|
106
|
+
highlightClass: 'k-search-highlight',
|
|
107
|
+
highlightMarkClass: 'k-search-highlight-mark',
|
|
108
|
+
charClass: 'k-text-char'
|
|
109
|
+
});
|
|
110
|
+
}, []);
|
|
111
|
+
const done = React.useCallback(({ pdfPages, pdfDoc }) => {
|
|
112
|
+
setDoc(pdfDoc);
|
|
113
|
+
setPages(pdfPages);
|
|
114
|
+
initScroller();
|
|
115
|
+
setLoading(false);
|
|
116
|
+
triggerOnLoad();
|
|
117
|
+
}, []);
|
|
118
|
+
const error = React.useCallback((reason) => {
|
|
119
|
+
setLoading(false);
|
|
120
|
+
setDoc(null);
|
|
121
|
+
setPages([]);
|
|
122
|
+
if (props.onError) {
|
|
123
|
+
const errorEvent = {
|
|
124
|
+
error: typeof reason === 'string' ? { message: reason } : reason,
|
|
125
|
+
target: target.current
|
|
126
|
+
};
|
|
127
|
+
props.onError.call(undefined, errorEvent);
|
|
128
|
+
}
|
|
129
|
+
}, [props.onError]);
|
|
130
|
+
React.useEffect(() => {
|
|
131
|
+
if (pagesRef.current) {
|
|
132
|
+
if (props.url || props.data || props.arrayBuffer) {
|
|
133
|
+
setLoading(true);
|
|
134
|
+
(0, utils_1.removeChildren)(pagesRef.current);
|
|
135
|
+
(0, utils_1.loadPDF)({
|
|
136
|
+
url: props.url,
|
|
137
|
+
data: props.data,
|
|
138
|
+
arrayBuffer: props.arrayBuffer,
|
|
139
|
+
dom: pagesRef.current,
|
|
140
|
+
zoom: utils_1.DEFAULT_ZOOM_LEVEL,
|
|
141
|
+
done,
|
|
142
|
+
error
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
setLoading(false);
|
|
147
|
+
(0, utils_1.removeChildren)(pagesRef.current);
|
|
148
|
+
setDoc(null);
|
|
149
|
+
setPages([]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, [props.url, props.data, props.arrayBuffer, error]);
|
|
153
|
+
const reload = React.useCallback((pdfDoc, zoomLev = utils_1.DEFAULT_ZOOM_LEVEL) => {
|
|
154
|
+
if (pagesRef.current) {
|
|
155
|
+
setLoading(true);
|
|
156
|
+
(0, utils_1.removeChildren)(pagesRef.current);
|
|
157
|
+
(0, utils_1.reloadDocument)({
|
|
158
|
+
pdfDoc,
|
|
159
|
+
zoom: zoomLev,
|
|
160
|
+
dom: pagesRef.current,
|
|
161
|
+
done: (pdfPages) => {
|
|
162
|
+
setPages(pdfPages);
|
|
163
|
+
setLoading(false);
|
|
164
|
+
},
|
|
165
|
+
error
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, [error]);
|
|
169
|
+
const onSearch = React.useCallback(() => {
|
|
170
|
+
setShowSearch(true);
|
|
171
|
+
initSearch(pagesRef.current);
|
|
172
|
+
}, []);
|
|
173
|
+
const onSearchTextChange = React.useCallback((e) => {
|
|
174
|
+
const text = e.value;
|
|
175
|
+
const currentMatches = refObj.search.search({ text, matchCase });
|
|
176
|
+
setCurrentMatch(currentMatches.length ? 1 : 0);
|
|
177
|
+
setMatches(currentMatches.length);
|
|
178
|
+
setSearchText(text);
|
|
179
|
+
}, [matchCase]);
|
|
180
|
+
const onMatchCaseClick = React.useCallback(() => {
|
|
181
|
+
const currentMatches = refObj.search.search({ text: searchText, matchCase: !matchCase });
|
|
182
|
+
setCurrentMatch(currentMatches.length ? 1 : 0);
|
|
183
|
+
setMatches(currentMatches.length);
|
|
184
|
+
setMatchCase(!matchCase);
|
|
185
|
+
}, [matchCase, searchText]);
|
|
186
|
+
const onNextMatch = React.useCallback(() => {
|
|
187
|
+
(0, utils_1.goToNextSearchMatch)(refObj);
|
|
188
|
+
setCurrentMatch((currentMatch + 1) > matches ? 1 : (currentMatch + 1));
|
|
189
|
+
}, [currentMatch, matches]);
|
|
190
|
+
const onPrevMatch = React.useCallback(() => {
|
|
191
|
+
(0, utils_1.goToPreviousSearchMatch)(refObj);
|
|
192
|
+
setCurrentMatch((currentMatch - 1) < 1 ? matches : (currentMatch - 1));
|
|
193
|
+
}, [currentMatch, matches]);
|
|
194
|
+
const onClose = React.useCallback(() => {
|
|
195
|
+
refObj.search.destroy();
|
|
196
|
+
setCurrentMatch(0);
|
|
197
|
+
setMatches(0);
|
|
198
|
+
setMatchCase(false);
|
|
199
|
+
setSearchText('');
|
|
200
|
+
setShowSearch(false);
|
|
201
|
+
}, []);
|
|
202
|
+
const onTextBoxKeyDown = React.useCallback((e) => {
|
|
203
|
+
if (e.key === 'Enter') {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
(0, utils_1.goToNextSearchMatch)(refObj);
|
|
206
|
+
setCurrentMatch((currentMatch + 1) > matches ? 1 : (currentMatch + 1));
|
|
207
|
+
}
|
|
208
|
+
else if (e.key === 'Escape') {
|
|
209
|
+
onClose();
|
|
210
|
+
}
|
|
211
|
+
}, [currentMatch, matches]);
|
|
212
|
+
const onPageChange = React.useCallback((e) => {
|
|
213
|
+
if (pagesRef.current && pagesRef.current.parentNode instanceof HTMLDivElement) {
|
|
214
|
+
const page = pagesRef.current.querySelector('.k-page');
|
|
215
|
+
if (page instanceof HTMLDivElement) {
|
|
216
|
+
const top = (page.offsetHeight + page.offsetTop) * e.skip;
|
|
217
|
+
pagesRef.current.parentNode.scrollTo({ top, behavior: 'auto' });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
setSkip(e.skip);
|
|
221
|
+
}, [skip]);
|
|
222
|
+
const onScroll = React.useCallback((e) => {
|
|
223
|
+
const targetEl = e.target;
|
|
224
|
+
const page = targetEl.querySelector('.k-page');
|
|
225
|
+
if (page) {
|
|
226
|
+
setSkip(Math.floor(targetEl.scrollTop / (page.offsetHeight + page.offsetTop)));
|
|
227
|
+
}
|
|
228
|
+
}, []);
|
|
229
|
+
const onZoomIn = React.useCallback(() => {
|
|
230
|
+
const newZoom = Math.min(zoom + zoomStep, zoomMax);
|
|
231
|
+
if (newZoom !== zoom && doc) {
|
|
232
|
+
setZoom(newZoom);
|
|
233
|
+
reload(doc, newZoom);
|
|
234
|
+
}
|
|
235
|
+
}, [zoom, doc]);
|
|
236
|
+
const onZoomOut = React.useCallback(() => {
|
|
237
|
+
const newZoom = Math.max(zoom - zoomStep, zoomMin);
|
|
238
|
+
if (newZoom !== zoom && doc) {
|
|
239
|
+
setZoom(newZoom);
|
|
240
|
+
reload(doc, newZoom);
|
|
241
|
+
}
|
|
242
|
+
}, [zoom, doc]);
|
|
243
|
+
const onZoomLevelChange = React.useCallback((e) => {
|
|
244
|
+
const item = e.value;
|
|
245
|
+
const newZoom = item ? (0, utils_1.calculateZoomLevel)(item.value, item.type, zoom, pagesRef.current) : 1;
|
|
246
|
+
if (zoom !== newZoom && doc) {
|
|
247
|
+
setZoom(newZoom);
|
|
248
|
+
reload(doc, newZoom);
|
|
249
|
+
}
|
|
250
|
+
setZoomLevel(item);
|
|
251
|
+
}, [zoom, doc]);
|
|
252
|
+
const onTextSelection = React.useCallback(() => {
|
|
253
|
+
refObj.scroller.disablePanEventsTracking();
|
|
254
|
+
setEnabledSelection(true);
|
|
255
|
+
}, []);
|
|
256
|
+
const onPinning = React.useCallback(() => {
|
|
257
|
+
refObj.scroller.enablePanEventsTracking();
|
|
258
|
+
setEnabledSelection(false);
|
|
259
|
+
}, []);
|
|
260
|
+
const onDownload = React.useCallback(() => {
|
|
261
|
+
(0, utils_1.download)({
|
|
262
|
+
url: props.url,
|
|
263
|
+
data: props.data,
|
|
264
|
+
arrayBuffer: props.arrayBuffer,
|
|
265
|
+
error
|
|
266
|
+
}, props.saveFileName, props.saveOptions, triggerOnDownload);
|
|
267
|
+
}, [props.url, props.data, props.arrayBuffer, error, props.saveFileName, props.saveOptions, triggerOnDownload]);
|
|
268
|
+
const onPrint = React.useCallback(() => {
|
|
269
|
+
setLoading(true);
|
|
270
|
+
const onError = (e) => {
|
|
271
|
+
error(typeof (e ? e.message || e : null) === 'string' ? e.message || e : loc.toLanguageString(messages_1.popupBlocked, messages_1.messages[messages_1.popupBlocked]));
|
|
272
|
+
};
|
|
273
|
+
const onDone = () => {
|
|
274
|
+
setLoading(false);
|
|
275
|
+
};
|
|
276
|
+
(0, utils_1.print)(pages, onDone, onError);
|
|
277
|
+
}, [pages, error]);
|
|
278
|
+
const onAdd = React.useCallback((e) => {
|
|
279
|
+
const st = e.newState;
|
|
280
|
+
if (st[0] && st[0].getRawFile) {
|
|
281
|
+
const file = st[0].getRawFile();
|
|
282
|
+
file.arrayBuffer().then((arrayBuffer) => {
|
|
283
|
+
if (pagesRef.current) {
|
|
284
|
+
setLoading(true);
|
|
285
|
+
(0, utils_1.removeChildren)(pagesRef.current);
|
|
286
|
+
(0, utils_1.loadPDF)({
|
|
287
|
+
arrayBuffer,
|
|
288
|
+
dom: pagesRef.current,
|
|
289
|
+
zoom: utils_1.DEFAULT_ZOOM_LEVEL,
|
|
290
|
+
done,
|
|
291
|
+
error
|
|
292
|
+
});
|
|
293
|
+
setZoom(utils_1.DEFAULT_ZOOM_LEVEL);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}, [error]);
|
|
298
|
+
const onFileOpen = React.useCallback((e) => {
|
|
299
|
+
const targetEl = e.target;
|
|
300
|
+
if (targetEl instanceof HTMLElement && targetEl.parentNode) {
|
|
301
|
+
const toolbarEl = targetEl.closest('.k-toolbar');
|
|
302
|
+
const input = toolbarEl && toolbarEl.querySelector('.k-upload input');
|
|
303
|
+
if (input) {
|
|
304
|
+
input.click();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}, []);
|
|
308
|
+
const noDocument = !doc;
|
|
309
|
+
const loader = (loading && React.createElement("div", { className: "k-loader-container k-loader-container-md k-loader-top" },
|
|
310
|
+
React.createElement("div", { className: "k-loader-container-overlay k-overlay-light" }),
|
|
311
|
+
React.createElement("div", { className: "k-loader-container-inner " },
|
|
312
|
+
React.createElement(kendo_react_indicators_1.Loader, { size: 'large' }))));
|
|
313
|
+
const toolbar = (React.createElement(kendo_react_buttons_1.Toolbar, { buttons: navigation },
|
|
314
|
+
React.createElement(kendo_react_data_tools_1.Pager, { previousNext: true, type: 'input', skip: skip, take: 1, total: pages.length, info: false, onPageChange: onPageChange }),
|
|
315
|
+
React.createElement(kendo_react_buttons_1.ToolbarSpacer, null),
|
|
316
|
+
React.createElement(kendo_react_buttons_1.ButtonGroup, null,
|
|
317
|
+
React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.zoomIn, messages_1.messages[messages_1.zoomIn]), disabled: zoom === zoomMax || noDocument, onClick: onZoomIn, icon: 'zoom-in' }),
|
|
318
|
+
React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.zoomOut, messages_1.messages[messages_1.zoomOut]), disabled: zoom === zoomMin || noDocument, onClick: onZoomOut, icon: 'zoom-out' })),
|
|
319
|
+
React.createElement(kendo_react_dropdowns_1.ComboBox, { disabled: noDocument, data: (props.zoomLevels || zoomLevels).map(level => (Object.assign(Object.assign({}, level), { text: level.locationString
|
|
320
|
+
? loc.toLanguageString(level.locationString, messages_1.messages[level.locationString])
|
|
321
|
+
: level.text }))), dataItemKey: 'id', textField: 'text', value: noDocument ? null : zoomLevel, onChange: onZoomLevelChange }),
|
|
322
|
+
React.createElement(kendo_react_buttons_1.ButtonGroup, null,
|
|
323
|
+
React.createElement(kendo_react_buttons_1.Button, { className: 'k-toolbar-button', title: loc.toLanguageString(messages_1.enableSelection, messages_1.messages[messages_1.enableSelection]), icon: 'cursor', disabled: noDocument, togglable: true, selected: enabledSelection && !noDocument, onClick: onTextSelection }),
|
|
324
|
+
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', disabled: noDocument, togglable: true, selected: !enabledSelection && !noDocument, onClick: onPinning })),
|
|
325
|
+
React.createElement(kendo_react_buttons_1.ToolbarSpacer, null),
|
|
326
|
+
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', disabled: noDocument, onClick: onSearch }),
|
|
327
|
+
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', onClick: onFileOpen }),
|
|
328
|
+
React.createElement("div", { style: { display: 'none' } },
|
|
329
|
+
React.createElement(kendo_react_upload_1.Upload, { restrictions: { allowedExtensions: ['.pdf'] }, onAdd: onAdd, autoUpload: false, defaultFiles: [], multiple: false, accept: ".pdf,.PDF", withCredentials: false })),
|
|
330
|
+
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', disabled: noDocument, onClick: onDownload }),
|
|
331
|
+
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', disabled: noDocument, onClick: onPrint })));
|
|
332
|
+
const content = (React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto', {
|
|
333
|
+
'k-enable-text-select': enabledSelection,
|
|
334
|
+
'k-enable-panning': !enabledSelection
|
|
335
|
+
}), onScroll: onScroll },
|
|
336
|
+
showSearch && (React.createElement("div", { className: 'k-search-panel k-pos-sticky k-top-center' },
|
|
337
|
+
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,
|
|
338
|
+
React.createElement(kendo_react_buttons_1.Button, { icon: "convert-lowercase", title: loc.toLanguageString(messages_1.matchCase, messages_1.messages[messages_1.matchCase]), fillMode: "flat", togglable: true, selected: matchCase, onClick: onMatchCaseClick }))) }),
|
|
339
|
+
React.createElement("span", { className: "k-search-matches" },
|
|
340
|
+
React.createElement("span", null, currentMatch),
|
|
341
|
+
" of ",
|
|
342
|
+
React.createElement("span", null, matches)),
|
|
343
|
+
React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.prevMatch, messages_1.messages[messages_1.prevMatch]), fillMode: 'flat', icon: 'arrow-up', disabled: matches === 0, onClick: onPrevMatch }),
|
|
344
|
+
React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.nextMatch, messages_1.messages[messages_1.nextMatch]), fillMode: 'flat', icon: 'arrow-down', disabled: matches === 0, onClick: onNextMatch }),
|
|
345
|
+
React.createElement(kendo_react_buttons_1.Button, { title: loc.toLanguageString(messages_1.close, messages_1.messages[messages_1.close]), fillMode: 'flat', icon: 'close', onClick: onClose }))),
|
|
346
|
+
React.createElement("div", { ref: pagesRef, className: 'k-pdf-viewer-pages' })));
|
|
347
|
+
return (React.createElement("div", { className: 'k-pdf-viewer', style: props.style, ref: pdfViewerRef },
|
|
348
|
+
props.onRenderLoader ? props.onRenderLoader.call(undefined, loader || null) : loader,
|
|
349
|
+
props.onRenderToolbar ? props.onRenderToolbar.call(undefined, toolbar) : toolbar,
|
|
350
|
+
props.onRenderContent ? props.onRenderContent.call(undefined, content) : content));
|
|
351
|
+
});
|
|
352
|
+
exports.PDFViewer.displayName = 'KendoReactPDFViewer';
|
|
353
|
+
exports.PDFViewer.propTypes = {
|
|
354
|
+
url: PropTypes.string,
|
|
355
|
+
data: PropTypes.string,
|
|
356
|
+
arrayBuffer: PropTypes.any,
|
|
357
|
+
typedArray: PropTypes.any,
|
|
358
|
+
style: PropTypes.object,
|
|
359
|
+
saveFileName: PropTypes.string,
|
|
360
|
+
saveOptions: PropTypes.object,
|
|
361
|
+
zoomLevels: PropTypes.arrayOf(PropTypes.any),
|
|
362
|
+
onError: PropTypes.func,
|
|
363
|
+
onLoad: PropTypes.func,
|
|
364
|
+
onDownload: PropTypes.func,
|
|
365
|
+
onRenderToolbar: PropTypes.func,
|
|
366
|
+
onRenderContent: PropTypes.func,
|
|
367
|
+
onRenderLoader: PropTypes.func
|
|
368
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PDFViewer, PDFViewerProps, PDFViewerHandle, LoadEvent, ErrorEvent, DownloadEvent } from './PDFViewer';
|
package/dist/npm/main.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PDFViewer = void 0;
|
|
4
|
+
var PDFViewer_1 = require("./PDFViewer");
|
|
5
|
+
Object.defineProperty(exports, "PDFViewer", { enumerable: true, get: function () { return PDFViewer_1.PDFViewer; } });
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.messages = exports.popupBlocked = exports.fitToPage = exports.fitToWidth = exports.actualWidth = exports.nextMatch = exports.prevMatch = exports.matchCase = exports.close = exports.print = exports.download = exports.open = exports.search = exports.enablePanning = exports.enableSelection = exports.zoomOut = exports.zoomIn = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
exports.zoomIn = 'pdfviewer.zoomIn';
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
exports.zoomOut = 'pdfviewer.zoomOut';
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
exports.enableSelection = 'pdfviewer.enableSelection';
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
exports.enablePanning = 'pdfviewer.enablePanning';
|
|
20
|
+
/**
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
23
|
+
exports.search = 'pdfviewer.search';
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
exports.open = 'pdfviewer.open';
|
|
28
|
+
/**
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
exports.download = 'pdfviewer.download';
|
|
32
|
+
/**
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
exports.print = 'pdfviewer.print';
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
exports.close = 'pdfviewer.close';
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
43
|
+
exports.matchCase = 'pdfviewer.matchCase';
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
exports.prevMatch = 'pdfviewer.prevMatch';
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
exports.nextMatch = 'pdfviewer.nextMatch';
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
exports.actualWidth = 'pdfviewer.actualWidth';
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
exports.fitToWidth = 'pdfviewer.fitToWidth';
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
*/
|
|
63
|
+
exports.fitToPage = 'pdfviewer.fitToPage';
|
|
64
|
+
/**
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
67
|
+
exports.popupBlocked = 'pdfviewer.popupBlocked';
|
|
68
|
+
/**
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
71
|
+
exports.messages = {
|
|
72
|
+
[exports.zoomIn]: 'Zoom in',
|
|
73
|
+
[exports.zoomOut]: 'Zoom out',
|
|
74
|
+
[exports.enableSelection]: 'Enable selection',
|
|
75
|
+
[exports.enablePanning]: 'Enable panning',
|
|
76
|
+
[exports.search]: 'Search',
|
|
77
|
+
[exports.open]: 'Open',
|
|
78
|
+
[exports.download]: 'Download',
|
|
79
|
+
[exports.print]: 'Print',
|
|
80
|
+
[exports.close]: 'Close',
|
|
81
|
+
[exports.matchCase]: 'Match case',
|
|
82
|
+
[exports.prevMatch]: 'Previous match',
|
|
83
|
+
[exports.nextMatch]: 'Next match',
|
|
84
|
+
[exports.actualWidth]: 'Actual width',
|
|
85
|
+
[exports.fitToWidth]: 'Fit to width',
|
|
86
|
+
[exports.fitToPage]: 'Fit to page',
|
|
87
|
+
[exports.popupBlocked]: 'Popup is blocked.'
|
|
88
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageMetadata = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
exports.packageMetadata = {
|
|
8
|
+
name: '@progress/kendo-react-pdf-viewer',
|
|
9
|
+
productName: 'KendoReact',
|
|
10
|
+
productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
|
|
11
|
+
publishDate: 1669290352,
|
|
12
|
+
version: '',
|
|
13
|
+
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'
|
|
14
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
export declare class Scroller {
|
|
5
|
+
options: any;
|
|
6
|
+
state: any;
|
|
7
|
+
element: any;
|
|
8
|
+
throttledOnDrag: any;
|
|
9
|
+
draggable: any;
|
|
10
|
+
throttledOnElementScroll: any;
|
|
11
|
+
constructor(element: any, options: any);
|
|
12
|
+
destroy(): void;
|
|
13
|
+
initDraggable(): void;
|
|
14
|
+
destroyDraggable(): void;
|
|
15
|
+
bindEvents(): void;
|
|
16
|
+
bindDraggableEvents(): void;
|
|
17
|
+
bindElementScroll(): void;
|
|
18
|
+
unbindEvents(): void;
|
|
19
|
+
unbindDraggableEvents(): void;
|
|
20
|
+
unbindElementScroll(): void;
|
|
21
|
+
setState(newState: any): void;
|
|
22
|
+
resetState(): void;
|
|
23
|
+
enablePanEventsTracking(): void;
|
|
24
|
+
disablePanEventsTracking(): void;
|
|
25
|
+
shouldTrackPanEvents(): any;
|
|
26
|
+
onElementScroll: () => void;
|
|
27
|
+
OnDragStart: (e: any) => void;
|
|
28
|
+
onDrag: (e: any) => void;
|
|
29
|
+
onDragEnd: () => void;
|
|
30
|
+
calculateEventLocationDelta(e: any): void;
|
|
31
|
+
scrollTo(x: any, y: any, options?: {
|
|
32
|
+
trackScrollEvent: boolean;
|
|
33
|
+
}): void;
|
|
34
|
+
}
|