react-pdfjs-multi 0.5.0 → 1.0.0-rc.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.
Files changed (54) hide show
  1. package/README.md +154 -34
  2. package/dist/assets/secondaryToolbarButton-rotateCcw.png +0 -0
  3. package/dist/assets/secondaryToolbarButton-rotateCcw@2x.png +0 -0
  4. package/dist/assets/secondaryToolbarButton-rotateCw.png +0 -0
  5. package/dist/assets/secondaryToolbarButton-rotateCw@2x.png +0 -0
  6. package/dist/assets/texture.png +0 -0
  7. package/dist/assets/toolbarButton-download.png +0 -0
  8. package/dist/assets/toolbarButton-download@2x.png +0 -0
  9. package/dist/assets/toolbarButton-menuArrows.png +0 -0
  10. package/dist/assets/toolbarButton-sidebarToggle.png +0 -0
  11. package/dist/assets/toolbarButton-sidebarToggle@2x.png +0 -0
  12. package/dist/assets/toolbarButton-zoomIn.png +0 -0
  13. package/dist/assets/toolbarButton-zoomIn@2x.png +0 -0
  14. package/dist/assets/toolbarButton-zoomOut.png +0 -0
  15. package/dist/assets/toolbarButton-zoomOut@2x.png +0 -0
  16. package/dist/components/PdfMultiViewer/PdfMultiViewer.d.ts +19 -0
  17. package/dist/components/PdfMultiViewer/PdfMultiViewerView.d.ts +20 -0
  18. package/dist/components/PdfMultiViewer/index.d.ts +4 -0
  19. package/dist/components/PdfMultiViewer/usePdfMultiViewer.d.ts +44 -0
  20. package/dist/components/PdfRenderer/PdfRenderer.d.ts +28 -0
  21. package/dist/{PdfRendererControls.d.ts → components/PdfRenderer/PdfRendererControls.d.ts} +14 -15
  22. package/dist/components/PdfRenderer/PdfRendererView.d.ts +20 -0
  23. package/dist/components/PdfRenderer/ZoomSelectBox.d.ts +9 -0
  24. package/dist/components/PdfRenderer/index.d.ts +7 -0
  25. package/dist/components/PdfRenderer/usePdfRenderer.d.ts +32 -0
  26. package/dist/components/index.d.ts +2 -0
  27. package/dist/{I18nContext.d.ts → contexts/I18nContext.d.ts} +12 -12
  28. package/dist/contexts/index.d.ts +1 -0
  29. package/dist/index.css +6 -0
  30. package/dist/index.css.map +1 -0
  31. package/dist/index.d.ts +6 -5
  32. package/dist/index.js +816 -1820
  33. package/dist/index.js.map +1 -0
  34. package/dist/index.mjs +826 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/lib/filenameHelper.d.ts +1 -1
  37. package/dist/lib/iconStyles.d.ts +3 -0
  38. package/dist/lib/index.d.ts +2 -0
  39. package/dist/lib/pdfjsLib.d.ts +2 -0
  40. package/dist/lib/resizeAutoZoomEvent.d.ts +0 -1
  41. package/dist/pdf.worker.min.mjs +28 -0
  42. package/dist/pdfjsLib-DFD5U54F.js +9 -0
  43. package/dist/pdfjsLib-DgdIcD_k.mjs +8 -0
  44. package/dist/pdfjsLib-DgdIcD_k.mjs.map +1 -0
  45. package/dist/pdfjsLib-cEuHH6WZ.mjs +3 -0
  46. package/dist/pdfjsLib-z4sS0gWp.js +41 -0
  47. package/dist/pdfjsLib-z4sS0gWp.js.map +1 -0
  48. package/dist/react-pdfjs-multi.css +4 -5
  49. package/dist/types/iconConfig.d.ts +10 -0
  50. package/package.json +46 -70
  51. package/dist/PdfMultiViewer.d.ts +0 -57
  52. package/dist/PdfRenderer.d.ts +0 -56
  53. package/dist/ZoomSelectBox.d.ts +0 -32
  54. package/dist/index.es.js +0 -1830
package/dist/index.js CHANGED
@@ -1,1839 +1,835 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = require('react');
8
- var React__default = _interopDefault(React);
9
-
10
- /*! *****************************************************************************
11
- Copyright (c) Microsoft Corporation. All rights reserved.
12
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
13
- this file except in compliance with the License. You may obtain a copy of the
14
- License at http://www.apache.org/licenses/LICENSE-2.0
15
-
16
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
18
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
19
- MERCHANTABLITY OR NON-INFRINGEMENT.
20
-
21
- See the Apache Version 2.0 License for specific language governing permissions
22
- and limitations under the License.
23
- ***************************************************************************** */
24
- /* global Reflect, Promise */
25
-
26
- var extendStatics = function(d, b) {
27
- extendStatics = Object.setPrototypeOf ||
28
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30
- return extendStatics(d, b);
31
- };
32
-
33
- function __extends(d, b) {
34
- extendStatics(d, b);
35
- function __() { this.constructor = d; }
36
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
- }
38
-
39
- var __assign = function() {
40
- __assign = Object.assign || function __assign(t) {
41
- for (var s, i = 1, n = arguments.length; i < n; i++) {
42
- s = arguments[i];
43
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
-
50
- function __awaiter(thisArg, _arguments, P, generator) {
51
- return new (P || (P = Promise))(function (resolve, reject) {
52
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
53
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
54
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
55
- step((generator = generator.apply(thisArg, _arguments || [])).next());
56
- });
57
- }
58
-
59
- function __generator(thisArg, body) {
60
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
61
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
62
- function verb(n) { return function (v) { return step([n, v]); }; }
63
- function step(op) {
64
- if (f) throw new TypeError("Generator is already executing.");
65
- while (_) try {
66
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
67
- if (y = 0, t) op = [op[0] & 2, t.value];
68
- switch (op[0]) {
69
- case 0: case 1: t = op; break;
70
- case 4: _.label++; return { value: op[1], done: false };
71
- case 5: _.label++; y = op[1]; op = [0]; continue;
72
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
73
- default:
74
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
75
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
76
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
77
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
78
- if (t[2]) _.ops.pop();
79
- _.trys.pop(); continue;
80
- }
81
- op = body.call(thisArg, _);
82
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
83
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
84
- }
85
- }
86
-
87
- function unwrapExports (x) {
88
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
89
- }
90
-
91
- function createCommonjsModule(fn, module) {
92
- return module = { exports: {} }, fn(module, module.exports), module.exports;
93
- }
94
-
95
- var reactIs_production_min = createCommonjsModule(function (module, exports) {
96
- Object.defineProperty(exports,"__esModule",{value:!0});
97
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
98
- 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118,x=b?Symbol.for("react.scope"):60119;function y(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function z(a){return y(a)===m}
99
- exports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
100
- exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};
101
- exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};
102
- });
103
-
104
- unwrapExports(reactIs_production_min);
105
- var reactIs_production_min_1 = reactIs_production_min.typeOf;
106
- var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
107
- var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
108
- var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
109
- var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
110
- var reactIs_production_min_6 = reactIs_production_min.Element;
111
- var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
112
- var reactIs_production_min_8 = reactIs_production_min.Fragment;
113
- var reactIs_production_min_9 = reactIs_production_min.Lazy;
114
- var reactIs_production_min_10 = reactIs_production_min.Memo;
115
- var reactIs_production_min_11 = reactIs_production_min.Portal;
116
- var reactIs_production_min_12 = reactIs_production_min.Profiler;
117
- var reactIs_production_min_13 = reactIs_production_min.StrictMode;
118
- var reactIs_production_min_14 = reactIs_production_min.Suspense;
119
- var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
120
- var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
121
- var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
122
- var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
123
- var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
124
- var reactIs_production_min_20 = reactIs_production_min.isElement;
125
- var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
126
- var reactIs_production_min_22 = reactIs_production_min.isFragment;
127
- var reactIs_production_min_23 = reactIs_production_min.isLazy;
128
- var reactIs_production_min_24 = reactIs_production_min.isMemo;
129
- var reactIs_production_min_25 = reactIs_production_min.isPortal;
130
- var reactIs_production_min_26 = reactIs_production_min.isProfiler;
131
- var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
132
- var reactIs_production_min_28 = reactIs_production_min.isSuspense;
133
-
134
- var reactIs_development = createCommonjsModule(function (module, exports) {
135
-
136
-
137
-
138
- if (process.env.NODE_ENV !== "production") {
139
- (function() {
140
-
141
- Object.defineProperty(exports, '__esModule', { value: true });
142
-
143
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
144
- // nor polyfill, then a plain number is used for performance.
145
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
146
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
147
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
148
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
149
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
150
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
151
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
152
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
153
- // (unstable) APIs that have been removed. Can we remove the symbols?
154
-
155
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
156
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
157
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
158
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
159
- var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
160
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
161
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
162
- var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
163
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
164
- var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
165
-
166
- function isValidElementType(type) {
167
- return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
168
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
169
- }
170
-
171
- /**
172
- * Forked from fbjs/warning:
173
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
174
- *
175
- * Only change is we use console.warn instead of console.error,
176
- * and do nothing when 'console' is not supported.
177
- * This really simplifies the code.
178
- * ---
179
- * Similar to invariant but only logs a warning if the condition is not met.
180
- * This can be used to log issues in development environments in critical
181
- * paths. Removing the logging code for production environments will keep the
182
- * same logic and follow the same code paths.
183
- */
184
- var lowPriorityWarningWithoutStack = function () {};
185
-
186
- {
187
- var printWarning = function (format) {
188
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
189
- args[_key - 1] = arguments[_key];
190
- }
191
-
192
- var argIndex = 0;
193
- var message = 'Warning: ' + format.replace(/%s/g, function () {
194
- return args[argIndex++];
195
- });
196
-
197
- if (typeof console !== 'undefined') {
198
- console.warn(message);
199
- }
200
-
201
- try {
202
- // --- Welcome to debugging React ---
203
- // This error was thrown as a convenience so that you can use this stack
204
- // to find the callsite that caused this warning to fire.
205
- throw new Error(message);
206
- } catch (x) {}
207
- };
208
-
209
- lowPriorityWarningWithoutStack = function (condition, format) {
210
- if (format === undefined) {
211
- throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
212
- }
213
-
214
- if (!condition) {
215
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
216
- args[_key2 - 2] = arguments[_key2];
217
- }
218
-
219
- printWarning.apply(void 0, [format].concat(args));
220
- }
221
- };
222
- }
223
-
224
- var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
225
-
226
- function typeOf(object) {
227
- if (typeof object === 'object' && object !== null) {
228
- var $$typeof = object.$$typeof;
229
-
230
- switch ($$typeof) {
231
- case REACT_ELEMENT_TYPE:
232
- var type = object.type;
233
-
234
- switch (type) {
235
- case REACT_ASYNC_MODE_TYPE:
236
- case REACT_CONCURRENT_MODE_TYPE:
237
- case REACT_FRAGMENT_TYPE:
238
- case REACT_PROFILER_TYPE:
239
- case REACT_STRICT_MODE_TYPE:
240
- case REACT_SUSPENSE_TYPE:
241
- return type;
242
-
243
- default:
244
- var $$typeofType = type && type.$$typeof;
245
-
246
- switch ($$typeofType) {
247
- case REACT_CONTEXT_TYPE:
248
- case REACT_FORWARD_REF_TYPE:
249
- case REACT_PROVIDER_TYPE:
250
- return $$typeofType;
251
-
252
- default:
253
- return $$typeof;
254
- }
255
-
256
- }
257
-
258
- case REACT_LAZY_TYPE:
259
- case REACT_MEMO_TYPE:
260
- case REACT_PORTAL_TYPE:
261
- return $$typeof;
262
- }
263
- }
264
-
265
- return undefined;
266
- } // AsyncMode is deprecated along with isAsyncMode
267
-
268
- var AsyncMode = REACT_ASYNC_MODE_TYPE;
269
- var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
270
- var ContextConsumer = REACT_CONTEXT_TYPE;
271
- var ContextProvider = REACT_PROVIDER_TYPE;
272
- var Element = REACT_ELEMENT_TYPE;
273
- var ForwardRef = REACT_FORWARD_REF_TYPE;
274
- var Fragment = REACT_FRAGMENT_TYPE;
275
- var Lazy = REACT_LAZY_TYPE;
276
- var Memo = REACT_MEMO_TYPE;
277
- var Portal = REACT_PORTAL_TYPE;
278
- var Profiler = REACT_PROFILER_TYPE;
279
- var StrictMode = REACT_STRICT_MODE_TYPE;
280
- var Suspense = REACT_SUSPENSE_TYPE;
281
- var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
282
-
283
- function isAsyncMode(object) {
284
- {
285
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
286
- hasWarnedAboutDeprecatedIsAsyncMode = true;
287
- lowPriorityWarningWithoutStack$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
288
- }
289
- }
290
-
291
- return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
292
- }
293
- function isConcurrentMode(object) {
294
- return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
295
- }
296
- function isContextConsumer(object) {
297
- return typeOf(object) === REACT_CONTEXT_TYPE;
298
- }
299
- function isContextProvider(object) {
300
- return typeOf(object) === REACT_PROVIDER_TYPE;
301
- }
302
- function isElement(object) {
303
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
304
- }
305
- function isForwardRef(object) {
306
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
307
- }
308
- function isFragment(object) {
309
- return typeOf(object) === REACT_FRAGMENT_TYPE;
310
- }
311
- function isLazy(object) {
312
- return typeOf(object) === REACT_LAZY_TYPE;
313
- }
314
- function isMemo(object) {
315
- return typeOf(object) === REACT_MEMO_TYPE;
316
- }
317
- function isPortal(object) {
318
- return typeOf(object) === REACT_PORTAL_TYPE;
319
- }
320
- function isProfiler(object) {
321
- return typeOf(object) === REACT_PROFILER_TYPE;
322
- }
323
- function isStrictMode(object) {
324
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
325
- }
326
- function isSuspense(object) {
327
- return typeOf(object) === REACT_SUSPENSE_TYPE;
328
- }
1
+ const require_pdfjsLib = require('./pdfjsLib-z4sS0gWp.js');
2
+ let react = require("react");
3
+ react = require_pdfjsLib.__toESM(react);
4
+ require("pdfjs-dist/web/pdf_viewer.css");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let pdfjs_dist_build_pdf_mjs = require("pdfjs-dist/build/pdf.mjs");
7
+
8
+ //#region src/lib/resizeAutoZoomEvent.ts
9
+ (() => {
10
+ const throttle = (type, name) => {
11
+ let running = false;
12
+ const func = () => {
13
+ if (running) return;
14
+ running = true;
15
+ requestAnimationFrame(() => {
16
+ window.dispatchEvent(new Event(name));
17
+ running = false;
18
+ });
19
+ };
20
+ window.addEventListener(type, func);
21
+ };
22
+ throttle("resize", "resizeAutoZoom");
23
+ })();
329
24
 
330
- exports.typeOf = typeOf;
331
- exports.AsyncMode = AsyncMode;
332
- exports.ConcurrentMode = ConcurrentMode;
333
- exports.ContextConsumer = ContextConsumer;
334
- exports.ContextProvider = ContextProvider;
335
- exports.Element = Element;
336
- exports.ForwardRef = ForwardRef;
337
- exports.Fragment = Fragment;
338
- exports.Lazy = Lazy;
339
- exports.Memo = Memo;
340
- exports.Portal = Portal;
341
- exports.Profiler = Profiler;
342
- exports.StrictMode = StrictMode;
343
- exports.Suspense = Suspense;
344
- exports.isValidElementType = isValidElementType;
345
- exports.isAsyncMode = isAsyncMode;
346
- exports.isConcurrentMode = isConcurrentMode;
347
- exports.isContextConsumer = isContextConsumer;
348
- exports.isContextProvider = isContextProvider;
349
- exports.isElement = isElement;
350
- exports.isForwardRef = isForwardRef;
351
- exports.isFragment = isFragment;
352
- exports.isLazy = isLazy;
353
- exports.isMemo = isMemo;
354
- exports.isPortal = isPortal;
355
- exports.isProfiler = isProfiler;
356
- exports.isStrictMode = isStrictMode;
357
- exports.isSuspense = isSuspense;
358
- })();
359
- }
25
+ //#endregion
26
+ //#region src/contexts/I18nContext.tsx
27
+ const defaultI18n = {
28
+ zoom: "Automatic zoom",
29
+ originalSize: "Original size",
30
+ scaleUp: "Scale up",
31
+ scaleDown: "Scale down",
32
+ rotateLeft: "Rotate left",
33
+ rotateRight: "Rotate right",
34
+ download: "Download"
35
+ };
36
+ const I18nContext = react.default.createContext(defaultI18n);
37
+
38
+ //#endregion
39
+ //#region src/components/PdfRenderer/ZoomSelectBox.tsx
40
+ const createSelectOptions = ({ originalSize, zoom }) => [
41
+ {
42
+ id: "automated",
43
+ text: `${zoom}`
44
+ },
45
+ {
46
+ id: "50-percent",
47
+ text: "50%",
48
+ value: 50
49
+ },
50
+ {
51
+ id: "75-percent",
52
+ text: "75%",
53
+ value: 75
54
+ },
55
+ {
56
+ id: "original",
57
+ text: `${originalSize} (100%)`,
58
+ value: 100
59
+ },
60
+ {
61
+ id: "125-percent",
62
+ text: "125%",
63
+ value: 125
64
+ },
65
+ {
66
+ id: "150-percent",
67
+ text: "150%",
68
+ value: 150
69
+ },
70
+ {
71
+ id: "200-percent",
72
+ text: "200%",
73
+ value: 200
74
+ },
75
+ {
76
+ id: "300-percent",
77
+ text: "300%",
78
+ value: 300
79
+ },
80
+ {
81
+ id: "400-percent",
82
+ text: "400%",
83
+ value: 400
84
+ },
85
+ { id: "calculated" }
86
+ ];
87
+ const showCalculatedScale = (scale, i18nData) => {
88
+ return createSelectOptions(i18nData).filter((option) => option.value === scale).length === 0 && scale % 10 === 0 ? scale : 0;
89
+ };
90
+ const ZoomSelectBox = ({ autoZoom, scale, setScale }) => {
91
+ const i18nData = (0, react.useContext)(I18nContext);
92
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
93
+ className: "dropdown-toolbar-container",
94
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
95
+ className: "dropdown-toolbar",
96
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
97
+ value: scale,
98
+ onChange: (e) => {
99
+ setScale(parseInt(e.target.value, 10));
100
+ },
101
+ children: createSelectOptions(i18nData).map(({ id, text, value }) => {
102
+ switch (id) {
103
+ case "calculated": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
104
+ value: showCalculatedScale(scale, i18nData),
105
+ hidden: true,
106
+ disabled: true,
107
+ children: `${scale}%`
108
+ }, `${id}-${scale}`);
109
+ case "automated": return autoZoom && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
110
+ value: -1,
111
+ children: text
112
+ }, `${id}-${scale}`);
113
+ default: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
114
+ value,
115
+ children: text
116
+ }, id);
117
+ }
118
+ })
119
+ })
120
+ })
121
+ });
122
+ };
123
+ var ZoomSelectBox_default = ZoomSelectBox;
124
+
125
+ //#endregion
126
+ //#region src/components/PdfRenderer/PdfRendererControls.tsx
127
+ const PdfControls = ({ autoZoom, downloadBtn, onDownload, onZoomIn, onZoomOut, onRotateRight, onRotateLeft, scale, setScale }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
128
+ className: "renderer-controls",
129
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
130
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(I18nContext.Consumer, { children: ({ scaleDown, scaleUp }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
131
+ className: "button-group",
132
+ children: [
133
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
134
+ className: "renderer-controls-button",
135
+ type: "button",
136
+ onClick: onZoomOut,
137
+ "aria-label": scaleDown,
138
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
139
+ className: "zoom-out-label",
140
+ "aria-hidden": "true"
141
+ })
142
+ }),
143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "split-button-seperator" }),
144
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
145
+ className: "renderer-controls-button",
146
+ type: "button",
147
+ onClick: onZoomIn,
148
+ "aria-label": scaleUp,
149
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
150
+ className: "zoom-in-label",
151
+ "aria-hidden": "true"
152
+ })
153
+ })
154
+ ]
155
+ }) }),
156
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomSelectBox_default, {
157
+ autoZoom,
158
+ scale,
159
+ setScale
160
+ }),
161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(I18nContext.Consumer, { children: ({ rotateLeft, rotateRight, download }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
162
+ className: "button-group",
163
+ children: [
164
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
165
+ className: "renderer-controls-button",
166
+ type: "button",
167
+ onClick: onRotateLeft,
168
+ "aria-label": rotateLeft,
169
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
170
+ className: "rotate-left-label",
171
+ "aria-hidden": "true"
172
+ })
173
+ }),
174
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "split-button-seperator" }),
175
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
176
+ className: "renderer-controls-button",
177
+ type: "button",
178
+ onClick: onRotateRight,
179
+ "aria-label": rotateRight,
180
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
181
+ className: "rotate-right-label",
182
+ "aria-hidden": "true"
183
+ })
184
+ })
185
+ ]
186
+ }), downloadBtn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
187
+ className: "button-group",
188
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
189
+ className: "renderer-controls-button",
190
+ type: "button",
191
+ onClick: onDownload,
192
+ "aria-label": download,
193
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
194
+ className: "download-label",
195
+ "aria-hidden": "true"
196
+ })
197
+ })
198
+ })] }) })
199
+ ] })
360
200
  });
