Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

react-transition-group.js 80KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
  4. (global = global || self, factory(global.ReactTransitionGroup = {}, global.React, global.ReactDOM));
  5. }(this, function (exports, React, ReactDOM) { 'use strict';
  6. var React__default = 'default' in React ? React['default'] : React;
  7. ReactDOM = ReactDOM && ReactDOM.hasOwnProperty('default') ? ReactDOM['default'] : ReactDOM;
  8. function _extends() {
  9. _extends = Object.assign || function (target) {
  10. for (var i = 1; i < arguments.length; i++) {
  11. var source = arguments[i];
  12. for (var key in source) {
  13. if (Object.prototype.hasOwnProperty.call(source, key)) {
  14. target[key] = source[key];
  15. }
  16. }
  17. }
  18. return target;
  19. };
  20. return _extends.apply(this, arguments);
  21. }
  22. function _objectWithoutPropertiesLoose(source, excluded) {
  23. if (source == null) return {};
  24. var target = {};
  25. var sourceKeys = Object.keys(source);
  26. var key, i;
  27. for (i = 0; i < sourceKeys.length; i++) {
  28. key = sourceKeys[i];
  29. if (excluded.indexOf(key) >= 0) continue;
  30. target[key] = source[key];
  31. }
  32. return target;
  33. }
  34. function _inheritsLoose(subClass, superClass) {
  35. subClass.prototype = Object.create(superClass.prototype);
  36. subClass.prototype.constructor = subClass;
  37. subClass.__proto__ = superClass;
  38. }
  39. function createCommonjsModule(fn, module) {
  40. return module = { exports: {} }, fn(module, module.exports), module.exports;
  41. }
  42. /*
  43. object-assign
  44. (c) Sindre Sorhus
  45. @license MIT
  46. */
  47. /* eslint-disable no-unused-vars */
  48. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  49. var hasOwnProperty = Object.prototype.hasOwnProperty;
  50. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  51. function toObject(val) {
  52. if (val === null || val === undefined) {
  53. throw new TypeError('Object.assign cannot be called with null or undefined');
  54. }
  55. return Object(val);
  56. }
  57. function shouldUseNative() {
  58. try {
  59. if (!Object.assign) {
  60. return false;
  61. }
  62. // Detect buggy property enumeration order in older V8 versions.
  63. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  64. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  65. test1[5] = 'de';
  66. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  67. return false;
  68. }
  69. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  70. var test2 = {};
  71. for (var i = 0; i < 10; i++) {
  72. test2['_' + String.fromCharCode(i)] = i;
  73. }
  74. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  75. return test2[n];
  76. });
  77. if (order2.join('') !== '0123456789') {
  78. return false;
  79. }
  80. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  81. var test3 = {};
  82. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  83. test3[letter] = letter;
  84. });
  85. if (Object.keys(Object.assign({}, test3)).join('') !==
  86. 'abcdefghijklmnopqrst') {
  87. return false;
  88. }
  89. return true;
  90. } catch (err) {
  91. // We don't expect any of the above to throw, but better to be safe.
  92. return false;
  93. }
  94. }
  95. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  96. var from;
  97. var to = toObject(target);
  98. var symbols;
  99. for (var s = 1; s < arguments.length; s++) {
  100. from = Object(arguments[s]);
  101. for (var key in from) {
  102. if (hasOwnProperty.call(from, key)) {
  103. to[key] = from[key];
  104. }
  105. }
  106. if (getOwnPropertySymbols) {
  107. symbols = getOwnPropertySymbols(from);
  108. for (var i = 0; i < symbols.length; i++) {
  109. if (propIsEnumerable.call(from, symbols[i])) {
  110. to[symbols[i]] = from[symbols[i]];
  111. }
  112. }
  113. }
  114. }
  115. return to;
  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. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  124. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  125. var printWarning = function() {};
  126. {
  127. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  128. var loggedTypeFailures = {};
  129. printWarning = function(text) {
  130. var message = 'Warning: ' + text;
  131. if (typeof console !== 'undefined') {
  132. console.error(message);
  133. }
  134. try {
  135. // --- Welcome to debugging React ---
  136. // This error was thrown as a convenience so that you can use this stack
  137. // to find the callsite that caused this warning to fire.
  138. throw new Error(message);
  139. } catch (x) {}
  140. };
  141. }
  142. /**
  143. * Assert that the values match with the type specs.
  144. * Error messages are memorized and will only be shown once.
  145. *
  146. * @param {object} typeSpecs Map of name to a ReactPropType
  147. * @param {object} values Runtime values that need to be type-checked
  148. * @param {string} location e.g. "prop", "context", "child context"
  149. * @param {string} componentName Name of the component for error messages.
  150. * @param {?Function} getStack Returns the component stack.
  151. * @private
  152. */
  153. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  154. {
  155. for (var typeSpecName in typeSpecs) {
  156. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  157. var error;
  158. // Prop type validation may throw. In case they do, we don't want to
  159. // fail the render phase where it didn't fail before. So we log it.
  160. // After these have been cleaned up, we'll let them throw.
  161. try {
  162. // This is intentionally an invariant that gets caught. It's the same
  163. // behavior as without this statement except with a better message.
  164. if (typeof typeSpecs[typeSpecName] !== 'function') {
  165. var err = Error(
  166. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  167. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  168. );
  169. err.name = 'Invariant Violation';
  170. throw err;
  171. }
  172. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  173. } catch (ex) {
  174. error = ex;
  175. }
  176. if (error && !(error instanceof Error)) {
  177. printWarning(
  178. (componentName || 'React class') + ': type specification of ' +
  179. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  180. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  181. 'You may have forgotten to pass an argument to the type checker ' +
  182. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  183. 'shape all require an argument).'
  184. );
  185. }
  186. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  187. // Only monitor this failure once because there tends to be a lot of the
  188. // same error.
  189. loggedTypeFailures[error.message] = true;
  190. var stack = getStack ? getStack() : '';
  191. printWarning(
  192. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  193. );
  194. }
  195. }
  196. }
  197. }
  198. }
  199. var checkPropTypes_1 = checkPropTypes;
  200. var printWarning$1 = function() {};
  201. {
  202. printWarning$1 = function(text) {
  203. var message = 'Warning: ' + text;
  204. if (typeof console !== 'undefined') {
  205. console.error(message);
  206. }
  207. try {
  208. // --- Welcome to debugging React ---
  209. // This error was thrown as a convenience so that you can use this stack
  210. // to find the callsite that caused this warning to fire.
  211. throw new Error(message);
  212. } catch (x) {}
  213. };
  214. }
  215. function emptyFunctionThatReturnsNull() {
  216. return null;
  217. }
  218. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  219. /* global Symbol */
  220. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  221. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  222. /**
  223. * Returns the iterator method function contained on the iterable object.
  224. *
  225. * Be sure to invoke the function with the iterable as context:
  226. *
  227. * var iteratorFn = getIteratorFn(myIterable);
  228. * if (iteratorFn) {
  229. * var iterator = iteratorFn.call(myIterable);
  230. * ...
  231. * }
  232. *
  233. * @param {?object} maybeIterable
  234. * @return {?function}
  235. */
  236. function getIteratorFn(maybeIterable) {
  237. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  238. if (typeof iteratorFn === 'function') {
  239. return iteratorFn;
  240. }
  241. }
  242. /**
  243. * Collection of methods that allow declaration and validation of props that are
  244. * supplied to React components. Example usage:
  245. *
  246. * var Props = require('ReactPropTypes');
  247. * var MyArticle = React.createClass({
  248. * propTypes: {
  249. * // An optional string prop named "description".
  250. * description: Props.string,
  251. *
  252. * // A required enum prop named "category".
  253. * category: Props.oneOf(['News','Photos']).isRequired,
  254. *
  255. * // A prop named "dialog" that requires an instance of Dialog.
  256. * dialog: Props.instanceOf(Dialog).isRequired
  257. * },
  258. * render: function() { ... }
  259. * });
  260. *
  261. * A more formal specification of how these methods are used:
  262. *
  263. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  264. * decl := ReactPropTypes.{type}(.isRequired)?
  265. *
  266. * Each and every declaration produces a function with the same signature. This
  267. * allows the creation of custom validation functions. For example:
  268. *
  269. * var MyLink = React.createClass({
  270. * propTypes: {
  271. * // An optional string or URI prop named "href".
  272. * href: function(props, propName, componentName) {
  273. * var propValue = props[propName];
  274. * if (propValue != null && typeof propValue !== 'string' &&
  275. * !(propValue instanceof URI)) {
  276. * return new Error(
  277. * 'Expected a string or an URI for ' + propName + ' in ' +
  278. * componentName
  279. * );
  280. * }
  281. * }
  282. * },
  283. * render: function() {...}
  284. * });
  285. *
  286. * @internal
  287. */
  288. var ANONYMOUS = '<<anonymous>>';
  289. // Important!
  290. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  291. var ReactPropTypes = {
  292. array: createPrimitiveTypeChecker('array'),
  293. bool: createPrimitiveTypeChecker('boolean'),
  294. func: createPrimitiveTypeChecker('function'),
  295. number: createPrimitiveTypeChecker('number'),
  296. object: createPrimitiveTypeChecker('object'),
  297. string: createPrimitiveTypeChecker('string'),
  298. symbol: createPrimitiveTypeChecker('symbol'),
  299. any: createAnyTypeChecker(),
  300. arrayOf: createArrayOfTypeChecker,
  301. element: createElementTypeChecker(),
  302. instanceOf: createInstanceTypeChecker,
  303. node: createNodeChecker(),
  304. objectOf: createObjectOfTypeChecker,
  305. oneOf: createEnumTypeChecker,
  306. oneOfType: createUnionTypeChecker,
  307. shape: createShapeTypeChecker,
  308. exact: createStrictShapeTypeChecker,
  309. };
  310. /**
  311. * inlined Object.is polyfill to avoid requiring consumers ship their own
  312. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  313. */
  314. /*eslint-disable no-self-compare*/
  315. function is(x, y) {
  316. // SameValue algorithm
  317. if (x === y) {
  318. // Steps 1-5, 7-10
  319. // Steps 6.b-6.e: +0 != -0
  320. return x !== 0 || 1 / x === 1 / y;
  321. } else {
  322. // Step 6.a: NaN == NaN
  323. return x !== x && y !== y;
  324. }
  325. }
  326. /*eslint-enable no-self-compare*/
  327. /**
  328. * We use an Error-like object for backward compatibility as people may call
  329. * PropTypes directly and inspect their output. However, we don't use real
  330. * Errors anymore. We don't inspect their stack anyway, and creating them
  331. * is prohibitively expensive if they are created too often, such as what
  332. * happens in oneOfType() for any type before the one that matched.
  333. */
  334. function PropTypeError(message) {
  335. this.message = message;
  336. this.stack = '';
  337. }
  338. // Make `instanceof Error` still work for returned errors.
  339. PropTypeError.prototype = Error.prototype;
  340. function createChainableTypeChecker(validate) {
  341. {
  342. var manualPropTypeCallCache = {};
  343. var manualPropTypeWarningCount = 0;
  344. }
  345. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  346. componentName = componentName || ANONYMOUS;
  347. propFullName = propFullName || propName;
  348. if (secret !== ReactPropTypesSecret_1) {
  349. if (throwOnDirectAccess) {
  350. // New behavior only for users of `prop-types` package
  351. var err = new Error(
  352. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  353. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  354. 'Read more at http://fb.me/use-check-prop-types'
  355. );
  356. err.name = 'Invariant Violation';
  357. throw err;
  358. } else if (typeof console !== 'undefined') {
  359. // Old behavior for people using React.PropTypes
  360. var cacheKey = componentName + ':' + propName;
  361. if (
  362. !manualPropTypeCallCache[cacheKey] &&
  363. // Avoid spamming the console because they are often not actionable except for lib authors
  364. manualPropTypeWarningCount < 3
  365. ) {
  366. printWarning$1(
  367. 'You are manually calling a React.PropTypes validation ' +
  368. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  369. 'and will throw in the standalone `prop-types` package. ' +
  370. 'You may be seeing this warning due to a third-party PropTypes ' +
  371. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  372. );
  373. manualPropTypeCallCache[cacheKey] = true;
  374. manualPropTypeWarningCount++;
  375. }
  376. }
  377. }
  378. if (props[propName] == null) {
  379. if (isRequired) {
  380. if (props[propName] === null) {
  381. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  382. }
  383. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  384. }
  385. return null;
  386. } else {
  387. return validate(props, propName, componentName, location, propFullName);
  388. }
  389. }
  390. var chainedCheckType = checkType.bind(null, false);
  391. chainedCheckType.isRequired = checkType.bind(null, true);
  392. return chainedCheckType;
  393. }
  394. function createPrimitiveTypeChecker(expectedType) {
  395. function validate(props, propName, componentName, location, propFullName, secret) {
  396. var propValue = props[propName];
  397. var propType = getPropType(propValue);
  398. if (propType !== expectedType) {
  399. // `propValue` being instance of, say, date/regexp, pass the 'object'
  400. // check, but we can offer a more precise error message here rather than
  401. // 'of type `object`'.
  402. var preciseType = getPreciseType(propValue);
  403. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  404. }
  405. return null;
  406. }
  407. return createChainableTypeChecker(validate);
  408. }
  409. function createAnyTypeChecker() {
  410. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  411. }
  412. function createArrayOfTypeChecker(typeChecker) {
  413. function validate(props, propName, componentName, location, propFullName) {
  414. if (typeof typeChecker !== 'function') {
  415. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  416. }
  417. var propValue = props[propName];
  418. if (!Array.isArray(propValue)) {
  419. var propType = getPropType(propValue);
  420. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  421. }
  422. for (var i = 0; i < propValue.length; i++) {
  423. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  424. if (error instanceof Error) {
  425. return error;
  426. }
  427. }
  428. return null;
  429. }
  430. return createChainableTypeChecker(validate);
  431. }
  432. function createElementTypeChecker() {
  433. function validate(props, propName, componentName, location, propFullName) {
  434. var propValue = props[propName];
  435. if (!isValidElement(propValue)) {
  436. var propType = getPropType(propValue);
  437. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  438. }
  439. return null;
  440. }
  441. return createChainableTypeChecker(validate);
  442. }
  443. function createInstanceTypeChecker(expectedClass) {
  444. function validate(props, propName, componentName, location, propFullName) {
  445. if (!(props[propName] instanceof expectedClass)) {
  446. var expectedClassName = expectedClass.name || ANONYMOUS;
  447. var actualClassName = getClassName(props[propName]);
  448. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  449. }
  450. return null;
  451. }
  452. return createChainableTypeChecker(validate);
  453. }
  454. function createEnumTypeChecker(expectedValues) {
  455. if (!Array.isArray(expectedValues)) {
  456. printWarning$1('Invalid argument supplied to oneOf, expected an instance of array.');
  457. return emptyFunctionThatReturnsNull;
  458. }
  459. function validate(props, propName, componentName, location, propFullName) {
  460. var propValue = props[propName];
  461. for (var i = 0; i < expectedValues.length; i++) {
  462. if (is(propValue, expectedValues[i])) {
  463. return null;
  464. }
  465. }
  466. var valuesString = JSON.stringify(expectedValues);
  467. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  468. }
  469. return createChainableTypeChecker(validate);
  470. }
  471. function createObjectOfTypeChecker(typeChecker) {
  472. function validate(props, propName, componentName, location, propFullName) {
  473. if (typeof typeChecker !== 'function') {
  474. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  475. }
  476. var propValue = props[propName];
  477. var propType = getPropType(propValue);
  478. if (propType !== 'object') {
  479. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  480. }
  481. for (var key in propValue) {
  482. if (propValue.hasOwnProperty(key)) {
  483. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  484. if (error instanceof Error) {
  485. return error;
  486. }
  487. }
  488. }
  489. return null;
  490. }
  491. return createChainableTypeChecker(validate);
  492. }
  493. function createUnionTypeChecker(arrayOfTypeCheckers) {
  494. if (!Array.isArray(arrayOfTypeCheckers)) {
  495. printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.');
  496. return emptyFunctionThatReturnsNull;
  497. }
  498. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  499. var checker = arrayOfTypeCheckers[i];
  500. if (typeof checker !== 'function') {
  501. printWarning$1(
  502. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  503. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  504. );
  505. return emptyFunctionThatReturnsNull;
  506. }
  507. }
  508. function validate(props, propName, componentName, location, propFullName) {
  509. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  510. var checker = arrayOfTypeCheckers[i];
  511. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  512. return null;
  513. }
  514. }
  515. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  516. }
  517. return createChainableTypeChecker(validate);
  518. }
  519. function createNodeChecker() {
  520. function validate(props, propName, componentName, location, propFullName) {
  521. if (!isNode(props[propName])) {
  522. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  523. }
  524. return null;
  525. }
  526. return createChainableTypeChecker(validate);
  527. }
  528. function createShapeTypeChecker(shapeTypes) {
  529. function validate(props, propName, componentName, location, propFullName) {
  530. var propValue = props[propName];
  531. var propType = getPropType(propValue);
  532. if (propType !== 'object') {
  533. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  534. }
  535. for (var key in shapeTypes) {
  536. var checker = shapeTypes[key];
  537. if (!checker) {
  538. continue;
  539. }
  540. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  541. if (error) {
  542. return error;
  543. }
  544. }
  545. return null;
  546. }
  547. return createChainableTypeChecker(validate);
  548. }
  549. function createStrictShapeTypeChecker(shapeTypes) {
  550. function validate(props, propName, componentName, location, propFullName) {
  551. var propValue = props[propName];
  552. var propType = getPropType(propValue);
  553. if (propType !== 'object') {
  554. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  555. }
  556. // We need to check all keys in case some are required but missing from
  557. // props.
  558. var allKeys = objectAssign({}, props[propName], shapeTypes);
  559. for (var key in allKeys) {
  560. var checker = shapeTypes[key];
  561. if (!checker) {
  562. return new PropTypeError(
  563. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  564. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  565. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  566. );
  567. }
  568. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  569. if (error) {
  570. return error;
  571. }
  572. }
  573. return null;
  574. }
  575. return createChainableTypeChecker(validate);
  576. }
  577. function isNode(propValue) {
  578. switch (typeof propValue) {
  579. case 'number':
  580. case 'string':
  581. case 'undefined':
  582. return true;
  583. case 'boolean':
  584. return !propValue;
  585. case 'object':
  586. if (Array.isArray(propValue)) {
  587. return propValue.every(isNode);
  588. }
  589. if (propValue === null || isValidElement(propValue)) {
  590. return true;
  591. }
  592. var iteratorFn = getIteratorFn(propValue);
  593. if (iteratorFn) {
  594. var iterator = iteratorFn.call(propValue);
  595. var step;
  596. if (iteratorFn !== propValue.entries) {
  597. while (!(step = iterator.next()).done) {
  598. if (!isNode(step.value)) {
  599. return false;
  600. }
  601. }
  602. } else {
  603. // Iterator will provide entry [k,v] tuples rather than values.
  604. while (!(step = iterator.next()).done) {
  605. var entry = step.value;
  606. if (entry) {
  607. if (!isNode(entry[1])) {
  608. return false;
  609. }
  610. }
  611. }
  612. }
  613. } else {
  614. return false;
  615. }
  616. return true;
  617. default:
  618. return false;
  619. }
  620. }
  621. function isSymbol(propType, propValue) {
  622. // Native Symbol.
  623. if (propType === 'symbol') {
  624. return true;
  625. }
  626. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  627. if (propValue['@@toStringTag'] === 'Symbol') {
  628. return true;
  629. }
  630. // Fallback for non-spec compliant Symbols which are polyfilled.
  631. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  632. return true;
  633. }
  634. return false;
  635. }
  636. // Equivalent of `typeof` but with special handling for array and regexp.
  637. function getPropType(propValue) {
  638. var propType = typeof propValue;
  639. if (Array.isArray(propValue)) {
  640. return 'array';
  641. }
  642. if (propValue instanceof RegExp) {
  643. // Old webkits (at least until Android 4.0) return 'function' rather than
  644. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  645. // passes PropTypes.object.
  646. return 'object';
  647. }
  648. if (isSymbol(propType, propValue)) {
  649. return 'symbol';
  650. }
  651. return propType;
  652. }
  653. // This handles more types than `getPropType`. Only used for error messages.
  654. // See `createPrimitiveTypeChecker`.
  655. function getPreciseType(propValue) {
  656. if (typeof propValue === 'undefined' || propValue === null) {
  657. return '' + propValue;
  658. }
  659. var propType = getPropType(propValue);
  660. if (propType === 'object') {
  661. if (propValue instanceof Date) {
  662. return 'date';
  663. } else if (propValue instanceof RegExp) {
  664. return 'regexp';
  665. }
  666. }
  667. return propType;
  668. }
  669. // Returns a string that is postfixed to a warning about an invalid type.
  670. // For example, "undefined" or "of type array"
  671. function getPostfixForTypeWarning(value) {
  672. var type = getPreciseType(value);
  673. switch (type) {
  674. case 'array':
  675. case 'object':
  676. return 'an ' + type;
  677. case 'boolean':
  678. case 'date':
  679. case 'regexp':
  680. return 'a ' + type;
  681. default:
  682. return type;
  683. }
  684. }
  685. // Returns class name of the object, if any.
  686. function getClassName(propValue) {
  687. if (!propValue.constructor || !propValue.constructor.name) {
  688. return ANONYMOUS;
  689. }
  690. return propValue.constructor.name;
  691. }
  692. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  693. ReactPropTypes.PropTypes = ReactPropTypes;
  694. return ReactPropTypes;
  695. };
  696. var propTypes = createCommonjsModule(function (module) {
  697. /**
  698. * Copyright (c) 2013-present, Facebook, Inc.
  699. *
  700. * This source code is licensed under the MIT license found in the
  701. * LICENSE file in the root directory of this source tree.
  702. */
  703. {
  704. var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
  705. Symbol.for &&
  706. Symbol.for('react.element')) ||
  707. 0xeac7;
  708. var isValidElement = function(object) {
  709. return typeof object === 'object' &&
  710. object !== null &&
  711. object.$$typeof === REACT_ELEMENT_TYPE;
  712. };
  713. // By explicitly using `prop-types` you are opting into new development behavior.
  714. // http://fb.me/prop-types-in-prod
  715. var throwOnDirectAccess = true;
  716. module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
  717. }
  718. });
  719. var propTypes_1 = propTypes.object;
  720. var propTypes_2 = propTypes.oneOfType;
  721. var propTypes_3 = propTypes.element;
  722. var propTypes_4 = propTypes.bool;
  723. var propTypes_5 = propTypes.func;
  724. function hasClass(element, className) {
  725. if (element.classList) return !!className && element.classList.contains(className);
  726. return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
  727. }
  728. function addClass(element, className) {
  729. if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + " " + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + " " + className);
  730. }
  731. function replaceClassName(origClass, classToRemove) {
  732. return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
  733. }
  734. function removeClass(element, className) {
  735. if (element.classList) {
  736. element.classList.remove(className);
  737. } else if (typeof element.className === 'string') {
  738. element.className = replaceClassName(element.className, className);
  739. } else {
  740. element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
  741. }
  742. }
  743. var config = {
  744. disabled: false
  745. };
  746. var timeoutsShape = propTypes.oneOfType([propTypes.number, propTypes.shape({
  747. enter: propTypes.number,
  748. exit: propTypes.number,
  749. appear: propTypes.number
  750. }).isRequired]);
  751. var classNamesShape = propTypes.oneOfType([propTypes.string, propTypes.shape({
  752. enter: propTypes.string,
  753. exit: propTypes.string,
  754. active: propTypes.string
  755. }), propTypes.shape({
  756. enter: propTypes.string,
  757. enterDone: propTypes.string,
  758. enterActive: propTypes.string,
  759. exit: propTypes.string,
  760. exitDone: propTypes.string,
  761. exitActive: propTypes.string
  762. })]);
  763. var TransitionGroupContext = React__default.createContext(null);
  764. var UNMOUNTED = 'unmounted';
  765. var EXITED = 'exited';
  766. var ENTERING = 'entering';
  767. var ENTERED = 'entered';
  768. var EXITING = 'exiting';
  769. /**
  770. * The Transition component lets you describe a transition from one component
  771. * state to another _over time_ with a simple declarative API. Most commonly
  772. * it's used to animate the mounting and unmounting of a component, but can also
  773. * be used to describe in-place transition states as well.
  774. *
  775. * ---
  776. *
  777. * **Note**: `Transition` is a platform-agnostic base component. If you're using
  778. * transitions in CSS, you'll probably want to use
  779. * [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
  780. * instead. It inherits all the features of `Transition`, but contains
  781. * additional features necessary to play nice with CSS transitions (hence the
  782. * name of the component).
  783. *
  784. * ---
  785. *
  786. * By default the `Transition` component does not alter the behavior of the
  787. * component it renders, it only tracks "enter" and "exit" states for the
  788. * components. It's up to you to give meaning and effect to those states. For
  789. * example we can add styles to a component when it enters or exits:
  790. *
  791. * ```jsx
  792. * import { Transition } from 'react-transition-group';
  793. *
  794. * const duration = 300;
  795. *
  796. * const defaultStyle = {
  797. * transition: `opacity ${duration}ms ease-in-out`,
  798. * opacity: 0,
  799. * }
  800. *
  801. * const transitionStyles = {
  802. * entering: { opacity: 1 },
  803. * entered: { opacity: 1 },
  804. * exiting: { opacity: 0 },
  805. * exited: { opacity: 0 },
  806. * };
  807. *
  808. * const Fade = ({ in: inProp }) => (
  809. * <Transition in={inProp} timeout={duration}>
  810. * {state => (
  811. * <div style={{
  812. * ...defaultStyle,
  813. * ...transitionStyles[state]
  814. * }}>
  815. * I'm a fade Transition!
  816. * </div>
  817. * )}
  818. * </Transition>
  819. * );
  820. * ```
  821. *
  822. * There are 4 main states a Transition can be in:
  823. * - `'entering'`
  824. * - `'entered'`
  825. * - `'exiting'`
  826. * - `'exited'`
  827. *
  828. * Transition state is toggled via the `in` prop. When `true` the component
  829. * begins the "Enter" stage. During this stage, the component will shift from
  830. * its current transition state, to `'entering'` for the duration of the
  831. * transition and then to the `'entered'` stage once it's complete. Let's take
  832. * the following example (we'll use the
  833. * [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
  834. *
  835. * ```jsx
  836. * function App() {
  837. * const [inProp, setInProp] = useState(false);
  838. * return (
  839. * <div>
  840. * <Transition in={inProp} timeout={500}>
  841. * {state => (
  842. * // ...
  843. * )}
  844. * </Transition>
  845. * <button onClick={() => setInProp(true)}>
  846. * Click to Enter
  847. * </button>
  848. * </div>
  849. * );
  850. * }
  851. * ```
  852. *
  853. * When the button is clicked the component will shift to the `'entering'` state
  854. * and stay there for 500ms (the value of `timeout`) before it finally switches
  855. * to `'entered'`.
  856. *
  857. * When `in` is `false` the same thing happens except the state moves from
  858. * `'exiting'` to `'exited'`.
  859. */
  860. var Transition =
  861. /*#__PURE__*/
  862. function (_React$Component) {
  863. _inheritsLoose(Transition, _React$Component);
  864. function Transition(props, context) {
  865. var _this;
  866. _this = _React$Component.call(this, props, context) || this;
  867. var parentGroup = context; // In the context of a TransitionGroup all enters are really appears
  868. var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
  869. var initialStatus;
  870. _this.appearStatus = null;
  871. if (props.in) {
  872. if (appear) {
  873. initialStatus = EXITED;
  874. _this.appearStatus = ENTERING;
  875. } else {
  876. initialStatus = ENTERED;
  877. }
  878. } else {
  879. if (props.unmountOnExit || props.mountOnEnter) {
  880. initialStatus = UNMOUNTED;
  881. } else {
  882. initialStatus = EXITED;
  883. }
  884. }
  885. _this.state = {
  886. status: initialStatus
  887. };
  888. _this.nextCallback = null;
  889. return _this;
  890. }
  891. Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
  892. var nextIn = _ref.in;
  893. if (nextIn && prevState.status === UNMOUNTED) {
  894. return {
  895. status: EXITED
  896. };
  897. }
  898. return null;
  899. }; // getSnapshotBeforeUpdate(prevProps) {
  900. // let nextStatus = null
  901. // if (prevProps !== this.props) {
  902. // const { status } = this.state
  903. // if (this.props.in) {
  904. // if (status !== ENTERING && status !== ENTERED) {
  905. // nextStatus = ENTERING
  906. // }
  907. // } else {
  908. // if (status === ENTERING || status === ENTERED) {
  909. // nextStatus = EXITING
  910. // }
  911. // }
  912. // }
  913. // return { nextStatus }
  914. // }
  915. var _proto = Transition.prototype;
  916. _proto.componentDidMount = function componentDidMount() {
  917. this.updateStatus(true, this.appearStatus);
  918. };
  919. _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
  920. var nextStatus = null;
  921. if (prevProps !== this.props) {
  922. var status = this.state.status;
  923. if (this.props.in) {
  924. if (status !== ENTERING && status !== ENTERED) {
  925. nextStatus = ENTERING;
  926. }
  927. } else {
  928. if (status === ENTERING || status === ENTERED) {
  929. nextStatus = EXITING;
  930. }
  931. }
  932. }
  933. this.updateStatus(false, nextStatus);
  934. };
  935. _proto.componentWillUnmount = function componentWillUnmount() {
  936. this.cancelNextCallback();
  937. };
  938. _proto.getTimeouts = function getTimeouts() {
  939. var timeout = this.props.timeout;
  940. var exit, enter, appear;
  941. exit = enter = appear = timeout;
  942. if (timeout != null && typeof timeout !== 'number') {
  943. exit = timeout.exit;
  944. enter = timeout.enter; // TODO: remove fallback for next major
  945. appear = timeout.appear !== undefined ? timeout.appear : enter;
  946. }
  947. return {
  948. exit: exit,
  949. enter: enter,
  950. appear: appear
  951. };
  952. };
  953. _proto.updateStatus = function updateStatus(mounting, nextStatus) {
  954. if (mounting === void 0) {
  955. mounting = false;
  956. }
  957. if (nextStatus !== null) {
  958. // nextStatus will always be ENTERING or EXITING.
  959. this.cancelNextCallback();
  960. var node = ReactDOM.findDOMNode(this);
  961. if (nextStatus === ENTERING) {
  962. this.performEnter(node, mounting);
  963. } else {
  964. this.performExit(node);
  965. }
  966. } else if (this.props.unmountOnExit && this.state.status === EXITED) {
  967. this.setState({
  968. status: UNMOUNTED
  969. });
  970. }
  971. };
  972. _proto.performEnter = function performEnter(node, mounting) {
  973. var _this2 = this;
  974. var enter = this.props.enter;
  975. var appearing = this.context ? this.context.isMounting : mounting;
  976. var timeouts = this.getTimeouts();
  977. var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED
  978. // if we are mounting and running this it means appear _must_ be set
  979. if (!mounting && !enter || config.disabled) {
  980. this.safeSetState({
  981. status: ENTERED
  982. }, function () {
  983. _this2.props.onEntered(node);
  984. });
  985. return;
  986. }
  987. this.props.onEnter(node, appearing);
  988. this.safeSetState({
  989. status: ENTERING
  990. }, function () {
  991. _this2.props.onEntering(node, appearing);
  992. _this2.onTransitionEnd(node, enterTimeout, function () {
  993. _this2.safeSetState({
  994. status: ENTERED
  995. }, function () {
  996. _this2.props.onEntered(node, appearing);
  997. });
  998. });
  999. });
  1000. };
  1001. _proto.performExit = function performExit(node) {
  1002. var _this3 = this;
  1003. var exit = this.props.exit;
  1004. var timeouts = this.getTimeouts(); // no exit animation skip right to EXITED
  1005. if (!exit || config.disabled) {
  1006. this.safeSetState({
  1007. status: EXITED
  1008. }, function () {
  1009. _this3.props.onExited(node);
  1010. });
  1011. return;
  1012. }
  1013. this.props.onExit(node);
  1014. this.safeSetState({
  1015. status: EXITING
  1016. }, function () {
  1017. _this3.props.onExiting(node);
  1018. _this3.onTransitionEnd(node, timeouts.exit, function () {
  1019. _this3.safeSetState({
  1020. status: EXITED
  1021. }, function () {
  1022. _this3.props.onExited(node);
  1023. });
  1024. });
  1025. });
  1026. };
  1027. _proto.cancelNextCallback = function cancelNextCallback() {
  1028. if (this.nextCallback !== null) {
  1029. this.nextCallback.cancel();
  1030. this.nextCallback = null;
  1031. }
  1032. };
  1033. _proto.safeSetState = function safeSetState(nextState, callback) {
  1034. // This shouldn't be necessary, but there are weird race conditions with
  1035. // setState callbacks and unmounting in testing, so always make sure that
  1036. // we can cancel any pending setState callbacks after we unmount.
  1037. callback = this.setNextCallback(callback);
  1038. this.setState(nextState, callback);
  1039. };
  1040. _proto.setNextCallback = function setNextCallback(callback) {
  1041. var _this4 = this;
  1042. var active = true;
  1043. this.nextCallback = function (event) {
  1044. if (active) {
  1045. active = false;
  1046. _this4.nextCallback = null;
  1047. callback(event);
  1048. }
  1049. };
  1050. this.nextCallback.cancel = function () {
  1051. active = false;
  1052. };
  1053. return this.nextCallback;
  1054. };
  1055. _proto.onTransitionEnd = function onTransitionEnd(node, timeout, handler) {
  1056. this.setNextCallback(handler);
  1057. var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
  1058. if (!node || doesNotHaveTimeoutOrListener) {
  1059. setTimeout(this.nextCallback, 0);
  1060. return;
  1061. }
  1062. if (this.props.addEndListener) {
  1063. this.props.addEndListener(node, this.nextCallback);
  1064. }
  1065. if (timeout != null) {
  1066. setTimeout(this.nextCallback, timeout);
  1067. }
  1068. };
  1069. _proto.render = function render() {
  1070. var status = this.state.status;
  1071. if (status === UNMOUNTED) {
  1072. return null;
  1073. }
  1074. var _this$props = this.props,
  1075. children = _this$props.children,
  1076. childProps = _objectWithoutPropertiesLoose(_this$props, ["children"]); // filter props for Transtition
  1077. delete childProps.in;
  1078. delete childProps.mountOnEnter;
  1079. delete childProps.unmountOnExit;
  1080. delete childProps.appear;
  1081. delete childProps.enter;
  1082. delete childProps.exit;
  1083. delete childProps.timeout;
  1084. delete childProps.addEndListener;
  1085. delete childProps.onEnter;
  1086. delete childProps.onEntering;
  1087. delete childProps.onEntered;
  1088. delete childProps.onExit;
  1089. delete childProps.onExiting;
  1090. delete childProps.onExited;
  1091. if (typeof children === 'function') {
  1092. // allows for nested Transitions
  1093. return React__default.createElement(TransitionGroupContext.Provider, {
  1094. value: null
  1095. }, children(status, childProps));
  1096. }
  1097. var child = React__default.Children.only(children);
  1098. return (// allows for nested Transitions
  1099. React__default.createElement(TransitionGroupContext.Provider, {
  1100. value: null
  1101. }, React__default.cloneElement(child, childProps))
  1102. );
  1103. };
  1104. return Transition;
  1105. }(React__default.Component);
  1106. Transition.contextType = TransitionGroupContext;
  1107. Transition.propTypes = {
  1108. /**
  1109. * A `function` child can be used instead of a React element. This function is
  1110. * called with the current transition status (`'entering'`, `'entered'`,
  1111. * `'exiting'`, `'exited'`), which can be used to apply context
  1112. * specific props to a component.
  1113. *
  1114. * ```jsx
  1115. * <Transition in={this.state.in} timeout={150}>
  1116. * {state => (
  1117. * <MyComponent className={`fade fade-${state}`} />
  1118. * )}
  1119. * </Transition>
  1120. * ```
  1121. */
  1122. children: propTypes.oneOfType([propTypes.func.isRequired, propTypes.element.isRequired]).isRequired,
  1123. /**
  1124. * Show the component; triggers the enter or exit states
  1125. */
  1126. in: propTypes.bool,
  1127. /**
  1128. * By default the child component is mounted immediately along with
  1129. * the parent `Transition` component. If you want to "lazy mount" the component on the
  1130. * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
  1131. * mounted, even on "exited", unless you also specify `unmountOnExit`.
  1132. */
  1133. mountOnEnter: propTypes.bool,
  1134. /**
  1135. * By default the child component stays mounted after it reaches the `'exited'` state.
  1136. * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
  1137. */
  1138. unmountOnExit: propTypes.bool,
  1139. /**
  1140. * Normally a component is not transitioned if it is shown when the
  1141. * `<Transition>` component mounts. If you want to transition on the first
  1142. * mount set `appear` to `true`, and the component will transition in as soon
  1143. * as the `<Transition>` mounts.
  1144. *
  1145. * > **Note**: there are no special appear states like `appearing`/`appeared`, this prop
  1146. * > only adds an additional enter transition. However, in the
  1147. * > `<CSSTransition>` component that first enter transition does result in
  1148. * > additional `.appear-*` classes, that way you can choose to style it
  1149. * > differently.
  1150. */
  1151. appear: propTypes.bool,
  1152. /**
  1153. * Enable or disable enter transitions.
  1154. */
  1155. enter: propTypes.bool,
  1156. /**
  1157. * Enable or disable exit transitions.
  1158. */
  1159. exit: propTypes.bool,
  1160. /**
  1161. * The duration of the transition, in milliseconds.
  1162. * Required unless `addEndListener` is provided.
  1163. *
  1164. * You may specify a single timeout for all transitions:
  1165. *
  1166. * ```jsx
  1167. * timeout={500}
  1168. * ```
  1169. *
  1170. * or individually:
  1171. *
  1172. * ```jsx
  1173. * timeout={{
  1174. * appear: 500,
  1175. * enter: 300,
  1176. * exit: 500,
  1177. * }}
  1178. * ```
  1179. *
  1180. * - `appear` defaults to the value of `enter`
  1181. * - `enter` defaults to `0`
  1182. * - `exit` defaults to `0`
  1183. *
  1184. * @type {number | { enter?: number, exit?: number, appear?: number }}
  1185. */
  1186. timeout: function timeout(props) {
  1187. var pt = timeoutsShape;
  1188. if (!props.addEndListener) pt = pt.isRequired;
  1189. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1190. args[_key - 1] = arguments[_key];
  1191. }
  1192. return pt.apply(void 0, [props].concat(args));
  1193. },
  1194. /**
  1195. * Add a custom transition end trigger. Called with the transitioning
  1196. * DOM node and a `done` callback. Allows for more fine grained transition end
  1197. * logic. **Note:** Timeouts are still used as a fallback if provided.
  1198. *
  1199. * ```jsx
  1200. * addEndListener={(node, done) => {
  1201. * // use the css transitionend event to mark the finish of a transition
  1202. * node.addEventListener('transitionend', done, false);
  1203. * }}
  1204. * ```
  1205. */
  1206. addEndListener: propTypes.func,
  1207. /**
  1208. * Callback fired before the "entering" status is applied. An extra parameter
  1209. * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
  1210. *
  1211. * @type Function(node: HtmlElement, isAppearing: bool) -> void
  1212. */
  1213. onEnter: propTypes.func,
  1214. /**
  1215. * Callback fired after the "entering" status is applied. An extra parameter
  1216. * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
  1217. *
  1218. * @type Function(node: HtmlElement, isAppearing: bool)
  1219. */
  1220. onEntering: propTypes.func,
  1221. /**
  1222. * Callback fired after the "entered" status is applied. An extra parameter
  1223. * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
  1224. *
  1225. * @type Function(node: HtmlElement, isAppearing: bool) -> void
  1226. */
  1227. onEntered: propTypes.func,
  1228. /**
  1229. * Callback fired before the "exiting" status is applied.
  1230. *
  1231. * @type Function(node: HtmlElement) -> void
  1232. */
  1233. onExit: propTypes.func,
  1234. /**
  1235. * Callback fired after the "exiting" status is applied.
  1236. *
  1237. * @type Function(node: HtmlElement) -> void
  1238. */
  1239. onExiting: propTypes.func,
  1240. /**
  1241. * Callback fired after the "exited" status is applied.
  1242. *
  1243. * @type Function(node: HtmlElement) -> void
  1244. */
  1245. onExited: propTypes.func // Name the function so it is clearer in the documentation
  1246. };
  1247. function noop() {}
  1248. Transition.defaultProps = {
  1249. in: false,
  1250. mountOnEnter: false,
  1251. unmountOnExit: false,
  1252. appear: false,
  1253. enter: true,
  1254. exit: true,
  1255. onEnter: noop,
  1256. onEntering: noop,
  1257. onEntered: noop,
  1258. onExit: noop,
  1259. onExiting: noop,
  1260. onExited: noop
  1261. };
  1262. Transition.UNMOUNTED = 0;
  1263. Transition.EXITED = 1;
  1264. Transition.ENTERING = 2;
  1265. Transition.ENTERED = 3;
  1266. Transition.EXITING = 4;
  1267. var _addClass = function addClass$1(node, classes) {
  1268. return node && classes && classes.split(' ').forEach(function (c) {
  1269. return addClass(node, c);
  1270. });
  1271. };
  1272. var removeClass$1 = function removeClass$1(node, classes) {
  1273. return node && classes && classes.split(' ').forEach(function (c) {
  1274. return removeClass(node, c);
  1275. });
  1276. };
  1277. /**
  1278. * A transition component inspired by the excellent
  1279. * [ng-animate](http://www.nganimate.org/) library, you should use it if you're
  1280. * using CSS transitions or animations. It's built upon the
  1281. * [`Transition`](https://reactcommunity.org/react-transition-group/transition)
  1282. * component, so it inherits all of its props.
  1283. *
  1284. * `CSSTransition` applies a pair of class names during the `appear`, `enter`,
  1285. * and `exit` states of the transition. The first class is applied and then a
  1286. * second `*-active` class in order to activate the CSS transition. After the
  1287. * transition, matching `*-done` class names are applied to persist the
  1288. * transition state.
  1289. *
  1290. * ```jsx
  1291. * function App() {
  1292. * const [inProp, setInProp] = useState(false);
  1293. * return (
  1294. * <div>
  1295. * <CSSTransition in={inProp} timeout={200} classNames="my-node">
  1296. * <div>
  1297. * {"I'll receive my-node-* classes"}
  1298. * </div>
  1299. * </CSSTransition>
  1300. * <button type="button" onClick={() => setInProp(true)}>
  1301. * Click to Enter
  1302. * </button>
  1303. * </div>
  1304. * );
  1305. * }
  1306. * ```
  1307. *
  1308. * When the `in` prop is set to `true`, the child component will first receive
  1309. * the class `example-enter`, then the `example-enter-active` will be added in
  1310. * the next tick. `CSSTransition` [forces a
  1311. * reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)
  1312. * between before adding the `example-enter-active`. This is an important trick
  1313. * because it allows us to transition between `example-enter` and
  1314. * `example-enter-active` even though they were added immediately one after
  1315. * another. Most notably, this is what makes it possible for us to animate
  1316. * _appearance_.
  1317. *
  1318. * ```css
  1319. * .my-node-enter {
  1320. * opacity: 0;
  1321. * }
  1322. * .my-node-enter-active {
  1323. * opacity: 1;
  1324. * transition: opacity 200ms;
  1325. * }
  1326. * .my-node-exit {
  1327. * opacity: 1;
  1328. * }
  1329. * .my-node-exit-active {
  1330. * opacity: 0;
  1331. * transition: opacity 200ms;
  1332. * }
  1333. * ```
  1334. *
  1335. * `*-active` classes represent which styles you want to animate **to**.
  1336. *
  1337. * **Note**: If you're using the
  1338. * [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)
  1339. * prop, make sure to define styles for `.appear-*` classes as well.
  1340. */
  1341. var CSSTransition =
  1342. /*#__PURE__*/
  1343. function (_React$Component) {
  1344. _inheritsLoose(CSSTransition, _React$Component);
  1345. function CSSTransition() {
  1346. var _this;
  1347. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1348. args[_key] = arguments[_key];
  1349. }
  1350. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  1351. _this.appliedClasses = {
  1352. appear: {},
  1353. enter: {},
  1354. exit: {}
  1355. };
  1356. _this.onEnter = function (node, appearing) {
  1357. _this.removeClasses(node, 'exit');
  1358. _this.addClass(node, appearing ? 'appear' : 'enter', 'base');
  1359. if (_this.props.onEnter) {
  1360. _this.props.onEnter(node, appearing);
  1361. }
  1362. };
  1363. _this.onEntering = function (node, appearing) {
  1364. var type = appearing ? 'appear' : 'enter';
  1365. _this.addClass(node, type, 'active');
  1366. if (_this.props.onEntering) {
  1367. _this.props.onEntering(node, appearing);
  1368. }
  1369. };
  1370. _this.onEntered = function (node, appearing) {
  1371. var type = appearing ? 'appear' : 'enter';
  1372. _this.removeClasses(node, type);
  1373. _this.addClass(node, type, 'done');
  1374. if (_this.props.onEntered) {
  1375. _this.props.onEntered(node, appearing);
  1376. }
  1377. };
  1378. _this.onExit = function (node) {
  1379. _this.removeClasses(node, 'appear');
  1380. _this.removeClasses(node, 'enter');
  1381. _this.addClass(node, 'exit', 'base');
  1382. if (_this.props.onExit) {
  1383. _this.props.onExit(node);
  1384. }
  1385. };
  1386. _this.onExiting = function (node) {
  1387. _this.addClass(node, 'exit', 'active');
  1388. if (_this.props.onExiting) {
  1389. _this.props.onExiting(node);
  1390. }
  1391. };
  1392. _this.onExited = function (node) {
  1393. _this.removeClasses(node, 'exit');
  1394. _this.addClass(node, 'exit', 'done');
  1395. if (_this.props.onExited) {
  1396. _this.props.onExited(node);
  1397. }
  1398. };
  1399. _this.getClassNames = function (type) {
  1400. var classNames = _this.props.classNames;
  1401. var isStringClassNames = typeof classNames === 'string';
  1402. var prefix = isStringClassNames && classNames ? classNames + "-" : '';
  1403. var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type];
  1404. var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"];
  1405. var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"];
  1406. return {
  1407. baseClassName: baseClassName,
  1408. activeClassName: activeClassName,
  1409. doneClassName: doneClassName
  1410. };
  1411. };
  1412. return _this;
  1413. }
  1414. var _proto = CSSTransition.prototype;
  1415. _proto.addClass = function addClass(node, type, phase) {
  1416. var className = this.getClassNames(type)[phase + "ClassName"];
  1417. if (type === 'appear' && phase === 'done') {
  1418. className += " " + this.getClassNames('enter').doneClassName;
  1419. } // This is for to force a repaint,
  1420. // which is necessary in order to transition styles when adding a class name.
  1421. if (phase === 'active') {
  1422. /* eslint-disable no-unused-expressions */
  1423. node && node.scrollTop;
  1424. }
  1425. this.appliedClasses[type][phase] = className;
  1426. _addClass(node, className);
  1427. };
  1428. _proto.removeClasses = function removeClasses(node, type) {
  1429. var _this$appliedClasses$ = this.appliedClasses[type],
  1430. baseClassName = _this$appliedClasses$.base,
  1431. activeClassName = _this$appliedClasses$.active,
  1432. doneClassName = _this$appliedClasses$.done;
  1433. this.appliedClasses[type] = {};
  1434. if (baseClassName) {
  1435. removeClass$1(node, baseClassName);
  1436. }
  1437. if (activeClassName) {
  1438. removeClass$1(node, activeClassName);
  1439. }
  1440. if (doneClassName) {
  1441. removeClass$1(node, doneClassName);
  1442. }
  1443. };
  1444. _proto.render = function render() {
  1445. var _this$props = this.props,
  1446. _ = _this$props.classNames,
  1447. props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]);
  1448. return React__default.createElement(Transition, _extends({}, props, {
  1449. onEnter: this.onEnter,
  1450. onEntered: this.onEntered,
  1451. onEntering: this.onEntering,
  1452. onExit: this.onExit,
  1453. onExiting: this.onExiting,
  1454. onExited: this.onExited
  1455. }));
  1456. };
  1457. return CSSTransition;
  1458. }(React__default.Component);
  1459. CSSTransition.defaultProps = {
  1460. classNames: ''
  1461. };
  1462. CSSTransition.propTypes = _extends({}, Transition.propTypes, {
  1463. /**
  1464. * The animation classNames applied to the component as it appears, enters,
  1465. * exits or has finished the transition. A single name can be provided and it
  1466. * will be suffixed for each stage: e.g.
  1467. *
  1468. * `classNames="fade"` applies `fade-appear`, `fade-appear-active`,
  1469. * `fade-appear-done`, `fade-enter`, `fade-enter-active`, `fade-enter-done`,
  1470. * `fade-exit`, `fade-exit-active`, and `fade-exit-done`.
  1471. *
  1472. * **Note**: `fade-appear-done` and `fade-enter-done` will _both_ be applied.
  1473. * This allows you to define different behavior for when appearing is done and
  1474. * when regular entering is done, using selectors like
  1475. * `.fade-enter-done:not(.fade-appear-done)`. For example, you could apply an
  1476. * epic entrance animation when element first appears in the DOM using
  1477. * [Animate.css](https://daneden.github.io/animate.css/). Otherwise you can
  1478. * simply use `fade-enter-done` for defining both cases.
  1479. *
  1480. * Each individual classNames can also be specified independently like:
  1481. *
  1482. * ```js
  1483. * classNames={{
  1484. * appear: 'my-appear',
  1485. * appearActive: 'my-active-appear',
  1486. * appearDone: 'my-done-appear',
  1487. * enter: 'my-enter',
  1488. * enterActive: 'my-active-enter',
  1489. * enterDone: 'my-done-enter',
  1490. * exit: 'my-exit',
  1491. * exitActive: 'my-active-exit',
  1492. * exitDone: 'my-done-exit',
  1493. * }}
  1494. * ```
  1495. *
  1496. * If you want to set these classes using CSS Modules:
  1497. *
  1498. * ```js
  1499. * import styles from './styles.css';
  1500. * ```
  1501. *
  1502. * you might want to use camelCase in your CSS file, that way could simply
  1503. * spread them instead of listing them one by one:
  1504. *
  1505. * ```js
  1506. * classNames={{ ...styles }}
  1507. * ```
  1508. *
  1509. * @type {string | {
  1510. * appear?: string,
  1511. * appearActive?: string,
  1512. * appearDone?: string,
  1513. * enter?: string,
  1514. * enterActive?: string,
  1515. * enterDone?: string,
  1516. * exit?: string,
  1517. * exitActive?: string,
  1518. * exitDone?: string,
  1519. * }}
  1520. */
  1521. classNames: classNamesShape,
  1522. /**
  1523. * A `<Transition>` callback fired immediately after the 'enter' or 'appear' class is
  1524. * applied.
  1525. *
  1526. * @type Function(node: HtmlElement, isAppearing: bool)
  1527. */
  1528. onEnter: propTypes.func,
  1529. /**
  1530. * A `<Transition>` callback fired immediately after the 'enter-active' or
  1531. * 'appear-active' class is applied.
  1532. *
  1533. * @type Function(node: HtmlElement, isAppearing: bool)
  1534. */
  1535. onEntering: propTypes.func,
  1536. /**
  1537. * A `<Transition>` callback fired immediately after the 'enter' or
  1538. * 'appear' classes are **removed** and the `done` class is added to the DOM node.
  1539. *
  1540. * @type Function(node: HtmlElement, isAppearing: bool)
  1541. */
  1542. onEntered: propTypes.func,
  1543. /**
  1544. * A `<Transition>` callback fired immediately after the 'exit' class is
  1545. * applied.
  1546. *
  1547. * @type Function(node: HtmlElement)
  1548. */
  1549. onExit: propTypes.func,
  1550. /**
  1551. * A `<Transition>` callback fired immediately after the 'exit-active' is applied.
  1552. *
  1553. * @type Function(node: HtmlElement)
  1554. */
  1555. onExiting: propTypes.func,
  1556. /**
  1557. * A `<Transition>` callback fired immediately after the 'exit' classes
  1558. * are **removed** and the `exit-done` class is added to the DOM node.
  1559. *
  1560. * @type Function(node: HtmlElement)
  1561. */
  1562. onExited: propTypes.func
  1563. });
  1564. function _assertThisInitialized(self) {
  1565. if (self === void 0) {
  1566. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1567. }
  1568. return self;
  1569. }
  1570. /**
  1571. * Given `this.props.children`, return an object mapping key to child.
  1572. *
  1573. * @param {*} children `this.props.children`
  1574. * @return {object} Mapping of key to child
  1575. */
  1576. function getChildMapping(children, mapFn) {
  1577. var mapper = function mapper(child) {
  1578. return mapFn && React.isValidElement(child) ? mapFn(child) : child;
  1579. };
  1580. var result = Object.create(null);
  1581. if (children) React.Children.map(children, function (c) {
  1582. return c;
  1583. }).forEach(function (child) {
  1584. // run the map function here instead so that the key is the computed one
  1585. result[child.key] = mapper(child);
  1586. });
  1587. return result;
  1588. }
  1589. /**
  1590. * When you're adding or removing children some may be added or removed in the
  1591. * same render pass. We want to show *both* since we want to simultaneously
  1592. * animate elements in and out. This function takes a previous set of keys
  1593. * and a new set of keys and merges them with its best guess of the correct
  1594. * ordering. In the future we may expose some of the utilities in
  1595. * ReactMultiChild to make this easy, but for now React itself does not
  1596. * directly have this concept of the union of prevChildren and nextChildren
  1597. * so we implement it here.
  1598. *
  1599. * @param {object} prev prev children as returned from
  1600. * `ReactTransitionChildMapping.getChildMapping()`.
  1601. * @param {object} next next children as returned from
  1602. * `ReactTransitionChildMapping.getChildMapping()`.
  1603. * @return {object} a key set that contains all keys in `prev` and all keys
  1604. * in `next` in a reasonable order.
  1605. */
  1606. function mergeChildMappings(prev, next) {
  1607. prev = prev || {};
  1608. next = next || {};
  1609. function getValueForKey(key) {
  1610. return key in next ? next[key] : prev[key];
  1611. } // For each key of `next`, the list of keys to insert before that key in
  1612. // the combined list
  1613. var nextKeysPending = Object.create(null);
  1614. var pendingKeys = [];
  1615. for (var prevKey in prev) {
  1616. if (prevKey in next) {
  1617. if (pendingKeys.length) {
  1618. nextKeysPending[prevKey] = pendingKeys;
  1619. pendingKeys = [];
  1620. }
  1621. } else {
  1622. pendingKeys.push(prevKey);
  1623. }
  1624. }
  1625. var i;
  1626. var childMapping = {};
  1627. for (var nextKey in next) {
  1628. if (nextKeysPending[nextKey]) {
  1629. for (i = 0; i < nextKeysPending[nextKey].length; i++) {
  1630. var pendingNextKey = nextKeysPending[nextKey][i];
  1631. childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
  1632. }
  1633. }
  1634. childMapping[nextKey] = getValueForKey(nextKey);
  1635. } // Finally, add the keys which didn't appear before any key in `next`
  1636. for (i = 0; i < pendingKeys.length; i++) {
  1637. childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
  1638. }
  1639. return childMapping;
  1640. }
  1641. function getProp(child, prop, props) {
  1642. return props[prop] != null ? props[prop] : child.props[prop];
  1643. }
  1644. function getInitialChildMapping(props, onExited) {
  1645. return getChildMapping(props.children, function (child) {
  1646. return React.cloneElement(child, {
  1647. onExited: onExited.bind(null, child),
  1648. in: true,
  1649. appear: getProp(child, 'appear', props),
  1650. enter: getProp(child, 'enter', props),
  1651. exit: getProp(child, 'exit', props)
  1652. });
  1653. });
  1654. }
  1655. function getNextChildMapping(nextProps, prevChildMapping, onExited) {
  1656. var nextChildMapping = getChildMapping(nextProps.children);
  1657. var children = mergeChildMappings(prevChildMapping, nextChildMapping);
  1658. Object.keys(children).forEach(function (key) {
  1659. var child = children[key];
  1660. if (!React.isValidElement(child)) return;
  1661. var hasPrev = key in prevChildMapping;
  1662. var hasNext = key in nextChildMapping;
  1663. var prevChild = prevChildMapping[key];
  1664. var isLeaving = React.isValidElement(prevChild) && !prevChild.props.in; // item is new (entering)
  1665. if (hasNext && (!hasPrev || isLeaving)) {
  1666. // console.log('entering', key)
  1667. children[key] = React.cloneElement(child, {
  1668. onExited: onExited.bind(null, child),
  1669. in: true,
  1670. exit: getProp(child, 'exit', nextProps),
  1671. enter: getProp(child, 'enter', nextProps)
  1672. });
  1673. } else if (!hasNext && hasPrev && !isLeaving) {
  1674. // item is old (exiting)
  1675. // console.log('leaving', key)
  1676. children[key] = React.cloneElement(child, {
  1677. in: false
  1678. });
  1679. } else if (hasNext && hasPrev && React.isValidElement(prevChild)) {
  1680. // item hasn't changed transition states
  1681. // copy over the last transition props;
  1682. // console.log('unchanged', key)
  1683. children[key] = React.cloneElement(child, {
  1684. onExited: onExited.bind(null, child),
  1685. in: prevChild.props.in,
  1686. exit: getProp(child, 'exit', nextProps),
  1687. enter: getProp(child, 'enter', nextProps)
  1688. });
  1689. }
  1690. });
  1691. return children;
  1692. }
  1693. var values = Object.values || function (obj) {
  1694. return Object.keys(obj).map(function (k) {
  1695. return obj[k];
  1696. });
  1697. };
  1698. var defaultProps = {
  1699. component: 'div',
  1700. childFactory: function childFactory(child) {
  1701. return child;
  1702. }
  1703. /**
  1704. * The `<TransitionGroup>` component manages a set of transition components
  1705. * (`<Transition>` and `<CSSTransition>`) in a list. Like with the transition
  1706. * components, `<TransitionGroup>` is a state machine for managing the mounting
  1707. * and unmounting of components over time.
  1708. *
  1709. * Consider the example below. As items are removed or added to the TodoList the
  1710. * `in` prop is toggled automatically by the `<TransitionGroup>`.
  1711. *
  1712. * Note that `<TransitionGroup>` does not define any animation behavior!
  1713. * Exactly _how_ a list item animates is up to the individual transition
  1714. * component. This means you can mix and match animations across different list
  1715. * items.
  1716. */
  1717. };
  1718. var TransitionGroup =
  1719. /*#__PURE__*/
  1720. function (_React$Component) {
  1721. _inheritsLoose(TransitionGroup, _React$Component);
  1722. function TransitionGroup(props, context) {
  1723. var _this;
  1724. _this = _React$Component.call(this, props, context) || this;
  1725. var handleExited = _this.handleExited.bind(_assertThisInitialized(_assertThisInitialized(_this))); // Initial children should all be entering, dependent on appear
  1726. _this.state = {
  1727. contextValue: {
  1728. isMounting: true
  1729. },
  1730. handleExited: handleExited,
  1731. firstRender: true
  1732. };
  1733. return _this;
  1734. }
  1735. var _proto = TransitionGroup.prototype;
  1736. _proto.componentDidMount = function componentDidMount() {
  1737. this.mounted = true;
  1738. this.setState({
  1739. contextValue: {
  1740. isMounting: false
  1741. }
  1742. });
  1743. };
  1744. _proto.componentWillUnmount = function componentWillUnmount() {
  1745. this.mounted = false;
  1746. };
  1747. TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {
  1748. var prevChildMapping = _ref.children,
  1749. handleExited = _ref.handleExited,
  1750. firstRender = _ref.firstRender;
  1751. return {
  1752. children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),
  1753. firstRender: false
  1754. };
  1755. };
  1756. _proto.handleExited = function handleExited(child, node) {
  1757. var currentChildMapping = getChildMapping(this.props.children);
  1758. if (child.key in currentChildMapping) return;
  1759. if (child.props.onExited) {
  1760. child.props.onExited(node);
  1761. }
  1762. if (this.mounted) {
  1763. this.setState(function (state) {
  1764. var children = _extends({}, state.children);
  1765. delete children[child.key];
  1766. return {
  1767. children: children
  1768. };
  1769. });
  1770. }
  1771. };
  1772. _proto.render = function render() {
  1773. var _this$props = this.props,
  1774. Component = _this$props.component,
  1775. childFactory = _this$props.childFactory,
  1776. props = _objectWithoutPropertiesLoose(_this$props, ["component", "childFactory"]);
  1777. var contextValue = this.state.contextValue;
  1778. var children = values(this.state.children).map(childFactory);
  1779. delete props.appear;
  1780. delete props.enter;
  1781. delete props.exit;
  1782. if (Component === null) {
  1783. return React__default.createElement(TransitionGroupContext.Provider, {
  1784. value: contextValue
  1785. }, children);
  1786. }
  1787. return React__default.createElement(TransitionGroupContext.Provider, {
  1788. value: contextValue
  1789. }, React__default.createElement(Component, props, children));
  1790. };
  1791. return TransitionGroup;
  1792. }(React__default.Component);
  1793. TransitionGroup.propTypes = {
  1794. /**
  1795. * `<TransitionGroup>` renders a `<div>` by default. You can change this
  1796. * behavior by providing a `component` prop.
  1797. * If you use React v16+ and would like to avoid a wrapping `<div>` element
  1798. * you can pass in `component={null}`. This is useful if the wrapping div
  1799. * borks your css styles.
  1800. */
  1801. component: propTypes.any,
  1802. /**
  1803. * A set of `<Transition>` components, that are toggled `in` and out as they
  1804. * leave. the `<TransitionGroup>` will inject specific transition props, so
  1805. * remember to spread them through if you are wrapping the `<Transition>` as
  1806. * with our `<Fade>` example.
  1807. *
  1808. * While this component is meant for multiple `Transition` or `CSSTransition`
  1809. * children, sometimes you may want to have a single transition child with
  1810. * content that you want to be transitioned out and in when you change it
  1811. * (e.g. routes, images etc.) In that case you can change the `key` prop of
  1812. * the transition child as you change its content, this will cause
  1813. * `TransitionGroup` to transition the child out and back in.
  1814. */
  1815. children: propTypes.node,
  1816. /**
  1817. * A convenience prop that enables or disables appear animations
  1818. * for all children. Note that specifying this will override any defaults set
  1819. * on individual children Transitions.
  1820. */
  1821. appear: propTypes.bool,
  1822. /**
  1823. * A convenience prop that enables or disables enter animations
  1824. * for all children. Note that specifying this will override any defaults set
  1825. * on individual children Transitions.
  1826. */
  1827. enter: propTypes.bool,
  1828. /**
  1829. * A convenience prop that enables or disables exit animations
  1830. * for all children. Note that specifying this will override any defaults set
  1831. * on individual children Transitions.
  1832. */
  1833. exit: propTypes.bool,
  1834. /**
  1835. * You may need to apply reactive updates to a child as it is exiting.
  1836. * This is generally done by using `cloneElement` however in the case of an exiting
  1837. * child the element has already been removed and not accessible to the consumer.
  1838. *
  1839. * If you do need to update a child as it leaves you can provide a `childFactory`
  1840. * to wrap every child, even the ones that are leaving.
  1841. *
  1842. * @type Function(child: ReactElement) -> ReactElement
  1843. */
  1844. childFactory: propTypes.func
  1845. };
  1846. TransitionGroup.defaultProps = defaultProps;
  1847. /**
  1848. * The `<ReplaceTransition>` component is a specialized `Transition` component
  1849. * that animates between two children.
  1850. *
  1851. * ```jsx
  1852. * <ReplaceTransition in>
  1853. * <Fade><div>I appear first</div></Fade>
  1854. * <Fade><div>I replace the above</div></Fade>
  1855. * </ReplaceTransition>
  1856. * ```
  1857. */
  1858. var ReplaceTransition =
  1859. /*#__PURE__*/
  1860. function (_React$Component) {
  1861. _inheritsLoose(ReplaceTransition, _React$Component);
  1862. function ReplaceTransition() {
  1863. var _this;
  1864. for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
  1865. _args[_key] = arguments[_key];
  1866. }
  1867. _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
  1868. _this.handleEnter = function () {
  1869. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1870. args[_key2] = arguments[_key2];
  1871. }
  1872. return _this.handleLifecycle('onEnter', 0, args);
  1873. };
  1874. _this.handleEntering = function () {
  1875. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1876. args[_key3] = arguments[_key3];
  1877. }
  1878. return _this.handleLifecycle('onEntering', 0, args);
  1879. };
  1880. _this.handleEntered = function () {
  1881. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  1882. args[_key4] = arguments[_key4];
  1883. }
  1884. return _this.handleLifecycle('onEntered', 0, args);
  1885. };
  1886. _this.handleExit = function () {
  1887. for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  1888. args[_key5] = arguments[_key5];
  1889. }
  1890. return _this.handleLifecycle('onExit', 1, args);
  1891. };
  1892. _this.handleExiting = function () {
  1893. for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1894. args[_key6] = arguments[_key6];
  1895. }
  1896. return _this.handleLifecycle('onExiting', 1, args);
  1897. };
  1898. _this.handleExited = function () {
  1899. for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1900. args[_key7] = arguments[_key7];
  1901. }
  1902. return _this.handleLifecycle('onExited', 1, args);
  1903. };
  1904. return _this;
  1905. }
  1906. var _proto = ReplaceTransition.prototype;
  1907. _proto.handleLifecycle = function handleLifecycle(handler, idx, originalArgs) {
  1908. var _child$props;
  1909. var children = this.props.children;
  1910. var child = React__default.Children.toArray(children)[idx];
  1911. if (child.props[handler]) (_child$props = child.props)[handler].apply(_child$props, originalArgs);
  1912. if (this.props[handler]) this.props[handler](ReactDOM.findDOMNode(this));
  1913. };
  1914. _proto.render = function render() {
  1915. var _this$props = this.props,
  1916. children = _this$props.children,
  1917. inProp = _this$props.in,
  1918. props = _objectWithoutPropertiesLoose(_this$props, ["children", "in"]);
  1919. var _React$Children$toArr = React__default.Children.toArray(children),
  1920. first = _React$Children$toArr[0],
  1921. second = _React$Children$toArr[1];
  1922. delete props.onEnter;
  1923. delete props.onEntering;
  1924. delete props.onEntered;
  1925. delete props.onExit;
  1926. delete props.onExiting;
  1927. delete props.onExited;
  1928. return React__default.createElement(TransitionGroup, props, inProp ? React__default.cloneElement(first, {
  1929. key: 'first',
  1930. onEnter: this.handleEnter,
  1931. onEntering: this.handleEntering,
  1932. onEntered: this.handleEntered
  1933. }) : React__default.cloneElement(second, {
  1934. key: 'second',
  1935. onEnter: this.handleExit,
  1936. onEntering: this.handleExiting,
  1937. onEntered: this.handleExited
  1938. }));
  1939. };
  1940. return ReplaceTransition;
  1941. }(React__default.Component);
  1942. ReplaceTransition.propTypes = {
  1943. in: propTypes.bool.isRequired,
  1944. children: function children(props, propName) {
  1945. if (React__default.Children.count(props[propName]) !== 2) return new Error("\"" + propName + "\" must be exactly two transition components.");
  1946. return null;
  1947. }
  1948. };
  1949. var _leaveRenders, _enterRenders;
  1950. function areChildrenDifferent(oldChildren, newChildren) {
  1951. if (oldChildren === newChildren) return false;
  1952. if (React__default.isValidElement(oldChildren) && React__default.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) {
  1953. return false;
  1954. }
  1955. return true;
  1956. }
  1957. /**
  1958. * Enum of modes for SwitchTransition component
  1959. * @enum { string }
  1960. */
  1961. var modes = {
  1962. out: 'out-in',
  1963. in: 'in-out'
  1964. };
  1965. var callHook = function callHook(element, name, cb) {
  1966. return function () {
  1967. var _element$props;
  1968. element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments);
  1969. cb();
  1970. };
  1971. };
  1972. var leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) {
  1973. var current = _ref.current,
  1974. changeState = _ref.changeState;
  1975. return React__default.cloneElement(current, {
  1976. in: false,
  1977. onExited: callHook(current, 'onExited', function () {
  1978. changeState(ENTERING, null);
  1979. })
  1980. });
  1981. }, _leaveRenders[modes.in] = function (_ref2) {
  1982. var current = _ref2.current,
  1983. changeState = _ref2.changeState,
  1984. children = _ref2.children;
  1985. return [current, React__default.cloneElement(children, {
  1986. in: true,
  1987. onEntered: callHook(children, 'onEntered', function () {
  1988. changeState(ENTERING);
  1989. })
  1990. })];
  1991. }, _leaveRenders);
  1992. var enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) {
  1993. var children = _ref3.children,
  1994. changeState = _ref3.changeState;
  1995. return React__default.cloneElement(children, {
  1996. in: true,
  1997. onEntered: callHook(children, 'onEntered', function () {
  1998. changeState(ENTERED, React__default.cloneElement(children, {
  1999. in: true
  2000. }));
  2001. })
  2002. });
  2003. }, _enterRenders[modes.in] = function (_ref4) {
  2004. var current = _ref4.current,
  2005. children = _ref4.children,
  2006. changeState = _ref4.changeState;
  2007. return [React__default.cloneElement(current, {
  2008. in: false,
  2009. onExited: callHook(current, 'onExited', function () {
  2010. changeState(ENTERED, React__default.cloneElement(children, {
  2011. in: true
  2012. }));
  2013. })
  2014. }), React__default.cloneElement(children, {
  2015. in: true
  2016. })];
  2017. }, _enterRenders);
  2018. /**
  2019. * A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).
  2020. * You can use it when you want to control the render between state transitions.
  2021. * Based on the selected mode and the child's key which is the `Transition` or `CSSTransition` component, the `SwitchTransition` makes a consistent transition between them.
  2022. *
  2023. * If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.
  2024. * If the `in-out` mode is selected, the `SwitchTransition` inserts a new child first, waits for the new child to enter and then removes the old child
  2025. *
  2026. * ```jsx
  2027. *
  2028. * function App() {
  2029. * const [state, setState] = useState(false);
  2030. * return (
  2031. * <SwitchTransition>
  2032. * <FadeTransition key={state ? "Goodbye, world!" : "Hello, world!"}
  2033. * addEndListener={(node, done) => node.addEventListener("transitionend", done, false)}
  2034. * classNames='fade' >
  2035. * <button onClick={() => setState(state => !state)}>
  2036. * {state ? "Goodbye, world!" : "Hello, world!"}
  2037. * </button>
  2038. * </FadeTransition>
  2039. * </SwitchTransition>
  2040. * )
  2041. * }
  2042. * ```
  2043. */
  2044. var SwitchTransition =
  2045. /*#__PURE__*/
  2046. function (_React$Component) {
  2047. _inheritsLoose(SwitchTransition, _React$Component);
  2048. function SwitchTransition() {
  2049. var _this;
  2050. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2051. args[_key] = arguments[_key];
  2052. }
  2053. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  2054. _this.state = {
  2055. status: ENTERED,
  2056. current: null
  2057. };
  2058. _this.appeared = false;
  2059. _this.changeState = function (status, current) {
  2060. if (current === void 0) {
  2061. current = _this.state.current;
  2062. }
  2063. _this.setState({
  2064. status: status,
  2065. current: current
  2066. });
  2067. };
  2068. return _this;
  2069. }
  2070. var _proto = SwitchTransition.prototype;
  2071. _proto.componentDidMount = function componentDidMount() {
  2072. this.appeared = true;
  2073. };
  2074. SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
  2075. if (props.children == null) {
  2076. return {
  2077. current: null
  2078. };
  2079. }
  2080. if (state.status === ENTERING && props.mode === modes.in) {
  2081. return {
  2082. status: ENTERING
  2083. };
  2084. }
  2085. if (state.current && areChildrenDifferent(state.current, props.children)) {
  2086. return {
  2087. status: EXITING
  2088. };
  2089. }
  2090. return {
  2091. current: React__default.cloneElement(props.children, {
  2092. in: true
  2093. })
  2094. };
  2095. };
  2096. _proto.render = function render() {
  2097. var _this$props = this.props,
  2098. children = _this$props.children,
  2099. mode = _this$props.mode,
  2100. _this$state = this.state,
  2101. status = _this$state.status,
  2102. current = _this$state.current;
  2103. var data = {
  2104. children: children,
  2105. current: current,
  2106. changeState: this.changeState,
  2107. status: status
  2108. };
  2109. var component;
  2110. switch (status) {
  2111. case ENTERING:
  2112. component = enterRenders[mode](data);
  2113. break;
  2114. case EXITING:
  2115. component = leaveRenders[mode](data);
  2116. break;
  2117. case ENTERED:
  2118. component = current;
  2119. }
  2120. return React__default.createElement(TransitionGroupContext.Provider, {
  2121. value: {
  2122. isMounting: !this.appeared
  2123. }
  2124. }, component);
  2125. };
  2126. return SwitchTransition;
  2127. }(React__default.Component);
  2128. SwitchTransition.propTypes = {
  2129. /**
  2130. * Transition modes.
  2131. * `out-in`: Current element transitions out first, then when complete, the new element transitions in.
  2132. * `in-out: New element transitions in first, then when complete, the current element transitions out.`
  2133. *
  2134. * @type {'out-in'|'in-out'}
  2135. */
  2136. mode: propTypes.oneOf([modes.in, modes.out]),
  2137. /**
  2138. * Any `Transition` or `CSSTransition` component
  2139. */
  2140. children: propTypes.oneOfType([propTypes.element.isRequired])
  2141. };
  2142. SwitchTransition.defaultProps = {
  2143. mode: modes.out
  2144. };
  2145. exports.CSSTransition = CSSTransition;
  2146. exports.ReplaceTransition = ReplaceTransition;
  2147. exports.SwitchTransition = SwitchTransition;
  2148. exports.Transition = Transition;
  2149. exports.TransitionGroup = TransitionGroup;
  2150. exports.config = config;
  2151. Object.defineProperty(exports, '__esModule', { value: true });
  2152. }));