react-router-dom 5.2.0 → 6.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +345 -0
  2. package/{LICENSE → LICENSE.md} +3 -1
  3. package/README.md +4 -36
  4. package/dist/dom.d.ts +76 -0
  5. package/dist/index.d.ts +246 -0
  6. package/dist/index.js +1058 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/main.js +19 -0
  9. package/dist/react-router-dom.development.js +1005 -0
  10. package/dist/react-router-dom.development.js.map +1 -0
  11. package/dist/react-router-dom.production.min.js +12 -0
  12. package/dist/react-router-dom.production.min.js.map +1 -0
  13. package/dist/server.d.ts +28 -0
  14. package/dist/server.js +319 -0
  15. package/dist/server.mjs +291 -0
  16. package/dist/umd/react-router-dom.development.js +1306 -0
  17. package/dist/umd/react-router-dom.development.js.map +1 -0
  18. package/dist/umd/react-router-dom.production.min.js +12 -0
  19. package/dist/umd/react-router-dom.production.min.js.map +1 -0
  20. package/package.json +38 -54
  21. package/server.d.ts +28 -0
  22. package/server.js +319 -0
  23. package/server.mjs +291 -0
  24. package/BrowserRouter.js +0 -3
  25. package/HashRouter.js +0 -3
  26. package/Link.js +0 -3
  27. package/MemoryRouter.js +0 -3
  28. package/NavLink.js +0 -3
  29. package/Prompt.js +0 -3
  30. package/Redirect.js +0 -3
  31. package/Route.js +0 -3
  32. package/Router.js +0 -3
  33. package/StaticRouter.js +0 -3
  34. package/Switch.js +0 -3
  35. package/cjs/react-router-dom.js +0 -443
  36. package/cjs/react-router-dom.js.map +0 -1
  37. package/cjs/react-router-dom.min.js +0 -2
  38. package/cjs/react-router-dom.min.js.map +0 -1
  39. package/es/BrowserRouter.js +0 -5
  40. package/es/HashRouter.js +0 -5
  41. package/es/Link.js +0 -5
  42. package/es/MemoryRouter.js +0 -5
  43. package/es/NavLink.js +0 -5
  44. package/es/Prompt.js +0 -5
  45. package/es/Redirect.js +0 -5
  46. package/es/Route.js +0 -5
  47. package/es/Router.js +0 -5
  48. package/es/StaticRouter.js +0 -5
  49. package/es/Switch.js +0 -5
  50. package/es/generatePath.js +0 -5
  51. package/es/matchPath.js +0 -5
  52. package/es/warnAboutDeprecatedESMImport.js +0 -34
  53. package/es/withRouter.js +0 -5
  54. package/esm/react-router-dom.js +0 -317
  55. package/esm/react-router-dom.js.map +0 -1
  56. package/generatePath.js +0 -3
  57. package/index.js +0 -7
  58. package/matchPath.js +0 -3
  59. package/modules/BrowserRouter.js +0 -36
  60. package/modules/HashRouter.js +0 -35
  61. package/modules/Link.js +0 -146
  62. package/modules/NavLink.js +0 -125
  63. package/modules/index.js +0 -21
  64. package/modules/utils/locationUtils.js +0 -10
  65. package/umd/react-router-dom.js +0 -3969
  66. package/umd/react-router-dom.js.map +0 -1
  67. package/umd/react-router-dom.min.js +0 -2
  68. package/umd/react-router-dom.min.js.map +0 -1
  69. package/warnAboutDeprecatedCJSRequire.js +0 -36
  70. package/withRouter.js +0 -3
