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