fad8587d31d36474efb12200cf01793f.json 15 KB
{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\n/* eslint react/prop-types: 0 */\n\nimport * as React from 'react';\nimport OriginCSSMotion from './CSSMotion';\nimport { supportTransition } from './util/motion';\nimport { STATUS_ADD, STATUS_KEEP, STATUS_REMOVE, STATUS_REMOVED, diffKeys, parseKeys } from './util/diff';\nvar MOTION_PROP_NAMES = ['eventProps', 'visible', 'children', 'motionName', 'motionAppear', 'motionEnter', 'motionLeave', 'motionLeaveImmediately', 'motionDeadline', 'removeOnLeave', 'leavedClassName', 'onAppearStart', 'onAppearActive', 'onAppearEnd', 'onEnterStart', 'onEnterActive', 'onEnterEnd', 'onLeaveStart', 'onLeaveActive', 'onLeaveEnd'];\n/**\n * Generate a CSSMotionList component with config\n * @param transitionSupport No need since CSSMotionList no longer depends on transition support\n * @param CSSMotion CSSMotion component\n */\n\nexport function genCSSMotionList(transitionSupport) {\n  var CSSMotion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : OriginCSSMotion;\n\n  var CSSMotionList = /*#__PURE__*/function (_React$Component) {\n    _inherits(CSSMotionList, _React$Component);\n\n    var _super = _createSuper(CSSMotionList);\n\n    function CSSMotionList() {\n      var _this;\n\n      _classCallCheck(this, CSSMotionList);\n\n      _this = _super.apply(this, arguments);\n      _this.state = {\n        keyEntities: []\n      };\n\n      _this.removeKey = function (removeKey) {\n        _this.setState(function (_ref) {\n          var keyEntities = _ref.keyEntities;\n          return {\n            keyEntities: keyEntities.map(function (entity) {\n              if (entity.key !== removeKey) return entity;\n              return _objectSpread(_objectSpread({}, entity), {}, {\n                status: STATUS_REMOVED\n              });\n            })\n          };\n        });\n      };\n\n      return _this;\n    }\n\n    _createClass(CSSMotionList, [{\n      key: \"render\",\n      value: function render() {\n        var _this2 = this;\n\n        var keyEntities = this.state.keyEntities;\n\n        var _this$props = this.props,\n            component = _this$props.component,\n            children = _this$props.children,\n            _onVisibleChanged = _this$props.onVisibleChanged,\n            restProps = _objectWithoutProperties(_this$props, [\"component\", \"children\", \"onVisibleChanged\"]);\n\n        var Component = component || React.Fragment;\n        var motionProps = {};\n        MOTION_PROP_NAMES.forEach(function (prop) {\n          motionProps[prop] = restProps[prop];\n          delete restProps[prop];\n        });\n        delete restProps.keys;\n        return /*#__PURE__*/React.createElement(Component, Object.assign({}, restProps), keyEntities.map(function (_ref2) {\n          var status = _ref2.status,\n              eventProps = _objectWithoutProperties(_ref2, [\"status\"]);\n\n          var visible = status === STATUS_ADD || status === STATUS_KEEP;\n          return /*#__PURE__*/React.createElement(CSSMotion, Object.assign({}, motionProps, {\n            key: eventProps.key,\n            visible: visible,\n            eventProps: eventProps,\n            onVisibleChanged: function onVisibleChanged(changedVisible) {\n              _onVisibleChanged === null || _onVisibleChanged === void 0 ? void 0 : _onVisibleChanged(changedVisible, {\n                key: eventProps.key\n              });\n\n              if (!changedVisible) {\n                _this2.removeKey(eventProps.key);\n              }\n            }\n          }), children);\n        }));\n      }\n    }], [{\n      key: \"getDerivedStateFromProps\",\n      value: function getDerivedStateFromProps(_ref3, _ref4) {\n        var keys = _ref3.keys;\n        var keyEntities = _ref4.keyEntities;\n        var parsedKeyObjects = parseKeys(keys);\n        var mixedKeyEntities = diffKeys(keyEntities, parsedKeyObjects);\n        return {\n          keyEntities: mixedKeyEntities.filter(function (entity) {\n            var prevEntity = keyEntities.find(function (_ref5) {\n              var key = _ref5.key;\n              return entity.key === key;\n            }); // Remove if already mark as removed\n\n            if (prevEntity && prevEntity.status === STATUS_REMOVED && entity.status === STATUS_REMOVE) {\n              return false;\n            }\n\n            return true;\n          })\n        };\n      }\n    }]);\n\n    return CSSMotionList;\n  }(React.Component);\n\n  CSSMotionList.defaultProps = {\n    component: 'div'\n  };\n  return CSSMotionList;\n}\nexport default genCSSMotionList(supportTransition);","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-motion/es/CSSMotionList.js"],"names":["_objectWithoutProperties","_objectSpread","_classCallCheck","_createClass","_inherits","_createSuper","React","OriginCSSMotion","supportTransition","STATUS_ADD","STATUS_KEEP","STATUS_REMOVE","STATUS_REMOVED","diffKeys","parseKeys","MOTION_PROP_NAMES","genCSSMotionList","transitionSupport","CSSMotion","arguments","length","undefined","CSSMotionList","_React$Component","_super","_this","apply","state","keyEntities","removeKey","setState","_ref","map","entity","key","status","value","render","_this2","_this$props","props","component","children","_onVisibleChanged","onVisibleChanged","restProps","Component","Fragment","motionProps","forEach","prop","keys","createElement","Object","assign","_ref2","eventProps","visible","changedVisible","getDerivedStateFromProps","_ref3","_ref4","parsedKeyObjects","mixedKeyEntities","filter","prevEntity","find","_ref5","defaultProps"],"mappings":"AAAA,OAAOA,wBAAP,MAAqC,oDAArC;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAOC,SAAP,MAAsB,qCAAtB;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AAEA;;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,eAAP,MAA4B,aAA5B;AACA,SAASC,iBAAT,QAAkC,eAAlC;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,aAAlC,EAAiDC,cAAjD,EAAiEC,QAAjE,EAA2EC,SAA3E,QAA4F,aAA5F;AACA,IAAIC,iBAAiB,GAAG,CAAC,YAAD,EAAe,SAAf,EAA0B,UAA1B,EAAsC,YAAtC,EAAoD,cAApD,EAAoE,aAApE,EAAmF,aAAnF,EAAkG,wBAAlG,EAA4H,gBAA5H,EAA8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kB;AACrD,gBAAIgC,UAAU,GAAGrC,WAAW,CAACsC,IAAZ,CAAiB,UAAUC,KAAV,EAAiB;AACjD,kBAAIjC,GAAG,GAAGiC,KAAK,CAACjC,GAAhB;AACA,qBAAOD,MAAM,CAACC,GAAP,KAAeA,GAAtB;AACD,aAHgB,CAAjB,CADqD,CAIjD;;AAEJ,gBAAI+B,UAAU,IAAIA,UAAU,CAAC9B,MAAX,KAAsBvB,cAApC,IAAsDqB,MAAM,CAACE,MAAP,KAAkBxB,aAA5E,EAA2F;AACzF,qBAAO,KAAP;AACD;;AAED,mBAAO,IAAP;AACD,WAXY;AADR,SAAP;AAcD;AArBE,KAAD,CAzCQ,CAAZ;;AAiEA,WAAOW,aAAP;AACD,GAlGgC,CAkG/BhB,KAAK,CAACwC,SAlGyB,CAAjC;;AAoGAxB,EAAAA,aAAa,CAAC8C,YAAd,GAA6B;AAC3B3B,IAAAA,SAAS,EAAE;AADgB,GAA7B;AAGA,SAAOnB,aAAP;AACD;AACD,eAAeN,gBAAgB,CAACR,iBAAD,CAA/B","sourcesContent":["import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\n\n/* eslint react/prop-types: 0 */\nimport * as React from 'react';\nimport OriginCSSMotion from './CSSMotion';\nimport { supportTransition } from './util/motion';\nimport { STATUS_ADD, STATUS_KEEP, STATUS_REMOVE, STATUS_REMOVED, diffKeys, parseKeys } from './util/diff';\nvar MOTION_PROP_NAMES = ['eventProps', 'visible', 'children', 'motionName', 'motionAppear', 'motionEnter', 'motionLeave', 'motionLeaveImmediately', 'motionDeadline', 'removeOnLeave', 'leavedClassName', 'onAppearStart', 'onAppearActive', 'onAppearEnd', 'onEnterStart', 'onEnterActive', 'onEnterEnd', 'onLeaveStart', 'onLeaveActive', 'onLeaveEnd'];\n/**\n * Generate a CSSMotionList component with config\n * @param transitionSupport No need since CSSMotionList no longer depends on transition support\n * @param CSSMotion CSSMotion component\n */\n\nexport function genCSSMotionList(transitionSupport) {\n  var CSSMotion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : OriginCSSMotion;\n\n  var CSSMotionList = /*#__PURE__*/function (_React$Component) {\n    _inherits(CSSMotionList, _React$Component);\n\n    var _super = _createSuper(CSSMotionList);\n\n    function CSSMotionList() {\n      var _this;\n\n      _classCallCheck(this, CSSMotionList);\n\n      _this = _super.apply(this, arguments);\n      _this.state = {\n        keyEntities: []\n      };\n\n      _this.removeKey = function (removeKey) {\n        _this.setState(function (_ref) {\n          var keyEntities = _ref.keyEntities;\n          return {\n            keyEntities: keyEntities.map(function (entity) {\n              if (entity.key !== removeKey) return entity;\n              return _objectSpread(_objectSpread({}, entity), {}, {\n                status: STATUS_REMOVED\n              });\n            })\n          };\n        });\n      };\n\n      return _this;\n    }\n\n    _createClass(CSSMotionList, [{\n      key: \"render\",\n      value: function render() {\n        var _this2 = this;\n\n        var keyEntities = this.state.keyEntities;\n\n        var _this$props = this.props,\n            component = _this$props.component,\n            children = _this$props.children,\n            _onVisibleChanged = _this$props.onVisibleChanged,\n            restProps = _objectWithoutProperties(_this$props, [\"component\", \"children\", \"onVisibleChanged\"]);\n\n        var Component = component || React.Fragment;\n        var motionProps = {};\n        MOTION_PROP_NAMES.forEach(function (prop) {\n          motionProps[prop] = restProps[prop];\n          delete restProps[prop];\n        });\n        delete restProps.keys;\n        return /*#__PURE__*/React.createElement(Component, Object.assign({}, restProps), keyEntities.map(function (_ref2) {\n          var status = _ref2.status,\n              eventProps = _objectWithoutProperties(_ref2, [\"status\"]);\n\n          var visible = status === STATUS_ADD || status === STATUS_KEEP;\n          return /*#__PURE__*/React.createElement(CSSMotion, Object.assign({}, motionProps, {\n            key: eventProps.key,\n            visible: visible,\n            eventProps: eventProps,\n            onVisibleChanged: function onVisibleChanged(changedVisible) {\n              _onVisibleChanged === null || _onVisibleChanged === void 0 ? void 0 : _onVisibleChanged(changedVisible, {\n                key: eventProps.key\n              });\n\n              if (!changedVisible) {\n                _this2.removeKey(eventProps.key);\n              }\n            }\n          }), children);\n        }));\n      }\n    }], [{\n      key: \"getDerivedStateFromProps\",\n      value: function getDerivedStateFromProps(_ref3, _ref4) {\n        var keys = _ref3.keys;\n        var keyEntities = _ref4.keyEntities;\n        var parsedKeyObjects = parseKeys(keys);\n        var mixedKeyEntities = diffKeys(keyEntities, parsedKeyObjects);\n        return {\n          keyEntities: mixedKeyEntities.filter(function (entity) {\n            var prevEntity = keyEntities.find(function (_ref5) {\n              var key = _ref5.key;\n              return entity.key === key;\n            }); // Remove if already mark as removed\n\n            if (prevEntity && prevEntity.status === STATUS_REMOVED && entity.status === STATUS_REMOVE) {\n              return false;\n            }\n\n            return true;\n          })\n        };\n      }\n    }]);\n\n    return CSSMotionList;\n  }(React.Component);\n\n  CSSMotionList.defaultProps = {\n    component: 'div'\n  };\n  return CSSMotionList;\n}\nexport default genCSSMotionList(supportTransition);"]},"metadata":{},"sourceType":"module"}