361
-
362
- unwrapExports(reactIs_development);
363
- var reactIs_development_1 = reactIs_development.typeOf;
364
- var reactIs_development_2 = reactIs_development.AsyncMode;
365
- var reactIs_development_3 = reactIs_development.ConcurrentMode;
366
- var reactIs_development_4 = reactIs_development.ContextConsumer;
367
- var reactIs_development_5 = reactIs_development.ContextProvider;
368
- var reactIs_development_6 = reactIs_development.Element;
369
- var reactIs_development_7 = reactIs_development.ForwardRef;
370
- var reactIs_development_8 = reactIs_development.Fragment;
371
- var reactIs_development_9 = reactIs_development.Lazy;
372
- var reactIs_development_10 = reactIs_development.Memo;
373
- var reactIs_development_11 = reactIs_development.Portal;
374
- var reactIs_development_12 = reactIs_development.Profiler;
375
- var reactIs_development_13 = reactIs_development.StrictMode;
376
- var reactIs_development_14 = reactIs_development.Suspense;
377
- var reactIs_development_15 = reactIs_development.isValidElementType;
378
- var reactIs_development_16 = reactIs_development.isAsyncMode;
379
- var reactIs_development_17 = reactIs_development.isConcurrentMode;
380
- var reactIs_development_18 = reactIs_development.isContextConsumer;
381
- var reactIs_development_19 = reactIs_development.isContextProvider;
382
- var reactIs_development_20 = reactIs_development.isElement;
383
- var reactIs_development_21 = reactIs_development.isForwardRef;
384
- var reactIs_development_22 = reactIs_development.isFragment;
385
- var reactIs_development_23 = reactIs_development.isLazy;
386
- var reactIs_development_24 = reactIs_development.isMemo;
387
- var reactIs_development_25 = reactIs_development.isPortal;
388
- var reactIs_development_26 = reactIs_development.isProfiler;
389
- var reactIs_development_27 = reactIs_development.isStrictMode;
390
- var reactIs_development_28 = reactIs_development.isSuspense;
391
-
392
- var reactIs = createCommonjsModule(function (module) {
393
-
394
- if (process.env.NODE_ENV === 'production') {
395
- module.exports = reactIs_production_min;
396
- } else {
397
- module.exports = reactIs_development;
398
- }
201
+ var PdfRendererControls_default = PdfControls;
202
+
203
+ //#endregion
204
+ //#region src/components/PdfRenderer/PdfRendererView.tsx
205
+ const PdfRendererView = ({ autoZoom, containerRef, controls, downloadBtn, iconStyles, i18nData, isLoading, scale, setScale, onDownload, onRotateLeft, onRotateRight, onZoomIn, onZoomOut }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
206
+ className: "pdfjs-multi renderer-container",
207
+ style: iconStyles,
208
+ children: [controls && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(I18nContext.Provider, {
209
+ value: {
210
+ ...defaultI18n,
211
+ ...i18nData ?? {}
212
+ },
213
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PdfRendererControls_default, {
214
+ autoZoom,
215
+ downloadBtn,
216
+ scale,
217
+ setScale,
218
+ onDownload,
219
+ onZoomIn,
220
+ onZoomOut,
221
+ onRotateRight,
222
+ onRotateLeft
223
+ })
224
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
225
+ className: "renderer-stage",
226
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
227
+ ref: containerRef,
228
+ className: `renderer-target-container ${!controls ? "no-controls" : ""} `,
229
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
230
+ id: "viewer",
231
+ className: `pdfViewer ${isLoading ? "hidden" : ""}`
232
+ })
233
+ })
234
+ })]
399
235
  });
