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 | React = React && React.hasOwnProperty('default') ? 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 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 | |
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 | function makeEmptyFunction(arg) {
|
1246 | return function () {
|
1247 | return arg;
|
1248 | };
|
1249 | }
|
1250 |
|
1251 | |
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 | var emptyFunction$1 = function emptyFunction() {};
|
1257 |
|
1258 | emptyFunction$1.thatReturns = makeEmptyFunction;
|
1259 | emptyFunction$1.thatReturnsFalse = makeEmptyFunction(false);
|
1260 | emptyFunction$1.thatReturnsTrue = makeEmptyFunction(true);
|
1261 | emptyFunction$1.thatReturnsNull = makeEmptyFunction(null);
|
1262 | emptyFunction$1.thatReturnsThis = function () {
|
1263 | return this;
|
1264 | };
|
1265 | emptyFunction$1.thatReturnsArgument = function (arg) {
|
1266 | return arg;
|
1267 | };
|
1268 |
|
1269 | var emptyFunction_1 = emptyFunction$1;
|
1270 |
|
1271 | |
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 | var warning$1 = emptyFunction_1;
|
1279 |
|
1280 | {
|
1281 | var printWarning$2 = function printWarning(format) {
|
1282 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1283 | args[_key - 1] = arguments[_key];
|
1284 | }
|
1285 |
|
1286 | var argIndex = 0;
|
1287 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
1288 | return args[argIndex++];
|
1289 | });
|
1290 | if (typeof console !== 'undefined') {
|
1291 | console.error(message);
|
1292 | }
|
1293 | try {
|
1294 |
|
1295 |
|
1296 |
|
1297 | throw new Error(message);
|
1298 | } catch (x) {}
|
1299 | };
|
1300 |
|
1301 | warning$1 = function warning(condition, format) {
|
1302 | if (format === undefined) {
|
1303 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
1304 | }
|
1305 |
|
1306 | if (format.indexOf('Failed Composite propType: ') === 0) {
|
1307 | return;
|
1308 | }
|
1309 |
|
1310 | if (!condition) {
|
1311 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
1312 | args[_key2 - 2] = arguments[_key2];
|
1313 | }
|
1314 |
|
1315 | printWarning$2.apply(undefined, [format].concat(args));
|
1316 | }
|
1317 | };
|
1318 | }
|
1319 |
|
1320 | var warning_1 = warning$1;
|
1321 |
|
1322 | var implementation = createCommonjsModule(function (module, exports) {
|
1323 |
|
1324 | exports.__esModule = true;
|
1325 |
|
1326 |
|
1327 |
|
1328 | var _react2 = _interopRequireDefault(React);
|
1329 |
|
1330 |
|
1331 |
|
1332 | var _propTypes2 = _interopRequireDefault(propTypes);
|
1333 |
|
1334 |
|
1335 |
|
1336 | var _gud2 = _interopRequireDefault(gud);
|
1337 |
|
1338 |
|
1339 |
|
1340 | var _warning2 = _interopRequireDefault(warning_1);
|
1341 |
|
1342 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1343 |
|
1344 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1345 |
|
1346 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
1347 |
|
1348 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
1349 |
|
1350 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
1351 |
|
1352 |
|
1353 |
|
1354 | function objectIs(x, y) {
|
1355 | if (x === y) {
|
1356 | return x !== 0 || 1 / x === 1 / y;
|
1357 | } else {
|
1358 | return x !== x && y !== y;
|
1359 | }
|
1360 | }
|
1361 |
|
1362 | function createEventEmitter(value) {
|
1363 | var handlers = [];
|
1364 | return {
|
1365 | on: function on(handler) {
|
1366 | handlers.push(handler);
|
1367 | },
|
1368 | off: function off(handler) {
|
1369 | handlers = handlers.filter(function (h) {
|
1370 | return h !== handler;
|
1371 | });
|
1372 | },
|
1373 | get: function get() {
|
1374 | return value;
|
1375 | },
|
1376 | set: function set(newValue, changedBits) {
|
1377 | value = newValue;
|
1378 | handlers.forEach(function (handler) {
|
1379 | return handler(value, changedBits);
|
1380 | });
|
1381 | }
|
1382 | };
|
1383 | }
|
1384 |
|
1385 | function onlyChild(children) {
|
1386 | return Array.isArray(children) ? children[0] : children;
|
1387 | }
|
1388 |
|
1389 | function createReactContext(defaultValue, calculateChangedBits) {
|
1390 | var _Provider$childContex, _Consumer$contextType;
|
1391 |
|
1392 | var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__';
|
1393 |
|
1394 | var Provider = function (_Component) {
|
1395 | _inherits(Provider, _Component);
|
1396 |
|
1397 | function Provider() {
|
1398 | var _temp, _this, _ret;
|
1399 |
|
1400 | _classCallCheck(this, Provider);
|
1401 |
|
1402 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1403 | args[_key] = arguments[_key];
|
1404 | }
|
1405 |
|
1406 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret);
|
1407 | }
|
1408 |
|
1409 | Provider.prototype.getChildContext = function getChildContext() {
|
1410 | var _ref;
|
1411 |
|
1412 | return _ref = {}, _ref[contextProp] = this.emitter, _ref;
|
1413 | };
|
1414 |
|
1415 | Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1416 | if (this.props.value !== nextProps.value) {
|
1417 | var oldValue = this.props.value;
|
1418 | var newValue = nextProps.value;
|
1419 | var changedBits = void 0;
|
1420 |
|
1421 | if (objectIs(oldValue, newValue)) {
|
1422 | changedBits = 0;
|
1423 | } else {
|
1424 | changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
1425 | {
|
1426 | (0, _warning2.default)((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
|
1427 | }
|
1428 |
|
1429 | changedBits |= 0;
|
1430 |
|
1431 | if (changedBits !== 0) {
|
1432 | this.emitter.set(nextProps.value, changedBits);
|
1433 | }
|
1434 | }
|
1435 | }
|
1436 | };
|
1437 |
|
1438 | Provider.prototype.render = function render() {
|
1439 | return this.props.children;
|
1440 | };
|
1441 |
|
1442 | return Provider;
|
1443 | }(React.Component);
|
1444 |
|
1445 | Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex);
|
1446 |
|
1447 | var Consumer = function (_Component2) {
|
1448 | _inherits(Consumer, _Component2);
|
1449 |
|
1450 | function Consumer() {
|
1451 | var _temp2, _this2, _ret2;
|
1452 |
|
1453 | _classCallCheck(this, Consumer);
|
1454 |
|
1455 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
1456 | args[_key2] = arguments[_key2];
|
1457 | }
|
1458 |
|
1459 | return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.state = {
|
1460 | value: _this2.getValue()
|
1461 | }, _this2.onUpdate = function (newValue, changedBits) {
|
1462 | var observedBits = _this2.observedBits | 0;
|
1463 | if ((observedBits & changedBits) !== 0) {
|
1464 | _this2.setState({ value: _this2.getValue() });
|
1465 | }
|
1466 | }, _temp2), _possibleConstructorReturn(_this2, _ret2);
|
1467 | }
|
1468 |
|
1469 | Consumer.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1470 | var observedBits = nextProps.observedBits;
|
1471 |
|
1472 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
1473 | : observedBits;
|
1474 | };
|
1475 |
|
1476 | Consumer.prototype.componentDidMount = function componentDidMount() {
|
1477 | if (this.context[contextProp]) {
|
1478 | this.context[contextProp].on(this.onUpdate);
|
1479 | }
|
1480 | var observedBits = this.props.observedBits;
|
1481 |
|
1482 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
1483 | : observedBits;
|
1484 | };
|
1485 |
|
1486 | Consumer.prototype.componentWillUnmount = function componentWillUnmount() {
|
1487 | if (this.context[contextProp]) {
|
1488 | this.context[contextProp].off(this.onUpdate);
|
1489 | }
|
1490 | };
|
1491 |
|
1492 | Consumer.prototype.getValue = function getValue() {
|
1493 | if (this.context[contextProp]) {
|
1494 | return this.context[contextProp].get();
|
1495 | } else {
|
1496 | return defaultValue;
|
1497 | }
|
1498 | };
|
1499 |
|
1500 | Consumer.prototype.render = function render() {
|
1501 | return onlyChild(this.props.children)(this.state.value);
|
1502 | };
|
1503 |
|
1504 | return Consumer;
|
1505 | }(React.Component);
|
1506 |
|
1507 | Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = _propTypes2.default.object, _Consumer$contextType);
|
1508 |
|
1509 |
|
1510 | return {
|
1511 | Provider: Provider,
|
1512 | Consumer: Consumer
|
1513 | };
|
1514 | }
|
1515 |
|
1516 | exports.default = createReactContext;
|
1517 | module.exports = exports['default'];
|
1518 | });
|
1519 |
|
1520 | unwrapExports(implementation);
|
1521 |
|
1522 | var lib = createCommonjsModule(function (module, exports) {
|
1523 |
|
1524 | exports.__esModule = true;
|
1525 |
|
1526 |
|
1527 |
|
1528 | var _react2 = _interopRequireDefault(React);
|
1529 |
|
1530 |
|
1531 |
|
1532 | var _implementation2 = _interopRequireDefault(implementation);
|
1533 |
|
1534 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1535 |
|
1536 | exports.default = _react2.default.createContext || _implementation2.default;
|
1537 | module.exports = exports['default'];
|
1538 | });
|
1539 |
|
1540 | var createContext = unwrapExports(lib);
|
1541 |
|
1542 |
|
1543 |
|
1544 | var createNamedContext = function createNamedContext(name) {
|
1545 | var context = createContext();
|
1546 | context.Provider.displayName = name + ".Provider";
|
1547 | context.Consumer.displayName = name + ".Consumer";
|
1548 | return context;
|
1549 | };
|
1550 |
|
1551 | var context =
|
1552 |
|
1553 | createNamedContext('Router');
|
1554 |
|
1555 | |
1556 |
|
1557 |
|
1558 |
|
1559 | var Router =
|
1560 |
|
1561 | function (_React$Component) {
|
1562 | _inheritsLoose(Router, _React$Component);
|
1563 |
|
1564 | Router.computeRootMatch = function computeRootMatch(pathname) {
|
1565 | return {
|
1566 | path: "/",
|
1567 | url: "/",
|
1568 | params: {},
|
1569 | isExact: pathname === "/"
|
1570 | };
|
1571 | };
|
1572 |
|
1573 | function Router(props) {
|
1574 | var _this;
|
1575 |
|
1576 | _this = _React$Component.call(this, props) || this;
|
1577 | _this.state = {
|
1578 | location: props.history.location
|
1579 | };
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 |
|
1585 | _this._isMounted = false;
|
1586 | _this._pendingLocation = null;
|
1587 |
|
1588 | if (!props.staticContext) {
|
1589 | _this.unlisten = props.history.listen(function (location) {
|
1590 | if (_this._isMounted) {
|
1591 | _this.setState({
|
1592 | location: location
|
1593 | });
|
1594 | } else {
|
1595 | _this._pendingLocation = location;
|
1596 | }
|
1597 | });
|
1598 | }
|
1599 |
|
1600 | return _this;
|
1601 | }
|
1602 |
|
1603 | var _proto = Router.prototype;
|
1604 |
|
1605 | _proto.componentDidMount = function componentDidMount() {
|
1606 | this._isMounted = true;
|
1607 |
|
1608 | if (this._pendingLocation) {
|
1609 | this.setState({
|
1610 | location: this._pendingLocation
|
1611 | });
|
1612 | }
|
1613 | };
|
1614 |
|
1615 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1616 | if (this.unlisten) this.unlisten();
|
1617 | };
|
1618 |
|
1619 | _proto.render = function render() {
|
1620 | return React.createElement(context.Provider, {
|
1621 | children: this.props.children || null,
|
1622 | value: {
|
1623 | history: this.props.history,
|
1624 | location: this.state.location,
|
1625 | match: Router.computeRootMatch(this.state.location.pathname),
|
1626 | staticContext: this.props.staticContext
|
1627 | }
|
1628 | });
|
1629 | };
|
1630 |
|
1631 | return Router;
|
1632 | }(React.Component);
|
1633 |
|
1634 | {
|
1635 | Router.propTypes = {
|
1636 | children: propTypes.node,
|
1637 | history: propTypes.object.isRequired,
|
1638 | staticContext: propTypes.object
|
1639 | };
|
1640 |
|
1641 | Router.prototype.componentDidUpdate = function (prevProps) {
|
1642 | warning(prevProps.history === this.props.history, "You cannot change <Router history>");
|
1643 | };
|
1644 | }
|
1645 |
|
1646 | |
1647 |
|
1648 |
|
1649 |
|
1650 | var MemoryRouter =
|
1651 |
|
1652 | function (_React$Component) {
|
1653 | _inheritsLoose(MemoryRouter, _React$Component);
|
1654 |
|
1655 | function MemoryRouter() {
|
1656 | var _this;
|
1657 |
|
1658 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1659 | args[_key] = arguments[_key];
|
1660 | }
|
1661 |
|
1662 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
1663 | _this.history = createMemoryHistory(_this.props);
|
1664 | return _this;
|
1665 | }
|
1666 |
|
1667 | var _proto = MemoryRouter.prototype;
|
1668 |
|
1669 | _proto.render = function render() {
|
1670 | return React.createElement(Router, {
|
1671 | history: this.history,
|
1672 | children: this.props.children
|
1673 | });
|
1674 | };
|
1675 |
|
1676 | return MemoryRouter;
|
1677 | }(React.Component);
|
1678 |
|
1679 | {
|
1680 | MemoryRouter.propTypes = {
|
1681 | initialEntries: propTypes.array,
|
1682 | initialIndex: propTypes.number,
|
1683 | getUserConfirmation: propTypes.func,
|
1684 | keyLength: propTypes.number,
|
1685 | children: propTypes.node
|
1686 | };
|
1687 |
|
1688 | MemoryRouter.prototype.componentDidMount = function () {
|
1689 | warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.");
|
1690 | };
|
1691 | }
|
1692 |
|
1693 | var Lifecycle =
|
1694 |
|
1695 | function (_React$Component) {
|
1696 | _inheritsLoose(Lifecycle, _React$Component);
|
1697 |
|
1698 | function Lifecycle() {
|
1699 | return _React$Component.apply(this, arguments) || this;
|
1700 | }
|
1701 |
|
1702 | var _proto = Lifecycle.prototype;
|
1703 |
|
1704 | _proto.componentDidMount = function componentDidMount() {
|
1705 | if (this.props.onMount) this.props.onMount.call(this, this);
|
1706 | };
|
1707 |
|
1708 | _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
1709 | if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
|
1710 | };
|
1711 |
|
1712 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1713 | if (this.props.onUnmount) this.props.onUnmount.call(this, this);
|
1714 | };
|
1715 |
|
1716 | _proto.render = function render() {
|
1717 | return null;
|
1718 | };
|
1719 |
|
1720 | return Lifecycle;
|
1721 | }(React.Component);
|
1722 |
|
1723 | |
1724 |
|
1725 |
|
1726 |
|
1727 | function Prompt(_ref) {
|
1728 | var message = _ref.message,
|
1729 | _ref$when = _ref.when,
|
1730 | when = _ref$when === void 0 ? true : _ref$when;
|
1731 | return React.createElement(context.Consumer, null, function (context$$1) {
|
1732 | !context$$1 ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
|
1733 | if (!when || context$$1.staticContext) return null;
|
1734 | var method = context$$1.history.block;
|
1735 | return React.createElement(Lifecycle, {
|
1736 | onMount: function onMount(self) {
|
1737 | self.release = method(message);
|
1738 | },
|
1739 | onUpdate: function onUpdate(self, prevProps) {
|
1740 | if (prevProps.message !== message) {
|
1741 | self.release();
|
1742 | self.release = method(message);
|
1743 | }
|
1744 | },
|
1745 | onUnmount: function onUnmount(self) {
|
1746 | self.release();
|
1747 | },
|
1748 | message: message
|
1749 | });
|
1750 | });
|
1751 | }
|
1752 |
|
1753 | {
|
1754 | var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
|
1755 | Prompt.propTypes = {
|
1756 | when: propTypes.bool,
|
1757 | message: messageType.isRequired
|
1758 | };
|
1759 | }
|
1760 |
|
1761 | var isarray = Array.isArray || function (arr) {
|
1762 | return Object.prototype.toString.call(arr) == '[object Array]';
|
1763 | };
|
1764 |
|
1765 | |
1766 |
|
1767 |
|
1768 | var pathToRegexp_1 = pathToRegexp;
|
1769 | var parse_1 = parse;
|
1770 | var compile_1 = compile;
|
1771 | var tokensToFunction_1 = tokensToFunction;
|
1772 | var tokensToRegExp_1 = tokensToRegExp;
|
1773 |
|
1774 | |
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 | var PATH_REGEXP = new RegExp([
|
1780 |
|
1781 |
|
1782 | '(\\\\.)',
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 | '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
|
1790 | ].join('|'), 'g');
|
1791 |
|
1792 | |
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 | function parse (str, options) {
|
1800 | var tokens = [];
|
1801 | var key = 0;
|
1802 | var index = 0;
|
1803 | var path = '';
|
1804 | var defaultDelimiter = options && options.delimiter || '/';
|
1805 | var res;
|
1806 |
|
1807 | while ((res = PATH_REGEXP.exec(str)) != null) {
|
1808 | var m = res[0];
|
1809 | var escaped = res[1];
|
1810 | var offset = res.index;
|
1811 | path += str.slice(index, offset);
|
1812 | index = offset + m.length;
|
1813 |
|
1814 |
|
1815 | if (escaped) {
|
1816 | path += escaped[1];
|
1817 | continue
|
1818 | }
|
1819 |
|
1820 | var next = str[index];
|
1821 | var prefix = res[2];
|
1822 | var name = res[3];
|
1823 | var capture = res[4];
|
1824 | var group = res[5];
|
1825 | var modifier = res[6];
|
1826 | var asterisk = res[7];
|
1827 |
|
1828 |
|
1829 | if (path) {
|
1830 | tokens.push(path);
|
1831 | path = '';
|
1832 | }
|
1833 |
|
1834 | var partial = prefix != null && next != null && next !== prefix;
|
1835 | var repeat = modifier === '+' || modifier === '*';
|
1836 | var optional = modifier === '?' || modifier === '*';
|
1837 | var delimiter = res[2] || defaultDelimiter;
|
1838 | var pattern = capture || group;
|
1839 |
|
1840 | tokens.push({
|
1841 | name: name || key++,
|
1842 | prefix: prefix || '',
|
1843 | delimiter: delimiter,
|
1844 | optional: optional,
|
1845 | repeat: repeat,
|
1846 | partial: partial,
|
1847 | asterisk: !!asterisk,
|
1848 | pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
|
1849 | });
|
1850 | }
|
1851 |
|
1852 |
|
1853 | if (index < str.length) {
|
1854 | path += str.substr(index);
|
1855 | }
|
1856 |
|
1857 |
|
1858 | if (path) {
|
1859 | tokens.push(path);
|
1860 | }
|
1861 |
|
1862 | return tokens
|
1863 | }
|
1864 |
|
1865 | |
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 | function compile (str, options) {
|
1873 | return tokensToFunction(parse(str, options))
|
1874 | }
|
1875 |
|
1876 | |
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 | function encodeURIComponentPretty (str) {
|
1883 | return encodeURI(str).replace(/[\/?#]/g, function (c) {
|
1884 | return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
1885 | })
|
1886 | }
|
1887 |
|
1888 | |
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 | function encodeAsterisk (str) {
|
1895 | return encodeURI(str).replace(/[?#]/g, function (c) {
|
1896 | return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
1897 | })
|
1898 | }
|
1899 |
|
1900 | |
1901 |
|
1902 |
|
1903 | function tokensToFunction (tokens) {
|
1904 |
|
1905 | var matches = new Array(tokens.length);
|
1906 |
|
1907 |
|
1908 | for (var i = 0; i < tokens.length; i++) {
|
1909 | if (typeof tokens[i] === 'object') {
|
1910 | matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
|
1911 | }
|
1912 | }
|
1913 |
|
1914 | return function (obj, opts) {
|
1915 | var path = '';
|
1916 | var data = obj || {};
|
1917 | var options = opts || {};
|
1918 | var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
|
1919 |
|
1920 | for (var i = 0; i < tokens.length; i++) {
|
1921 | var token = tokens[i];
|
1922 |
|
1923 | if (typeof token === 'string') {
|
1924 | path += token;
|
1925 |
|
1926 | continue
|
1927 | }
|
1928 |
|
1929 | var value = data[token.name];
|
1930 | var segment;
|
1931 |
|
1932 | if (value == null) {
|
1933 | if (token.optional) {
|
1934 |
|
1935 | if (token.partial) {
|
1936 | path += token.prefix;
|
1937 | }
|
1938 |
|
1939 | continue
|
1940 | } else {
|
1941 | throw new TypeError('Expected "' + token.name + '" to be defined')
|
1942 | }
|
1943 | }
|
1944 |
|
1945 | if (isarray(value)) {
|
1946 | if (!token.repeat) {
|
1947 | throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
|
1948 | }
|
1949 |
|
1950 | if (value.length === 0) {
|
1951 | if (token.optional) {
|
1952 | continue
|
1953 | } else {
|
1954 | throw new TypeError('Expected "' + token.name + '" to not be empty')
|
1955 | }
|
1956 | }
|
1957 |
|
1958 | for (var j = 0; j < value.length; j++) {
|
1959 | segment = encode(value[j]);
|
1960 |
|
1961 | if (!matches[i].test(segment)) {
|
1962 | throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
|
1963 | }
|
1964 |
|
1965 | path += (j === 0 ? token.prefix : token.delimiter) + segment;
|
1966 | }
|
1967 |
|
1968 | continue
|
1969 | }
|
1970 |
|
1971 | segment = token.asterisk ? encodeAsterisk(value) : encode(value);
|
1972 |
|
1973 | if (!matches[i].test(segment)) {
|
1974 | throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
|
1975 | }
|
1976 |
|
1977 | path += token.prefix + segment;
|
1978 | }
|
1979 |
|
1980 | return path
|
1981 | }
|
1982 | }
|
1983 |
|
1984 | |
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 |
|
1990 | function escapeString (str) {
|
1991 | return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
|
1992 | }
|
1993 |
|
1994 | |
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 | function escapeGroup (group) {
|
2001 | return group.replace(/([=!:$\/()])/g, '\\$1')
|
2002 | }
|
2003 |
|
2004 | |
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 | function attachKeys (re, keys) {
|
2012 | re.keys = keys;
|
2013 | return re
|
2014 | }
|
2015 |
|
2016 | |
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 | function flags (options) {
|
2023 | return options.sensitive ? '' : 'i'
|
2024 | }
|
2025 |
|
2026 | |
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 | function regexpToRegexp (path, keys) {
|
2034 |
|
2035 | var groups = path.source.match(/\((?!\?)/g);
|
2036 |
|
2037 | if (groups) {
|
2038 | for (var i = 0; i < groups.length; i++) {
|
2039 | keys.push({
|
2040 | name: i,
|
2041 | prefix: null,
|
2042 | delimiter: null,
|
2043 | optional: false,
|
2044 | repeat: false,
|
2045 | partial: false,
|
2046 | asterisk: false,
|
2047 | pattern: null
|
2048 | });
|
2049 | }
|
2050 | }
|
2051 |
|
2052 | return attachKeys(path, keys)
|
2053 | }
|
2054 |
|
2055 | |
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 | function arrayToRegexp (path, keys, options) {
|
2064 | var parts = [];
|
2065 |
|
2066 | for (var i = 0; i < path.length; i++) {
|
2067 | parts.push(pathToRegexp(path[i], keys, options).source);
|
2068 | }
|
2069 |
|
2070 | var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
|
2071 |
|
2072 | return attachKeys(regexp, keys)
|
2073 | }
|
2074 |
|
2075 | |
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 | function stringToRegexp (path, keys, options) {
|
2084 | return tokensToRegExp(parse(path, options), keys, options)
|
2085 | }
|
2086 |
|
2087 | |
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 | function tokensToRegExp (tokens, keys, options) {
|
2096 | if (!isarray(keys)) {
|
2097 | options = (keys || options);
|
2098 | keys = [];
|
2099 | }
|
2100 |
|
2101 | options = options || {};
|
2102 |
|
2103 | var strict = options.strict;
|
2104 | var end = options.end !== false;
|
2105 | var route = '';
|
2106 |
|
2107 |
|
2108 | for (var i = 0; i < tokens.length; i++) {
|
2109 | var token = tokens[i];
|
2110 |
|
2111 | if (typeof token === 'string') {
|
2112 | route += escapeString(token);
|
2113 | } else {
|
2114 | var prefix = escapeString(token.prefix);
|
2115 | var capture = '(?:' + token.pattern + ')';
|
2116 |
|
2117 | keys.push(token);
|
2118 |
|
2119 | if (token.repeat) {
|
2120 | capture += '(?:' + prefix + capture + ')*';
|
2121 | }
|
2122 |
|
2123 | if (token.optional) {
|
2124 | if (!token.partial) {
|
2125 | capture = '(?:' + prefix + '(' + capture + '))?';
|
2126 | } else {
|
2127 | capture = prefix + '(' + capture + ')?';
|
2128 | }
|
2129 | } else {
|
2130 | capture = prefix + '(' + capture + ')';
|
2131 | }
|
2132 |
|
2133 | route += capture;
|
2134 | }
|
2135 | }
|
2136 |
|
2137 | var delimiter = escapeString(options.delimiter || '/');
|
2138 | var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 | if (!strict) {
|
2145 | route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
|
2146 | }
|
2147 |
|
2148 | if (end) {
|
2149 | route += '$';
|
2150 | } else {
|
2151 |
|
2152 |
|
2153 | route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
|
2154 | }
|
2155 |
|
2156 | return attachKeys(new RegExp('^' + route, flags(options)), keys)
|
2157 | }
|
2158 |
|
2159 | |
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 | function pathToRegexp (path, keys, options) {
|
2172 | if (!isarray(keys)) {
|
2173 | options = (keys || options);
|
2174 | keys = [];
|
2175 | }
|
2176 |
|
2177 | options = options || {};
|
2178 |
|
2179 | if (path instanceof RegExp) {
|
2180 | return regexpToRegexp(path, (keys))
|
2181 | }
|
2182 |
|
2183 | if (isarray(path)) {
|
2184 | return arrayToRegexp( (path), (keys), options)
|
2185 | }
|
2186 |
|
2187 | return stringToRegexp( (path), (keys), options)
|
2188 | }
|
2189 | pathToRegexp_1.parse = parse_1;
|
2190 | pathToRegexp_1.compile = compile_1;
|
2191 | pathToRegexp_1.tokensToFunction = tokensToFunction_1;
|
2192 | pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
|
2193 |
|
2194 | var cache = {};
|
2195 | var cacheLimit = 10000;
|
2196 | var cacheCount = 0;
|
2197 |
|
2198 | function compilePath(path) {
|
2199 | if (cache[path]) return cache[path];
|
2200 | var generator = pathToRegexp_1.compile(path);
|
2201 |
|
2202 | if (cacheCount < cacheLimit) {
|
2203 | cache[path] = generator;
|
2204 | cacheCount++;
|
2205 | }
|
2206 |
|
2207 | return generator;
|
2208 | }
|
2209 | |
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 | function generatePath(path, params) {
|
2215 | if (path === void 0) {
|
2216 | path = "/";
|
2217 | }
|
2218 |
|
2219 | if (params === void 0) {
|
2220 | params = {};
|
2221 | }
|
2222 |
|
2223 | return path === "/" ? path : compilePath(path)(params, {
|
2224 | pretty: true
|
2225 | });
|
2226 | }
|
2227 |
|
2228 | |
2229 |
|
2230 |
|
2231 |
|
2232 | function Redirect(_ref) {
|
2233 | var computedMatch = _ref.computedMatch,
|
2234 | to = _ref.to,
|
2235 | _ref$push = _ref.push,
|
2236 | push = _ref$push === void 0 ? false : _ref$push;
|
2237 | return React.createElement(context.Consumer, null, function (context$$1) {
|
2238 | !context$$1 ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
|
2239 | var history = context$$1.history,
|
2240 | staticContext = context$$1.staticContext;
|
2241 | var method = push ? history.push : history.replace;
|
2242 | var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
|
2243 | pathname: generatePath(to.pathname, computedMatch.params)
|
2244 | }) : to);
|
2245 |
|
2246 |
|
2247 | if (staticContext) {
|
2248 | method(location);
|
2249 | return null;
|
2250 | }
|
2251 |
|
2252 | return React.createElement(Lifecycle, {
|
2253 | onMount: function onMount() {
|
2254 | method(location);
|
2255 | },
|
2256 | onUpdate: function onUpdate(self, prevProps) {
|
2257 | if (!locationsAreEqual(prevProps.to, location)) {
|
2258 | method(location);
|
2259 | }
|
2260 | },
|
2261 | to: to
|
2262 | });
|
2263 | });
|
2264 | }
|
2265 |
|
2266 | {
|
2267 | Redirect.propTypes = {
|
2268 | push: propTypes.bool,
|
2269 | from: propTypes.string,
|
2270 | to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
|
2271 | };
|
2272 | }
|
2273 |
|
2274 | var reactIs_production_min = createCommonjsModule(function (module, exports) {
|
2275 | Object.defineProperty(exports,"__esModule",{value:!0});
|
2276 | 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"):
|
2277 | 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;
|
2278 | 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};
|
2279 | 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};
|
2280 | });
|
2281 |
|
2282 | unwrapExports(reactIs_production_min);
|
2283 | var reactIs_production_min_1 = reactIs_production_min.typeOf;
|
2284 | var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
|
2285 | var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
|
2286 | var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
|
2287 | var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
|
2288 | var reactIs_production_min_6 = reactIs_production_min.Element;
|
2289 | var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
|
2290 | var reactIs_production_min_8 = reactIs_production_min.Fragment;
|
2291 | var reactIs_production_min_9 = reactIs_production_min.Profiler;
|
2292 | var reactIs_production_min_10 = reactIs_production_min.Portal;
|
2293 | var reactIs_production_min_11 = reactIs_production_min.StrictMode;
|
2294 | var reactIs_production_min_12 = reactIs_production_min.isValidElementType;
|
2295 | var reactIs_production_min_13 = reactIs_production_min.isAsyncMode;
|
2296 | var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode;
|
2297 | var reactIs_production_min_15 = reactIs_production_min.isContextConsumer;
|
2298 | var reactIs_production_min_16 = reactIs_production_min.isContextProvider;
|
2299 | var reactIs_production_min_17 = reactIs_production_min.isElement;
|
2300 | var reactIs_production_min_18 = reactIs_production_min.isForwardRef;
|
2301 | var reactIs_production_min_19 = reactIs_production_min.isFragment;
|
2302 | var reactIs_production_min_20 = reactIs_production_min.isProfiler;
|
2303 | var reactIs_production_min_21 = reactIs_production_min.isPortal;
|
2304 | var reactIs_production_min_22 = reactIs_production_min.isStrictMode;
|
2305 |
|
2306 | var reactIs_development = createCommonjsModule(function (module, exports) {
|
2307 |
|
2308 |
|
2309 |
|
2310 | {
|
2311 | (function() {
|
2312 |
|
2313 | Object.defineProperty(exports, '__esModule', { value: true });
|
2314 |
|
2315 |
|
2316 |
|
2317 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
2318 |
|
2319 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
2320 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
2321 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
2322 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
2323 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
2324 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
2325 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
2326 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
2327 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
2328 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
2329 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
2330 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
2331 |
|
2332 | function isValidElementType(type) {
|
2333 | return typeof type === 'string' || typeof type === 'function' ||
|
2334 |
|
2335 | 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);
|
2336 | }
|
2337 |
|
2338 | |
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 | var lowPriorityWarning = function () {};
|
2353 |
|
2354 | {
|
2355 | var printWarning = function (format) {
|
2356 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2357 | args[_key - 1] = arguments[_key];
|
2358 | }
|
2359 |
|
2360 | var argIndex = 0;
|
2361 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
2362 | return args[argIndex++];
|
2363 | });
|
2364 | if (typeof console !== 'undefined') {
|
2365 | console.warn(message);
|
2366 | }
|
2367 | try {
|
2368 |
|
2369 |
|
2370 |
|
2371 | throw new Error(message);
|
2372 | } catch (x) {}
|
2373 | };
|
2374 |
|
2375 | lowPriorityWarning = function (condition, format) {
|
2376 | if (format === undefined) {
|
2377 | throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
2378 | }
|
2379 | if (!condition) {
|
2380 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
2381 | args[_key2 - 2] = arguments[_key2];
|
2382 | }
|
2383 |
|
2384 | printWarning.apply(undefined, [format].concat(args));
|
2385 | }
|
2386 | };
|
2387 | }
|
2388 |
|
2389 | var lowPriorityWarning$1 = lowPriorityWarning;
|
2390 |
|
2391 | function typeOf(object) {
|
2392 | if (typeof object === 'object' && object !== null) {
|
2393 | var $$typeof = object.$$typeof;
|
2394 |
|
2395 | switch ($$typeof) {
|
2396 | case REACT_ELEMENT_TYPE:
|
2397 | var type = object.type;
|
2398 |
|
2399 | switch (type) {
|
2400 | case REACT_CONCURRENT_MODE_TYPE:
|
2401 | case REACT_FRAGMENT_TYPE:
|
2402 | case REACT_PROFILER_TYPE:
|
2403 | case REACT_STRICT_MODE_TYPE:
|
2404 | return type;
|
2405 | default:
|
2406 | var $$typeofType = type && type.$$typeof;
|
2407 |
|
2408 | switch ($$typeofType) {
|
2409 | case REACT_CONTEXT_TYPE:
|
2410 | case REACT_FORWARD_REF_TYPE:
|
2411 | case REACT_PROVIDER_TYPE:
|
2412 | return $$typeofType;
|
2413 | default:
|
2414 | return $$typeof;
|
2415 | }
|
2416 | }
|
2417 | case REACT_PORTAL_TYPE:
|
2418 | return $$typeof;
|
2419 | }
|
2420 | }
|
2421 |
|
2422 | return undefined;
|
2423 | }
|
2424 |
|
2425 |
|
2426 | var AsyncMode = REACT_CONCURRENT_MODE_TYPE;
|
2427 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
2428 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
2429 | var ContextProvider = REACT_PROVIDER_TYPE;
|
2430 | var Element = REACT_ELEMENT_TYPE;
|
2431 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
2432 | var Fragment = REACT_FRAGMENT_TYPE;
|
2433 | var Profiler = REACT_PROFILER_TYPE;
|
2434 | var Portal = REACT_PORTAL_TYPE;
|
2435 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
2436 |
|
2437 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
2438 |
|
2439 |
|
2440 | function isAsyncMode(object) {
|
2441 | {
|
2442 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
2443 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
2444 | 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.');
|
2445 | }
|
2446 | }
|
2447 | return isConcurrentMode(object);
|
2448 | }
|
2449 | function isConcurrentMode(object) {
|
2450 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
2451 | }
|
2452 | function isContextConsumer(object) {
|
2453 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
2454 | }
|
2455 | function isContextProvider(object) {
|
2456 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
2457 | }
|
2458 | function isElement(object) {
|
2459 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
2460 | }
|
2461 | function isForwardRef(object) {
|
2462 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
2463 | }
|
2464 | function isFragment(object) {
|
2465 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
2466 | }
|
2467 | function isProfiler(object) {
|
2468 | return typeOf(object) === REACT_PROFILER_TYPE;
|
2469 | }
|
2470 | function isPortal(object) {
|
2471 | return typeOf(object) === REACT_PORTAL_TYPE;
|
2472 | }
|
2473 | function isStrictMode(object) {
|
2474 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
2475 | }
|
2476 |
|
2477 | exports.typeOf = typeOf;
|
2478 | exports.AsyncMode = AsyncMode;
|
2479 | exports.ConcurrentMode = ConcurrentMode;
|
2480 | exports.ContextConsumer = ContextConsumer;
|
2481 | exports.ContextProvider = ContextProvider;
|
2482 | exports.Element = Element;
|
2483 | exports.ForwardRef = ForwardRef;
|
2484 | exports.Fragment = Fragment;
|
2485 | exports.Profiler = Profiler;
|
2486 | exports.Portal = Portal;
|
2487 | exports.StrictMode = StrictMode;
|
2488 | exports.isValidElementType = isValidElementType;
|
2489 | exports.isAsyncMode = isAsyncMode;
|
2490 | exports.isConcurrentMode = isConcurrentMode;
|
2491 | exports.isContextConsumer = isContextConsumer;
|
2492 | exports.isContextProvider = isContextProvider;
|
2493 | exports.isElement = isElement;
|
2494 | exports.isForwardRef = isForwardRef;
|
2495 | exports.isFragment = isFragment;
|
2496 | exports.isProfiler = isProfiler;
|
2497 | exports.isPortal = isPortal;
|
2498 | exports.isStrictMode = isStrictMode;
|
2499 | })();
|
2500 | }
|
2501 | });
|
2502 |
|
2503 | unwrapExports(reactIs_development);
|
2504 | var reactIs_development_1 = reactIs_development.typeOf;
|
2505 | var reactIs_development_2 = reactIs_development.AsyncMode;
|
2506 | var reactIs_development_3 = reactIs_development.ConcurrentMode;
|
2507 | var reactIs_development_4 = reactIs_development.ContextConsumer;
|
2508 | var reactIs_development_5 = reactIs_development.ContextProvider;
|
2509 | var reactIs_development_6 = reactIs_development.Element;
|
2510 | var reactIs_development_7 = reactIs_development.ForwardRef;
|
2511 | var reactIs_development_8 = reactIs_development.Fragment;
|
2512 | var reactIs_development_9 = reactIs_development.Profiler;
|
2513 | var reactIs_development_10 = reactIs_development.Portal;
|
2514 | var reactIs_development_11 = reactIs_development.StrictMode;
|
2515 | var reactIs_development_12 = reactIs_development.isValidElementType;
|
2516 | var reactIs_development_13 = reactIs_development.isAsyncMode;
|
2517 | var reactIs_development_14 = reactIs_development.isConcurrentMode;
|
2518 | var reactIs_development_15 = reactIs_development.isContextConsumer;
|
2519 | var reactIs_development_16 = reactIs_development.isContextProvider;
|
2520 | var reactIs_development_17 = reactIs_development.isElement;
|
2521 | var reactIs_development_18 = reactIs_development.isForwardRef;
|
2522 | var reactIs_development_19 = reactIs_development.isFragment;
|
2523 | var reactIs_development_20 = reactIs_development.isProfiler;
|
2524 | var reactIs_development_21 = reactIs_development.isPortal;
|
2525 | var reactIs_development_22 = reactIs_development.isStrictMode;
|
2526 |
|
2527 | var reactIs = createCommonjsModule(function (module) {
|
2528 |
|
2529 | {
|
2530 | module.exports = reactIs_development;
|
2531 | }
|
2532 | });
|
2533 | var reactIs_1 = reactIs.isValidElementType;
|
2534 |
|
2535 | var cache$1 = {};
|
2536 | var cacheLimit$1 = 10000;
|
2537 | var cacheCount$1 = 0;
|
2538 |
|
2539 | function compilePath$1(path, options) {
|
2540 | var cacheKey = "" + options.end + options.strict + options.sensitive;
|
2541 | var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
|
2542 | if (pathCache[path]) return pathCache[path];
|
2543 | var keys = [];
|
2544 | var regexp = pathToRegexp_1(path, keys, options);
|
2545 | var result = {
|
2546 | regexp: regexp,
|
2547 | keys: keys
|
2548 | };
|
2549 |
|
2550 | if (cacheCount$1 < cacheLimit$1) {
|
2551 | pathCache[path] = result;
|
2552 | cacheCount$1++;
|
2553 | }
|
2554 |
|
2555 | return result;
|
2556 | }
|
2557 | |
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 | function matchPath(pathname, options) {
|
2563 | if (options === void 0) {
|
2564 | options = {};
|
2565 | }
|
2566 |
|
2567 | if (typeof options === "string") options = {
|
2568 | path: options
|
2569 | };
|
2570 | var _options = options,
|
2571 | path = _options.path,
|
2572 | _options$exact = _options.exact,
|
2573 | exact = _options$exact === void 0 ? false : _options$exact,
|
2574 | _options$strict = _options.strict,
|
2575 | strict = _options$strict === void 0 ? false : _options$strict,
|
2576 | _options$sensitive = _options.sensitive,
|
2577 | sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
|
2578 | var paths = [].concat(path);
|
2579 | return paths.reduce(function (matched, path) {
|
2580 | if (matched) return matched;
|
2581 |
|
2582 | var _compilePath = compilePath$1(path, {
|
2583 | end: exact,
|
2584 | strict: strict,
|
2585 | sensitive: sensitive
|
2586 | }),
|
2587 | regexp = _compilePath.regexp,
|
2588 | keys = _compilePath.keys;
|
2589 |
|
2590 | var match = regexp.exec(pathname);
|
2591 | if (!match) return null;
|
2592 | var url = match[0],
|
2593 | values = match.slice(1);
|
2594 | var isExact = pathname === url;
|
2595 | if (exact && !isExact) return null;
|
2596 | return {
|
2597 | path: path,
|
2598 |
|
2599 | url: path === "/" && url === "" ? "/" : url,
|
2600 |
|
2601 | isExact: isExact,
|
2602 |
|
2603 | params: keys.reduce(function (memo, key, index) {
|
2604 | memo[key.name] = values[index];
|
2605 | return memo;
|
2606 | }, {})
|
2607 | };
|
2608 | }, null);
|
2609 | }
|
2610 |
|
2611 | function isEmptyChildren(children) {
|
2612 | return React.Children.count(children) === 0;
|
2613 | }
|
2614 | |
2615 |
|
2616 |
|
2617 |
|
2618 |
|
2619 | var Route =
|
2620 |
|
2621 | function (_React$Component) {
|
2622 | _inheritsLoose(Route, _React$Component);
|
2623 |
|
2624 | function Route() {
|
2625 | return _React$Component.apply(this, arguments) || this;
|
2626 | }
|
2627 |
|
2628 | var _proto = Route.prototype;
|
2629 |
|
2630 | _proto.render = function render() {
|
2631 | var _this = this;
|
2632 |
|
2633 | return React.createElement(context.Consumer, null, function (context$$1) {
|
2634 | !context$$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
|
2635 | var location = _this.props.location || context$$1.location;
|
2636 | var match = _this.props.computedMatch ? _this.props.computedMatch
|
2637 | : _this.props.path ? matchPath(location.pathname, _this.props) : context$$1.match;
|
2638 |
|
2639 | var props = _extends({}, context$$1, {
|
2640 | location: location,
|
2641 | match: match
|
2642 | });
|
2643 |
|
2644 | var _this$props = _this.props,
|
2645 | children = _this$props.children,
|
2646 | component = _this$props.component,
|
2647 | render = _this$props.render;
|
2648 |
|
2649 |
|
2650 | if (Array.isArray(children) && children.length === 0) {
|
2651 | children = null;
|
2652 | }
|
2653 |
|
2654 | if (typeof children === "function") {
|
2655 | children = children(props);
|
2656 |
|
2657 | if (children === undefined) {
|
2658 | {
|
2659 | var path = _this.props.path;
|
2660 | warning(false, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`");
|
2661 | }
|
2662 |
|
2663 | children = null;
|
2664 | }
|
2665 | }
|
2666 |
|
2667 | return React.createElement(context.Provider, {
|
2668 | value: props
|
2669 | }, children && !isEmptyChildren(children) ? children : props.match ? component ? React.createElement(component, props) : render ? render(props) : null : null);
|
2670 | });
|
2671 | };
|
2672 |
|
2673 | return Route;
|
2674 | }(React.Component);
|
2675 |
|
2676 | {
|
2677 | Route.propTypes = {
|
2678 | children: propTypes.oneOfType([propTypes.func, propTypes.node]),
|
2679 | component: function component(props, propName) {
|
2680 | if (props[propName] && !reactIs_1(props[propName])) {
|
2681 | return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
|
2682 | }
|
2683 | },
|
2684 | exact: propTypes.bool,
|
2685 | location: propTypes.object,
|
2686 | path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
|
2687 | render: propTypes.func,
|
2688 | sensitive: propTypes.bool,
|
2689 | strict: propTypes.bool
|
2690 | };
|
2691 |
|
2692 | Route.prototype.componentDidMount = function () {
|
2693 | 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");
|
2694 | 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");
|
2695 | 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");
|
2696 | };
|
2697 |
|
2698 | Route.prototype.componentDidUpdate = function (prevProps) {
|
2699 | 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.');
|
2700 | 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.');
|
2701 | };
|
2702 | }
|
2703 |
|
2704 | function _objectWithoutPropertiesLoose(source, excluded) {
|
2705 | if (source == null) return {};
|
2706 | var target = {};
|
2707 | var sourceKeys = Object.keys(source);
|
2708 | var key, i;
|
2709 |
|
2710 | for (i = 0; i < sourceKeys.length; i++) {
|
2711 | key = sourceKeys[i];
|
2712 | if (excluded.indexOf(key) >= 0) continue;
|
2713 | target[key] = source[key];
|
2714 | }
|
2715 |
|
2716 | return target;
|
2717 | }
|
2718 |
|
2719 | function addLeadingSlash$1(path) {
|
2720 | return path.charAt(0) === "/" ? path : "/" + path;
|
2721 | }
|
2722 |
|
2723 | function addBasename(basename, location) {
|
2724 | if (!basename) return location;
|
2725 | return _extends({}, location, {
|
2726 | pathname: addLeadingSlash$1(basename) + location.pathname
|
2727 | });
|
2728 | }
|
2729 |
|
2730 | function stripBasename$1(basename, location) {
|
2731 | if (!basename) return location;
|
2732 | var base = addLeadingSlash$1(basename);
|
2733 | if (location.pathname.indexOf(base) !== 0) return location;
|
2734 | return _extends({}, location, {
|
2735 | pathname: location.pathname.substr(base.length)
|
2736 | });
|
2737 | }
|
2738 |
|
2739 | function createURL(location) {
|
2740 | return typeof location === "string" ? location : createPath(location);
|
2741 | }
|
2742 |
|
2743 | function staticHandler(methodName) {
|
2744 | return function () {
|
2745 | invariant(false, "You cannot %s with <StaticRouter>", methodName);
|
2746 | };
|
2747 | }
|
2748 |
|
2749 | function noop() {}
|
2750 | |
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 | var StaticRouter =
|
2759 |
|
2760 | function (_React$Component) {
|
2761 | _inheritsLoose(StaticRouter, _React$Component);
|
2762 |
|
2763 | function StaticRouter() {
|
2764 | var _this;
|
2765 |
|
2766 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2767 | args[_key] = arguments[_key];
|
2768 | }
|
2769 |
|
2770 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
2771 |
|
2772 | _this.handlePush = function (location) {
|
2773 | return _this.navigateTo(location, "PUSH");
|
2774 | };
|
2775 |
|
2776 | _this.handleReplace = function (location) {
|
2777 | return _this.navigateTo(location, "REPLACE");
|
2778 | };
|
2779 |
|
2780 | _this.handleListen = function () {
|
2781 | return noop;
|
2782 | };
|
2783 |
|
2784 | _this.handleBlock = function () {
|
2785 | return noop;
|
2786 | };
|
2787 |
|
2788 | return _this;
|
2789 | }
|
2790 |
|
2791 | var _proto = StaticRouter.prototype;
|
2792 |
|
2793 | _proto.navigateTo = function navigateTo(location, action) {
|
2794 | var _this$props = this.props,
|
2795 | _this$props$basename = _this$props.basename,
|
2796 | basename = _this$props$basename === void 0 ? "" : _this$props$basename,
|
2797 | context = _this$props.context;
|
2798 | context.action = action;
|
2799 | context.location = addBasename(basename, createLocation(location));
|
2800 | context.url = createURL(context.location);
|
2801 | };
|
2802 |
|
2803 | _proto.render = function render() {
|
2804 | var _this$props2 = this.props,
|
2805 | _this$props2$basename = _this$props2.basename,
|
2806 | basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
|
2807 | _this$props2$context = _this$props2.context,
|
2808 | context = _this$props2$context === void 0 ? {} : _this$props2$context,
|
2809 | _this$props2$location = _this$props2.location,
|
2810 | location = _this$props2$location === void 0 ? "/" : _this$props2$location,
|
2811 | rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
|
2812 |
|
2813 | var history = {
|
2814 | createHref: function createHref(path) {
|
2815 | return addLeadingSlash$1(basename + createURL(path));
|
2816 | },
|
2817 | action: "POP",
|
2818 | location: stripBasename$1(basename, createLocation(location)),
|
2819 | push: this.handlePush,
|
2820 | replace: this.handleReplace,
|
2821 | go: staticHandler("go"),
|
2822 | goBack: staticHandler("goBack"),
|
2823 | goForward: staticHandler("goForward"),
|
2824 | listen: this.handleListen,
|
2825 | block: this.handleBlock
|
2826 | };
|
2827 | return React.createElement(Router, _extends({}, rest, {
|
2828 | history: history,
|
2829 | staticContext: context
|
2830 | }));
|
2831 | };
|
2832 |
|
2833 | return StaticRouter;
|
2834 | }(React.Component);
|
2835 |
|
2836 | {
|
2837 | StaticRouter.propTypes = {
|
2838 | basename: propTypes.string,
|
2839 | context: propTypes.object,
|
2840 | location: propTypes.oneOfType([propTypes.string, propTypes.object])
|
2841 | };
|
2842 |
|
2843 | StaticRouter.prototype.componentDidMount = function () {
|
2844 | warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.");
|
2845 | };
|
2846 | }
|
2847 |
|
2848 | |
2849 |
|
2850 |
|
2851 |
|
2852 | var Switch =
|
2853 |
|
2854 | function (_React$Component) {
|
2855 | _inheritsLoose(Switch, _React$Component);
|
2856 |
|
2857 | function Switch() {
|
2858 | return _React$Component.apply(this, arguments) || this;
|
2859 | }
|
2860 |
|
2861 | var _proto = Switch.prototype;
|
2862 |
|
2863 | _proto.render = function render() {
|
2864 | var _this = this;
|
2865 |
|
2866 | return React.createElement(context.Consumer, null, function (context$$1) {
|
2867 | !context$$1 ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
|
2868 | var location = _this.props.location || context$$1.location;
|
2869 | var element, match;
|
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 | React.Children.forEach(_this.props.children, function (child) {
|
2875 | if (match == null && React.isValidElement(child)) {
|
2876 | element = child;
|
2877 | var path = child.props.path || child.props.from;
|
2878 | match = path ? matchPath(location.pathname, _extends({}, child.props, {
|
2879 | path: path
|
2880 | })) : context$$1.match;
|
2881 | }
|
2882 | });
|
2883 | return match ? React.cloneElement(element, {
|
2884 | location: location,
|
2885 | computedMatch: match
|
2886 | }) : null;
|
2887 | });
|
2888 | };
|
2889 |
|
2890 | return Switch;
|
2891 | }(React.Component);
|
2892 |
|
2893 | {
|
2894 | Switch.propTypes = {
|
2895 | children: propTypes.node,
|
2896 | location: propTypes.object
|
2897 | };
|
2898 |
|
2899 | Switch.prototype.componentDidUpdate = function (prevProps) {
|
2900 | 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.');
|
2901 | 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.');
|
2902 | };
|
2903 | }
|
2904 |
|
2905 | |
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 | var REACT_STATICS = {
|
2912 | childContextTypes: true,
|
2913 | contextType: true,
|
2914 | contextTypes: true,
|
2915 | defaultProps: true,
|
2916 | displayName: true,
|
2917 | getDefaultProps: true,
|
2918 | getDerivedStateFromProps: true,
|
2919 | mixins: true,
|
2920 | propTypes: true,
|
2921 | type: true
|
2922 | };
|
2923 |
|
2924 | var KNOWN_STATICS = {
|
2925 | name: true,
|
2926 | length: true,
|
2927 | prototype: true,
|
2928 | caller: true,
|
2929 | callee: true,
|
2930 | arguments: true,
|
2931 | arity: true
|
2932 | };
|
2933 |
|
2934 | var FORWARD_REF_STATICS = {
|
2935 | '$$typeof': true,
|
2936 | render: true
|
2937 | };
|
2938 |
|
2939 | var TYPE_STATICS = {};
|
2940 | TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
2941 |
|
2942 | var defineProperty = Object.defineProperty;
|
2943 | var getOwnPropertyNames = Object.getOwnPropertyNames;
|
2944 | var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
|
2945 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
2946 | var getPrototypeOf = Object.getPrototypeOf;
|
2947 | var objectPrototype = Object.prototype;
|
2948 |
|
2949 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
2950 | if (typeof sourceComponent !== 'string') {
|
2951 |
|
2952 |
|
2953 | if (objectPrototype) {
|
2954 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
2955 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
2956 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
2957 | }
|
2958 | }
|
2959 |
|
2960 | var keys = getOwnPropertyNames(sourceComponent);
|
2961 |
|
2962 | if (getOwnPropertySymbols$1) {
|
2963 | keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
|
2964 | }
|
2965 |
|
2966 | var targetStatics = TYPE_STATICS[targetComponent['$$typeof']] || REACT_STATICS;
|
2967 | var sourceStatics = TYPE_STATICS[sourceComponent['$$typeof']] || REACT_STATICS;
|
2968 |
|
2969 | for (var i = 0; i < keys.length; ++i) {
|
2970 | var key = keys[i];
|
2971 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
2972 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
2973 | try {
|
2974 |
|
2975 | defineProperty(targetComponent, key, descriptor);
|
2976 | } catch (e) {}
|
2977 | }
|
2978 | }
|
2979 |
|
2980 | return targetComponent;
|
2981 | }
|
2982 |
|
2983 | return targetComponent;
|
2984 | }
|
2985 |
|
2986 | var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
2987 |
|
2988 | |
2989 |
|
2990 |
|
2991 |
|
2992 | function withRouter(Component) {
|
2993 | var C = function C(props) {
|
2994 | var wrappedComponentRef = props.wrappedComponentRef,
|
2995 | remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
|
2996 |
|
2997 | return React.createElement(Route, {
|
2998 | children: function children(routeComponentProps) {
|
2999 | return React.createElement(Component, _extends({}, remainingProps, routeComponentProps, {
|
3000 | ref: wrappedComponentRef
|
3001 | }));
|
3002 | }
|
3003 | });
|
3004 | };
|
3005 |
|
3006 | C.displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
|
3007 | C.WrappedComponent = Component;
|
3008 |
|
3009 | {
|
3010 | C.propTypes = {
|
3011 | wrappedComponentRef: propTypes.func
|
3012 | };
|
3013 | }
|
3014 |
|
3015 | return hoistNonReactStatics_cjs(C, Component);
|
3016 | }
|
3017 |
|
3018 | {
|
3019 | if (typeof window !== "undefined") {
|
3020 | var global$1 = window;
|
3021 | var key$1 = "__react_router_build__";
|
3022 | var buildNames = {
|
3023 | cjs: "CommonJS",
|
3024 | esm: "ES modules",
|
3025 | umd: "UMD"
|
3026 | };
|
3027 |
|
3028 | if (global$1[key$1] && global$1[key$1] !== "umd") {
|
3029 | var initialBuildName = buildNames[global$1[key$1]];
|
3030 | var secondaryBuildName = buildNames["umd"];
|
3031 |
|
3032 |
|
3033 | 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.");
|
3034 | }
|
3035 |
|
3036 | global$1[key$1] = "umd";
|
3037 | }
|
3038 | }
|
3039 |
|
3040 | exports.MemoryRouter = MemoryRouter;
|
3041 | exports.Prompt = Prompt;
|
3042 | exports.Redirect = Redirect;
|
3043 | exports.Route = Route;
|
3044 | exports.Router = Router;
|
3045 | exports.StaticRouter = StaticRouter;
|
3046 | exports.Switch = Switch;
|
3047 | exports.generatePath = generatePath;
|
3048 | exports.matchPath = matchPath;
|
3049 | exports.withRouter = withRouter;
|
3050 | exports.__RouterContext = context;
|
3051 |
|
3052 | Object.defineProperty(exports, '__esModule', { value: true });
|
3053 |
|
3054 | })));
|