123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('redux'), require('react-dom')) :
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'redux', 'react-dom'], factory) :
- (global = global || self, factory(global.ReactRedux = {}, global.React, global.Redux, global.ReactDOM));
- }(this, function (exports, React, redux, reactDom) { 'use strict';
- var React__default = 'default' in React ? React['default'] : React;
- function unwrapExports (x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
- var reactIs_development = createCommonjsModule(function (module, exports) {
- {
- (function() {
- Object.defineProperty(exports, '__esModule', { value: true });
- // 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_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
- 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);
- }
- /**
- * Forked from fbjs/warning:
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
- *
- * Only change is we use console.warn instead of console.error,
- * and do nothing when 'console' is not supported.
- * This really simplifies the code.
- * ---
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
- var lowPriorityWarning = function () {};
- {
- var printWarning = function (format) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.warn(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) {}
- };
- lowPriorityWarning = function (condition, format) {
- if (format === undefined) {
- throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
- if (!condition) {
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
- args[_key2 - 2] = arguments[_key2];
- }
- printWarning.apply(undefined, [format].concat(args));
- }
- };
- }
- var lowPriorityWarning$1 = lowPriorityWarning;
- 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_PROVIDER_TYPE:
- return $$typeofType;
- default:
- return $$typeof;
- }
- }
- case REACT_LAZY_TYPE:
- case REACT_MEMO_TYPE:
- 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;
- lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
- }
- }
- 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;
- }
- exports.typeOf = typeOf;
- exports.AsyncMode = AsyncMode;
- exports.ConcurrentMode = ConcurrentMode;
- exports.ContextConsumer = ContextConsumer;
- exports.ContextProvider = ContextProvider;
- exports.Element = Element;
- exports.ForwardRef = ForwardRef;
- exports.Fragment = Fragment;
- exports.Lazy = Lazy;
- exports.Memo = Memo;
- exports.Portal = Portal;
- exports.Profiler = Profiler;
- exports.StrictMode = StrictMode;
- exports.Suspense = Suspense;
- exports.isValidElementType = isValidElementType;
- exports.isAsyncMode = isAsyncMode;
- exports.isConcurrentMode = isConcurrentMode;
- exports.isContextConsumer = isContextConsumer;
- exports.isContextProvider = isContextProvider;
- exports.isElement = isElement;
- exports.isForwardRef = isForwardRef;
- exports.isFragment = isFragment;
- exports.isLazy = isLazy;
- exports.isMemo = isMemo;
- exports.isPortal = isPortal;
- exports.isProfiler = isProfiler;
- exports.isStrictMode = isStrictMode;
- exports.isSuspense = isSuspense;
- })();
- }
- });
- unwrapExports(reactIs_development);
- var reactIs_development_1 = reactIs_development.typeOf;
- var reactIs_development_2 = reactIs_development.AsyncMode;
- var reactIs_development_3 = reactIs_development.ConcurrentMode;
- var reactIs_development_4 = reactIs_development.ContextConsumer;
- var reactIs_development_5 = reactIs_development.ContextProvider;
- var reactIs_development_6 = reactIs_development.Element;
- var reactIs_development_7 = reactIs_development.ForwardRef;
- var reactIs_development_8 = reactIs_development.Fragment;
- var reactIs_development_9 = reactIs_development.Lazy;
- var reactIs_development_10 = reactIs_development.Memo;
- var reactIs_development_11 = reactIs_development.Portal;
- var reactIs_development_12 = reactIs_development.Profiler;
- var reactIs_development_13 = reactIs_development.StrictMode;
- var reactIs_development_14 = reactIs_development.Suspense;
- var reactIs_development_15 = reactIs_development.isValidElementType;
- var reactIs_development_16 = reactIs_development.isAsyncMode;
- var reactIs_development_17 = reactIs_development.isConcurrentMode;
- var reactIs_development_18 = reactIs_development.isContextConsumer;
- var reactIs_development_19 = reactIs_development.isContextProvider;
- var reactIs_development_20 = reactIs_development.isElement;
- var reactIs_development_21 = reactIs_development.isForwardRef;
- var reactIs_development_22 = reactIs_development.isFragment;
- var reactIs_development_23 = reactIs_development.isLazy;
- var reactIs_development_24 = reactIs_development.isMemo;
- var reactIs_development_25 = reactIs_development.isPortal;
- var reactIs_development_26 = reactIs_development.isProfiler;
- var reactIs_development_27 = reactIs_development.isStrictMode;
- var reactIs_development_28 = reactIs_development.isSuspense;
- var reactIs = createCommonjsModule(function (module) {
- {
- module.exports = reactIs_development;
- }
- });
- var reactIs_1 = reactIs.isValidElementType;
- var reactIs_2 = reactIs.isContextConsumer;
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = 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) {
- symbols = getOwnPropertySymbols(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 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
- var ReactPropTypesSecret_1 = ReactPropTypesSecret;
- var printWarning = function() {};
- {
- var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
- var loggedTypeFailures = {};
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
- 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) {}
- };
- }
- /**
- * 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(typeSpecs, values, location, componentName, getStack) {
- {
- for (var typeSpecName in typeSpecs) {
- if (has(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(
- (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(
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
- );
- }
- }
- }
- }
- }
- /**
- * Resets warning cache when testing.
- *
- * @private
- */
- checkPropTypes.resetWarningCache = function() {
- {
- loggedTypeFailures = {};
- }
- };
- var checkPropTypes_1 = checkPropTypes;
- var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
- var printWarning$1 = function() {};
- {
- 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) {}
- };
- }
- 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_1) {
- 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$1(
- '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_1);
- 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.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$1(
- '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$1('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$1(propValue, key)) {
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
- if (error instanceof Error) {
- return error;
- }
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
- function createUnionTypeChecker(arrayOfTypeCheckers) {
- if (!Array.isArray(arrayOfTypeCheckers)) {
- printWarning$1('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$1(
- '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_1) == 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_1);
- 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 = objectAssign({}, 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_1);
- 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_1;
- ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
- ReactPropTypes.PropTypes = ReactPropTypes;
- return ReactPropTypes;
- };
- var propTypes = createCommonjsModule(function (module) {
- /**
- * 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;
- // By explicitly using `prop-types` you are opting into new development behavior.
- // http://fb.me/prop-types-in-prod
- var throwOnDirectAccess = true;
- module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
- }
- });
- var ReactReduxContext =
- /*#__PURE__*/
- React__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
- var nullListeners = {
- notify: function notify() {}
- };
- 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 Subscription =
- /*#__PURE__*/
- function () {
- function Subscription(store, parentSub) {
- this.store = store;
- this.parentSub = parentSub;
- this.unsubscribe = null;
- this.listeners = nullListeners;
- this.handleChangeWrapper = this.handleChangeWrapper.bind(this);
- }
- var _proto = Subscription.prototype;
- _proto.addNestedSub = function addNestedSub(listener) {
- this.trySubscribe();
- return this.listeners.subscribe(listener);
- };
- _proto.notifyNestedSubs = function notifyNestedSubs() {
- this.listeners.notify();
- };
- _proto.handleChangeWrapper = function handleChangeWrapper() {
- if (this.onStateChange) {
- this.onStateChange();
- }
- };
- _proto.isSubscribed = function isSubscribed() {
- return Boolean(this.unsubscribe);
- };
- _proto.trySubscribe = function trySubscribe() {
- if (!this.unsubscribe) {
- this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.handleChangeWrapper) : this.store.subscribe(this.handleChangeWrapper);
- this.listeners = createListenerCollection();
- }
- };
- _proto.tryUnsubscribe = function tryUnsubscribe() {
- if (this.unsubscribe) {
- this.unsubscribe();
- this.unsubscribe = null;
- this.listeners.clear();
- this.listeners = nullListeners;
- }
- };
- return Subscription;
- }();
- function Provider(_ref) {
- var store = _ref.store,
- context = _ref.context,
- children = _ref.children;
- var contextValue = React.useMemo(function () {
- var subscription = new Subscription(store);
- subscription.onStateChange = subscription.notifyNestedSubs;
- return {
- store: store,
- subscription: subscription
- };
- }, [store]);
- var previousState = React.useMemo(function () {
- return store.getState();
- }, [store]);
- React.useEffect(function () {
- var subscription = contextValue.subscription;
- subscription.trySubscribe();
- if (previousState !== store.getState()) {
- subscription.notifyNestedSubs();
- }
- return function () {
- subscription.tryUnsubscribe();
- subscription.onStateChange = null;
- };
- }, [contextValue, previousState]);
- var Context = context || ReactReduxContext;
- return React__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;
- }
- /**
- * 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.ForwardRef] = FORWARD_REF_STATICS;
- function getStatics(component) {
- if (reactIs.isMemo(component)) {
- return MEMO_STATICS;
- }
- return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
- }
- var defineProperty = Object.defineProperty;
- var getOwnPropertyNames = Object.getOwnPropertyNames;
- var getOwnPropertySymbols$1 = 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$1) {
- keys = keys.concat(getOwnPropertySymbols$1(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;
- }
- return targetComponent;
- }
- var hoistNonReactStatics_cjs = hoistNonReactStatics;
- // 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;
- 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, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]);
- {
- 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_1(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 forwardedRef = props.forwardedRef,
- wrapperProps = _objectWithoutPropertiesLoose(props, ["forwardedRef"]);
- return [props.context, forwardedRef, wrapperProps];
- }, [props]),
- propsContext = _useMemo[0],
- forwardedRef = _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_2(React__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.
- var subscription = new Subscription(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.
- 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 React__default.createElement(WrappedComponent, _extends({}, actualChildProps, {
- ref: forwardedRef
- }));
- }, [forwardedRef, 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 React__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.memo(ConnectFunction) : ConnectFunction;
- Connect.WrappedComponent = WrappedComponent;
- Connect.displayName = displayName;
- if (forwardRef) {
- var forwarded = React__default.forwardRef(function forwardConnectRef(props, ref) {
- return React__default.createElement(Connect, _extends({}, props, {
- forwardedRef: 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;
- }
- /**
- * @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 redux.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);
- }
- 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, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]);
- 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);
- }
- /*
- 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, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]);
- 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 new Subscription(store, contextSub);
- }, [store, contextSub]);
- var latestSubscriptionCallbackError = React.useRef();
- var latestSelector = React.useRef();
- var latestSelectedState = React.useRef();
- var selectedState;
- try {
- if (selector !== latestSelector.current || latestSubscriptionCallbackError.current) {
- selectedState = selector(store.getState());
- } 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;
- latestSelectedState.current = selectedState;
- latestSubscriptionCallbackError.current = undefined;
- });
- useIsomorphicLayoutEffect(function () {
- function checkForUpdates() {
- try {
- var newSelectedState = latestSelector.current(store.getState());
- if (equalityFn(newSelectedState, latestSelectedState.current)) {
- return;
- }
- latestSelectedState.current = newSelectedState;
- } 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 useSelectors");
- }
- var _useReduxContext = useReduxContext$1(),
- store = _useReduxContext.store,
- contextSub = _useReduxContext.subscription;
- return useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub);
- };
- }
- /**
- * 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();
- 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 });
- }));
|