1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('redux')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'react', 'redux'], factory) :
|
4 | (factory((global.ReactRedux = {}),global.React,global.Redux));
|
5 | }(this, (function (exports,react,redux) { '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 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | function makeEmptyFunction(arg) {
|
33 | return function () {
|
34 | return arg;
|
35 | };
|
36 | }
|
37 |
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 | var emptyFunction = function emptyFunction() {};
|
44 |
|
45 | emptyFunction.thatReturns = makeEmptyFunction;
|
46 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
47 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
48 | emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
49 | emptyFunction.thatReturnsThis = function () {
|
50 | return this;
|
51 | };
|
52 | emptyFunction.thatReturnsArgument = function (arg) {
|
53 | return arg;
|
54 | };
|
55 |
|
56 | var emptyFunction_1 = emptyFunction;
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | var validateFormat = function validateFormat(format) {};
|
78 |
|
79 | {
|
80 | validateFormat = function validateFormat(format) {
|
81 | if (format === undefined) {
|
82 | throw new Error('invariant requires an error message argument');
|
83 | }
|
84 | };
|
85 | }
|
86 |
|
87 | function invariant(condition, format, a, b, c, d, e, f) {
|
88 | validateFormat(format);
|
89 |
|
90 | if (!condition) {
|
91 | var error;
|
92 | if (format === undefined) {
|
93 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
94 | } else {
|
95 | var args = [a, b, c, d, e, f];
|
96 | var argIndex = 0;
|
97 | error = new Error(format.replace(/%s/g, function () {
|
98 | return args[argIndex++];
|
99 | }));
|
100 | error.name = 'Invariant Violation';
|
101 | }
|
102 |
|
103 | error.framesToPop = 1;
|
104 | throw error;
|
105 | }
|
106 | }
|
107 |
|
108 | var invariant_1 = invariant;
|
109 |
|
110 | |
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | var warning = emptyFunction_1;
|
118 |
|
119 | {
|
120 | var printWarning = function printWarning(format) {
|
121 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
122 | args[_key - 1] = arguments[_key];
|
123 | }
|
124 |
|
125 | var argIndex = 0;
|
126 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
127 | return args[argIndex++];
|
128 | });
|
129 | if (typeof console !== 'undefined') {
|
130 | console.error(message);
|
131 | }
|
132 | try {
|
133 |
|
134 |
|
135 |
|
136 | throw new Error(message);
|
137 | } catch (x) {}
|
138 | };
|
139 |
|
140 | warning = function warning(condition, format) {
|
141 | if (format === undefined) {
|
142 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
143 | }
|
144 |
|
145 | if (format.indexOf('Failed Composite propType: ') === 0) {
|
146 | return;
|
147 | }
|
148 |
|
149 | if (!condition) {
|
150 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
151 | args[_key2 - 2] = arguments[_key2];
|
152 | }
|
153 |
|
154 | printWarning.apply(undefined, [format].concat(args));
|
155 | }
|
156 | };
|
157 | }
|
158 |
|
159 | var warning_1 = warning;
|
160 |
|
161 | |
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
168 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
169 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
170 |
|
171 | function toObject(val) {
|
172 | if (val === null || val === undefined) {
|
173 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
174 | }
|
175 |
|
176 | return Object(val);
|
177 | }
|
178 |
|
179 | function shouldUseNative() {
|
180 | try {
|
181 | if (!Object.assign) {
|
182 | return false;
|
183 | }
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | var test1 = new String('abc');
|
189 | test1[5] = 'de';
|
190 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
191 | return false;
|
192 | }
|
193 |
|
194 |
|
195 | var test2 = {};
|
196 | for (var i = 0; i < 10; i++) {
|
197 | test2['_' + String.fromCharCode(i)] = i;
|
198 | }
|
199 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
200 | return test2[n];
|
201 | });
|
202 | if (order2.join('') !== '0123456789') {
|
203 | return false;
|
204 | }
|
205 |
|
206 |
|
207 | var test3 = {};
|
208 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
209 | test3[letter] = letter;
|
210 | });
|
211 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
212 | 'abcdefghijklmnopqrst') {
|
213 | return false;
|
214 | }
|
215 |
|
216 | return true;
|
217 | } catch (err) {
|
218 |
|
219 | return false;
|
220 | }
|
221 | }
|
222 |
|
223 | var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
224 | var from;
|
225 | var to = toObject(target);
|
226 | var symbols;
|
227 |
|
228 | for (var s = 1; s < arguments.length; s++) {
|
229 | from = Object(arguments[s]);
|
230 |
|
231 | for (var key in from) {
|
232 | if (hasOwnProperty.call(from, key)) {
|
233 | to[key] = from[key];
|
234 | }
|
235 | }
|
236 |
|
237 | if (getOwnPropertySymbols) {
|
238 | symbols = getOwnPropertySymbols(from);
|
239 | for (var i = 0; i < symbols.length; i++) {
|
240 | if (propIsEnumerable.call(from, symbols[i])) {
|
241 | to[symbols[i]] = from[symbols[i]];
|
242 | }
|
243 | }
|
244 | }
|
245 | }
|
246 |
|
247 | return to;
|
248 | };
|
249 |
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
258 |
|
259 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
260 |
|
261 | {
|
262 | var invariant$1 = invariant_1;
|
263 | var warning$1 = warning_1;
|
264 | var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
265 | var loggedTypeFailures = {};
|
266 | }
|
267 |
|
268 | |
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
280 | {
|
281 | for (var typeSpecName in typeSpecs) {
|
282 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
283 | var error;
|
284 |
|
285 |
|
286 |
|
287 | try {
|
288 |
|
289 |
|
290 | invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
291 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
292 | } catch (ex) {
|
293 | error = ex;
|
294 | }
|
295 | warning$1(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
296 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
297 |
|
298 |
|
299 | loggedTypeFailures[error.message] = true;
|
300 |
|
301 | var stack = getStack ? getStack() : '';
|
302 |
|
303 | warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
304 | }
|
305 | }
|
306 | }
|
307 | }
|
308 | }
|
309 |
|
310 | var checkPropTypes_1 = checkPropTypes;
|
311 |
|
312 | var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
313 |
|
314 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
315 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
316 |
|
317 | |
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 | function getIteratorFn(maybeIterable) {
|
332 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
333 | if (typeof iteratorFn === 'function') {
|
334 | return iteratorFn;
|
335 | }
|
336 | }
|
337 |
|
338 | |
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 | var ANONYMOUS = '<<anonymous>>';
|
386 |
|
387 |
|
388 |
|
389 | var ReactPropTypes = {
|
390 | array: createPrimitiveTypeChecker('array'),
|
391 | bool: createPrimitiveTypeChecker('boolean'),
|
392 | func: createPrimitiveTypeChecker('function'),
|
393 | number: createPrimitiveTypeChecker('number'),
|
394 | object: createPrimitiveTypeChecker('object'),
|
395 | string: createPrimitiveTypeChecker('string'),
|
396 | symbol: createPrimitiveTypeChecker('symbol'),
|
397 |
|
398 | any: createAnyTypeChecker(),
|
399 | arrayOf: createArrayOfTypeChecker,
|
400 | element: createElementTypeChecker(),
|
401 | instanceOf: createInstanceTypeChecker,
|
402 | node: createNodeChecker(),
|
403 | objectOf: createObjectOfTypeChecker,
|
404 | oneOf: createEnumTypeChecker,
|
405 | oneOfType: createUnionTypeChecker,
|
406 | shape: createShapeTypeChecker,
|
407 | exact: createStrictShapeTypeChecker,
|
408 | };
|
409 |
|
410 | |
411 |
|
412 |
|
413 |
|
414 |
|
415 | function is(x, y) {
|
416 |
|
417 | if (x === y) {
|
418 |
|
419 |
|
420 | return x !== 0 || 1 / x === 1 / y;
|
421 | } else {
|
422 |
|
423 | return x !== x && y !== y;
|
424 | }
|
425 | }
|
426 |
|
427 |
|
428 | |
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 | function PropTypeError(message) {
|
436 | this.message = message;
|
437 | this.stack = '';
|
438 | }
|
439 |
|
440 | PropTypeError.prototype = Error.prototype;
|
441 |
|
442 | function createChainableTypeChecker(validate) {
|
443 | {
|
444 | var manualPropTypeCallCache = {};
|
445 | var manualPropTypeWarningCount = 0;
|
446 | }
|
447 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
448 | componentName = componentName || ANONYMOUS;
|
449 | propFullName = propFullName || propName;
|
450 |
|
451 | if (secret !== ReactPropTypesSecret_1) {
|
452 | if (throwOnDirectAccess) {
|
453 |
|
454 | invariant_1(
|
455 | false,
|
456 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
457 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
458 | 'Read more at http://fb.me/use-check-prop-types'
|
459 | );
|
460 | } else if (typeof console !== 'undefined') {
|
461 |
|
462 | var cacheKey = componentName + ':' + propName;
|
463 | if (
|
464 | !manualPropTypeCallCache[cacheKey] &&
|
465 |
|
466 | manualPropTypeWarningCount < 3
|
467 | ) {
|
468 | warning_1(
|
469 | false,
|
470 | 'You are manually calling a React.PropTypes validation ' +
|
471 | 'function for the `%s` prop on `%s`. This is deprecated ' +
|
472 | 'and will throw in the standalone `prop-types` package. ' +
|
473 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
474 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
|
475 | propFullName,
|
476 | componentName
|
477 | );
|
478 | manualPropTypeCallCache[cacheKey] = true;
|
479 | manualPropTypeWarningCount++;
|
480 | }
|
481 | }
|
482 | }
|
483 | if (props[propName] == null) {
|
484 | if (isRequired) {
|
485 | if (props[propName] === null) {
|
486 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
487 | }
|
488 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
489 | }
|
490 | return null;
|
491 | } else {
|
492 | return validate(props, propName, componentName, location, propFullName);
|
493 | }
|
494 | }
|
495 |
|
496 | var chainedCheckType = checkType.bind(null, false);
|
497 | chainedCheckType.isRequired = checkType.bind(null, true);
|
498 |
|
499 | return chainedCheckType;
|
500 | }
|
501 |
|
502 | function createPrimitiveTypeChecker(expectedType) {
|
503 | function validate(props, propName, componentName, location, propFullName, secret) {
|
504 | var propValue = props[propName];
|
505 | var propType = getPropType(propValue);
|
506 | if (propType !== expectedType) {
|
507 |
|
508 |
|
509 |
|
510 | var preciseType = getPreciseType(propValue);
|
511 |
|
512 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
513 | }
|
514 | return null;
|
515 | }
|
516 | return createChainableTypeChecker(validate);
|
517 | }
|
518 |
|
519 | function createAnyTypeChecker() {
|
520 | return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
|
521 | }
|
522 |
|
523 | function createArrayOfTypeChecker(typeChecker) {
|
524 | function validate(props, propName, componentName, location, propFullName) {
|
525 | if (typeof typeChecker !== 'function') {
|
526 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
527 | }
|
528 | var propValue = props[propName];
|
529 | if (!Array.isArray(propValue)) {
|
530 | var propType = getPropType(propValue);
|
531 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
532 | }
|
533 | for (var i = 0; i < propValue.length; i++) {
|
534 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
535 | if (error instanceof Error) {
|
536 | return error;
|
537 | }
|
538 | }
|
539 | return null;
|
540 | }
|
541 | return createChainableTypeChecker(validate);
|
542 | }
|
543 |
|
544 | function createElementTypeChecker() {
|
545 | function validate(props, propName, componentName, location, propFullName) {
|
546 | var propValue = props[propName];
|
547 | if (!isValidElement(propValue)) {
|
548 | var propType = getPropType(propValue);
|
549 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
550 | }
|
551 | return null;
|
552 | }
|
553 | return createChainableTypeChecker(validate);
|
554 | }
|
555 |
|
556 | function createInstanceTypeChecker(expectedClass) {
|
557 | function validate(props, propName, componentName, location, propFullName) {
|
558 | if (!(props[propName] instanceof expectedClass)) {
|
559 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
560 | var actualClassName = getClassName(props[propName]);
|
561 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
562 | }
|
563 | return null;
|
564 | }
|
565 | return createChainableTypeChecker(validate);
|
566 | }
|
567 |
|
568 | function createEnumTypeChecker(expectedValues) {
|
569 | if (!Array.isArray(expectedValues)) {
|
570 | warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
|
571 | return emptyFunction_1.thatReturnsNull;
|
572 | }
|
573 |
|
574 | function validate(props, propName, componentName, location, propFullName) {
|
575 | var propValue = props[propName];
|
576 | for (var i = 0; i < expectedValues.length; i++) {
|
577 | if (is(propValue, expectedValues[i])) {
|
578 | return null;
|
579 | }
|
580 | }
|
581 |
|
582 | var valuesString = JSON.stringify(expectedValues);
|
583 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
584 | }
|
585 | return createChainableTypeChecker(validate);
|
586 | }
|
587 |
|
588 | function createObjectOfTypeChecker(typeChecker) {
|
589 | function validate(props, propName, componentName, location, propFullName) {
|
590 | if (typeof typeChecker !== 'function') {
|
591 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
592 | }
|
593 | var propValue = props[propName];
|
594 | var propType = getPropType(propValue);
|
595 | if (propType !== 'object') {
|
596 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
597 | }
|
598 | for (var key in propValue) {
|
599 | if (propValue.hasOwnProperty(key)) {
|
600 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
601 | if (error instanceof Error) {
|
602 | return error;
|
603 | }
|
604 | }
|
605 | }
|
606 | return null;
|
607 | }
|
608 | return createChainableTypeChecker(validate);
|
609 | }
|
610 |
|
611 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
612 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
613 | warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
|
614 | return emptyFunction_1.thatReturnsNull;
|
615 | }
|
616 |
|
617 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
618 | var checker = arrayOfTypeCheckers[i];
|
619 | if (typeof checker !== 'function') {
|
620 | warning_1(
|
621 | false,
|
622 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
623 | 'received %s at index %s.',
|
624 | getPostfixForTypeWarning(checker),
|
625 | i
|
626 | );
|
627 | return emptyFunction_1.thatReturnsNull;
|
628 | }
|
629 | }
|
630 |
|
631 | function validate(props, propName, componentName, location, propFullName) {
|
632 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
633 | var checker = arrayOfTypeCheckers[i];
|
634 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
635 | return null;
|
636 | }
|
637 | }
|
638 |
|
639 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
640 | }
|
641 | return createChainableTypeChecker(validate);
|
642 | }
|
643 |
|
644 | function createNodeChecker() {
|
645 | function validate(props, propName, componentName, location, propFullName) {
|
646 | if (!isNode(props[propName])) {
|
647 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
648 | }
|
649 | return null;
|
650 | }
|
651 | return createChainableTypeChecker(validate);
|
652 | }
|
653 |
|
654 | function createShapeTypeChecker(shapeTypes) {
|
655 | function validate(props, propName, componentName, location, propFullName) {
|
656 | var propValue = props[propName];
|
657 | var propType = getPropType(propValue);
|
658 | if (propType !== 'object') {
|
659 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
660 | }
|
661 | for (var key in shapeTypes) {
|
662 | var checker = shapeTypes[key];
|
663 | if (!checker) {
|
664 | continue;
|
665 | }
|
666 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
667 | if (error) {
|
668 | return error;
|
669 | }
|
670 | }
|
671 | return null;
|
672 | }
|
673 | return createChainableTypeChecker(validate);
|
674 | }
|
675 |
|
676 | function createStrictShapeTypeChecker(shapeTypes) {
|
677 | function validate(props, propName, componentName, location, propFullName) {
|
678 | var propValue = props[propName];
|
679 | var propType = getPropType(propValue);
|
680 | if (propType !== 'object') {
|
681 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
682 | }
|
683 |
|
684 |
|
685 | var allKeys = objectAssign({}, props[propName], shapeTypes);
|
686 | for (var key in allKeys) {
|
687 | var checker = shapeTypes[key];
|
688 | if (!checker) {
|
689 | return new PropTypeError(
|
690 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
691 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
692 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
693 | );
|
694 | }
|
695 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
696 | if (error) {
|
697 | return error;
|
698 | }
|
699 | }
|
700 | return null;
|
701 | }
|
702 |
|
703 | return createChainableTypeChecker(validate);
|
704 | }
|
705 |
|
706 | function isNode(propValue) {
|
707 | switch (typeof propValue) {
|
708 | case 'number':
|
709 | case 'string':
|
710 | case 'undefined':
|
711 | return true;
|
712 | case 'boolean':
|
713 | return !propValue;
|
714 | case 'object':
|
715 | if (Array.isArray(propValue)) {
|
716 | return propValue.every(isNode);
|
717 | }
|
718 | if (propValue === null || isValidElement(propValue)) {
|
719 | return true;
|
720 | }
|
721 |
|
722 | var iteratorFn = getIteratorFn(propValue);
|
723 | if (iteratorFn) {
|
724 | var iterator = iteratorFn.call(propValue);
|
725 | var step;
|
726 | if (iteratorFn !== propValue.entries) {
|
727 | while (!(step = iterator.next()).done) {
|
728 | if (!isNode(step.value)) {
|
729 | return false;
|
730 | }
|
731 | }
|
732 | } else {
|
733 |
|
734 | while (!(step = iterator.next()).done) {
|
735 | var entry = step.value;
|
736 | if (entry) {
|
737 | if (!isNode(entry[1])) {
|
738 | return false;
|
739 | }
|
740 | }
|
741 | }
|
742 | }
|
743 | } else {
|
744 | return false;
|
745 | }
|
746 |
|
747 | return true;
|
748 | default:
|
749 | return false;
|
750 | }
|
751 | }
|
752 |
|
753 | function isSymbol(propType, propValue) {
|
754 |
|
755 | if (propType === 'symbol') {
|
756 | return true;
|
757 | }
|
758 |
|
759 |
|
760 | if (propValue['@@toStringTag'] === 'Symbol') {
|
761 | return true;
|
762 | }
|
763 |
|
764 |
|
765 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
766 | return true;
|
767 | }
|
768 |
|
769 | return false;
|
770 | }
|
771 |
|
772 |
|
773 | function getPropType(propValue) {
|
774 | var propType = typeof propValue;
|
775 | if (Array.isArray(propValue)) {
|
776 | return 'array';
|
777 | }
|
778 | if (propValue instanceof RegExp) {
|
779 |
|
780 |
|
781 |
|
782 | return 'object';
|
783 | }
|
784 | if (isSymbol(propType, propValue)) {
|
785 | return 'symbol';
|
786 | }
|
787 | return propType;
|
788 | }
|
789 |
|
790 |
|
791 |
|
792 | function getPreciseType(propValue) {
|
793 | if (typeof propValue === 'undefined' || propValue === null) {
|
794 | return '' + propValue;
|
795 | }
|
796 | var propType = getPropType(propValue);
|
797 | if (propType === 'object') {
|
798 | if (propValue instanceof Date) {
|
799 | return 'date';
|
800 | } else if (propValue instanceof RegExp) {
|
801 | return 'regexp';
|
802 | }
|
803 | }
|
804 | return propType;
|
805 | }
|
806 |
|
807 |
|
808 |
|
809 | function getPostfixForTypeWarning(value) {
|
810 | var type = getPreciseType(value);
|
811 | switch (type) {
|
812 | case 'array':
|
813 | case 'object':
|
814 | return 'an ' + type;
|
815 | case 'boolean':
|
816 | case 'date':
|
817 | case 'regexp':
|
818 | return 'a ' + type;
|
819 | default:
|
820 | return type;
|
821 | }
|
822 | }
|
823 |
|
824 |
|
825 | function getClassName(propValue) {
|
826 | if (!propValue.constructor || !propValue.constructor.name) {
|
827 | return ANONYMOUS;
|
828 | }
|
829 | return propValue.constructor.name;
|
830 | }
|
831 |
|
832 | ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
833 | ReactPropTypes.PropTypes = ReactPropTypes;
|
834 |
|
835 | return ReactPropTypes;
|
836 | };
|
837 |
|
838 | var propTypes = createCommonjsModule(function (module) {
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 | {
|
847 | var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
|
848 | Symbol.for &&
|
849 | Symbol.for('react.element')) ||
|
850 | 0xeac7;
|
851 |
|
852 | var isValidElement = function(object) {
|
853 | return typeof object === 'object' &&
|
854 | object !== null &&
|
855 | object.$$typeof === REACT_ELEMENT_TYPE;
|
856 | };
|
857 |
|
858 |
|
859 |
|
860 | var throwOnDirectAccess = true;
|
861 | module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
862 | }
|
863 | });
|
864 |
|
865 | var subscriptionShape = propTypes.shape({
|
866 | trySubscribe: propTypes.func.isRequired,
|
867 | tryUnsubscribe: propTypes.func.isRequired,
|
868 | notifyNestedSubs: propTypes.func.isRequired,
|
869 | isSubscribed: propTypes.func.isRequired
|
870 | });
|
871 | var storeShape = propTypes.shape({
|
872 | subscribe: propTypes.func.isRequired,
|
873 | dispatch: propTypes.func.isRequired,
|
874 | getState: propTypes.func.isRequired
|
875 | });
|
876 |
|
877 | |
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 | function warning$2(message) {
|
884 |
|
885 | if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
886 | console.error(message);
|
887 | }
|
888 |
|
889 |
|
890 |
|
891 | try {
|
892 |
|
893 |
|
894 |
|
895 | throw new Error(message);
|
896 |
|
897 | } catch (e) {}
|
898 |
|
899 |
|
900 | }
|
901 |
|
902 | var didWarnAboutReceivingStore = false;
|
903 |
|
904 | function warnAboutReceivingStore() {
|
905 | if (didWarnAboutReceivingStore) {
|
906 | return;
|
907 | }
|
908 |
|
909 | didWarnAboutReceivingStore = true;
|
910 | warning$2('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reduxjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.');
|
911 | }
|
912 |
|
913 | function createProvider(storeKey) {
|
914 | var _Provider$childContex;
|
915 |
|
916 | if (storeKey === void 0) {
|
917 | storeKey = 'store';
|
918 | }
|
919 |
|
920 | var subscriptionKey = storeKey + "Subscription";
|
921 |
|
922 | var Provider =
|
923 |
|
924 | function (_Component) {
|
925 | _inheritsLoose(Provider, _Component);
|
926 |
|
927 | var _proto = Provider.prototype;
|
928 |
|
929 | _proto.getChildContext = function getChildContext() {
|
930 | var _ref;
|
931 |
|
932 | return _ref = {}, _ref[storeKey] = this[storeKey], _ref[subscriptionKey] = null, _ref;
|
933 | };
|
934 |
|
935 | function Provider(props, context) {
|
936 | var _this;
|
937 |
|
938 | _this = _Component.call(this, props, context) || this;
|
939 | _this[storeKey] = props.store;
|
940 | return _this;
|
941 | }
|
942 |
|
943 | _proto.render = function render() {
|
944 | return react.Children.only(this.props.children);
|
945 | };
|
946 |
|
947 | return Provider;
|
948 | }(react.Component);
|
949 |
|
950 | {
|
951 | Provider.prototype.componentWillReceiveProps = function (nextProps) {
|
952 | if (this[storeKey] !== nextProps.store) {
|
953 | warnAboutReceivingStore();
|
954 | }
|
955 | };
|
956 | }
|
957 |
|
958 | Provider.propTypes = {
|
959 | store: storeShape.isRequired,
|
960 | children: propTypes.element.isRequired
|
961 | };
|
962 | Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[storeKey] = storeShape.isRequired, _Provider$childContex[subscriptionKey] = subscriptionShape, _Provider$childContex);
|
963 | return Provider;
|
964 | }
|
965 | var Provider = createProvider();
|
966 |
|
967 | function _assertThisInitialized(self) {
|
968 | if (self === void 0) {
|
969 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
970 | }
|
971 |
|
972 | return self;
|
973 | }
|
974 |
|
975 | function _extends() {
|
976 | _extends = Object.assign || function (target) {
|
977 | for (var i = 1; i < arguments.length; i++) {
|
978 | var source = arguments[i];
|
979 |
|
980 | for (var key in source) {
|
981 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
982 | target[key] = source[key];
|
983 | }
|
984 | }
|
985 | }
|
986 |
|
987 | return target;
|
988 | };
|
989 |
|
990 | return _extends.apply(this, arguments);
|
991 | }
|
992 |
|
993 | function _objectWithoutPropertiesLoose(source, excluded) {
|
994 | if (source == null) return {};
|
995 | var target = {};
|
996 | var sourceKeys = Object.keys(source);
|
997 | var key, i;
|
998 |
|
999 | for (i = 0; i < sourceKeys.length; i++) {
|
1000 | key = sourceKeys[i];
|
1001 | if (excluded.indexOf(key) >= 0) continue;
|
1002 | target[key] = source[key];
|
1003 | }
|
1004 |
|
1005 | return target;
|
1006 | }
|
1007 |
|
1008 | var reactIs_development = createCommonjsModule(function (module, exports) {
|
1009 |
|
1010 |
|
1011 |
|
1012 | {
|
1013 | (function() {
|
1014 |
|
1015 | Object.defineProperty(exports, '__esModule', { value: true });
|
1016 |
|
1017 |
|
1018 |
|
1019 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
1020 |
|
1021 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
1022 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
1023 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
1024 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
1025 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
1026 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
1027 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
1028 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
1029 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
1030 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
1031 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
1032 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
1033 |
|
1034 | function isValidElementType(type) {
|
1035 | return typeof type === 'string' || typeof type === 'function' ||
|
1036 |
|
1037 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
1038 | }
|
1039 |
|
1040 | |
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 | var lowPriorityWarning = function () {};
|
1055 |
|
1056 | {
|
1057 | var printWarning = function (format) {
|
1058 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1059 | args[_key - 1] = arguments[_key];
|
1060 | }
|
1061 |
|
1062 | var argIndex = 0;
|
1063 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
1064 | return args[argIndex++];
|
1065 | });
|
1066 | if (typeof console !== 'undefined') {
|
1067 | console.warn(message);
|
1068 | }
|
1069 | try {
|
1070 |
|
1071 |
|
1072 |
|
1073 | throw new Error(message);
|
1074 | } catch (x) {}
|
1075 | };
|
1076 |
|
1077 | lowPriorityWarning = function (condition, format) {
|
1078 | if (format === undefined) {
|
1079 | throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
1080 | }
|
1081 | if (!condition) {
|
1082 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
1083 | args[_key2 - 2] = arguments[_key2];
|
1084 | }
|
1085 |
|
1086 | printWarning.apply(undefined, [format].concat(args));
|
1087 | }
|
1088 | };
|
1089 | }
|
1090 |
|
1091 | var lowPriorityWarning$1 = lowPriorityWarning;
|
1092 |
|
1093 | function typeOf(object) {
|
1094 | if (typeof object === 'object' && object !== null) {
|
1095 | var $$typeof = object.$$typeof;
|
1096 |
|
1097 | switch ($$typeof) {
|
1098 | case REACT_ELEMENT_TYPE:
|
1099 | var type = object.type;
|
1100 |
|
1101 | switch (type) {
|
1102 | case REACT_CONCURRENT_MODE_TYPE:
|
1103 | case REACT_FRAGMENT_TYPE:
|
1104 | case REACT_PROFILER_TYPE:
|
1105 | case REACT_STRICT_MODE_TYPE:
|
1106 | return type;
|
1107 | default:
|
1108 | var $$typeofType = type && type.$$typeof;
|
1109 |
|
1110 | switch ($$typeofType) {
|
1111 | case REACT_CONTEXT_TYPE:
|
1112 | case REACT_FORWARD_REF_TYPE:
|
1113 | case REACT_PROVIDER_TYPE:
|
1114 | return $$typeofType;
|
1115 | default:
|
1116 | return $$typeof;
|
1117 | }
|
1118 | }
|
1119 | case REACT_PORTAL_TYPE:
|
1120 | return $$typeof;
|
1121 | }
|
1122 | }
|
1123 |
|
1124 | return undefined;
|
1125 | }
|
1126 |
|
1127 |
|
1128 | var AsyncMode = REACT_CONCURRENT_MODE_TYPE;
|
1129 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
1130 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
1131 | var ContextProvider = REACT_PROVIDER_TYPE;
|
1132 | var Element = REACT_ELEMENT_TYPE;
|
1133 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
1134 | var Fragment = REACT_FRAGMENT_TYPE;
|
1135 | var Profiler = REACT_PROFILER_TYPE;
|
1136 | var Portal = REACT_PORTAL_TYPE;
|
1137 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
1138 |
|
1139 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
1140 |
|
1141 |
|
1142 | function isAsyncMode(object) {
|
1143 | {
|
1144 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
1145 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
1146 | 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.');
|
1147 | }
|
1148 | }
|
1149 | return isConcurrentMode(object);
|
1150 | }
|
1151 | function isConcurrentMode(object) {
|
1152 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
1153 | }
|
1154 | function isContextConsumer(object) {
|
1155 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
1156 | }
|
1157 | function isContextProvider(object) {
|
1158 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
1159 | }
|
1160 | function isElement(object) {
|
1161 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
1162 | }
|
1163 | function isForwardRef(object) {
|
1164 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
1165 | }
|
1166 | function isFragment(object) {
|
1167 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
1168 | }
|
1169 | function isProfiler(object) {
|
1170 | return typeOf(object) === REACT_PROFILER_TYPE;
|
1171 | }
|
1172 | function isPortal(object) {
|
1173 | return typeOf(object) === REACT_PORTAL_TYPE;
|
1174 | }
|
1175 | function isStrictMode(object) {
|
1176 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
1177 | }
|
1178 |
|
1179 | exports.typeOf = typeOf;
|
1180 | exports.AsyncMode = AsyncMode;
|
1181 | exports.ConcurrentMode = ConcurrentMode;
|
1182 | exports.ContextConsumer = ContextConsumer;
|
1183 | exports.ContextProvider = ContextProvider;
|
1184 | exports.Element = Element;
|
1185 | exports.ForwardRef = ForwardRef;
|
1186 | exports.Fragment = Fragment;
|
1187 | exports.Profiler = Profiler;
|
1188 | exports.Portal = Portal;
|
1189 | exports.StrictMode = StrictMode;
|
1190 | exports.isValidElementType = isValidElementType;
|
1191 | exports.isAsyncMode = isAsyncMode;
|
1192 | exports.isConcurrentMode = isConcurrentMode;
|
1193 | exports.isContextConsumer = isContextConsumer;
|
1194 | exports.isContextProvider = isContextProvider;
|
1195 | exports.isElement = isElement;
|
1196 | exports.isForwardRef = isForwardRef;
|
1197 | exports.isFragment = isFragment;
|
1198 | exports.isProfiler = isProfiler;
|
1199 | exports.isPortal = isPortal;
|
1200 | exports.isStrictMode = isStrictMode;
|
1201 | })();
|
1202 | }
|
1203 | });
|
1204 |
|
1205 | unwrapExports(reactIs_development);
|
1206 | var reactIs_development_1 = reactIs_development.typeOf;
|
1207 | var reactIs_development_2 = reactIs_development.AsyncMode;
|
1208 | var reactIs_development_3 = reactIs_development.ConcurrentMode;
|
1209 | var reactIs_development_4 = reactIs_development.ContextConsumer;
|
1210 | var reactIs_development_5 = reactIs_development.ContextProvider;
|
1211 | var reactIs_development_6 = reactIs_development.Element;
|
1212 | var reactIs_development_7 = reactIs_development.ForwardRef;
|
1213 | var reactIs_development_8 = reactIs_development.Fragment;
|
1214 | var reactIs_development_9 = reactIs_development.Profiler;
|
1215 | var reactIs_development_10 = reactIs_development.Portal;
|
1216 | var reactIs_development_11 = reactIs_development.StrictMode;
|
1217 | var reactIs_development_12 = reactIs_development.isValidElementType;
|
1218 | var reactIs_development_13 = reactIs_development.isAsyncMode;
|
1219 | var reactIs_development_14 = reactIs_development.isConcurrentMode;
|
1220 | var reactIs_development_15 = reactIs_development.isContextConsumer;
|
1221 | var reactIs_development_16 = reactIs_development.isContextProvider;
|
1222 | var reactIs_development_17 = reactIs_development.isElement;
|
1223 | var reactIs_development_18 = reactIs_development.isForwardRef;
|
1224 | var reactIs_development_19 = reactIs_development.isFragment;
|
1225 | var reactIs_development_20 = reactIs_development.isProfiler;
|
1226 | var reactIs_development_21 = reactIs_development.isPortal;
|
1227 | var reactIs_development_22 = reactIs_development.isStrictMode;
|
1228 |
|
1229 | var reactIs = createCommonjsModule(function (module) {
|
1230 |
|
1231 | {
|
1232 | module.exports = reactIs_development;
|
1233 | }
|
1234 | });
|
1235 | var reactIs_1 = reactIs.isValidElementType;
|
1236 |
|
1237 | var _ReactIs$ForwardRef;
|
1238 |
|
1239 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
1240 |
|
1241 | |
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 | var REACT_STATICS = {
|
1248 | childContextTypes: true,
|
1249 | contextTypes: true,
|
1250 | defaultProps: true,
|
1251 | displayName: true,
|
1252 | getDefaultProps: true,
|
1253 | getDerivedStateFromProps: true,
|
1254 | mixins: true,
|
1255 | propTypes: true,
|
1256 | type: true
|
1257 | };
|
1258 |
|
1259 | var KNOWN_STATICS = {
|
1260 | name: true,
|
1261 | length: true,
|
1262 | prototype: true,
|
1263 | caller: true,
|
1264 | callee: true,
|
1265 | arguments: true,
|
1266 | arity: true
|
1267 | };
|
1268 |
|
1269 | var TYPE_STATICS = _defineProperty({}, reactIs.ForwardRef, (_ReactIs$ForwardRef = {}, _defineProperty(_ReactIs$ForwardRef, '$$typeof', true), _defineProperty(_ReactIs$ForwardRef, 'render', true), _ReactIs$ForwardRef));
|
1270 |
|
1271 | var defineProperty = Object.defineProperty;
|
1272 | var getOwnPropertyNames = Object.getOwnPropertyNames;
|
1273 | var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
|
1274 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
1275 | var getPrototypeOf = Object.getPrototypeOf;
|
1276 | var objectPrototype = Object.prototype;
|
1277 |
|
1278 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
1279 | if (typeof sourceComponent !== 'string') {
|
1280 |
|
1281 |
|
1282 | if (objectPrototype) {
|
1283 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
1284 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
1285 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
1286 | }
|
1287 | }
|
1288 |
|
1289 | var keys = getOwnPropertyNames(sourceComponent);
|
1290 |
|
1291 | if (getOwnPropertySymbols$1) {
|
1292 | keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
|
1293 | }
|
1294 |
|
1295 | var targetStatics = TYPE_STATICS[targetComponent['$$typeof']] || REACT_STATICS;
|
1296 | var sourceStatics = TYPE_STATICS[sourceComponent['$$typeof']] || REACT_STATICS;
|
1297 |
|
1298 | for (var i = 0; i < keys.length; ++i) {
|
1299 | var key = keys[i];
|
1300 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
1301 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
1302 | try {
|
1303 |
|
1304 | defineProperty(targetComponent, key, descriptor);
|
1305 | } catch (e) {}
|
1306 | }
|
1307 | }
|
1308 |
|
1309 | return targetComponent;
|
1310 | }
|
1311 |
|
1312 | return targetComponent;
|
1313 | }
|
1314 |
|
1315 | var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
1316 |
|
1317 | |
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 | var invariant$2 = function(condition, format, a, b, c, d, e, f) {
|
1325 | {
|
1326 | if (format === undefined) {
|
1327 | throw new Error('invariant requires an error message argument');
|
1328 | }
|
1329 | }
|
1330 |
|
1331 | if (!condition) {
|
1332 | var error;
|
1333 | if (format === undefined) {
|
1334 | error = new Error(
|
1335 | 'Minified exception occurred; use the non-minified dev environment ' +
|
1336 | 'for the full error message and additional helpful warnings.'
|
1337 | );
|
1338 | } else {
|
1339 | var args = [a, b, c, d, e, f];
|
1340 | var argIndex = 0;
|
1341 | error = new Error(
|
1342 | format.replace(/%s/g, function() { return args[argIndex++]; })
|
1343 | );
|
1344 | error.name = 'Invariant Violation';
|
1345 | }
|
1346 |
|
1347 | error.framesToPop = 1;
|
1348 | throw error;
|
1349 | }
|
1350 | };
|
1351 |
|
1352 | var invariant_1$1 = invariant$2;
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 | var CLEARED = null;
|
1358 | var nullListeners = {
|
1359 | notify: function notify() {}
|
1360 | };
|
1361 |
|
1362 | function createListenerCollection() {
|
1363 |
|
1364 |
|
1365 | var current = [];
|
1366 | var next = [];
|
1367 | return {
|
1368 | clear: function clear() {
|
1369 | next = CLEARED;
|
1370 | current = CLEARED;
|
1371 | },
|
1372 | notify: function notify() {
|
1373 | var listeners = current = next;
|
1374 |
|
1375 | for (var i = 0; i < listeners.length; i++) {
|
1376 | listeners[i]();
|
1377 | }
|
1378 | },
|
1379 | get: function get() {
|
1380 | return next;
|
1381 | },
|
1382 | subscribe: function subscribe(listener) {
|
1383 | var isSubscribed = true;
|
1384 | if (next === current) next = current.slice();
|
1385 | next.push(listener);
|
1386 | return function unsubscribe() {
|
1387 | if (!isSubscribed || current === CLEARED) return;
|
1388 | isSubscribed = false;
|
1389 | if (next === current) next = current.slice();
|
1390 | next.splice(next.indexOf(listener), 1);
|
1391 | };
|
1392 | }
|
1393 | };
|
1394 | }
|
1395 |
|
1396 | var Subscription =
|
1397 |
|
1398 | function () {
|
1399 | function Subscription(store, parentSub, onStateChange) {
|
1400 | this.store = store;
|
1401 | this.parentSub = parentSub;
|
1402 | this.onStateChange = onStateChange;
|
1403 | this.unsubscribe = null;
|
1404 | this.listeners = nullListeners;
|
1405 | }
|
1406 |
|
1407 | var _proto = Subscription.prototype;
|
1408 |
|
1409 | _proto.addNestedSub = function addNestedSub(listener) {
|
1410 | this.trySubscribe();
|
1411 | return this.listeners.subscribe(listener);
|
1412 | };
|
1413 |
|
1414 | _proto.notifyNestedSubs = function notifyNestedSubs() {
|
1415 | this.listeners.notify();
|
1416 | };
|
1417 |
|
1418 | _proto.isSubscribed = function isSubscribed() {
|
1419 | return Boolean(this.unsubscribe);
|
1420 | };
|
1421 |
|
1422 | _proto.trySubscribe = function trySubscribe() {
|
1423 | if (!this.unsubscribe) {
|
1424 | this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.onStateChange) : this.store.subscribe(this.onStateChange);
|
1425 | this.listeners = createListenerCollection();
|
1426 | }
|
1427 | };
|
1428 |
|
1429 | _proto.tryUnsubscribe = function tryUnsubscribe() {
|
1430 | if (this.unsubscribe) {
|
1431 | this.unsubscribe();
|
1432 | this.unsubscribe = null;
|
1433 | this.listeners.clear();
|
1434 | this.listeners = nullListeners;
|
1435 | }
|
1436 | };
|
1437 |
|
1438 | return Subscription;
|
1439 | }();
|
1440 |
|
1441 | var hotReloadingVersion = 0;
|
1442 | var dummyState = {};
|
1443 |
|
1444 | function noop() {}
|
1445 |
|
1446 | function makeSelectorStateful(sourceSelector, store) {
|
1447 |
|
1448 | var selector = {
|
1449 | run: function runComponentSelector(props) {
|
1450 | try {
|
1451 | var nextProps = sourceSelector(store.getState(), props);
|
1452 |
|
1453 | if (nextProps !== selector.props || selector.error) {
|
1454 | selector.shouldComponentUpdate = true;
|
1455 | selector.props = nextProps;
|
1456 | selector.error = null;
|
1457 | }
|
1458 | } catch (error) {
|
1459 | selector.shouldComponentUpdate = true;
|
1460 | selector.error = error;
|
1461 | }
|
1462 | }
|
1463 | };
|
1464 | return selector;
|
1465 | }
|
1466 |
|
1467 | function connectAdvanced(
|
1468 | /*
|
1469 | selectorFactory is a func that is responsible for returning the selector function used to
|
1470 | compute new props from state, props, and dispatch. For example:
|
1471 | export default connectAdvanced((dispatch, options) => (state, props) => ({
|
1472 | thing: state.things[props.thingId],
|
1473 | saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
|
1474 | }))(YourComponent)
|
1475 | Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
|
1476 | outside of their selector as an optimization. Options passed to connectAdvanced are passed to
|
1477 | the selectorFactory, along with displayName and WrappedComponent, as the second argument.
|
1478 | Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
|
1479 | props. Do not use connectAdvanced directly without memoizing results between calls to your
|
1480 | selector, otherwise the Connect component will re-render on every state or props change.
|
1481 | */
|
1482 | selectorFactory, // options object:
|
1483 | _ref) {
|
1484 | var _contextTypes, _childContextTypes;
|
1485 |
|
1486 | if (_ref === void 0) {
|
1487 | _ref = {};
|
1488 | }
|
1489 |
|
1490 | var _ref2 = _ref,
|
1491 | _ref2$getDisplayName = _ref2.getDisplayName,
|
1492 | getDisplayName = _ref2$getDisplayName === void 0 ? function (name) {
|
1493 | return "ConnectAdvanced(" + name + ")";
|
1494 | } : _ref2$getDisplayName,
|
1495 | _ref2$methodName = _ref2.methodName,
|
1496 | methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName,
|
1497 | _ref2$renderCountProp = _ref2.renderCountProp,
|
1498 | renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp,
|
1499 | _ref2$shouldHandleSta = _ref2.shouldHandleStateChanges,
|
1500 | shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta,
|
1501 | _ref2$storeKey = _ref2.storeKey,
|
1502 | storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey,
|
1503 | _ref2$withRef = _ref2.withRef,
|
1504 | withRef = _ref2$withRef === void 0 ? false : _ref2$withRef,
|
1505 | connectOptions = _objectWithoutPropertiesLoose(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef"]);
|
1506 |
|
1507 | var subscriptionKey = storeKey + 'Subscription';
|
1508 | var version = hotReloadingVersion++;
|
1509 | var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = storeShape, _contextTypes[subscriptionKey] = subscriptionShape, _contextTypes);
|
1510 | var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = subscriptionShape, _childContextTypes);
|
1511 | return function wrapWithConnect(WrappedComponent) {
|
1512 | invariant_1$1(reactIs_1(WrappedComponent), "You must pass a component to the function returned by " + (methodName + ". Instead received " + JSON.stringify(WrappedComponent)));
|
1513 | var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
1514 | var displayName = getDisplayName(wrappedComponentName);
|
1515 |
|
1516 | var selectorFactoryOptions = _extends({}, connectOptions, {
|
1517 | getDisplayName: getDisplayName,
|
1518 | methodName: methodName,
|
1519 | renderCountProp: renderCountProp,
|
1520 | shouldHandleStateChanges: shouldHandleStateChanges,
|
1521 | storeKey: storeKey,
|
1522 | withRef: withRef,
|
1523 | displayName: displayName,
|
1524 | wrappedComponentName: wrappedComponentName,
|
1525 | WrappedComponent: WrappedComponent
|
1526 |
|
1527 |
|
1528 |
|
1529 | });
|
1530 |
|
1531 | var Connect =
|
1532 |
|
1533 | function (_Component) {
|
1534 | _inheritsLoose(Connect, _Component);
|
1535 |
|
1536 | function Connect(props, context) {
|
1537 | var _this;
|
1538 |
|
1539 | _this = _Component.call(this, props, context) || this;
|
1540 | _this.version = version;
|
1541 | _this.state = {};
|
1542 | _this.renderCount = 0;
|
1543 | _this.store = props[storeKey] || context[storeKey];
|
1544 | _this.propsMode = Boolean(props[storeKey]);
|
1545 | _this.setWrappedInstance = _this.setWrappedInstance.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
1546 | invariant_1$1(_this.store, "Could not find \"" + storeKey + "\" in either the context or props of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + ("or explicitly pass \"" + storeKey + "\" as a prop to \"" + displayName + "\"."));
|
1547 |
|
1548 | _this.initSelector();
|
1549 |
|
1550 | _this.initSubscription();
|
1551 |
|
1552 | return _this;
|
1553 | }
|
1554 |
|
1555 | var _proto = Connect.prototype;
|
1556 |
|
1557 | _proto.getChildContext = function getChildContext() {
|
1558 | var _ref3;
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 | var subscription = this.propsMode ? null : this.subscription;
|
1565 | return _ref3 = {}, _ref3[subscriptionKey] = subscription || this.context[subscriptionKey], _ref3;
|
1566 | };
|
1567 |
|
1568 | _proto.componentDidMount = function componentDidMount() {
|
1569 | if (!shouldHandleStateChanges) return;
|
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 | this.subscription.trySubscribe();
|
1577 | this.selector.run(this.props);
|
1578 | if (this.selector.shouldComponentUpdate) this.forceUpdate();
|
1579 | };
|
1580 |
|
1581 | _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1582 | this.selector.run(nextProps);
|
1583 | };
|
1584 |
|
1585 | _proto.shouldComponentUpdate = function shouldComponentUpdate() {
|
1586 | return this.selector.shouldComponentUpdate;
|
1587 | };
|
1588 |
|
1589 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1590 | if (this.subscription) this.subscription.tryUnsubscribe();
|
1591 | this.subscription = null;
|
1592 | this.notifyNestedSubs = noop;
|
1593 | this.store = null;
|
1594 | this.selector.run = noop;
|
1595 | this.selector.shouldComponentUpdate = false;
|
1596 | };
|
1597 |
|
1598 | _proto.getWrappedInstance = function getWrappedInstance() {
|
1599 | invariant_1$1(withRef, "To access the wrapped instance, you need to specify " + ("{ withRef: true } in the options argument of the " + methodName + "() call."));
|
1600 | return this.wrappedInstance;
|
1601 | };
|
1602 |
|
1603 | _proto.setWrappedInstance = function setWrappedInstance(ref) {
|
1604 | this.wrappedInstance = ref;
|
1605 | };
|
1606 |
|
1607 | _proto.initSelector = function initSelector() {
|
1608 | var sourceSelector = selectorFactory(this.store.dispatch, selectorFactoryOptions);
|
1609 | this.selector = makeSelectorStateful(sourceSelector, this.store);
|
1610 | this.selector.run(this.props);
|
1611 | };
|
1612 |
|
1613 | _proto.initSubscription = function initSubscription() {
|
1614 | if (!shouldHandleStateChanges) return;
|
1615 |
|
1616 |
|
1617 | var parentSub = (this.propsMode ? this.props : this.context)[subscriptionKey];
|
1618 | this.subscription = new Subscription(this.store, parentSub, this.onStateChange.bind(this));
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 | this.notifyNestedSubs = this.subscription.notifyNestedSubs.bind(this.subscription);
|
1626 | };
|
1627 |
|
1628 | _proto.onStateChange = function onStateChange() {
|
1629 | this.selector.run(this.props);
|
1630 |
|
1631 | if (!this.selector.shouldComponentUpdate) {
|
1632 | this.notifyNestedSubs();
|
1633 | } else {
|
1634 | this.componentDidUpdate = this.notifyNestedSubsOnComponentDidUpdate;
|
1635 | this.setState(dummyState);
|
1636 | }
|
1637 | };
|
1638 |
|
1639 | _proto.notifyNestedSubsOnComponentDidUpdate = function notifyNestedSubsOnComponentDidUpdate() {
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 | this.componentDidUpdate = undefined;
|
1646 | this.notifyNestedSubs();
|
1647 | };
|
1648 |
|
1649 | _proto.isSubscribed = function isSubscribed() {
|
1650 | return Boolean(this.subscription) && this.subscription.isSubscribed();
|
1651 | };
|
1652 |
|
1653 | _proto.addExtraProps = function addExtraProps(props) {
|
1654 | if (!withRef && !renderCountProp && !(this.propsMode && this.subscription)) return props;
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 | var withExtras = _extends({}, props);
|
1660 |
|
1661 | if (withRef) withExtras.ref = this.setWrappedInstance;
|
1662 | if (renderCountProp) withExtras[renderCountProp] = this.renderCount++;
|
1663 | if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription;
|
1664 | return withExtras;
|
1665 | };
|
1666 |
|
1667 | _proto.render = function render() {
|
1668 | var selector = this.selector;
|
1669 | selector.shouldComponentUpdate = false;
|
1670 |
|
1671 | if (selector.error) {
|
1672 | throw selector.error;
|
1673 | } else {
|
1674 | return react.createElement(WrappedComponent, this.addExtraProps(selector.props));
|
1675 | }
|
1676 | };
|
1677 |
|
1678 | return Connect;
|
1679 | }(react.Component);
|
1680 |
|
1681 |
|
1682 |
|
1683 | Connect.WrappedComponent = WrappedComponent;
|
1684 | Connect.displayName = displayName;
|
1685 | Connect.childContextTypes = childContextTypes;
|
1686 | Connect.contextTypes = contextTypes;
|
1687 | Connect.propTypes = contextTypes;
|
1688 |
|
1689 | {
|
1690 | Connect.prototype.componentWillUpdate = function componentWillUpdate() {
|
1691 | var _this2 = this;
|
1692 |
|
1693 |
|
1694 | if (this.version !== version) {
|
1695 | this.version = version;
|
1696 | this.initSelector();
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 | var oldListeners = [];
|
1703 |
|
1704 | if (this.subscription) {
|
1705 | oldListeners = this.subscription.listeners.get();
|
1706 | this.subscription.tryUnsubscribe();
|
1707 | }
|
1708 |
|
1709 | this.initSubscription();
|
1710 |
|
1711 | if (shouldHandleStateChanges) {
|
1712 | this.subscription.trySubscribe();
|
1713 | oldListeners.forEach(function (listener) {
|
1714 | return _this2.subscription.listeners.subscribe(listener);
|
1715 | });
|
1716 | }
|
1717 | }
|
1718 | };
|
1719 | }
|
1720 |
|
1721 | return hoistNonReactStatics_cjs(Connect, WrappedComponent);
|
1722 | };
|
1723 | }
|
1724 |
|
1725 | var hasOwn = Object.prototype.hasOwnProperty;
|
1726 |
|
1727 | function is(x, y) {
|
1728 | if (x === y) {
|
1729 | return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
1730 | } else {
|
1731 | return x !== x && y !== y;
|
1732 | }
|
1733 | }
|
1734 |
|
1735 | function shallowEqual(objA, objB) {
|
1736 | if (is(objA, objB)) return true;
|
1737 |
|
1738 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
1739 | return false;
|
1740 | }
|
1741 |
|
1742 | var keysA = Object.keys(objA);
|
1743 | var keysB = Object.keys(objB);
|
1744 | if (keysA.length !== keysB.length) return false;
|
1745 |
|
1746 | for (var i = 0; i < keysA.length; i++) {
|
1747 | if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
1748 | return false;
|
1749 | }
|
1750 | }
|
1751 |
|
1752 | return true;
|
1753 | }
|
1754 |
|
1755 | |
1756 |
|
1757 |
|
1758 |
|
1759 | function isPlainObject(obj) {
|
1760 | if (typeof obj !== 'object' || obj === null) return false;
|
1761 | var proto = obj;
|
1762 |
|
1763 | while (Object.getPrototypeOf(proto) !== null) {
|
1764 | proto = Object.getPrototypeOf(proto);
|
1765 | }
|
1766 |
|
1767 | return Object.getPrototypeOf(obj) === proto;
|
1768 | }
|
1769 |
|
1770 | function verifyPlainObject(value, displayName, methodName) {
|
1771 | if (!isPlainObject(value)) {
|
1772 | warning$2(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
|
1773 | }
|
1774 | }
|
1775 |
|
1776 | function wrapMapToPropsConstant(getConstant) {
|
1777 | return function initConstantSelector(dispatch, options) {
|
1778 | var constant = getConstant(dispatch, options);
|
1779 |
|
1780 | function constantSelector() {
|
1781 | return constant;
|
1782 | }
|
1783 |
|
1784 | constantSelector.dependsOnOwnProps = false;
|
1785 | return constantSelector;
|
1786 | };
|
1787 | }
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 | function getDependsOnOwnProps(mapToProps) {
|
1796 | return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
|
1797 | }
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 | function wrapMapToPropsFunc(mapToProps, methodName) {
|
1811 | return function initProxySelector(dispatch, _ref) {
|
1812 | var displayName = _ref.displayName;
|
1813 |
|
1814 | var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
|
1815 | return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
|
1816 | };
|
1817 |
|
1818 |
|
1819 | proxy.dependsOnOwnProps = true;
|
1820 |
|
1821 | proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
|
1822 | proxy.mapToProps = mapToProps;
|
1823 | proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
|
1824 | var props = proxy(stateOrDispatch, ownProps);
|
1825 |
|
1826 | if (typeof props === 'function') {
|
1827 | proxy.mapToProps = props;
|
1828 | proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
|
1829 | props = proxy(stateOrDispatch, ownProps);
|
1830 | }
|
1831 |
|
1832 | verifyPlainObject(props, displayName, methodName);
|
1833 | return props;
|
1834 | };
|
1835 |
|
1836 | return proxy;
|
1837 | };
|
1838 | }
|
1839 |
|
1840 | function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
|
1841 | return typeof mapDispatchToProps === 'function' ? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : undefined;
|
1842 | }
|
1843 | function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
|
1844 | return !mapDispatchToProps ? wrapMapToPropsConstant(function (dispatch) {
|
1845 | return {
|
1846 | dispatch: dispatch
|
1847 | };
|
1848 | }) : undefined;
|
1849 | }
|
1850 | function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
|
1851 | return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(function (dispatch) {
|
1852 | return redux.bindActionCreators(mapDispatchToProps, dispatch);
|
1853 | }) : undefined;
|
1854 | }
|
1855 | var defaultMapDispatchToPropsFactories = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
|
1856 |
|
1857 | function whenMapStateToPropsIsFunction(mapStateToProps) {
|
1858 | return typeof mapStateToProps === 'function' ? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : undefined;
|
1859 | }
|
1860 | function whenMapStateToPropsIsMissing(mapStateToProps) {
|
1861 | return !mapStateToProps ? wrapMapToPropsConstant(function () {
|
1862 | return {};
|
1863 | }) : undefined;
|
1864 | }
|
1865 | var defaultMapStateToPropsFactories = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
|
1866 |
|
1867 | function defaultMergeProps(stateProps, dispatchProps, ownProps) {
|
1868 | return _extends({}, ownProps, stateProps, dispatchProps);
|
1869 | }
|
1870 | function wrapMergePropsFunc(mergeProps) {
|
1871 | return function initMergePropsProxy(dispatch, _ref) {
|
1872 | var displayName = _ref.displayName,
|
1873 | pure = _ref.pure,
|
1874 | areMergedPropsEqual = _ref.areMergedPropsEqual;
|
1875 | var hasRunOnce = false;
|
1876 | var mergedProps;
|
1877 | return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
|
1878 | var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
1879 |
|
1880 | if (hasRunOnce) {
|
1881 | if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
|
1882 | } else {
|
1883 | hasRunOnce = true;
|
1884 | mergedProps = nextMergedProps;
|
1885 | verifyPlainObject(mergedProps, displayName, 'mergeProps');
|
1886 | }
|
1887 |
|
1888 | return mergedProps;
|
1889 | };
|
1890 | };
|
1891 | }
|
1892 | function whenMergePropsIsFunction(mergeProps) {
|
1893 | return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
|
1894 | }
|
1895 | function whenMergePropsIsOmitted(mergeProps) {
|
1896 | return !mergeProps ? function () {
|
1897 | return defaultMergeProps;
|
1898 | } : undefined;
|
1899 | }
|
1900 | var defaultMergePropsFactories = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
|
1901 |
|
1902 | function verify(selector, methodName, displayName) {
|
1903 | if (!selector) {
|
1904 | throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
|
1905 | } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
|
1906 | if (!selector.hasOwnProperty('dependsOnOwnProps')) {
|
1907 | warning$2("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
|
1908 | }
|
1909 | }
|
1910 | }
|
1911 |
|
1912 | function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
|
1913 | verify(mapStateToProps, 'mapStateToProps', displayName);
|
1914 | verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
|
1915 | verify(mergeProps, 'mergeProps', displayName);
|
1916 | }
|
1917 |
|
1918 | function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
|
1919 | return function impureFinalPropsSelector(state, ownProps) {
|
1920 | return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
|
1921 | };
|
1922 | }
|
1923 | function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
|
1924 | var areStatesEqual = _ref.areStatesEqual,
|
1925 | areOwnPropsEqual = _ref.areOwnPropsEqual,
|
1926 | areStatePropsEqual = _ref.areStatePropsEqual;
|
1927 | var hasRunAtLeastOnce = false;
|
1928 | var state;
|
1929 | var ownProps;
|
1930 | var stateProps;
|
1931 | var dispatchProps;
|
1932 | var mergedProps;
|
1933 |
|
1934 | function handleFirstCall(firstState, firstOwnProps) {
|
1935 | state = firstState;
|
1936 | ownProps = firstOwnProps;
|
1937 | stateProps = mapStateToProps(state, ownProps);
|
1938 | dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
1939 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
1940 | hasRunAtLeastOnce = true;
|
1941 | return mergedProps;
|
1942 | }
|
1943 |
|
1944 | function handleNewPropsAndNewState() {
|
1945 | stateProps = mapStateToProps(state, ownProps);
|
1946 | if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
1947 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
1948 | return mergedProps;
|
1949 | }
|
1950 |
|
1951 | function handleNewProps() {
|
1952 | if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
|
1953 | if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
1954 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
1955 | return mergedProps;
|
1956 | }
|
1957 |
|
1958 | function handleNewState() {
|
1959 | var nextStateProps = mapStateToProps(state, ownProps);
|
1960 | var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
|
1961 | stateProps = nextStateProps;
|
1962 | if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
1963 | return mergedProps;
|
1964 | }
|
1965 |
|
1966 | function handleSubsequentCalls(nextState, nextOwnProps) {
|
1967 | var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
|
1968 | var stateChanged = !areStatesEqual(nextState, state);
|
1969 | state = nextState;
|
1970 | ownProps = nextOwnProps;
|
1971 | if (propsChanged && stateChanged) return handleNewPropsAndNewState();
|
1972 | if (propsChanged) return handleNewProps();
|
1973 | if (stateChanged) return handleNewState();
|
1974 | return mergedProps;
|
1975 | }
|
1976 |
|
1977 | return function pureFinalPropsSelector(nextState, nextOwnProps) {
|
1978 | return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
|
1979 | };
|
1980 | }
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 | function finalPropsSelectorFactory(dispatch, _ref2) {
|
1987 | var initMapStateToProps = _ref2.initMapStateToProps,
|
1988 | initMapDispatchToProps = _ref2.initMapDispatchToProps,
|
1989 | initMergeProps = _ref2.initMergeProps,
|
1990 | options = _objectWithoutPropertiesLoose(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]);
|
1991 |
|
1992 | var mapStateToProps = initMapStateToProps(dispatch, options);
|
1993 | var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
1994 | var mergeProps = initMergeProps(dispatch, options);
|
1995 |
|
1996 | {
|
1997 | verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
|
1998 | }
|
1999 |
|
2000 | var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
|
2001 | return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
|
2002 | }
|
2003 |
|
2004 | |
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 | function match(arg, factories, name) {
|
2022 | for (var i = factories.length - 1; i >= 0; i--) {
|
2023 | var result = factories[i](arg);
|
2024 | if (result) return result;
|
2025 | }
|
2026 |
|
2027 | return function (dispatch, options) {
|
2028 | throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
|
2029 | };
|
2030 | }
|
2031 |
|
2032 | function strictEqual(a, b) {
|
2033 | return a === b;
|
2034 | }
|
2035 |
|
2036 |
|
2037 |
|
2038 | function createConnect(_temp) {
|
2039 | var _ref = _temp === void 0 ? {} : _temp,
|
2040 | _ref$connectHOC = _ref.connectHOC,
|
2041 | connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC,
|
2042 | _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
|
2043 | mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? defaultMapStateToPropsFactories : _ref$mapStateToPropsF,
|
2044 | _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
|
2045 | mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? defaultMapDispatchToPropsFactories : _ref$mapDispatchToPro,
|
2046 | _ref$mergePropsFactor = _ref.mergePropsFactories,
|
2047 | mergePropsFactories = _ref$mergePropsFactor === void 0 ? defaultMergePropsFactories : _ref$mergePropsFactor,
|
2048 | _ref$selectorFactory = _ref.selectorFactory,
|
2049 | selectorFactory = _ref$selectorFactory === void 0 ? finalPropsSelectorFactory : _ref$selectorFactory;
|
2050 |
|
2051 | return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
|
2052 | if (_ref2 === void 0) {
|
2053 | _ref2 = {};
|
2054 | }
|
2055 |
|
2056 | var _ref3 = _ref2,
|
2057 | _ref3$pure = _ref3.pure,
|
2058 | pure = _ref3$pure === void 0 ? true : _ref3$pure,
|
2059 | _ref3$areStatesEqual = _ref3.areStatesEqual,
|
2060 | areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
|
2061 | _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
|
2062 | areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua,
|
2063 | _ref3$areStatePropsEq = _ref3.areStatePropsEqual,
|
2064 | areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq,
|
2065 | _ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
|
2066 | areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE,
|
2067 | extraOptions = _objectWithoutPropertiesLoose(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]);
|
2068 |
|
2069 | var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
|
2070 | var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
|
2071 | var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
|
2072 | return connectHOC(selectorFactory, _extends({
|
2073 |
|
2074 | methodName: 'connect',
|
2075 |
|
2076 | getDisplayName: function getDisplayName(name) {
|
2077 | return "Connect(" + name + ")";
|
2078 | },
|
2079 |
|
2080 | shouldHandleStateChanges: Boolean(mapStateToProps),
|
2081 |
|
2082 | initMapStateToProps: initMapStateToProps,
|
2083 | initMapDispatchToProps: initMapDispatchToProps,
|
2084 | initMergeProps: initMergeProps,
|
2085 | pure: pure,
|
2086 | areStatesEqual: areStatesEqual,
|
2087 | areOwnPropsEqual: areOwnPropsEqual,
|
2088 | areStatePropsEqual: areStatePropsEqual,
|
2089 | areMergedPropsEqual: areMergedPropsEqual
|
2090 | }, extraOptions));
|
2091 | };
|
2092 | }
|
2093 | var connect = createConnect();
|
2094 |
|
2095 | exports.Provider = Provider;
|
2096 | exports.createProvider = createProvider;
|
2097 | exports.connectAdvanced = connectAdvanced;
|
2098 | exports.connect = connect;
|
2099 |
|
2100 | Object.defineProperty(exports, '__esModule', { value: true });
|
2101 |
|
2102 | })));
|