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