1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
4 | (global = global || self, factory(global.ReactRouter = {}, global.React));
|
5 | }(this, function (exports, React) { 'use strict';
|
6 |
|
7 | React = React && React.hasOwnProperty('default') ? React['default'] : React;
|
8 |
|
9 | function _setPrototypeOf(o, p) {
|
10 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
11 | o.__proto__ = p;
|
12 | return o;
|
13 | };
|
14 |
|
15 | return _setPrototypeOf(o, p);
|
16 | }
|
17 |
|
18 | function _inheritsLoose(subClass, superClass) {
|
19 | subClass.prototype = Object.create(superClass.prototype);
|
20 | subClass.prototype.constructor = subClass;
|
21 | _setPrototypeOf(subClass, superClass);
|
22 | }
|
23 |
|
24 | function unwrapExports (x) {
|
25 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
26 | }
|
27 |
|
28 | function createCommonjsModule(fn, module) {
|
29 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
30 | }
|
31 |
|
32 | var reactIs_production_min = createCommonjsModule(function (module, exports) {
|
33 | Object.defineProperty(exports,"__esModule",{value:!0});
|
34 | 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"):
|
35 | 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;function x(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 y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
|
36 | 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;
|
37 | 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)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
|
38 | exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
|
39 | });
|
40 |
|
41 | unwrapExports(reactIs_production_min);
|
42 | var reactIs_production_min_1 = reactIs_production_min.typeOf;
|
43 | var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
|
44 | var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
|
45 | var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
|
46 | var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
|
47 | var reactIs_production_min_6 = reactIs_production_min.Element;
|
48 | var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
|
49 | var reactIs_production_min_8 = reactIs_production_min.Fragment;
|
50 | var reactIs_production_min_9 = reactIs_production_min.Lazy;
|
51 | var reactIs_production_min_10 = reactIs_production_min.Memo;
|
52 | var reactIs_production_min_11 = reactIs_production_min.Portal;
|
53 | var reactIs_production_min_12 = reactIs_production_min.Profiler;
|
54 | var reactIs_production_min_13 = reactIs_production_min.StrictMode;
|
55 | var reactIs_production_min_14 = reactIs_production_min.Suspense;
|
56 | var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
|
57 | var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
|
58 | var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
|
59 | var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
|
60 | var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
|
61 | var reactIs_production_min_20 = reactIs_production_min.isElement;
|
62 | var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
|
63 | var reactIs_production_min_22 = reactIs_production_min.isFragment;
|
64 | var reactIs_production_min_23 = reactIs_production_min.isLazy;
|
65 | var reactIs_production_min_24 = reactIs_production_min.isMemo;
|
66 | var reactIs_production_min_25 = reactIs_production_min.isPortal;
|
67 | var reactIs_production_min_26 = reactIs_production_min.isProfiler;
|
68 | var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
|
69 | var reactIs_production_min_28 = reactIs_production_min.isSuspense;
|
70 |
|
71 | var reactIs_development = createCommonjsModule(function (module, exports) {
|
72 |
|
73 |
|
74 |
|
75 | {
|
76 | (function() {
|
77 |
|
78 | Object.defineProperty(exports, '__esModule', { value: true });
|
79 |
|
80 |
|
81 |
|
82 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
83 |
|
84 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
85 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
86 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
87 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
88 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
89 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
90 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
91 |
|
92 |
|
93 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
94 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
95 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
96 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
97 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
98 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
99 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
100 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
101 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
102 |
|
103 | function isValidElementType(type) {
|
104 | return typeof type === 'string' || typeof type === 'function' ||
|
105 |
|
106 | 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);
|
107 | }
|
108 |
|
109 | |
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | var lowPriorityWarning = function () {};
|
124 |
|
125 | {
|
126 | var printWarning = function (format) {
|
127 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
128 | args[_key - 1] = arguments[_key];
|
129 | }
|
130 |
|
131 | var argIndex = 0;
|
132 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
133 | return args[argIndex++];
|
134 | });
|
135 | if (typeof console !== 'undefined') {
|
136 | console.warn(message);
|
137 | }
|
138 | try {
|
139 |
|
140 |
|
141 |
|
142 | throw new Error(message);
|
143 | } catch (x) {}
|
144 | };
|
145 |
|
146 | lowPriorityWarning = function (condition, format) {
|
147 | if (format === undefined) {
|
148 | throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
149 | }
|
150 | if (!condition) {
|
151 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
152 | args[_key2 - 2] = arguments[_key2];
|
153 | }
|
154 |
|
155 | printWarning.apply(undefined, [format].concat(args));
|
156 | }
|
157 | };
|
158 | }
|
159 |
|
160 | var lowPriorityWarning$1 = lowPriorityWarning;
|
161 |
|
162 | function typeOf(object) {
|
163 | if (typeof object === 'object' && object !== null) {
|
164 | var $$typeof = object.$$typeof;
|
165 | switch ($$typeof) {
|
166 | case REACT_ELEMENT_TYPE:
|
167 | var type = object.type;
|
168 |
|
169 | switch (type) {
|
170 | case REACT_ASYNC_MODE_TYPE:
|
171 | case REACT_CONCURRENT_MODE_TYPE:
|
172 | case REACT_FRAGMENT_TYPE:
|
173 | case REACT_PROFILER_TYPE:
|
174 | case REACT_STRICT_MODE_TYPE:
|
175 | case REACT_SUSPENSE_TYPE:
|
176 | return type;
|
177 | default:
|
178 | var $$typeofType = type && type.$$typeof;
|
179 |
|
180 | switch ($$typeofType) {
|
181 | case REACT_CONTEXT_TYPE:
|
182 | case REACT_FORWARD_REF_TYPE:
|
183 | case REACT_PROVIDER_TYPE:
|
184 | return $$typeofType;
|
185 | default:
|
186 | return $$typeof;
|
187 | }
|
188 | }
|
189 | case REACT_LAZY_TYPE:
|
190 | case REACT_MEMO_TYPE:
|
191 | case REACT_PORTAL_TYPE:
|
192 | return $$typeof;
|
193 | }
|
194 | }
|
195 |
|
196 | return undefined;
|
197 | }
|
198 |
|
199 |
|
200 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
201 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
202 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
203 | var ContextProvider = REACT_PROVIDER_TYPE;
|
204 | var Element = REACT_ELEMENT_TYPE;
|
205 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
206 | var Fragment = REACT_FRAGMENT_TYPE;
|
207 | var Lazy = REACT_LAZY_TYPE;
|
208 | var Memo = REACT_MEMO_TYPE;
|
209 | var Portal = REACT_PORTAL_TYPE;
|
210 | var Profiler = REACT_PROFILER_TYPE;
|
211 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
212 | var Suspense = REACT_SUSPENSE_TYPE;
|
213 |
|
214 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
215 |
|
216 |
|
217 | function isAsyncMode(object) {
|
218 | {
|
219 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
220 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
221 | lowPriorityWarning$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.');
|
222 | }
|
223 | }
|
224 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
225 | }
|
226 | function isConcurrentMode(object) {
|
227 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
228 | }
|
229 | function isContextConsumer(object) {
|
230 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
231 | }
|
232 | function isContextProvider(object) {
|
233 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
234 | }
|
235 | function isElement(object) {
|
236 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
237 | }
|
238 | function isForwardRef(object) {
|
239 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
240 | }
|
241 | function isFragment(object) {
|
242 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
243 | }
|
244 | function isLazy(object) {
|
245 | return typeOf(object) === REACT_LAZY_TYPE;
|
246 | }
|
247 | function isMemo(object) {
|
248 | return typeOf(object) === REACT_MEMO_TYPE;
|
249 | }
|
250 | function isPortal(object) {
|
251 | return typeOf(object) === REACT_PORTAL_TYPE;
|
252 | }
|
253 | function isProfiler(object) {
|
254 | return typeOf(object) === REACT_PROFILER_TYPE;
|
255 | }
|
256 | function isStrictMode(object) {
|
257 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
258 | }
|
259 | function isSuspense(object) {
|
260 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
261 | }
|
262 |
|
263 | exports.typeOf = typeOf;
|
264 | exports.AsyncMode = AsyncMode;
|
265 | exports.ConcurrentMode = ConcurrentMode;
|
266 | exports.ContextConsumer = ContextConsumer;
|
267 | exports.ContextProvider = ContextProvider;
|
268 | exports.Element = Element;
|
269 | exports.ForwardRef = ForwardRef;
|
270 | exports.Fragment = Fragment;
|
271 | exports.Lazy = Lazy;
|
272 | exports.Memo = Memo;
|
273 | exports.Portal = Portal;
|
274 | exports.Profiler = Profiler;
|
275 | exports.StrictMode = StrictMode;
|
276 | exports.Suspense = Suspense;
|
277 | exports.isValidElementType = isValidElementType;
|
278 | exports.isAsyncMode = isAsyncMode;
|
279 | exports.isConcurrentMode = isConcurrentMode;
|
280 | exports.isContextConsumer = isContextConsumer;
|
281 | exports.isContextProvider = isContextProvider;
|
282 | exports.isElement = isElement;
|
283 | exports.isForwardRef = isForwardRef;
|
284 | exports.isFragment = isFragment;
|
285 | exports.isLazy = isLazy;
|
286 | exports.isMemo = isMemo;
|
287 | exports.isPortal = isPortal;
|
288 | exports.isProfiler = isProfiler;
|
289 | exports.isStrictMode = isStrictMode;
|
290 | exports.isSuspense = isSuspense;
|
291 | })();
|
292 | }
|
293 | });
|
294 |
|
295 | unwrapExports(reactIs_development);
|
296 | var reactIs_development_1 = reactIs_development.typeOf;
|
297 | var reactIs_development_2 = reactIs_development.AsyncMode;
|
298 | var reactIs_development_3 = reactIs_development.ConcurrentMode;
|
299 | var reactIs_development_4 = reactIs_development.ContextConsumer;
|
300 | var reactIs_development_5 = reactIs_development.ContextProvider;
|
301 | var reactIs_development_6 = reactIs_development.Element;
|
302 | var reactIs_development_7 = reactIs_development.ForwardRef;
|
303 | var reactIs_development_8 = reactIs_development.Fragment;
|
304 | var reactIs_development_9 = reactIs_development.Lazy;
|
305 | var reactIs_development_10 = reactIs_development.Memo;
|
306 | var reactIs_development_11 = reactIs_development.Portal;
|
307 | var reactIs_development_12 = reactIs_development.Profiler;
|
308 | var reactIs_development_13 = reactIs_development.StrictMode;
|
309 | var reactIs_development_14 = reactIs_development.Suspense;
|
310 | var reactIs_development_15 = reactIs_development.isValidElementType;
|
311 | var reactIs_development_16 = reactIs_development.isAsyncMode;
|
312 | var reactIs_development_17 = reactIs_development.isConcurrentMode;
|
313 | var reactIs_development_18 = reactIs_development.isContextConsumer;
|
314 | var reactIs_development_19 = reactIs_development.isContextProvider;
|
315 | var reactIs_development_20 = reactIs_development.isElement;
|
316 | var reactIs_development_21 = reactIs_development.isForwardRef;
|
317 | var reactIs_development_22 = reactIs_development.isFragment;
|
318 | var reactIs_development_23 = reactIs_development.isLazy;
|
319 | var reactIs_development_24 = reactIs_development.isMemo;
|
320 | var reactIs_development_25 = reactIs_development.isPortal;
|
321 | var reactIs_development_26 = reactIs_development.isProfiler;
|
322 | var reactIs_development_27 = reactIs_development.isStrictMode;
|
323 | var reactIs_development_28 = reactIs_development.isSuspense;
|
324 |
|
325 | var reactIs = createCommonjsModule(function (module) {
|
326 |
|
327 | {
|
328 | module.exports = reactIs_development;
|
329 | }
|
330 | });
|
331 | var reactIs_1 = reactIs.isValidElementType;
|
332 |
|
333 | |
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
340 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
341 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
342 |
|
343 | function toObject(val) {
|
344 | if (val === null || val === undefined) {
|
345 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
346 | }
|
347 |
|
348 | return Object(val);
|
349 | }
|
350 |
|
351 | function shouldUseNative() {
|
352 | try {
|
353 | if (!Object.assign) {
|
354 | return false;
|
355 | }
|
356 |
|
357 |
|
358 |
|
359 |
|
360 | var test1 = new String('abc');
|
361 | test1[5] = 'de';
|
362 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
363 | return false;
|
364 | }
|
365 |
|
366 |
|
367 | var test2 = {};
|
368 | for (var i = 0; i < 10; i++) {
|
369 | test2['_' + String.fromCharCode(i)] = i;
|
370 | }
|
371 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
372 | return test2[n];
|
373 | });
|
374 | if (order2.join('') !== '0123456789') {
|
375 | return false;
|
376 | }
|
377 |
|
378 |
|
379 | var test3 = {};
|
380 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
381 | test3[letter] = letter;
|
382 | });
|
383 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
384 | 'abcdefghijklmnopqrst') {
|
385 | return false;
|
386 | }
|
387 |
|
388 | return true;
|
389 | } catch (err) {
|
390 |
|
391 | return false;
|
392 | }
|
393 | }
|
394 |
|
395 | var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
396 | var from;
|
397 | var to = toObject(target);
|
398 | var symbols;
|
399 |
|
400 | for (var s = 1; s < arguments.length; s++) {
|
401 | from = Object(arguments[s]);
|
402 |
|
403 | for (var key in from) {
|
404 | if (hasOwnProperty.call(from, key)) {
|
405 | to[key] = from[key];
|
406 | }
|
407 | }
|
408 |
|
409 | if (getOwnPropertySymbols) {
|
410 | symbols = getOwnPropertySymbols(from);
|
411 | for (var i = 0; i < symbols.length; i++) {
|
412 | if (propIsEnumerable.call(from, symbols[i])) {
|
413 | to[symbols[i]] = from[symbols[i]];
|
414 | }
|
415 | }
|
416 | }
|
417 | }
|
418 |
|
419 | return to;
|
420 | };
|
421 |
|
422 | |
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
430 |
|
431 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
432 |
|
433 | var printWarning = function() {};
|
434 |
|
435 | {
|
436 | var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
437 | var loggedTypeFailures = {};
|
438 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
439 |
|
440 | printWarning = function(text) {
|
441 | var message = 'Warning: ' + text;
|
442 | if (typeof console !== 'undefined') {
|
443 | console.error(message);
|
444 | }
|
445 | try {
|
446 |
|
447 |
|
448 |
|
449 | throw new Error(message);
|
450 | } catch (x) {}
|
451 | };
|
452 | }
|
453 |
|
454 | |
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
466 | {
|
467 | for (var typeSpecName in typeSpecs) {
|
468 | if (has(typeSpecs, typeSpecName)) {
|
469 | var error;
|
470 |
|
471 |
|
472 |
|
473 | try {
|
474 |
|
475 |
|
476 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
477 | var err = Error(
|
478 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
479 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
480 | );
|
481 | err.name = 'Invariant Violation';
|
482 | throw err;
|
483 | }
|
484 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
485 | } catch (ex) {
|
486 | error = ex;
|
487 | }
|
488 | if (error && !(error instanceof Error)) {
|
489 | printWarning(
|
490 | (componentName || 'React class') + ': type specification of ' +
|
491 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
492 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
493 | 'You may have forgotten to pass an argument to the type checker ' +
|
494 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
495 | 'shape all require an argument).'
|
496 | );
|
497 | }
|
498 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
499 |
|
500 |
|
501 | loggedTypeFailures[error.message] = true;
|
502 |
|
503 | var stack = getStack ? getStack() : '';
|
504 |
|
505 | printWarning(
|
506 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
507 | );
|
508 | }
|
509 | }
|
510 | }
|
511 | }
|
512 | }
|
513 |
|
514 | |
515 |
|
516 |
|
517 |
|
518 |
|
519 | checkPropTypes.resetWarningCache = function() {
|
520 | {
|
521 | loggedTypeFailures = {};
|
522 | }
|
523 | };
|
524 |
|
525 | var checkPropTypes_1 = checkPropTypes;
|
526 |
|
527 | var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
528 | var printWarning$1 = function() {};
|
529 |
|
530 | {
|
531 | printWarning$1 = function(text) {
|
532 | var message = 'Warning: ' + text;
|
533 | if (typeof console !== 'undefined') {
|
534 | console.error(message);
|
535 | }
|
536 | try {
|
537 |
|
538 |
|
539 |
|
540 | throw new Error(message);
|
541 | } catch (x) {}
|
542 | };
|
543 | }
|
544 |
|
545 | function emptyFunctionThatReturnsNull() {
|
546 | return null;
|
547 | }
|
548 |
|
549 | var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
550 |
|
551 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
552 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
553 |
|
554 | |
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 | function getIteratorFn(maybeIterable) {
|
569 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
570 | if (typeof iteratorFn === 'function') {
|
571 | return iteratorFn;
|
572 | }
|
573 | }
|
574 |
|
575 | |
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 | var ANONYMOUS = '<<anonymous>>';
|
623 |
|
624 |
|
625 |
|
626 | var ReactPropTypes = {
|
627 | array: createPrimitiveTypeChecker('array'),
|
628 | bool: createPrimitiveTypeChecker('boolean'),
|
629 | func: createPrimitiveTypeChecker('function'),
|
630 | number: createPrimitiveTypeChecker('number'),
|
631 | object: createPrimitiveTypeChecker('object'),
|
632 | string: createPrimitiveTypeChecker('string'),
|
633 | symbol: createPrimitiveTypeChecker('symbol'),
|
634 |
|
635 | any: createAnyTypeChecker(),
|
636 | arrayOf: createArrayOfTypeChecker,
|
637 | element: createElementTypeChecker(),
|
638 | elementType: createElementTypeTypeChecker(),
|
639 | instanceOf: createInstanceTypeChecker,
|
640 | node: createNodeChecker(),
|
641 | objectOf: createObjectOfTypeChecker,
|
642 | oneOf: createEnumTypeChecker,
|
643 | oneOfType: createUnionTypeChecker,
|
644 | shape: createShapeTypeChecker,
|
645 | exact: createStrictShapeTypeChecker,
|
646 | };
|
647 |
|
648 | |
649 |
|
650 |
|
651 |
|
652 |
|
653 | function is(x, y) {
|
654 |
|
655 | if (x === y) {
|
656 |
|
657 |
|
658 | return x !== 0 || 1 / x === 1 / y;
|
659 | } else {
|
660 |
|
661 | return x !== x && y !== y;
|
662 | }
|
663 | }
|
664 |
|
665 |
|
666 | |
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 | function PropTypeError(message) {
|
674 | this.message = message;
|
675 | this.stack = '';
|
676 | }
|
677 |
|
678 | PropTypeError.prototype = Error.prototype;
|
679 |
|
680 | function createChainableTypeChecker(validate) {
|
681 | {
|
682 | var manualPropTypeCallCache = {};
|
683 | var manualPropTypeWarningCount = 0;
|
684 | }
|
685 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
686 | componentName = componentName || ANONYMOUS;
|
687 | propFullName = propFullName || propName;
|
688 |
|
689 | if (secret !== ReactPropTypesSecret_1) {
|
690 | if (throwOnDirectAccess) {
|
691 |
|
692 | var err = new Error(
|
693 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
694 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
695 | 'Read more at http://fb.me/use-check-prop-types'
|
696 | );
|
697 | err.name = 'Invariant Violation';
|
698 | throw err;
|
699 | } else if ( typeof console !== 'undefined') {
|
700 |
|
701 | var cacheKey = componentName + ':' + propName;
|
702 | if (
|
703 | !manualPropTypeCallCache[cacheKey] &&
|
704 |
|
705 | manualPropTypeWarningCount < 3
|
706 | ) {
|
707 | printWarning$1(
|
708 | 'You are manually calling a React.PropTypes validation ' +
|
709 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
710 | 'and will throw in the standalone `prop-types` package. ' +
|
711 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
712 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
713 | );
|
714 | manualPropTypeCallCache[cacheKey] = true;
|
715 | manualPropTypeWarningCount++;
|
716 | }
|
717 | }
|
718 | }
|
719 | if (props[propName] == null) {
|
720 | if (isRequired) {
|
721 | if (props[propName] === null) {
|
722 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
723 | }
|
724 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
725 | }
|
726 | return null;
|
727 | } else {
|
728 | return validate(props, propName, componentName, location, propFullName);
|
729 | }
|
730 | }
|
731 |
|
732 | var chainedCheckType = checkType.bind(null, false);
|
733 | chainedCheckType.isRequired = checkType.bind(null, true);
|
734 |
|
735 | return chainedCheckType;
|
736 | }
|
737 |
|
738 | function createPrimitiveTypeChecker(expectedType) {
|
739 | function validate(props, propName, componentName, location, propFullName, secret) {
|
740 | var propValue = props[propName];
|
741 | var propType = getPropType(propValue);
|
742 | if (propType !== expectedType) {
|
743 |
|
744 |
|
745 |
|
746 | var preciseType = getPreciseType(propValue);
|
747 |
|
748 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
749 | }
|
750 | return null;
|
751 | }
|
752 | return createChainableTypeChecker(validate);
|
753 | }
|
754 |
|
755 | function createAnyTypeChecker() {
|
756 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
757 | }
|
758 |
|
759 | function createArrayOfTypeChecker(typeChecker) {
|
760 | function validate(props, propName, componentName, location, propFullName) {
|
761 | if (typeof typeChecker !== 'function') {
|
762 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
763 | }
|
764 | var propValue = props[propName];
|
765 | if (!Array.isArray(propValue)) {
|
766 | var propType = getPropType(propValue);
|
767 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
768 | }
|
769 | for (var i = 0; i < propValue.length; i++) {
|
770 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
771 | if (error instanceof Error) {
|
772 | return error;
|
773 | }
|
774 | }
|
775 | return null;
|
776 | }
|
777 | return createChainableTypeChecker(validate);
|
778 | }
|
779 |
|
780 | function createElementTypeChecker() {
|
781 | function validate(props, propName, componentName, location, propFullName) {
|
782 | var propValue = props[propName];
|
783 | if (!isValidElement(propValue)) {
|
784 | var propType = getPropType(propValue);
|
785 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
786 | }
|
787 | return null;
|
788 | }
|
789 | return createChainableTypeChecker(validate);
|
790 | }
|
791 |
|
792 | function createElementTypeTypeChecker() {
|
793 | function validate(props, propName, componentName, location, propFullName) {
|
794 | var propValue = props[propName];
|
795 | if (!reactIs.isValidElementType(propValue)) {
|
796 | var propType = getPropType(propValue);
|
797 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
798 | }
|
799 | return null;
|
800 | }
|
801 | return createChainableTypeChecker(validate);
|
802 | }
|
803 |
|
804 | function createInstanceTypeChecker(expectedClass) {
|
805 | function validate(props, propName, componentName, location, propFullName) {
|
806 | if (!(props[propName] instanceof expectedClass)) {
|
807 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
808 | var actualClassName = getClassName(props[propName]);
|
809 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
810 | }
|
811 | return null;
|
812 | }
|
813 | return createChainableTypeChecker(validate);
|
814 | }
|
815 |
|
816 | function createEnumTypeChecker(expectedValues) {
|
817 | if (!Array.isArray(expectedValues)) {
|
818 | {
|
819 | if (arguments.length > 1) {
|
820 | printWarning$1(
|
821 | 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
822 | 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
823 | );
|
824 | } else {
|
825 | printWarning$1('Invalid argument supplied to oneOf, expected an array.');
|
826 | }
|
827 | }
|
828 | return emptyFunctionThatReturnsNull;
|
829 | }
|
830 |
|
831 | function validate(props, propName, componentName, location, propFullName) {
|
832 | var propValue = props[propName];
|
833 | for (var i = 0; i < expectedValues.length; i++) {
|
834 | if (is(propValue, expectedValues[i])) {
|
835 | return null;
|
836 | }
|
837 | }
|
838 |
|
839 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
840 | var type = getPreciseType(value);
|
841 | if (type === 'symbol') {
|
842 | return String(value);
|
843 | }
|
844 | return value;
|
845 | });
|
846 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
847 | }
|
848 | return createChainableTypeChecker(validate);
|
849 | }
|
850 |
|
851 | function createObjectOfTypeChecker(typeChecker) {
|
852 | function validate(props, propName, componentName, location, propFullName) {
|
853 | if (typeof typeChecker !== 'function') {
|
854 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
855 | }
|
856 | var propValue = props[propName];
|
857 | var propType = getPropType(propValue);
|
858 | if (propType !== 'object') {
|
859 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
860 | }
|
861 | for (var key in propValue) {
|
862 | if (has$1(propValue, key)) {
|
863 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
864 | if (error instanceof Error) {
|
865 | return error;
|
866 | }
|
867 | }
|
868 | }
|
869 | return null;
|
870 | }
|
871 | return createChainableTypeChecker(validate);
|
872 | }
|
873 |
|
874 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
875 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
876 | printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
|
877 | return emptyFunctionThatReturnsNull;
|
878 | }
|
879 |
|
880 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
881 | var checker = arrayOfTypeCheckers[i];
|
882 | if (typeof checker !== 'function') {
|
883 | printWarning$1(
|
884 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
885 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
886 | );
|
887 | return emptyFunctionThatReturnsNull;
|
888 | }
|
889 | }
|
890 |
|
891 | function validate(props, propName, componentName, location, propFullName) {
|
892 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
893 | var checker = arrayOfTypeCheckers[i];
|
894 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
895 | return null;
|
896 | }
|
897 | }
|
898 |
|
899 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
900 | }
|
901 | return createChainableTypeChecker(validate);
|
902 | }
|
903 |
|
904 | function createNodeChecker() {
|
905 | function validate(props, propName, componentName, location, propFullName) {
|
906 | if (!isNode(props[propName])) {
|
907 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
908 | }
|
909 | return null;
|
910 | }
|
911 | return createChainableTypeChecker(validate);
|
912 | }
|
913 |
|
914 | function createShapeTypeChecker(shapeTypes) {
|
915 | function validate(props, propName, componentName, location, propFullName) {
|
916 | var propValue = props[propName];
|
917 | var propType = getPropType(propValue);
|
918 | if (propType !== 'object') {
|
919 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
920 | }
|
921 | for (var key in shapeTypes) {
|
922 | var checker = shapeTypes[key];
|
923 | if (!checker) {
|
924 | continue;
|
925 | }
|
926 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
927 | if (error) {
|
928 | return error;
|
929 | }
|
930 | }
|
931 | return null;
|
932 | }
|
933 | return createChainableTypeChecker(validate);
|
934 | }
|
935 |
|
936 | function createStrictShapeTypeChecker(shapeTypes) {
|
937 | function validate(props, propName, componentName, location, propFullName) {
|
938 | var propValue = props[propName];
|
939 | var propType = getPropType(propValue);
|
940 | if (propType !== 'object') {
|
941 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
942 | }
|
943 |
|
944 |
|
945 | var allKeys = objectAssign({}, props[propName], shapeTypes);
|
946 | for (var key in allKeys) {
|
947 | var checker = shapeTypes[key];
|
948 | if (!checker) {
|
949 | return new PropTypeError(
|
950 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
951 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
952 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
953 | );
|
954 | }
|
955 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
956 | if (error) {
|
957 | return error;
|
958 | }
|
959 | }
|
960 | return null;
|
961 | }
|
962 |
|
963 | return createChainableTypeChecker(validate);
|
964 | }
|
965 |
|
966 | function isNode(propValue) {
|
967 | switch (typeof propValue) {
|
968 | case 'number':
|
969 | case 'string':
|
970 | case 'undefined':
|
971 | return true;
|
972 | case 'boolean':
|
973 | return !propValue;
|
974 | case 'object':
|
975 | if (Array.isArray(propValue)) {
|
976 | return propValue.every(isNode);
|
977 | }
|
978 | if (propValue === null || isValidElement(propValue)) {
|
979 | return true;
|
980 | }
|
981 |
|
982 | var iteratorFn = getIteratorFn(propValue);
|
983 | if (iteratorFn) {
|
984 | var iterator = iteratorFn.call(propValue);
|
985 | var step;
|
986 | if (iteratorFn !== propValue.entries) {
|
987 | while (!(step = iterator.next()).done) {
|
988 | if (!isNode(step.value)) {
|
989 | return false;
|
990 | }
|
991 | }
|
992 | } else {
|
993 |
|
994 | while (!(step = iterator.next()).done) {
|
995 | var entry = step.value;
|
996 | if (entry) {
|
997 | if (!isNode(entry[1])) {
|
998 | return false;
|
999 | }
|
1000 | }
|
1001 | }
|
1002 | }
|
1003 | } else {
|
1004 | return false;
|
1005 | }
|
1006 |
|
1007 | return true;
|
1008 | default:
|
1009 | return false;
|
1010 | }
|
1011 | }
|
1012 |
|
1013 | function isSymbol(propType, propValue) {
|
1014 |
|
1015 | if (propType === 'symbol') {
|
1016 | return true;
|
1017 | }
|
1018 |
|
1019 |
|
1020 | if (!propValue) {
|
1021 | return false;
|
1022 | }
|
1023 |
|
1024 |
|
1025 | if (propValue['@@toStringTag'] === 'Symbol') {
|
1026 | return true;
|
1027 | }
|
1028 |
|
1029 |
|
1030 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
1031 | return true;
|
1032 | }
|
1033 |
|
1034 | return false;
|
1035 | }
|
1036 |
|
1037 |
|
1038 | function getPropType(propValue) {
|
1039 | var propType = typeof propValue;
|
1040 | if (Array.isArray(propValue)) {
|
1041 | return 'array';
|
1042 | }
|
1043 | if (propValue instanceof RegExp) {
|
1044 |
|
1045 |
|
1046 |
|
1047 | return 'object';
|
1048 | }
|
1049 | if (isSymbol(propType, propValue)) {
|
1050 | return 'symbol';
|
1051 | }
|
1052 | return propType;
|
1053 | }
|
1054 |
|
1055 |
|
1056 |
|
1057 | function getPreciseType(propValue) {
|
1058 | if (typeof propValue === 'undefined' || propValue === null) {
|
1059 | return '' + propValue;
|
1060 | }
|
1061 | var propType = getPropType(propValue);
|
1062 | if (propType === 'object') {
|
1063 | if (propValue instanceof Date) {
|
1064 | return 'date';
|
1065 | } else if (propValue instanceof RegExp) {
|
1066 | return 'regexp';
|
1067 | }
|
1068 | }
|
1069 | return propType;
|
1070 | }
|
1071 |
|
1072 |
|
1073 |
|
1074 | function getPostfixForTypeWarning(value) {
|
1075 | var type = getPreciseType(value);
|
1076 | switch (type) {
|
1077 | case 'array':
|
1078 | case 'object':
|
1079 | return 'an ' + type;
|
1080 | case 'boolean':
|
1081 | case 'date':
|
1082 | case 'regexp':
|
1083 | return 'a ' + type;
|
1084 | default:
|
1085 | return type;
|
1086 | }
|
1087 | }
|
1088 |
|
1089 |
|
1090 | function getClassName(propValue) {
|
1091 | if (!propValue.constructor || !propValue.constructor.name) {
|
1092 | return ANONYMOUS;
|
1093 | }
|
1094 | return propValue.constructor.name;
|
1095 | }
|
1096 |
|
1097 | ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
1098 | ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
|
1099 | ReactPropTypes.PropTypes = ReactPropTypes;
|
1100 |
|
1101 | return ReactPropTypes;
|
1102 | };
|
1103 |
|
1104 | var propTypes = createCommonjsModule(function (module) {
|
1105 | |
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 | {
|
1113 | var ReactIs = reactIs;
|
1114 |
|
1115 |
|
1116 |
|
1117 | var throwOnDirectAccess = true;
|
1118 | module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
|
1119 | }
|
1120 | });
|
1121 |
|
1122 | function _extends() {
|
1123 | _extends = Object.assign || function (target) {
|
1124 | for (var i = 1; i < arguments.length; i++) {
|
1125 | var source = arguments[i];
|
1126 |
|
1127 | for (var key in source) {
|
1128 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
1129 | target[key] = source[key];
|
1130 | }
|
1131 | }
|
1132 | }
|
1133 |
|
1134 | return target;
|
1135 | };
|
1136 |
|
1137 | return _extends.apply(this, arguments);
|
1138 | }
|
1139 |
|
1140 | function isAbsolute(pathname) {
|
1141 | return pathname.charAt(0) === '/';
|
1142 | }
|
1143 |
|
1144 |
|
1145 | function spliceOne(list, index) {
|
1146 | for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
1147 | list[i] = list[k];
|
1148 | }
|
1149 |
|
1150 | list.pop();
|
1151 | }
|
1152 |
|
1153 |
|
1154 | function resolvePathname(to) {
|
1155 | var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
1156 |
|
1157 | var toParts = to && to.split('/') || [];
|
1158 | var fromParts = from && from.split('/') || [];
|
1159 |
|
1160 | var isToAbs = to && isAbsolute(to);
|
1161 | var isFromAbs = from && isAbsolute(from);
|
1162 | var mustEndAbs = isToAbs || isFromAbs;
|
1163 |
|
1164 | if (to && isAbsolute(to)) {
|
1165 |
|
1166 | fromParts = toParts;
|
1167 | } else if (toParts.length) {
|
1168 |
|
1169 | fromParts.pop();
|
1170 | fromParts = fromParts.concat(toParts);
|
1171 | }
|
1172 |
|
1173 | if (!fromParts.length) return '/';
|
1174 |
|
1175 | var hasTrailingSlash = void 0;
|
1176 | if (fromParts.length) {
|
1177 | var last = fromParts[fromParts.length - 1];
|
1178 | hasTrailingSlash = last === '.' || last === '..' || last === '';
|
1179 | } else {
|
1180 | hasTrailingSlash = false;
|
1181 | }
|
1182 |
|
1183 | var up = 0;
|
1184 | for (var i = fromParts.length; i >= 0; i--) {
|
1185 | var part = fromParts[i];
|
1186 |
|
1187 | if (part === '.') {
|
1188 | spliceOne(fromParts, i);
|
1189 | } else if (part === '..') {
|
1190 | spliceOne(fromParts, i);
|
1191 | up++;
|
1192 | } else if (up) {
|
1193 | spliceOne(fromParts, i);
|
1194 | up--;
|
1195 | }
|
1196 | }
|
1197 |
|
1198 | if (!mustEndAbs) for (; up--; up) {
|
1199 | fromParts.unshift('..');
|
1200 | }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
|
1201 |
|
1202 | var result = fromParts.join('/');
|
1203 |
|
1204 | if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
1205 |
|
1206 | return result;
|
1207 | }
|
1208 |
|
1209 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
1210 |
|
1211 | function valueEqual(a, b) {
|
1212 | if (a === b) return true;
|
1213 |
|
1214 | if (a == null || b == null) return false;
|
1215 |
|
1216 | if (Array.isArray(a)) {
|
1217 | return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
|
1218 | return valueEqual(item, b[index]);
|
1219 | });
|
1220 | }
|
1221 |
|
1222 | var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
|
1223 | var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
|
1224 |
|
1225 | if (aType !== bType) return false;
|
1226 |
|
1227 | if (aType === 'object') {
|
1228 | var aValue = a.valueOf();
|
1229 | var bValue = b.valueOf();
|
1230 |
|
1231 | if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
|
1232 |
|
1233 | var aKeys = Object.keys(a);
|
1234 | var bKeys = Object.keys(b);
|
1235 |
|
1236 | if (aKeys.length !== bKeys.length) return false;
|
1237 |
|
1238 | return aKeys.every(function (key) {
|
1239 | return valueEqual(a[key], b[key]);
|
1240 | });
|
1241 | }
|
1242 |
|
1243 | return false;
|
1244 | }
|
1245 |
|
1246 | function warning(condition, message) {
|
1247 | {
|
1248 | if (condition) {
|
1249 | return;
|
1250 | }
|
1251 |
|
1252 | var text = "Warning: " + message;
|
1253 |
|
1254 | if (typeof console !== 'undefined') {
|
1255 | console.warn(text);
|
1256 | }
|
1257 |
|
1258 | try {
|
1259 | throw Error(text);
|
1260 | } catch (x) {}
|
1261 | }
|
1262 | }
|
1263 |
|
1264 | var prefix = 'Invariant failed';
|
1265 | function invariant(condition, message) {
|
1266 | if (condition) {
|
1267 | return;
|
1268 | }
|
1269 |
|
1270 | {
|
1271 | throw new Error(prefix + ": " + (message || ''));
|
1272 | }
|
1273 | }
|
1274 |
|
1275 | function parsePath(path) {
|
1276 | var pathname = path || '/';
|
1277 | var search = '';
|
1278 | var hash = '';
|
1279 | var hashIndex = pathname.indexOf('#');
|
1280 |
|
1281 | if (hashIndex !== -1) {
|
1282 | hash = pathname.substr(hashIndex);
|
1283 | pathname = pathname.substr(0, hashIndex);
|
1284 | }
|
1285 |
|
1286 | var searchIndex = pathname.indexOf('?');
|
1287 |
|
1288 | if (searchIndex !== -1) {
|
1289 | search = pathname.substr(searchIndex);
|
1290 | pathname = pathname.substr(0, searchIndex);
|
1291 | }
|
1292 |
|
1293 | return {
|
1294 | pathname: pathname,
|
1295 | search: search === '?' ? '' : search,
|
1296 | hash: hash === '#' ? '' : hash
|
1297 | };
|
1298 | }
|
1299 | function createPath(location) {
|
1300 | var pathname = location.pathname,
|
1301 | search = location.search,
|
1302 | hash = location.hash;
|
1303 | var path = pathname || '/';
|
1304 | if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
|
1305 | if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
|
1306 | return path;
|
1307 | }
|
1308 |
|
1309 | function createLocation(path, state, key, currentLocation) {
|
1310 | var location;
|
1311 |
|
1312 | if (typeof path === 'string') {
|
1313 |
|
1314 | location = parsePath(path);
|
1315 | location.state = state;
|
1316 | } else {
|
1317 |
|
1318 | location = _extends({}, path);
|
1319 | if (location.pathname === undefined) location.pathname = '';
|
1320 |
|
1321 | if (location.search) {
|
1322 | if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
|
1323 | } else {
|
1324 | location.search = '';
|
1325 | }
|
1326 |
|
1327 | if (location.hash) {
|
1328 | if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
|
1329 | } else {
|
1330 | location.hash = '';
|
1331 | }
|
1332 |
|
1333 | if (state !== undefined && location.state === undefined) location.state = state;
|
1334 | }
|
1335 |
|
1336 | try {
|
1337 | location.pathname = decodeURI(location.pathname);
|
1338 | } catch (e) {
|
1339 | if (e instanceof URIError) {
|
1340 | throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
|
1341 | } else {
|
1342 | throw e;
|
1343 | }
|
1344 | }
|
1345 |
|
1346 | if (key) location.key = key;
|
1347 |
|
1348 | if (currentLocation) {
|
1349 |
|
1350 | if (!location.pathname) {
|
1351 | location.pathname = currentLocation.pathname;
|
1352 | } else if (location.pathname.charAt(0) !== '/') {
|
1353 | location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
|
1354 | }
|
1355 | } else {
|
1356 |
|
1357 | if (!location.pathname) {
|
1358 | location.pathname = '/';
|
1359 | }
|
1360 | }
|
1361 |
|
1362 | return location;
|
1363 | }
|
1364 | function locationsAreEqual(a, b) {
|
1365 | return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
|
1366 | }
|
1367 |
|
1368 | function createTransitionManager() {
|
1369 | var prompt = null;
|
1370 |
|
1371 | function setPrompt(nextPrompt) {
|
1372 | warning(prompt == null, 'A history supports only one prompt at a time') ;
|
1373 | prompt = nextPrompt;
|
1374 | return function () {
|
1375 | if (prompt === nextPrompt) prompt = null;
|
1376 | };
|
1377 | }
|
1378 |
|
1379 | function confirmTransitionTo(location, action, getUserConfirmation, callback) {
|
1380 |
|
1381 |
|
1382 |
|
1383 | if (prompt != null) {
|
1384 | var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
|
1385 |
|
1386 | if (typeof result === 'string') {
|
1387 | if (typeof getUserConfirmation === 'function') {
|
1388 | getUserConfirmation(result, callback);
|
1389 | } else {
|
1390 | warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') ;
|
1391 | callback(true);
|
1392 | }
|
1393 | } else {
|
1394 |
|
1395 | callback(result !== false);
|
1396 | }
|
1397 | } else {
|
1398 | callback(true);
|
1399 | }
|
1400 | }
|
1401 |
|
1402 | var listeners = [];
|
1403 |
|
1404 | function appendListener(fn) {
|
1405 | var isActive = true;
|
1406 |
|
1407 | function listener() {
|
1408 | if (isActive) fn.apply(void 0, arguments);
|
1409 | }
|
1410 |
|
1411 | listeners.push(listener);
|
1412 | return function () {
|
1413 | isActive = false;
|
1414 | listeners = listeners.filter(function (item) {
|
1415 | return item !== listener;
|
1416 | });
|
1417 | };
|
1418 | }
|
1419 |
|
1420 | function notifyListeners() {
|
1421 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1422 | args[_key] = arguments[_key];
|
1423 | }
|
1424 |
|
1425 | listeners.forEach(function (listener) {
|
1426 | return listener.apply(void 0, args);
|
1427 | });
|
1428 | }
|
1429 |
|
1430 | return {
|
1431 | setPrompt: setPrompt,
|
1432 | confirmTransitionTo: confirmTransitionTo,
|
1433 | appendListener: appendListener,
|
1434 | notifyListeners: notifyListeners
|
1435 | };
|
1436 | }
|
1437 |
|
1438 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
1439 |
|
1440 | function clamp(n, lowerBound, upperBound) {
|
1441 | return Math.min(Math.max(n, lowerBound), upperBound);
|
1442 | }
|
1443 | |
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 | function createMemoryHistory(props) {
|
1449 | if (props === void 0) {
|
1450 | props = {};
|
1451 | }
|
1452 |
|
1453 | var _props = props,
|
1454 | getUserConfirmation = _props.getUserConfirmation,
|
1455 | _props$initialEntries = _props.initialEntries,
|
1456 | initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
|
1457 | _props$initialIndex = _props.initialIndex,
|
1458 | initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
|
1459 | _props$keyLength = _props.keyLength,
|
1460 | keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
|
1461 | var transitionManager = createTransitionManager();
|
1462 |
|
1463 | function setState(nextState) {
|
1464 | _extends(history, nextState);
|
1465 |
|
1466 | history.length = history.entries.length;
|
1467 | transitionManager.notifyListeners(history.location, history.action);
|
1468 | }
|
1469 |
|
1470 | function createKey() {
|
1471 | return Math.random().toString(36).substr(2, keyLength);
|
1472 | }
|
1473 |
|
1474 | var index = clamp(initialIndex, 0, initialEntries.length - 1);
|
1475 | var entries = initialEntries.map(function (entry) {
|
1476 | return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
|
1477 | });
|
1478 |
|
1479 | var createHref = createPath;
|
1480 |
|
1481 | function push(path, state) {
|
1482 | warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
|
1483 | var action = 'PUSH';
|
1484 | var location = createLocation(path, state, createKey(), history.location);
|
1485 | transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
1486 | if (!ok) return;
|
1487 | var prevIndex = history.index;
|
1488 | var nextIndex = prevIndex + 1;
|
1489 | var nextEntries = history.entries.slice(0);
|
1490 |
|
1491 | if (nextEntries.length > nextIndex) {
|
1492 | nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
|
1493 | } else {
|
1494 | nextEntries.push(location);
|
1495 | }
|
1496 |
|
1497 | setState({
|
1498 | action: action,
|
1499 | location: location,
|
1500 | index: nextIndex,
|
1501 | entries: nextEntries
|
1502 | });
|
1503 | });
|
1504 | }
|
1505 |
|
1506 | function replace(path, state) {
|
1507 | warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
|
1508 | var action = 'REPLACE';
|
1509 | var location = createLocation(path, state, createKey(), history.location);
|
1510 | transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
1511 | if (!ok) return;
|
1512 | history.entries[history.index] = location;
|
1513 | setState({
|
1514 | action: action,
|
1515 | location: location
|
1516 | });
|
1517 | });
|
1518 | }
|
1519 |
|
1520 | function go(n) {
|
1521 | var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
|
1522 | var action = 'POP';
|
1523 | var location = history.entries[nextIndex];
|
1524 | transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
1525 | if (ok) {
|
1526 | setState({
|
1527 | action: action,
|
1528 | location: location,
|
1529 | index: nextIndex
|
1530 | });
|
1531 | } else {
|
1532 |
|
1533 |
|
1534 | setState();
|
1535 | }
|
1536 | });
|
1537 | }
|
1538 |
|
1539 | function goBack() {
|
1540 | go(-1);
|
1541 | }
|
1542 |
|
1543 | function goForward() {
|
1544 | go(1);
|
1545 | }
|
1546 |
|
1547 | function canGo(n) {
|
1548 | var nextIndex = history.index + n;
|
1549 | return nextIndex >= 0 && nextIndex < history.entries.length;
|
1550 | }
|
1551 |
|
1552 | function block(prompt) {
|
1553 | if (prompt === void 0) {
|
1554 | prompt = false;
|
1555 | }
|
1556 |
|
1557 | return transitionManager.setPrompt(prompt);
|
1558 | }
|
1559 |
|
1560 | function listen(listener) {
|
1561 | return transitionManager.appendListener(listener);
|
1562 | }
|
1563 |
|
1564 | var history = {
|
1565 | length: entries.length,
|
1566 | action: 'POP',
|
1567 | location: entries[index],
|
1568 | index: index,
|
1569 | entries: entries,
|
1570 | createHref: createHref,
|
1571 | push: push,
|
1572 | replace: replace,
|
1573 | go: go,
|
1574 | goBack: goBack,
|
1575 | goForward: goForward,
|
1576 | canGo: canGo,
|
1577 | block: block,
|
1578 | listen: listen
|
1579 | };
|
1580 | return history;
|
1581 | }
|
1582 |
|
1583 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
1584 | var commonjsGlobal = typeof globalThis !== "undefined"
|
1585 | ?
|
1586 | globalThis : typeof window !== "undefined" ? window
|
1587 | : typeof global !== "undefined" ? global
|
1588 | : {};
|
1589 |
|
1590 | function getUniqueId() {
|
1591 | var key = "__global_unique_id__";
|
1592 | return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
|
1593 | }
|
1594 |
|
1595 |
|
1596 |
|
1597 | function objectIs(x, y) {
|
1598 | if (x === y) {
|
1599 | return x !== 0 || 1 / x === 1 / y;
|
1600 | } else {
|
1601 |
|
1602 | return x !== x && y !== y;
|
1603 | }
|
1604 | }
|
1605 |
|
1606 | function createEventEmitter(value) {
|
1607 | var handlers = [];
|
1608 | return {
|
1609 | on: function on(handler) {
|
1610 | handlers.push(handler);
|
1611 | },
|
1612 | off: function off(handler) {
|
1613 | handlers = handlers.filter(function (h) {
|
1614 | return h !== handler;
|
1615 | });
|
1616 | },
|
1617 | get: function get() {
|
1618 | return value;
|
1619 | },
|
1620 | set: function set(newValue, changedBits) {
|
1621 | value = newValue;
|
1622 | handlers.forEach(function (handler) {
|
1623 | return handler(value, changedBits);
|
1624 | });
|
1625 | }
|
1626 | };
|
1627 | }
|
1628 |
|
1629 | function onlyChild(children) {
|
1630 | return Array.isArray(children) ? children[0] : children;
|
1631 | }
|
1632 |
|
1633 | function createReactContext(defaultValue, calculateChangedBits) {
|
1634 | var _Provider$childContex, _Consumer$contextType;
|
1635 |
|
1636 | var contextProp = "__create-react-context-" + getUniqueId() + "__";
|
1637 |
|
1638 | var Provider = function (_React$Component) {
|
1639 | _inheritsLoose(Provider, _React$Component);
|
1640 |
|
1641 | function Provider() {
|
1642 | var _this;
|
1643 |
|
1644 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1645 | args[_key] = arguments[_key];
|
1646 | }
|
1647 |
|
1648 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
1649 | _this.emitter = createEventEmitter(_this.props.value);
|
1650 | return _this;
|
1651 | }
|
1652 |
|
1653 | var _proto = Provider.prototype;
|
1654 |
|
1655 | _proto.getChildContext = function getChildContext() {
|
1656 | var _ref;
|
1657 |
|
1658 | return _ref = {}, _ref[contextProp] = this.emitter, _ref;
|
1659 | };
|
1660 |
|
1661 | _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1662 | if (this.props.value !== nextProps.value) {
|
1663 | var oldValue = this.props.value;
|
1664 | var newValue = nextProps.value;
|
1665 | var changedBits;
|
1666 |
|
1667 | if (objectIs(oldValue, newValue)) {
|
1668 | changedBits = 0;
|
1669 | } else {
|
1670 | changedBits = typeof calculateChangedBits === "function" ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
1671 |
|
1672 | {
|
1673 | warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, "calculateChangedBits: Expected the return value to be a " + "31-bit integer. Instead received: " + changedBits) ;
|
1674 | }
|
1675 |
|
1676 | changedBits |= 0;
|
1677 |
|
1678 | if (changedBits !== 0) {
|
1679 | this.emitter.set(nextProps.value, changedBits);
|
1680 | }
|
1681 | }
|
1682 | }
|
1683 | };
|
1684 |
|
1685 | _proto.render = function render() {
|
1686 | return this.props.children;
|
1687 | };
|
1688 |
|
1689 | return Provider;
|
1690 | }(React.Component);
|
1691 |
|
1692 | Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
|
1693 |
|
1694 | var Consumer = function (_React$Component2) {
|
1695 | _inheritsLoose(Consumer, _React$Component2);
|
1696 |
|
1697 | function Consumer() {
|
1698 | var _this2;
|
1699 |
|
1700 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
1701 | args[_key2] = arguments[_key2];
|
1702 | }
|
1703 |
|
1704 | _this2 = _React$Component2.call.apply(_React$Component2, [this].concat(args)) || this;
|
1705 | _this2.observedBits = void 0;
|
1706 | _this2.state = {
|
1707 | value: _this2.getValue()
|
1708 | };
|
1709 |
|
1710 | _this2.onUpdate = function (newValue, changedBits) {
|
1711 | var observedBits = _this2.observedBits | 0;
|
1712 |
|
1713 | if ((observedBits & changedBits) !== 0) {
|
1714 | _this2.setState({
|
1715 | value: _this2.getValue()
|
1716 | });
|
1717 | }
|
1718 | };
|
1719 |
|
1720 | return _this2;
|
1721 | }
|
1722 |
|
1723 | var _proto2 = Consumer.prototype;
|
1724 |
|
1725 | _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1726 | var observedBits = nextProps.observedBits;
|
1727 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
1728 | : observedBits;
|
1729 | };
|
1730 |
|
1731 | _proto2.componentDidMount = function componentDidMount() {
|
1732 | if (this.context[contextProp]) {
|
1733 | this.context[contextProp].on(this.onUpdate);
|
1734 | }
|
1735 |
|
1736 | var observedBits = this.props.observedBits;
|
1737 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
1738 | : observedBits;
|
1739 | };
|
1740 |
|
1741 | _proto2.componentWillUnmount = function componentWillUnmount() {
|
1742 | if (this.context[contextProp]) {
|
1743 | this.context[contextProp].off(this.onUpdate);
|
1744 | }
|
1745 | };
|
1746 |
|
1747 | _proto2.getValue = function getValue() {
|
1748 | if (this.context[contextProp]) {
|
1749 | return this.context[contextProp].get();
|
1750 | } else {
|
1751 | return defaultValue;
|
1752 | }
|
1753 | };
|
1754 |
|
1755 | _proto2.render = function render() {
|
1756 | return onlyChild(this.props.children)(this.state.value);
|
1757 | };
|
1758 |
|
1759 | return Consumer;
|
1760 | }(React.Component);
|
1761 |
|
1762 | Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = propTypes.object, _Consumer$contextType);
|
1763 | return {
|
1764 | Provider: Provider,
|
1765 | Consumer: Consumer
|
1766 | };
|
1767 | }
|
1768 |
|
1769 |
|
1770 | var createContext = React.createContext || createReactContext;
|
1771 |
|
1772 |
|
1773 |
|
1774 | var createNamedContext = function createNamedContext(name) {
|
1775 | var context = createContext();
|
1776 | context.displayName = name;
|
1777 | return context;
|
1778 | };
|
1779 |
|
1780 | var historyContext = createNamedContext("Router-History");
|
1781 |
|
1782 | var context = createNamedContext("Router");
|
1783 |
|
1784 | |
1785 |
|
1786 |
|
1787 |
|
1788 | var Router = function (_React$Component) {
|
1789 | _inheritsLoose(Router, _React$Component);
|
1790 |
|
1791 | Router.computeRootMatch = function computeRootMatch(pathname) {
|
1792 | return {
|
1793 | path: "/",
|
1794 | url: "/",
|
1795 | params: {},
|
1796 | isExact: pathname === "/"
|
1797 | };
|
1798 | };
|
1799 |
|
1800 | function Router(props) {
|
1801 | var _this;
|
1802 |
|
1803 | _this = _React$Component.call(this, props) || this;
|
1804 | _this.state = {
|
1805 | location: props.history.location
|
1806 | };
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 |
|
1812 | _this._isMounted = false;
|
1813 | _this._pendingLocation = null;
|
1814 |
|
1815 | if (!props.staticContext) {
|
1816 | _this.unlisten = props.history.listen(function (location) {
|
1817 | _this._pendingLocation = location;
|
1818 | });
|
1819 | }
|
1820 |
|
1821 | return _this;
|
1822 | }
|
1823 |
|
1824 | var _proto = Router.prototype;
|
1825 |
|
1826 | _proto.componentDidMount = function componentDidMount() {
|
1827 | var _this2 = this;
|
1828 |
|
1829 | this._isMounted = true;
|
1830 |
|
1831 | if (this.unlisten) {
|
1832 |
|
1833 |
|
1834 | this.unlisten();
|
1835 | }
|
1836 |
|
1837 | if (!this.props.staticContext) {
|
1838 | this.unlisten = this.props.history.listen(function (location) {
|
1839 | if (_this2._isMounted) {
|
1840 | _this2.setState({
|
1841 | location: location
|
1842 | });
|
1843 | }
|
1844 | });
|
1845 | }
|
1846 |
|
1847 | if (this._pendingLocation) {
|
1848 | this.setState({
|
1849 | location: this._pendingLocation
|
1850 | });
|
1851 | }
|
1852 | };
|
1853 |
|
1854 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1855 | if (this.unlisten) {
|
1856 | this.unlisten();
|
1857 | this._isMounted = false;
|
1858 | this._pendingLocation = null;
|
1859 | }
|
1860 | };
|
1861 |
|
1862 | _proto.render = function render() {
|
1863 | return React.createElement(context.Provider, {
|
1864 | value: {
|
1865 | history: this.props.history,
|
1866 | location: this.state.location,
|
1867 | match: Router.computeRootMatch(this.state.location.pathname),
|
1868 | staticContext: this.props.staticContext
|
1869 | }
|
1870 | }, React.createElement(historyContext.Provider, {
|
1871 | children: this.props.children || null,
|
1872 | value: this.props.history
|
1873 | }));
|
1874 | };
|
1875 |
|
1876 | return Router;
|
1877 | }(React.Component);
|
1878 |
|
1879 | {
|
1880 | Router.propTypes = {
|
1881 | children: propTypes.node,
|
1882 | history: propTypes.object.isRequired,
|
1883 | staticContext: propTypes.object
|
1884 | };
|
1885 |
|
1886 | Router.prototype.componentDidUpdate = function (prevProps) {
|
1887 | warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
|
1888 | };
|
1889 | }
|
1890 |
|
1891 | |
1892 |
|
1893 |
|
1894 |
|
1895 | var MemoryRouter = function (_React$Component) {
|
1896 | _inheritsLoose(MemoryRouter, _React$Component);
|
1897 |
|
1898 | function MemoryRouter() {
|
1899 | var _this;
|
1900 |
|
1901 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1902 | args[_key] = arguments[_key];
|
1903 | }
|
1904 |
|
1905 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
1906 | _this.history = createMemoryHistory(_this.props);
|
1907 | return _this;
|
1908 | }
|
1909 |
|
1910 | var _proto = MemoryRouter.prototype;
|
1911 |
|
1912 | _proto.render = function render() {
|
1913 | return React.createElement(Router, {
|
1914 | history: this.history,
|
1915 | children: this.props.children
|
1916 | });
|
1917 | };
|
1918 |
|
1919 | return MemoryRouter;
|
1920 | }(React.Component);
|
1921 |
|
1922 | {
|
1923 | MemoryRouter.propTypes = {
|
1924 | initialEntries: propTypes.array,
|
1925 | initialIndex: propTypes.number,
|
1926 | getUserConfirmation: propTypes.func,
|
1927 | keyLength: propTypes.number,
|
1928 | children: propTypes.node
|
1929 | };
|
1930 |
|
1931 | MemoryRouter.prototype.componentDidMount = function () {
|
1932 | warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
|
1933 | };
|
1934 | }
|
1935 |
|
1936 | var Lifecycle = function (_React$Component) {
|
1937 | _inheritsLoose(Lifecycle, _React$Component);
|
1938 |
|
1939 | function Lifecycle() {
|
1940 | return _React$Component.apply(this, arguments) || this;
|
1941 | }
|
1942 |
|
1943 | var _proto = Lifecycle.prototype;
|
1944 |
|
1945 | _proto.componentDidMount = function componentDidMount() {
|
1946 | if (this.props.onMount) this.props.onMount.call(this, this);
|
1947 | };
|
1948 |
|
1949 | _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
1950 | if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
|
1951 | };
|
1952 |
|
1953 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1954 | if (this.props.onUnmount) this.props.onUnmount.call(this, this);
|
1955 | };
|
1956 |
|
1957 | _proto.render = function render() {
|
1958 | return null;
|
1959 | };
|
1960 |
|
1961 | return Lifecycle;
|
1962 | }(React.Component);
|
1963 |
|
1964 | |
1965 |
|
1966 |
|
1967 |
|
1968 | function Prompt(_ref) {
|
1969 | var message = _ref.message,
|
1970 | _ref$when = _ref.when,
|
1971 | when = _ref$when === void 0 ? true : _ref$when;
|
1972 | return React.createElement(context.Consumer, null, function (context) {
|
1973 | !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
|
1974 | if (!when || context.staticContext) return null;
|
1975 | var method = context.history.block;
|
1976 | return React.createElement(Lifecycle, {
|
1977 | onMount: function onMount(self) {
|
1978 | self.release = method(message);
|
1979 | },
|
1980 | onUpdate: function onUpdate(self, prevProps) {
|
1981 | if (prevProps.message !== message) {
|
1982 | self.release();
|
1983 | self.release = method(message);
|
1984 | }
|
1985 | },
|
1986 | onUnmount: function onUnmount(self) {
|
1987 | self.release();
|
1988 | },
|
1989 | message: message
|
1990 | });
|
1991 | });
|
1992 | }
|
1993 |
|
1994 | {
|
1995 | var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
|
1996 | Prompt.propTypes = {
|
1997 | when: propTypes.bool,
|
1998 | message: messageType.isRequired
|
1999 | };
|
2000 | }
|
2001 |
|
2002 | var isarray = Array.isArray || function (arr) {
|
2003 | return Object.prototype.toString.call(arr) == '[object Array]';
|
2004 | };
|
2005 |
|
2006 | |
2007 |
|
2008 |
|
2009 | var pathToRegexp_1 = pathToRegexp;
|
2010 | var parse_1 = parse;
|
2011 | var compile_1 = compile;
|
2012 | var tokensToFunction_1 = tokensToFunction;
|
2013 | var tokensToRegExp_1 = tokensToRegExp;
|
2014 |
|
2015 | |
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 | var PATH_REGEXP = new RegExp([
|
2021 |
|
2022 |
|
2023 | '(\\\\.)',
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 | '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
|
2031 | ].join('|'), 'g');
|
2032 |
|
2033 | |
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 |
|
2040 | function parse (str, options) {
|
2041 | var tokens = [];
|
2042 | var key = 0;
|
2043 | var index = 0;
|
2044 | var path = '';
|
2045 | var defaultDelimiter = options && options.delimiter || '/';
|
2046 | var res;
|
2047 |
|
2048 | while ((res = PATH_REGEXP.exec(str)) != null) {
|
2049 | var m = res[0];
|
2050 | var escaped = res[1];
|
2051 | var offset = res.index;
|
2052 | path += str.slice(index, offset);
|
2053 | index = offset + m.length;
|
2054 |
|
2055 |
|
2056 | if (escaped) {
|
2057 | path += escaped[1];
|
2058 | continue
|
2059 | }
|
2060 |
|
2061 | var next = str[index];
|
2062 | var prefix = res[2];
|
2063 | var name = res[3];
|
2064 | var capture = res[4];
|
2065 | var group = res[5];
|
2066 | var modifier = res[6];
|
2067 | var asterisk = res[7];
|
2068 |
|
2069 |
|
2070 | if (path) {
|
2071 | tokens.push(path);
|
2072 | path = '';
|
2073 | }
|
2074 |
|
2075 | var partial = prefix != null && next != null && next !== prefix;
|
2076 | var repeat = modifier === '+' || modifier === '*';
|
2077 | var optional = modifier === '?' || modifier === '*';
|
2078 | var delimiter = res[2] || defaultDelimiter;
|
2079 | var pattern = capture || group;
|
2080 |
|
2081 | tokens.push({
|
2082 | name: name || key++,
|
2083 | prefix: prefix || '',
|
2084 | delimiter: delimiter,
|
2085 | optional: optional,
|
2086 | repeat: repeat,
|
2087 | partial: partial,
|
2088 | asterisk: !!asterisk,
|
2089 | pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
|
2090 | });
|
2091 | }
|
2092 |
|
2093 |
|
2094 | if (index < str.length) {
|
2095 | path += str.substr(index);
|
2096 | }
|
2097 |
|
2098 |
|
2099 | if (path) {
|
2100 | tokens.push(path);
|
2101 | }
|
2102 |
|
2103 | return tokens
|
2104 | }
|
2105 |
|
2106 | |
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 | function compile (str, options) {
|
2114 | return tokensToFunction(parse(str, options))
|
2115 | }
|
2116 |
|
2117 | |
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 | function encodeURIComponentPretty (str) {
|
2124 | return encodeURI(str).replace(/[\/?#]/g, function (c) {
|
2125 | return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
2126 | })
|
2127 | }
|
2128 |
|
2129 | |
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 | function encodeAsterisk (str) {
|
2136 | return encodeURI(str).replace(/[?#]/g, function (c) {
|
2137 | return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
2138 | })
|
2139 | }
|
2140 |
|
2141 | |
2142 |
|
2143 |
|
2144 | function tokensToFunction (tokens) {
|
2145 |
|
2146 | var matches = new Array(tokens.length);
|
2147 |
|
2148 |
|
2149 | for (var i = 0; i < tokens.length; i++) {
|
2150 | if (typeof tokens[i] === 'object') {
|
2151 | matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
|
2152 | }
|
2153 | }
|
2154 |
|
2155 | return function (obj, opts) {
|
2156 | var path = '';
|
2157 | var data = obj || {};
|
2158 | var options = opts || {};
|
2159 | var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
|
2160 |
|
2161 | for (var i = 0; i < tokens.length; i++) {
|
2162 | var token = tokens[i];
|
2163 |
|
2164 | if (typeof token === 'string') {
|
2165 | path += token;
|
2166 |
|
2167 | continue
|
2168 | }
|
2169 |
|
2170 | var value = data[token.name];
|
2171 | var segment;
|
2172 |
|
2173 | if (value == null) {
|
2174 | if (token.optional) {
|
2175 |
|
2176 | if (token.partial) {
|
2177 | path += token.prefix;
|
2178 | }
|
2179 |
|
2180 | continue
|
2181 | } else {
|
2182 | throw new TypeError('Expected "' + token.name + '" to be defined')
|
2183 | }
|
2184 | }
|
2185 |
|
2186 | if (isarray(value)) {
|
2187 | if (!token.repeat) {
|
2188 | throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
|
2189 | }
|
2190 |
|
2191 | if (value.length === 0) {
|
2192 | if (token.optional) {
|
2193 | continue
|
2194 | } else {
|
2195 | throw new TypeError('Expected "' + token.name + '" to not be empty')
|
2196 | }
|
2197 | }
|
2198 |
|
2199 | for (var j = 0; j < value.length; j++) {
|
2200 | segment = encode(value[j]);
|
2201 |
|
2202 | if (!matches[i].test(segment)) {
|
2203 | throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
|
2204 | }
|
2205 |
|
2206 | path += (j === 0 ? token.prefix : token.delimiter) + segment;
|
2207 | }
|
2208 |
|
2209 | continue
|
2210 | }
|
2211 |
|
2212 | segment = token.asterisk ? encodeAsterisk(value) : encode(value);
|
2213 |
|
2214 | if (!matches[i].test(segment)) {
|
2215 | throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
|
2216 | }
|
2217 |
|
2218 | path += token.prefix + segment;
|
2219 | }
|
2220 |
|
2221 | return path
|
2222 | }
|
2223 | }
|
2224 |
|
2225 | |
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 | function escapeString (str) {
|
2232 | return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
|
2233 | }
|
2234 |
|
2235 | |
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 | function escapeGroup (group) {
|
2242 | return group.replace(/([=!:$\/()])/g, '\\$1')
|
2243 | }
|
2244 |
|
2245 | |
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 | function attachKeys (re, keys) {
|
2253 | re.keys = keys;
|
2254 | return re
|
2255 | }
|
2256 |
|
2257 | |
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 | function flags (options) {
|
2264 | return options.sensitive ? '' : 'i'
|
2265 | }
|
2266 |
|
2267 | |
2268 |
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 | function regexpToRegexp (path, keys) {
|
2275 |
|
2276 | var groups = path.source.match(/\((?!\?)/g);
|
2277 |
|
2278 | if (groups) {
|
2279 | for (var i = 0; i < groups.length; i++) {
|
2280 | keys.push({
|
2281 | name: i,
|
2282 | prefix: null,
|
2283 | delimiter: null,
|
2284 | optional: false,
|
2285 | repeat: false,
|
2286 | partial: false,
|
2287 | asterisk: false,
|
2288 | pattern: null
|
2289 | });
|
2290 | }
|
2291 | }
|
2292 |
|
2293 | return attachKeys(path, keys)
|
2294 | }
|
2295 |
|
2296 | |
2297 |
|
2298 |
|
2299 |
|
2300 |
|
2301 |
|
2302 |
|
2303 |
|
2304 | function arrayToRegexp (path, keys, options) {
|
2305 | var parts = [];
|
2306 |
|
2307 | for (var i = 0; i < path.length; i++) {
|
2308 | parts.push(pathToRegexp(path[i], keys, options).source);
|
2309 | }
|
2310 |
|
2311 | var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
|
2312 |
|
2313 | return attachKeys(regexp, keys)
|
2314 | }
|
2315 |
|
2316 | |
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 |
|
2323 |
|
2324 | function stringToRegexp (path, keys, options) {
|
2325 | return tokensToRegExp(parse(path, options), keys, options)
|
2326 | }
|
2327 |
|
2328 | |
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 | function tokensToRegExp (tokens, keys, options) {
|
2337 | if (!isarray(keys)) {
|
2338 | options = (keys || options);
|
2339 | keys = [];
|
2340 | }
|
2341 |
|
2342 | options = options || {};
|
2343 |
|
2344 | var strict = options.strict;
|
2345 | var end = options.end !== false;
|
2346 | var route = '';
|
2347 |
|
2348 |
|
2349 | for (var i = 0; i < tokens.length; i++) {
|
2350 | var token = tokens[i];
|
2351 |
|
2352 | if (typeof token === 'string') {
|
2353 | route += escapeString(token);
|
2354 | } else {
|
2355 | var prefix = escapeString(token.prefix);
|
2356 | var capture = '(?:' + token.pattern + ')';
|
2357 |
|
2358 | keys.push(token);
|
2359 |
|
2360 | if (token.repeat) {
|
2361 | capture += '(?:' + prefix + capture + ')*';
|
2362 | }
|
2363 |
|
2364 | if (token.optional) {
|
2365 | if (!token.partial) {
|
2366 | capture = '(?:' + prefix + '(' + capture + '))?';
|
2367 | } else {
|
2368 | capture = prefix + '(' + capture + ')?';
|
2369 | }
|
2370 | } else {
|
2371 | capture = prefix + '(' + capture + ')';
|
2372 | }
|
2373 |
|
2374 | route += capture;
|
2375 | }
|
2376 | }
|
2377 |
|
2378 | var delimiter = escapeString(options.delimiter || '/');
|
2379 | var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 | if (!strict) {
|
2386 | route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
|
2387 | }
|
2388 |
|
2389 | if (end) {
|
2390 | route += '$';
|
2391 | } else {
|
2392 |
|
2393 |
|
2394 | route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
|
2395 | }
|
2396 |
|
2397 | return attachKeys(new RegExp('^' + route, flags(options)), keys)
|
2398 | }
|
2399 |
|
2400 | |
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 | function pathToRegexp (path, keys, options) {
|
2413 | if (!isarray(keys)) {
|
2414 | options = (keys || options);
|
2415 | keys = [];
|
2416 | }
|
2417 |
|
2418 | options = options || {};
|
2419 |
|
2420 | if (path instanceof RegExp) {
|
2421 | return regexpToRegexp(path, (keys))
|
2422 | }
|
2423 |
|
2424 | if (isarray(path)) {
|
2425 | return arrayToRegexp( (path), (keys), options)
|
2426 | }
|
2427 |
|
2428 | return stringToRegexp( (path), (keys), options)
|
2429 | }
|
2430 | pathToRegexp_1.parse = parse_1;
|
2431 | pathToRegexp_1.compile = compile_1;
|
2432 | pathToRegexp_1.tokensToFunction = tokensToFunction_1;
|
2433 | pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
|
2434 |
|
2435 | var cache = {};
|
2436 | var cacheLimit = 10000;
|
2437 | var cacheCount = 0;
|
2438 |
|
2439 | function compilePath(path) {
|
2440 | if (cache[path]) return cache[path];
|
2441 | var generator = pathToRegexp_1.compile(path);
|
2442 |
|
2443 | if (cacheCount < cacheLimit) {
|
2444 | cache[path] = generator;
|
2445 | cacheCount++;
|
2446 | }
|
2447 |
|
2448 | return generator;
|
2449 | }
|
2450 | |
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 | function generatePath(path, params) {
|
2456 | if (path === void 0) {
|
2457 | path = "/";
|
2458 | }
|
2459 |
|
2460 | if (params === void 0) {
|
2461 | params = {};
|
2462 | }
|
2463 |
|
2464 | return path === "/" ? path : compilePath(path)(params, {
|
2465 | pretty: true
|
2466 | });
|
2467 | }
|
2468 |
|
2469 | |
2470 |
|
2471 |
|
2472 |
|
2473 | function Redirect(_ref) {
|
2474 | var computedMatch = _ref.computedMatch,
|
2475 | to = _ref.to,
|
2476 | _ref$push = _ref.push,
|
2477 | push = _ref$push === void 0 ? false : _ref$push;
|
2478 | return React.createElement(context.Consumer, null, function (context) {
|
2479 | !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
|
2480 | var history = context.history,
|
2481 | staticContext = context.staticContext;
|
2482 | var method = push ? history.push : history.replace;
|
2483 | var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
|
2484 | pathname: generatePath(to.pathname, computedMatch.params)
|
2485 | }) : to);
|
2486 |
|
2487 |
|
2488 | if (staticContext) {
|
2489 | method(location);
|
2490 | return null;
|
2491 | }
|
2492 |
|
2493 | return React.createElement(Lifecycle, {
|
2494 | onMount: function onMount() {
|
2495 | method(location);
|
2496 | },
|
2497 | onUpdate: function onUpdate(self, prevProps) {
|
2498 | var prevLocation = createLocation(prevProps.to);
|
2499 |
|
2500 | if (!locationsAreEqual(prevLocation, _extends({}, location, {
|
2501 | key: prevLocation.key
|
2502 | }))) {
|
2503 | method(location);
|
2504 | }
|
2505 | },
|
2506 | to: to
|
2507 | });
|
2508 | });
|
2509 | }
|
2510 |
|
2511 | {
|
2512 | Redirect.propTypes = {
|
2513 | push: propTypes.bool,
|
2514 | from: propTypes.string,
|
2515 | to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
|
2516 | };
|
2517 | }
|
2518 |
|
2519 | var cache$1 = {};
|
2520 | var cacheLimit$1 = 10000;
|
2521 | var cacheCount$1 = 0;
|
2522 |
|
2523 | function compilePath$1(path, options) {
|
2524 | var cacheKey = "" + options.end + options.strict + options.sensitive;
|
2525 | var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
|
2526 | if (pathCache[path]) return pathCache[path];
|
2527 | var keys = [];
|
2528 | var regexp = pathToRegexp_1(path, keys, options);
|
2529 | var result = {
|
2530 | regexp: regexp,
|
2531 | keys: keys
|
2532 | };
|
2533 |
|
2534 | if (cacheCount$1 < cacheLimit$1) {
|
2535 | pathCache[path] = result;
|
2536 | cacheCount$1++;
|
2537 | }
|
2538 |
|
2539 | return result;
|
2540 | }
|
2541 | |
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 | function matchPath(pathname, options) {
|
2547 | if (options === void 0) {
|
2548 | options = {};
|
2549 | }
|
2550 |
|
2551 | if (typeof options === "string" || Array.isArray(options)) {
|
2552 | options = {
|
2553 | path: options
|
2554 | };
|
2555 | }
|
2556 |
|
2557 | var _options = options,
|
2558 | path = _options.path,
|
2559 | _options$exact = _options.exact,
|
2560 | exact = _options$exact === void 0 ? false : _options$exact,
|
2561 | _options$strict = _options.strict,
|
2562 | strict = _options$strict === void 0 ? false : _options$strict,
|
2563 | _options$sensitive = _options.sensitive,
|
2564 | sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
|
2565 | var paths = [].concat(path);
|
2566 | return paths.reduce(function (matched, path) {
|
2567 | if (!path && path !== "") return null;
|
2568 | if (matched) return matched;
|
2569 |
|
2570 | var _compilePath = compilePath$1(path, {
|
2571 | end: exact,
|
2572 | strict: strict,
|
2573 | sensitive: sensitive
|
2574 | }),
|
2575 | regexp = _compilePath.regexp,
|
2576 | keys = _compilePath.keys;
|
2577 |
|
2578 | var match = regexp.exec(pathname);
|
2579 | if (!match) return null;
|
2580 | var url = match[0],
|
2581 | values = match.slice(1);
|
2582 | var isExact = pathname === url;
|
2583 | if (exact && !isExact) return null;
|
2584 | return {
|
2585 | path: path,
|
2586 |
|
2587 | url: path === "/" && url === "" ? "/" : url,
|
2588 |
|
2589 | isExact: isExact,
|
2590 |
|
2591 | params: keys.reduce(function (memo, key, index) {
|
2592 | memo[key.name] = values[index];
|
2593 | return memo;
|
2594 | }, {})
|
2595 | };
|
2596 | }, null);
|
2597 | }
|
2598 |
|
2599 | function isEmptyChildren(children) {
|
2600 | return React.Children.count(children) === 0;
|
2601 | }
|
2602 |
|
2603 | function evalChildrenDev(children, props, path) {
|
2604 | var value = children(props);
|
2605 | warning(value !== undefined, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") ;
|
2606 | return value || null;
|
2607 | }
|
2608 | |
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 | var Route = function (_React$Component) {
|
2614 | _inheritsLoose(Route, _React$Component);
|
2615 |
|
2616 | function Route() {
|
2617 | return _React$Component.apply(this, arguments) || this;
|
2618 | }
|
2619 |
|
2620 | var _proto = Route.prototype;
|
2621 |
|
2622 | _proto.render = function render() {
|
2623 | var _this = this;
|
2624 |
|
2625 | return React.createElement(context.Consumer, null, function (context$1) {
|
2626 | !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
|
2627 | var location = _this.props.location || context$1.location;
|
2628 | var match = _this.props.computedMatch ? _this.props.computedMatch
|
2629 | : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
|
2630 |
|
2631 | var props = _extends({}, context$1, {
|
2632 | location: location,
|
2633 | match: match
|
2634 | });
|
2635 |
|
2636 | var _this$props = _this.props,
|
2637 | children = _this$props.children,
|
2638 | component = _this$props.component,
|
2639 | render = _this$props.render;
|
2640 |
|
2641 |
|
2642 | if (Array.isArray(children) && isEmptyChildren(children)) {
|
2643 | children = null;
|
2644 | }
|
2645 |
|
2646 | return React.createElement(context.Provider, {
|
2647 | value: props
|
2648 | }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? React.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
|
2649 | });
|
2650 | };
|
2651 |
|
2652 | return Route;
|
2653 | }(React.Component);
|
2654 |
|
2655 | {
|
2656 | Route.propTypes = {
|
2657 | children: propTypes.oneOfType([propTypes.func, propTypes.node]),
|
2658 | component: function component(props, propName) {
|
2659 | if (props[propName] && !reactIs_1(props[propName])) {
|
2660 | return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
|
2661 | }
|
2662 | },
|
2663 | exact: propTypes.bool,
|
2664 | location: propTypes.object,
|
2665 | path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
|
2666 | render: propTypes.func,
|
2667 | sensitive: propTypes.bool,
|
2668 | strict: propTypes.bool
|
2669 | };
|
2670 |
|
2671 | Route.prototype.componentDidMount = function () {
|
2672 | warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.component), "You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored") ;
|
2673 | warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.render), "You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored") ;
|
2674 | warning(!(this.props.component && this.props.render), "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored") ;
|
2675 | };
|
2676 |
|
2677 | Route.prototype.componentDidUpdate = function (prevProps) {
|
2678 | warning(!(this.props.location && !prevProps.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
|
2679 | warning(!(!this.props.location && prevProps.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
|
2680 | };
|
2681 | }
|
2682 |
|
2683 | function _objectWithoutPropertiesLoose(source, excluded) {
|
2684 | if (source == null) return {};
|
2685 | var target = {};
|
2686 | var sourceKeys = Object.keys(source);
|
2687 | var key, i;
|
2688 |
|
2689 | for (i = 0; i < sourceKeys.length; i++) {
|
2690 | key = sourceKeys[i];
|
2691 | if (excluded.indexOf(key) >= 0) continue;
|
2692 | target[key] = source[key];
|
2693 | }
|
2694 |
|
2695 | return target;
|
2696 | }
|
2697 |
|
2698 | function addLeadingSlash(path) {
|
2699 | return path.charAt(0) === "/" ? path : "/" + path;
|
2700 | }
|
2701 |
|
2702 | function addBasename(basename, location) {
|
2703 | if (!basename) return location;
|
2704 | return _extends({}, location, {
|
2705 | pathname: addLeadingSlash(basename) + location.pathname
|
2706 | });
|
2707 | }
|
2708 |
|
2709 | function stripBasename(basename, location) {
|
2710 | if (!basename) return location;
|
2711 | var base = addLeadingSlash(basename);
|
2712 | if (location.pathname.indexOf(base) !== 0) return location;
|
2713 | return _extends({}, location, {
|
2714 | pathname: location.pathname.substr(base.length)
|
2715 | });
|
2716 | }
|
2717 |
|
2718 | function createURL(location) {
|
2719 | return typeof location === "string" ? location : createPath(location);
|
2720 | }
|
2721 |
|
2722 | function staticHandler(methodName) {
|
2723 | return function () {
|
2724 | invariant(false, "You cannot %s with <StaticRouter>") ;
|
2725 | };
|
2726 | }
|
2727 |
|
2728 | function noop() {}
|
2729 | |
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 |
|
2736 |
|
2737 | var StaticRouter = function (_React$Component) {
|
2738 | _inheritsLoose(StaticRouter, _React$Component);
|
2739 |
|
2740 | function StaticRouter() {
|
2741 | var _this;
|
2742 |
|
2743 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2744 | args[_key] = arguments[_key];
|
2745 | }
|
2746 |
|
2747 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
2748 |
|
2749 | _this.handlePush = function (location) {
|
2750 | return _this.navigateTo(location, "PUSH");
|
2751 | };
|
2752 |
|
2753 | _this.handleReplace = function (location) {
|
2754 | return _this.navigateTo(location, "REPLACE");
|
2755 | };
|
2756 |
|
2757 | _this.handleListen = function () {
|
2758 | return noop;
|
2759 | };
|
2760 |
|
2761 | _this.handleBlock = function () {
|
2762 | return noop;
|
2763 | };
|
2764 |
|
2765 | return _this;
|
2766 | }
|
2767 |
|
2768 | var _proto = StaticRouter.prototype;
|
2769 |
|
2770 | _proto.navigateTo = function navigateTo(location, action) {
|
2771 | var _this$props = this.props,
|
2772 | _this$props$basename = _this$props.basename,
|
2773 | basename = _this$props$basename === void 0 ? "" : _this$props$basename,
|
2774 | _this$props$context = _this$props.context,
|
2775 | context = _this$props$context === void 0 ? {} : _this$props$context;
|
2776 | context.action = action;
|
2777 | context.location = addBasename(basename, createLocation(location));
|
2778 | context.url = createURL(context.location);
|
2779 | };
|
2780 |
|
2781 | _proto.render = function render() {
|
2782 | var _this$props2 = this.props,
|
2783 | _this$props2$basename = _this$props2.basename,
|
2784 | basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
|
2785 | _this$props2$context = _this$props2.context,
|
2786 | context = _this$props2$context === void 0 ? {} : _this$props2$context,
|
2787 | _this$props2$location = _this$props2.location,
|
2788 | location = _this$props2$location === void 0 ? "/" : _this$props2$location,
|
2789 | rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
|
2790 |
|
2791 | var history = {
|
2792 | createHref: function createHref(path) {
|
2793 | return addLeadingSlash(basename + createURL(path));
|
2794 | },
|
2795 | action: "POP",
|
2796 | location: stripBasename(basename, createLocation(location)),
|
2797 | push: this.handlePush,
|
2798 | replace: this.handleReplace,
|
2799 | go: staticHandler(),
|
2800 | goBack: staticHandler(),
|
2801 | goForward: staticHandler(),
|
2802 | listen: this.handleListen,
|
2803 | block: this.handleBlock
|
2804 | };
|
2805 | return React.createElement(Router, _extends({}, rest, {
|
2806 | history: history,
|
2807 | staticContext: context
|
2808 | }));
|
2809 | };
|
2810 |
|
2811 | return StaticRouter;
|
2812 | }(React.Component);
|
2813 |
|
2814 | {
|
2815 | StaticRouter.propTypes = {
|
2816 | basename: propTypes.string,
|
2817 | context: propTypes.object,
|
2818 | location: propTypes.oneOfType([propTypes.string, propTypes.object])
|
2819 | };
|
2820 |
|
2821 | StaticRouter.prototype.componentDidMount = function () {
|
2822 | warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
|
2823 | };
|
2824 | }
|
2825 |
|
2826 | |
2827 |
|
2828 |
|
2829 |
|
2830 | var Switch = function (_React$Component) {
|
2831 | _inheritsLoose(Switch, _React$Component);
|
2832 |
|
2833 | function Switch() {
|
2834 | return _React$Component.apply(this, arguments) || this;
|
2835 | }
|
2836 |
|
2837 | var _proto = Switch.prototype;
|
2838 |
|
2839 | _proto.render = function render() {
|
2840 | var _this = this;
|
2841 |
|
2842 | return React.createElement(context.Consumer, null, function (context) {
|
2843 | !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
|
2844 | var location = _this.props.location || context.location;
|
2845 | var element, match;
|
2846 |
|
2847 |
|
2848 |
|
2849 |
|
2850 | React.Children.forEach(_this.props.children, function (child) {
|
2851 | if (match == null && React.isValidElement(child)) {
|
2852 | element = child;
|
2853 | var path = child.props.path || child.props.from;
|
2854 | match = path ? matchPath(location.pathname, _extends({}, child.props, {
|
2855 | path: path
|
2856 | })) : context.match;
|
2857 | }
|
2858 | });
|
2859 | return match ? React.cloneElement(element, {
|
2860 | location: location,
|
2861 | computedMatch: match
|
2862 | }) : null;
|
2863 | });
|
2864 | };
|
2865 |
|
2866 | return Switch;
|
2867 | }(React.Component);
|
2868 |
|
2869 | {
|
2870 | Switch.propTypes = {
|
2871 | children: propTypes.node,
|
2872 | location: propTypes.object
|
2873 | };
|
2874 |
|
2875 | Switch.prototype.componentDidUpdate = function (prevProps) {
|
2876 | warning(!(this.props.location && !prevProps.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
|
2877 | warning(!(!this.props.location && prevProps.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
|
2878 | };
|
2879 | }
|
2880 |
|
2881 | |
2882 |
|
2883 |
|
2884 |
|
2885 |
|
2886 | var REACT_STATICS = {
|
2887 | childContextTypes: true,
|
2888 | contextType: true,
|
2889 | contextTypes: true,
|
2890 | defaultProps: true,
|
2891 | displayName: true,
|
2892 | getDefaultProps: true,
|
2893 | getDerivedStateFromError: true,
|
2894 | getDerivedStateFromProps: true,
|
2895 | mixins: true,
|
2896 | propTypes: true,
|
2897 | type: true
|
2898 | };
|
2899 |
|
2900 | var KNOWN_STATICS = {
|
2901 | name: true,
|
2902 | length: true,
|
2903 | prototype: true,
|
2904 | caller: true,
|
2905 | callee: true,
|
2906 | arguments: true,
|
2907 | arity: true
|
2908 | };
|
2909 |
|
2910 | var FORWARD_REF_STATICS = {
|
2911 | '$$typeof': true,
|
2912 | render: true,
|
2913 | defaultProps: true,
|
2914 | displayName: true,
|
2915 | propTypes: true
|
2916 | };
|
2917 |
|
2918 | var MEMO_STATICS = {
|
2919 | '$$typeof': true,
|
2920 | compare: true,
|
2921 | defaultProps: true,
|
2922 | displayName: true,
|
2923 | propTypes: true,
|
2924 | type: true
|
2925 | };
|
2926 |
|
2927 | var TYPE_STATICS = {};
|
2928 | TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
2929 |
|
2930 | function getStatics(component) {
|
2931 | if (reactIs.isMemo(component)) {
|
2932 | return MEMO_STATICS;
|
2933 | }
|
2934 | return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
2935 | }
|
2936 |
|
2937 | var defineProperty = Object.defineProperty;
|
2938 | var getOwnPropertyNames = Object.getOwnPropertyNames;
|
2939 | var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
|
2940 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
2941 | var getPrototypeOf = Object.getPrototypeOf;
|
2942 | var objectPrototype = Object.prototype;
|
2943 |
|
2944 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
2945 | if (typeof sourceComponent !== 'string') {
|
2946 |
|
2947 |
|
2948 | if (objectPrototype) {
|
2949 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
2950 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
2951 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
2952 | }
|
2953 | }
|
2954 |
|
2955 | var keys = getOwnPropertyNames(sourceComponent);
|
2956 |
|
2957 | if (getOwnPropertySymbols$1) {
|
2958 | keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
|
2959 | }
|
2960 |
|
2961 | var targetStatics = getStatics(targetComponent);
|
2962 | var sourceStatics = getStatics(sourceComponent);
|
2963 |
|
2964 | for (var i = 0; i < keys.length; ++i) {
|
2965 | var key = keys[i];
|
2966 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
2967 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
2968 | try {
|
2969 |
|
2970 | defineProperty(targetComponent, key, descriptor);
|
2971 | } catch (e) {}
|
2972 | }
|
2973 | }
|
2974 |
|
2975 | return targetComponent;
|
2976 | }
|
2977 |
|
2978 | return targetComponent;
|
2979 | }
|
2980 |
|
2981 | var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
2982 |
|
2983 | |
2984 |
|
2985 |
|
2986 |
|
2987 | function withRouter(Component) {
|
2988 | var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
|
2989 |
|
2990 | var C = function C(props) {
|
2991 | var wrappedComponentRef = props.wrappedComponentRef,
|
2992 | remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
|
2993 |
|
2994 | return React.createElement(context.Consumer, null, function (context) {
|
2995 | !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
|
2996 | return React.createElement(Component, _extends({}, remainingProps, context, {
|
2997 | ref: wrappedComponentRef
|
2998 | }));
|
2999 | });
|
3000 | };
|
3001 |
|
3002 | C.displayName = displayName;
|
3003 | C.WrappedComponent = Component;
|
3004 |
|
3005 | {
|
3006 | C.propTypes = {
|
3007 | wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
|
3008 | };
|
3009 | }
|
3010 |
|
3011 | return hoistNonReactStatics_cjs(C, Component);
|
3012 | }
|
3013 |
|
3014 | var useContext = React.useContext;
|
3015 | function useHistory() {
|
3016 | {
|
3017 | !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
|
3018 | }
|
3019 |
|
3020 | return useContext(historyContext);
|
3021 | }
|
3022 | function useLocation() {
|
3023 | {
|
3024 | !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
|
3025 | }
|
3026 |
|
3027 | return useContext(context).location;
|
3028 | }
|
3029 | function useParams() {
|
3030 | {
|
3031 | !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
|
3032 | }
|
3033 |
|
3034 | var match = useContext(context).match;
|
3035 | return match ? match.params : {};
|
3036 | }
|
3037 | function useRouteMatch(path) {
|
3038 | {
|
3039 | !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
|
3040 | }
|
3041 |
|
3042 | var location = useLocation();
|
3043 | var match = useContext(context).match;
|
3044 | return path ? matchPath(location.pathname, path) : match;
|
3045 | }
|
3046 |
|
3047 | {
|
3048 | if (typeof window !== "undefined") {
|
3049 | var global$1 = window;
|
3050 | var key = "__react_router_build__";
|
3051 | var buildNames = {
|
3052 | cjs: "CommonJS",
|
3053 | esm: "ES modules",
|
3054 | umd: "UMD"
|
3055 | };
|
3056 |
|
3057 | if (global$1[key] && global$1[key] !== "umd") {
|
3058 | var initialBuildName = buildNames[global$1[key]];
|
3059 | var secondaryBuildName = buildNames["umd"];
|
3060 |
|
3061 |
|
3062 | throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
|
3063 | }
|
3064 |
|
3065 | global$1[key] = "umd";
|
3066 | }
|
3067 | }
|
3068 |
|
3069 | exports.MemoryRouter = MemoryRouter;
|
3070 | exports.Prompt = Prompt;
|
3071 | exports.Redirect = Redirect;
|
3072 | exports.Route = Route;
|
3073 | exports.Router = Router;
|
3074 | exports.StaticRouter = StaticRouter;
|
3075 | exports.Switch = Switch;
|
3076 | exports.__HistoryContext = historyContext;
|
3077 | exports.__RouterContext = context;
|
3078 | exports.generatePath = generatePath;
|
3079 | exports.matchPath = matchPath;
|
3080 | exports.useHistory = useHistory;
|
3081 | exports.useLocation = useLocation;
|
3082 | exports.useParams = useParams;
|
3083 | exports.useRouteMatch = useRouteMatch;
|
3084 | exports.withRouter = withRouter;
|
3085 |
|
3086 | Object.defineProperty(exports, '__esModule', { value: true });
|
3087 |
|
3088 | }));
|
3089 |
|