400
-
401
- /*
402
- object-assign
403
- (c) Sindre Sorhus
404
- @license MIT
405
- */
406
- /* eslint-disable no-unused-vars */
407
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
408
- var hasOwnProperty = Object.prototype.hasOwnProperty;
409
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
410
-
411
- function toObject(val) {
412
- if (val === null || val === undefined) {
413
- throw new TypeError('Object.assign cannot be called with null or undefined');
236
+ var PdfRendererView_default = PdfRendererView;
237
+
238
+ //#endregion
239
+ //#region src/lib/filenameHelper.ts
240
+ const isDataSchema = (url) => {
241
+ let i = 0, ii = url.length;
242
+ while (i < ii && url[i].trim() === "") i++;
243
+ return url.substring(i, i + 5).toLowerCase() === "data:";
244
+ };
245
+ const getPDFFileNameFromURL = (url, defaultFilename = "document.pdf") => {
246
+ if (typeof url !== "string") return defaultFilename;
247
+ if (isDataSchema(url)) {
248
+ console.warn("getPDFFileNameFromURL: ignoring \"data:\" URL for performance reasons.");
249
+ return defaultFilename;
414
250
  }
251
+ const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
252
+ const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
253
+ const splitURI = reURI.exec(url);
254
+ let suggestedFilename = null;
255
+ if (splitURI) suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
256
+ if (suggestedFilename) {
257
+ suggestedFilename = suggestedFilename[0];
258
+ if (suggestedFilename.includes("%")) try {
259
+ const suggestedFilenameResult = reFilename.exec(decodeURIComponent(suggestedFilename));
260
+ if (suggestedFilenameResult) suggestedFilename = suggestedFilenameResult[0];
261
+ } catch (_ex) {}
262
+ }
263
+ return suggestedFilename || defaultFilename;
264
+ };
415
265
 
416
- return Object(val);
417
- }
418
-
419
- function shouldUseNative() {
420
- try {
421
- if (!Object.assign) {
422
- return false;
423
- }
424
-
425
- // Detect buggy property enumeration order in older V8 versions.
426
-
427
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
428
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
429
- test1[5] = 'de';
430
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
431
- return false;
432
- }
433
-
434
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
435
- var test2 = {};
436
- for (var i = 0; i < 10; i++) {
437
- test2['_' + String.fromCharCode(i)] = i;
438
- }
439
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
440
- return test2[n];
441
- });
442
- if (order2.join('') !== '0123456789') {
443
- return false;
266
+ //#endregion
267
+ //#region src/components/PdfRenderer/usePdfRenderer.ts
268
+ const SCALE = {
269
+ percent: 100,
270
+ min: 10,
271
+ max: 1e3,
272
+ roundTo: 10,
273
+ auto: -1,
274
+ default: 100
275
+ };
276
+ const AUTO_FIT = {
277
+ maxContainerWidth: 1020,
278
+ padding: 56,
279
+ fallbackWidth: 1019
280
+ };
281
+ const ZOOM = {
282
+ largeStepMin: 110,
283
+ largeStepMax: 990,
284
+ specialSteps: new Set([75, 125]),
285
+ roundingExceptions: new Set([125]),
286
+ stepLarge: 20,
287
+ stepDefault: 10,
288
+ stepSmall: 5
289
+ };
290
+ const ROTATION_STEP = 90;
291
+ const SCROLL_DEFAULT = 0;
292
+ const roundToNearest = (numToRound, numToRoundTo) => Math.round(numToRound / numToRoundTo) * numToRoundTo;
293
+ const usePdfRenderer = ({ activeIndex, autoZoom, pdfChangeHook, pdfDoc, rotation, scrollLeft, scrollTop, zoom }) => {
294
+ const containerRef = (0, react.useRef)(null);
295
+ const pdfViewerRef = (0, react.useRef)(null);
296
+ const downloadManagerRef = (0, react.useRef)(null);
297
+ const initialAutoZoomRef = (0, react.useRef)(autoZoom);
298
+ const latestPdfDocRef = (0, react.useRef)(pdfDoc);
299
+ const [scale, setScaleState] = (0, react.useState)(SCALE.default);
300
+ const [isLoading, setIsLoading] = (0, react.useState)(true);
301
+ const scaleRef = (0, react.useRef)(scale);
302
+ (0, react.useEffect)(() => {
303
+ scaleRef.current = scale;
304
+ }, [scale]);
305
+ (0, react.useEffect)(() => {
306
+ latestPdfDocRef.current = pdfDoc;
307
+ }, [pdfDoc]);
308
+ const applyScale = (0, react.useCallback)((nextScaleValue) => {
309
+ const nextScale = nextScaleValue >= SCALE.min ? nextScaleValue : SCALE.min;
310
+ setScaleState(nextScale);
311
+ if (pdfViewerRef.current) pdfViewerRef.current.currentScaleValue = String(nextScale / SCALE.percent);
312
+ }, []);
313
+ const autoFitScale = (0, react.useCallback)(() => {
314
+ const firstPage = pdfViewerRef.current?._pages?.[0];
315
+ if (!firstPage) return;
316
+ const originalWidth = firstPage.viewport.width / firstPage.scale;
317
+ const offsetWidth = containerRef.current?.offsetWidth;
318
+ const containerWidth = offsetWidth && offsetWidth < AUTO_FIT.maxContainerWidth ? offsetWidth - AUTO_FIT.padding : AUTO_FIT.fallbackWidth;
319
+ let nextScale = SCALE.auto;
320
+ if (containerRef.current) nextScale = Math.abs(containerWidth) / originalWidth;
321
+ applyScale(nextScale * SCALE.percent);
322
+ }, [applyScale]);
323
+ const setScale = (0, react.useCallback)((nextScaleValue) => {
324
+ if (autoZoom && nextScaleValue < 0) {
325
+ autoFitScale();
326
+ return;
444
327
  }
445
-
446
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
447
- var test3 = {};
448
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
449
- test3[letter] = letter;
450
- });
451
- if (Object.keys(Object.assign({}, test3)).join('') !==
452
- 'abcdefghijklmnopqrst') {
453
- return false;
328
+ applyScale(nextScaleValue);
329
+ }, [
330
+ applyScale,
331
+ autoFitScale,
332
+ autoZoom
333
+ ]);
334
+ const setScrollTop = (0, react.useCallback)((nextScrollTop) => {
335
+ if (containerRef.current) containerRef.current.scrollTop = nextScrollTop ?? SCROLL_DEFAULT;
336
+ }, []);
337
+ const setScrollLeft = (0, react.useCallback)((nextScrollLeft) => {
338
+ if (containerRef.current) containerRef.current.scrollLeft = nextScrollLeft ?? SCROLL_DEFAULT;
339
+ }, []);
340
+ const rePosition = (0, react.useCallback)(async () => {
341
+ if (!pdfViewerRef.current) return;
342
+ await pdfViewerRef.current.firstPagePromise;
343
+ if (rotation) pdfViewerRef.current.pagesRotation = rotation;
344
+ if (zoom) setScale(zoom);
345
+ else if (!zoom && autoZoom) autoFitScale();
346
+ if (typeof scrollTop !== "undefined") setScrollTop(scrollTop ?? null);
347
+ if (typeof scrollLeft !== "undefined") setScrollLeft(scrollLeft ?? null);
348
+ }, [
349
+ autoFitScale,
350
+ autoZoom,
351
+ rotation,
352
+ scrollLeft,
353
+ scrollTop,
354
+ setScale,
355
+ setScrollLeft,
356
+ setScrollTop,
357
+ zoom
358
+ ]);
359
+ const rePositionRef = (0, react.useRef)(rePosition);
360
+ (0, react.useEffect)(() => {
361
+ rePositionRef.current = rePosition;
362
+ }, [rePosition]);
363
+ (0, react.useEffect)(() => {
364
+ let cancelled = false;
365
+ const setupViewer = async () => {
366
+ const { PdfjsLib } = await Promise.resolve().then(() => require("./pdfjsLib-DFD5U54F.js"));
367
+ if (cancelled) return;
368
+ globalThis.pdfjsLib = PdfjsLib;
369
+ const { PDFViewer, DownloadManager, EventBus } = globalThis.__pdfjsViewer ?? await import("pdfjs-dist/web/pdf_viewer.mjs");
370
+ downloadManagerRef.current = new DownloadManager();
371
+ if (!containerRef.current) return;
372
+ pdfViewerRef.current = new PDFViewer({
373
+ container: containerRef.current,
374
+ eventBus: new EventBus()
375
+ });
376
+ pdfViewerRef.current.setDocument(latestPdfDocRef.current);
377
+ if (initialAutoZoomRef.current) window.addEventListener("resizeAutoZoom", autoFitScale);
378
+ await rePositionRef.current();
379
+ if (!cancelled) setIsLoading(false);
380
+ };
381
+ setupViewer();
382
+ return () => {
383
+ cancelled = true;
384
+ if (initialAutoZoomRef.current) window.removeEventListener("resizeAutoZoom", autoFitScale);
385
+ pdfViewerRef.current = null;
386
+ downloadManagerRef.current = null;
387
+ };
388
+ }, [autoFitScale]);
389
+ const prevPdfDocRef = (0, react.useRef)(pdfDoc);
390
+ const prevActiveIndexRef = (0, react.useRef)(activeIndex);
391
+ (0, react.useEffect)(() => {
392
+ if (!pdfViewerRef.current) {
393
+ prevPdfDocRef.current = pdfDoc;
394
+ prevActiveIndexRef.current = activeIndex;
395
+ return;
454
396
  }
455
-
456
- return true;
457
- } catch (err) {
458
- // We don't expect any of the above to throw, but better to be safe.
459
- return false;
460
- }
461
- }
462
-
463
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
464
- var from;
465
- var to = toObject(target);
466
- var symbols;
467
-
468
- for (var s = 1; s < arguments.length; s++) {
469
- from = Object(arguments[s]);
470
-
471
- for (var key in from) {
472
- if (hasOwnProperty.call(from, key)) {
473
- to[key] = from[key];
474
- }
397
+ if (prevPdfDocRef.current !== pdfDoc) {
398
+ if (typeof pdfChangeHook === "function") pdfChangeHook(String(prevActiveIndexRef.current), {
399
+ zoom: scaleRef.current,
400
+ rotation: pdfViewerRef.current.pagesRotation,
401
+ scrollTop: containerRef.current?.scrollTop ?? null,
402
+ scrollLeft: containerRef.current?.scrollLeft ?? null
403
+ });
404
+ pdfViewerRef.current.setDocument(pdfDoc);
405
+ rePosition();
475
406
  }
476
-
477
- if (getOwnPropertySymbols) {
478
- symbols = getOwnPropertySymbols(from);
479
- for (var i = 0; i < symbols.length; i++) {
480
- if (propIsEnumerable.call(from, symbols[i])) {
481
- to[symbols[i]] = from[symbols[i]];
482
- }
407
+ prevPdfDocRef.current = pdfDoc;
408
+ prevActiveIndexRef.current = activeIndex;
409
+ }, [
410
+ activeIndex,
411
+ pdfChangeHook,
412
+ pdfDoc,
413
+ rePosition
414
+ ]);
415
+ const zoomIn = (0, react.useCallback)(() => {
416
+ const nextScale = roundToNearest(scaleRef.current, SCALE.roundTo);
417
+ let newScale = nextScale;
418
+ if (nextScale >= ZOOM.largeStepMin && nextScale < ZOOM.largeStepMax) newScale = nextScale + ZOOM.stepLarge;
419
+ else if (ZOOM.specialSteps.has(nextScale)) newScale = nextScale + ZOOM.stepSmall;
420
+ else newScale = nextScale + ZOOM.stepDefault;
421
+ if (newScale > SCALE.max) return;
422
+ setScale(newScale);
423
+ }, [setScale]);
424
+ const zoomOut = (0, react.useCallback)(() => {
425
+ let nextScale = scaleRef.current;
426
+ nextScale = ZOOM.roundingExceptions.has(nextScale) ? nextScale : roundToNearest(nextScale, SCALE.roundTo);
427
+ let newScale = nextScale;
428
+ if (nextScale > ZOOM.largeStepMin && !ZOOM.specialSteps.has(nextScale)) newScale = nextScale - ZOOM.stepLarge;
429
+ else if (ZOOM.specialSteps.has(nextScale)) newScale = nextScale - ZOOM.stepSmall;
430
+ else newScale = nextScale - ZOOM.stepDefault;
431
+ if (newScale <= 0) return;
432
+ setScale(newScale);
433
+ }, [setScale]);
434
+ const rotateRight = (0, react.useCallback)(() => {
435
+ if (!pdfViewerRef.current) return;
436
+ const currentRotation = pdfViewerRef.current.pagesRotation;
437
+ pdfViewerRef.current.pagesRotation = currentRotation + ROTATION_STEP;
438
+ }, []);
439
+ const rotateLeft = (0, react.useCallback)(() => {
440
+ if (!pdfViewerRef.current) return;
441
+ const currentRotation = pdfViewerRef.current.pagesRotation;
442
+ pdfViewerRef.current.pagesRotation = currentRotation - ROTATION_STEP;
443
+ }, []);
444
+ return {
445
+ containerRef,
446
+ download: (0, react.useCallback)(async () => {
447
+ if (!downloadManagerRef.current) return;
448
+ const url = pdfDoc._transport?._params?.url;
449
+ let filename = getPDFFileNameFromURL(url ?? "");
450
+ if (typeof pdfDoc.getMetadata === "function") try {
451
+ const contentDispositionFilename = (await pdfDoc.getMetadata()).contentDispositionFilename;
452
+ if (typeof contentDispositionFilename === "string" && contentDispositionFilename.trim()) filename = contentDispositionFilename;
453
+ } catch (_error) {}
454
+ const downloadByUrl = () => {
455
+ if (!url) return;
456
+ downloadManagerRef.current.downloadUrl(url, filename);
457
+ };
458
+ try {
459
+ const data = await pdfDoc.getData();
460
+ downloadManagerRef.current.download(data, url ?? "", filename);
461
+ } catch (_e) {
462
+ downloadByUrl();
483
463
  }
484
- }
485
- }
486
-
487
- return to;
464
+ }, [pdfDoc]),
465
+ isLoading,
466
+ pdfViewerRef,
467
+ rotateLeft,
468
+ rotateRight,
469
+ scale,
470
+ setScale,
471
+ zoomIn,
472
+ zoomOut
473
+ };
488
474
  };
