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