You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

react.js 55KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. /** @license React v16.3.2
  2. * react.development.js
  3. *
  4. * Copyright (c) 2013-present, Facebook, Inc.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. (function (global, factory) {
  11. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  12. typeof define === 'function' && define.amd ? define(factory) :
  13. (global.React = factory());
  14. }(this, (function () { 'use strict';
  15. /*
  16. object-assign
  17. (c) Sindre Sorhus
  18. @license MIT
  19. */
  20. /* eslint-disable no-unused-vars */
  21. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  22. var hasOwnProperty = Object.prototype.hasOwnProperty;
  23. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  24. function toObject(val) {
  25. if (val === null || val === undefined) {
  26. throw new TypeError('Object.assign cannot be called with null or undefined');
  27. }
  28. return Object(val);
  29. }
  30. function shouldUseNative() {
  31. try {
  32. if (!Object.assign) {
  33. return false;
  34. }
  35. // Detect buggy property enumeration order in older V8 versions.
  36. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  37. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  38. test1[5] = 'de';
  39. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  40. return false;
  41. }
  42. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  43. var test2 = {};
  44. for (var i = 0; i < 10; i++) {
  45. test2['_' + String.fromCharCode(i)] = i;
  46. }
  47. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  48. return test2[n];
  49. });
  50. if (order2.join('') !== '0123456789') {
  51. return false;
  52. }
  53. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  54. var test3 = {};
  55. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  56. test3[letter] = letter;
  57. });
  58. if (Object.keys(Object.assign({}, test3)).join('') !==
  59. 'abcdefghijklmnopqrst') {
  60. return false;
  61. }
  62. return true;
  63. } catch (err) {
  64. // We don't expect any of the above to throw, but better to be safe.
  65. return false;
  66. }
  67. }
  68. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  69. var from;
  70. var to = toObject(target);
  71. var symbols;
  72. for (var s = 1; s < arguments.length; s++) {
  73. from = Object(arguments[s]);
  74. for (var key in from) {
  75. if (hasOwnProperty.call(from, key)) {
  76. to[key] = from[key];
  77. }
  78. }
  79. if (getOwnPropertySymbols) {
  80. symbols = getOwnPropertySymbols(from);
  81. for (var i = 0; i < symbols.length; i++) {
  82. if (propIsEnumerable.call(from, symbols[i])) {
  83. to[symbols[i]] = from[symbols[i]];
  84. }
  85. }
  86. }
  87. }
  88. return to;
  89. };
  90. // TODO: this is special because it gets imported during build.
  91. var ReactVersion = '16.3.2';
  92. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  93. // nor polyfill, then a plain number is used for performance.
  94. var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
  95. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
  96. var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
  97. var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
  98. var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
  99. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
  100. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol['for']('react.strict_mode') : 0xeacc;
  101. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol['for']('react.provider') : 0xeacd;
  102. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol['for']('react.context') : 0xeace;
  103. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol['for']('react.async_mode') : 0xeacf;
  104. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol['for']('react.forward_ref') : 0xead0;
  105. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  106. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  107. function getIteratorFn(maybeIterable) {
  108. if (maybeIterable === null || typeof maybeIterable === 'undefined') {
  109. return null;
  110. }
  111. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  112. if (typeof maybeIterator === 'function') {
  113. return maybeIterator;
  114. }
  115. return null;
  116. }
  117. /**
  118. * Copyright (c) 2013-present, Facebook, Inc.
  119. *
  120. * This source code is licensed under the MIT license found in the
  121. * LICENSE file in the root directory of this source tree.
  122. *
  123. */
  124. /**
  125. * Use invariant() to assert state which your program assumes to be true.
  126. *
  127. * Provide sprintf-style format (only %s is supported) and arguments
  128. * to provide information about what broke and what you were
  129. * expecting.
  130. *
  131. * The invariant message will be stripped in production, but the invariant
  132. * will remain to ensure logic does not differ in production.
  133. */
  134. var validateFormat = function validateFormat(format) {};
  135. {
  136. validateFormat = function validateFormat(format) {
  137. if (format === undefined) {
  138. throw new Error('invariant requires an error message argument');
  139. }
  140. };
  141. }
  142. function invariant(condition, format, a, b, c, d, e, f) {
  143. validateFormat(format);
  144. if (!condition) {
  145. var error;
  146. if (format === undefined) {
  147. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  148. } else {
  149. var args = [a, b, c, d, e, f];
  150. var argIndex = 0;
  151. error = new Error(format.replace(/%s/g, function () {
  152. return args[argIndex++];
  153. }));
  154. error.name = 'Invariant Violation';
  155. }
  156. error.framesToPop = 1; // we don't care about invariant's own frame
  157. throw error;
  158. }
  159. }
  160. var invariant_1 = invariant;
  161. // Relying on the `invariant()` implementation lets us
  162. // have preserve the format and params in the www builds.
  163. /**
  164. * Copyright (c) 2013-present, Facebook, Inc.
  165. *
  166. * This source code is licensed under the MIT license found in the
  167. * LICENSE file in the root directory of this source tree.
  168. *
  169. */
  170. var emptyObject = {};
  171. {
  172. Object.freeze(emptyObject);
  173. }
  174. var emptyObject_1 = emptyObject;
  175. /**
  176. * Forked from fbjs/warning:
  177. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  178. *
  179. * Only change is we use console.warn instead of console.error,
  180. * and do nothing when 'console' is not supported.
  181. * This really simplifies the code.
  182. * ---
  183. * Similar to invariant but only logs a warning if the condition is not met.
  184. * This can be used to log issues in development environments in critical
  185. * paths. Removing the logging code for production environments will keep the
  186. * same logic and follow the same code paths.
  187. */
  188. var lowPriorityWarning = function () {};
  189. {
  190. var printWarning = function (format) {
  191. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  192. args[_key - 1] = arguments[_key];
  193. }
  194. var argIndex = 0;
  195. var message = 'Warning: ' + format.replace(/%s/g, function () {
  196. return args[argIndex++];
  197. });
  198. if (typeof console !== 'undefined') {
  199. console.warn(message);
  200. }
  201. try {
  202. // --- Welcome to debugging React ---
  203. // This error was thrown as a convenience so that you can use this stack
  204. // to find the callsite that caused this warning to fire.
  205. throw new Error(message);
  206. } catch (x) {}
  207. };
  208. lowPriorityWarning = function (condition, format) {
  209. if (format === undefined) {
  210. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  211. }
  212. if (!condition) {
  213. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  214. args[_key2 - 2] = arguments[_key2];
  215. }
  216. printWarning.apply(undefined, [format].concat(args));
  217. }
  218. };
  219. }
  220. var lowPriorityWarning$1 = lowPriorityWarning;
  221. /**
  222. * Copyright (c) 2013-present, Facebook, Inc.
  223. *
  224. * This source code is licensed under the MIT license found in the
  225. * LICENSE file in the root directory of this source tree.
  226. *
  227. *
  228. */
  229. function makeEmptyFunction(arg) {
  230. return function () {
  231. return arg;
  232. };
  233. }
  234. /**
  235. * This function accepts and discards inputs; it has no side effects. This is
  236. * primarily useful idiomatically for overridable function endpoints which
  237. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  238. */
  239. var emptyFunction = function emptyFunction() {};
  240. emptyFunction.thatReturns = makeEmptyFunction;
  241. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  242. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  243. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  244. emptyFunction.thatReturnsThis = function () {
  245. return this;
  246. };
  247. emptyFunction.thatReturnsArgument = function (arg) {
  248. return arg;
  249. };
  250. var emptyFunction_1 = emptyFunction;
  251. /**
  252. * Copyright (c) 2014-present, Facebook, Inc.
  253. *
  254. * This source code is licensed under the MIT license found in the
  255. * LICENSE file in the root directory of this source tree.
  256. *
  257. */
  258. /**
  259. * Similar to invariant but only logs a warning if the condition is not met.
  260. * This can be used to log issues in development environments in critical
  261. * paths. Removing the logging code for production environments will keep the
  262. * same logic and follow the same code paths.
  263. */
  264. var warning = emptyFunction_1;
  265. {
  266. var printWarning$1 = function printWarning(format) {
  267. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  268. args[_key - 1] = arguments[_key];
  269. }
  270. var argIndex = 0;
  271. var message = 'Warning: ' + format.replace(/%s/g, function () {
  272. return args[argIndex++];
  273. });
  274. if (typeof console !== 'undefined') {
  275. console.error(message);
  276. }
  277. try {
  278. // --- Welcome to debugging React ---
  279. // This error was thrown as a convenience so that you can use this stack
  280. // to find the callsite that caused this warning to fire.
  281. throw new Error(message);
  282. } catch (x) {}
  283. };
  284. warning = function warning(condition, format) {
  285. if (format === undefined) {
  286. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  287. }
  288. if (format.indexOf('Failed Composite propType: ') === 0) {
  289. return; // Ignore CompositeComponent proptype check.
  290. }
  291. if (!condition) {
  292. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  293. args[_key2 - 2] = arguments[_key2];
  294. }
  295. printWarning$1.apply(undefined, [format].concat(args));
  296. }
  297. };
  298. }
  299. var warning_1 = warning;
  300. var didWarnStateUpdateForUnmountedComponent = {};
  301. function warnNoop(publicInstance, callerName) {
  302. {
  303. var _constructor = publicInstance.constructor;
  304. var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
  305. var warningKey = componentName + '.' + callerName;
  306. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  307. return;
  308. }
  309. warning_1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
  310. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  311. }
  312. }
  313. /**
  314. * This is the abstract API for an update queue.
  315. */
  316. var ReactNoopUpdateQueue = {
  317. /**
  318. * Checks whether or not this composite component is mounted.
  319. * @param {ReactClass} publicInstance The instance we want to test.
  320. * @return {boolean} True if mounted, false otherwise.
  321. * @protected
  322. * @final
  323. */
  324. isMounted: function (publicInstance) {
  325. return false;
  326. },
  327. /**
  328. * Forces an update. This should only be invoked when it is known with
  329. * certainty that we are **not** in a DOM transaction.
  330. *
  331. * You may want to call this when you know that some deeper aspect of the
  332. * component's state has changed but `setState` was not called.
  333. *
  334. * This will not invoke `shouldComponentUpdate`, but it will invoke
  335. * `componentWillUpdate` and `componentDidUpdate`.
  336. *
  337. * @param {ReactClass} publicInstance The instance that should rerender.
  338. * @param {?function} callback Called after component is updated.
  339. * @param {?string} callerName name of the calling function in the public API.
  340. * @internal
  341. */
  342. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  343. warnNoop(publicInstance, 'forceUpdate');
  344. },
  345. /**
  346. * Replaces all of the state. Always use this or `setState` to mutate state.
  347. * You should treat `this.state` as immutable.
  348. *
  349. * There is no guarantee that `this.state` will be immediately updated, so
  350. * accessing `this.state` after calling this method may return the old value.
  351. *
  352. * @param {ReactClass} publicInstance The instance that should rerender.
  353. * @param {object} completeState Next state.
  354. * @param {?function} callback Called after component is updated.
  355. * @param {?string} callerName name of the calling function in the public API.
  356. * @internal
  357. */
  358. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  359. warnNoop(publicInstance, 'replaceState');
  360. },
  361. /**
  362. * Sets a subset of the state. This only exists because _pendingState is
  363. * internal. This provides a merging strategy that is not available to deep
  364. * properties which is confusing. TODO: Expose pendingState or don't use it
  365. * during the merge.
  366. *
  367. * @param {ReactClass} publicInstance The instance that should rerender.
  368. * @param {object} partialState Next partial state to be merged with state.
  369. * @param {?function} callback Called after component is updated.
  370. * @param {?string} Name of the calling function in the public API.
  371. * @internal
  372. */
  373. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  374. warnNoop(publicInstance, 'setState');
  375. }
  376. };
  377. /**
  378. * Base class helpers for the updating state of a component.
  379. */
  380. function Component(props, context, updater) {
  381. this.props = props;
  382. this.context = context;
  383. this.refs = emptyObject_1;
  384. // We initialize the default updater but the real one gets injected by the
  385. // renderer.
  386. this.updater = updater || ReactNoopUpdateQueue;
  387. }
  388. Component.prototype.isReactComponent = {};
  389. /**
  390. * Sets a subset of the state. Always use this to mutate
  391. * state. You should treat `this.state` as immutable.
  392. *
  393. * There is no guarantee that `this.state` will be immediately updated, so
  394. * accessing `this.state` after calling this method may return the old value.
  395. *
  396. * There is no guarantee that calls to `setState` will run synchronously,
  397. * as they may eventually be batched together. You can provide an optional
  398. * callback that will be executed when the call to setState is actually
  399. * completed.
  400. *
  401. * When a function is provided to setState, it will be called at some point in
  402. * the future (not synchronously). It will be called with the up to date
  403. * component arguments (state, props, context). These values can be different
  404. * from this.* because your function may be called after receiveProps but before
  405. * shouldComponentUpdate, and this new state, props, and context will not yet be
  406. * assigned to this.
  407. *
  408. * @param {object|function} partialState Next partial state or function to
  409. * produce next partial state to be merged with current state.
  410. * @param {?function} callback Called after state is updated.
  411. * @final
  412. * @protected
  413. */
  414. Component.prototype.setState = function (partialState, callback) {
  415. !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant_1(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
  416. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  417. };
  418. /**
  419. * Forces an update. This should only be invoked when it is known with
  420. * certainty that we are **not** in a DOM transaction.
  421. *
  422. * You may want to call this when you know that some deeper aspect of the
  423. * component's state has changed but `setState` was not called.
  424. *
  425. * This will not invoke `shouldComponentUpdate`, but it will invoke
  426. * `componentWillUpdate` and `componentDidUpdate`.
  427. *
  428. * @param {?function} callback Called after update is complete.
  429. * @final
  430. * @protected
  431. */
  432. Component.prototype.forceUpdate = function (callback) {
  433. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  434. };
  435. /**
  436. * Deprecated APIs. These APIs used to exist on classic React classes but since
  437. * we would like to deprecate them, we're not going to move them over to this
  438. * modern base class. Instead, we define a getter that warns if it's accessed.
  439. */
  440. {
  441. var deprecatedAPIs = {
  442. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  443. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  444. };
  445. var defineDeprecationWarning = function (methodName, info) {
  446. Object.defineProperty(Component.prototype, methodName, {
  447. get: function () {
  448. lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  449. return undefined;
  450. }
  451. });
  452. };
  453. for (var fnName in deprecatedAPIs) {
  454. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  455. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  456. }
  457. }
  458. }
  459. function ComponentDummy() {}
  460. ComponentDummy.prototype = Component.prototype;
  461. /**
  462. * Convenience component with default shallow equality check for sCU.
  463. */
  464. function PureComponent(props, context, updater) {
  465. this.props = props;
  466. this.context = context;
  467. this.refs = emptyObject_1;
  468. this.updater = updater || ReactNoopUpdateQueue;
  469. }
  470. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  471. pureComponentPrototype.constructor = PureComponent;
  472. // Avoid an extra prototype jump for these methods.
  473. objectAssign(pureComponentPrototype, Component.prototype);
  474. pureComponentPrototype.isPureReactComponent = true;
  475. // an immutable object with a single mutable value
  476. function createRef() {
  477. var refObject = {
  478. current: null
  479. };
  480. {
  481. Object.seal(refObject);
  482. }
  483. return refObject;
  484. }
  485. /**
  486. * Keeps track of the current owner.
  487. *
  488. * The current owner is the component who should own any components that are
  489. * currently being constructed.
  490. */
  491. var ReactCurrentOwner = {
  492. /**
  493. * @internal
  494. * @type {ReactComponent}
  495. */
  496. current: null
  497. };
  498. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  499. var RESERVED_PROPS = {
  500. key: true,
  501. ref: true,
  502. __self: true,
  503. __source: true
  504. };
  505. var specialPropKeyWarningShown = void 0;
  506. var specialPropRefWarningShown = void 0;
  507. function hasValidRef(config) {
  508. {
  509. if (hasOwnProperty$1.call(config, 'ref')) {
  510. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  511. if (getter && getter.isReactWarning) {
  512. return false;
  513. }
  514. }
  515. }
  516. return config.ref !== undefined;
  517. }
  518. function hasValidKey(config) {
  519. {
  520. if (hasOwnProperty$1.call(config, 'key')) {
  521. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  522. if (getter && getter.isReactWarning) {
  523. return false;
  524. }
  525. }
  526. }
  527. return config.key !== undefined;
  528. }
  529. function defineKeyPropWarningGetter(props, displayName) {
  530. var warnAboutAccessingKey = function () {
  531. if (!specialPropKeyWarningShown) {
  532. specialPropKeyWarningShown = true;
  533. warning_1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  534. }
  535. };
  536. warnAboutAccessingKey.isReactWarning = true;
  537. Object.defineProperty(props, 'key', {
  538. get: warnAboutAccessingKey,
  539. configurable: true
  540. });
  541. }
  542. function defineRefPropWarningGetter(props, displayName) {
  543. var warnAboutAccessingRef = function () {
  544. if (!specialPropRefWarningShown) {
  545. specialPropRefWarningShown = true;
  546. warning_1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  547. }
  548. };
  549. warnAboutAccessingRef.isReactWarning = true;
  550. Object.defineProperty(props, 'ref', {
  551. get: warnAboutAccessingRef,
  552. configurable: true
  553. });
  554. }
  555. /**
  556. * Factory method to create a new React element. This no longer adheres to
  557. * the class pattern, so do not use new to call it. Also, no instanceof check
  558. * will work. Instead test $$typeof field against Symbol.for('react.element') to check
  559. * if something is a React Element.
  560. *
  561. * @param {*} type
  562. * @param {*} key
  563. * @param {string|object} ref
  564. * @param {*} self A *temporary* helper to detect places where `this` is
  565. * different from the `owner` when React.createElement is called, so that we
  566. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  567. * functions, and as long as `this` and owner are the same, there will be no
  568. * change in behavior.
  569. * @param {*} source An annotation object (added by a transpiler or otherwise)
  570. * indicating filename, line number, and/or other information.
  571. * @param {*} owner
  572. * @param {*} props
  573. * @internal
  574. */
  575. var ReactElement = function (type, key, ref, self, source, owner, props) {
  576. var element = {
  577. // This tag allows us to uniquely identify this as a React Element
  578. $$typeof: REACT_ELEMENT_TYPE,
  579. // Built-in properties that belong on the element
  580. type: type,
  581. key: key,
  582. ref: ref,
  583. props: props,
  584. // Record the component responsible for creating this element.
  585. _owner: owner
  586. };
  587. {
  588. // The validation flag is currently mutative. We put it on
  589. // an external backing store so that we can freeze the whole object.
  590. // This can be replaced with a WeakMap once they are implemented in
  591. // commonly used development environments.
  592. element._store = {};
  593. // To make comparing ReactElements easier for testing purposes, we make
  594. // the validation flag non-enumerable (where possible, which should
  595. // include every environment we run tests in), so the test framework
  596. // ignores it.
  597. Object.defineProperty(element._store, 'validated', {
  598. configurable: false,
  599. enumerable: false,
  600. writable: true,
  601. value: false
  602. });
  603. // self and source are DEV only properties.
  604. Object.defineProperty(element, '_self', {
  605. configurable: false,
  606. enumerable: false,
  607. writable: false,
  608. value: self
  609. });
  610. // Two elements created in two different places should be considered
  611. // equal for testing purposes and therefore we hide it from enumeration.
  612. Object.defineProperty(element, '_source', {
  613. configurable: false,
  614. enumerable: false,
  615. writable: false,
  616. value: source
  617. });
  618. if (Object.freeze) {
  619. Object.freeze(element.props);
  620. Object.freeze(element);
  621. }
  622. }
  623. return element;
  624. };
  625. /**
  626. * Create and return a new ReactElement of the given type.
  627. * See https://reactjs.org/docs/react-api.html#createelement
  628. */
  629. function createElement(type, config, children) {
  630. var propName = void 0;
  631. // Reserved names are extracted
  632. var props = {};
  633. var key = null;
  634. var ref = null;
  635. var self = null;
  636. var source = null;
  637. if (config != null) {
  638. if (hasValidRef(config)) {
  639. ref = config.ref;
  640. }
  641. if (hasValidKey(config)) {
  642. key = '' + config.key;
  643. }
  644. self = config.__self === undefined ? null : config.__self;
  645. source = config.__source === undefined ? null : config.__source;
  646. // Remaining properties are added to a new props object
  647. for (propName in config) {
  648. if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  649. props[propName] = config[propName];
  650. }
  651. }
  652. }
  653. // Children can be more than one argument, and those are transferred onto
  654. // the newly allocated props object.
  655. var childrenLength = arguments.length - 2;
  656. if (childrenLength === 1) {
  657. props.children = children;
  658. } else if (childrenLength > 1) {
  659. var childArray = Array(childrenLength);
  660. for (var i = 0; i < childrenLength; i++) {
  661. childArray[i] = arguments[i + 2];
  662. }
  663. {
  664. if (Object.freeze) {
  665. Object.freeze(childArray);
  666. }
  667. }
  668. props.children = childArray;
  669. }
  670. // Resolve default props
  671. if (type && type.defaultProps) {
  672. var defaultProps = type.defaultProps;
  673. for (propName in defaultProps) {
  674. if (props[propName] === undefined) {
  675. props[propName] = defaultProps[propName];
  676. }
  677. }
  678. }
  679. {
  680. if (key || ref) {
  681. if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
  682. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  683. if (key) {
  684. defineKeyPropWarningGetter(props, displayName);
  685. }
  686. if (ref) {
  687. defineRefPropWarningGetter(props, displayName);
  688. }
  689. }
  690. }
  691. }
  692. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  693. }
  694. /**
  695. * Return a function that produces ReactElements of a given type.
  696. * See https://reactjs.org/docs/react-api.html#createfactory
  697. */
  698. function cloneAndReplaceKey(oldElement, newKey) {
  699. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  700. return newElement;
  701. }
  702. /**
  703. * Clone and return a new ReactElement using element as the starting point.
  704. * See https://reactjs.org/docs/react-api.html#cloneelement
  705. */
  706. function cloneElement(element, config, children) {
  707. !!(element === null || element === undefined) ? invariant_1(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
  708. var propName = void 0;
  709. // Original props are copied
  710. var props = objectAssign({}, element.props);
  711. // Reserved names are extracted
  712. var key = element.key;
  713. var ref = element.ref;
  714. // Self is preserved since the owner is preserved.
  715. var self = element._self;
  716. // Source is preserved since cloneElement is unlikely to be targeted by a
  717. // transpiler, and the original source is probably a better indicator of the
  718. // true owner.
  719. var source = element._source;
  720. // Owner will be preserved, unless ref is overridden
  721. var owner = element._owner;
  722. if (config != null) {
  723. if (hasValidRef(config)) {
  724. // Silently steal the ref from the parent.
  725. ref = config.ref;
  726. owner = ReactCurrentOwner.current;
  727. }
  728. if (hasValidKey(config)) {
  729. key = '' + config.key;
  730. }
  731. // Remaining properties override existing props
  732. var defaultProps = void 0;
  733. if (element.type && element.type.defaultProps) {
  734. defaultProps = element.type.defaultProps;
  735. }
  736. for (propName in config) {
  737. if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  738. if (config[propName] === undefined && defaultProps !== undefined) {
  739. // Resolve default props
  740. props[propName] = defaultProps[propName];
  741. } else {
  742. props[propName] = config[propName];
  743. }
  744. }
  745. }
  746. }
  747. // Children can be more than one argument, and those are transferred onto
  748. // the newly allocated props object.
  749. var childrenLength = arguments.length - 2;
  750. if (childrenLength === 1) {
  751. props.children = children;
  752. } else if (childrenLength > 1) {
  753. var childArray = Array(childrenLength);
  754. for (var i = 0; i < childrenLength; i++) {
  755. childArray[i] = arguments[i + 2];
  756. }
  757. props.children = childArray;
  758. }
  759. return ReactElement(element.type, key, ref, self, source, owner, props);
  760. }
  761. /**
  762. * Verifies the object is a ReactElement.
  763. * See https://reactjs.org/docs/react-api.html#isvalidelement
  764. * @param {?object} object
  765. * @return {boolean} True if `object` is a valid component.
  766. * @final
  767. */
  768. function isValidElement(object) {
  769. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  770. }
  771. var ReactDebugCurrentFrame = {};
  772. {
  773. // Component that is being worked on
  774. ReactDebugCurrentFrame.getCurrentStack = null;
  775. ReactDebugCurrentFrame.getStackAddendum = function () {
  776. var impl = ReactDebugCurrentFrame.getCurrentStack;
  777. if (impl) {
  778. return impl();
  779. }
  780. return null;
  781. };
  782. }
  783. var SEPARATOR = '.';
  784. var SUBSEPARATOR = ':';
  785. /**
  786. * Escape and wrap key so it is safe to use as a reactid
  787. *
  788. * @param {string} key to be escaped.
  789. * @return {string} the escaped key.
  790. */
  791. function escape(key) {
  792. var escapeRegex = /[=:]/g;
  793. var escaperLookup = {
  794. '=': '=0',
  795. ':': '=2'
  796. };
  797. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  798. return escaperLookup[match];
  799. });
  800. return '$' + escapedString;
  801. }
  802. /**
  803. * TODO: Test that a single child and an array with one item have the same key
  804. * pattern.
  805. */
  806. var didWarnAboutMaps = false;
  807. var userProvidedKeyEscapeRegex = /\/+/g;
  808. function escapeUserProvidedKey(text) {
  809. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  810. }
  811. var POOL_SIZE = 10;
  812. var traverseContextPool = [];
  813. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  814. if (traverseContextPool.length) {
  815. var traverseContext = traverseContextPool.pop();
  816. traverseContext.result = mapResult;
  817. traverseContext.keyPrefix = keyPrefix;
  818. traverseContext.func = mapFunction;
  819. traverseContext.context = mapContext;
  820. traverseContext.count = 0;
  821. return traverseContext;
  822. } else {
  823. return {
  824. result: mapResult,
  825. keyPrefix: keyPrefix,
  826. func: mapFunction,
  827. context: mapContext,
  828. count: 0
  829. };
  830. }
  831. }
  832. function releaseTraverseContext(traverseContext) {
  833. traverseContext.result = null;
  834. traverseContext.keyPrefix = null;
  835. traverseContext.func = null;
  836. traverseContext.context = null;
  837. traverseContext.count = 0;
  838. if (traverseContextPool.length < POOL_SIZE) {
  839. traverseContextPool.push(traverseContext);
  840. }
  841. }
  842. /**
  843. * @param {?*} children Children tree container.
  844. * @param {!string} nameSoFar Name of the key path so far.
  845. * @param {!function} callback Callback to invoke with each child found.
  846. * @param {?*} traverseContext Used to pass information throughout the traversal
  847. * process.
  848. * @return {!number} The number of children in this subtree.
  849. */
  850. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  851. var type = typeof children;
  852. if (type === 'undefined' || type === 'boolean') {
  853. // All of the above are perceived as null.
  854. children = null;
  855. }
  856. var invokeCallback = false;
  857. if (children === null) {
  858. invokeCallback = true;
  859. } else {
  860. switch (type) {
  861. case 'string':
  862. case 'number':
  863. invokeCallback = true;
  864. break;
  865. case 'object':
  866. switch (children.$$typeof) {
  867. case REACT_ELEMENT_TYPE:
  868. case REACT_PORTAL_TYPE:
  869. invokeCallback = true;
  870. }
  871. }
  872. }
  873. if (invokeCallback) {
  874. callback(traverseContext, children,
  875. // If it's the only child, treat the name as if it was wrapped in an array
  876. // so that it's consistent if the number of children grows.
  877. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  878. return 1;
  879. }
  880. var child = void 0;
  881. var nextName = void 0;
  882. var subtreeCount = 0; // Count of children found in the current subtree.
  883. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  884. if (Array.isArray(children)) {
  885. for (var i = 0; i < children.length; i++) {
  886. child = children[i];
  887. nextName = nextNamePrefix + getComponentKey(child, i);
  888. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  889. }
  890. } else {
  891. var iteratorFn = getIteratorFn(children);
  892. if (typeof iteratorFn === 'function') {
  893. {
  894. // Warn about using Maps as children
  895. if (iteratorFn === children.entries) {
  896. !didWarnAboutMaps ? warning_1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()) : void 0;
  897. didWarnAboutMaps = true;
  898. }
  899. }
  900. var iterator = iteratorFn.call(children);
  901. var step = void 0;
  902. var ii = 0;
  903. while (!(step = iterator.next()).done) {
  904. child = step.value;
  905. nextName = nextNamePrefix + getComponentKey(child, ii++);
  906. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  907. }
  908. } else if (type === 'object') {
  909. var addendum = '';
  910. {
  911. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  912. }
  913. var childrenString = '' + children;
  914. invariant_1(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
  915. }
  916. }
  917. return subtreeCount;
  918. }
  919. /**
  920. * Traverses children that are typically specified as `props.children`, but
  921. * might also be specified through attributes:
  922. *
  923. * - `traverseAllChildren(this.props.children, ...)`
  924. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  925. *
  926. * The `traverseContext` is an optional argument that is passed through the
  927. * entire traversal. It can be used to store accumulations or anything else that
  928. * the callback might find relevant.
  929. *
  930. * @param {?*} children Children tree object.
  931. * @param {!function} callback To invoke upon traversing each child.
  932. * @param {?*} traverseContext Context for traversal.
  933. * @return {!number} The number of children in this subtree.
  934. */
  935. function traverseAllChildren(children, callback, traverseContext) {
  936. if (children == null) {
  937. return 0;
  938. }
  939. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  940. }
  941. /**
  942. * Generate a key string that identifies a component within a set.
  943. *
  944. * @param {*} component A component that could contain a manual key.
  945. * @param {number} index Index that is used if a manual key is not provided.
  946. * @return {string}
  947. */
  948. function getComponentKey(component, index) {
  949. // Do some typechecking here since we call this blindly. We want to ensure
  950. // that we don't block potential future ES APIs.
  951. if (typeof component === 'object' && component !== null && component.key != null) {
  952. // Explicit key
  953. return escape(component.key);
  954. }
  955. // Implicit key determined by the index in the set
  956. return index.toString(36);
  957. }
  958. function forEachSingleChild(bookKeeping, child, name) {
  959. var func = bookKeeping.func,
  960. context = bookKeeping.context;
  961. func.call(context, child, bookKeeping.count++);
  962. }
  963. /**
  964. * Iterates through children that are typically specified as `props.children`.
  965. *
  966. * See https://reactjs.org/docs/react-api.html#react.children.foreach
  967. *
  968. * The provided forEachFunc(child, index) will be called for each
  969. * leaf child.
  970. *
  971. * @param {?*} children Children tree container.
  972. * @param {function(*, int)} forEachFunc
  973. * @param {*} forEachContext Context for forEachContext.
  974. */
  975. function forEachChildren(children, forEachFunc, forEachContext) {
  976. if (children == null) {
  977. return children;
  978. }
  979. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  980. traverseAllChildren(children, forEachSingleChild, traverseContext);
  981. releaseTraverseContext(traverseContext);
  982. }
  983. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  984. var result = bookKeeping.result,
  985. keyPrefix = bookKeeping.keyPrefix,
  986. func = bookKeeping.func,
  987. context = bookKeeping.context;
  988. var mappedChild = func.call(context, child, bookKeeping.count++);
  989. if (Array.isArray(mappedChild)) {
  990. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction_1.thatReturnsArgument);
  991. } else if (mappedChild != null) {
  992. if (isValidElement(mappedChild)) {
  993. mappedChild = cloneAndReplaceKey(mappedChild,
  994. // Keep both the (mapped) and old keys if they differ, just as
  995. // traverseAllChildren used to do for objects as children
  996. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  997. }
  998. result.push(mappedChild);
  999. }
  1000. }
  1001. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  1002. var escapedPrefix = '';
  1003. if (prefix != null) {
  1004. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  1005. }
  1006. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  1007. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  1008. releaseTraverseContext(traverseContext);
  1009. }
  1010. /**
  1011. * Maps children that are typically specified as `props.children`.
  1012. *
  1013. * See https://reactjs.org/docs/react-api.html#react.children.map
  1014. *
  1015. * The provided mapFunction(child, key, index) will be called for each
  1016. * leaf child.
  1017. *
  1018. * @param {?*} children Children tree container.
  1019. * @param {function(*, int)} func The map function.
  1020. * @param {*} context Context for mapFunction.
  1021. * @return {object} Object containing the ordered map of results.
  1022. */
  1023. function mapChildren(children, func, context) {
  1024. if (children == null) {
  1025. return children;
  1026. }
  1027. var result = [];
  1028. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  1029. return result;
  1030. }
  1031. /**
  1032. * Count the number of children that are typically specified as
  1033. * `props.children`.
  1034. *
  1035. * See https://reactjs.org/docs/react-api.html#react.children.count
  1036. *
  1037. * @param {?*} children Children tree container.
  1038. * @return {number} The number of children.
  1039. */
  1040. function countChildren(children, context) {
  1041. return traverseAllChildren(children, emptyFunction_1.thatReturnsNull, null);
  1042. }
  1043. /**
  1044. * Flatten a children object (typically specified as `props.children`) and
  1045. * return an array with appropriately re-keyed children.
  1046. *
  1047. * See https://reactjs.org/docs/react-api.html#react.children.toarray
  1048. */
  1049. function toArray(children) {
  1050. var result = [];
  1051. mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction_1.thatReturnsArgument);
  1052. return result;
  1053. }
  1054. /**
  1055. * Returns the first child in a collection of children and verifies that there
  1056. * is only one child in the collection.
  1057. *
  1058. * See https://reactjs.org/docs/react-api.html#react.children.only
  1059. *
  1060. * The current implementation of this function assumes that a single child gets
  1061. * passed without a wrapper, but the purpose of this helper function is to
  1062. * abstract away the particular structure of children.
  1063. *
  1064. * @param {?object} children Child collection structure.
  1065. * @return {ReactElement} The first and only `ReactElement` contained in the
  1066. * structure.
  1067. */
  1068. function onlyChild(children) {
  1069. !isValidElement(children) ? invariant_1(false, 'React.Children.only expected to receive a single React element child.') : void 0;
  1070. return children;
  1071. }
  1072. function createContext(defaultValue, calculateChangedBits) {
  1073. if (calculateChangedBits === undefined) {
  1074. calculateChangedBits = null;
  1075. } else {
  1076. {
  1077. !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warning_1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
  1078. }
  1079. }
  1080. var context = {
  1081. $$typeof: REACT_CONTEXT_TYPE,
  1082. _calculateChangedBits: calculateChangedBits,
  1083. _defaultValue: defaultValue,
  1084. _currentValue: defaultValue,
  1085. _changedBits: 0,
  1086. // These are circular
  1087. Provider: null,
  1088. Consumer: null
  1089. };
  1090. context.Provider = {
  1091. $$typeof: REACT_PROVIDER_TYPE,
  1092. _context: context
  1093. };
  1094. context.Consumer = context;
  1095. {
  1096. context._currentRenderer = null;
  1097. }
  1098. return context;
  1099. }
  1100. function forwardRef(render) {
  1101. {
  1102. !(typeof render === 'function') ? warning_1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render) : void 0;
  1103. }
  1104. return {
  1105. $$typeof: REACT_FORWARD_REF_TYPE,
  1106. render: render
  1107. };
  1108. }
  1109. var describeComponentFrame = function (name, source, ownerName) {
  1110. return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
  1111. };
  1112. function isValidElementType(type) {
  1113. return typeof type === 'string' || typeof type === 'function' ||
  1114. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  1115. type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
  1116. }
  1117. function getComponentName(fiber) {
  1118. var type = fiber.type;
  1119. if (typeof type === 'function') {
  1120. return type.displayName || type.name;
  1121. }
  1122. if (typeof type === 'string') {
  1123. return type;
  1124. }
  1125. switch (type) {
  1126. case REACT_FRAGMENT_TYPE:
  1127. return 'ReactFragment';
  1128. case REACT_PORTAL_TYPE:
  1129. return 'ReactPortal';
  1130. case REACT_CALL_TYPE:
  1131. return 'ReactCall';
  1132. case REACT_RETURN_TYPE:
  1133. return 'ReactReturn';
  1134. }
  1135. if (typeof type === 'object' && type !== null) {
  1136. switch (type.$$typeof) {
  1137. case REACT_FORWARD_REF_TYPE:
  1138. var functionName = type.render.displayName || type.render.name || '';
  1139. return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
  1140. }
  1141. }
  1142. return null;
  1143. }
  1144. /**
  1145. * Copyright (c) 2013-present, Facebook, Inc.
  1146. *
  1147. * This source code is licensed under the MIT license found in the
  1148. * LICENSE file in the root directory of this source tree.
  1149. */
  1150. var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  1151. var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
  1152. /**
  1153. * Copyright (c) 2013-present, Facebook, Inc.
  1154. *
  1155. * This source code is licensed under the MIT license found in the
  1156. * LICENSE file in the root directory of this source tree.
  1157. */
  1158. {
  1159. var invariant$2 = invariant_1;
  1160. var warning$2 = warning_1;
  1161. var ReactPropTypesSecret = ReactPropTypesSecret_1;
  1162. var loggedTypeFailures = {};
  1163. }
  1164. /**
  1165. * Assert that the values match with the type specs.
  1166. * Error messages are memorized and will only be shown once.
  1167. *
  1168. * @param {object} typeSpecs Map of name to a ReactPropType
  1169. * @param {object} values Runtime values that need to be type-checked
  1170. * @param {string} location e.g. "prop", "context", "child context"
  1171. * @param {string} componentName Name of the component for error messages.
  1172. * @param {?Function} getStack Returns the component stack.
  1173. * @private
  1174. */
  1175. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  1176. {
  1177. for (var typeSpecName in typeSpecs) {
  1178. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  1179. var error;
  1180. // Prop type validation may throw. In case they do, we don't want to
  1181. // fail the render phase where it didn't fail before. So we log it.
  1182. // After these have been cleaned up, we'll let them throw.
  1183. try {
  1184. // This is intentionally an invariant that gets caught. It's the same
  1185. // behavior as without this statement except with a better message.
  1186. invariant$2(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
  1187. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  1188. } catch (ex) {
  1189. error = ex;
  1190. }
  1191. warning$2(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
  1192. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  1193. // Only monitor this failure once because there tends to be a lot of the
  1194. // same error.
  1195. loggedTypeFailures[error.message] = true;
  1196. var stack = getStack ? getStack() : '';
  1197. warning$2(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
  1198. }
  1199. }
  1200. }
  1201. }
  1202. }
  1203. var checkPropTypes_1 = checkPropTypes;
  1204. /**
  1205. * ReactElementValidator provides a wrapper around a element factory
  1206. * which validates the props passed to the element. This is intended to be
  1207. * used only in DEV and could be replaced by a static type checker for languages
  1208. * that support it.
  1209. */
  1210. var currentlyValidatingElement = void 0;
  1211. var propTypesMisspellWarningShown = void 0;
  1212. var getDisplayName = function () {};
  1213. var getStackAddendum = function () {};
  1214. {
  1215. currentlyValidatingElement = null;
  1216. propTypesMisspellWarningShown = false;
  1217. getDisplayName = function (element) {
  1218. if (element == null) {
  1219. return '#empty';
  1220. } else if (typeof element === 'string' || typeof element === 'number') {
  1221. return '#text';
  1222. } else if (typeof element.type === 'string') {
  1223. return element.type;
  1224. } else if (element.type === REACT_FRAGMENT_TYPE) {
  1225. return 'React.Fragment';
  1226. } else {
  1227. return element.type.displayName || element.type.name || 'Unknown';
  1228. }
  1229. };
  1230. getStackAddendum = function () {
  1231. var stack = '';
  1232. if (currentlyValidatingElement) {
  1233. var name = getDisplayName(currentlyValidatingElement);
  1234. var owner = currentlyValidatingElement._owner;
  1235. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
  1236. }
  1237. stack += ReactDebugCurrentFrame.getStackAddendum() || '';
  1238. return stack;
  1239. };
  1240. }
  1241. function getDeclarationErrorAddendum() {
  1242. if (ReactCurrentOwner.current) {
  1243. var name = getComponentName(ReactCurrentOwner.current);
  1244. if (name) {
  1245. return '\n\nCheck the render method of `' + name + '`.';
  1246. }
  1247. }
  1248. return '';
  1249. }
  1250. function getSourceInfoErrorAddendum(elementProps) {
  1251. if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
  1252. var source = elementProps.__source;
  1253. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  1254. var lineNumber = source.lineNumber;
  1255. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  1256. }
  1257. return '';
  1258. }
  1259. /**
  1260. * Warn if there's no key explicitly set on dynamic arrays of children or
  1261. * object keys are not valid. This allows us to keep track of children between
  1262. * updates.
  1263. */
  1264. var ownerHasKeyUseWarning = {};
  1265. function getCurrentComponentErrorInfo(parentType) {
  1266. var info = getDeclarationErrorAddendum();
  1267. if (!info) {
  1268. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  1269. if (parentName) {
  1270. info = '\n\nCheck the top-level render call using <' + parentName + '>.';
  1271. }
  1272. }
  1273. return info;
  1274. }
  1275. /**
  1276. * Warn if the element doesn't have an explicit key assigned to it.
  1277. * This element is in an array. The array could grow and shrink or be
  1278. * reordered. All children that haven't already been validated are required to
  1279. * have a "key" property assigned to it. Error statuses are cached so a warning
  1280. * will only be shown once.
  1281. *
  1282. * @internal
  1283. * @param {ReactElement} element Element that requires a key.
  1284. * @param {*} parentType element's parent's type.
  1285. */
  1286. function validateExplicitKey(element, parentType) {
  1287. if (!element._store || element._store.validated || element.key != null) {
  1288. return;
  1289. }
  1290. element._store.validated = true;
  1291. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  1292. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  1293. return;
  1294. }
  1295. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  1296. // Usually the current owner is the offender, but if it accepts children as a
  1297. // property, it may be the creator of the child that's responsible for
  1298. // assigning it a key.
  1299. var childOwner = '';
  1300. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  1301. // Give the component that originally created this child.
  1302. childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
  1303. }
  1304. currentlyValidatingElement = element;
  1305. {
  1306. warning_1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum());
  1307. }
  1308. currentlyValidatingElement = null;
  1309. }
  1310. /**
  1311. * Ensure that every element either is passed in a static location, in an
  1312. * array with an explicit keys property defined, or in an object literal
  1313. * with valid key property.
  1314. *
  1315. * @internal
  1316. * @param {ReactNode} node Statically passed child of any type.
  1317. * @param {*} parentType node's parent's type.
  1318. */
  1319. function validateChildKeys(node, parentType) {
  1320. if (typeof node !== 'object') {
  1321. return;
  1322. }
  1323. if (Array.isArray(node)) {
  1324. for (var i = 0; i < node.length; i++) {
  1325. var child = node[i];
  1326. if (isValidElement(child)) {
  1327. validateExplicitKey(child, parentType);
  1328. }
  1329. }
  1330. } else if (isValidElement(node)) {
  1331. // This element was passed in a valid location.
  1332. if (node._store) {
  1333. node._store.validated = true;
  1334. }
  1335. } else if (node) {
  1336. var iteratorFn = getIteratorFn(node);
  1337. if (typeof iteratorFn === 'function') {
  1338. // Entry iterators used to provide implicit keys,
  1339. // but now we print a separate warning for them later.
  1340. if (iteratorFn !== node.entries) {
  1341. var iterator = iteratorFn.call(node);
  1342. var step = void 0;
  1343. while (!(step = iterator.next()).done) {
  1344. if (isValidElement(step.value)) {
  1345. validateExplicitKey(step.value, parentType);
  1346. }
  1347. }
  1348. }
  1349. }
  1350. }
  1351. }
  1352. /**
  1353. * Given an element, validate that its props follow the propTypes definition,
  1354. * provided by the type.
  1355. *
  1356. * @param {ReactElement} element
  1357. */
  1358. function validatePropTypes(element) {
  1359. var componentClass = element.type;
  1360. if (typeof componentClass !== 'function') {
  1361. return;
  1362. }
  1363. var name = componentClass.displayName || componentClass.name;
  1364. var propTypes = componentClass.propTypes;
  1365. if (propTypes) {
  1366. currentlyValidatingElement = element;
  1367. checkPropTypes_1(propTypes, element.props, 'prop', name, getStackAddendum);
  1368. currentlyValidatingElement = null;
  1369. } else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  1370. propTypesMisspellWarningShown = true;
  1371. warning_1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  1372. }
  1373. if (typeof componentClass.getDefaultProps === 'function') {
  1374. !componentClass.getDefaultProps.isReactClassApproved ? warning_1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
  1375. }
  1376. }
  1377. /**
  1378. * Given a fragment, validate that it can only be provided with fragment props
  1379. * @param {ReactElement} fragment
  1380. */
  1381. function validateFragmentProps(fragment) {
  1382. currentlyValidatingElement = fragment;
  1383. var keys = Object.keys(fragment.props);
  1384. for (var i = 0; i < keys.length; i++) {
  1385. var key = keys[i];
  1386. if (key !== 'children' && key !== 'key') {
  1387. warning_1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
  1388. break;
  1389. }
  1390. }
  1391. if (fragment.ref !== null) {
  1392. warning_1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
  1393. }
  1394. currentlyValidatingElement = null;
  1395. }
  1396. function createElementWithValidation(type, props, children) {
  1397. var validType = isValidElementType(type);
  1398. // We warn in this case but don't throw. We expect the element creation to
  1399. // succeed and there will likely be errors in render.
  1400. if (!validType) {
  1401. var info = '';
  1402. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  1403. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
  1404. }
  1405. var sourceInfo = getSourceInfoErrorAddendum(props);
  1406. if (sourceInfo) {
  1407. info += sourceInfo;
  1408. } else {
  1409. info += getDeclarationErrorAddendum();
  1410. }
  1411. info += getStackAddendum() || '';
  1412. var typeString = void 0;
  1413. if (type === null) {
  1414. typeString = 'null';
  1415. } else if (Array.isArray(type)) {
  1416. typeString = 'array';
  1417. } else {
  1418. typeString = typeof type;
  1419. }
  1420. warning_1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  1421. }
  1422. var element = createElement.apply(this, arguments);
  1423. // The result can be nullish if a mock or a custom function is used.
  1424. // TODO: Drop this when these are no longer allowed as the type argument.
  1425. if (element == null) {
  1426. return element;
  1427. }
  1428. // Skip key warning if the type isn't valid since our key validation logic
  1429. // doesn't expect a non-string/function type and can throw confusing errors.
  1430. // We don't want exception behavior to differ between dev and prod.
  1431. // (Rendering will throw with a helpful message and as soon as the type is
  1432. // fixed, the key warnings will appear.)
  1433. if (validType) {
  1434. for (var i = 2; i < arguments.length; i++) {
  1435. validateChildKeys(arguments[i], type);
  1436. }
  1437. }
  1438. if (type === REACT_FRAGMENT_TYPE) {
  1439. validateFragmentProps(element);
  1440. } else {
  1441. validatePropTypes(element);
  1442. }
  1443. return element;
  1444. }
  1445. function createFactoryWithValidation(type) {
  1446. var validatedFactory = createElementWithValidation.bind(null, type);
  1447. validatedFactory.type = type;
  1448. // Legacy hook: remove it
  1449. {
  1450. Object.defineProperty(validatedFactory, 'type', {
  1451. enumerable: false,
  1452. get: function () {
  1453. lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  1454. Object.defineProperty(this, 'type', {
  1455. value: type
  1456. });
  1457. return type;
  1458. }
  1459. });
  1460. }
  1461. return validatedFactory;
  1462. }
  1463. function cloneElementWithValidation(element, props, children) {
  1464. var newElement = cloneElement.apply(this, arguments);
  1465. for (var i = 2; i < arguments.length; i++) {
  1466. validateChildKeys(arguments[i], newElement.type);
  1467. }
  1468. validatePropTypes(newElement);
  1469. return newElement;
  1470. }
  1471. var React = {
  1472. Children: {
  1473. map: mapChildren,
  1474. forEach: forEachChildren,
  1475. count: countChildren,
  1476. toArray: toArray,
  1477. only: onlyChild
  1478. },
  1479. createRef: createRef,
  1480. Component: Component,
  1481. PureComponent: PureComponent,
  1482. createContext: createContext,
  1483. forwardRef: forwardRef,
  1484. Fragment: REACT_FRAGMENT_TYPE,
  1485. StrictMode: REACT_STRICT_MODE_TYPE,
  1486. unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
  1487. createElement: createElementWithValidation,
  1488. cloneElement: cloneElementWithValidation,
  1489. createFactory: createFactoryWithValidation,
  1490. isValidElement: isValidElement,
  1491. version: ReactVersion,
  1492. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  1493. ReactCurrentOwner: ReactCurrentOwner,
  1494. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  1495. assign: objectAssign
  1496. }
  1497. };
  1498. {
  1499. objectAssign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
  1500. // These should not be included in production.
  1501. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  1502. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  1503. // TODO: remove in React 17.0.
  1504. ReactComponentTreeHook: {}
  1505. });
  1506. }
  1507. var React$2 = Object.freeze({
  1508. default: React
  1509. });
  1510. var React$3 = ( React$2 && React ) || React$2;
  1511. // TODO: decide on the top-level export form.
  1512. // This is hacky but makes it work with both Rollup and Jest.
  1513. var react = React$3['default'] ? React$3['default'] : React$3;
  1514. return react;
  1515. })));