mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 16:35:14 +00:00
1 line
21 KiB
JSON
1 line
21 KiB
JSON
{"ast":null,"code":"import _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\n\nvar _leaveRenders, _enterRenders;\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { ENTERED, ENTERING, EXITING } from './Transition';\nimport TransitionGroupContext from './TransitionGroupContext';\n\nfunction areChildrenDifferent(oldChildren, newChildren) {\n if (oldChildren === newChildren) return false;\n\n if (React.isValidElement(oldChildren) && React.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) {\n return false;\n }\n\n return true;\n}\n/**\n * Enum of modes for SwitchTransition component\n * @enum { string }\n */\n\n\nexport var modes = {\n out: 'out-in',\n in: 'in-out'\n};\n\nvar callHook = function callHook(element, name, cb) {\n return function () {\n var _element$props;\n\n element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments);\n cb();\n };\n};\n\nvar leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) {\n var current = _ref.current,\n changeState = _ref.changeState;\n return React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERING, null);\n })\n });\n}, _leaveRenders[modes.in] = function (_ref2) {\n var current = _ref2.current,\n changeState = _ref2.changeState,\n children = _ref2.children;\n return [current, React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERING);\n })\n })];\n}, _leaveRenders);\nvar enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) {\n var children = _ref3.children,\n changeState = _ref3.changeState;\n return React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n });\n}, _enterRenders[modes.in] = function (_ref4) {\n var current = _ref4.current,\n children = _ref4.children,\n changeState = _ref4.changeState;\n return [React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n }), React.cloneElement(children, {\n in: true\n })];\n}, _enterRenders);\n/**\n * A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).\n * You can use it when you want to control the render between state transitions.\n * 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.\n *\n * If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.\n * 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.\n *\n * **Note**: If you want the animation to happen simultaneously\n * (that is, to have the old child removed and a new child inserted **at the same time**),\n * you should use\n * [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group)\n * instead.\n *\n * ```jsx\n * function App() {\n * const [state, setState] = useState(false);\n * return (\n * <SwitchTransition>\n * <CSSTransition\n * key={state ? \"Goodbye, world!\" : \"Hello, world!\"}\n * addEndListener={(node, done) => node.addEventListener(\"transitionend\", done, false)}\n * classNames='fade'\n * >\n * <button onClick={() => setState(state => !state)}>\n * {state ? \"Goodbye, world!\" : \"Hello, world!\"}\n * </button>\n * </CSSTransition>\n * </SwitchTransition>\n * );\n * }\n * ```\n *\n * ```css\n * .fade-enter{\n * opacity: 0;\n * }\n * .fade-exit{\n * opacity: 1;\n * }\n * .fade-enter-active{\n * opacity: 1;\n * }\n * .fade-exit-active{\n * opacity: 0;\n * }\n * .fade-enter-active,\n * .fade-exit-active{\n * transition: opacity 500ms;\n * }\n * ```\n */\n\nvar SwitchTransition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(SwitchTransition, _React$Component);\n\n function SwitchTransition() {\n var _this;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;\n _this.state = {\n status: ENTERED,\n current: null\n };\n _this.appeared = false;\n\n _this.changeState = function (status, current) {\n if (current === void 0) {\n current = _this.state.current;\n }\n\n _this.setState({\n status: status,\n current: current\n });\n };\n\n return _this;\n }\n\n var _proto = SwitchTransition.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.appeared = true;\n };\n\n SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {\n if (props.children == null) {\n return {\n current: null\n };\n }\n\n if (state.status === ENTERING && props.mode === modes.in) {\n return {\n status: ENTERING\n };\n }\n\n if (state.current && areChildrenDifferent(state.current, props.children)) {\n return {\n status: EXITING\n };\n }\n\n return {\n current: React.cloneElement(props.children, {\n in: true\n })\n };\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n children = _this$props.children,\n mode = _this$props.mode,\n _this$state = this.state,\n status = _this$state.status,\n current = _this$state.current;\n var data = {\n children: children,\n current: current,\n changeState: this.changeState,\n status: status\n };\n var component;\n\n switch (status) {\n case ENTERING:\n component = enterRenders[mode](data);\n break;\n\n case EXITING:\n component = leaveRenders[mode](data);\n break;\n\n case ENTERED:\n component = current;\n }\n\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: {\n isMounting: !this.appeared\n }\n }, component);\n };\n\n return SwitchTransition;\n}(React.Component);\n\nSwitchTransition.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * Transition modes.\n * `out-in`: Current element transitions out first, then when complete, the new element transitions in.\n * `in-out`: New element transitions in first, then when complete, the current element transitions out.\n *\n * @type {'out-in'|'in-out'}\n */\n mode: PropTypes.oneOf([modes.in, modes.out]),\n\n /**\n * Any `Transition` or `CSSTransition` component.\n */\n children: PropTypes.oneOfType([PropTypes.element.isRequired])\n} : {};\nSwitchTransition.defaultProps = {\n mode: modes.out\n};\nexport default SwitchTransition;","map":{"version":3,"sources":["/app/node_modules/react-transition-group/esm/SwitchTransition.js"],"names":["_inheritsLoose","_leaveRenders","_enterRenders","React","PropTypes","ENTERED","ENTERING","EXITING","TransitionGroupContext","areChildrenDifferent","oldChildren","newChildren","isValidElement","key","modes","out","in","callHook","element","name","cb","_element$props","props","apply","arguments","leaveRenders","_ref","current","changeState","cloneElement","onExited","_ref2","children","onEntered","enterRenders","_ref3","_ref4","SwitchTransition","_React$Component","_this","_len","length","args","Array","_key","call","concat","state","status","appeared","setState","_proto","prototype","componentDidMount","getDerivedStateFromProps","mode","render","_this$props","_this$state","data","component","createElement","Provider","value","isMounting","Component","propTypes","process","env","NODE_ENV","oneOf","oneOfType","isRequired","defaultProps"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;;AAEA,IAAIC,aAAJ,EAAmBC,aAAnB;;AAEA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,OAAT,EAAkBC,QAAlB,EAA4BC,OAA5B,QAA2C,cAA3C;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;;AAEA,SAASC,oBAAT,CAA8BC,WAA9B,EAA2CC,WAA3C,EAAwD;AACtD,MAAID,WAAW,KAAKC,WAApB,EAAiC,OAAO,KAAP;;AAEjC,MAAIR,KAAK,CAACS,cAAN,CAAqBF,WAArB,KAAqCP,KAAK,CAACS,cAAN,CAAqBD,WAArB,CAArC,IAA0ED,WAAW,CAACG,GAAZ,IAAmB,IAA7F,IAAqGH,WAAW,CAACG,GAAZ,KAAoBF,WAAW,CAACE,GAAzI,EAA8I;AAC5I,WAAO,KAAP;AACD;;AAED,SAAO,IAAP;AACD;AACD;AACA;AACA;AACA;;;AAGA,OAAO,IAAIC,KAAK,GAAG;AACjBC,EAAAA,GAAG,EAAE,QADY;AAEjBC,EAAAA,EAAE,EAAE;AAFa,CAAZ;;AAKP,IAAIC,QAAQ,GAAG,SAASA,QAAT,CAAkBC,OAAlB,EAA2BC,IAA3B,EAAiCC,EAAjC,EAAqC;AAClD,SAAO,YAAY;AACjB,QAAIC,cAAJ;;AAEAH,IAAAA,OAAO,CAACI,KAAR,CAAcH,IAAd,KAAuB,CAACE,cAAc,GAAGH,OA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zC,KAAK,CAACC;AADkB,CAAhC;AAGA,eAAesB,gBAAf","sourcesContent":["import _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\n\nvar _leaveRenders, _enterRenders;\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { ENTERED, ENTERING, EXITING } from './Transition';\nimport TransitionGroupContext from './TransitionGroupContext';\n\nfunction areChildrenDifferent(oldChildren, newChildren) {\n if (oldChildren === newChildren) return false;\n\n if (React.isValidElement(oldChildren) && React.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) {\n return false;\n }\n\n return true;\n}\n/**\n * Enum of modes for SwitchTransition component\n * @enum { string }\n */\n\n\nexport var modes = {\n out: 'out-in',\n in: 'in-out'\n};\n\nvar callHook = function callHook(element, name, cb) {\n return function () {\n var _element$props;\n\n element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments);\n cb();\n };\n};\n\nvar leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) {\n var current = _ref.current,\n changeState = _ref.changeState;\n return React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERING, null);\n })\n });\n}, _leaveRenders[modes.in] = function (_ref2) {\n var current = _ref2.current,\n changeState = _ref2.changeState,\n children = _ref2.children;\n return [current, React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERING);\n })\n })];\n}, _leaveRenders);\nvar enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) {\n var children = _ref3.children,\n changeState = _ref3.changeState;\n return React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n });\n}, _enterRenders[modes.in] = function (_ref4) {\n var current = _ref4.current,\n children = _ref4.children,\n changeState = _ref4.changeState;\n return [React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n }), React.cloneElement(children, {\n in: true\n })];\n}, _enterRenders);\n/**\n * A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).\n * You can use it when you want to control the render between state transitions.\n * 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.\n *\n * If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.\n * 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.\n *\n * **Note**: If you want the animation to happen simultaneously\n * (that is, to have the old child removed and a new child inserted **at the same time**),\n * you should use\n * [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group)\n * instead.\n *\n * ```jsx\n * function App() {\n * const [state, setState] = useState(false);\n * return (\n * <SwitchTransition>\n * <CSSTransition\n * key={state ? \"Goodbye, world!\" : \"Hello, world!\"}\n * addEndListener={(node, done) => node.addEventListener(\"transitionend\", done, false)}\n * classNames='fade'\n * >\n * <button onClick={() => setState(state => !state)}>\n * {state ? \"Goodbye, world!\" : \"Hello, world!\"}\n * </button>\n * </CSSTransition>\n * </SwitchTransition>\n * );\n * }\n * ```\n *\n * ```css\n * .fade-enter{\n * opacity: 0;\n * }\n * .fade-exit{\n * opacity: 1;\n * }\n * .fade-enter-active{\n * opacity: 1;\n * }\n * .fade-exit-active{\n * opacity: 0;\n * }\n * .fade-enter-active,\n * .fade-exit-active{\n * transition: opacity 500ms;\n * }\n * ```\n */\n\nvar SwitchTransition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(SwitchTransition, _React$Component);\n\n function SwitchTransition() {\n var _this;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;\n _this.state = {\n status: ENTERED,\n current: null\n };\n _this.appeared = false;\n\n _this.changeState = function (status, current) {\n if (current === void 0) {\n current = _this.state.current;\n }\n\n _this.setState({\n status: status,\n current: current\n });\n };\n\n return _this;\n }\n\n var _proto = SwitchTransition.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.appeared = true;\n };\n\n SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {\n if (props.children == null) {\n return {\n current: null\n };\n }\n\n if (state.status === ENTERING && props.mode === modes.in) {\n return {\n status: ENTERING\n };\n }\n\n if (state.current && areChildrenDifferent(state.current, props.children)) {\n return {\n status: EXITING\n };\n }\n\n return {\n current: React.cloneElement(props.children, {\n in: true\n })\n };\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n children = _this$props.children,\n mode = _this$props.mode,\n _this$state = this.state,\n status = _this$state.status,\n current = _this$state.current;\n var data = {\n children: children,\n current: current,\n changeState: this.changeState,\n status: status\n };\n var component;\n\n switch (status) {\n case ENTERING:\n component = enterRenders[mode](data);\n break;\n\n case EXITING:\n component = leaveRenders[mode](data);\n break;\n\n case ENTERED:\n component = current;\n }\n\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: {\n isMounting: !this.appeared\n }\n }, component);\n };\n\n return SwitchTransition;\n}(React.Component);\n\nSwitchTransition.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * Transition modes.\n * `out-in`: Current element transitions out first, then when complete, the new element transitions in.\n * `in-out`: New element transitions in first, then when complete, the current element transitions out.\n *\n * @type {'out-in'|'in-out'}\n */\n mode: PropTypes.oneOf([modes.in, modes.out]),\n\n /**\n * Any `Transition` or `CSSTransition` component.\n */\n children: PropTypes.oneOfType([PropTypes.element.isRequired])\n} : {};\nSwitchTransition.defaultProps = {\n mode: modes.out\n};\nexport default SwitchTransition;"]},"metadata":{},"sourceType":"module"} |