You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2834 lines
107 KiB
2834 lines
107 KiB
(function (global, factory) { |
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) : |
|
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) : |
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRedux = {}, global.React, global.ReactDOM)); |
|
})(this, (function (exports, React, reactDom) { 'use strict'; |
|
|
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } |
|
|
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); |
|
|
|
var propTypes = {exports: {}}; |
|
|
|
var reactIs$3 = {exports: {}}; |
|
|
|
var reactIs_development$2 = {}; |
|
|
|
/** @license React v16.13.1 |
|
* react-is.development.js |
|
* |
|
* Copyright (c) Facebook, Inc. and its affiliates. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
|
|
|
|
{ |
|
(function() { |
|
|
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol |
|
// nor polyfill, then a plain number is used for performance. |
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for; |
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; |
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; |
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; |
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; |
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; |
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; |
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary |
|
// (unstable) APIs that have been removed. Can we remove the symbols? |
|
|
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; |
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; |
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; |
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; |
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; |
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; |
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; |
|
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; |
|
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; |
|
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; |
|
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; |
|
|
|
function isValidElementType(type) { |
|
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. |
|
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 || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); |
|
} |
|
|
|
function typeOf(object) { |
|
if (typeof object === 'object' && object !== null) { |
|
var $$typeof = object.$$typeof; |
|
|
|
switch ($$typeof) { |
|
case REACT_ELEMENT_TYPE: |
|
var type = object.type; |
|
|
|
switch (type) { |
|
case REACT_ASYNC_MODE_TYPE: |
|
case REACT_CONCURRENT_MODE_TYPE: |
|
case REACT_FRAGMENT_TYPE: |
|
case REACT_PROFILER_TYPE: |
|
case REACT_STRICT_MODE_TYPE: |
|
case REACT_SUSPENSE_TYPE: |
|
return type; |
|
|
|
default: |
|
var $$typeofType = type && type.$$typeof; |
|
|
|
switch ($$typeofType) { |
|
case REACT_CONTEXT_TYPE: |
|
case REACT_FORWARD_REF_TYPE: |
|
case REACT_LAZY_TYPE: |
|
case REACT_MEMO_TYPE: |
|
case REACT_PROVIDER_TYPE: |
|
return $$typeofType; |
|
|
|
default: |
|
return $$typeof; |
|
} |
|
|
|
} |
|
|
|
case REACT_PORTAL_TYPE: |
|
return $$typeof; |
|
} |
|
} |
|
|
|
return undefined; |
|
} // AsyncMode is deprecated along with isAsyncMode |
|
|
|
var AsyncMode = REACT_ASYNC_MODE_TYPE; |
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; |
|
var ContextConsumer = REACT_CONTEXT_TYPE; |
|
var ContextProvider = REACT_PROVIDER_TYPE; |
|
var Element = REACT_ELEMENT_TYPE; |
|
var ForwardRef = REACT_FORWARD_REF_TYPE; |
|
var Fragment = REACT_FRAGMENT_TYPE; |
|
var Lazy = REACT_LAZY_TYPE; |
|
var Memo = REACT_MEMO_TYPE; |
|
var Portal = REACT_PORTAL_TYPE; |
|
var Profiler = REACT_PROFILER_TYPE; |
|
var StrictMode = REACT_STRICT_MODE_TYPE; |
|
var Suspense = REACT_SUSPENSE_TYPE; |
|
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated |
|
|
|
function isAsyncMode(object) { |
|
{ |
|
if (!hasWarnedAboutDeprecatedIsAsyncMode) { |
|
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint |
|
|
|
console['warn']('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.'); |
|
} |
|
} |
|
|
|
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; |
|
} |
|
function isConcurrentMode(object) { |
|
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; |
|
} |
|
function isContextConsumer(object) { |
|
return typeOf(object) === REACT_CONTEXT_TYPE; |
|
} |
|
function isContextProvider(object) { |
|
return typeOf(object) === REACT_PROVIDER_TYPE; |
|
} |
|
function isElement(object) { |
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
|
} |
|
function isForwardRef(object) { |
|
return typeOf(object) === REACT_FORWARD_REF_TYPE; |
|
} |
|
function isFragment(object) { |
|
return typeOf(object) === REACT_FRAGMENT_TYPE; |
|
} |
|
function isLazy(object) { |
|
return typeOf(object) === REACT_LAZY_TYPE; |
|
} |
|
function isMemo(object) { |
|
return typeOf(object) === REACT_MEMO_TYPE; |
|
} |
|
function isPortal(object) { |
|
return typeOf(object) === REACT_PORTAL_TYPE; |
|
} |
|
function isProfiler(object) { |
|
return typeOf(object) === REACT_PROFILER_TYPE; |
|
} |
|
function isStrictMode(object) { |
|
return typeOf(object) === REACT_STRICT_MODE_TYPE; |
|
} |
|
function isSuspense(object) { |
|
return typeOf(object) === REACT_SUSPENSE_TYPE; |
|
} |
|
|
|
reactIs_development$2.AsyncMode = AsyncMode; |
|
reactIs_development$2.ConcurrentMode = ConcurrentMode; |
|
reactIs_development$2.ContextConsumer = ContextConsumer; |
|
reactIs_development$2.ContextProvider = ContextProvider; |
|
reactIs_development$2.Element = Element; |
|
reactIs_development$2.ForwardRef = ForwardRef; |
|
reactIs_development$2.Fragment = Fragment; |
|
reactIs_development$2.Lazy = Lazy; |
|
reactIs_development$2.Memo = Memo; |
|
reactIs_development$2.Portal = Portal; |
|
reactIs_development$2.Profiler = Profiler; |
|
reactIs_development$2.StrictMode = StrictMode; |
|
reactIs_development$2.Suspense = Suspense; |
|
reactIs_development$2.isAsyncMode = isAsyncMode; |
|
reactIs_development$2.isConcurrentMode = isConcurrentMode; |
|
reactIs_development$2.isContextConsumer = isContextConsumer; |
|
reactIs_development$2.isContextProvider = isContextProvider; |
|
reactIs_development$2.isElement = isElement; |
|
reactIs_development$2.isForwardRef = isForwardRef; |
|
reactIs_development$2.isFragment = isFragment; |
|
reactIs_development$2.isLazy = isLazy; |
|
reactIs_development$2.isMemo = isMemo; |
|
reactIs_development$2.isPortal = isPortal; |
|
reactIs_development$2.isProfiler = isProfiler; |
|
reactIs_development$2.isStrictMode = isStrictMode; |
|
reactIs_development$2.isSuspense = isSuspense; |
|
reactIs_development$2.isValidElementType = isValidElementType; |
|
reactIs_development$2.typeOf = typeOf; |
|
})(); |
|
} |
|
|
|
{ |
|
reactIs$3.exports = reactIs_development$2; |
|
} |
|
|
|
/* |
|
object-assign |
|
(c) Sindre Sorhus |
|
@license MIT |
|
*/ |
|
/* eslint-disable no-unused-vars */ |
|
var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols; |
|
var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
var propIsEnumerable = Object.prototype.propertyIsEnumerable; |
|
|
|
function toObject(val) { |
|
if (val === null || val === undefined) { |
|
throw new TypeError('Object.assign cannot be called with null or undefined'); |
|
} |
|
|
|
return Object(val); |
|
} |
|
|
|
function shouldUseNative() { |
|
try { |
|
if (!Object.assign) { |
|
return false; |
|
} |
|
|
|
// Detect buggy property enumeration order in older V8 versions. |
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 |
|
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers |
|
test1[5] = 'de'; |
|
if (Object.getOwnPropertyNames(test1)[0] === '5') { |
|
return false; |
|
} |
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 |
|
var test2 = {}; |
|
for (var i = 0; i < 10; i++) { |
|
test2['_' + String.fromCharCode(i)] = i; |
|
} |
|
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { |
|
return test2[n]; |
|
}); |
|
if (order2.join('') !== '0123456789') { |
|
return false; |
|
} |
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 |
|
var test3 = {}; |
|
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { |
|
test3[letter] = letter; |
|
}); |
|
if (Object.keys(Object.assign({}, test3)).join('') !== |
|
'abcdefghijklmnopqrst') { |
|
return false; |
|
} |
|
|
|
return true; |
|
} catch (err) { |
|
// We don't expect any of the above to throw, but better to be safe. |
|
return false; |
|
} |
|
} |
|
|
|
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { |
|
var from; |
|
var to = toObject(target); |
|
var symbols; |
|
|
|
for (var s = 1; s < arguments.length; s++) { |
|
from = Object(arguments[s]); |
|
|
|
for (var key in from) { |
|
if (hasOwnProperty.call(from, key)) { |
|
to[key] = from[key]; |
|
} |
|
} |
|
|
|
if (getOwnPropertySymbols$1) { |
|
symbols = getOwnPropertySymbols$1(from); |
|
for (var i = 0; i < symbols.length; i++) { |
|
if (propIsEnumerable.call(from, symbols[i])) { |
|
to[symbols[i]] = from[symbols[i]]; |
|
} |
|
} |
|
} |
|
} |
|
|
|
return to; |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2013-present, Facebook, Inc. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
var ReactPropTypesSecret$2 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; |
|
|
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret$2; |
|
|
|
/** |
|
* Copyright (c) 2013-present, Facebook, Inc. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
var printWarning$1 = function() {}; |
|
|
|
{ |
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1; |
|
var loggedTypeFailures = {}; |
|
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty); |
|
|
|
printWarning$1 = function(text) { |
|
var message = 'Warning: ' + text; |
|
if (typeof console !== 'undefined') { |
|
console.error(message); |
|
} |
|
try { |
|
// --- Welcome to debugging React --- |
|
// This error was thrown as a convenience so that you can use this stack |
|
// to find the callsite that caused this warning to fire. |
|
throw new Error(message); |
|
} catch (x) {} |
|
}; |
|
} |
|
|
|
/** |
|
* Assert that the values match with the type specs. |
|
* Error messages are memorized and will only be shown once. |
|
* |
|
* @param {object} typeSpecs Map of name to a ReactPropType |
|
* @param {object} values Runtime values that need to be type-checked |
|
* @param {string} location e.g. "prop", "context", "child context" |
|
* @param {string} componentName Name of the component for error messages. |
|
* @param {?Function} getStack Returns the component stack. |
|
* @private |
|
*/ |
|
function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) { |
|
{ |
|
for (var typeSpecName in typeSpecs) { |
|
if (has$1(typeSpecs, typeSpecName)) { |
|
var error; |
|
// Prop type validation may throw. In case they do, we don't want to |
|
// fail the render phase where it didn't fail before. So we log it. |
|
// After these have been cleaned up, we'll let them throw. |
|
try { |
|
// This is intentionally an invariant that gets caught. It's the same |
|
// behavior as without this statement except with a better message. |
|
if (typeof typeSpecs[typeSpecName] !== 'function') { |
|
var err = Error( |
|
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + |
|
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' |
|
); |
|
err.name = 'Invariant Violation'; |
|
throw err; |
|
} |
|
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1); |
|
} catch (ex) { |
|
error = ex; |
|
} |
|
if (error && !(error instanceof Error)) { |
|
printWarning$1( |
|
(componentName || 'React class') + ': type specification of ' + |
|
location + ' `' + typeSpecName + '` is invalid; the type checker ' + |
|
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + |
|
'You may have forgotten to pass an argument to the type checker ' + |
|
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + |
|
'shape all require an argument).' |
|
); |
|
} |
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) { |
|
// Only monitor this failure once because there tends to be a lot of the |
|
// same error. |
|
loggedTypeFailures[error.message] = true; |
|
|
|
var stack = getStack ? getStack() : ''; |
|
|
|
printWarning$1( |
|
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') |
|
); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
/** |
|
* Resets warning cache when testing. |
|
* |
|
* @private |
|
*/ |
|
checkPropTypes$1.resetWarningCache = function() { |
|
{ |
|
loggedTypeFailures = {}; |
|
} |
|
}; |
|
|
|
var checkPropTypes_1 = checkPropTypes$1; |
|
|
|
/** |
|
* Copyright (c) 2013-present, Facebook, Inc. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
var ReactIs$1 = reactIs$3.exports; |
|
var assign = objectAssign; |
|
|
|
var ReactPropTypesSecret = ReactPropTypesSecret_1; |
|
var checkPropTypes = checkPropTypes_1; |
|
|
|
var has = Function.call.bind(Object.prototype.hasOwnProperty); |
|
var printWarning = function() {}; |
|
|
|
{ |
|
printWarning = function(text) { |
|
var message = 'Warning: ' + text; |
|
if (typeof console !== 'undefined') { |
|
console.error(message); |
|
} |
|
try { |
|
// --- Welcome to debugging React --- |
|
// This error was thrown as a convenience so that you can use this stack |
|
// to find the callsite that caused this warning to fire. |
|
throw new Error(message); |
|
} catch (x) {} |
|
}; |
|
} |
|
|
|
function emptyFunctionThatReturnsNull() { |
|
return null; |
|
} |
|
|
|
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) { |
|
/* global Symbol */ |
|
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; |
|
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. |
|
|
|
/** |
|
* Returns the iterator method function contained on the iterable object. |
|
* |
|
* Be sure to invoke the function with the iterable as context: |
|
* |
|
* var iteratorFn = getIteratorFn(myIterable); |
|
* if (iteratorFn) { |
|
* var iterator = iteratorFn.call(myIterable); |
|
* ... |
|
* } |
|
* |
|
* @param {?object} maybeIterable |
|
* @return {?function} |
|
*/ |
|
function getIteratorFn(maybeIterable) { |
|
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); |
|
if (typeof iteratorFn === 'function') { |
|
return iteratorFn; |
|
} |
|
} |
|
|
|
/** |
|
* Collection of methods that allow declaration and validation of props that are |
|
* supplied to React components. Example usage: |
|
* |
|
* var Props = require('ReactPropTypes'); |
|
* var MyArticle = React.createClass({ |
|
* propTypes: { |
|
* // An optional string prop named "description". |
|
* description: Props.string, |
|
* |
|
* // A required enum prop named "category". |
|
* category: Props.oneOf(['News','Photos']).isRequired, |
|
* |
|
* // A prop named "dialog" that requires an instance of Dialog. |
|
* dialog: Props.instanceOf(Dialog).isRequired |
|
* }, |
|
* render: function() { ... } |
|
* }); |
|
* |
|
* A more formal specification of how these methods are used: |
|
* |
|
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) |
|
* decl := ReactPropTypes.{type}(.isRequired)? |
|
* |
|
* Each and every declaration produces a function with the same signature. This |
|
* allows the creation of custom validation functions. For example: |
|
* |
|
* var MyLink = React.createClass({ |
|
* propTypes: { |
|
* // An optional string or URI prop named "href". |
|
* href: function(props, propName, componentName) { |
|
* var propValue = props[propName]; |
|
* if (propValue != null && typeof propValue !== 'string' && |
|
* !(propValue instanceof URI)) { |
|
* return new Error( |
|
* 'Expected a string or an URI for ' + propName + ' in ' + |
|
* componentName |
|
* ); |
|
* } |
|
* } |
|
* }, |
|
* render: function() {...} |
|
* }); |
|
* |
|
* @internal |
|
*/ |
|
|
|
var ANONYMOUS = '<<anonymous>>'; |
|
|
|
// Important! |
|
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`. |
|
var ReactPropTypes = { |
|
array: createPrimitiveTypeChecker('array'), |
|
bool: createPrimitiveTypeChecker('boolean'), |
|
func: createPrimitiveTypeChecker('function'), |
|
number: createPrimitiveTypeChecker('number'), |
|
object: createPrimitiveTypeChecker('object'), |
|
string: createPrimitiveTypeChecker('string'), |
|
symbol: createPrimitiveTypeChecker('symbol'), |
|
|
|
any: createAnyTypeChecker(), |
|
arrayOf: createArrayOfTypeChecker, |
|
element: createElementTypeChecker(), |
|
elementType: createElementTypeTypeChecker(), |
|
instanceOf: createInstanceTypeChecker, |
|
node: createNodeChecker(), |
|
objectOf: createObjectOfTypeChecker, |
|
oneOf: createEnumTypeChecker, |
|
oneOfType: createUnionTypeChecker, |
|
shape: createShapeTypeChecker, |
|
exact: createStrictShapeTypeChecker, |
|
}; |
|
|
|
/** |
|
* inlined Object.is polyfill to avoid requiring consumers ship their own |
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is |
|
*/ |
|
/*eslint-disable no-self-compare*/ |
|
function is(x, y) { |
|
// SameValue algorithm |
|
if (x === y) { |
|
// Steps 1-5, 7-10 |
|
// Steps 6.b-6.e: +0 != -0 |
|
return x !== 0 || 1 / x === 1 / y; |
|
} else { |
|
// Step 6.a: NaN == NaN |
|
return x !== x && y !== y; |
|
} |
|
} |
|
/*eslint-enable no-self-compare*/ |
|
|
|
/** |
|
* We use an Error-like object for backward compatibility as people may call |
|
* PropTypes directly and inspect their output. However, we don't use real |
|
* Errors anymore. We don't inspect their stack anyway, and creating them |
|
* is prohibitively expensive if they are created too often, such as what |
|
* happens in oneOfType() for any type before the one that matched. |
|
*/ |
|
function PropTypeError(message) { |
|
this.message = message; |
|
this.stack = ''; |
|
} |
|
// Make `instanceof Error` still work for returned errors. |
|
PropTypeError.prototype = Error.prototype; |
|
|
|
function createChainableTypeChecker(validate) { |
|
{ |
|
var manualPropTypeCallCache = {}; |
|
var manualPropTypeWarningCount = 0; |
|
} |
|
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { |
|
componentName = componentName || ANONYMOUS; |
|
propFullName = propFullName || propName; |
|
|
|
if (secret !== ReactPropTypesSecret) { |
|
if (throwOnDirectAccess) { |
|
// New behavior only for users of `prop-types` package |
|
var err = new Error( |
|
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + |
|
'Use `PropTypes.checkPropTypes()` to call them. ' + |
|
'Read more at http://fb.me/use-check-prop-types' |
|
); |
|
err.name = 'Invariant Violation'; |
|
throw err; |
|
} else if (typeof console !== 'undefined') { |
|
// Old behavior for people using React.PropTypes |
|
var cacheKey = componentName + ':' + propName; |
|
if ( |
|
!manualPropTypeCallCache[cacheKey] && |
|
// Avoid spamming the console because they are often not actionable except for lib authors |
|
manualPropTypeWarningCount < 3 |
|
) { |
|
printWarning( |
|
'You are manually calling a React.PropTypes validation ' + |
|
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + |
|
'and will throw in the standalone `prop-types` package. ' + |
|
'You may be seeing this warning due to a third-party PropTypes ' + |
|
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' |
|
); |
|
manualPropTypeCallCache[cacheKey] = true; |
|
manualPropTypeWarningCount++; |
|
} |
|
} |
|
} |
|
if (props[propName] == null) { |
|
if (isRequired) { |
|
if (props[propName] === null) { |
|
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); |
|
} |
|
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); |
|
} |
|
return null; |
|
} else { |
|
return validate(props, propName, componentName, location, propFullName); |
|
} |
|
} |
|
|
|
var chainedCheckType = checkType.bind(null, false); |
|
chainedCheckType.isRequired = checkType.bind(null, true); |
|
|
|
return chainedCheckType; |
|
} |
|
|
|
function createPrimitiveTypeChecker(expectedType) { |
|
function validate(props, propName, componentName, location, propFullName, secret) { |
|
var propValue = props[propName]; |
|
var propType = getPropType(propValue); |
|
if (propType !== expectedType) { |
|
// `propValue` being instance of, say, date/regexp, pass the 'object' |
|
// check, but we can offer a more precise error message here rather than |
|
// 'of type `object`'. |
|
var preciseType = getPreciseType(propValue); |
|
|
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createAnyTypeChecker() { |
|
return createChainableTypeChecker(emptyFunctionThatReturnsNull); |
|
} |
|
|
|
function createArrayOfTypeChecker(typeChecker) { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
if (typeof typeChecker !== 'function') { |
|
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); |
|
} |
|
var propValue = props[propName]; |
|
if (!Array.isArray(propValue)) { |
|
var propType = getPropType(propValue); |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); |
|
} |
|
for (var i = 0; i < propValue.length; i++) { |
|
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); |
|
if (error instanceof Error) { |
|
return error; |
|
} |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createElementTypeChecker() { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
var propValue = props[propName]; |
|
if (!isValidElement(propValue)) { |
|
var propType = getPropType(propValue); |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createElementTypeTypeChecker() { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
var propValue = props[propName]; |
|
if (!ReactIs$1.isValidElementType(propValue)) { |
|
var propType = getPropType(propValue); |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createInstanceTypeChecker(expectedClass) { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
if (!(props[propName] instanceof expectedClass)) { |
|
var expectedClassName = expectedClass.name || ANONYMOUS; |
|
var actualClassName = getClassName(props[propName]); |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createEnumTypeChecker(expectedValues) { |
|
if (!Array.isArray(expectedValues)) { |
|
{ |
|
if (arguments.length > 1) { |
|
printWarning( |
|
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + |
|
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' |
|
); |
|
} else { |
|
printWarning('Invalid argument supplied to oneOf, expected an array.'); |
|
} |
|
} |
|
return emptyFunctionThatReturnsNull; |
|
} |
|
|
|
function validate(props, propName, componentName, location, propFullName) { |
|
var propValue = props[propName]; |
|
for (var i = 0; i < expectedValues.length; i++) { |
|
if (is(propValue, expectedValues[i])) { |
|
return null; |
|
} |
|
} |
|
|
|
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { |
|
var type = getPreciseType(value); |
|
if (type === 'symbol') { |
|
return String(value); |
|
} |
|
return value; |
|
}); |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createObjectOfTypeChecker(typeChecker) { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
if (typeof typeChecker !== 'function') { |
|
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); |
|
} |
|
var propValue = props[propName]; |
|
var propType = getPropType(propValue); |
|
if (propType !== 'object') { |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); |
|
} |
|
for (var key in propValue) { |
|
if (has(propValue, key)) { |
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); |
|
if (error instanceof Error) { |
|
return error; |
|
} |
|
} |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createUnionTypeChecker(arrayOfTypeCheckers) { |
|
if (!Array.isArray(arrayOfTypeCheckers)) { |
|
printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ; |
|
return emptyFunctionThatReturnsNull; |
|
} |
|
|
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { |
|
var checker = arrayOfTypeCheckers[i]; |
|
if (typeof checker !== 'function') { |
|
printWarning( |
|
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + |
|
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' |
|
); |
|
return emptyFunctionThatReturnsNull; |
|
} |
|
} |
|
|
|
function validate(props, propName, componentName, location, propFullName) { |
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { |
|
var checker = arrayOfTypeCheckers[i]; |
|
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { |
|
return null; |
|
} |
|
} |
|
|
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createNodeChecker() { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
if (!isNode(props[propName])) { |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createShapeTypeChecker(shapeTypes) { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
var propValue = props[propName]; |
|
var propType = getPropType(propValue); |
|
if (propType !== 'object') { |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); |
|
} |
|
for (var key in shapeTypes) { |
|
var checker = shapeTypes[key]; |
|
if (!checker) { |
|
continue; |
|
} |
|
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); |
|
if (error) { |
|
return error; |
|
} |
|
} |
|
return null; |
|
} |
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function createStrictShapeTypeChecker(shapeTypes) { |
|
function validate(props, propName, componentName, location, propFullName) { |
|
var propValue = props[propName]; |
|
var propType = getPropType(propValue); |
|
if (propType !== 'object') { |
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); |
|
} |
|
// We need to check all keys in case some are required but missing from |
|
// props. |
|
var allKeys = assign({}, props[propName], shapeTypes); |
|
for (var key in allKeys) { |
|
var checker = shapeTypes[key]; |
|
if (!checker) { |
|
return new PropTypeError( |
|
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + |
|
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') + |
|
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') |
|
); |
|
} |
|
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); |
|
if (error) { |
|
return error; |
|
} |
|
} |
|
return null; |
|
} |
|
|
|
return createChainableTypeChecker(validate); |
|
} |
|
|
|
function isNode(propValue) { |
|
switch (typeof propValue) { |
|
case 'number': |
|
case 'string': |
|
case 'undefined': |
|
return true; |
|
case 'boolean': |
|
return !propValue; |
|
case 'object': |
|
if (Array.isArray(propValue)) { |
|
return propValue.every(isNode); |
|
} |
|
if (propValue === null || isValidElement(propValue)) { |
|
return true; |
|
} |
|
|
|
var iteratorFn = getIteratorFn(propValue); |
|
if (iteratorFn) { |
|
var iterator = iteratorFn.call(propValue); |
|
var step; |
|
if (iteratorFn !== propValue.entries) { |
|
while (!(step = iterator.next()).done) { |
|
if (!isNode(step.value)) { |
|
return false; |
|
} |
|
} |
|
} else { |
|
// Iterator will provide entry [k,v] tuples rather than values. |
|
while (!(step = iterator.next()).done) { |
|
var entry = step.value; |
|
if (entry) { |
|
if (!isNode(entry[1])) { |
|
return false; |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
return false; |
|
} |
|
|
|
return true; |
|
default: |
|
return false; |
|
} |
|
} |
|
|
|
function isSymbol(propType, propValue) { |
|
// Native Symbol. |
|
if (propType === 'symbol') { |
|
return true; |
|
} |
|
|
|
// falsy value can't be a Symbol |
|
if (!propValue) { |
|
return false; |
|
} |
|
|
|
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' |
|
if (propValue['@@toStringTag'] === 'Symbol') { |
|
return true; |
|
} |
|
|
|
// Fallback for non-spec compliant Symbols which are polyfilled. |
|
if (typeof Symbol === 'function' && propValue instanceof Symbol) { |
|
return true; |
|
} |
|
|
|
return false; |
|
} |
|
|
|
// Equivalent of `typeof` but with special handling for array and regexp. |
|
function getPropType(propValue) { |
|
var propType = typeof propValue; |
|
if (Array.isArray(propValue)) { |
|
return 'array'; |
|
} |
|
if (propValue instanceof RegExp) { |
|
// Old webkits (at least until Android 4.0) return 'function' rather than |
|
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/ |
|
// passes PropTypes.object. |
|
return 'object'; |
|
} |
|
if (isSymbol(propType, propValue)) { |
|
return 'symbol'; |
|
} |
|
return propType; |
|
} |
|
|
|
// This handles more types than `getPropType`. Only used for error messages. |
|
// See `createPrimitiveTypeChecker`. |
|
function getPreciseType(propValue) { |
|
if (typeof propValue === 'undefined' || propValue === null) { |
|
return '' + propValue; |
|
} |
|
var propType = getPropType(propValue); |
|
if (propType === 'object') { |
|
if (propValue instanceof Date) { |
|
return 'date'; |
|
} else if (propValue instanceof RegExp) { |
|
return 'regexp'; |
|
} |
|
} |
|
return propType; |
|
} |
|
|
|
// Returns a string that is postfixed to a warning about an invalid type. |
|
// For example, "undefined" or "of type array" |
|
function getPostfixForTypeWarning(value) { |
|
var type = getPreciseType(value); |
|
switch (type) { |
|
case 'array': |
|
case 'object': |
|
return 'an ' + type; |
|
case 'boolean': |
|
case 'date': |
|
case 'regexp': |
|
return 'a ' + type; |
|
default: |
|
return type; |
|
} |
|
} |
|
|
|
// Returns class name of the object, if any. |
|
function getClassName(propValue) { |
|
if (!propValue.constructor || !propValue.constructor.name) { |
|
return ANONYMOUS; |
|
} |
|
return propValue.constructor.name; |
|
} |
|
|
|
ReactPropTypes.checkPropTypes = checkPropTypes; |
|
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; |
|
ReactPropTypes.PropTypes = ReactPropTypes; |
|
|
|
return ReactPropTypes; |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2013-present, Facebook, Inc. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
{ |
|
var ReactIs = reactIs$3.exports; |
|
|
|
// By explicitly using `prop-types` you are opting into new development behavior. |
|
// http://fb.me/prop-types-in-prod |
|
var throwOnDirectAccess = true; |
|
propTypes.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess); |
|
} |
|
|
|
var PropTypes = propTypes.exports; |
|
|
|
var ReactReduxContext = /*#__PURE__*/React__default["default"].createContext(null); |
|
|
|
{ |
|
ReactReduxContext.displayName = 'ReactRedux'; |
|
} |
|
|
|
// Default to a dummy "batch" implementation that just runs the callback |
|
function defaultNoopBatch(callback) { |
|
callback(); |
|
} |
|
|
|
var batch = defaultNoopBatch; // Allow injecting another batching function later |
|
|
|
var setBatch = function setBatch(newBatch) { |
|
return batch = newBatch; |
|
}; // Supply a getter just to skip dealing with ESM bindings |
|
|
|
var getBatch = function getBatch() { |
|
return batch; |
|
}; |
|
|
|
// well as nesting subscriptions of descendant components, so that we can ensure the |
|
// ancestor components re-render before descendants |
|
|
|
function createListenerCollection() { |
|
var batch = getBatch(); |
|
var first = null; |
|
var last = null; |
|
return { |
|
clear: function clear() { |
|
first = null; |
|
last = null; |
|
}, |
|
notify: function notify() { |
|
batch(function () { |
|
var listener = first; |
|
|
|
while (listener) { |
|
listener.callback(); |
|
listener = listener.next; |
|
} |
|
}); |
|
}, |
|
get: function get() { |
|
var listeners = []; |
|
var listener = first; |
|
|
|
while (listener) { |
|
listeners.push(listener); |
|
listener = listener.next; |
|
} |
|
|
|
return listeners; |
|
}, |
|
subscribe: function subscribe(callback) { |
|
var isSubscribed = true; |
|
var listener = last = { |
|
callback: callback, |
|
next: null, |
|
prev: last |
|
}; |
|
|
|
if (listener.prev) { |
|
listener.prev.next = listener; |
|
} else { |
|
first = listener; |
|
} |
|
|
|
return function unsubscribe() { |
|
if (!isSubscribed || first === null) return; |
|
isSubscribed = false; |
|
|
|
if (listener.next) { |
|
listener.next.prev = listener.prev; |
|
} else { |
|
last = listener.prev; |
|
} |
|
|
|
if (listener.prev) { |
|
listener.prev.next = listener.next; |
|
} else { |
|
first = listener.next; |
|
} |
|
}; |
|
} |
|
}; |
|
} |
|
|
|
var nullListeners = { |
|
notify: function notify() {}, |
|
get: function get() { |
|
return []; |
|
} |
|
}; |
|
function createSubscription(store, parentSub) { |
|
var unsubscribe; |
|
var listeners = nullListeners; |
|
|
|
function addNestedSub(listener) { |
|
trySubscribe(); |
|
return listeners.subscribe(listener); |
|
} |
|
|
|
function notifyNestedSubs() { |
|
listeners.notify(); |
|
} |
|
|
|
function handleChangeWrapper() { |
|
if (subscription.onStateChange) { |
|
subscription.onStateChange(); |
|
} |
|
} |
|
|
|
function isSubscribed() { |
|
return Boolean(unsubscribe); |
|
} |
|
|
|
function trySubscribe() { |
|
if (!unsubscribe) { |
|
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper); |
|
listeners = createListenerCollection(); |
|
} |
|
} |
|
|
|
function tryUnsubscribe() { |
|
if (unsubscribe) { |
|
unsubscribe(); |
|
unsubscribe = undefined; |
|
listeners.clear(); |
|
listeners = nullListeners; |
|
} |
|
} |
|
|
|
var subscription = { |
|
addNestedSub: addNestedSub, |
|
notifyNestedSubs: notifyNestedSubs, |
|
handleChangeWrapper: handleChangeWrapper, |
|
isSubscribed: isSubscribed, |
|
trySubscribe: trySubscribe, |
|
tryUnsubscribe: tryUnsubscribe, |
|
getListeners: function getListeners() { |
|
return listeners; |
|
} |
|
}; |
|
return subscription; |
|
} |
|
|
|
// To get around it, we can conditionally useEffect on the server (no-op) and |
|
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store |
|
// subscription callback always has the selector from the latest render commit |
|
// available, otherwise a store update may happen between render and the effect, |
|
// which may cause missed updates; we also must ensure the store subscription |
|
// is created synchronously, otherwise a store update may occur before the |
|
// subscription is created and an inconsistent state may be observed |
|
|
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect; |
|
|
|
function Provider(_ref) { |
|
var store = _ref.store, |
|
context = _ref.context, |
|
children = _ref.children; |
|
var contextValue = React.useMemo(function () { |
|
var subscription = createSubscription(store); |
|
return { |
|
store: store, |
|
subscription: subscription |
|
}; |
|
}, [store]); |
|
var previousState = React.useMemo(function () { |
|
return store.getState(); |
|
}, [store]); |
|
useIsomorphicLayoutEffect(function () { |
|
var subscription = contextValue.subscription; |
|
subscription.onStateChange = subscription.notifyNestedSubs; |
|
subscription.trySubscribe(); |
|
|
|
if (previousState !== store.getState()) { |
|
subscription.notifyNestedSubs(); |
|
} |
|
|
|
return function () { |
|
subscription.tryUnsubscribe(); |
|
subscription.onStateChange = null; |
|
}; |
|
}, [contextValue, previousState]); |
|
var Context = context || ReactReduxContext; |
|
return /*#__PURE__*/React__default["default"].createElement(Context.Provider, { |
|
value: contextValue |
|
}, children); |
|
} |
|
|
|
{ |
|
Provider.propTypes = { |
|
store: PropTypes.shape({ |
|
subscribe: PropTypes.func.isRequired, |
|
dispatch: PropTypes.func.isRequired, |
|
getState: PropTypes.func.isRequired |
|
}), |
|
context: PropTypes.object, |
|
children: PropTypes.any |
|
}; |
|
} |
|
|
|
function _extends() { |
|
_extends = Object.assign || function (target) { |
|
for (var i = 1; i < arguments.length; i++) { |
|
var source = arguments[i]; |
|
|
|
for (var key in source) { |
|
if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
target[key] = source[key]; |
|
} |
|
} |
|
} |
|
|
|
return target; |
|
}; |
|
|
|
return _extends.apply(this, arguments); |
|
} |
|
|
|
function _objectWithoutPropertiesLoose(source, excluded) { |
|
if (source == null) return {}; |
|
var target = {}; |
|
var sourceKeys = Object.keys(source); |
|
var key, i; |
|
|
|
for (i = 0; i < sourceKeys.length; i++) { |
|
key = sourceKeys[i]; |
|
if (excluded.indexOf(key) >= 0) continue; |
|
target[key] = source[key]; |
|
} |
|
|
|
return target; |
|
} |
|
|
|
var reactIs$2 = {exports: {}}; |
|
|
|
var reactIs_development$1 = {}; |
|
|
|
/** @license React v16.13.1 |
|
* react-is.development.js |
|
* |
|
* Copyright (c) Facebook, Inc. and its affiliates. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
|
|
|
|
{ |
|
(function() { |
|
|
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol |
|
// nor polyfill, then a plain number is used for performance. |
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for; |
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; |
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; |
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; |
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; |
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; |
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; |
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary |
|
// (unstable) APIs that have been removed. Can we remove the symbols? |
|
|
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; |
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; |
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; |
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; |
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; |
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; |
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; |
|
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; |
|
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; |
|
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; |
|
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; |
|
|
|
function isValidElementType(type) { |
|
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. |
|
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 || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); |
|
} |
|
|
|
function typeOf(object) { |
|
if (typeof object === 'object' && object !== null) { |
|
var $$typeof = object.$$typeof; |
|
|
|
switch ($$typeof) { |
|
case REACT_ELEMENT_TYPE: |
|
var type = object.type; |
|
|
|
switch (type) { |
|
case REACT_ASYNC_MODE_TYPE: |
|
case REACT_CONCURRENT_MODE_TYPE: |
|
case REACT_FRAGMENT_TYPE: |
|
case REACT_PROFILER_TYPE: |
|
case REACT_STRICT_MODE_TYPE: |
|
case REACT_SUSPENSE_TYPE: |
|
return type; |
|
|
|
default: |
|
var $$typeofType = type && type.$$typeof; |
|
|
|
switch ($$typeofType) { |
|
case REACT_CONTEXT_TYPE: |
|
case REACT_FORWARD_REF_TYPE: |
|
case REACT_LAZY_TYPE: |
|
case REACT_MEMO_TYPE: |
|
case REACT_PROVIDER_TYPE: |
|
return $$typeofType; |
|
|
|
default: |
|
return $$typeof; |
|
} |
|
|
|
} |
|
|
|
case REACT_PORTAL_TYPE: |
|
return $$typeof; |
|
} |
|
} |
|
|
|
return undefined; |
|
} // AsyncMode is deprecated along with isAsyncMode |
|
|
|
var AsyncMode = REACT_ASYNC_MODE_TYPE; |
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; |
|
var ContextConsumer = REACT_CONTEXT_TYPE; |
|
var ContextProvider = REACT_PROVIDER_TYPE; |
|
var Element = REACT_ELEMENT_TYPE; |
|
var ForwardRef = REACT_FORWARD_REF_TYPE; |
|
var Fragment = REACT_FRAGMENT_TYPE; |
|
var Lazy = REACT_LAZY_TYPE; |
|
var Memo = REACT_MEMO_TYPE; |
|
var Portal = REACT_PORTAL_TYPE; |
|
var Profiler = REACT_PROFILER_TYPE; |
|
var StrictMode = REACT_STRICT_MODE_TYPE; |
|
var Suspense = REACT_SUSPENSE_TYPE; |
|
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated |
|
|
|
function isAsyncMode(object) { |
|
{ |
|
if (!hasWarnedAboutDeprecatedIsAsyncMode) { |
|
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint |
|
|
|
console['warn']('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.'); |
|
} |
|
} |
|
|
|
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; |
|
} |
|
function isConcurrentMode(object) { |
|
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; |
|
} |
|
function isContextConsumer(object) { |
|
return typeOf(object) === REACT_CONTEXT_TYPE; |
|
} |
|
function isContextProvider(object) { |
|
return typeOf(object) === REACT_PROVIDER_TYPE; |
|
} |
|
function isElement(object) { |
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
|
} |
|
function isForwardRef(object) { |
|
return typeOf(object) === REACT_FORWARD_REF_TYPE; |
|
} |
|
function isFragment(object) { |
|
return typeOf(object) === REACT_FRAGMENT_TYPE; |
|
} |
|
function isLazy(object) { |
|
return typeOf(object) === REACT_LAZY_TYPE; |
|
} |
|
function isMemo(object) { |
|
return typeOf(object) === REACT_MEMO_TYPE; |
|
} |
|
function isPortal(object) { |
|
return typeOf(object) === REACT_PORTAL_TYPE; |
|
} |
|
function isProfiler(object) { |
|
return typeOf(object) === REACT_PROFILER_TYPE; |
|
} |
|
function isStrictMode(object) { |
|
return typeOf(object) === REACT_STRICT_MODE_TYPE; |
|
} |
|
function isSuspense(object) { |
|
return typeOf(object) === REACT_SUSPENSE_TYPE; |
|
} |
|
|
|
reactIs_development$1.AsyncMode = AsyncMode; |
|
reactIs_development$1.ConcurrentMode = ConcurrentMode; |
|
reactIs_development$1.ContextConsumer = ContextConsumer; |
|
reactIs_development$1.ContextProvider = ContextProvider; |
|
reactIs_development$1.Element = Element; |
|
reactIs_development$1.ForwardRef = ForwardRef; |
|
reactIs_development$1.Fragment = Fragment; |
|
reactIs_development$1.Lazy = Lazy; |
|
reactIs_development$1.Memo = Memo; |
|
reactIs_development$1.Portal = Portal; |
|
reactIs_development$1.Profiler = Profiler; |
|
reactIs_development$1.StrictMode = StrictMode; |
|
reactIs_development$1.Suspense = Suspense; |
|
reactIs_development$1.isAsyncMode = isAsyncMode; |
|
reactIs_development$1.isConcurrentMode = isConcurrentMode; |
|
reactIs_development$1.isContextConsumer = isContextConsumer; |
|
reactIs_development$1.isContextProvider = isContextProvider; |
|
reactIs_development$1.isElement = isElement; |
|
reactIs_development$1.isForwardRef = isForwardRef; |
|
reactIs_development$1.isFragment = isFragment; |
|
reactIs_development$1.isLazy = isLazy; |
|
reactIs_development$1.isMemo = isMemo; |
|
reactIs_development$1.isPortal = isPortal; |
|
reactIs_development$1.isProfiler = isProfiler; |
|
reactIs_development$1.isStrictMode = isStrictMode; |
|
reactIs_development$1.isSuspense = isSuspense; |
|
reactIs_development$1.isValidElementType = isValidElementType; |
|
reactIs_development$1.typeOf = typeOf; |
|
})(); |
|
} |
|
|
|
{ |
|
reactIs$2.exports = reactIs_development$1; |
|
} |
|
|
|
var reactIs$1 = reactIs$2.exports; |
|
|
|
/** |
|
* Copyright 2015, Yahoo! Inc. |
|
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. |
|
*/ |
|
var REACT_STATICS = { |
|
childContextTypes: true, |
|
contextType: true, |
|
contextTypes: true, |
|
defaultProps: true, |
|
displayName: true, |
|
getDefaultProps: true, |
|
getDerivedStateFromError: true, |
|
getDerivedStateFromProps: true, |
|
mixins: true, |
|
propTypes: true, |
|
type: true |
|
}; |
|
var KNOWN_STATICS = { |
|
name: true, |
|
length: true, |
|
prototype: true, |
|
caller: true, |
|
callee: true, |
|
arguments: true, |
|
arity: true |
|
}; |
|
var FORWARD_REF_STATICS = { |
|
'$$typeof': true, |
|
render: true, |
|
defaultProps: true, |
|
displayName: true, |
|
propTypes: true |
|
}; |
|
var MEMO_STATICS = { |
|
'$$typeof': true, |
|
compare: true, |
|
defaultProps: true, |
|
displayName: true, |
|
propTypes: true, |
|
type: true |
|
}; |
|
var TYPE_STATICS = {}; |
|
TYPE_STATICS[reactIs$1.ForwardRef] = FORWARD_REF_STATICS; |
|
TYPE_STATICS[reactIs$1.Memo] = MEMO_STATICS; |
|
|
|
function getStatics(component) { |
|
// React v16.11 and below |
|
if (reactIs$1.isMemo(component)) { |
|
return MEMO_STATICS; |
|
} // React v16.12 and above |
|
|
|
|
|
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS; |
|
} |
|
|
|
var defineProperty = Object.defineProperty; |
|
var getOwnPropertyNames = Object.getOwnPropertyNames; |
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols; |
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
|
var getPrototypeOf = Object.getPrototypeOf; |
|
var objectPrototype = Object.prototype; |
|
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { |
|
if (typeof sourceComponent !== 'string') { |
|
// don't hoist over string (html) components |
|
if (objectPrototype) { |
|
var inheritedComponent = getPrototypeOf(sourceComponent); |
|
|
|
if (inheritedComponent && inheritedComponent !== objectPrototype) { |
|
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); |
|
} |
|
} |
|
|
|
var keys = getOwnPropertyNames(sourceComponent); |
|
|
|
if (getOwnPropertySymbols) { |
|
keys = keys.concat(getOwnPropertySymbols(sourceComponent)); |
|
} |
|
|
|
var targetStatics = getStatics(targetComponent); |
|
var sourceStatics = getStatics(sourceComponent); |
|
|
|
for (var i = 0; i < keys.length; ++i) { |
|
var key = keys[i]; |
|
|
|
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { |
|
var descriptor = getOwnPropertyDescriptor(sourceComponent, key); |
|
|
|
try { |
|
// Avoid failures from read-only properties |
|
defineProperty(targetComponent, key, descriptor); |
|
} catch (e) {} |
|
} |
|
} |
|
} |
|
|
|
return targetComponent; |
|
} |
|
|
|
var hoistNonReactStatics_cjs = hoistNonReactStatics; |
|
|
|
var reactIs = {exports: {}}; |
|
|
|
var reactIs_development = {}; |
|
|
|
/** @license React v17.0.2 |
|
* react-is.development.js |
|
* |
|
* Copyright (c) Facebook, Inc. and its affiliates. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
{ |
|
(function() { |
|
|
|
// ATTENTION |
|
// When adding new symbols to this file, |
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' |
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol |
|
// nor polyfill, then a plain number is used for performance. |
|
var REACT_ELEMENT_TYPE = 0xeac7; |
|
var REACT_PORTAL_TYPE = 0xeaca; |
|
var REACT_FRAGMENT_TYPE = 0xeacb; |
|
var REACT_STRICT_MODE_TYPE = 0xeacc; |
|
var REACT_PROFILER_TYPE = 0xead2; |
|
var REACT_PROVIDER_TYPE = 0xeacd; |
|
var REACT_CONTEXT_TYPE = 0xeace; |
|
var REACT_FORWARD_REF_TYPE = 0xead0; |
|
var REACT_SUSPENSE_TYPE = 0xead1; |
|
var REACT_SUSPENSE_LIST_TYPE = 0xead8; |
|
var REACT_MEMO_TYPE = 0xead3; |
|
var REACT_LAZY_TYPE = 0xead4; |
|
var REACT_BLOCK_TYPE = 0xead9; |
|
var REACT_SERVER_BLOCK_TYPE = 0xeada; |
|
var REACT_FUNDAMENTAL_TYPE = 0xead5; |
|
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; |
|
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; |
|
|
|
if (typeof Symbol === 'function' && Symbol.for) { |
|
var symbolFor = Symbol.for; |
|
REACT_ELEMENT_TYPE = symbolFor('react.element'); |
|
REACT_PORTAL_TYPE = symbolFor('react.portal'); |
|
REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); |
|
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); |
|
REACT_PROFILER_TYPE = symbolFor('react.profiler'); |
|
REACT_PROVIDER_TYPE = symbolFor('react.provider'); |
|
REACT_CONTEXT_TYPE = symbolFor('react.context'); |
|
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); |
|
REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); |
|
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); |
|
REACT_MEMO_TYPE = symbolFor('react.memo'); |
|
REACT_LAZY_TYPE = symbolFor('react.lazy'); |
|
REACT_BLOCK_TYPE = symbolFor('react.block'); |
|
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); |
|
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); |
|
symbolFor('react.scope'); |
|
symbolFor('react.opaque.id'); |
|
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); |
|
symbolFor('react.offscreen'); |
|
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); |
|
} |
|
|
|
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. |
|
|
|
var enableScopeAPI = false; // Experimental Create Event Handle API. |
|
|
|
function isValidElementType(type) { |
|
if (typeof type === 'string' || typeof type === 'function') { |
|
return true; |
|
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). |
|
|
|
|
|
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { |
|
return true; |
|
} |
|
|
|
if (typeof type === 'object' && type !== null) { |
|
if (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_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { |
|
return true; |
|
} |
|
} |
|
|
|
return false; |
|
} |
|
|
|
function typeOf(object) { |
|
if (typeof object === 'object' && object !== null) { |
|
var $$typeof = object.$$typeof; |
|
|
|
switch ($$typeof) { |
|
case REACT_ELEMENT_TYPE: |
|
var type = object.type; |
|
|
|
switch (type) { |
|
case REACT_FRAGMENT_TYPE: |
|
case REACT_PROFILER_TYPE: |
|
case REACT_STRICT_MODE_TYPE: |
|
case REACT_SUSPENSE_TYPE: |
|
case REACT_SUSPENSE_LIST_TYPE: |
|
return type; |
|
|
|
default: |
|
var $$typeofType = type && type.$$typeof; |
|
|
|
switch ($$typeofType) { |
|
case REACT_CONTEXT_TYPE: |
|
case REACT_FORWARD_REF_TYPE: |
|
case REACT_LAZY_TYPE: |
|
case REACT_MEMO_TYPE: |
|
case REACT_PROVIDER_TYPE: |
|
return $$typeofType; |
|
|
|
default: |
|
return $$typeof; |
|
} |
|
|
|
} |
|
|
|
case REACT_PORTAL_TYPE: |
|
return $$typeof; |
|
} |
|
} |
|
|
|
return undefined; |
|
} |
|
var ContextConsumer = REACT_CONTEXT_TYPE; |
|
var ContextProvider = REACT_PROVIDER_TYPE; |
|
var Element = REACT_ELEMENT_TYPE; |
|
var ForwardRef = REACT_FORWARD_REF_TYPE; |
|
var Fragment = REACT_FRAGMENT_TYPE; |
|
var Lazy = REACT_LAZY_TYPE; |
|
var Memo = REACT_MEMO_TYPE; |
|
var Portal = REACT_PORTAL_TYPE; |
|
var Profiler = REACT_PROFILER_TYPE; |
|
var StrictMode = REACT_STRICT_MODE_TYPE; |
|
var Suspense = REACT_SUSPENSE_TYPE; |
|
var hasWarnedAboutDeprecatedIsAsyncMode = false; |
|
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated |
|
|
|
function isAsyncMode(object) { |
|
{ |
|
if (!hasWarnedAboutDeprecatedIsAsyncMode) { |
|
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint |
|
|
|
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.'); |
|
} |
|
} |
|
|
|
return false; |
|
} |
|
function isConcurrentMode(object) { |
|
{ |
|
if (!hasWarnedAboutDeprecatedIsConcurrentMode) { |
|
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint |
|
|
|
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.'); |
|
} |
|
} |
|
|
|
return false; |
|
} |
|
function isContextConsumer(object) { |
|
return typeOf(object) === REACT_CONTEXT_TYPE; |
|
} |
|
function isContextProvider(object) { |
|
return typeOf(object) === REACT_PROVIDER_TYPE; |
|
} |
|
function isElement(object) { |
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
|
} |
|
function isForwardRef(object) { |
|
return typeOf(object) === REACT_FORWARD_REF_TYPE; |
|
} |
|
function isFragment(object) { |
|
return typeOf(object) === REACT_FRAGMENT_TYPE; |
|
} |
|
function isLazy(object) { |
|
return typeOf(object) === REACT_LAZY_TYPE; |
|
} |
|
function isMemo(object) { |
|
return typeOf(object) === REACT_MEMO_TYPE; |
|
} |
|
function isPortal(object) { |
|
return typeOf(object) === REACT_PORTAL_TYPE; |
|
} |
|
function isProfiler(object) { |
|
return typeOf(object) === REACT_PROFILER_TYPE; |
|
} |
|
function isStrictMode(object) { |
|
return typeOf(object) === REACT_STRICT_MODE_TYPE; |
|
} |
|
function isSuspense(object) { |
|
return typeOf(object) === REACT_SUSPENSE_TYPE; |
|
} |
|
|
|
reactIs_development.ContextConsumer = ContextConsumer; |
|
reactIs_development.ContextProvider = ContextProvider; |
|
reactIs_development.Element = Element; |
|
reactIs_development.ForwardRef = ForwardRef; |
|
reactIs_development.Fragment = Fragment; |
|
reactIs_development.Lazy = Lazy; |
|
reactIs_development.Memo = Memo; |
|
reactIs_development.Portal = Portal; |
|
reactIs_development.Profiler = Profiler; |
|
reactIs_development.StrictMode = StrictMode; |
|
reactIs_development.Suspense = Suspense; |
|
reactIs_development.isAsyncMode = isAsyncMode; |
|
reactIs_development.isConcurrentMode = isConcurrentMode; |
|
reactIs_development.isContextConsumer = isContextConsumer; |
|
reactIs_development.isContextProvider = isContextProvider; |
|
reactIs_development.isElement = isElement; |
|
reactIs_development.isForwardRef = isForwardRef; |
|
reactIs_development.isFragment = isFragment; |
|
reactIs_development.isLazy = isLazy; |
|
reactIs_development.isMemo = isMemo; |
|
reactIs_development.isPortal = isPortal; |
|
reactIs_development.isProfiler = isProfiler; |
|
reactIs_development.isStrictMode = isStrictMode; |
|
reactIs_development.isSuspense = isSuspense; |
|
reactIs_development.isValidElementType = isValidElementType; |
|
reactIs_development.typeOf = typeOf; |
|
})(); |
|
} |
|
|
|
{ |
|
reactIs.exports = reactIs_development; |
|
} |
|
|
|
var _excluded$2 = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"], |
|
_excluded2 = ["reactReduxForwardedRef"]; |
|
|
|
var EMPTY_ARRAY = []; |
|
var NO_SUBSCRIPTION_ARRAY = [null, null]; |
|
|
|
var stringifyComponent = function stringifyComponent(Comp) { |
|
try { |
|
return JSON.stringify(Comp); |
|
} catch (err) { |
|
return String(Comp); |
|
} |
|
}; |
|
|
|
function storeStateUpdatesReducer(state, action) { |
|
var updateCount = state[1]; |
|
return [action.payload, updateCount + 1]; |
|
} |
|
|
|
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) { |
|
useIsomorphicLayoutEffect(function () { |
|
return effectFunc.apply(void 0, effectArgs); |
|
}, dependencies); |
|
} |
|
|
|
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) { |
|
// We want to capture the wrapper props and child props we used for later comparisons |
|
lastWrapperProps.current = wrapperProps; |
|
lastChildProps.current = actualChildProps; |
|
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update |
|
|
|
if (childPropsFromStoreUpdate.current) { |
|
childPropsFromStoreUpdate.current = null; |
|
notifyNestedSubs(); |
|
} |
|
} |
|
|
|
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) { |
|
// If we're not subscribed to the store, nothing to do here |
|
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts |
|
|
|
var didUnsubscribe = false; |
|
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component |
|
|
|
var checkForUpdates = function checkForUpdates() { |
|
if (didUnsubscribe) { |
|
// Don't run stale listeners. |
|
// Redux doesn't guarantee unsubscriptions happen until next dispatch. |
|
return; |
|
} |
|
|
|
var latestStoreState = store.getState(); |
|
var newChildProps, error; |
|
|
|
try { |
|
// Actually run the selector with the most recent store state and wrapper props |
|
// to determine what the child props should be |
|
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current); |
|
} catch (e) { |
|
error = e; |
|
lastThrownError = e; |
|
} |
|
|
|
if (!error) { |
|
lastThrownError = null; |
|
} // If the child props haven't changed, nothing to do here - cascade the subscription update |
|
|
|
|
|
if (newChildProps === lastChildProps.current) { |
|
if (!renderIsScheduled.current) { |
|
notifyNestedSubs(); |
|
} |
|
} else { |
|
// Save references to the new child props. Note that we track the "child props from store update" |
|
// as a ref instead of a useState/useReducer because we need a way to determine if that value has |
|
// been processed. If this went into useState/useReducer, we couldn't clear out the value without |
|
// forcing another re-render, which we don't want. |
|
lastChildProps.current = newChildProps; |
|
childPropsFromStoreUpdate.current = newChildProps; |
|
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render |
|
|
|
forceComponentUpdateDispatch({ |
|
type: 'STORE_UPDATED', |
|
payload: { |
|
error: error |
|
} |
|
}); |
|
} |
|
}; // Actually subscribe to the nearest connected ancestor (or store) |
|
|
|
|
|
subscription.onStateChange = checkForUpdates; |
|
subscription.trySubscribe(); // Pull data from the store after first render in case the store has |
|
// changed since we began. |
|
|
|
checkForUpdates(); |
|
|
|
var unsubscribeWrapper = function unsubscribeWrapper() { |
|
didUnsubscribe = true; |
|
subscription.tryUnsubscribe(); |
|
subscription.onStateChange = null; |
|
|
|
if (lastThrownError) { |
|
// It's possible that we caught an error due to a bad mapState function, but the |
|
// parent re-rendered without this component and we're about to unmount. |
|
// This shouldn't happen as long as we do top-down subscriptions correctly, but |
|
// if we ever do those wrong, this throw will surface the error in our tests. |
|
// In that case, throw the error from here so it doesn't get lost. |
|
throw lastThrownError; |
|
} |
|
}; |
|
|
|
return unsubscribeWrapper; |
|
} |
|
|
|
var initStateUpdates = function initStateUpdates() { |
|
return [null, 0]; |
|
}; |
|
|
|
function connectAdvanced( |
|
/* |
|
selectorFactory is a func that is responsible for returning the selector function used to |
|
compute new props from state, props, and dispatch. For example: |
|
export default connectAdvanced((dispatch, options) => (state, props) => ({ |
|
thing: state.things[props.thingId], |
|
saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)), |
|
}))(YourComponent) |
|
Access to dispatch is provided to the factory so selectorFactories can bind actionCreators |
|
outside of their selector as an optimization. Options passed to connectAdvanced are passed to |
|
the selectorFactory, along with displayName and WrappedComponent, as the second argument. |
|
Note that selectorFactory is responsible for all caching/memoization of inbound and outbound |
|
props. Do not use connectAdvanced directly without memoizing results between calls to your |
|
selector, otherwise the Connect component will re-render on every state or props change. |
|
*/ |
|
selectorFactory, // options object: |
|
_ref) { |
|
if (_ref === void 0) { |
|
_ref = {}; |
|
} |
|
|
|
var _ref2 = _ref, |
|
_ref2$getDisplayName = _ref2.getDisplayName, |
|
getDisplayName = _ref2$getDisplayName === void 0 ? function (name) { |
|
return "ConnectAdvanced(" + name + ")"; |
|
} : _ref2$getDisplayName, |
|
_ref2$methodName = _ref2.methodName, |
|
methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName, |
|
_ref2$renderCountProp = _ref2.renderCountProp, |
|
renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp, |
|
_ref2$shouldHandleSta = _ref2.shouldHandleStateChanges, |
|
shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta, |
|
_ref2$storeKey = _ref2.storeKey, |
|
storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey, |
|
_ref2$withRef = _ref2.withRef, |
|
withRef = _ref2$withRef === void 0 ? false : _ref2$withRef, |
|
_ref2$forwardRef = _ref2.forwardRef, |
|
forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef, |
|
_ref2$context = _ref2.context, |
|
context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context, |
|
connectOptions = _objectWithoutPropertiesLoose(_ref2, _excluded$2); |
|
|
|
{ |
|
if (renderCountProp !== undefined) { |
|
throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension"); |
|
} |
|
|
|
if (withRef) { |
|
throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component'); |
|
} |
|
|
|
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect'; |
|
|
|
if (storeKey !== 'store') { |
|
throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage); |
|
} |
|
} |
|
|
|
var Context = context; |
|
return function wrapWithConnect(WrappedComponent) { |
|
if (!reactIs.exports.isValidElementType(WrappedComponent)) { |
|
throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent))); |
|
} |
|
|
|
var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; |
|
var displayName = getDisplayName(wrappedComponentName); |
|
|
|
var selectorFactoryOptions = _extends({}, connectOptions, { |
|
getDisplayName: getDisplayName, |
|
methodName: methodName, |
|
renderCountProp: renderCountProp, |
|
shouldHandleStateChanges: shouldHandleStateChanges, |
|
storeKey: storeKey, |
|
displayName: displayName, |
|
wrappedComponentName: wrappedComponentName, |
|
WrappedComponent: WrappedComponent |
|
}); |
|
|
|
var pure = connectOptions.pure; |
|
|
|
function createChildSelector(store) { |
|
return selectorFactory(store.dispatch, selectorFactoryOptions); |
|
} // If we aren't running in "pure" mode, we don't want to memoize values. |
|
// To avoid conditionally calling hooks, we fall back to a tiny wrapper |
|
// that just executes the given callback immediately. |
|
|
|
|
|
var usePureOnlyMemo = pure ? React.useMemo : function (callback) { |
|
return callback(); |
|
}; |
|
|
|
function ConnectFunction(props) { |
|
var _useMemo = React.useMemo(function () { |
|
// Distinguish between actual "data" props that were passed to the wrapper component, |
|
// and values needed to control behavior (forwarded refs, alternate context instances). |
|
// To maintain the wrapperProps object reference, memoize this destructuring. |
|
var reactReduxForwardedRef = props.reactReduxForwardedRef, |
|
wrapperProps = _objectWithoutPropertiesLoose(props, _excluded2); |
|
|
|
return [props.context, reactReduxForwardedRef, wrapperProps]; |
|
}, [props]), |
|
propsContext = _useMemo[0], |
|
reactReduxForwardedRef = _useMemo[1], |
|
wrapperProps = _useMemo[2]; |
|
|
|
var ContextToUse = React.useMemo(function () { |
|
// Users may optionally pass in a custom context instance to use instead of our ReactReduxContext. |
|
// Memoize the check that determines which context instance we should use. |
|
return propsContext && propsContext.Consumer && reactIs.exports.isContextConsumer( /*#__PURE__*/React__default["default"].createElement(propsContext.Consumer, null)) ? propsContext : Context; |
|
}, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available |
|
|
|
var contextValue = React.useContext(ContextToUse); // The store _must_ exist as either a prop or in context. |
|
// We'll check to see if it _looks_ like a Redux store first. |
|
// This allows us to pass through a `store` prop that is just a plain value. |
|
|
|
var didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch); |
|
var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store); |
|
|
|
if (!didStoreComeFromProps && !didStoreComeFromContext) { |
|
throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options.")); |
|
} // Based on the previous check, one of these must be true |
|
|
|
|
|
var store = didStoreComeFromProps ? props.store : contextValue.store; |
|
var childPropsSelector = React.useMemo(function () { |
|
// The child props selector needs the store reference as an input. |
|
// Re-create this selector whenever the store changes. |
|
return createChildSelector(store); |
|
}, [store]); |
|
|
|
var _useMemo2 = React.useMemo(function () { |
|
if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY; // This Subscription's source should match where store came from: props vs. context. A component |
|
// connected to the store via props shouldn't use subscription from context, or vice versa. |
|
|
|
// This Subscription's source should match where store came from: props vs. context. A component |
|
// connected to the store via props shouldn't use subscription from context, or vice versa. |
|
var subscription = createSubscription(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in |
|
// the middle of the notification loop, where `subscription` will then be null. This can |
|
// probably be avoided if Subscription's listeners logic is changed to not call listeners |
|
// that have been unsubscribed in the middle of the notification loop. |
|
|
|
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in |
|
// the middle of the notification loop, where `subscription` will then be null. This can |
|
// probably be avoided if Subscription's listeners logic is changed to not call listeners |
|
// that have been unsubscribed in the middle of the notification loop. |
|
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription); |
|
return [subscription, notifyNestedSubs]; |
|
}, [store, didStoreComeFromProps, contextValue]), |
|
subscription = _useMemo2[0], |
|
notifyNestedSubs = _useMemo2[1]; // Determine what {store, subscription} value should be put into nested context, if necessary, |
|
// and memoize that value to avoid unnecessary context updates. |
|
|
|
|
|
var overriddenContextValue = React.useMemo(function () { |
|
if (didStoreComeFromProps) { |
|
// This component is directly subscribed to a store from props. |
|
// We don't want descendants reading from this store - pass down whatever |
|
// the existing context value is from the nearest connected ancestor. |
|
return contextValue; |
|
} // Otherwise, put this component's subscription instance into context, so that |
|
// connected descendants won't update until after this component is done |
|
|
|
|
|
return _extends({}, contextValue, { |
|
subscription: subscription |
|
}); |
|
}, [didStoreComeFromProps, contextValue, subscription]); // We need to force this wrapper component to re-render whenever a Redux store update |
|
// causes a change to the calculated child component props (or we caught an error in mapState) |
|
|
|
var _useReducer = React.useReducer(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates), |
|
_useReducer$ = _useReducer[0], |
|
previousStateUpdateResult = _useReducer$[0], |
|
forceComponentUpdateDispatch = _useReducer[1]; // Propagate any mapState/mapDispatch errors upwards |
|
|
|
|
|
if (previousStateUpdateResult && previousStateUpdateResult.error) { |
|
throw previousStateUpdateResult.error; |
|
} // Set up refs to coordinate values between the subscription effect and the render logic |
|
|
|
|
|
var lastChildProps = React.useRef(); |
|
var lastWrapperProps = React.useRef(wrapperProps); |
|
var childPropsFromStoreUpdate = React.useRef(); |
|
var renderIsScheduled = React.useRef(false); |
|
var actualChildProps = usePureOnlyMemo(function () { |
|
// Tricky logic here: |
|
// - This render may have been triggered by a Redux store update that produced new child props |
|
// - However, we may have gotten new wrapper props after that |
|
// If we have new child props, and the same wrapper props, we know we should use the new child props as-is. |
|
// But, if we have new wrapper props, those might change the child props, so we have to recalculate things. |
|
// So, we'll use the child props from store update only if the wrapper props are the same as last time. |
|
if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) { |
|
return childPropsFromStoreUpdate.current; |
|
} // TODO We're reading the store directly in render() here. Bad idea? |
|
// This will likely cause Bad Things (TM) to happen in Concurrent Mode. |
|
// Note that we do this because on renders _not_ caused by store updates, we need the latest store state |
|
// to determine what the child props should be. |
|
|
|
|
|
return childPropsSelector(store.getState(), wrapperProps); |
|
}, [store, previousStateUpdateResult, wrapperProps]); // We need this to execute synchronously every time we re-render. However, React warns |
|
// about useLayoutEffect in SSR, so we try to detect environment and fall back to |
|
// just useEffect instead to avoid the warning, since neither will run anyway. |
|
|
|
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes |
|
|
|
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component. |
|
// We memoize the elements for the rendered child component as an optimization. |
|
|
|
var renderedWrappedComponent = React.useMemo(function () { |
|
return /*#__PURE__*/React__default["default"].createElement(WrappedComponent, _extends({}, actualChildProps, { |
|
ref: reactReduxForwardedRef |
|
})); |
|
}, [reactReduxForwardedRef, WrappedComponent, actualChildProps]); // If React sees the exact same element reference as last time, it bails out of re-rendering |
|
// that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate. |
|
|
|
var renderedChild = React.useMemo(function () { |
|
if (shouldHandleStateChanges) { |
|
// If this component is subscribed to store updates, we need to pass its own |
|
// subscription instance down to our descendants. That means rendering the same |
|
// Context instance, and putting a different value into the context. |
|
return /*#__PURE__*/React__default["default"].createElement(ContextToUse.Provider, { |
|
value: overriddenContextValue |
|
}, renderedWrappedComponent); |
|
} |
|
|
|
return renderedWrappedComponent; |
|
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]); |
|
return renderedChild; |
|
} // If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed. |
|
|
|
|
|
var Connect = pure ? React__default["default"].memo(ConnectFunction) : ConnectFunction; |
|
Connect.WrappedComponent = WrappedComponent; |
|
Connect.displayName = ConnectFunction.displayName = displayName; |
|
|
|
if (forwardRef) { |
|
var forwarded = React__default["default"].forwardRef(function forwardConnectRef(props, ref) { |
|
return /*#__PURE__*/React__default["default"].createElement(Connect, _extends({}, props, { |
|
reactReduxForwardedRef: ref |
|
})); |
|
}); |
|
forwarded.displayName = displayName; |
|
forwarded.WrappedComponent = WrappedComponent; |
|
return hoistNonReactStatics_cjs(forwarded, WrappedComponent); |
|
} |
|
|
|
return hoistNonReactStatics_cjs(Connect, WrappedComponent); |
|
}; |
|
} |
|
|
|
function is(x, y) { |
|
if (x === y) { |
|
return x !== 0 || y !== 0 || 1 / x === 1 / y; |
|
} else { |
|
return x !== x && y !== y; |
|
} |
|
} |
|
|
|
function shallowEqual(objA, objB) { |
|
if (is(objA, objB)) return true; |
|
|
|
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { |
|
return false; |
|
} |
|
|
|
var keysA = Object.keys(objA); |
|
var keysB = Object.keys(objB); |
|
if (keysA.length !== keysB.length) return false; |
|
|
|
for (var i = 0; i < keysA.length; i++) { |
|
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { |
|
return false; |
|
} |
|
} |
|
|
|
return true; |
|
} |
|
|
|
function bindActionCreators(actionCreators, dispatch) { |
|
var boundActionCreators = {}; |
|
|
|
var _loop = function _loop(key) { |
|
var actionCreator = actionCreators[key]; |
|
|
|
if (typeof actionCreator === 'function') { |
|
boundActionCreators[key] = function () { |
|
return dispatch(actionCreator.apply(void 0, arguments)); |
|
}; |
|
} |
|
}; |
|
|
|
for (var key in actionCreators) { |
|
_loop(key); |
|
} |
|
|
|
return boundActionCreators; |
|
} |
|
|
|
/** |
|
* @param {any} obj The object to inspect. |
|
* @returns {boolean} True if the argument appears to be a plain object. |
|
*/ |
|
function isPlainObject(obj) { |
|
if (typeof obj !== 'object' || obj === null) return false; |
|
var proto = Object.getPrototypeOf(obj); |
|
if (proto === null) return true; |
|
var baseProto = proto; |
|
|
|
while (Object.getPrototypeOf(baseProto) !== null) { |
|
baseProto = Object.getPrototypeOf(baseProto); |
|
} |
|
|
|
return proto === baseProto; |
|
} |
|
|
|
/** |
|
* Prints a warning in the console if it exists. |
|
* |
|
* @param {String} message The warning message. |
|
* @returns {void} |
|
*/ |
|
function warning(message) { |
|
/* eslint-disable no-console */ |
|
if (typeof console !== 'undefined' && typeof console.error === 'function') { |
|
console.error(message); |
|
} |
|
/* eslint-enable no-console */ |
|
|
|
|
|
try { |
|
// This error was thrown as a convenience so that if you enable |
|
// "break on all exceptions" in your console, |
|
// it would pause the execution at this line. |
|
throw new Error(message); |
|
/* eslint-disable no-empty */ |
|
} catch (e) {} |
|
/* eslint-enable no-empty */ |
|
|
|
} |
|
|
|
function verifyPlainObject(value, displayName, methodName) { |
|
if (!isPlainObject(value)) { |
|
warning(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + "."); |
|
} |
|
} |
|
|
|
function wrapMapToPropsConstant(getConstant) { |
|
return function initConstantSelector(dispatch, options) { |
|
var constant = getConstant(dispatch, options); |
|
|
|
function constantSelector() { |
|
return constant; |
|
} |
|
|
|
constantSelector.dependsOnOwnProps = false; |
|
return constantSelector; |
|
}; |
|
} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args |
|
// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine |
|
// whether mapToProps needs to be invoked when props have changed. |
|
// |
|
// A length of one signals that mapToProps does not depend on props from the parent component. |
|
// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and |
|
// therefore not reporting its length accurately.. |
|
|
|
function getDependsOnOwnProps(mapToProps) { |
|
return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; |
|
} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction, |
|
// this function wraps mapToProps in a proxy function which does several things: |
|
// |
|
// * Detects whether the mapToProps function being called depends on props, which |
|
// is used by selectorFactory to decide if it should reinvoke on props changes. |
|
// |
|
// * On first call, handles mapToProps if returns another function, and treats that |
|
// new function as the true mapToProps for subsequent calls. |
|
// |
|
// * On first call, verifies the first result is a plain object, in order to warn |
|
// the developer that their mapToProps function is not returning a valid result. |
|
// |
|
|
|
function wrapMapToPropsFunc(mapToProps, methodName) { |
|
return function initProxySelector(dispatch, _ref) { |
|
var displayName = _ref.displayName; |
|
|
|
var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) { |
|
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch); |
|
}; // allow detectFactoryAndVerify to get ownProps |
|
|
|
|
|
proxy.dependsOnOwnProps = true; |
|
|
|
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) { |
|
proxy.mapToProps = mapToProps; |
|
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps); |
|
var props = proxy(stateOrDispatch, ownProps); |
|
|
|
if (typeof props === 'function') { |
|
proxy.mapToProps = props; |
|
proxy.dependsOnOwnProps = getDependsOnOwnProps(props); |
|
props = proxy(stateOrDispatch, ownProps); |
|
} |
|
|
|
verifyPlainObject(props, displayName, methodName); |
|
return props; |
|
}; |
|
|
|
return proxy; |
|
}; |
|
} |
|
|
|
function whenMapDispatchToPropsIsFunction(mapDispatchToProps) { |
|
return typeof mapDispatchToProps === 'function' ? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : undefined; |
|
} |
|
function whenMapDispatchToPropsIsMissing(mapDispatchToProps) { |
|
return !mapDispatchToProps ? wrapMapToPropsConstant(function (dispatch) { |
|
return { |
|
dispatch: dispatch |
|
}; |
|
}) : undefined; |
|
} |
|
function whenMapDispatchToPropsIsObject(mapDispatchToProps) { |
|
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(function (dispatch) { |
|
return bindActionCreators(mapDispatchToProps, dispatch); |
|
}) : undefined; |
|
} |
|
var defaultMapDispatchToPropsFactories = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject]; |
|
|
|
function whenMapStateToPropsIsFunction(mapStateToProps) { |
|
return typeof mapStateToProps === 'function' ? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : undefined; |
|
} |
|
function whenMapStateToPropsIsMissing(mapStateToProps) { |
|
return !mapStateToProps ? wrapMapToPropsConstant(function () { |
|
return {}; |
|
}) : undefined; |
|
} |
|
var defaultMapStateToPropsFactories = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]; |
|
|
|
function defaultMergeProps(stateProps, dispatchProps, ownProps) { |
|
return _extends({}, ownProps, stateProps, dispatchProps); |
|
} |
|
function wrapMergePropsFunc(mergeProps) { |
|
return function initMergePropsProxy(dispatch, _ref) { |
|
var displayName = _ref.displayName, |
|
pure = _ref.pure, |
|
areMergedPropsEqual = _ref.areMergedPropsEqual; |
|
var hasRunOnce = false; |
|
var mergedProps; |
|
return function mergePropsProxy(stateProps, dispatchProps, ownProps) { |
|
var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
|
|
if (hasRunOnce) { |
|
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps; |
|
} else { |
|
hasRunOnce = true; |
|
mergedProps = nextMergedProps; |
|
verifyPlainObject(mergedProps, displayName, 'mergeProps'); |
|
} |
|
|
|
return mergedProps; |
|
}; |
|
}; |
|
} |
|
function whenMergePropsIsFunction(mergeProps) { |
|
return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined; |
|
} |
|
function whenMergePropsIsOmitted(mergeProps) { |
|
return !mergeProps ? function () { |
|
return defaultMergeProps; |
|
} : undefined; |
|
} |
|
var defaultMergePropsFactories = [whenMergePropsIsFunction, whenMergePropsIsOmitted]; |
|
|
|
function verify(selector, methodName, displayName) { |
|
if (!selector) { |
|
throw new Error("Unexpected value for " + methodName + " in " + displayName + "."); |
|
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') { |
|
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) { |
|
warning("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps."); |
|
} |
|
} |
|
} |
|
|
|
function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) { |
|
verify(mapStateToProps, 'mapStateToProps', displayName); |
|
verify(mapDispatchToProps, 'mapDispatchToProps', displayName); |
|
verify(mergeProps, 'mergeProps', displayName); |
|
} |
|
|
|
var _excluded$1 = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]; |
|
function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) { |
|
return function impureFinalPropsSelector(state, ownProps) { |
|
return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps); |
|
}; |
|
} |
|
function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) { |
|
var areStatesEqual = _ref.areStatesEqual, |
|
areOwnPropsEqual = _ref.areOwnPropsEqual, |
|
areStatePropsEqual = _ref.areStatePropsEqual; |
|
var hasRunAtLeastOnce = false; |
|
var state; |
|
var ownProps; |
|
var stateProps; |
|
var dispatchProps; |
|
var mergedProps; |
|
|
|
function handleFirstCall(firstState, firstOwnProps) { |
|
state = firstState; |
|
ownProps = firstOwnProps; |
|
stateProps = mapStateToProps(state, ownProps); |
|
dispatchProps = mapDispatchToProps(dispatch, ownProps); |
|
mergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
hasRunAtLeastOnce = true; |
|
return mergedProps; |
|
} |
|
|
|
function handleNewPropsAndNewState() { |
|
stateProps = mapStateToProps(state, ownProps); |
|
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); |
|
mergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
return mergedProps; |
|
} |
|
|
|
function handleNewProps() { |
|
if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps); |
|
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); |
|
mergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
return mergedProps; |
|
} |
|
|
|
function handleNewState() { |
|
var nextStateProps = mapStateToProps(state, ownProps); |
|
var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps); |
|
stateProps = nextStateProps; |
|
if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
return mergedProps; |
|
} |
|
|
|
function handleSubsequentCalls(nextState, nextOwnProps) { |
|
var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps); |
|
var stateChanged = !areStatesEqual(nextState, state); |
|
state = nextState; |
|
ownProps = nextOwnProps; |
|
if (propsChanged && stateChanged) return handleNewPropsAndNewState(); |
|
if (propsChanged) return handleNewProps(); |
|
if (stateChanged) return handleNewState(); |
|
return mergedProps; |
|
} |
|
|
|
return function pureFinalPropsSelector(nextState, nextOwnProps) { |
|
return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps); |
|
}; |
|
} // TODO: Add more comments |
|
// If pure is true, the selector returned by selectorFactory will memoize its results, |
|
// allowing connectAdvanced's shouldComponentUpdate to return false if final |
|
// props have not changed. If false, the selector will always return a new |
|
// object and shouldComponentUpdate will always return true. |
|
|
|
function finalPropsSelectorFactory(dispatch, _ref2) { |
|
var initMapStateToProps = _ref2.initMapStateToProps, |
|
initMapDispatchToProps = _ref2.initMapDispatchToProps, |
|
initMergeProps = _ref2.initMergeProps, |
|
options = _objectWithoutPropertiesLoose(_ref2, _excluded$1); |
|
|
|
var mapStateToProps = initMapStateToProps(dispatch, options); |
|
var mapDispatchToProps = initMapDispatchToProps(dispatch, options); |
|
var mergeProps = initMergeProps(dispatch, options); |
|
|
|
{ |
|
verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); |
|
} |
|
|
|
var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; |
|
return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); |
|
} |
|
|
|
var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]; |
|
/* |
|
connect is a facade over connectAdvanced. It turns its args into a compatible |
|
selectorFactory, which has the signature: |
|
|
|
(dispatch, options) => (nextState, nextOwnProps) => nextFinalProps |
|
|
|
connect passes its args to connectAdvanced as options, which will in turn pass them to |
|
selectorFactory each time a Connect component instance is instantiated or hot reloaded. |
|
|
|
selectorFactory returns a final props selector from its mapStateToProps, |
|
mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps, |
|
mergePropsFactories, and pure args. |
|
|
|
The resulting final props selector is called by the Connect component instance whenever |
|
it receives new props or store state. |
|
*/ |
|
|
|
function match(arg, factories, name) { |
|
for (var i = factories.length - 1; i >= 0; i--) { |
|
var result = factories[i](arg); |
|
if (result) return result; |
|
} |
|
|
|
return function (dispatch, options) { |
|
throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + "."); |
|
}; |
|
} |
|
|
|
function strictEqual(a, b) { |
|
return a === b; |
|
} // createConnect with default args builds the 'official' connect behavior. Calling it with |
|
// different options opens up some testing and extensibility scenarios |
|
|
|
|
|
function createConnect(_temp) { |
|
var _ref = _temp === void 0 ? {} : _temp, |
|
_ref$connectHOC = _ref.connectHOC, |
|
connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC, |
|
_ref$mapStateToPropsF = _ref.mapStateToPropsFactories, |
|
mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? defaultMapStateToPropsFactories : _ref$mapStateToPropsF, |
|
_ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, |
|
mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? defaultMapDispatchToPropsFactories : _ref$mapDispatchToPro, |
|
_ref$mergePropsFactor = _ref.mergePropsFactories, |
|
mergePropsFactories = _ref$mergePropsFactor === void 0 ? defaultMergePropsFactories : _ref$mergePropsFactor, |
|
_ref$selectorFactory = _ref.selectorFactory, |
|
selectorFactory = _ref$selectorFactory === void 0 ? finalPropsSelectorFactory : _ref$selectorFactory; |
|
|
|
return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) { |
|
if (_ref2 === void 0) { |
|
_ref2 = {}; |
|
} |
|
|
|
var _ref3 = _ref2, |
|
_ref3$pure = _ref3.pure, |
|
pure = _ref3$pure === void 0 ? true : _ref3$pure, |
|
_ref3$areStatesEqual = _ref3.areStatesEqual, |
|
areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual, |
|
_ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual, |
|
areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua, |
|
_ref3$areStatePropsEq = _ref3.areStatePropsEqual, |
|
areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq, |
|
_ref3$areMergedPropsE = _ref3.areMergedPropsEqual, |
|
areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE, |
|
extraOptions = _objectWithoutPropertiesLoose(_ref3, _excluded); |
|
|
|
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); |
|
var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); |
|
var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); |
|
return connectHOC(selectorFactory, _extends({ |
|
// used in error messages |
|
methodName: 'connect', |
|
// used to compute Connect's displayName from the wrapped component's displayName. |
|
getDisplayName: function getDisplayName(name) { |
|
return "Connect(" + name + ")"; |
|
}, |
|
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes |
|
shouldHandleStateChanges: Boolean(mapStateToProps), |
|
// passed through to selectorFactory |
|
initMapStateToProps: initMapStateToProps, |
|
initMapDispatchToProps: initMapDispatchToProps, |
|
initMergeProps: initMergeProps, |
|
pure: pure, |
|
areStatesEqual: areStatesEqual, |
|
areOwnPropsEqual: areOwnPropsEqual, |
|
areStatePropsEqual: areStatePropsEqual, |
|
areMergedPropsEqual: areMergedPropsEqual |
|
}, extraOptions)); |
|
}; |
|
} |
|
var connect = /*#__PURE__*/createConnect(); |
|
|
|
/** |
|
* A hook to access the value of the `ReactReduxContext`. This is a low-level |
|
* hook that you should usually not need to call directly. |
|
* |
|
* @returns {any} the value of the `ReactReduxContext` |
|
* |
|
* @example |
|
* |
|
* import React from 'react' |
|
* import { useReduxContext } from 'react-redux' |
|
* |
|
* export const CounterComponent = ({ value }) => { |
|
* const { store } = useReduxContext() |
|
* return <div>{store.getState()}</div> |
|
* } |
|
*/ |
|
|
|
function useReduxContext() { |
|
var contextValue = React.useContext(ReactReduxContext); |
|
|
|
if (!contextValue) { |
|
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>'); |
|
} |
|
|
|
return contextValue; |
|
} |
|
|
|
/** |
|
* Hook factory, which creates a `useStore` hook bound to a given context. |
|
* |
|
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`. |
|
* @returns {Function} A `useStore` hook bound to the specified context. |
|
*/ |
|
|
|
function createStoreHook(context) { |
|
if (context === void 0) { |
|
context = ReactReduxContext; |
|
} |
|
|
|
var useReduxContext$1 = context === ReactReduxContext ? useReduxContext : function () { |
|
return React.useContext(context); |
|
}; |
|
return function useStore() { |
|
var _useReduxContext = useReduxContext$1(), |
|
store = _useReduxContext.store; |
|
|
|
return store; |
|
}; |
|
} |
|
/** |
|
* A hook to access the redux store. |
|
* |
|
* @returns {any} the redux store |
|
* |
|
* @example |
|
* |
|
* import React from 'react' |
|
* import { useStore } from 'react-redux' |
|
* |
|
* export const ExampleComponent = () => { |
|
* const store = useStore() |
|
* return <div>{store.getState()}</div> |
|
* } |
|
*/ |
|
|
|
var useStore = /*#__PURE__*/createStoreHook(); |
|
|
|
/** |
|
* Hook factory, which creates a `useDispatch` hook bound to a given context. |
|
* |
|
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`. |
|
* @returns {Function} A `useDispatch` hook bound to the specified context. |
|
*/ |
|
|
|
function createDispatchHook(context) { |
|
if (context === void 0) { |
|
context = ReactReduxContext; |
|
} |
|
|
|
var useStore$1 = context === ReactReduxContext ? useStore : createStoreHook(context); |
|
return function useDispatch() { |
|
var store = useStore$1(); |
|
return store.dispatch; |
|
}; |
|
} |
|
/** |
|
* A hook to access the redux `dispatch` function. |
|
* |
|
* @returns {any|function} redux store's `dispatch` function |
|
* |
|
* @example |
|
* |
|
* import React, { useCallback } from 'react' |
|
* import { useDispatch } from 'react-redux' |
|
* |
|
* export const CounterComponent = ({ value }) => { |
|
* const dispatch = useDispatch() |
|
* const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), []) |
|
* return ( |
|
* <div> |
|
* <span>{value}</span> |
|
* <button onClick={increaseCounter}>Increase counter</button> |
|
* </div> |
|
* ) |
|
* } |
|
*/ |
|
|
|
var useDispatch = /*#__PURE__*/createDispatchHook(); |
|
|
|
var refEquality = function refEquality(a, b) { |
|
return a === b; |
|
}; |
|
|
|
function useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub) { |
|
var _useReducer = React.useReducer(function (s) { |
|
return s + 1; |
|
}, 0), |
|
forceRender = _useReducer[1]; |
|
|
|
var subscription = React.useMemo(function () { |
|
return createSubscription(store, contextSub); |
|
}, [store, contextSub]); |
|
var latestSubscriptionCallbackError = React.useRef(); |
|
var latestSelector = React.useRef(); |
|
var latestStoreState = React.useRef(); |
|
var latestSelectedState = React.useRef(); |
|
var storeState = store.getState(); |
|
var selectedState; |
|
|
|
try { |
|
if (selector !== latestSelector.current || storeState !== latestStoreState.current || latestSubscriptionCallbackError.current) { |
|
var newSelectedState = selector(storeState); // ensure latest selected state is reused so that a custom equality function can result in identical references |
|
|
|
if (latestSelectedState.current === undefined || !equalityFn(newSelectedState, latestSelectedState.current)) { |
|
selectedState = newSelectedState; |
|
} else { |
|
selectedState = latestSelectedState.current; |
|
} |
|
} else { |
|
selectedState = latestSelectedState.current; |
|
} |
|
} catch (err) { |
|
if (latestSubscriptionCallbackError.current) { |
|
err.message += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\n"; |
|
} |
|
|
|
throw err; |
|
} |
|
|
|
useIsomorphicLayoutEffect(function () { |
|
latestSelector.current = selector; |
|
latestStoreState.current = storeState; |
|
latestSelectedState.current = selectedState; |
|
latestSubscriptionCallbackError.current = undefined; |
|
}); |
|
useIsomorphicLayoutEffect(function () { |
|
function checkForUpdates() { |
|
try { |
|
var newStoreState = store.getState(); // Avoid calling selector multiple times if the store's state has not changed |
|
|
|
if (newStoreState === latestStoreState.current) { |
|
return; |
|
} |
|
|
|
var _newSelectedState = latestSelector.current(newStoreState); |
|
|
|
if (equalityFn(_newSelectedState, latestSelectedState.current)) { |
|
return; |
|
} |
|
|
|
latestSelectedState.current = _newSelectedState; |
|
latestStoreState.current = newStoreState; |
|
} catch (err) { |
|
// we ignore all errors here, since when the component |
|
// is re-rendered, the selectors are called again, and |
|
// will throw again, if neither props nor store state |
|
// changed |
|
latestSubscriptionCallbackError.current = err; |
|
} |
|
|
|
forceRender(); |
|
} |
|
|
|
subscription.onStateChange = checkForUpdates; |
|
subscription.trySubscribe(); |
|
checkForUpdates(); |
|
return function () { |
|
return subscription.tryUnsubscribe(); |
|
}; |
|
}, [store, subscription]); |
|
return selectedState; |
|
} |
|
/** |
|
* Hook factory, which creates a `useSelector` hook bound to a given context. |
|
* |
|
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`. |
|
* @returns {Function} A `useSelector` hook bound to the specified context. |
|
*/ |
|
|
|
|
|
function createSelectorHook(context) { |
|
if (context === void 0) { |
|
context = ReactReduxContext; |
|
} |
|
|
|
var useReduxContext$1 = context === ReactReduxContext ? useReduxContext : function () { |
|
return React.useContext(context); |
|
}; |
|
return function useSelector(selector, equalityFn) { |
|
if (equalityFn === void 0) { |
|
equalityFn = refEquality; |
|
} |
|
|
|
{ |
|
if (!selector) { |
|
throw new Error("You must pass a selector to useSelector"); |
|
} |
|
|
|
if (typeof selector !== 'function') { |
|
throw new Error("You must pass a function as a selector to useSelector"); |
|
} |
|
|
|
if (typeof equalityFn !== 'function') { |
|
throw new Error("You must pass a function as an equality function to useSelector"); |
|
} |
|
} |
|
|
|
var _useReduxContext = useReduxContext$1(), |
|
store = _useReduxContext.store, |
|
contextSub = _useReduxContext.subscription; |
|
|
|
var selectedState = useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub); |
|
React.useDebugValue(selectedState); |
|
return selectedState; |
|
}; |
|
} |
|
/** |
|
* A hook to access the redux store's state. This hook takes a selector function |
|
* as an argument. The selector is called with the store state. |
|
* |
|
* This hook takes an optional equality comparison function as the second parameter |
|
* that allows you to customize the way the selected state is compared to determine |
|
* whether the component needs to be re-rendered. |
|
* |
|
* @param {Function} selector the selector function |
|
* @param {Function=} equalityFn the function that will be used to determine equality |
|
* |
|
* @returns {any} the selected state |
|
* |
|
* @example |
|
* |
|
* import React from 'react' |
|
* import { useSelector } from 'react-redux' |
|
* |
|
* export const CounterComponent = () => { |
|
* const counter = useSelector(state => state.counter) |
|
* return <div>{counter}</div> |
|
* } |
|
*/ |
|
|
|
var useSelector = /*#__PURE__*/createSelectorHook(); |
|
|
|
// with standard React renderers (ReactDOM, React Native) |
|
|
|
setBatch(reactDom.unstable_batchedUpdates); |
|
|
|
Object.defineProperty(exports, 'batch', { |
|
enumerable: true, |
|
get: function () { return reactDom.unstable_batchedUpdates; } |
|
}); |
|
exports.Provider = Provider; |
|
exports.ReactReduxContext = ReactReduxContext; |
|
exports.connect = connect; |
|
exports.connectAdvanced = connectAdvanced; |
|
exports.createDispatchHook = createDispatchHook; |
|
exports.createSelectorHook = createSelectorHook; |
|
exports.createStoreHook = createStoreHook; |
|
exports.shallowEqual = shallowEqual; |
|
exports.useDispatch = useDispatch; |
|
exports.useSelector = useSelector; |
|
exports.useStore = useStore; |
|
|
|
Object.defineProperty(exports, '__esModule', { value: true }); |
|
|
|
}));
|
|
|