489
475
 
490
- /**
491
- * Copyright (c) 2013-present, Facebook, Inc.
492
- *
493
- * This source code is licensed under the MIT license found in the
494
- * LICENSE file in the root directory of this source tree.
495
- */
496
-
497
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
498
-
499
- var ReactPropTypesSecret_1 = ReactPropTypesSecret;
500
-
501
- var printWarning = function() {};
502
-
503
- if (process.env.NODE_ENV !== 'production') {
504
- var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
505
- var loggedTypeFailures = {};
506
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
507
-
508
- printWarning = function(text) {
509
- var message = 'Warning: ' + text;
510
- if (typeof console !== 'undefined') {
511
- console.error(message);
512
- }
513
- try {
514
- // --- Welcome to debugging React ---
515
- // This error was thrown as a convenience so that you can use this stack
516
- // to find the callsite that caused this warning to fire.
517
- throw new Error(message);
518
- } catch (x) {}
519
- };
520
- }
521
-
522
- /**
523
- * Assert that the values match with the type specs.
524
- * Error messages are memorized and will only be shown once.
525
- *
526
- * @param {object} typeSpecs Map of name to a ReactPropType
527
- * @param {object} values Runtime values that need to be type-checked
528
- * @param {string} location e.g. "prop", "context", "child context"
529
- * @param {string} componentName Name of the component for error messages.
530
- * @param {?Function} getStack Returns the component stack.
531
- * @private
532
- */
533
- function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
534
- if (process.env.NODE_ENV !== 'production') {
535
- for (var typeSpecName in typeSpecs) {
536
- if (has(typeSpecs, typeSpecName)) {
537
- var error;
538
- // Prop type validation may throw. In case they do, we don't want to
539
- // fail the render phase where it didn't fail before. So we log it.
540
- // After these have been cleaned up, we'll let them throw.
541
- try {
542
- // This is intentionally an invariant that gets caught. It's the same
543
- // behavior as without this statement except with a better message.
544
- if (typeof typeSpecs[typeSpecName] !== 'function') {
545
- var err = Error(
546
- (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
547
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
548
- );
549
- err.name = 'Invariant Violation';
550
- throw err;
551
- }
552
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
553
- } catch (ex) {
554
- error = ex;
555
- }
556
- if (error && !(error instanceof Error)) {
557
- printWarning(
558
- (componentName || 'React class') + ': type specification of ' +
559
- location + ' `' + typeSpecName + '` is invalid; the type checker ' +
560
- 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
561
- 'You may have forgotten to pass an argument to the type checker ' +
562
- 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
563
- 'shape all require an argument).'
564
- );
565
- }
566
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
567
- // Only monitor this failure once because there tends to be a lot of the
568
- // same error.
569
- loggedTypeFailures[error.message] = true;
570
-
571
- var stack = getStack ? getStack() : '';
572
-
573
- printWarning(
574
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
575
- );
576
- }
577
- }
578
- }
579
- }
580
- }
581
-
582
- /**
583
- * Resets warning cache when testing.
584
- *
585
- * @private
586
- */
587
- checkPropTypes.resetWarningCache = function() {
588
- if (process.env.NODE_ENV !== 'production') {
589
- loggedTypeFailures = {};
590
- }
476
+ //#endregion
477
+ //#region src/lib/iconStyles.ts
478
+ const iconVarMap = {
479
+ zoomIn: "--pdfjs-multi-control-icon-zoom-in",
480
+ zoomOut: "--pdfjs-multi-control-icon-zoom-out",
481
+ rotateLeft: "--pdfjs-multi-control-icon-rotate-left",
482
+ rotateRight: "--pdfjs-multi-control-icon-rotate-right",
483
+ download: "--pdfjs-multi-control-icon-download",
484
+ selectArrow: "--pdfjs-multi-select-icon",
485
+ toggleList: "--pdfjs-multi-control-icon-toggle-list",
486
+ texture: "--pdfjs-multi-texture"
591
487
  };
592
-
593
- var checkPropTypes_1 = checkPropTypes;
594
-
595
- var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
596
- var printWarning$1 = function() {};
597
-
598
- if (process.env.NODE_ENV !== 'production') {
599
- printWarning$1 = function(text) {
600
- var message = 'Warning: ' + text;
601
- if (typeof console !== 'undefined') {
602
- console.error(message);
603
- }
604
- try {
605
- // --- Welcome to debugging React ---
606
- // This error was thrown as a convenience so that you can use this stack
607
- // to find the callsite that caused this warning to fire.
608
- throw new Error(message);
609
- } catch (x) {}
610
- };
611
- }
612
-
613
- function emptyFunctionThatReturnsNull() {
614
- return null;
615
- }
616
-
617
- var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
618
- /* global Symbol */
619
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
620
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
621
-
622
- /**
623
- * Returns the iterator method function contained on the iterable object.
624
- *
625
- * Be sure to invoke the function with the iterable as context:
626
- *
627
- * var iteratorFn = getIteratorFn(myIterable);
628
- * if (iteratorFn) {
629
- * var iterator = iteratorFn.call(myIterable);
630
- * ...
631
- * }
632
- *
633
- * @param {?object} maybeIterable
634
- * @return {?function}
635
- */
636
- function getIteratorFn(maybeIterable) {
637
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
638
- if (typeof iteratorFn === 'function') {
639
- return iteratorFn;
640
- }
641
- }
642
-
643
- /**
644
- * Collection of methods that allow declaration and validation of props that are
645
- * supplied to React components. Example usage:
646
- *
647
- * var Props = require('ReactPropTypes');
648
- * var MyArticle = React.createClass({
649
- * propTypes: {
650
- * // An optional string prop named "description".
651
- * description: Props.string,
652
- *
653
- * // A required enum prop named "category".
654
- * category: Props.oneOf(['News','Photos']).isRequired,
655
- *
656
- * // A prop named "dialog" that requires an instance of Dialog.
657
- * dialog: Props.instanceOf(Dialog).isRequired
658
- * },
659
- * render: function() { ... }
660
- * });
661
- *
662
- * A more formal specification of how these methods are used:
663
- *
664
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
665
- * decl := ReactPropTypes.{type}(.isRequired)?
666
- *
667
- * Each and every declaration produces a function with the same signature. This
668
- * allows the creation of custom validation functions. For example:
669
- *
670
- * var MyLink = React.createClass({
671
- * propTypes: {
672
- * // An optional string or URI prop named "href".
673
- * href: function(props, propName, componentName) {
674
- * var propValue = props[propName];
675
- * if (propValue != null && typeof propValue !== 'string' &&
676
- * !(propValue instanceof URI)) {
677
- * return new Error(
678
- * 'Expected a string or an URI for ' + propName + ' in ' +
679
- * componentName
680
- * );
681
- * }
682
- * }
683
- * },
684
- * render: function() {...}
685
- * });
686
- *
687
- * @internal
688
- */
689
-
690
- var ANONYMOUS = '<<anonymous>>';
691
-
692
- // Important!
693
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
694
- var ReactPropTypes = {
695
- array: createPrimitiveTypeChecker('array'),
696
- bool: createPrimitiveTypeChecker('boolean'),
697
- func: createPrimitiveTypeChecker('function'),
698
- number: createPrimitiveTypeChecker('number'),
699
- object: createPrimitiveTypeChecker('object'),
700
- string: createPrimitiveTypeChecker('string'),
701
- symbol: createPrimitiveTypeChecker('symbol'),
702
-
703
- any: createAnyTypeChecker(),
704
- arrayOf: createArrayOfTypeChecker,
705
- element: createElementTypeChecker(),
706
- elementType: createElementTypeTypeChecker(),
707
- instanceOf: createInstanceTypeChecker,
708
- node: createNodeChecker(),
709
- objectOf: createObjectOfTypeChecker,
710
- oneOf: createEnumTypeChecker,
711
- oneOfType: createUnionTypeChecker,
712
- shape: createShapeTypeChecker,
713
- exact: createStrictShapeTypeChecker,
714
- };
715
-
716
- /**
717
- * inlined Object.is polyfill to avoid requiring consumers ship their own
718
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
719
- */
720
- /*eslint-disable no-self-compare*/
721
- function is(x, y) {
722
- // SameValue algorithm
723
- if (x === y) {
724
- // Steps 1-5, 7-10
725
- // Steps 6.b-6.e: +0 != -0
726
- return x !== 0 || 1 / x === 1 / y;
727
- } else {
728
- // Step 6.a: NaN == NaN
729
- return x !== x && y !== y;
730
- }
731
- }
732
- /*eslint-enable no-self-compare*/
733
-
734
- /**
735
- * We use an Error-like object for backward compatibility as people may call
736
- * PropTypes directly and inspect their output. However, we don't use real
737
- * Errors anymore. We don't inspect their stack anyway, and creating them
738
- * is prohibitively expensive if they are created too often, such as what
739
- * happens in oneOfType() for any type before the one that matched.
740
- */
741
- function PropTypeError(message) {
742
- this.message = message;
743
- this.stack = '';
744
- }
745
- // Make `instanceof Error` still work for returned errors.
746
- PropTypeError.prototype = Error.prototype;
747
-
748
- function createChainableTypeChecker(validate) {
749
- if (process.env.NODE_ENV !== 'production') {
750
- var manualPropTypeCallCache = {};
751
- var manualPropTypeWarningCount = 0;
752
- }
753
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
754
- componentName = componentName || ANONYMOUS;
755
- propFullName = propFullName || propName;
756
-
757
- if (secret !== ReactPropTypesSecret_1) {
758
- if (throwOnDirectAccess) {
759
- // New behavior only for users of `prop-types` package
760
- var err = new Error(
761
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
762
- 'Use `PropTypes.checkPropTypes()` to call them. ' +
763
- 'Read more at http://fb.me/use-check-prop-types'
764
- );
765
- err.name = 'Invariant Violation';
766
- throw err;
767
- } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
768
- // Old behavior for people using React.PropTypes
769
- var cacheKey = componentName + ':' + propName;
770
- if (
771
- !manualPropTypeCallCache[cacheKey] &&
772
- // Avoid spamming the console because they are often not actionable except for lib authors
773
- manualPropTypeWarningCount < 3
774
- ) {
775
- printWarning$1(
776
- 'You are manually calling a React.PropTypes validation ' +
777
- 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
778
- 'and will throw in the standalone `prop-types` package. ' +
779
- 'You may be seeing this warning due to a third-party PropTypes ' +
780
- 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
781
- );
782
- manualPropTypeCallCache[cacheKey] = true;
783
- manualPropTypeWarningCount++;
784
- }
785
- }
786
- }
787
- if (props[propName] == null) {
788
- if (isRequired) {
789
- if (props[propName] === null) {
790
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
791
- }
792
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
793
- }
794
- return null;
795
- } else {
796
- return validate(props, propName, componentName, location, propFullName);
797
- }
798
- }
799
-
800
- var chainedCheckType = checkType.bind(null, false);
801
- chainedCheckType.isRequired = checkType.bind(null, true);
802
-
803
- return chainedCheckType;
804
- }
805
-
806
- function createPrimitiveTypeChecker(expectedType) {
807
- function validate(props, propName, componentName, location, propFullName, secret) {
808
- var propValue = props[propName];
809
- var propType = getPropType(propValue);
810
- if (propType !== expectedType) {
811
- // `propValue` being instance of, say, date/regexp, pass the 'object'
812
- // check, but we can offer a more precise error message here rather than
813
- // 'of type `object`'.
814
- var preciseType = getPreciseType(propValue);
815
-
816
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
817
- }
818
- return null;
819
- }
820
- return createChainableTypeChecker(validate);
821
- }
822
-
823
- function createAnyTypeChecker() {
824
- return createChainableTypeChecker(emptyFunctionThatReturnsNull);
825
- }
826
-
827
- function createArrayOfTypeChecker(typeChecker) {
828
- function validate(props, propName, componentName, location, propFullName) {
829
- if (typeof typeChecker !== 'function') {
830
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
831
- }
832
- var propValue = props[propName];
833
- if (!Array.isArray(propValue)) {
834
- var propType = getPropType(propValue);
835
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
836
- }
837
- for (var i = 0; i < propValue.length; i++) {
838
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
839
- if (error instanceof Error) {
840
- return error;
841
- }
842
- }
843
- return null;
844
- }
845
- return createChainableTypeChecker(validate);
846
- }
847
-
848
- function createElementTypeChecker() {
849
- function validate(props, propName, componentName, location, propFullName) {
850
- var propValue = props[propName];
851
- if (!isValidElement(propValue)) {
852
- var propType = getPropType(propValue);
853
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
854
- }
855
- return null;
856
- }
857
- return createChainableTypeChecker(validate);
858
- }
859
-
860
- function createElementTypeTypeChecker() {
861
- function validate(props, propName, componentName, location, propFullName) {
862
- var propValue = props[propName];
863
- if (!reactIs.isValidElementType(propValue)) {
864
- var propType = getPropType(propValue);
865
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
866
- }
867
- return null;
868
- }
869
- return createChainableTypeChecker(validate);
870
- }
871
-
872
- function createInstanceTypeChecker(expectedClass) {
873
- function validate(props, propName, componentName, location, propFullName) {
874
- if (!(props[propName] instanceof expectedClass)) {
875
- var expectedClassName = expectedClass.name || ANONYMOUS;
876
- var actualClassName = getClassName(props[propName]);
877
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
878
- }
879
- return null;
880
- }
881
- return createChainableTypeChecker(validate);
882
- }
883
-
884
- function createEnumTypeChecker(expectedValues) {
885
- if (!Array.isArray(expectedValues)) {
886
- if (process.env.NODE_ENV !== 'production') {
887
- if (arguments.length > 1) {
888
- printWarning$1(
889
- 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
890
- 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
891
- );
892
- } else {
893
- printWarning$1('Invalid argument supplied to oneOf, expected an array.');
894
- }
895
- }
896
- return emptyFunctionThatReturnsNull;
897
- }
898
-
899
- function validate(props, propName, componentName, location, propFullName) {
900
- var propValue = props[propName];
901
- for (var i = 0; i < expectedValues.length; i++) {
902
- if (is(propValue, expectedValues[i])) {
903
- return null;
904
- }
905
- }
906
-
907
- var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
908
- var type = getPreciseType(value);
909
- if (type === 'symbol') {
910
- return String(value);
911
- }
912
- return value;
913
- });
914
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
915
- }
916
- return createChainableTypeChecker(validate);
917
- }
918
-
919
- function createObjectOfTypeChecker(typeChecker) {
920
- function validate(props, propName, componentName, location, propFullName) {
921
- if (typeof typeChecker !== 'function') {
922
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
923
- }
924
- var propValue = props[propName];
925
- var propType = getPropType(propValue);
926
- if (propType !== 'object') {
927
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
928
- }
929
- for (var key in propValue) {
930
- if (has$1(propValue, key)) {
931
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
932
- if (error instanceof Error) {
933
- return error;
934
- }
935
- }
936
- }
937
- return null;
938
- }
939
- return createChainableTypeChecker(validate);
940
- }
941
-
942
- function createUnionTypeChecker(arrayOfTypeCheckers) {
943
- if (!Array.isArray(arrayOfTypeCheckers)) {
944
- process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
945
- return emptyFunctionThatReturnsNull;
946
- }
947
-
948
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
949
- var checker = arrayOfTypeCheckers[i];
950
- if (typeof checker !== 'function') {
951
- printWarning$1(
952
- 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
953
- 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
954
- );
955
- return emptyFunctionThatReturnsNull;
956
- }
957
- }
958
-
959
- function validate(props, propName, componentName, location, propFullName) {
960
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
961
- var checker = arrayOfTypeCheckers[i];
962
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
963
- return null;
964
- }
965
- }
966
-
967
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
968
- }
969
- return createChainableTypeChecker(validate);
970
- }
971
-
972
- function createNodeChecker() {
973
- function validate(props, propName, componentName, location, propFullName) {
974
- if (!isNode(props[propName])) {
975
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
976
- }
977
- return null;
978
- }
979
- return createChainableTypeChecker(validate);
980
- }
981
-
982
- function createShapeTypeChecker(shapeTypes) {
983
- function validate(props, propName, componentName, location, propFullName) {
984
- var propValue = props[propName];
985
- var propType = getPropType(propValue);
986
- if (propType !== 'object') {
987
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
988
- }
989
- for (var key in shapeTypes) {
990
- var checker = shapeTypes[key];
991
- if (!checker) {
992
- continue;
993
- }
994
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
995
- if (error) {
996
- return error;
997
- }
998
- }
999
- return null;
1000
- }
1001
- return createChainableTypeChecker(validate);
1002
- }
1003
-
1004
- function createStrictShapeTypeChecker(shapeTypes) {
1005
- function validate(props, propName, componentName, location, propFullName) {
1006
- var propValue = props[propName];
1007
- var propType = getPropType(propValue);
1008
- if (propType !== 'object') {
1009
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1010
- }
1011
- // We need to check all keys in case some are required but missing from
1012
- // props.
1013
- var allKeys = objectAssign({}, props[propName], shapeTypes);
1014
- for (var key in allKeys) {
1015
- var checker = shapeTypes[key];
1016
- if (!checker) {
1017
- return new PropTypeError(
1018
- 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1019
- '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1020
- '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1021
- );
1022
- }
1023
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
1024
- if (error) {
1025
- return error;
1026
- }
1027
- }
1028
- return null;
1029
- }
1030
-
1031
- return createChainableTypeChecker(validate);
1032
- }
1033
-
1034
- function isNode(propValue) {
1035
- switch (typeof propValue) {
1036
- case 'number':
1037
- case 'string':
1038
- case 'undefined':
1039
- return true;
1040
- case 'boolean':
1041
- return !propValue;
1042
- case 'object':
1043
- if (Array.isArray(propValue)) {
1044
- return propValue.every(isNode);
1045
- }
1046
- if (propValue === null || isValidElement(propValue)) {
1047
- return true;
1048
- }
1049
-
1050
- var iteratorFn = getIteratorFn(propValue);
1051
- if (iteratorFn) {
1052
- var iterator = iteratorFn.call(propValue);
1053
- var step;
1054
- if (iteratorFn !== propValue.entries) {
1055
- while (!(step = iterator.next()).done) {
1056
- if (!isNode(step.value)) {
1057
- return false;
1058
- }
1059
- }
1060
- } else {
1061
- // Iterator will provide entry [k,v] tuples rather than values.
1062
- while (!(step = iterator.next()).done) {
1063
- var entry = step.value;
1064
- if (entry) {
1065
- if (!isNode(entry[1])) {
1066
- return false;
1067
- }
1068
- }
1069
- }
1070
- }
1071
- } else {
1072
- return false;
1073
- }
1074
-
1075
- return true;
1076
- default:
1077
- return false;
1078
- }
1079
- }
1080
-
1081
- function isSymbol(propType, propValue) {
1082
- // Native Symbol.
1083
- if (propType === 'symbol') {
1084
- return true;
1085
- }
1086
-
1087
- // falsy value can't be a Symbol
1088
- if (!propValue) {
1089
- return false;
1090
- }
1091
-
1092
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1093
- if (propValue['@@toStringTag'] === 'Symbol') {
1094
- return true;
1095
- }
1096
-
1097
- // Fallback for non-spec compliant Symbols which are polyfilled.
1098
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1099
- return true;
1100
- }
1101
-
1102
- return false;
1103
- }
1104
-
1105
- // Equivalent of `typeof` but with special handling for array and regexp.
1106
- function getPropType(propValue) {
1107
- var propType = typeof propValue;
1108
- if (Array.isArray(propValue)) {
1109
- return 'array';
1110
- }
1111
- if (propValue instanceof RegExp) {
1112
- // Old webkits (at least until Android 4.0) return 'function' rather than
1113
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1114
- // passes PropTypes.object.
1115
- return 'object';
1116
- }
1117
- if (isSymbol(propType, propValue)) {
1118
- return 'symbol';
1119
- }
1120
- return propType;
1121
- }
1122
-
1123
- // This handles more types than `getPropType`. Only used for error messages.
1124
- // See `createPrimitiveTypeChecker`.
1125
- function getPreciseType(propValue) {
1126
- if (typeof propValue === 'undefined' || propValue === null) {
1127
- return '' + propValue;
1128
- }
1129
- var propType = getPropType(propValue);
1130
- if (propType === 'object') {
1131
- if (propValue instanceof Date) {
1132
- return 'date';
1133
- } else if (propValue instanceof RegExp) {
1134
- return 'regexp';
1135
- }
1136
- }
1137
- return propType;
1138
- }
1139
-
1140
- // Returns a string that is postfixed to a warning about an invalid type.
1141
- // For example, "undefined" or "of type array"
1142
- function getPostfixForTypeWarning(value) {
1143
- var type = getPreciseType(value);
1144
- switch (type) {
1145
- case 'array':
1146
- case 'object':
1147
- return 'an ' + type;
1148
- case 'boolean':
1149
- case 'date':
1150
- case 'regexp':
1151
- return 'a ' + type;
1152
- default:
1153
- return type;
1154
- }
1155
- }
1156
-
1157
- // Returns class name of the object, if any.
1158
- function getClassName(propValue) {
1159
- if (!propValue.constructor || !propValue.constructor.name) {
1160
- return ANONYMOUS;
1161
- }
1162
- return propValue.constructor.name;
1163
- }
1164
-
1165
- ReactPropTypes.checkPropTypes = checkPropTypes_1;
1166
- ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
1167
- ReactPropTypes.PropTypes = ReactPropTypes;
1168
-
1169
- return ReactPropTypes;
488
+ const toCssValue = (value) => {
489
+ const trimmed = value.trim();
490
+ if (!trimmed) return void 0;
491
+ if (trimmed === "none") return "none";
492
+ if (/^[a-z-]+\(/i.test(trimmed)) return trimmed;
493
+ return `url("${trimmed.replaceAll("\"", "\\\"")}")`;
1170
494
  };
1171
-
1172
- function emptyFunction() {}
1173
- function emptyFunctionWithReset() {}
1174
- emptyFunctionWithReset.resetWarningCache = emptyFunction;
1175
-
1176
- var factoryWithThrowingShims = function() {
1177
- function shim(props, propName, componentName, location, propFullName, secret) {
1178
- if (secret === ReactPropTypesSecret_1) {
1179
- // It is still safe when called from React.
1180
- return;
1181
- }
1182
- var err = new Error(
1183
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1184
- 'Use PropTypes.checkPropTypes() to call them. ' +
1185
- 'Read more at http://fb.me/use-check-prop-types'
1186
- );
1187
- err.name = 'Invariant Violation';
1188
- throw err;
1189
- } shim.isRequired = shim;
1190
- function getShim() {
1191
- return shim;
1192
- } // Important!
1193
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1194
- var ReactPropTypes = {
1195
- array: shim,
1196
- bool: shim,
1197
- func: shim,
1198
- number: shim,
1199
- object: shim,
1200
- string: shim,
1201
- symbol: shim,
1202
-
1203
- any: shim,
1204
- arrayOf: getShim,
1205
- element: shim,
1206
- elementType: shim,
1207
- instanceOf: getShim,
1208
- node: shim,
1209
- objectOf: getShim,
1210
- oneOf: getShim,
1211
- oneOfType: getShim,
1212
- shape: getShim,
1213
- exact: getShim,
1214
-
1215
- checkPropTypes: emptyFunctionWithReset,
1216
- resetWarningCache: emptyFunction
1217
- };
1218
-
1219
- ReactPropTypes.PropTypes = ReactPropTypes;
1220
-
1221
- return ReactPropTypes;
495
+ const buildIconStyles = (icons) => {
496
+ if (!icons) return void 0;
497
+ const style = {};
498
+ for (const [key, cssVar] of Object.entries(iconVarMap)) {
499
+ const iconValue = icons[key];
500
+ if (!iconValue) continue;
501
+ const cssValue = toCssValue(iconValue);
502
+ if (!cssValue) continue;
503
+ style[cssVar] = cssValue;
504
+ }
505
+ return Object.keys(style).length ? style : void 0;
1222
506
  };
1223
507
 
1224
- var propTypes = createCommonjsModule(function (module) {
1225
- /**
1226
- * Copyright (c) 2013-present, Facebook, Inc.
1227
- *
1228
- * This source code is licensed under the MIT license found in the
1229
- * LICENSE file in the root directory of this source tree.
1230
- */
1231
-
1232
- if (process.env.NODE_ENV !== 'production') {
1233
- var ReactIs = reactIs;
1234
-
1235
- // By explicitly using `prop-types` you are opting into new development behavior.
1236
- // http://fb.me/prop-types-in-prod
1237
- var throwOnDirectAccess = true;
1238
- module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
1239
- } else {
1240
- // By explicitly using `prop-types` you are opting into new production behavior.
1241
- // http://fb.me/prop-types-in-prod
1242
- module.exports = factoryWithThrowingShims();
1243
- }
508
+ //#endregion
509
+ //#region src/components/PdfRenderer/PdfRenderer.tsx
510
+ const PdfRenderer = (0, react.forwardRef)(({ pdfDoc, activeIndex = "0", autoZoom = true, controls = true, downloadBtn = true, icons, i18nData = defaultI18n, pdfChangeHook = null, zoom, rotation = 0, scrollTop = 0, scrollLeft = 0 }, ref) => {
511
+ const { containerRef, download, isLoading, pdfViewerRef, rotateLeft, rotateRight, scale, setScale, zoomIn, zoomOut } = usePdfRenderer({
512
+ activeIndex,
513
+ autoZoom,
514
+ pdfChangeHook,
515
+ pdfDoc,
516
+ rotation,
517
+ scrollLeft,
518
+ scrollTop,
519
+ zoom
520
+ });
521
+ (0, react.useImperativeHandle)(ref, () => ({ get pdfViewer() {
522
+ return pdfViewerRef.current;
523
+ } }));
524
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PdfRendererView_default, {
525
+ autoZoom,
526
+ containerRef,
527
+ controls,
528
+ downloadBtn,
529
+ iconStyles: buildIconStyles(icons),
530
+ i18nData,
531
+ isLoading,
532
+ scale,
533
+ setScale,
534
+ onDownload: download,
535
+ onRotateLeft: rotateLeft,
536
+ onRotateRight: rotateRight,
537
+ onZoomIn: zoomIn,
538
+ onZoomOut: zoomOut
539
+ });
1244
540
  });
1245
-
1246
- // Polyfill for creating CustomEvents on IE9/10/11
1247
-
1248
- // code pulled from:
1249
- // https://github.com/d4tocchini/customevent-polyfill
1250
- // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
1251
-
1252
- (function() {
1253
- if (typeof window === 'undefined') {
1254
- return;
1255
- }
1256
-
1257
- try {
1258
- var ce = new window.CustomEvent('test', { cancelable: true });
1259
- ce.preventDefault();
1260
- if (ce.defaultPrevented !== true) {
1261
- // IE has problems with .preventDefault() on custom events
1262
- // http://stackoverflow.com/questions/23349191
1263
- throw new Error('Could not prevent default');
1264
- }
1265
- } catch (e) {
1266
- var CustomEvent = function(event, params) {
1267
- var evt, origPrevent;
1268
- params = params || {};
1269
- params.bubbles = !!params.bubbles;
1270
- params.cancelable = !!params.cancelable;
1271
-
1272
- evt = document.createEvent('CustomEvent');
1273
- evt.initCustomEvent(
1274
- event,
1275
- params.bubbles,
1276
- params.cancelable,
1277
- params.detail
1278
- );
1279
- origPrevent = evt.preventDefault;
1280
- evt.preventDefault = function() {
1281
- origPrevent.call(this);
1282
- try {
1283
- Object.defineProperty(this, 'defaultPrevented', {
1284
- get: function() {
1285
- return true;
1286
- }
1287
- });
1288
- } catch (e) {
1289
- this.defaultPrevented = true;
1290
- }
1291
- };
1292
- return evt;
1293
- };
1294
-
1295
- CustomEvent.prototype = window.Event.prototype;
1296
- window.CustomEvent = CustomEvent; // expose definition to window
1297
- }
1298
- })();
1299
-
1300
- (function () {
1301
- var throttle = function (type, name) {
1302
- var running = false;
1303
- var func = function () {
1304
- if (running) {
1305
- return;
1306
- }
1307
- running = true;
1308
- requestAnimationFrame(function () {
1309
- window.dispatchEvent(new CustomEvent(name));
1310
- running = false;
1311
- });
1312
- };
1313
- window.addEventListener(type, func);
1314
- };
1315
- throttle('resize', 'resizeAutoZoom');
1316
- })();
1317
-
1318
- var defaultI18n = {
1319
- zoom: 'Automatic zoom',
1320
- originalSize: 'Original size',
1321
- scaleUp: 'Scale up',
1322
- scaleDown: 'Scale down',
1323
- rotateLeft: 'Rotate left',
1324
- rotateRight: 'Rotate right',
1325
- download: 'Download',
1326
- };
1327
- var I18nContext = React__default.createContext(defaultI18n);
1328
-
1329
- var ZoomSelectBox = (function (_super) {
1330
- __extends(ZoomSelectBox, _super);
1331
- function ZoomSelectBox() {
1332
- var _this = _super !== null && _super.apply(this, arguments) || this;
1333
- _this.createSelectOptions = function (_a) {
1334
- var originalSize = _a.originalSize, zoom = _a.zoom;
1335
- return [
1336
- {
1337
- id: 'automated',
1338
- text: "" + zoom,
1339
- },
1340
- {
1341
- id: '50-percent',
1342
- text: '50%',
1343
- value: 50,
1344
- },
1345
- {
1346
- id: '75-percent',
1347
- text: '75%',
1348
- value: 75,
1349
- },
1350
- {
1351
- id: 'original',
1352
- text: originalSize + " (100%)",
1353
- value: 100,
1354
- },
1355
- {
1356
- id: '125-percent',
1357
- text: '125%',
1358
- value: 125,
1359
- },
1360
- {
1361
- id: '150-percent',
1362
- text: '150%',
1363
- value: 150,
1364
- },
1365
- {
1366
- id: '200-percent',
1367
- text: '200%',
1368
- value: 200,
1369
- },
1370
- {
1371
- id: '300-percent',
1372
- text: '300%',
1373
- value: 300,
1374
- },
1375
- {
1376
- id: '400-percent',
1377
- text: '400%',
1378
- value: 400,
1379
- },
1380
- {
1381
- id: 'calculated',
1382
- },
1383
- ];
1384
- };
1385
- _this.showCalculatedScale = function (i18nData) {
1386
- var scale = _this.props.scale;
1387
- return _this.createSelectOptions(i18nData).filter(function (option) { return option.value === scale; }).length === 0 && scale % 10 === 0
1388
- ? scale
1389
- : 0;
1390
- };
1391
- return _this;
1392
- }
1393
- ZoomSelectBox.prototype.render = function () {
1394
- var _this = this;
1395
- var _a = this.props, autoZoom = _a.autoZoom, scale = _a.scale, setScale = _a.setScale;
1396
- return (React__default.createElement(I18nContext.Consumer, null, function (i18nData) { return (React__default.createElement("div", { className: "dropdown-toolbar-container" },
1397
- React__default.createElement("span", { className: "dropdown-toolbar" },
1398
- React__default.createElement("select", { value: scale, onChange: function (e) {
1399
- setScale(parseInt(e.target.value, 10));
1400
- } }, _this.createSelectOptions(i18nData).map(function (_a) {
1401
- var id = _a.id, text = _a.text, value = _a.value;
1402
- switch (id) {
1403
- case 'calculated':
1404
- return (React__default.createElement("option", { key: id + "-" + scale, value: _this.showCalculatedScale(i18nData), hidden: true, disabled: true }, scale + "%"));
1405
- case 'automated':
1406
- return (autoZoom && (React__default.createElement("option", { key: id + "-" + scale, value: -1 }, text)));
1407
- default:
1408
- return (React__default.createElement("option", { key: id, value: value }, text));
1409
- }
1410
- }))))); }));
1411
- };
1412
- ZoomSelectBox.propTypes = {
1413
- scale: propTypes.number.isRequired,
1414
- setScale: propTypes.func.isRequired,
1415
- };
1416
- return ZoomSelectBox;
1417
- }(React.PureComponent));
1418
-
1419
- var PdfControls = function (_a) {
1420
- var autoZoom = _a.autoZoom, downloadBtn = _a.downloadBtn, onDownload = _a.onDownload, onZoomIn = _a.onZoomIn, onZoomOut = _a.onZoomOut, onRotateRight = _a.onRotateRight, onRotateLeft = _a.onRotateLeft, scale = _a.scale, setScale = _a.setScale;
1421
- return (React__default.createElement("div", { className: "renderer-controls" },
1422
- React__default.createElement("div", null,
1423
- React__default.createElement(I18nContext.Consumer, null, function (_a) {
1424
- var scaleDown = _a.scaleDown, scaleUp = _a.scaleUp;
1425
- return (React__default.createElement("div", { className: "button-group" },
1426
- React__default.createElement("button", { className: "renderer-controls-button", type: "button", onClick: onZoomOut },
1427
- React__default.createElement("span", { className: "zoom-out-label" }, scaleDown)),
1428
- React__default.createElement("div", { className: "split-button-seperator" }),
1429
- React__default.createElement("button", { className: "renderer-controls-button", type: "button", onClick: onZoomIn },
1430
- React__default.createElement("span", { className: "zoom-in-label" }, scaleUp))));
1431
- }),
1432
- React__default.createElement(ZoomSelectBox, { autoZoom: autoZoom, scale: scale, setScale: setScale }),
1433
- React__default.createElement(I18nContext.Consumer, null, function (_a) {
1434
- var scaleDown = _a.scaleDown, scaleUp = _a.scaleUp, download = _a.download;
1435
- return (React__default.createElement(React.Fragment, null,
1436
- React__default.createElement("div", { className: "button-group" },
1437
- React__default.createElement("button", { className: "renderer-controls-button", type: "button", onClick: onRotateLeft },
1438
- React__default.createElement("span", { className: "rotate-left-label" }, scaleDown)),
1439
- React__default.createElement("div", { className: "split-button-seperator" }),
1440
- React__default.createElement("button", { className: "renderer-controls-button", type: "button", onClick: onRotateRight },
1441
- React__default.createElement("span", { className: "rotate-right-label" }, scaleUp))),
1442
- downloadBtn && (React__default.createElement("div", { className: "button-group" },
1443
- React__default.createElement("button", { className: "renderer-controls-button", type: "button", onClick: onDownload },
1444
- React__default.createElement("span", { className: "download-label" }, download))))));
1445
- }))));
541
+ PdfRenderer.displayName = "PdfRenderer";
542
+ var PdfRenderer_default = PdfRenderer;
543
+
544
+ //#endregion
545
+ //#region src/components/PdfMultiViewer/PdfMultiViewerView.tsx
546
+ const PdfMultiViewerView = ({ activeIndex, autoZoom, controls, files, iconStyles, i18nData, listVisible, overlayMode, pdfToShow, viewerContainerRef, onRememberPosition, onSelectPdf, onToggleList }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
547
+ className: "pdfjs-multi pdf-multi-viewer",
548
+ ref: viewerContainerRef,
549
+ style: iconStyles,
550
+ children: [
551
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
552
+ className: "pdf-multi-viewer-option-bar",
553
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
554
+ className: `viewer-controls-button${listVisible ? " toggled" : ""}`,
555
+ onClick: onToggleList,
556
+ type: "button",
557
+ "aria-label": "Toggle list",
558
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
559
+ className: "toggle-list-label",
560
+ "aria-hidden": "true"
561
+ })
562
+ })
563
+ }),
564
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
565
+ className: `pdf-viewer-list${!listVisible ? " hidden" : ""}${overlayMode ? " overlay" : ""}`,
566
+ children: files.map((file, index) => {
567
+ const handleSelect = onSelectPdf(String(index), file);
568
+ const isLoading = Boolean(file.isLoading && !file.pdfProxy);
569
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
570
+ className: `pdf-viewer-list-item${file.pdfProxy ? " loaded" : ""}${isLoading ? " loading" : ""}${activeIndex === String(index) ? " active" : ""}`,
571
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
572
+ className: "pdf-viewer-list-item-button",
573
+ onClick: handleSelect,
574
+ type: "button",
575
+ children: [
576
+ file.title || file.source,
577
+ file.pdfProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
578
+ className: "pdf-viewer-list-item-meta",
579
+ children: [
580
+ i18nData?.pages ?? "Pages",
581
+ ": ",
582
+ file.pdfProxy.numPages
583
+ ]
584
+ }),
585
+ isLoading && !file.pdfProxy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
586
+ className: "pdf-viewer-list-item-meta",
587
+ children: i18nData?.loading ?? "Loading..."
588
+ })
589
+ ]
590
+ })
591
+ }, file.source);
592
+ })
593
+ }),
594
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
595
+ className: "pdf-viewer-multi-renderer",
596
+ children: pdfToShow?.pdfProxy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PdfRenderer_default, {
597
+ activeIndex,
598
+ autoZoom,
599
+ controls,
600
+ pdfDoc: pdfToShow.pdfProxy,
601
+ i18nData,
602
+ pdfChangeHook: onRememberPosition,
603
+ zoom: pdfToShow.zoom,
604
+ rotation: pdfToShow.rotation,
605
+ scrollTop: pdfToShow.scrollTop,
606
+ scrollLeft: pdfToShow.scrollLeft
607
+ }) : pdfToShow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("output", {
608
+ className: "pdf-viewer-loading",
609
+ "aria-live": "polite",
610
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
611
+ className: "pdf-viewer-loading-spinner",
612
+ "aria-hidden": "true"
613
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
614
+ className: "pdf-viewer-loading-text",
615
+ children: i18nData?.loading ?? "Loading..."
616
+ })]
617
+ }) : null
618
+ })
619
+ ]
620
+ });
621
+ var PdfMultiViewerView_default = PdfMultiViewerView;
622
+
623
+ //#endregion
624
+ //#region src/components/PdfMultiViewer/usePdfMultiViewer.ts
625
+ const createPdfFile = (pdf) => {
626
+ return typeof pdf === "object" ? {
627
+ ...pdf,
628
+ isLoading: false,
629
+ pdfProxy: null
630
+ } : {
631
+ isLoading: false,
632
+ source: pdf,
633
+ pdfProxy: null
634
+ };
1446
635
  };
