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