react.development.js 58 KB

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