@@ -1,3969 +0,0 @@
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.ReactRouterDOM = {}, global.React));
5
- }(this, function (exports, React) { 'use strict';
6
-
7
- var React__default = 'default' in React ? React['default'] : React;
8
-
9
- function _inheritsLoose(subClass, superClass) {
10
- subClass.prototype = Object.create(superClass.prototype);
11
- subClass.prototype.constructor = subClass;
12
- subClass.__proto__ = superClass;
13
- }
14
-
15
- function unwrapExports (x) {
16
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
17
- }
18
-
19
- function createCommonjsModule(fn, module) {
20
- return module = { exports: {} }, fn(module, module.exports), module.exports;
21
- }
22
-
23
- var reactIs_production_min = createCommonjsModule(function (module, exports) {
24
- Object.defineProperty(exports,"__esModule",{value:!0});
25
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
26
- 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118;function x(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
27
- exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
28
- exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
29
- exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
30
- });
31
-
32
- unwrapExports(reactIs_production_min);
33
- var reactIs_production_min_1 = reactIs_production_min.typeOf;
34
- var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
35
- var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
36
- var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
37
- var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
38
- var reactIs_production_min_6 = reactIs_production_min.Element;
39
- var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
40
- var reactIs_production_min_8 = reactIs_production_min.Fragment;
41
- var reactIs_production_min_9 = reactIs_production_min.Lazy;
42
- var reactIs_production_min_10 = reactIs_production_min.Memo;
43
- var reactIs_production_min_11 = reactIs_production_min.Portal;
44
- var reactIs_production_min_12 = reactIs_production_min.Profiler;
45
- var reactIs_production_min_13 = reactIs_production_min.StrictMode;
46
- var reactIs_production_min_14 = reactIs_production_min.Suspense;
47
- var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
48
- var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
49
- var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
50
- var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
51
- var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
52
- var reactIs_production_min_20 = reactIs_production_min.isElement;
53
- var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
54
- var reactIs_production_min_22 = reactIs_production_min.isFragment;
55
- var reactIs_production_min_23 = reactIs_production_min.isLazy;
56
- var reactIs_production_min_24 = reactIs_production_min.isMemo;
57
- var reactIs_production_min_25 = reactIs_production_min.isPortal;
58
- var reactIs_production_min_26 = reactIs_production_min.isProfiler;
59
- var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
60
- var reactIs_production_min_28 = reactIs_production_min.isSuspense;
61
-
62
- var reactIs_development = createCommonjsModule(function (module, exports) {
63
-
64
-
65
-
66
- {
67
- (function() {
68
-
69
- Object.defineProperty(exports, '__esModule', { value: true });
70
-
71
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
72
- // nor polyfill, then a plain number is used for performance.
73
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
74
-
75
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
76
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
77
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
78
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
79
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
80
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
81
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
82
- // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
83
- // (unstable) APIs that have been removed. Can we remove the symbols?
84
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
85
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
86
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
87
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
88
- var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
89
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
90
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
91
- var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
92
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
93
-
94
- function isValidElementType(type) {
95
- return typeof type === 'string' || typeof type === 'function' ||
96
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
97
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
98
- }
99
-
100
- /**
101
- * Forked from fbjs/warning:
102
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
103
- *
104
- * Only change is we use console.warn instead of console.error,
105
- * and do nothing when 'console' is not supported.
106
- * This really simplifies the code.
107
- * ---
108
- * Similar to invariant but only logs a warning if the condition is not met.
109
- * This can be used to log issues in development environments in critical
110
- * paths. Removing the logging code for production environments will keep the
111
- * same logic and follow the same code paths.
112
- */
113
-
114
- var lowPriorityWarning = function () {};
115
-
116
- {
117
- var printWarning = function (format) {
118
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
119
- args[_key - 1] = arguments[_key];
120
- }
121
-
122
- var argIndex = 0;
123
- var message = 'Warning: ' + format.replace(/%s/g, function () {
124
- return args[argIndex++];
125
- });
126
- if (typeof console !== 'undefined') {
127
- console.warn(message);
128
- }
129
- try {
130
- // --- Welcome to debugging React ---
131
- // This error was thrown as a convenience so that you can use this stack
132
- // to find the callsite that caused this warning to fire.
133
- throw new Error(message);
134
- } catch (x) {}
135
- };
136
-
137
- lowPriorityWarning = function (condition, format) {
138
- if (format === undefined) {
139
- throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
140
- }
141
- if (!condition) {
142
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
143
- args[_key2 - 2] = arguments[_key2];
144
- }
145
-
146
- printWarning.apply(undefined, [format].concat(args));
147
- }
148
- };
149
- }
150
-
151
- var lowPriorityWarning$1 = lowPriorityWarning;
152
-
153
- function typeOf(object) {
154
- if (typeof object === 'object' && object !== null) {
155
- var $$typeof = object.$$typeof;
156
- switch ($$typeof) {
157
- case REACT_ELEMENT_TYPE:
158
- var type = object.type;
159
-
160
- switch (type) {
161
- case REACT_ASYNC_MODE_TYPE:
162
- case REACT_CONCURRENT_MODE_TYPE:
163
- case REACT_FRAGMENT_TYPE:
164
- case REACT_PROFILER_TYPE:
165
- case REACT_STRICT_MODE_TYPE:
166
- case REACT_SUSPENSE_TYPE:
167
- return type;
168
- default:
169
- var $$typeofType = type && type.$$typeof;
170
-
171
- switch ($$typeofType) {
172
- case REACT_CONTEXT_TYPE:
173
- case REACT_FORWARD_REF_TYPE:
174
- case REACT_PROVIDER_TYPE:
175
- return $$typeofType;
176
- default:
177
- return $$typeof;
178
- }
179
- }
180
- case REACT_LAZY_TYPE:
181
- case REACT_MEMO_TYPE:
182
- case REACT_PORTAL_TYPE:
183
- return $$typeof;
184
- }
185
- }
186
-
187
- return undefined;
188
- }
189
-
190
- // AsyncMode is deprecated along with isAsyncMode
191
- var AsyncMode = REACT_ASYNC_MODE_TYPE;
192
- var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
193
- var ContextConsumer = REACT_CONTEXT_TYPE;
194
- var ContextProvider = REACT_PROVIDER_TYPE;
195
- var Element = REACT_ELEMENT_TYPE;
196
- var ForwardRef = REACT_FORWARD_REF_TYPE;
197
- var Fragment = REACT_FRAGMENT_TYPE;
198
- var Lazy = REACT_LAZY_TYPE;
199
- var Memo = REACT_MEMO_TYPE;
200
- var Portal = REACT_PORTAL_TYPE;
201
- var Profiler = REACT_PROFILER_TYPE;
202
- var StrictMode = REACT_STRICT_MODE_TYPE;
203
- var Suspense = REACT_SUSPENSE_TYPE;
204
-
205
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
206
-
207
- // AsyncMode should be deprecated
208
- function isAsyncMode(object) {
209
- {
210
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
211
- hasWarnedAboutDeprecatedIsAsyncMode = true;
212
- lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
213
- }
214
- }
215
- return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
216
- }
217
- function isConcurrentMode(object) {
218
- return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
219
- }
220
- function isContextConsumer(object) {
221
- return typeOf(object) === REACT_CONTEXT_TYPE;
222
- }
223
- function isContextProvider(object) {
224
- return typeOf(object) === REACT_PROVIDER_TYPE;
225
- }
226
- function isElement(object) {
227
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
228
- }
229
- function isForwardRef(object) {
230
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
231
- }
232
- function isFragment(object) {
233
- return typeOf(object) === REACT_FRAGMENT_TYPE;
234
- }
235
- function isLazy(object) {
236
- return typeOf(object) === REACT_LAZY_TYPE;
237
- }
238
- function isMemo(object) {
239
- return typeOf(object) === REACT_MEMO_TYPE;
240
- }
241
- function isPortal(object) {
242
- return typeOf(object) === REACT_PORTAL_TYPE;
243
- }
244
- function isProfiler(object) {
245
- return typeOf(object) === REACT_PROFILER_TYPE;
246
- }
247
- function isStrictMode(object) {
248
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
249
- }
250
- function isSuspense(object) {
251
- return typeOf(object) === REACT_SUSPENSE_TYPE;
252
- }
253
-
254
- exports.typeOf = typeOf;
255
- exports.AsyncMode = AsyncMode;
256
- exports.ConcurrentMode = ConcurrentMode;
257
- exports.ContextConsumer = ContextConsumer;
258
- exports.ContextProvider = ContextProvider;
259
- exports.Element = Element;
260
- exports.ForwardRef = ForwardRef;
261
- exports.Fragment = Fragment;
262
- exports.Lazy = Lazy;
263
- exports.Memo = Memo;
264
- exports.Portal = Portal;
265
- exports.Profiler = Profiler;
266
- exports.StrictMode = StrictMode;
267
- exports.Suspense = Suspense;
268
- exports.isValidElementType = isValidElementType;
269
- exports.isAsyncMode = isAsyncMode;
270
- exports.isConcurrentMode = isConcurrentMode;
271
- exports.isContextConsumer = isContextConsumer;
272
- exports.isContextProvider = isContextProvider;
273
- exports.isElement = isElement;
274
- exports.isForwardRef = isForwardRef;
275
- exports.isFragment = isFragment;
276
- exports.isLazy = isLazy;
277
- exports.isMemo = isMemo;
278
- exports.isPortal = isPortal;
279
- exports.isProfiler = isProfiler;
280
- exports.isStrictMode = isStrictMode;
281
- exports.isSuspense = isSuspense;
282
- })();
283
- }
284
- });
285
-
286
- unwrapExports(reactIs_development);
287
- var reactIs_development_1 = reactIs_development.typeOf;
288
- var reactIs_development_2 = reactIs_development.AsyncMode;
289
- var reactIs_development_3 = reactIs_development.ConcurrentMode;
290
- var reactIs_development_4 = reactIs_development.ContextConsumer;
291
- var reactIs_development_5 = reactIs_development.ContextProvider;
292
- var reactIs_development_6 = reactIs_development.Element;
293
- var reactIs_development_7 = reactIs_development.ForwardRef;
294
- var reactIs_development_8 = reactIs_development.Fragment;
295
- var reactIs_development_9 = reactIs_development.Lazy;
296
- var reactIs_development_10 = reactIs_development.Memo;
297
- var reactIs_development_11 = reactIs_development.Portal;
298
- var reactIs_development_12 = reactIs_development.Profiler;
299
- var reactIs_development_13 = reactIs_development.StrictMode;
300
- var reactIs_development_14 = reactIs_development.Suspense;
301
- var reactIs_development_15 = reactIs_development.isValidElementType;
302
- var reactIs_development_16 = reactIs_development.isAsyncMode;
303
- var reactIs_development_17 = reactIs_development.isConcurrentMode;
304
- var reactIs_development_18 = reactIs_development.isContextConsumer;
305
- var reactIs_development_19 = reactIs_development.isContextProvider;
306
- var reactIs_development_20 = reactIs_development.isElement;
307
- var reactIs_development_21 = reactIs_development.isForwardRef;
308
- var reactIs_development_22 = reactIs_development.isFragment;
309
- var reactIs_development_23 = reactIs_development.isLazy;
310
- var reactIs_development_24 = reactIs_development.isMemo;
311
- var reactIs_development_25 = reactIs_development.isPortal;
312
- var reactIs_development_26 = reactIs_development.isProfiler;
313
- var reactIs_development_27 = reactIs_development.isStrictMode;
314
- var reactIs_development_28 = reactIs_development.isSuspense;
315
-
316
- var reactIs = createCommonjsModule(function (module) {
317
-
318
- {
319
- module.exports = reactIs_development;
320
- }
321
- });
322
- var reactIs_1 = reactIs.isValidElementType;
323
-
324
- /*
325
- object-assign
326
- (c) Sindre Sorhus
327
- @license MIT
328
- */
329
- /* eslint-disable no-unused-vars */
330
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
331
- var hasOwnProperty = Object.prototype.hasOwnProperty;
332
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
333
-
334
- function toObject(val) {
335
- if (val === null || val === undefined) {
336
- throw new TypeError('Object.assign cannot be called with null or undefined');
337
- }
338
-
339
- return Object(val);
340
- }
341
-
342
- function shouldUseNative() {
343
- try {
344
- if (!Object.assign) {
345
- return false;
346
- }
347
-
348
- // Detect buggy property enumeration order in older V8 versions.
349
-
350
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
351
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
352
- test1[5] = 'de';
353
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
354
- return false;
355
- }
356
-
357
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
358
- var test2 = {};
359
- for (var i = 0; i < 10; i++) {
360
- test2['_' + String.fromCharCode(i)] = i;
361
- }
362
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
363
- return test2[n];
364
- });
365
- if (order2.join('') !== '0123456789') {
366
- return false;
367
- }
368
-
369
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
370
- var test3 = {};
371
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
372
- test3[letter] = letter;
373
- });
374
- if (Object.keys(Object.assign({}, test3)).join('') !==
375
- 'abcdefghijklmnopqrst') {
376
- return false;
377
- }
378
-
379
- return true;
380
- } catch (err) {
381
- // We don't expect any of the above to throw, but better to be safe.
382
- return false;
383
- }
384
- }
385
-
386
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
387
- var from;
388
- var to = toObject(target);
389
- var symbols;
390
-
391
- for (var s = 1; s < arguments.length; s++) {
392
- from = Object(arguments[s]);
393
-
394
- for (var key in from) {
395
- if (hasOwnProperty.call(from, key)) {
396
- to[key] = from[key];
397
- }
398
- }
399
-
400
- if (getOwnPropertySymbols) {
401
- symbols = getOwnPropertySymbols(from);
402
- for (var i = 0; i < symbols.length; i++) {
403
- if (propIsEnumerable.call(from, symbols[i])) {
404
- to[symbols[i]] = from[symbols[i]];
405
- }
406
- }
407
- }
408
- }
409
-
410
- return to;
411
- };
412
-
413
- /**
414
- * Copyright (c) 2013-present, Facebook, Inc.
415
- *
416
- * This source code is licensed under the MIT license found in the
417
- * LICENSE file in the root directory of this source tree.
418
- */
419
-
420
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
421
-
422
- var ReactPropTypesSecret_1 = ReactPropTypesSecret;
423
-
424
- var printWarning = function() {};
425
-
426
- {
427
- var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
428
- var loggedTypeFailures = {};
429
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
430
-
431
- printWarning = function(text) {
432
- var message = 'Warning: ' + text;
433
- if (typeof console !== 'undefined') {
434
- console.error(message);
435
- }
436
- try {
437
- // --- Welcome to debugging React ---
438
- // This error was thrown as a convenience so that you can use this stack
439
- // to find the callsite that caused this warning to fire.
440
- throw new Error(message);
441
- } catch (x) {}
442
- };
443
- }
444
-
445
- /**
446
- * Assert that the values match with the type specs.
447
- * Error messages are memorized and will only be shown once.
448
- *
449
- * @param {object} typeSpecs Map of name to a ReactPropType
450
- * @param {object} values Runtime values that need to be type-checked
451
- * @param {string} location e.g. "prop", "context", "child context"
452
- * @param {string} componentName Name of the component for error messages.
453
- * @param {?Function} getStack Returns the component stack.
454
- * @private
455
- */
456
- function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
457
- {
458
- for (var typeSpecName in typeSpecs) {
459
- if (has(typeSpecs, typeSpecName)) {
460
- var error;
461
- // Prop type validation may throw. In case they do, we don't want to
462
- // fail the render phase where it didn't fail before. So we log it.
463
- // After these have been cleaned up, we'll let them throw.
464
- try {
465
- // This is intentionally an invariant that gets caught. It's the same
466
- // behavior as without this statement except with a better message.
467
- if (typeof typeSpecs[typeSpecName] !== 'function') {
468
- var err = Error(
469
- (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
470
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
471
- );
472
- err.name = 'Invariant Violation';
473
- throw err;
474
- }
475
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
476
- } catch (ex) {
477
- error = ex;
478
- }
479
- if (error && !(error instanceof Error)) {
480
- printWarning(
481
- (componentName || 'React class') + ': type specification of ' +
482
- location + ' `' + typeSpecName + '` is invalid; the type checker ' +
483
- 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
484
- 'You may have forgotten to pass an argument to the type checker ' +
485
- 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
486
- 'shape all require an argument).'
487
- );
488
- }
489
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
490
- // Only monitor this failure once because there tends to be a lot of the
491
- // same error.
492
- loggedTypeFailures[error.message] = true;
493
-
494
- var stack = getStack ? getStack() : '';
495
-
496
- printWarning(
497
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
498
- );
499
- }
500
- }
501
- }
502
- }
503
- }
504
-
505
- /**
506
- * Resets warning cache when testing.
507
- *
508
- * @private
509
- */
510
- checkPropTypes.resetWarningCache = function() {
511
- {
512
- loggedTypeFailures = {};
513
- }
514
- };
515
-
516
- var checkPropTypes_1 = checkPropTypes;
517
-
518
- var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
519
- var printWarning$1 = function() {};
520
-
521
- {
522
- printWarning$1 = function(text) {
523
- var message = 'Warning: ' + text;
524
- if (typeof console !== 'undefined') {
525
- console.error(message);
526
- }
527
- try {
528
- // --- Welcome to debugging React ---
529
- // This error was thrown as a convenience so that you can use this stack
530
- // to find the callsite that caused this warning to fire.
531
- throw new Error(message);
532
- } catch (x) {}
533
- };
534
- }
535
-
536
- function emptyFunctionThatReturnsNull() {
537
- return null;
538
- }
539
-
540
- var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
541
- /* global Symbol */
542
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
543
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
544
-
545
- /**
546
- * Returns the iterator method function contained on the iterable object.
547
- *
548
- * Be sure to invoke the function with the iterable as context:
549
- *
550
- * var iteratorFn = getIteratorFn(myIterable);
551
- * if (iteratorFn) {
552
- * var iterator = iteratorFn.call(myIterable);
553
- * ...
554
- * }
555
- *
556
- * @param {?object} maybeIterable
557
- * @return {?function}
558
- */
559
- function getIteratorFn(maybeIterable) {
560
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
561
- if (typeof iteratorFn === 'function') {
562
- return iteratorFn;
563
- }
564
- }
565
-
566
- /**
567
- * Collection of methods that allow declaration and validation of props that are
568
- * supplied to React components. Example usage:
569
- *
570
- * var Props = require('ReactPropTypes');
571
- * var MyArticle = React.createClass({
572
- * propTypes: {
573
- * // An optional string prop named "description".
574
- * description: Props.string,
575
- *
576
- * // A required enum prop named "category".
577
- * category: Props.oneOf(['News','Photos']).isRequired,
578
- *
579
- * // A prop named "dialog" that requires an instance of Dialog.
580
- * dialog: Props.instanceOf(Dialog).isRequired
581
- * },
582
- * render: function() { ... }
583
- * });
584
- *
585
- * A more formal specification of how these methods are used:
586
- *
587
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
588
- * decl := ReactPropTypes.{type}(.isRequired)?
589
- *
590
- * Each and every declaration produces a function with the same signature. This
591
- * allows the creation of custom validation functions. For example:
592
- *
593
- * var MyLink = React.createClass({
594
- * propTypes: {
595
- * // An optional string or URI prop named "href".
596
- * href: function(props, propName, componentName) {
597
- * var propValue = props[propName];
598
- * if (propValue != null && typeof propValue !== 'string' &&
599
- * !(propValue instanceof URI)) {
600
- * return new Error(
601
- * 'Expected a string or an URI for ' + propName + ' in ' +
602
- * componentName
603
- * );
604
- * }
605
- * }
606
- * },
607
- * render: function() {...}
608
- * });
609
- *
610
- * @internal
611
- */
612
-
613
- var ANONYMOUS = '<<anonymous>>';
614
-
615
- // Important!
616
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
617
- var ReactPropTypes = {
618
- array: createPrimitiveTypeChecker('array'),
619
- bool: createPrimitiveTypeChecker('boolean'),
620
- func: createPrimitiveTypeChecker('function'),
621
- number: createPrimitiveTypeChecker('number'),
622
- object: createPrimitiveTypeChecker('object'),
623
- string: createPrimitiveTypeChecker('string'),
624
- symbol: createPrimitiveTypeChecker('symbol'),
625
-
626
- any: createAnyTypeChecker(),
627
- arrayOf: createArrayOfTypeChecker,
628
- element: createElementTypeChecker(),
629
- elementType: createElementTypeTypeChecker(),
630
- instanceOf: createInstanceTypeChecker,
631
- node: createNodeChecker(),
632
- objectOf: createObjectOfTypeChecker,
633
- oneOf: createEnumTypeChecker,
634
- oneOfType: createUnionTypeChecker,
635
- shape: createShapeTypeChecker,
636
- exact: createStrictShapeTypeChecker,
637
- };
638
-
639
- /**
640
- * inlined Object.is polyfill to avoid requiring consumers ship their own
641
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
642
- */
643
- /*eslint-disable no-self-compare*/
644
- function is(x, y) {
645
- // SameValue algorithm
646
- if (x === y) {
647
- // Steps 1-5, 7-10
648
- // Steps 6.b-6.e: +0 != -0
649
- return x !== 0 || 1 / x === 1 / y;
650
- } else {
651
- // Step 6.a: NaN == NaN
652
- return x !== x && y !== y;
653
- }
654
- }
655
- /*eslint-enable no-self-compare*/
656
-
657
- /**
658
- * We use an Error-like object for backward compatibility as people may call
659
- * PropTypes directly and inspect their output. However, we don't use real
660
- * Errors anymore. We don't inspect their stack anyway, and creating them
661
- * is prohibitively expensive if they are created too often, such as what
662
- * happens in oneOfType() for any type before the one that matched.
663
- */
664
- function PropTypeError(message) {
665
- this.message = message;
666
- this.stack = '';
667
- }
668
- // Make `instanceof Error` still work for returned errors.
669
- PropTypeError.prototype = Error.prototype;
670
-
671
- function createChainableTypeChecker(validate) {
672
- {
673
- var manualPropTypeCallCache = {};
674
- var manualPropTypeWarningCount = 0;
675
- }
676
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
677
- componentName = componentName || ANONYMOUS;
678
- propFullName = propFullName || propName;
679
-
680
- if (secret !== ReactPropTypesSecret_1) {
681
- if (throwOnDirectAccess) {
682
- // New behavior only for users of `prop-types` package
683
- var err = new Error(
684
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
685
- 'Use `PropTypes.checkPropTypes()` to call them. ' +
686
- 'Read more at http://fb.me/use-check-prop-types'
687
- );
688
- err.name = 'Invariant Violation';
689
- throw err;
690
- } else if ( typeof console !== 'undefined') {
691
- // Old behavior for people using React.PropTypes
692
- var cacheKey = componentName + ':' + propName;
693
- if (
694
- !manualPropTypeCallCache[cacheKey] &&
695
- // Avoid spamming the console because they are often not actionable except for lib authors
696
- manualPropTypeWarningCount < 3
697
- ) {
698
- printWarning$1(
699
- 'You are manually calling a React.PropTypes validation ' +
700
- 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
701
- 'and will throw in the standalone `prop-types` package. ' +
702
- 'You may be seeing this warning due to a third-party PropTypes ' +
703
- 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
704
- );
705
- manualPropTypeCallCache[cacheKey] = true;
706
- manualPropTypeWarningCount++;
707
- }
708
- }
709
- }
710
- if (props[propName] == null) {
711
- if (isRequired) {
712
- if (props[propName] === null) {
713
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
714
- }
715
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
716
- }
717
- return null;
718
- } else {
719
- return validate(props, propName, componentName, location, propFullName);
720
- }
721
- }
722
-
723
- var chainedCheckType = checkType.bind(null, false);
724
- chainedCheckType.isRequired = checkType.bind(null, true);
725
-
726
- return chainedCheckType;
727
- }
728
-
729
- function createPrimitiveTypeChecker(expectedType) {
730
- function validate(props, propName, componentName, location, propFullName, secret) {
731
- var propValue = props[propName];
732
- var propType = getPropType(propValue);
733
- if (propType !== expectedType) {
734
- // `propValue` being instance of, say, date/regexp, pass the 'object'
735
- // check, but we can offer a more precise error message here rather than
736
- // 'of type `object`'.
737
- var preciseType = getPreciseType(propValue);
738
-
739
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
740
- }
741
- return null;
742
- }
743
- return createChainableTypeChecker(validate);
744
- }
745
-
746
- function createAnyTypeChecker() {
747
- return createChainableTypeChecker(emptyFunctionThatReturnsNull);
748
- }
749
-
750
- function createArrayOfTypeChecker(typeChecker) {
751
- function validate(props, propName, componentName, location, propFullName) {
752
- if (typeof typeChecker !== 'function') {
753
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
754
- }
755
- var propValue = props[propName];
756
- if (!Array.isArray(propValue)) {
757
- var propType = getPropType(propValue);
758
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
759
- }
760
- for (var i = 0; i < propValue.length; i++) {
761
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
762
- if (error instanceof Error) {
763
- return error;
764
- }
765
- }
766
- return null;
767
- }
768
- return createChainableTypeChecker(validate);
769
- }
770
-
771
- function createElementTypeChecker() {
772
- function validate(props, propName, componentName, location, propFullName) {
773
- var propValue = props[propName];
774
- if (!isValidElement(propValue)) {
775
- var propType = getPropType(propValue);
776
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
777
- }
778
- return null;
779
- }
780
- return createChainableTypeChecker(validate);
781
- }
782
-
783
- function createElementTypeTypeChecker() {
784
- function validate(props, propName, componentName, location, propFullName) {
785
- var propValue = props[propName];
786
- if (!reactIs.isValidElementType(propValue)) {
787
- var propType = getPropType(propValue);
788
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
789
- }
790
- return null;
791
- }
792
- return createChainableTypeChecker(validate);
793
- }
794
-
795
- function createInstanceTypeChecker(expectedClass) {
796
- function validate(props, propName, componentName, location, propFullName) {
797
- if (!(props[propName] instanceof expectedClass)) {
798
- var expectedClassName = expectedClass.name || ANONYMOUS;
799
- var actualClassName = getClassName(props[propName]);
800
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
801
- }
802
- return null;
803
- }
804
- return createChainableTypeChecker(validate);
805
- }
806
-
807
- function createEnumTypeChecker(expectedValues) {
808
- if (!Array.isArray(expectedValues)) {
809
- {
810
- if (arguments.length > 1) {
811
- printWarning$1(
812
- 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
813
- 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
814
- );
815
- } else {
816
- printWarning$1('Invalid argument supplied to oneOf, expected an array.');
817
- }
818
- }
819
- return emptyFunctionThatReturnsNull;
820
- }
821
-
822
- function validate(props, propName, componentName, location, propFullName) {
823
- var propValue = props[propName];
824
- for (var i = 0; i < expectedValues.length; i++) {
825
- if (is(propValue, expectedValues[i])) {
826
- return null;
827
- }
828
- }
829
-
830
- var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
831
- var type = getPreciseType(value);
832
- if (type === 'symbol') {
833
- return String(value);
834
- }
835
- return value;
836
- });
837
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
838
- }
839
- return createChainableTypeChecker(validate);
840
- }
841
-
842
- function createObjectOfTypeChecker(typeChecker) {
843
- function validate(props, propName, componentName, location, propFullName) {
844
- if (typeof typeChecker !== 'function') {
845
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
846
- }
847
- var propValue = props[propName];
848
- var propType = getPropType(propValue);
849
- if (propType !== 'object') {
850
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
851
- }
852
- for (var key in propValue) {
853
- if (has$1(propValue, key)) {
854
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
855
- if (error instanceof Error) {
856
- return error;
857
- }
858
- }
859
- }
860
- return null;
861
- }
862
- return createChainableTypeChecker(validate);
863
- }
864
-
865
- function createUnionTypeChecker(arrayOfTypeCheckers) {
866
- if (!Array.isArray(arrayOfTypeCheckers)) {
867
- printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
868
- return emptyFunctionThatReturnsNull;
869
- }
870
-
871
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
872
- var checker = arrayOfTypeCheckers[i];
873
- if (typeof checker !== 'function') {
874
- printWarning$1(
875
- 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
876
- 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
877
- );
878
- return emptyFunctionThatReturnsNull;
879
- }
880
- }
881
-
882
- function validate(props, propName, componentName, location, propFullName) {
883
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
884
- var checker = arrayOfTypeCheckers[i];
885
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
886
- return null;
887
- }
888
- }
889
-
890
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
891
- }
892
- return createChainableTypeChecker(validate);
893
- }
894
-
895
- function createNodeChecker() {
896
- function validate(props, propName, componentName, location, propFullName) {
897
- if (!isNode(props[propName])) {
898
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
899
- }
900
- return null;
901
- }
902
- return createChainableTypeChecker(validate);
903
- }
904
-
905
- function createShapeTypeChecker(shapeTypes) {
906
- function validate(props, propName, componentName, location, propFullName) {
907
- var propValue = props[propName];
908
- var propType = getPropType(propValue);
909
- if (propType !== 'object') {
910
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
911
- }
912
- for (var key in shapeTypes) {
913
- var checker = shapeTypes[key];
914
- if (!checker) {
915
- continue;
916
- }
917
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
918
- if (error) {
919
- return error;
920
- }
921
- }
922
- return null;
923
- }
924
- return createChainableTypeChecker(validate);
925
- }
926
-
927
- function createStrictShapeTypeChecker(shapeTypes) {
928
- function validate(props, propName, componentName, location, propFullName) {
929
- var propValue = props[propName];
930
- var propType = getPropType(propValue);
931
- if (propType !== 'object') {
932
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
933
- }
934
- // We need to check all keys in case some are required but missing from
935
- // props.
936
- var allKeys = objectAssign({}, props[propName], shapeTypes);
937
- for (var key in allKeys) {
938
- var checker = shapeTypes[key];
939
- if (!checker) {
940
- return new PropTypeError(
941
- 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
942
- '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
943
- '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
944
- );
945
- }
946
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
947
- if (error) {
948
- return error;
949
- }
950
- }
951
- return null;
952
- }
953
-
954
- return createChainableTypeChecker(validate);
955
- }
956
-
957
- function isNode(propValue) {
958
- switch (typeof propValue) {
959
- case 'number':
960
- case 'string':
961
- case 'undefined':
962
- return true;
963
- case 'boolean':
964
- return !propValue;
965
- case 'object':
966
- if (Array.isArray(propValue)) {
967
- return propValue.every(isNode);
968
- }
969
- if (propValue === null || isValidElement(propValue)) {
970
- return true;
971
- }
972
-
973
- var iteratorFn = getIteratorFn(propValue);
974
- if (iteratorFn) {
975
- var iterator = iteratorFn.call(propValue);
976
- var step;
977
- if (iteratorFn !== propValue.entries) {
978
- while (!(step = iterator.next()).done) {
979
- if (!isNode(step.value)) {
980
- return false;
981
- }
982
- }
983
- } else {
984
- // Iterator will provide entry [k,v] tuples rather than values.
985
- while (!(step = iterator.next()).done) {
986
- var entry = step.value;
987
- if (entry) {
988
- if (!isNode(entry[1])) {
989
- return false;
990
- }
991
- }
992
- }
993
- }
994
- } else {
995
- return false;
996
- }
997
-
998
- return true;
999
- default:
1000
- return false;
1001
- }
1002
- }
1003
-
1004
- function isSymbol(propType, propValue) {
1005
- // Native Symbol.
1006
- if (propType === 'symbol') {
1007
- return true;
1008
- }
1009
-
1010
- // falsy value can't be a Symbol
1011
- if (!propValue) {
1012
- return false;
1013
- }
1014
-
1015
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1016
- if (propValue['@@toStringTag'] === 'Symbol') {
1017
- return true;
1018
- }
1019
-
1020
- // Fallback for non-spec compliant Symbols which are polyfilled.
1021
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1022
- return true;
1023
- }
1024
-
1025
- return false;
1026
- }
1027
-
1028
- // Equivalent of `typeof` but with special handling for array and regexp.
1029
- function getPropType(propValue) {
1030
- var propType = typeof propValue;
1031
- if (Array.isArray(propValue)) {
1032
- return 'array';
1033
- }
1034
- if (propValue instanceof RegExp) {
1035
- // Old webkits (at least until Android 4.0) return 'function' rather than
1036
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1037
- // passes PropTypes.object.
1038
- return 'object';
1039
- }
1040
- if (isSymbol(propType, propValue)) {
1041
- return 'symbol';
1042
- }
1043
- return propType;
1044
- }
1045
-
1046
- // This handles more types than `getPropType`. Only used for error messages.
1047
- // See `createPrimitiveTypeChecker`.
1048
- function getPreciseType(propValue) {
1049
- if (typeof propValue === 'undefined' || propValue === null) {
1050
- return '' + propValue;
1051
- }
1052
- var propType = getPropType(propValue);
1053
- if (propType === 'object') {
1054
- if (propValue instanceof Date) {
1055
- return 'date';
1056
- } else if (propValue instanceof RegExp) {
1057
- return 'regexp';
1058
- }
1059
- }
1060
- return propType;
1061
- }
1062
-
1063
- // Returns a string that is postfixed to a warning about an invalid type.
1064
- // For example, "undefined" or "of type array"
1065
- function getPostfixForTypeWarning(value) {
1066
- var type = getPreciseType(value);
1067
- switch (type) {
1068
- case 'array':
1069
- case 'object':
1070
- return 'an ' + type;
1071
- case 'boolean':
1072
- case 'date':
1073
- case 'regexp':
1074
- return 'a ' + type;
1075
- default:
1076
- return type;
1077
- }
1078
- }
1079
-
1080
- // Returns class name of the object, if any.
1081
- function getClassName(propValue) {
1082
- if (!propValue.constructor || !propValue.constructor.name) {
1083
- return ANONYMOUS;
1084
- }
1085
- return propValue.constructor.name;
1086
- }
1087
-
1088
- ReactPropTypes.checkPropTypes = checkPropTypes_1;
1089
- ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
1090
- ReactPropTypes.PropTypes = ReactPropTypes;
1091
-
1092
- return ReactPropTypes;
1093
- };
1094
-
1095
- var propTypes = createCommonjsModule(function (module) {
1096
- /**
1097
- * Copyright (c) 2013-present, Facebook, Inc.
1098
- *
1099
- * This source code is licensed under the MIT license found in the
1100
- * LICENSE file in the root directory of this source tree.
1101
- */
1102
-
1103
- {
1104
- var ReactIs = reactIs;
1105
-
1106
- // By explicitly using `prop-types` you are opting into new development behavior.
1107
- // http://fb.me/prop-types-in-prod
1108
- var throwOnDirectAccess = true;
1109
- module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
1110
- }
1111
- });
1112
-
1113
- function _extends() {
1114
- _extends = Object.assign || function (target) {
1115
- for (var i = 1; i < arguments.length; i++) {
1116
- var source = arguments[i];
1117
-
1118
- for (var key in source) {
1119
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1120
- target[key] = source[key];
1121
- }
1122
- }
1123
- }
1124
-
1125
- return target;
1126
- };
1127
-
1128
- return _extends.apply(this, arguments);
1129
- }
1130
-
1131
- function isAbsolute(pathname) {
1132
- return pathname.charAt(0) === '/';
1133
- }
1134
-
1135
- // About 1.5x faster than the two-arg version of Array#splice()
1136
- function spliceOne(list, index) {
1137
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
1138
- list[i] = list[k];
1139
- }
1140
-
1141
- list.pop();
1142
- }
1143
-
1144
- // This implementation is based heavily on node's url.parse
1145
- function resolvePathname(to) {
1146
- var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1147
-
1148
- var toParts = to && to.split('/') || [];
1149
- var fromParts = from && from.split('/') || [];
1150
-
1151
- var isToAbs = to && isAbsolute(to);
1152
- var isFromAbs = from && isAbsolute(from);
1153
- var mustEndAbs = isToAbs || isFromAbs;
1154
-
1155
- if (to && isAbsolute(to)) {
1156
- // to is absolute
1157
- fromParts = toParts;
1158
- } else if (toParts.length) {
1159
- // to is relative, drop the filename
1160
- fromParts.pop();
1161
- fromParts = fromParts.concat(toParts);
1162
- }
1163
-
1164
- if (!fromParts.length) return '/';
1165
-
1166
- var hasTrailingSlash = void 0;
1167
- if (fromParts.length) {
1168
- var last = fromParts[fromParts.length - 1];
1169
- hasTrailingSlash = last === '.' || last === '..' || last === '';
1170
- } else {
1171
- hasTrailingSlash = false;
1172
- }
1173
-
1174
- var up = 0;
1175
- for (var i = fromParts.length; i >= 0; i--) {
1176
- var part = fromParts[i];
1177
-
1178
- if (part === '.') {
1179
- spliceOne(fromParts, i);
1180
- } else if (part === '..') {
1181
- spliceOne(fromParts, i);
1182
- up++;
1183
- } else if (up) {
1184
- spliceOne(fromParts, i);
1185
- up--;
1186
- }
1187
- }
1188
-
1189
- if (!mustEndAbs) for (; up--; up) {
1190
- fromParts.unshift('..');
1191
- }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
1192
-
1193
- var result = fromParts.join('/');
1194
-
1195
- if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
1196
-
1197
- return result;
1198
- }
1199
-
1200
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1201
-
1202
- function valueEqual(a, b) {
1203
- if (a === b) return true;
1204
-
1205
- if (a == null || b == null) return false;
1206
-
1207
- if (Array.isArray(a)) {
1208
- return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
1209
- return valueEqual(item, b[index]);
1210
- });
1211
- }
1212
-
1213
- var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
1214
- var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
1215
-
1216
- if (aType !== bType) return false;
1217
-
1218
- if (aType === 'object') {
1219
- var aValue = a.valueOf();
1220
- var bValue = b.valueOf();
1221
-
1222
- if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
1223
-
1224
- var aKeys = Object.keys(a);
1225
- var bKeys = Object.keys(b);
1226
-
1227
- if (aKeys.length !== bKeys.length) return false;
1228
-
1229
- return aKeys.every(function (key) {
1230
- return valueEqual(a[key], b[key]);
1231
- });
1232
- }
1233
-
1234
- return false;
1235
- }
1236
-
1237
- function warning(condition, message) {
1238
- {
1239
- if (condition) {
1240
- return;
1241
- }
1242
-
1243
- var text = "Warning: " + message;
1244
-
1245
- if (typeof console !== 'undefined') {
1246
- console.warn(text);
1247
- }
1248
-
1249
- try {
1250
- throw Error(text);
1251
- } catch (x) {}
1252
- }
1253
- }
1254
-
1255
- var prefix = 'Invariant failed';
1256
- function invariant(condition, message) {
1257
- if (condition) {
1258
- return;
1259
- }
1260
-
1261
- {
1262
- throw new Error(prefix + ": " + (message || ''));
1263
- }
1264
- }
1265
-
1266
- function addLeadingSlash(path) {
1267
- return path.charAt(0) === '/' ? path : '/' + path;
1268
- }
1269
- function stripLeadingSlash(path) {
1270
- return path.charAt(0) === '/' ? path.substr(1) : path;
1271
- }
1272
- function hasBasename(path, prefix) {
1273
- return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
1274
- }
1275
- function stripBasename(path, prefix) {
1276
- return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
1277
- }
1278
- function stripTrailingSlash(path) {
1279
- return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
1280
- }
1281
- function parsePath(path) {
1282
- var pathname = path || '/';
1283
- var search = '';
1284
- var hash = '';
1285
- var hashIndex = pathname.indexOf('#');
1286
-
1287
- if (hashIndex !== -1) {
1288
- hash = pathname.substr(hashIndex);
1289
- pathname = pathname.substr(0, hashIndex);
1290
- }
1291
-
1292
- var searchIndex = pathname.indexOf('?');
1293
-
1294
- if (searchIndex !== -1) {
1295
- search = pathname.substr(searchIndex);
1296
- pathname = pathname.substr(0, searchIndex);
1297
- }
1298
-
1299
- return {
1300
- pathname: pathname,
1301
- search: search === '?' ? '' : search,
1302
- hash: hash === '#' ? '' : hash
1303
- };
1304
- }
1305
- function createPath(location) {
1306
- var pathname = location.pathname,
1307
- search = location.search,
1308
- hash = location.hash;
1309
- var path = pathname || '/';
1310
- if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
1311
- if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
1312
- return path;
1313
- }
1314
-
1315
- function createLocation(path, state, key, currentLocation) {
1316
- var location;
1317
-
1318
- if (typeof path === 'string') {
1319
- // Two-arg form: push(path, state)
1320
- location = parsePath(path);
1321
- location.state = state;
1322
- } else {
1323
- // One-arg form: push(location)
1324
- location = _extends({}, path);
1325
- if (location.pathname === undefined) location.pathname = '';
1326
-
1327
- if (location.search) {
1328
- if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
1329
- } else {
1330
- location.search = '';
1331
- }
1332
-
1333
- if (location.hash) {
1334
- if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
1335
- } else {
1336
- location.hash = '';
1337
- }
1338
-
1339
- if (state !== undefined && location.state === undefined) location.state = state;
1340
- }
1341
-
1342
- try {
1343
- location.pathname = decodeURI(location.pathname);
1344
- } catch (e) {
1345
- if (e instanceof URIError) {
1346
- throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
1347
- } else {
1348
- throw e;
1349
- }
1350
- }
1351
-
1352
- if (key) location.key = key;
1353
-
1354
- if (currentLocation) {
1355
- // Resolve incomplete/relative pathname relative to current location.
1356
- if (!location.pathname) {
1357
- location.pathname = currentLocation.pathname;
1358
- } else if (location.pathname.charAt(0) !== '/') {
1359
- location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
1360
- }
1361
- } else {
1362
- // When there is no prior location and pathname is empty, set it to /
1363
- if (!location.pathname) {
1364
- location.pathname = '/';
1365
- }
1366
- }
1367
-
1368
- return location;
1369
- }
1370
- function locationsAreEqual(a, b) {
1371
- return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
1372
- }
1373
-
1374
- function createTransitionManager() {
1375
- var prompt = null;
1376
-
1377
- function setPrompt(nextPrompt) {
1378
- warning(prompt == null, 'A history supports only one prompt at a time') ;
1379
- prompt = nextPrompt;
1380
- return function () {
1381
- if (prompt === nextPrompt) prompt = null;
1382
- };
1383
- }
1384
-
1385
- function confirmTransitionTo(location, action, getUserConfirmation, callback) {
1386
- // TODO: If another transition starts while we're still confirming
1387
- // the previous one, we may end up in a weird state. Figure out the
1388
- // best way to handle this.
1389
- if (prompt != null) {
1390
- var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
1391
-
1392
- if (typeof result === 'string') {
1393
- if (typeof getUserConfirmation === 'function') {
1394
- getUserConfirmation(result, callback);
1395
- } else {
1396
- warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') ;
1397
- callback(true);
1398
- }
1399
- } else {
1400
- // Return false from a transition hook to cancel the transition.
1401
- callback(result !== false);
1402
- }
1403
- } else {
1404
- callback(true);
1405
- }
1406
- }
1407
-
1408
- var listeners = [];
1409
-
1410
- function appendListener(fn) {
1411
- var isActive = true;
1412
-
1413
- function listener() {
1414
- if (isActive) fn.apply(void 0, arguments);
1415
- }
1416
-
1417
- listeners.push(listener);
1418
- return function () {
1419
- isActive = false;
1420
- listeners = listeners.filter(function (item) {
1421
- return item !== listener;
1422
- });
1423
- };
1424
- }
1425
-
1426
- function notifyListeners() {
1427
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1428
- args[_key] = arguments[_key];
1429
- }
1430
-
1431
- listeners.forEach(function (listener) {
1432
- return listener.apply(void 0, args);
1433
- });
1434
- }
1435
-
1436
- return {
1437
- setPrompt: setPrompt,
1438
- confirmTransitionTo: confirmTransitionTo,
1439
- appendListener: appendListener,
1440
- notifyListeners: notifyListeners
1441
- };
1442
- }
1443
-
1444
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
1445
- function getConfirmation(message, callback) {
1446
- callback(window.confirm(message)); // eslint-disable-line no-alert
1447
- }
1448
- /**
1449
- * Returns true if the HTML5 history API is supported. Taken from Modernizr.
1450
- *
1451
- * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
1452
- * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
1453
- * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
1454
- */
1455
-
1456
- function supportsHistory() {
1457
- var ua = window.navigator.userAgent;
1458
- if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
1459
- return window.history && 'pushState' in window.history;
1460
- }
1461
- /**
1462
- * Returns true if browser fires popstate on hash change.
1463
- * IE10 and IE11 do not.
1464
- */
1465
-
1466
- function supportsPopStateOnHashChange() {
1467
- return window.navigator.userAgent.indexOf('Trident') === -1;
1468
- }
1469
- /**
1470
- * Returns false if using go(n) with hash history causes a full page reload.
1471
- */
1472
-
1473
- function supportsGoWithoutReloadUsingHash() {
1474
- return window.navigator.userAgent.indexOf('Firefox') === -1;
1475
- }
1476
- /**
1477
- * Returns true if a given popstate event is an extraneous WebKit event.
1478
- * Accounts for the fact that Chrome on iOS fires real popstate events
1479
- * containing undefined state when pressing the back button.
1480
- */
1481
-
1482
- function isExtraneousPopstateEvent(event) {
1483
- event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
1484
- }
1485
-
1486
- var PopStateEvent = 'popstate';
1487
- var HashChangeEvent = 'hashchange';
1488
-
1489
- function getHistoryState() {
1490
- try {
1491
- return window.history.state || {};
1492
- } catch (e) {
1493
- // IE 11 sometimes throws when accessing window.history.state
1494
- // See https://github.com/ReactTraining/history/pull/289
1495
- return {};
1496
- }
1497
- }
1498
- /**
1499
- * Creates a history object that uses the HTML5 history API including
1500
- * pushState, replaceState, and the popstate event.
1501
- */
1502
-
1503
-
1504
- function createBrowserHistory(props) {
1505
- if (props === void 0) {
1506
- props = {};
1507
- }
1508
-
1509
- !canUseDOM ? invariant(false, 'Browser history needs a DOM') : void 0;
1510
- var globalHistory = window.history;
1511
- var canUseHistory = supportsHistory();
1512
- var needsHashChangeListener = !supportsPopStateOnHashChange();
1513
- var _props = props,
1514
- _props$forceRefresh = _props.forceRefresh,
1515
- forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
1516
- _props$getUserConfirm = _props.getUserConfirmation,
1517
- getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
1518
- _props$keyLength = _props.keyLength,
1519
- keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
1520
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
1521
-
1522
- function getDOMLocation(historyState) {
1523
- var _ref = historyState || {},
1524
- key = _ref.key,
1525
- state = _ref.state;
1526
-
1527
- var _window$location = window.location,
1528
- pathname = _window$location.pathname,
1529
- search = _window$location.search,
1530
- hash = _window$location.hash;
1531
- var path = pathname + search + hash;
1532
- warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') ;
1533
- if (basename) path = stripBasename(path, basename);
1534
- return createLocation(path, state, key);
1535
- }
1536
-
1537
- function createKey() {
1538
- return Math.random().toString(36).substr(2, keyLength);
1539
- }
1540
-
1541
- var transitionManager = createTransitionManager();
1542
-
1543
- function setState(nextState) {
1544
- _extends(history, nextState);
1545
-
1546
- history.length = globalHistory.length;
1547
- transitionManager.notifyListeners(history.location, history.action);
1548
- }
1549
-
1550
- function handlePopState(event) {
1551
- // Ignore extraneous popstate events in WebKit.
1552
- if (isExtraneousPopstateEvent(event)) return;
1553
- handlePop(getDOMLocation(event.state));
1554
- }
1555
-
1556
- function handleHashChange() {
1557
- handlePop(getDOMLocation(getHistoryState()));
1558
- }
1559
-
1560
- var forceNextPop = false;
1561
-
1562
- function handlePop(location) {
1563
- if (forceNextPop) {
1564
- forceNextPop = false;
1565
- setState();
1566
- } else {
1567
- var action = 'POP';
1568
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1569
- if (ok) {
1570
- setState({
1571
- action: action,
1572
- location: location
1573
- });
1574
- } else {
1575
- revertPop(location);
1576
- }
1577
- });
1578
- }
1579
- }
1580
-
1581
- function revertPop(fromLocation) {
1582
- var toLocation = history.location; // TODO: We could probably make this more reliable by
1583
- // keeping a list of keys we've seen in sessionStorage.
1584
- // Instead, we just default to 0 for keys we don't know.
1585
-
1586
- var toIndex = allKeys.indexOf(toLocation.key);
1587
- if (toIndex === -1) toIndex = 0;
1588
- var fromIndex = allKeys.indexOf(fromLocation.key);
1589
- if (fromIndex === -1) fromIndex = 0;
1590
- var delta = toIndex - fromIndex;
1591
-
1592
- if (delta) {
1593
- forceNextPop = true;
1594
- go(delta);
1595
- }
1596
- }
1597
-
1598
- var initialLocation = getDOMLocation(getHistoryState());
1599
- var allKeys = [initialLocation.key]; // Public interface
1600
-
1601
- function createHref(location) {
1602
- return basename + createPath(location);
1603
- }
1604
-
1605
- function push(path, state) {
1606
- 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') ;
1607
- var action = 'PUSH';
1608
- var location = createLocation(path, state, createKey(), history.location);
1609
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1610
- if (!ok) return;
1611
- var href = createHref(location);
1612
- var key = location.key,
1613
- state = location.state;
1614
-
1615
- if (canUseHistory) {
1616
- globalHistory.pushState({
1617
- key: key,
1618
- state: state
1619
- }, null, href);
1620
-
1621
- if (forceRefresh) {
1622
- window.location.href = href;
1623
- } else {
1624
- var prevIndex = allKeys.indexOf(history.location.key);
1625
- var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
1626
- nextKeys.push(location.key);
1627
- allKeys = nextKeys;
1628
- setState({
1629
- action: action,
1630
- location: location
1631
- });
1632
- }
1633
- } else {
1634
- warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') ;
1635
- window.location.href = href;
1636
- }
1637
- });
1638
- }
1639
-
1640
- function replace(path, state) {
1641
- 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') ;
1642
- var action = 'REPLACE';
1643
- var location = createLocation(path, state, createKey(), history.location);
1644
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1645
- if (!ok) return;
1646
- var href = createHref(location);
1647
- var key = location.key,
1648
- state = location.state;
1649
-
1650
- if (canUseHistory) {
1651
- globalHistory.replaceState({
1652
- key: key,
1653
- state: state
1654
- }, null, href);
1655
-
1656
- if (forceRefresh) {
1657
- window.location.replace(href);
1658
- } else {
1659
- var prevIndex = allKeys.indexOf(history.location.key);
1660
- if (prevIndex !== -1) allKeys[prevIndex] = location.key;
1661
- setState({
1662
- action: action,
1663
- location: location
1664
- });
1665
- }
1666
- } else {
1667
- warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') ;
1668
- window.location.replace(href);
1669
- }
1670
- });
1671
- }
1672
-
1673
- function go(n) {
1674
- globalHistory.go(n);
1675
- }
1676
-
1677
- function goBack() {
1678
- go(-1);
1679
- }
1680
-
1681
- function goForward() {
1682
- go(1);
1683
- }
1684
-
1685
- var listenerCount = 0;
1686
-
1687
- function checkDOMListeners(delta) {
1688
- listenerCount += delta;
1689
-
1690
- if (listenerCount === 1 && delta === 1) {
1691
- window.addEventListener(PopStateEvent, handlePopState);
1692
- if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
1693
- } else if (listenerCount === 0) {
1694
- window.removeEventListener(PopStateEvent, handlePopState);
1695
- if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
1696
- }
1697
- }
1698
-
1699
- var isBlocked = false;
1700
-
1701
- function block(prompt) {
1702
- if (prompt === void 0) {
1703
- prompt = false;
1704
- }
1705
-
1706
- var unblock = transitionManager.setPrompt(prompt);
1707
-
1708
- if (!isBlocked) {
1709
- checkDOMListeners(1);
1710
- isBlocked = true;
1711
- }
1712
-
1713
- return function () {
1714
- if (isBlocked) {
1715
- isBlocked = false;
1716
- checkDOMListeners(-1);
1717
- }
1718
-
1719
- return unblock();
1720
- };
1721
- }
1722
-
1723
- function listen(listener) {
1724
- var unlisten = transitionManager.appendListener(listener);
1725
- checkDOMListeners(1);
1726
- return function () {
1727
- checkDOMListeners(-1);
1728
- unlisten();
1729
- };
1730
- }
1731
-
1732
- var history = {
1733
- length: globalHistory.length,
1734
- action: 'POP',
1735
- location: initialLocation,
1736
- createHref: createHref,
1737
- push: push,
1738
- replace: replace,
1739
- go: go,
1740
- goBack: goBack,
1741
- goForward: goForward,
1742
- block: block,
1743
- listen: listen
1744
- };
1745
- return history;
1746
- }
1747
-
1748
- var HashChangeEvent$1 = 'hashchange';
1749
- var HashPathCoders = {
1750
- hashbang: {
1751
- encodePath: function encodePath(path) {
1752
- return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);
1753
- },
1754
- decodePath: function decodePath(path) {
1755
- return path.charAt(0) === '!' ? path.substr(1) : path;
1756
- }
1757
- },
1758
- noslash: {
1759
- encodePath: stripLeadingSlash,
1760
- decodePath: addLeadingSlash
1761
- },
1762
- slash: {
1763
- encodePath: addLeadingSlash,
1764
- decodePath: addLeadingSlash
1765
- }
1766
- };
1767
-
1768
- function getHashPath() {
1769
- // We can't use window.location.hash here because it's not
1770
- // consistent across browsers - Firefox will pre-decode it!
1771
- var href = window.location.href;
1772
- var hashIndex = href.indexOf('#');
1773
- return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
1774
- }
1775
-
1776
- function pushHashPath(path) {
1777
- window.location.hash = path;
1778
- }
1779
-
1780
- function replaceHashPath(path) {
1781
- var hashIndex = window.location.href.indexOf('#');
1782
- window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
1783
- }
1784
-
1785
- function createHashHistory(props) {
1786
- if (props === void 0) {
1787
- props = {};
1788
- }
1789
-
1790
- !canUseDOM ? invariant(false, 'Hash history needs a DOM') : void 0;
1791
- var globalHistory = window.history;
1792
- var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
1793
- var _props = props,
1794
- _props$getUserConfirm = _props.getUserConfirmation,
1795
- getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
1796
- _props$hashType = _props.hashType,
1797
- hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;
1798
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
1799
- var _HashPathCoders$hashT = HashPathCoders[hashType],
1800
- encodePath = _HashPathCoders$hashT.encodePath,
1801
- decodePath = _HashPathCoders$hashT.decodePath;
1802
-
1803
- function getDOMLocation() {
1804
- var path = decodePath(getHashPath());
1805
- warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') ;
1806
- if (basename) path = stripBasename(path, basename);
1807
- return createLocation(path);
1808
- }
1809
-
1810
- var transitionManager = createTransitionManager();
1811
-
1812
- function setState(nextState) {
1813
- _extends(history, nextState);
1814
-
1815
- history.length = globalHistory.length;
1816
- transitionManager.notifyListeners(history.location, history.action);
1817
- }
1818
-
1819
- var forceNextPop = false;
1820
- var ignorePath = null;
1821
-
1822
- function handleHashChange() {
1823
- var path = getHashPath();
1824
- var encodedPath = encodePath(path);
1825
-
1826
- if (path !== encodedPath) {
1827
- // Ensure we always have a properly-encoded hash.
1828
- replaceHashPath(encodedPath);
1829
- } else {
1830
- var location = getDOMLocation();
1831
- var prevLocation = history.location;
1832
- if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
1833
-
1834
- if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.
1835
-
1836
- ignorePath = null;
1837
- handlePop(location);
1838
- }
1839
- }
1840
-
1841
- function handlePop(location) {
1842
- if (forceNextPop) {
1843
- forceNextPop = false;
1844
- setState();
1845
- } else {
1846
- var action = 'POP';
1847
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1848
- if (ok) {
1849
- setState({
1850
- action: action,
1851
- location: location
1852
- });
1853
- } else {
1854
- revertPop(location);
1855
- }
1856
- });
1857
- }
1858
- }
1859
-
1860
- function revertPop(fromLocation) {
1861
- var toLocation = history.location; // TODO: We could probably make this more reliable by
1862
- // keeping a list of paths we've seen in sessionStorage.
1863
- // Instead, we just default to 0 for paths we don't know.
1864
-
1865
- var toIndex = allPaths.lastIndexOf(createPath(toLocation));
1866
- if (toIndex === -1) toIndex = 0;
1867
- var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
1868
- if (fromIndex === -1) fromIndex = 0;
1869
- var delta = toIndex - fromIndex;
1870
-
1871
- if (delta) {
1872
- forceNextPop = true;
1873
- go(delta);
1874
- }
1875
- } // Ensure the hash is encoded properly before doing anything else.
1876
-
1877
-
1878
- var path = getHashPath();
1879
- var encodedPath = encodePath(path);
1880
- if (path !== encodedPath) replaceHashPath(encodedPath);
1881
- var initialLocation = getDOMLocation();
1882
- var allPaths = [createPath(initialLocation)]; // Public interface
1883
-
1884
- function createHref(location) {
1885
- return '#' + encodePath(basename + createPath(location));
1886
- }
1887
-
1888
- function push(path, state) {
1889
- warning(state === undefined, 'Hash history cannot push state; it is ignored') ;
1890
- var action = 'PUSH';
1891
- var location = createLocation(path, undefined, undefined, history.location);
1892
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1893
- if (!ok) return;
1894
- var path = createPath(location);
1895
- var encodedPath = encodePath(basename + path);
1896
- var hashChanged = getHashPath() !== encodedPath;
1897
-
1898
- if (hashChanged) {
1899
- // We cannot tell if a hashchange was caused by a PUSH, so we'd
1900
- // rather setState here and ignore the hashchange. The caveat here
1901
- // is that other hash histories in the page will consider it a POP.
1902
- ignorePath = path;
1903
- pushHashPath(encodedPath);
1904
- var prevIndex = allPaths.lastIndexOf(createPath(history.location));
1905
- var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
1906
- nextPaths.push(path);
1907
- allPaths = nextPaths;
1908
- setState({
1909
- action: action,
1910
- location: location
1911
- });
1912
- } else {
1913
- warning(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack') ;
1914
- setState();
1915
- }
1916
- });
1917
- }
1918
-
1919
- function replace(path, state) {
1920
- warning(state === undefined, 'Hash history cannot replace state; it is ignored') ;
1921
- var action = 'REPLACE';
1922
- var location = createLocation(path, undefined, undefined, history.location);
1923
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1924
- if (!ok) return;
1925
- var path = createPath(location);
1926
- var encodedPath = encodePath(basename + path);
1927
- var hashChanged = getHashPath() !== encodedPath;
1928
-
1929
- if (hashChanged) {
1930
- // We cannot tell if a hashchange was caused by a REPLACE, so we'd
1931
- // rather setState here and ignore the hashchange. The caveat here
1932
- // is that other hash histories in the page will consider it a POP.
1933
- ignorePath = path;
1934
- replaceHashPath(encodedPath);
1935
- }
1936
-
1937
- var prevIndex = allPaths.indexOf(createPath(history.location));
1938
- if (prevIndex !== -1) allPaths[prevIndex] = path;
1939
- setState({
1940
- action: action,
1941
- location: location
1942
- });
1943
- });
1944
- }
1945
-
1946
- function go(n) {
1947
- warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser') ;
1948
- globalHistory.go(n);
1949
- }
1950
-
1951
- function goBack() {
1952
- go(-1);
1953
- }
1954
-
1955
- function goForward() {
1956
- go(1);
1957
- }
1958
-
1959
- var listenerCount = 0;
1960
-
1961
- function checkDOMListeners(delta) {
1962
- listenerCount += delta;
1963
-
1964
- if (listenerCount === 1 && delta === 1) {
1965
- window.addEventListener(HashChangeEvent$1, handleHashChange);
1966
- } else if (listenerCount === 0) {
1967
- window.removeEventListener(HashChangeEvent$1, handleHashChange);
1968
- }
1969
- }
1970
-
1971
- var isBlocked = false;
1972
-
1973
- function block(prompt) {
1974
- if (prompt === void 0) {
1975
- prompt = false;
1976
- }
1977
-
1978
- var unblock = transitionManager.setPrompt(prompt);
1979
-
1980
- if (!isBlocked) {
1981
- checkDOMListeners(1);
1982
- isBlocked = true;
1983
- }
1984
-
1985
- return function () {
1986
- if (isBlocked) {
1987
- isBlocked = false;
1988
- checkDOMListeners(-1);
1989
- }
1990
-
1991
- return unblock();
1992
- };
1993
- }
1994
-
1995
- function listen(listener) {
1996
- var unlisten = transitionManager.appendListener(listener);
1997
- checkDOMListeners(1);
1998
- return function () {
1999
- checkDOMListeners(-1);
2000
- unlisten();
2001
- };
2002
- }
2003
-
2004
- var history = {
2005
- length: globalHistory.length,
2006
- action: 'POP',
2007
- location: initialLocation,
2008
- createHref: createHref,
2009
- push: push,
2010
- replace: replace,
2011
- go: go,
2012
- goBack: goBack,
2013
- goForward: goForward,
2014
- block: block,
2015
- listen: listen
2016
- };
2017
- return history;
2018
- }
2019
-
2020
- function clamp(n, lowerBound, upperBound) {
2021
- return Math.min(Math.max(n, lowerBound), upperBound);
2022
- }
2023
- /**
2024
- * Creates a history object that stores locations in memory.
2025
- */
2026
-
2027
-
2028
- function createMemoryHistory(props) {
2029
- if (props === void 0) {
2030
- props = {};
2031
- }
2032
-
2033
- var _props = props,
2034
- getUserConfirmation = _props.getUserConfirmation,
2035
- _props$initialEntries = _props.initialEntries,
2036
- initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
2037
- _props$initialIndex = _props.initialIndex,
2038
- initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
2039
- _props$keyLength = _props.keyLength,
2040
- keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
2041
- var transitionManager = createTransitionManager();
2042
-
2043
- function setState(nextState) {
2044
- _extends(history, nextState);
2045
-
2046
- history.length = history.entries.length;
2047
- transitionManager.notifyListeners(history.location, history.action);
2048
- }
2049
-
2050
- function createKey() {
2051
- return Math.random().toString(36).substr(2, keyLength);
2052
- }
2053
-
2054
- var index = clamp(initialIndex, 0, initialEntries.length - 1);
2055
- var entries = initialEntries.map(function (entry) {
2056
- return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
2057
- }); // Public interface
2058
-
2059
- var createHref = createPath;
2060
-
2061
- function push(path, state) {
2062
- 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') ;
2063
- var action = 'PUSH';
2064
- var location = createLocation(path, state, createKey(), history.location);
2065
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2066
- if (!ok) return;
2067
- var prevIndex = history.index;
2068
- var nextIndex = prevIndex + 1;
2069
- var nextEntries = history.entries.slice(0);
2070
-
2071
- if (nextEntries.length > nextIndex) {
2072
- nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
2073
- } else {
2074
- nextEntries.push(location);
2075
- }
2076
-
2077
- setState({
2078
- action: action,
2079
- location: location,
2080
- index: nextIndex,
2081
- entries: nextEntries
2082
- });
2083
- });
2084
- }
2085
-
2086
- function replace(path, state) {
2087
- 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') ;
2088
- var action = 'REPLACE';
2089
- var location = createLocation(path, state, createKey(), history.location);
2090
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2091
- if (!ok) return;
2092
- history.entries[history.index] = location;
2093
- setState({
2094
- action: action,
2095
- location: location
2096
- });
2097
- });
2098
- }
2099
-
2100
- function go(n) {
2101
- var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
2102
- var action = 'POP';
2103
- var location = history.entries[nextIndex];
2104
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2105
- if (ok) {
2106
- setState({
2107
- action: action,
2108
- location: location,
2109
- index: nextIndex
2110
- });
2111
- } else {
2112
- // Mimic the behavior of DOM histories by
2113
- // causing a render after a cancelled POP.
2114
- setState();
2115
- }
2116
- });
2117
- }
2118
-
2119
- function goBack() {
2120
- go(-1);
2121
- }
2122
-
2123
- function goForward() {
2124
- go(1);
2125
- }
2126
-
2127
- function canGo(n) {
2128
- var nextIndex = history.index + n;
2129
- return nextIndex >= 0 && nextIndex < history.entries.length;
2130
- }
2131
-
2132
- function block(prompt) {
2133
- if (prompt === void 0) {
2134
- prompt = false;
2135
- }
2136
-
2137
- return transitionManager.setPrompt(prompt);
2138
- }
2139
-
2140
- function listen(listener) {
2141
- return transitionManager.appendListener(listener);
2142
- }
2143
-
2144
- var history = {
2145
- length: entries.length,
2146
- action: 'POP',
2147
- location: entries[index],
2148
- index: index,
2149
- entries: entries,
2150
- createHref: createHref,
2151
- push: push,
2152
- replace: replace,
2153
- go: go,
2154
- goBack: goBack,
2155
- goForward: goForward,
2156
- canGo: canGo,
2157
- block: block,
2158
- listen: listen
2159
- };
2160
- return history;
2161
- }
2162
-
2163
- function _inheritsLoose$1(subClass, superClass) {
2164
- subClass.prototype = Object.create(superClass.prototype);
2165
- subClass.prototype.constructor = subClass;
2166
- subClass.__proto__ = superClass;
2167
- }
2168
-
2169
- var MAX_SIGNED_31_BIT_INT = 1073741823;
2170
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
2171
-
2172
- function getUniqueId() {
2173
- var key = '__global_unique_id__';
2174
- return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
2175
- }
2176
-
2177
- function objectIs(x, y) {
2178
- if (x === y) {
2179
- return x !== 0 || 1 / x === 1 / y;
2180
- } else {
2181
- return x !== x && y !== y;
2182
- }
2183
- }
2184
-
2185
- function createEventEmitter(value) {
2186
- var handlers = [];
2187
- return {
2188
- on: function on(handler) {
2189
- handlers.push(handler);
2190
- },
2191
- off: function off(handler) {
2192
- handlers = handlers.filter(function (h) {
2193
- return h !== handler;
2194
- });
2195
- },
2196
- get: function get() {
2197
- return value;
2198
- },
2199
- set: function set(newValue, changedBits) {
2200
- value = newValue;
2201
- handlers.forEach(function (handler) {
2202
- return handler(value, changedBits);
2203
- });
2204
- }
2205
- };
2206
- }
2207
-
2208
- function onlyChild(children) {
2209
- return Array.isArray(children) ? children[0] : children;
2210
- }
2211
-
2212
- function createReactContext(defaultValue, calculateChangedBits) {
2213
- var _Provider$childContex, _Consumer$contextType;
2214
-
2215
- var contextProp = '__create-react-context-' + getUniqueId() + '__';
2216
-
2217
- var Provider = /*#__PURE__*/function (_Component) {
2218
- _inheritsLoose$1(Provider, _Component);
2219
-
2220
- function Provider() {
2221
- var _this;
2222
-
2223
- _this = _Component.apply(this, arguments) || this;
2224
- _this.emitter = createEventEmitter(_this.props.value);
2225
- return _this;
2226
- }
2227
-
2228
- var _proto = Provider.prototype;
2229
-
2230
- _proto.getChildContext = function getChildContext() {
2231
- var _ref;
2232
-
2233
- return _ref = {}, _ref[contextProp] = this.emitter, _ref;
2234
- };
2235
-
2236
- _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
2237
- if (this.props.value !== nextProps.value) {
2238
- var oldValue = this.props.value;
2239
- var newValue = nextProps.value;
2240
- var changedBits;
2241
-
2242
- if (objectIs(oldValue, newValue)) {
2243
- changedBits = 0;
2244
- } else {
2245
- changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
2246
-
2247
- {
2248
- warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
2249
- }
2250
-
2251
- changedBits |= 0;
2252
-
2253
- if (changedBits !== 0) {
2254
- this.emitter.set(nextProps.value, changedBits);
2255
- }
2256
- }
2257
- }
2258
- };
2259
-
2260
- _proto.render = function render() {
2261
- return this.props.children;
2262
- };
2263
-
2264
- return Provider;
2265
- }(React.Component);
2266
-
2267
- Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
2268
-
2269
- var Consumer = /*#__PURE__*/function (_Component2) {
2270
- _inheritsLoose$1(Consumer, _Component2);
2271
-
2272
- function Consumer() {
2273
- var _this2;
2274
-
2275
- _this2 = _Component2.apply(this, arguments) || this;
2276
- _this2.state = {
2277
- value: _this2.getValue()
2278
- };
2279
-
2280
- _this2.onUpdate = function (newValue, changedBits) {
2281
- var observedBits = _this2.observedBits | 0;
2282
-
2283
- if ((observedBits & changedBits) !== 0) {
2284
- _this2.setState({
2285
- value: _this2.getValue()
2286
- });
2287
- }
2288
- };
2289
-
2290
- return _this2;
2291
- }
2292
-
2293
- var _proto2 = Consumer.prototype;
2294
-
2295
- _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
2296
- var observedBits = nextProps.observedBits;
2297
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
2298
- };
2299
-
2300
- _proto2.componentDidMount = function componentDidMount() {
2301
- if (this.context[contextProp]) {
2302
- this.context[contextProp].on(this.onUpdate);
2303
- }
2304
-
2305
- var observedBits = this.props.observedBits;
2306
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
2307
- };
2308
-
2309
- _proto2.componentWillUnmount = function componentWillUnmount() {
2310
- if (this.context[contextProp]) {
2311
- this.context[contextProp].off(this.onUpdate);
2312
- }
2313
- };
2314
-
2315
- _proto2.getValue = function getValue() {
2316
- if (this.context[contextProp]) {
2317
- return this.context[contextProp].get();
2318
- } else {
2319
- return defaultValue;
2320
- }
2321
- };
2322
-
2323
- _proto2.render = function render() {
2324
- return onlyChild(this.props.children)(this.state.value);
2325
- };
2326
-
2327
- return Consumer;
2328
- }(React.Component);
2329
-
2330
- Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = propTypes.object, _Consumer$contextType);
2331
- return {
2332
- Provider: Provider,
2333
- Consumer: Consumer
2334
- };
2335
- }
2336
-
2337
- var index = React__default.createContext || createReactContext;
2338
-
2339
- var isarray = Array.isArray || function (arr) {
2340
- return Object.prototype.toString.call(arr) == '[object Array]';
2341
- };
2342
-
2343
- /**
2344
- * Expose `pathToRegexp`.
2345
- */
2346
- var pathToRegexp_1 = pathToRegexp;
2347
- var parse_1 = parse;
2348
- var compile_1 = compile;
2349
- var tokensToFunction_1 = tokensToFunction;
2350
- var tokensToRegExp_1 = tokensToRegExp;
2351
-
2352
- /**
2353
- * The main path matching regexp utility.
2354
- *
2355
- * @type {RegExp}
2356
- */
2357
- var PATH_REGEXP = new RegExp([
2358
- // Match escaped characters that would otherwise appear in future matches.
2359
- // This allows the user to escape special characters that won't transform.
2360
- '(\\\\.)',
2361
- // Match Express-style parameters and un-named parameters with a prefix
2362
- // and optional suffixes. Matches appear as:
2363
- //
2364
- // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
2365
- // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
2366
- // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
2367
- '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
2368
- ].join('|'), 'g');
2369
-
2370
- /**
2371
- * Parse a string for the raw tokens.
2372
- *
2373
- * @param {string} str
2374
- * @param {Object=} options
2375
- * @return {!Array}
2376
- */
2377
- function parse (str, options) {
2378
- var tokens = [];
2379
- var key = 0;
2380
- var index = 0;
2381
- var path = '';
2382
- var defaultDelimiter = options && options.delimiter || '/';
2383
- var res;
2384
-
2385
- while ((res = PATH_REGEXP.exec(str)) != null) {
2386
- var m = res[0];
2387
- var escaped = res[1];
2388
- var offset = res.index;
2389
- path += str.slice(index, offset);
2390
- index = offset + m.length;
2391
-
2392
- // Ignore already escaped sequences.
2393
- if (escaped) {
2394
- path += escaped[1];
2395
- continue
2396
- }
2397
-
2398
- var next = str[index];
2399
- var prefix = res[2];
2400
- var name = res[3];
2401
- var capture = res[4];
2402
- var group = res[5];
2403
- var modifier = res[6];
2404
- var asterisk = res[7];
2405
-
2406
- // Push the current path onto the tokens.
2407
- if (path) {
2408
- tokens.push(path);
2409
- path = '';
2410
- }
2411
-
2412
- var partial = prefix != null && next != null && next !== prefix;
2413
- var repeat = modifier === '+' || modifier === '*';
2414
- var optional = modifier === '?' || modifier === '*';
2415
- var delimiter = res[2] || defaultDelimiter;
2416
- var pattern = capture || group;
2417
-
2418
- tokens.push({
2419
- name: name || key++,
2420
- prefix: prefix || '',
2421
- delimiter: delimiter,
2422
- optional: optional,
2423
- repeat: repeat,
2424
- partial: partial,
2425
- asterisk: !!asterisk,
2426
- pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
2427
- });
2428
- }
2429
-
2430
- // Match any characters still remaining.
2431
- if (index < str.length) {
2432
- path += str.substr(index);
2433
- }
2434
-
2435
- // If the path exists, push it onto the end.
2436
- if (path) {
2437
- tokens.push(path);
2438
- }
2439
-
2440
- return tokens
2441
- }
2442
-
2443
- /**
2444
- * Compile a string to a template function for the path.
2445
- *
2446
- * @param {string} str
2447
- * @param {Object=} options
2448
- * @return {!function(Object=, Object=)}
2449
- */
2450
- function compile (str, options) {
2451
- return tokensToFunction(parse(str, options))
2452
- }
2453
-
2454
- /**
2455
- * Prettier encoding of URI path segments.
2456
- *
2457
- * @param {string}
2458
- * @return {string}
2459
- */
2460
- function encodeURIComponentPretty (str) {
2461
- return encodeURI(str).replace(/[\/?#]/g, function (c) {
2462
- return '%' + c.charCodeAt(0).toString(16).toUpperCase()
2463
- })
2464
- }
2465
-
2466
- /**
2467
- * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
2468
- *
2469
- * @param {string}
2470
- * @return {string}
2471
- */
2472
- function encodeAsterisk (str) {
2473
- return encodeURI(str).replace(/[?#]/g, function (c) {
2474
- return '%' + c.charCodeAt(0).toString(16).toUpperCase()
2475
- })
2476
- }
2477
-
2478
- /**
2479
- * Expose a method for transforming tokens into the path function.
2480
- */
2481
- function tokensToFunction (tokens) {
2482
- // Compile all the tokens into regexps.
2483
- var matches = new Array(tokens.length);
2484
-
2485
- // Compile all the patterns before compilation.
2486
- for (var i = 0; i < tokens.length; i++) {
2487
- if (typeof tokens[i] === 'object') {
2488
- matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
2489
- }
2490
- }
2491
-
2492
- return function (obj, opts) {
2493
- var path = '';
2494
- var data = obj || {};
2495
- var options = opts || {};
2496
- var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
2497
-
2498
- for (var i = 0; i < tokens.length; i++) {
2499
- var token = tokens[i];
2500
-
2501
- if (typeof token === 'string') {
2502
- path += token;
2503
-
2504
- continue
2505
- }
2506
-
2507
- var value = data[token.name];
2508
- var segment;
2509
-
2510
- if (value == null) {
2511
- if (token.optional) {
2512
- // Prepend partial segment prefixes.
2513
- if (token.partial) {
2514
- path += token.prefix;
2515
- }
2516
-
2517
- continue
2518
- } else {
2519
- throw new TypeError('Expected "' + token.name + '" to be defined')
2520
- }
2521
- }
2522
-
2523
- if (isarray(value)) {
2524
- if (!token.repeat) {
2525
- throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
2526
- }
2527
-
2528
- if (value.length === 0) {
2529
- if (token.optional) {
2530
- continue
2531
- } else {
2532
- throw new TypeError('Expected "' + token.name + '" to not be empty')
2533
- }
2534
- }
2535
-
2536
- for (var j = 0; j < value.length; j++) {
2537
- segment = encode(value[j]);
2538
-
2539
- if (!matches[i].test(segment)) {
2540
- throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
2541
- }
2542
-
2543
- path += (j === 0 ? token.prefix : token.delimiter) + segment;
2544
- }
2545
-
2546
- continue
2547
- }
2548
-
2549
- segment = token.asterisk ? encodeAsterisk(value) : encode(value);
2550
-
2551
- if (!matches[i].test(segment)) {
2552
- throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
2553
- }
2554
-
2555
- path += token.prefix + segment;
2556
- }
2557
-
2558
- return path
2559
- }
2560
- }
2561
-
2562
- /**
2563
- * Escape a regular expression string.
2564
- *
2565
- * @param {string} str
2566
- * @return {string}
2567
- */
2568
- function escapeString (str) {
2569
- return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
2570
- }
2571
-
2572
- /**
2573
- * Escape the capturing group by escaping special characters and meaning.
2574
- *
2575
- * @param {string} group
2576
- * @return {string}
2577
- */
2578
- function escapeGroup (group) {
2579
- return group.replace(/([=!:$\/()])/g, '\\$1')
2580
- }
2581
-
2582
- /**
2583
- * Attach the keys as a property of the regexp.
2584
- *
2585
- * @param {!RegExp} re
2586
- * @param {Array} keys
2587
- * @return {!RegExp}
2588
- */
2589
- function attachKeys (re, keys) {
2590
- re.keys = keys;
2591
- return re
2592
- }
2593
-
2594
- /**
2595
- * Get the flags for a regexp from the options.
2596
- *
2597
- * @param {Object} options
2598
- * @return {string}
2599
- */
2600
- function flags (options) {
2601
- return options.sensitive ? '' : 'i'
2602
- }
2603
-
2604
- /**
2605
- * Pull out keys from a regexp.
2606
- *
2607
- * @param {!RegExp} path
2608
- * @param {!Array} keys
2609
- * @return {!RegExp}
2610
- */
2611
- function regexpToRegexp (path, keys) {
2612
- // Use a negative lookahead to match only capturing groups.
2613
- var groups = path.source.match(/\((?!\?)/g);
2614
-
2615
- if (groups) {
2616
- for (var i = 0; i < groups.length; i++) {
2617
- keys.push({
2618
- name: i,
2619
- prefix: null,
2620
- delimiter: null,
2621
- optional: false,
2622
- repeat: false,
2623
- partial: false,
2624
- asterisk: false,
2625
- pattern: null
2626
- });
2627
- }
2628
- }
2629
-
2630
- return attachKeys(path, keys)
2631
- }
2632
-
2633
- /**
2634
- * Transform an array into a regexp.
2635
- *
2636
- * @param {!Array} path
2637
- * @param {Array} keys
2638
- * @param {!Object} options
2639
- * @return {!RegExp}
2640
- */
2641
- function arrayToRegexp (path, keys, options) {
2642
- var parts = [];
2643
-
2644
- for (var i = 0; i < path.length; i++) {
2645
- parts.push(pathToRegexp(path[i], keys, options).source);
2646
- }
2647
-
2648
- var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
2649
-
2650
- return attachKeys(regexp, keys)
2651
- }
2652
-
2653
- /**
2654
- * Create a path regexp from string input.
2655
- *
2656
- * @param {string} path
2657
- * @param {!Array} keys
2658
- * @param {!Object} options
2659
- * @return {!RegExp}
2660
- */
2661
- function stringToRegexp (path, keys, options) {
2662
- return tokensToRegExp(parse(path, options), keys, options)
2663
- }
2664
-
2665
- /**
2666
- * Expose a function for taking tokens and returning a RegExp.
2667
- *
2668
- * @param {!Array} tokens
2669
- * @param {(Array|Object)=} keys
2670
- * @param {Object=} options
2671
- * @return {!RegExp}
2672
- */
2673
- function tokensToRegExp (tokens, keys, options) {
2674
- if (!isarray(keys)) {
2675
- options = /** @type {!Object} */ (keys || options);
2676
- keys = [];
2677
- }
2678
-
2679
- options = options || {};
2680
-
2681
- var strict = options.strict;
2682
- var end = options.end !== false;
2683
- var route = '';
2684
-
2685
- // Iterate over the tokens and create our regexp string.
2686
- for (var i = 0; i < tokens.length; i++) {
2687
- var token = tokens[i];
2688
-
2689
- if (typeof token === 'string') {
2690
- route += escapeString(token);
2691
- } else {
2692
- var prefix = escapeString(token.prefix);
2693
- var capture = '(?:' + token.pattern + ')';
2694
-
2695
- keys.push(token);
2696
-
2697
- if (token.repeat) {
2698
- capture += '(?:' + prefix + capture + ')*';
2699
- }
2700
-
2701
- if (token.optional) {
2702
- if (!token.partial) {
2703
- capture = '(?:' + prefix + '(' + capture + '))?';
2704
- } else {
2705
- capture = prefix + '(' + capture + ')?';
2706
- }
2707
- } else {
2708
- capture = prefix + '(' + capture + ')';
2709
- }
2710
-
2711
- route += capture;
2712
- }
2713
- }
2714
-
2715
- var delimiter = escapeString(options.delimiter || '/');
2716
- var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
2717
-
2718
- // In non-strict mode we allow a slash at the end of match. If the path to
2719
- // match already ends with a slash, we remove it for consistency. The slash
2720
- // is valid at the end of a path match, not in the middle. This is important
2721
- // in non-ending mode, where "/test/" shouldn't match "/test//route".
2722
- if (!strict) {
2723
- route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
2724
- }
2725
-
2726
- if (end) {
2727
- route += '$';
2728
- } else {
2729
- // In non-ending mode, we need the capturing groups to match as much as
2730
- // possible by using a positive lookahead to the end or next path segment.
2731
- route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
2732
- }
2733
-
2734
- return attachKeys(new RegExp('^' + route, flags(options)), keys)
2735
- }
2736
-
2737
- /**
2738
- * Normalize the given path string, returning a regular expression.
2739
- *
2740
- * An empty array can be passed in for the keys, which will hold the
2741
- * placeholder key descriptions. For example, using `/user/:id`, `keys` will
2742
- * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
2743
- *
2744
- * @param {(string|RegExp|Array)} path
2745
- * @param {(Array|Object)=} keys
2746
- * @param {Object=} options
2747
- * @return {!RegExp}
2748
- */
2749
- function pathToRegexp (path, keys, options) {
2750
- if (!isarray(keys)) {
2751
- options = /** @type {!Object} */ (keys || options);
2752
- keys = [];
2753
- }
2754
-
2755
- options = options || {};
2756
-
2757
- if (path instanceof RegExp) {
2758
- return regexpToRegexp(path, /** @type {!Array} */ (keys))
2759
- }
2760
-
2761
- if (isarray(path)) {
2762
- return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
2763
- }
2764
-
2765
- return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
2766
- }
2767
- pathToRegexp_1.parse = parse_1;
2768
- pathToRegexp_1.compile = compile_1;
2769
- pathToRegexp_1.tokensToFunction = tokensToFunction_1;
2770
- pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
2771
-
2772
- function _objectWithoutPropertiesLoose(source, excluded) {
2773
- if (source == null) return {};
2774
- var target = {};
2775
- var sourceKeys = Object.keys(source);
2776
- var key, i;
2777
-
2778
- for (i = 0; i < sourceKeys.length; i++) {
2779
- key = sourceKeys[i];
2780
- if (excluded.indexOf(key) >= 0) continue;
2781
- target[key] = source[key];
2782
- }
2783
-
2784
- return target;
2785
- }
2786
-
2787
- /**
2788
- * Copyright 2015, Yahoo! Inc.
2789
- * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2790
- */
2791
-
2792
- var REACT_STATICS = {
2793
- childContextTypes: true,
2794
- contextType: true,
2795
- contextTypes: true,
2796
- defaultProps: true,
2797
- displayName: true,
2798
- getDefaultProps: true,
2799
- getDerivedStateFromError: true,
2800
- getDerivedStateFromProps: true,
2801
- mixins: true,
2802
- propTypes: true,
2803
- type: true
2804
- };
2805
-
2806
- var KNOWN_STATICS = {
2807
- name: true,
2808
- length: true,
2809
- prototype: true,
2810
- caller: true,
2811
- callee: true,
2812
- arguments: true,
2813
- arity: true
2814
- };
2815
-
2816
- var FORWARD_REF_STATICS = {
2817
- '$$typeof': true,
2818
- render: true,
2819
- defaultProps: true,
2820
- displayName: true,
2821
- propTypes: true
2822
- };
2823
-
2824
- var MEMO_STATICS = {
2825
- '$$typeof': true,
2826
- compare: true,
2827
- defaultProps: true,
2828
- displayName: true,
2829
- propTypes: true,
2830
- type: true
2831
- };
2832
-
2833
- var TYPE_STATICS = {};
2834
- TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
2835
-
2836
- function getStatics(component) {
2837
- if (reactIs.isMemo(component)) {
2838
- return MEMO_STATICS;
2839
- }
2840
- return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
2841
- }
2842
-
2843
- var defineProperty = Object.defineProperty;
2844
- var getOwnPropertyNames = Object.getOwnPropertyNames;
2845
- var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
2846
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2847
- var getPrototypeOf = Object.getPrototypeOf;
2848
- var objectPrototype = Object.prototype;
2849
-
2850
- function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
2851
- if (typeof sourceComponent !== 'string') {
2852
- // don't hoist over string (html) components
2853
-
2854
- if (objectPrototype) {
2855
- var inheritedComponent = getPrototypeOf(sourceComponent);
2856
- if (inheritedComponent && inheritedComponent !== objectPrototype) {
2857
- hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
2858
- }
2859
- }
2860
-
2861
- var keys = getOwnPropertyNames(sourceComponent);
2862
-
2863
- if (getOwnPropertySymbols$1) {
2864
- keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
2865
- }
2866
-
2867
- var targetStatics = getStatics(targetComponent);
2868
- var sourceStatics = getStatics(sourceComponent);
2869
-
2870
- for (var i = 0; i < keys.length; ++i) {
2871
- var key = keys[i];
2872
- if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
2873
- var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
2874
- try {
2875
- // Avoid failures from read-only properties
2876
- defineProperty(targetComponent, key, descriptor);
2877
- } catch (e) {}
2878
- }
2879
- }
2880
-
2881
- return targetComponent;
2882
- }
2883
-
2884
- return targetComponent;
2885
- }
2886
-
2887
- var hoistNonReactStatics_cjs = hoistNonReactStatics;
2888
-
2889
- var createNamedContext = function createNamedContext(name) {
2890
- var context = index();
2891
- context.displayName = name;
2892
- return context;
2893
- };
2894
-
2895
- var historyContext =
2896
- /*#__PURE__*/
2897
- createNamedContext("Router-History"); // TODO: Replace with React.createContext once we can assume React 16+
2898
-
2899
- var createNamedContext$1 = function createNamedContext(name) {
2900
- var context = index();
2901
- context.displayName = name;
2902
- return context;
2903
- };
2904
-
2905
- var context =
2906
- /*#__PURE__*/
2907
- createNamedContext$1("Router");
2908
- /**
2909
- * The public API for putting history on context.
2910
- */
2911
-
2912
- var Router =
2913
- /*#__PURE__*/
2914
- function (_React$Component) {
2915
- _inheritsLoose(Router, _React$Component);
2916
-
2917
- Router.computeRootMatch = function computeRootMatch(pathname) {
2918
- return {
2919
- path: "/",
2920
- url: "/",
2921
- params: {},
2922
- isExact: pathname === "/"
2923
- };
2924
- };
2925
-
2926
- function Router(props) {
2927
- var _this;
2928
-
2929
- _this = _React$Component.call(this, props) || this;
2930
- _this.state = {
2931
- location: props.history.location
2932
- }; // This is a bit of a hack. We have to start listening for location
2933
- // changes here in the constructor in case there are any <Redirect>s
2934
- // on the initial render. If there are, they will replace/push when
2935
- // they mount and since cDM fires in children before parents, we may
2936
- // get a new location before the <Router> is mounted.
2937
-
2938
- _this._isMounted = false;
2939
- _this._pendingLocation = null;
2940
-
2941
- if (!props.staticContext) {
2942
- _this.unlisten = props.history.listen(function (location) {
2943
- if (_this._isMounted) {
2944
- _this.setState({
2945
- location: location
2946
- });
2947
- } else {
2948
- _this._pendingLocation = location;
2949
- }
2950
- });
2951
- }
2952
-
2953
- return _this;
2954
- }
2955
-
2956
- var _proto = Router.prototype;
2957
-
2958
- _proto.componentDidMount = function componentDidMount() {
2959
- this._isMounted = true;
2960
-
2961
- if (this._pendingLocation) {
2962
- this.setState({
2963
- location: this._pendingLocation
2964
- });
2965
- }
2966
- };
2967
-
2968
- _proto.componentWillUnmount = function componentWillUnmount() {
2969
- if (this.unlisten) this.unlisten();
2970
- };
2971
-
2972
- _proto.render = function render() {
2973
- return React__default.createElement(context.Provider, {
2974
- value: {
2975
- history: this.props.history,
2976
- location: this.state.location,
2977
- match: Router.computeRootMatch(this.state.location.pathname),
2978
- staticContext: this.props.staticContext
2979
- }
2980
- }, React__default.createElement(historyContext.Provider, {
2981
- children: this.props.children || null,
2982
- value: this.props.history
2983
- }));
2984
- };
2985
-
2986
- return Router;
2987
- }(React__default.Component);
2988
-
2989
- {
2990
- Router.propTypes = {
2991
- children: propTypes.node,
2992
- history: propTypes.object.isRequired,
2993
- staticContext: propTypes.object
2994
- };
2995
-
2996
- Router.prototype.componentDidUpdate = function (prevProps) {
2997
- warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
2998
- };
2999
- }
3000
- /**
3001
- * The public API for a <Router> that stores location in memory.
3002
- */
3003
-
3004
-
3005
- var MemoryRouter =
3006
- /*#__PURE__*/
3007
- function (_React$Component) {
3008
- _inheritsLoose(MemoryRouter, _React$Component);
3009
-
3010
- function MemoryRouter() {
3011
- var _this;
3012
-
3013
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3014
- args[_key] = arguments[_key];
3015
- }
3016
-
3017
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
3018
- _this.history = createMemoryHistory(_this.props);
3019
- return _this;
3020
- }
3021
-
3022
- var _proto = MemoryRouter.prototype;
3023
-
3024
- _proto.render = function render() {
3025
- return React__default.createElement(Router, {
3026
- history: this.history,
3027
- children: this.props.children
3028
- });
3029
- };
3030
-
3031
- return MemoryRouter;
3032
- }(React__default.Component);
3033
-
3034
- {
3035
- MemoryRouter.propTypes = {
3036
- initialEntries: propTypes.array,
3037
- initialIndex: propTypes.number,
3038
- getUserConfirmation: propTypes.func,
3039
- keyLength: propTypes.number,
3040
- children: propTypes.node
3041
- };
3042
-
3043
- MemoryRouter.prototype.componentDidMount = function () {
3044
- warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
3045
- };
3046
- }
3047
-
3048
- var Lifecycle =
3049
- /*#__PURE__*/
3050
- function (_React$Component) {
3051
- _inheritsLoose(Lifecycle, _React$Component);
3052
-
3053
- function Lifecycle() {
3054
- return _React$Component.apply(this, arguments) || this;
3055
- }
3056
-
3057
- var _proto = Lifecycle.prototype;
3058
-
3059
- _proto.componentDidMount = function componentDidMount() {
3060
- if (this.props.onMount) this.props.onMount.call(this, this);
3061
- };
3062
-
3063
- _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
3064
- if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
3065
- };
3066
-
3067
- _proto.componentWillUnmount = function componentWillUnmount() {
3068
- if (this.props.onUnmount) this.props.onUnmount.call(this, this);
3069
- };
3070
-
3071
- _proto.render = function render() {
3072
- return null;
3073
- };
3074
-
3075
- return Lifecycle;
3076
- }(React__default.Component);
3077
- /**
3078
- * The public API for prompting the user before navigating away from a screen.
3079
- */
3080
-
3081
-
3082
- function Prompt(_ref) {
3083
- var message = _ref.message,
3084
- _ref$when = _ref.when,
3085
- when = _ref$when === void 0 ? true : _ref$when;
3086
- return React__default.createElement(context.Consumer, null, function (context) {
3087
- !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
3088
- if (!when || context.staticContext) return null;
3089
- var method = context.history.block;
3090
- return React__default.createElement(Lifecycle, {
3091
- onMount: function onMount(self) {
3092
- self.release = method(message);
3093
- },
3094
- onUpdate: function onUpdate(self, prevProps) {
3095
- if (prevProps.message !== message) {
3096
- self.release();
3097
- self.release = method(message);
3098
- }
3099
- },
3100
- onUnmount: function onUnmount(self) {
3101
- self.release();
3102
- },
3103
- message: message
3104
- });
3105
- });
3106
- }
3107
-
3108
- {
3109
- var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
3110
- Prompt.propTypes = {
3111
- when: propTypes.bool,
3112
- message: messageType.isRequired
3113
- };
3114
- }
3115
-
3116
- var cache = {};
3117
- var cacheLimit = 10000;
3118
- var cacheCount = 0;
3119
-
3120
- function compilePath(path) {
3121
- if (cache[path]) return cache[path];
3122
- var generator = pathToRegexp_1.compile(path);
3123
-
3124
- if (cacheCount < cacheLimit) {
3125
- cache[path] = generator;
3126
- cacheCount++;
3127
- }
3128
-
3129
- return generator;
3130
- }
3131
- /**
3132
- * Public API for generating a URL pathname from a path and parameters.
3133
- */
3134
-
3135
-
3136
- function generatePath(path, params) {
3137
- if (path === void 0) {
3138
- path = "/";
3139
- }
3140
-
3141
- if (params === void 0) {
3142
- params = {};
3143
- }
3144
-
3145
- return path === "/" ? path : compilePath(path)(params, {
3146
- pretty: true
3147
- });
3148
- }
3149
- /**
3150
- * The public API for navigating programmatically with a component.
3151
- */
3152
-
3153
-
3154
- function Redirect(_ref) {
3155
- var computedMatch = _ref.computedMatch,
3156
- to = _ref.to,
3157
- _ref$push = _ref.push,
3158
- push = _ref$push === void 0 ? false : _ref$push;
3159
- return React__default.createElement(context.Consumer, null, function (context) {
3160
- !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
3161
- var history = context.history,
3162
- staticContext = context.staticContext;
3163
- var method = push ? history.push : history.replace;
3164
- var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
3165
- pathname: generatePath(to.pathname, computedMatch.params)
3166
- }) : to); // When rendering in a static context,
3167
- // set the new location immediately.
3168
-
3169
- if (staticContext) {
3170
- method(location);
3171
- return null;
3172
- }
3173
-
3174
- return React__default.createElement(Lifecycle, {
3175
- onMount: function onMount() {
3176
- method(location);
3177
- },
3178
- onUpdate: function onUpdate(self, prevProps) {
3179
- var prevLocation = createLocation(prevProps.to);
3180
-
3181
- if (!locationsAreEqual(prevLocation, _extends({}, location, {
3182
- key: prevLocation.key
3183
- }))) {
3184
- method(location);
3185
- }
3186
- },
3187
- to: to
3188
- });
3189
- });
3190
- }
3191
-
3192
- {
3193
- Redirect.propTypes = {
3194
- push: propTypes.bool,
3195
- from: propTypes.string,
3196
- to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
3197
- };
3198
- }
3199
-
3200
- var cache$1 = {};
3201
- var cacheLimit$1 = 10000;
3202
- var cacheCount$1 = 0;
3203
-
3204
- function compilePath$1(path, options) {
3205
- var cacheKey = "" + options.end + options.strict + options.sensitive;
3206
- var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
3207
- if (pathCache[path]) return pathCache[path];
3208
- var keys = [];
3209
- var regexp = pathToRegexp_1(path, keys, options);
3210
- var result = {
3211
- regexp: regexp,
3212
- keys: keys
3213
- };
3214
-
3215
- if (cacheCount$1 < cacheLimit$1) {
3216
- pathCache[path] = result;
3217
- cacheCount$1++;
3218
- }
3219
-
3220
- return result;
3221
- }
3222
- /**
3223
- * Public API for matching a URL pathname to a path.
3224
- */
3225
-
3226
-
3227
- function matchPath(pathname, options) {
3228
- if (options === void 0) {
3229
- options = {};
3230
- }
3231
-
3232
- if (typeof options === "string" || Array.isArray(options)) {
3233
- options = {
3234
- path: options
3235
- };
3236
- }
3237
-
3238
- var _options = options,
3239
- path = _options.path,
3240
- _options$exact = _options.exact,
3241
- exact = _options$exact === void 0 ? false : _options$exact,
3242
- _options$strict = _options.strict,
3243
- strict = _options$strict === void 0 ? false : _options$strict,
3244
- _options$sensitive = _options.sensitive,
3245
- sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
3246
- var paths = [].concat(path);
3247
- return paths.reduce(function (matched, path) {
3248
- if (!path && path !== "") return null;
3249
- if (matched) return matched;
3250
-
3251
- var _compilePath = compilePath$1(path, {
3252
- end: exact,
3253
- strict: strict,
3254
- sensitive: sensitive
3255
- }),
3256
- regexp = _compilePath.regexp,
3257
- keys = _compilePath.keys;
3258
-
3259
- var match = regexp.exec(pathname);
3260
- if (!match) return null;
3261
- var url = match[0],
3262
- values = match.slice(1);
3263
- var isExact = pathname === url;
3264
- if (exact && !isExact) return null;
3265
- return {
3266
- path: path,
3267
- // the path used to match
3268
- url: path === "/" && url === "" ? "/" : url,
3269
- // the matched portion of the URL
3270
- isExact: isExact,
3271
- // whether or not we matched exactly
3272
- params: keys.reduce(function (memo, key, index) {
3273
- memo[key.name] = values[index];
3274
- return memo;
3275
- }, {})
3276
- };
3277
- }, null);
3278
- }
3279
-
3280
- function isEmptyChildren(children) {
3281
- return React__default.Children.count(children) === 0;
3282
- }
3283
-
3284
- function evalChildrenDev(children, props, path) {
3285
- var value = children(props);
3286
- 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`") ;
3287
- return value || null;
3288
- }
3289
- /**
3290
- * The public API for matching a single path and rendering.
3291
- */
3292
-
3293
-
3294
- var Route =
3295
- /*#__PURE__*/
3296
- function (_React$Component) {
3297
- _inheritsLoose(Route, _React$Component);
3298
-
3299
- function Route() {
3300
- return _React$Component.apply(this, arguments) || this;
3301
- }
3302
-
3303
- var _proto = Route.prototype;
3304
-
3305
- _proto.render = function render() {
3306
- var _this = this;
3307
-
3308
- return React__default.createElement(context.Consumer, null, function (context$1) {
3309
- !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
3310
- var location = _this.props.location || context$1.location;
3311
- var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
3312
- : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
3313
-
3314
- var props = _extends({}, context$1, {
3315
- location: location,
3316
- match: match
3317
- });
3318
-
3319
- var _this$props = _this.props,
3320
- children = _this$props.children,
3321
- component = _this$props.component,
3322
- render = _this$props.render; // Preact uses an empty array as children by
3323
- // default, so use null if that's the case.
3324
-
3325
- if (Array.isArray(children) && children.length === 0) {
3326
- children = null;
3327
- }
3328
-
3329
- return React__default.createElement(context.Provider, {
3330
- value: props
3331
- }, 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);
3332
- });
3333
- };
3334
-
3335
- return Route;
3336
- }(React__default.Component);
3337
-
3338
- {
3339
- Route.propTypes = {
3340
- children: propTypes.oneOfType([propTypes.func, propTypes.node]),
3341
- component: function component(props, propName) {
3342
- if (props[propName] && !reactIs_1(props[propName])) {
3343
- return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
3344
- }
3345
- },
3346
- exact: propTypes.bool,
3347
- location: propTypes.object,
3348
- path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
3349
- render: propTypes.func,
3350
- sensitive: propTypes.bool,
3351
- strict: propTypes.bool
3352
- };
3353
-
3354
- Route.prototype.componentDidMount = function () {
3355
- 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") ;
3356
- 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") ;
3357
- 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") ;
3358
- };
3359
-
3360
- Route.prototype.componentDidUpdate = function (prevProps) {
3361
- 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.') ;
3362
- 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.') ;
3363
- };
3364
- }
3365
-
3366
- function addLeadingSlash$1(path) {
3367
- return path.charAt(0) === "/" ? path : "/" + path;
3368
- }
3369
-
3370
- function addBasename(basename, location) {
3371
- if (!basename) return location;
3372
- return _extends({}, location, {
3373
- pathname: addLeadingSlash$1(basename) + location.pathname
3374
- });
3375
- }
3376
-
3377
- function stripBasename$1(basename, location) {
3378
- if (!basename) return location;
3379
- var base = addLeadingSlash$1(basename);
3380
- if (location.pathname.indexOf(base) !== 0) return location;
3381
- return _extends({}, location, {
3382
- pathname: location.pathname.substr(base.length)
3383
- });
3384
- }
3385
-
3386
- function createURL(location) {
3387
- return typeof location === "string" ? location : createPath(location);
3388
- }
3389
-
3390
- function staticHandler(methodName) {
3391
- return function () {
3392
- invariant(false, "You cannot %s with <StaticRouter>") ;
3393
- };
3394
- }
3395
-
3396
- function noop() {}
3397
- /**
3398
- * The public top-level API for a "static" <Router>, so-called because it
3399
- * can't actually change the current location. Instead, it just records
3400
- * location changes in a context object. Useful mainly in testing and
3401
- * server-rendering scenarios.
3402
- */
3403
-
3404
-
3405
- var StaticRouter =
3406
- /*#__PURE__*/
3407
- function (_React$Component) {
3408
- _inheritsLoose(StaticRouter, _React$Component);
3409
-
3410
- function StaticRouter() {
3411
- var _this;
3412
-
3413
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3414
- args[_key] = arguments[_key];
3415
- }
3416
-
3417
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
3418
-
3419
- _this.handlePush = function (location) {
3420
- return _this.navigateTo(location, "PUSH");
3421
- };
3422
-
3423
- _this.handleReplace = function (location) {
3424
- return _this.navigateTo(location, "REPLACE");
3425
- };
3426
-
3427
- _this.handleListen = function () {
3428
- return noop;
3429
- };
3430
-
3431
- _this.handleBlock = function () {
3432
- return noop;
3433
- };
3434
-
3435
- return _this;
3436
- }
3437
-
3438
- var _proto = StaticRouter.prototype;
3439
-
3440
- _proto.navigateTo = function navigateTo(location, action) {
3441
- var _this$props = this.props,
3442
- _this$props$basename = _this$props.basename,
3443
- basename = _this$props$basename === void 0 ? "" : _this$props$basename,
3444
- _this$props$context = _this$props.context,
3445
- context = _this$props$context === void 0 ? {} : _this$props$context;
3446
- context.action = action;
3447
- context.location = addBasename(basename, createLocation(location));
3448
- context.url = createURL(context.location);
3449
- };
3450
-
3451
- _proto.render = function render() {
3452
- var _this$props2 = this.props,
3453
- _this$props2$basename = _this$props2.basename,
3454
- basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
3455
- _this$props2$context = _this$props2.context,
3456
- context = _this$props2$context === void 0 ? {} : _this$props2$context,
3457
- _this$props2$location = _this$props2.location,
3458
- location = _this$props2$location === void 0 ? "/" : _this$props2$location,
3459
- rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
3460
-
3461
- var history = {
3462
- createHref: function createHref(path) {
3463
- return addLeadingSlash$1(basename + createURL(path));
3464
- },
3465
- action: "POP",
3466
- location: stripBasename$1(basename, createLocation(location)),
3467
- push: this.handlePush,
3468
- replace: this.handleReplace,
3469
- go: staticHandler(),
3470
- goBack: staticHandler(),
3471
- goForward: staticHandler(),
3472
- listen: this.handleListen,
3473
- block: this.handleBlock
3474
- };
3475
- return React__default.createElement(Router, _extends({}, rest, {
3476
- history: history,
3477
- staticContext: context
3478
- }));
3479
- };
3480
-
3481
- return StaticRouter;
3482
- }(React__default.Component);
3483
-
3484
- {
3485
- StaticRouter.propTypes = {
3486
- basename: propTypes.string,
3487
- context: propTypes.object,
3488
- location: propTypes.oneOfType([propTypes.string, propTypes.object])
3489
- };
3490
-
3491
- StaticRouter.prototype.componentDidMount = function () {
3492
- warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
3493
- };
3494
- }
3495
- /**
3496
- * The public API for rendering the first <Route> that matches.
3497
- */
3498
-
3499
-
3500
- var Switch =
3501
- /*#__PURE__*/
3502
- function (_React$Component) {
3503
- _inheritsLoose(Switch, _React$Component);
3504
-
3505
- function Switch() {
3506
- return _React$Component.apply(this, arguments) || this;
3507
- }
3508
-
3509
- var _proto = Switch.prototype;
3510
-
3511
- _proto.render = function render() {
3512
- var _this = this;
3513
-
3514
- return React__default.createElement(context.Consumer, null, function (context) {
3515
- !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
3516
- var location = _this.props.location || context.location;
3517
- var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
3518
- // here because toArray adds keys to all child elements and we do not want
3519
- // to trigger an unmount/remount for two <Route>s that render the same
3520
- // component at different URLs.
3521
-
3522
- React__default.Children.forEach(_this.props.children, function (child) {
3523
- if (match == null && React__default.isValidElement(child)) {
3524
- element = child;
3525
- var path = child.props.path || child.props.from;
3526
- match = path ? matchPath(location.pathname, _extends({}, child.props, {
3527
- path: path
3528
- })) : context.match;
3529
- }
3530
- });
3531
- return match ? React__default.cloneElement(element, {
3532
- location: location,
3533
- computedMatch: match
3534
- }) : null;
3535
- });
3536
- };
3537
-
3538
- return Switch;
3539
- }(React__default.Component);
3540
-
3541
- {
3542
- Switch.propTypes = {
3543
- children: propTypes.node,
3544
- location: propTypes.object
3545
- };
3546
-
3547
- Switch.prototype.componentDidUpdate = function (prevProps) {
3548
- 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.') ;
3549
- 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.') ;
3550
- };
3551
- }
3552
- /**
3553
- * A public higher-order component to access the imperative API
3554
- */
3555
-
3556
-
3557
- function withRouter(Component) {
3558
- var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
3559
-
3560
- var C = function C(props) {
3561
- var wrappedComponentRef = props.wrappedComponentRef,
3562
- remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
3563
-
3564
- return React__default.createElement(context.Consumer, null, function (context) {
3565
- !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
3566
- return React__default.createElement(Component, _extends({}, remainingProps, context, {
3567
- ref: wrappedComponentRef
3568
- }));
3569
- });
3570
- };
3571
-
3572
- C.displayName = displayName;
3573
- C.WrappedComponent = Component;
3574
-
3575
- {
3576
- C.propTypes = {
3577
- wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
3578
- };
3579
- }
3580
-
3581
- return hoistNonReactStatics_cjs(C, Component);
3582
- }
3583
-
3584
- var useContext = React__default.useContext;
3585
-
3586
- function useHistory() {
3587
- {
3588
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
3589
- }
3590
-
3591
- return useContext(historyContext);
3592
- }
3593
-
3594
- function useLocation() {
3595
- {
3596
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
3597
- }
3598
-
3599
- return useContext(context).location;
3600
- }
3601
-
3602
- function useParams() {
3603
- {
3604
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
3605
- }
3606
-
3607
- var match = useContext(context).match;
3608
- return match ? match.params : {};
3609
- }
3610
-
3611
- function useRouteMatch(path) {
3612
- {
3613
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
3614
- }
3615
-
3616
- var location = useLocation();
3617
- var match = useContext(context).match;
3618
- return path ? matchPath(location.pathname, path) : match;
3619
- }
3620
-
3621
- {
3622
- if (typeof window !== "undefined") {
3623
- var global$1 = window;
3624
- var key = "__react_router_build__";
3625
- var buildNames = {
3626
- cjs: "CommonJS",
3627
- esm: "ES modules",
3628
- umd: "UMD"
3629
- };
3630
-
3631
- if (global$1[key] && global$1[key] !== "esm") {
3632
- var initialBuildName = buildNames[global$1[key]];
3633
- var secondaryBuildName = buildNames["esm"]; // TODO: Add link to article that explains in detail how to avoid
3634
- // loading 2 different builds.
3635
-
3636
- 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.");
3637
- }
3638
-
3639
- global$1[key] = "esm";
3640
- }
3641
- }
3642
-
3643
- /**
3644
- * The public API for a <Router> that uses HTML5 history.
3645
- */
3646
-
3647
- var BrowserRouter =
3648
- /*#__PURE__*/
3649
- function (_React$Component) {
3650
- _inheritsLoose(BrowserRouter, _React$Component);
3651
-
3652
- function BrowserRouter() {
3653
- var _this;
3654
-
3655
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3656
- args[_key] = arguments[_key];
3657
- }
3658
-
3659
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
3660
- _this.history = createBrowserHistory(_this.props);
3661
- return _this;
3662
- }
3663
-
3664
- var _proto = BrowserRouter.prototype;
3665
-
3666
- _proto.render = function render() {
3667
- return React__default.createElement(Router, {
3668
- history: this.history,
3669
- children: this.props.children
3670
- });
3671
- };
3672
-
3673
- return BrowserRouter;
3674
- }(React__default.Component);
3675
-
3676
- {
3677
- BrowserRouter.propTypes = {
3678
- basename: propTypes.string,
3679
- children: propTypes.node,
3680
- forceRefresh: propTypes.bool,
3681
- getUserConfirmation: propTypes.func,
3682
- keyLength: propTypes.number
3683
- };
3684
-
3685
- BrowserRouter.prototype.componentDidMount = function () {
3686
- warning(!this.props.history, "<BrowserRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { BrowserRouter as Router }`.") ;
3687
- };
3688
- }
3689
-
3690
- /**
3691
- * The public API for a <Router> that uses window.location.hash.
3692
- */
3693
-
3694
- var HashRouter =
3695
- /*#__PURE__*/
3696
- function (_React$Component) {
3697
- _inheritsLoose(HashRouter, _React$Component);
3698
-
3699
- function HashRouter() {
3700
- var _this;
3701
-
3702
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3703
- args[_key] = arguments[_key];
3704
- }
3705
-
3706
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
3707
- _this.history = createHashHistory(_this.props);
3708
- return _this;
3709
- }
3710
-
3711
- var _proto = HashRouter.prototype;
3712
-
3713
- _proto.render = function render() {
3714
- return React__default.createElement(Router, {
3715
- history: this.history,
3716
- children: this.props.children
3717
- });
3718
- };
3719
-
3720
- return HashRouter;
3721
- }(React__default.Component);
3722
-
3723
- {
3724
- HashRouter.propTypes = {
3725
- basename: propTypes.string,
3726
- children: propTypes.node,
3727
- getUserConfirmation: propTypes.func,
3728
- hashType: propTypes.oneOf(["hashbang", "noslash", "slash"])
3729
- };
3730
-
3731
- HashRouter.prototype.componentDidMount = function () {
3732
- warning(!this.props.history, "<HashRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { HashRouter as Router }`.") ;
3733
- };
3734
- }
3735
-
3736
- var resolveToLocation = function resolveToLocation(to, currentLocation) {
3737
- return typeof to === "function" ? to(currentLocation) : to;
3738
- };
3739
- var normalizeToLocation = function normalizeToLocation(to, currentLocation) {
3740
- return typeof to === "string" ? createLocation(to, null, null, currentLocation) : to;
3741
- };
3742
-
3743
- var forwardRefShim = function forwardRefShim(C) {
3744
- return C;
3745
- };
3746
-
3747
- var forwardRef = React__default.forwardRef;
3748
-
3749
- if (typeof forwardRef === "undefined") {
3750
- forwardRef = forwardRefShim;
3751
- }
3752
-
3753
- function isModifiedEvent(event) {
3754
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
3755
- }
3756
-
3757
- var LinkAnchor = forwardRef(function (_ref, forwardedRef) {
3758
- var innerRef = _ref.innerRef,
3759
- navigate = _ref.navigate,
3760
- _onClick = _ref.onClick,
3761
- rest = _objectWithoutPropertiesLoose(_ref, ["innerRef", "navigate", "onClick"]);
3762
-
3763
- var target = rest.target;
3764
-
3765
- var props = _extends({}, rest, {
3766
- onClick: function onClick(event) {
3767
- try {
3768
- if (_onClick) _onClick(event);
3769
- } catch (ex) {
3770
- event.preventDefault();
3771
- throw ex;
3772
- }
3773
-
3774
- if (!event.defaultPrevented && // onClick prevented default
3775
- event.button === 0 && ( // ignore everything but left clicks
3776
- !target || target === "_self") && // let browser handle "target=_blank" etc.
3777
- !isModifiedEvent(event) // ignore clicks with modifier keys
3778
- ) {
3779
- event.preventDefault();
3780
- navigate();
3781
- }
3782
- }
3783
- }); // React 15 compat
3784
-
3785
-
3786
- if (forwardRefShim !== forwardRef) {
3787
- props.ref = forwardedRef || innerRef;
3788
- } else {
3789
- props.ref = innerRef;
3790
- }
3791
- /* eslint-disable-next-line jsx-a11y/anchor-has-content */
3792
-
3793
-
3794
- return React__default.createElement("a", props);
3795
- });
3796
-
3797
- {
3798
- LinkAnchor.displayName = "LinkAnchor";
3799
- }
3800
- /**
3801
- * The public API for rendering a history-aware <a>.
3802
- */
3803
-
3804
-
3805
- var Link = forwardRef(function (_ref2, forwardedRef) {
3806
- var _ref2$component = _ref2.component,
3807
- component = _ref2$component === void 0 ? LinkAnchor : _ref2$component,
3808
- replace = _ref2.replace,
3809
- to = _ref2.to,
3810
- innerRef = _ref2.innerRef,
3811
- rest = _objectWithoutPropertiesLoose(_ref2, ["component", "replace", "to", "innerRef"]);
3812
-
3813
- return React__default.createElement(context.Consumer, null, function (context) {
3814
- !context ? invariant(false, "You should not use <Link> outside a <Router>") : void 0;
3815
- var history = context.history;
3816
- var location = normalizeToLocation(resolveToLocation(to, context.location), context.location);
3817
- var href = location ? history.createHref(location) : "";
3818
-
3819
- var props = _extends({}, rest, {
3820
- href: href,
3821
- navigate: function navigate() {
3822
- var location = resolveToLocation(to, context.location);
3823
- var method = replace ? history.replace : history.push;
3824
- method(location);
3825
- }
3826
- }); // React 15 compat
3827
-
3828
-
3829
- if (forwardRefShim !== forwardRef) {
3830
- props.ref = forwardedRef || innerRef;
3831
- } else {
3832
- props.innerRef = innerRef;
3833
- }
3834
-
3835
- return React__default.createElement(component, props);
3836
- });
3837
- });
3838
-
3839
- {
3840
- var toType = propTypes.oneOfType([propTypes.string, propTypes.object, propTypes.func]);
3841
- var refType = propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.shape({
3842
- current: propTypes.any
3843
- })]);
3844
- Link.displayName = "Link";
3845
- Link.propTypes = {
3846
- innerRef: refType,
3847
- onClick: propTypes.func,
3848
- replace: propTypes.bool,
3849
- target: propTypes.string,
3850
- to: toType.isRequired
3851
- };
3852
- }
3853
-
3854
- var forwardRefShim$1 = function forwardRefShim(C) {
3855
- return C;
3856
- };
3857
-
3858
- var forwardRef$1 = React__default.forwardRef;
3859
-
3860
- if (typeof forwardRef$1 === "undefined") {
3861
- forwardRef$1 = forwardRefShim$1;
3862
- }
3863
-
3864
- function joinClassnames() {
3865
- for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
3866
- classnames[_key] = arguments[_key];
3867
- }
3868
-
3869
- return classnames.filter(function (i) {
3870
- return i;
3871
- }).join(" ");
3872
- }
3873
- /**
3874
- * A <Link> wrapper that knows if it's "active" or not.
3875
- */
3876
-
3877
-
3878
- var NavLink = forwardRef$1(function (_ref, forwardedRef) {
3879
- var _ref$ariaCurrent = _ref["aria-current"],
3880
- ariaCurrent = _ref$ariaCurrent === void 0 ? "page" : _ref$ariaCurrent,
3881
- _ref$activeClassName = _ref.activeClassName,
3882
- activeClassName = _ref$activeClassName === void 0 ? "active" : _ref$activeClassName,
3883
- activeStyle = _ref.activeStyle,
3884
- classNameProp = _ref.className,
3885
- exact = _ref.exact,
3886
- isActiveProp = _ref.isActive,
3887
- locationProp = _ref.location,
3888
- sensitive = _ref.sensitive,
3889
- strict = _ref.strict,
3890
- styleProp = _ref.style,
3891
- to = _ref.to,
3892
- innerRef = _ref.innerRef,
3893
- rest = _objectWithoutPropertiesLoose(_ref, ["aria-current", "activeClassName", "activeStyle", "className", "exact", "isActive", "location", "sensitive", "strict", "style", "to", "innerRef"]);
3894
-
3895
- return React__default.createElement(context.Consumer, null, function (context) {
3896
- !context ? invariant(false, "You should not use <NavLink> outside a <Router>") : void 0;
3897
- var currentLocation = locationProp || context.location;
3898
- var toLocation = normalizeToLocation(resolveToLocation(to, currentLocation), currentLocation);
3899
- var path = toLocation.pathname; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
3900
-
3901
- var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
3902
- var match = escapedPath ? matchPath(currentLocation.pathname, {
3903
- path: escapedPath,
3904
- exact: exact,
3905
- sensitive: sensitive,
3906
- strict: strict
3907
- }) : null;
3908
- var isActive = !!(isActiveProp ? isActiveProp(match, currentLocation) : match);
3909
- var className = isActive ? joinClassnames(classNameProp, activeClassName) : classNameProp;
3910
- var style = isActive ? _extends({}, styleProp, {}, activeStyle) : styleProp;
3911
-
3912
- var props = _extends({
3913
- "aria-current": isActive && ariaCurrent || null,
3914
- className: className,
3915
- style: style,
3916
- to: toLocation
3917
- }, rest); // React 15 compat
3918
-
3919
-
3920
- if (forwardRefShim$1 !== forwardRef$1) {
3921
- props.ref = forwardedRef || innerRef;
3922
- } else {
3923
- props.innerRef = innerRef;
3924
- }
3925
-
3926
- return React__default.createElement(Link, props);
3927
- });
3928
- });
3929
-
3930
- {
3931
- NavLink.displayName = "NavLink";
3932
- var ariaCurrentType = propTypes.oneOf(["page", "step", "location", "date", "time", "true"]);
3933
- NavLink.propTypes = _extends({}, Link.propTypes, {
3934
- "aria-current": ariaCurrentType,
3935
- activeClassName: propTypes.string,
3936
- activeStyle: propTypes.object,
3937
- className: propTypes.string,
3938
- exact: propTypes.bool,
3939
- isActive: propTypes.func,
3940
- location: propTypes.object,
3941
- sensitive: propTypes.bool,
3942
- strict: propTypes.bool,
3943
- style: propTypes.object
3944
- });
3945
- }
3946
-
3947
- exports.BrowserRouter = BrowserRouter;
3948
- exports.HashRouter = HashRouter;
3949
- exports.Link = Link;
3950
- exports.MemoryRouter = MemoryRouter;
3951
- exports.NavLink = NavLink;
3952
- exports.Prompt = Prompt;
3953
- exports.Redirect = Redirect;
3954
- exports.Route = Route;
3955
- exports.Router = Router;
3956
- exports.StaticRouter = StaticRouter;
3957
- exports.Switch = Switch;
3958
- exports.generatePath = generatePath;
3959
- exports.matchPath = matchPath;
3960
- exports.useHistory = useHistory;
3961
- exports.useLocation = useLocation;
3962
- exports.useParams = useParams;
3963
- exports.useRouteMatch = useRouteMatch;
3964
- exports.withRouter = withRouter;
3965
-
3966
- Object.defineProperty(exports, '__esModule', { value: true });
3967
-
3968
- }));
3969
- //# sourceMappingURL=react-router-dom.js.map