1447
-
1448
- var isDataSchema = function (url) {
1449
- var i = 0, ii = url.length;
1450
- while (i < ii && url[i].trim() === '') {
1451
- i++;
1452
- }
1453
- return url.substring(i, i + 5).toLowerCase() === 'data:';
1454
- };
1455
- var getPDFFileNameFromURL = function (url) {
1456
- var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
1457
- if (typeof url !== 'string') {
1458
- return defaultFilename;
1459
- }
1460
- if (isDataSchema(url)) {
1461
- console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
1462
- return defaultFilename;
1463
- }
1464
- var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
1465
- var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
1466
- var splitURI = reURI.exec(url);
1467
- var suggestedFilename = null;
1468
- if (splitURI) {
1469
- suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
1470
- }
1471
- if (suggestedFilename) {
1472
- suggestedFilename = suggestedFilename[0];
1473
- if (suggestedFilename.includes('%')) {
1474
- try {
1475
- var suggestedFilenameResult = reFilename.exec(decodeURIComponent(suggestedFilename));
1476
- if (suggestedFilenameResult) {
1477
- suggestedFilename = suggestedFilenameResult[0];
1478
- }
1479
- }
1480
- catch (ex) { }
1481
- }
1482
- }
1483
- return suggestedFilename || defaultFilename;
636
+ const usePdfMultiViewer = ({ pdfs, startIndex, i18nData, lazyLoad, initialLoadIndex, workerSrc }) => {
637
+ const viewerContainerRef = (0, react.useRef)(null);
638
+ const initialFilesRef = (0, react.useRef)(null);
639
+ const workerRef = (0, react.useRef)(null);
640
+ const loadingIndicesRef = (0, react.useRef)(/* @__PURE__ */ new Set());
641
+ const initialLoadDoneRef = (0, react.useRef)(false);
642
+ const [files, setFiles] = (0, react.useState)(() => {
643
+ const mapped = pdfs.map(createPdfFile);
644
+ initialFilesRef.current = mapped;
645
+ return mapped;
646
+ });
647
+ const [activeIndex, setActiveIndex] = (0, react.useState)(() => `${startIndex}`);
648
+ const [listVisible, setListVisible] = (0, react.useState)(true);
649
+ const [overlayMode, setOverlayMode] = (0, react.useState)(false);
650
+ const resolveIndex = (0, react.useCallback)((index) => {
651
+ const resolved = Number(index);
652
+ return Number.isNaN(resolved) ? 0 : resolved;
653
+ }, []);
654
+ (0, react.useEffect)(() => {
655
+ if (workerSrc) {
656
+ pdfjs_dist_build_pdf_mjs.GlobalWorkerOptions.workerSrc = workerSrc;
657
+ const worker = pdfjs_dist_build_pdf_mjs.PDFWorker.create({});
658
+ workerRef.current = worker;
659
+ return () => {
660
+ worker.destroy();
661
+ if (workerRef.current === worker) workerRef.current = null;
662
+ };
663
+ }
664
+ }, [workerSrc]);
665
+ const toggleList = (0, react.useCallback)(() => {
666
+ setListVisible((state) => !state);
667
+ }, []);
668
+ const setFileLoading = (0, react.useCallback)((index, isLoading) => {
669
+ setFiles((state) => state.map((pdfFile, pdfIndex) => {
670
+ if (pdfIndex !== index) return pdfFile;
671
+ return {
672
+ ...pdfFile,
673
+ isLoading
674
+ };
675
+ }));
676
+ }, []);
677
+ const loadPdfDocument = (0, react.useCallback)(async (file, index) => {
678
+ if (file.pdfProxy) return;
679
+ if (loadingIndicesRef.current.has(index)) return;
680
+ loadingIndicesRef.current.add(index);
681
+ setFileLoading(index, true);
682
+ try {
683
+ const worker = workerRef.current;
684
+ const pdfDoc = await pdfjs_dist_build_pdf_mjs.getDocument({
685
+ url: file.source,
686
+ ...worker ? { worker } : {}
687
+ }).promise;
688
+ setFiles((state) => state.map((pdfFile, pdfIndex) => {
689
+ if (pdfIndex !== index) return pdfFile;
690
+ return {
691
+ ...pdfFile,
692
+ isLoading: false,
693
+ pdfProxy: pdfDoc
694
+ };
695
+ }));
696
+ } catch (_error) {
697
+ setFileLoading(index, false);
698
+ } finally {
699
+ loadingIndicesRef.current.delete(index);
700
+ }
701
+ }, [setFileLoading]);
702
+ const selectPdf = (0, react.useCallback)((nextIndex, file) => () => {
703
+ setActiveIndex(nextIndex);
704
+ if (lazyLoad && !file.pdfProxy) loadPdfDocument(file, Number(nextIndex));
705
+ if (overlayMode && listVisible) toggleList();
706
+ }, [
707
+ lazyLoad,
708
+ listVisible,
709
+ loadPdfDocument,
710
+ overlayMode,
711
+ toggleList
712
+ ]);
713
+ const updateOverlayMode = (0, react.useCallback)((currentContainerWidth) => {
714
+ const containerWidth = currentContainerWidth || viewerContainerRef.current?.offsetWidth;
715
+ setOverlayMode((current) => {
716
+ if (containerWidth && containerWidth >= 330 && containerWidth <= 667 && !current) return true;
717
+ if (current && containerWidth && containerWidth > 667) return false;
718
+ return current;
719
+ });
720
+ }, []);
721
+ const onResizeEvent = (0, react.useCallback)(() => {
722
+ updateOverlayMode(viewerContainerRef.current?.offsetWidth);
723
+ }, [updateOverlayMode]);
724
+ const loadPdfDocuments = (0, react.useCallback)(() => {
725
+ (initialFilesRef.current ?? []).forEach(async (file, index) => {
726
+ await loadPdfDocument(file, index);
727
+ });
728
+ }, [loadPdfDocument]);
729
+ const rememberPosition = (0, react.useCallback)((index, position) => {
730
+ setFiles((state) => state.map((pdfFile, pdfIndex) => {
731
+ if (pdfIndex !== Number(index)) return pdfFile;
732
+ return {
733
+ ...pdfFile,
734
+ ...position
735
+ };
736
+ }));
737
+ }, []);
738
+ (0, react.useEffect)(() => {
739
+ window.addEventListener("resizeAutoZoom", onResizeEvent);
740
+ updateOverlayMode(viewerContainerRef.current?.offsetWidth);
741
+ if (!lazyLoad) loadPdfDocuments();
742
+ return () => {
743
+ window.removeEventListener("resizeAutoZoom", onResizeEvent);
744
+ };
745
+ }, [
746
+ lazyLoad,
747
+ loadPdfDocuments,
748
+ onResizeEvent,
749
+ updateOverlayMode
750
+ ]);
751
+ (0, react.useEffect)(() => {
752
+ if (!lazyLoad) return;
753
+ const initialIndex = resolveIndex(initialLoadIndex ?? startIndex);
754
+ const nextFile = files[initialIndex];
755
+ if (!nextFile) return;
756
+ if (initialLoadDoneRef.current) return;
757
+ initialLoadDoneRef.current = true;
758
+ loadPdfDocument(nextFile, initialIndex);
759
+ }, [
760
+ files,
761
+ initialLoadIndex,
762
+ lazyLoad,
763
+ loadPdfDocument,
764
+ resolveIndex,
765
+ startIndex
766
+ ]);
767
+ (0, react.useEffect)(() => {
768
+ if (!lazyLoad) return;
769
+ const nextIndex = resolveIndex(activeIndex);
770
+ const nextFile = files[nextIndex];
771
+ if (!nextFile) return;
772
+ loadPdfDocument(nextFile, nextIndex);
773
+ }, [
774
+ activeIndex,
775
+ files,
776
+ lazyLoad,
777
+ loadPdfDocument,
778
+ resolveIndex
779
+ ]);
780
+ return {
781
+ activeIndex,
782
+ files,
783
+ i18nData,
784
+ listVisible,
785
+ overlayMode,
786
+ pdfToShow: files[Number(activeIndex)],
787
+ rememberPosition,
788
+ selectPdf,
789
+ toggleList,
790
+ viewerContainerRef
791
+ };
1484
792
  };
1485
793
 
1486
- var roundToNearest = function (numToRound, numToRoundTo) {
1487
- return Math.round(numToRound / numToRoundTo) * numToRoundTo;
1488
- };
1489
- var _a = require('pdfjs-dist/web/pdf_viewer'), PDFViewer = _a.PDFViewer, DownloadManager = _a.DownloadManager;
1490
- var initialState = {
1491
- scale: 100,
1492
- isLoading: true,
1493
- firstPageWidth: 0,
1494
- };
1495
- var PdfRenderer = (function (_super) {
1496
- __extends(PdfRenderer, _super);
1497
- function PdfRenderer(props) {
1498
- var _this = _super.call(this, props) || this;
1499
- _this.state = initialState;
1500
- _this.autoFitScale = function () {
1501
- var firstPageWith = _this.pdfViewer._pages[0].viewport.width;
1502
- var currentScale = _this.pdfViewer._pages[0].scale;
1503
- var originalWidth = firstPageWith / currentScale;
1504
- var containerWidth = _this.container.current && _this.container.current.offsetWidth < 1020
1505
- ? _this.container.current.offsetWidth - 56
1506
- : 1019;
1507
- var nextScale = -1;
1508
- if (_this.container.current) {
1509
- nextScale = Math.abs(containerWidth) / originalWidth;
1510
- }
1511
- _this.setScale(nextScale * 100);
1512
- };
1513
- _this.setScale = function (scale) {
1514
- var autoZoom = _this.props.autoZoom;
1515
- if (autoZoom && scale < 0) {
1516
- _this.autoFitScale();
1517
- return;
1518
- }
1519
- var nextScale = scale >= 10 ? scale : 10;
1520
- _this.setState(function () { return ({ scale: nextScale }); });
1521
- _this.pdfViewer.currentScaleValue = nextScale / 100;
1522
- };
1523
- _this.zoomIn = function () {
1524
- var scale = _this.state.scale;
1525
- scale = roundToNearest(scale, 10);
1526
- var newScale;
1527
- if (scale >= 110 && scale < 990) {
1528
- newScale = scale + 20;
1529
- }
1530
- else if (scale === 75 || scale === 125) {
1531
- newScale = scale + 5;
1532
- }
1533
- else {
1534
- newScale = scale + 10;
1535
- }
1536
- if (newScale > 1000)
1537
- return;
1538
- _this.setScale(newScale);
1539
- };
1540
- _this.zoomOut = function () {
1541
- var scale = _this.state.scale;
1542
- scale = scale === 125 ? scale : roundToNearest(scale, 10);
1543
- var newScale;
1544
- if (scale > 110 && scale !== 125) {
1545
- newScale = scale - 20;
1546
- }
1547
- else if (scale === 75 || scale === 125) {
1548
- newScale = scale - 5;
1549
- }
1550
- else {
1551
- newScale = scale - 10;
1552
- }
1553
- if (newScale <= 0)
1554
- return;
1555
- _this.setScale(newScale);
1556
- };
1557
- _this.rotateRight = function () {
1558
- var currentRotation = _this.pdfViewer.pagesRotation;
1559
- _this.pdfViewer.pagesRotation = currentRotation + 90;
1560
- };
1561
- _this.rotateLeft = function () {
1562
- var currentRotation = _this.pdfViewer.pagesRotation;
1563
- _this.pdfViewer.pagesRotation = currentRotation - 90;
1564
- };
1565
- _this.download = function () { return __awaiter(_this, void 0, void 0, function () {
1566
- var pdfDoc, url, filename, downloadByUrl, data, blob, e_1;
1567
- var _this = this;
1568
- return __generator(this, function (_a) {
1569
- switch (_a.label) {
1570
- case 0:
1571
- pdfDoc = this.props.pdfDoc;
1572
- url = pdfDoc._transport._params.url;
1573
- filename = getPDFFileNameFromURL(url);
1574
- downloadByUrl = function () {
1575
- _this.downloadManager.downloadUrl(url, filename);
1576
- };
1577
- _a.label = 1;
1578
- case 1:
1579
- _a.trys.push([1, 3, , 4]);
1580
- return [4, this.props.pdfDoc.getData()];
1581
- case 2:
1582
- data = _a.sent();
1583
- blob = new Blob([data], { type: 'application/pdf' });
1584
- this.downloadManager.download(blob, url, filename);
1585
- return [3, 4];
1586
- case 3:
1587
- e_1 = _a.sent();
1588
- downloadByUrl();
1589
- return [3, 4];
1590
- case 4: return [2];
1591
- }
1592
- });
1593
- }); };
1594
- _this.container = React__default.createRef();
1595
- _this.pdfViewer = null;
1596
- _this.downloadManager = new DownloadManager({
1597
- disableCreateObjectURL: false,
1598
- });
1599
- return _this;
1600
- }
1601
- PdfRenderer.prototype.componentDidMount = function () {
1602
- return __awaiter(this, void 0, void 0, function () {
1603
- var _a, autoZoom, pdfDoc;
1604
- return __generator(this, function (_b) {
1605
- _a = this.props, autoZoom = _a.autoZoom, pdfDoc = _a.pdfDoc;
1606
- this.pdfViewer = new PDFViewer({
1607
- container: this.container.current,
1608
- });
1609
- this.pdfViewer.setDocument(pdfDoc);
1610
- if (autoZoom) {
1611
- window.addEventListener('resizeAutoZoom', this.autoFitScale);
1612
- }
1613
- this.rePosition();
1614
- this.setState(function () { return ({ isLoading: false }); });
1615
- return [2];
1616
- });
1617
- });
1618
- };
1619
- PdfRenderer.prototype.componentDidUpdate = function (prevProps) {
1620
- var _a = this.props, pdfDoc = _a.pdfDoc, pdfChangeHook = _a.pdfChangeHook;
1621
- if (pdfDoc !== prevProps.pdfDoc) {
1622
- if (typeof pdfChangeHook === 'function') {
1623
- pdfChangeHook(String(prevProps.activeIndex), {
1624
- zoom: this.state.scale,
1625
- rotation: this.pdfViewer.pagesRotation,
1626
- scrollTop: this.container.current && this.container.current.scrollTop,
1627
- scrollLeft: this.container.current && this.container.current.scrollLeft,
1628
- });
1629
- }
1630
- this.pdfViewer.setDocument(pdfDoc);
1631
- this.rePosition();
1632
- }
1633
- };
1634
- PdfRenderer.prototype.componentWillUnmount = function () {
1635
- if (this.props.autoZoom) {
1636
- window.removeEventListener('resizeAutoZoom', this.autoFitScale);
1637
- }
1638
- };
1639
- PdfRenderer.prototype.rePosition = function () {
1640
- return __awaiter(this, void 0, void 0, function () {
1641
- var _a, autoZoom, zoom, rotation, scrollTop, scrollLeft;
1642
- return __generator(this, function (_b) {
1643
- switch (_b.label) {
1644
- case 0:
1645
- _a = this.props, autoZoom = _a.autoZoom, zoom = _a.zoom, rotation = _a.rotation, scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
1646
- return [4, this.pdfViewer.firstPagePromise];
1647
- case 1:
1648
- _b.sent();
1649
- if (rotation) {
1650
- this.pdfViewer.pagesRotation = rotation;
1651
- }
1652
- if (zoom) {
1653
- this.setScale(zoom);
1654
- }
1655
- else if (!zoom && autoZoom) {
1656
- this.autoFitScale();
1657
- }
1658
- if (typeof scrollTop !== 'undefined') {
1659
- this.setScrollTop(scrollTop);
1660
- }
1661
- if (typeof scrollLeft !== 'undefined') {
1662
- this.setScrollLeft(scrollLeft);
1663
- }
1664
- return [2];
1665
- }
1666
- });
1667
- });
1668
- };
1669
- PdfRenderer.prototype.setScrollTop = function (scrollTop) {
1670
- if (this.container.current) {
1671
- this.container.current.scrollTop = scrollTop;
1672
- }
1673
- };
1674
- PdfRenderer.prototype.setScrollLeft = function (scrollLeft) {
1675
- if (this.container.current) {
1676
- this.container.current.scrollLeft = scrollLeft;
1677
- }
1678
- };
1679
- PdfRenderer.prototype.render = function () {
1680
- var _a = this.state, isLoading = _a.isLoading, scale = _a.scale;
1681
- var _b = this.props, autoZoom = _b.autoZoom, controls = _b.controls, downloadBtn = _b.downloadBtn, i18nData = _b.i18nData;
1682
- return (React__default.createElement("div", { className: "renderer-container" },
1683
- controls && (React__default.createElement(I18nContext.Provider, { value: __assign(__assign({}, defaultI18n), i18nData) },
1684
- React__default.createElement(PdfControls, { autoZoom: autoZoom, downloadBtn: downloadBtn, scale: scale, setScale: this.setScale, onDownload: this.download, onZoomIn: this.zoomIn, onZoomOut: this.zoomOut, onRotateRight: this.rotateRight, onRotateLeft: this.rotateLeft }))),
1685
- React__default.createElement("div", { ref: this.container, className: "renderer-target-container " + (!controls ? 'no-controls' : '') + " " },
1686
- React__default.createElement("div", { id: "viewer", className: "pdfViewer " + (isLoading ? 'hidden' : '') }))));
1687
- };
1688
- PdfRenderer.defaultProps = {
1689
- activeIndex: '0',
1690
- autoZoom: true,
1691
- controls: true,
1692
- downloadBtn: true,
1693
- i18nData: defaultI18n,
1694
- pdfChangeHook: null,
1695
- rotation: 0,
1696
- scrollTop: 0,
1697
- scrollLeft: 0,
1698
- };
1699
- return PdfRenderer;
1700
- }(React.PureComponent));
1701
-
1702
- var PdfjsLib = require('pdfjs-dist/build/pdf');
1703
- var initialState$1 = {
1704
- files: [],
1705
- activeIndex: '0',
1706
- listVisible: true,
1707
- overlayMode: false,
1708
- };
1709
- var PdfMultiViewer = (function (_super) {
1710
- __extends(PdfMultiViewer, _super);
1711
- function PdfMultiViewer(props) {
1712
- var _this = _super.call(this, props) || this;
1713
- _this.state = initialState$1;
1714
- _this.changePdf = function (activeIndex, file) { return function () {
1715
- var _a = _this.state, overlayMode = _a.overlayMode, listVisible = _a.listVisible;
1716
- if (!file.pdfProxy)
1717
- return;
1718
- _this.setState(function () { return ({ activeIndex: activeIndex }); });
1719
- if (overlayMode && listVisible)
1720
- _this.toggleList();
1721
- }; };
1722
- _this.toggleList = function () {
1723
- return _this.setState(function (state) { return ({ listVisible: !state.listVisible }); });
1724
- };
1725
- _this.setOverlayMode = function (currentContainerWidth) {
1726
- var containerWidth = currentContainerWidth ||
1727
- (_this.viewerContainer.current &&
1728
- _this.viewerContainer.current.offsetWidth);
1729
- var overlayMode = _this.state.overlayMode;
1730
- if (containerWidth &&
1731
- containerWidth >= 330 &&
1732
- containerWidth <= 667 &&
1733
- !overlayMode) {
1734
- _this.setState(function () { return ({ overlayMode: true }); });
1735
- }
1736
- else if (overlayMode && containerWidth && containerWidth > 667) {
1737
- _this.setState(function () { return ({ overlayMode: false }); });
1738
- }
1739
- };
1740
- _this.getViewerContainerWidth = function () {
1741
- return (_this.viewerContainer.current &&
1742
- _this.viewerContainer.current.offsetWidth) ||
1743
- undefined;
1744
- };
1745
- _this.onResizeEvent = function () { return _this.setOverlayMode(_this.getViewerContainerWidth()); };
1746
- _this.rememberPosition = function (index, position) {
1747
- return _this.setState(function (state) { return ({
1748
- files: state.files.map(function (pdfFile, pdfIndex) {
1749
- if (pdfIndex !== Number(index))
1750
- return pdfFile;
1751
- return __assign(__assign({}, pdfFile), position);
1752
- }),
1753
- }); });
1754
- };
1755
- PdfjsLib.GlobalWorkerOptions.workerSrc =
1756
- '//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js';
1757
- _this.worker = new PdfjsLib.PDFWorker('pdf-viewer');
1758
- _this.viewerContainer = React__default.createRef();
1759
- _this.state.activeIndex = String(props.startIndex);
1760
- _this.state.files = _this.props.pdfs.map(function (pdf) {
1761
- return typeof pdf === 'object'
1762
- ? __assign(__assign({}, pdf), { pdfProxy: null }) : {
1763
- source: pdf,
1764
- pdfProxy: null,
1765
- };
1766
- });
1767
- return _this;
1768
- }
1769
- PdfMultiViewer.prototype.loadPdfDocuments = function () {
1770
- var _this = this;
1771
- this.state.files.forEach(function (file, index) { return __awaiter(_this, void 0, void 0, function () {
1772
- var pdfDoc;
1773
- return __generator(this, function (_a) {
1774
- switch (_a.label) {
1775
- case 0: return [4, PdfjsLib.getDocument({
1776
- url: file.source,
1777
- worker: this.worker,
1778
- })];
1779
- case 1:
1780
- pdfDoc = _a.sent();
1781
- this.setState(function (state) { return ({
1782
- files: state.files.map(function (pdfFile, pdfIndex) {
1783
- if (pdfIndex !== index)
1784
- return pdfFile;
1785
- return __assign(__assign({}, pdfFile), { pdfProxy: pdfDoc });
1786
- }),
1787
- }); });
1788
- return [2];
1789
- }
1790
- });
1791
- }); });
1792
- };
1793
- PdfMultiViewer.prototype.renderListItems = function () {
1794
- var _this = this;
1795
- var activeIndex = this.state.activeIndex;
1796
- var i18nData = this.props.i18nData;
1797
- return this.state.files.map(function (file, index) { return (React__default.createElement("li", { className: "pdf-viewer-list-item" + (file.pdfProxy ? ' loaded' : '') + (activeIndex === String(index) ? ' active' : ''), key: file.source, onClick: _this.changePdf(String(index), file) },
1798
- file.title || file.source,
1799
- file.pdfProxy && (React__default.createElement("div", { className: "pdf-viewer-list-item-meta" },
1800
- i18nData.pages,
1801
- ": ",
1802
- file.pdfProxy.numPages)))); });
1803
- };
1804
- PdfMultiViewer.prototype.componentDidMount = function () {
1805
- window.addEventListener('resizeAutoZoom', this.onResizeEvent);
1806
- this.setOverlayMode(this.getViewerContainerWidth());
1807
- this.loadPdfDocuments();
1808
- };
1809
- PdfMultiViewer.prototype.componentWillUnmount = function () {
1810
- window.removeEventListener('resizeAutoZoom', this.onResizeEvent);
1811
- this.worker.destroy();
1812
- };
1813
- PdfMultiViewer.prototype.render = function () {
1814
- var _a = this.state, activeIndex = _a.activeIndex, files = _a.files, listVisible = _a.listVisible, overlayMode = _a.overlayMode;
1815
- var pdfToShow = files[Number(activeIndex)];
1816
- var _b = this.props, autoZoom = _b.autoZoom, controls = _b.controls, i18nData = _b.i18nData;
1817
- return (React__default.createElement("div", { className: "pdf-multi-viewer", ref: this.viewerContainer },
1818
- React__default.createElement("div", { className: "pdf-multi-viewer-option-bar" },
1819
- React__default.createElement("button", { className: "viewer-controls-button" + (listVisible ? ' toggled' : ''), onClick: this.toggleList },
1820
- React__default.createElement("span", { className: "toggle-list-label" }, "Toggle list"))),
1821
- React__default.createElement("ul", { className: "pdf-viewer-list" + (!listVisible ? ' hidden' : '') + (overlayMode ? ' overlay' : '') }, this.renderListItems()),
1822
- React__default.createElement("div", { className: "pdf-viewer-multi-renderer" }, pdfToShow.pdfProxy && (React__default.createElement(PdfRenderer, { activeIndex: activeIndex, autoZoom: autoZoom, controls: controls, pdfDoc: pdfToShow.pdfProxy, i18nData: i18nData, pdfChangeHook: this.rememberPosition, zoom: pdfToShow.zoom, rotation: pdfToShow.rotation, scrollTop: pdfToShow.scrollTop, scrollLeft: pdfToShow.scrollLeft })))));
1823
- };
1824
- PdfMultiViewer.defaultProps = {
1825
- autoZoom: true,
1826
- controls: true,
1827
- startIndex: '0',
1828
- i18nData: {
1829
- pages: 'Pages',
1830
- },
1831
- };
1832
- return PdfMultiViewer;
1833
- }(React.PureComponent));
1834
-
1835
- var PdfjsLib$1 = require('pdfjs-dist/build/pdf');
1836
-
1837
- exports.PdfMultiViewer = PdfMultiViewer;
1838
- exports.PdfRenderer = PdfRenderer;
1839
- exports.PdfjsLib = PdfjsLib$1;
794
+ //#endregion
795
+ //#region src/components/PdfMultiViewer/PdfMultiViewer.tsx
796
+ const PdfMultiViewer = ({ pdfs, autoZoom = true, controls = true, icons, lazyLoad = true, initialLoadIndex, startIndex = "0", i18nData = {
797
+ loading: "Loading...",
798
+ pages: "Pages"
799
+ }, workerSrc }) => {
800
+ const { activeIndex, files, listVisible, overlayMode, pdfToShow, rememberPosition, selectPdf, toggleList, viewerContainerRef } = usePdfMultiViewer({
801
+ i18nData,
802
+ pdfs,
803
+ startIndex,
804
+ lazyLoad,
805
+ initialLoadIndex,
806
+ workerSrc
807
+ });
808
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PdfMultiViewerView_default, {
809
+ activeIndex,
810
+ autoZoom,
811
+ controls,
812
+ files,
813
+ iconStyles: buildIconStyles(icons),
814
+ i18nData,
815
+ listVisible,
816
+ onRememberPosition: rememberPosition,
817
+ onSelectPdf: selectPdf,
818
+ onToggleList: toggleList,
819
+ overlayMode,
820
+ pdfToShow,
821
+ viewerContainerRef
822
+ });
823
+ };
824
+ var PdfMultiViewer_default = PdfMultiViewer;
825
+
826
+ //#endregion
827
+ exports.PdfMultiViewer = PdfMultiViewer_default;
828
+ exports.PdfRenderer = PdfRenderer_default;
829
+ Object.defineProperty(exports, 'PdfjsLib', {
830
+ enumerable: true,
831
+ get: function () {
832
+ return pdfjs_dist_build_pdf_mjs;
833
+ }
834
+ });
835
+ //# sourceMappingURL=index.js.map