d15c570f9e03d64155e54e229bc65d09.json
14.3 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\n/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */\n\nimport * as React from 'react';\nimport { useRef } from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport { fillRef } from \"rc-util/es/ref\";\nimport classNames from 'classnames';\nimport { getTransitionName, supportTransition } from './util/motion';\nimport { STATUS_NONE, STEP_PREPARE, STEP_START } from './interface';\nimport useStatus from './hooks/useStatus';\nimport DomWrapper from './DomWrapper';\nimport { isActive } from './hooks/useStepQueue';\n/**\n * `transitionSupport` is used for none transition test case.\n * Default we use browser transition event support check.\n */\n\nexport function genCSSMotion(config) {\n var transitionSupport = config;\n\n if (_typeof(config) === 'object') {\n transitionSupport = config.transitionSupport;\n }\n\n function isSupportTransition(props) {\n return !!(props.motionName && transitionSupport);\n }\n\n var CSSMotion = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _props$visible = props.visible,\n visible = _props$visible === void 0 ? true : _props$visible,\n _props$removeOnLeave = props.removeOnLeave,\n removeOnLeave = _props$removeOnLeave === void 0 ? true : _props$removeOnLeave,\n forceRender = props.forceRender,\n children = props.children,\n motionName = props.motionName,\n leavedClassName = props.leavedClassName,\n eventProps = props.eventProps;\n var supportMotion = isSupportTransition(props); // Ref to the react node, it may be a HTMLElement\n\n var nodeRef = useRef(); // Ref to the dom wrapper in case ref can not pass to HTMLElement\n\n var wrapperNodeRef = useRef();\n\n function getDomElement() {\n try {\n return findDOMNode(nodeRef.current || wrapperNodeRef.current);\n } catch (e) {\n // Only happen when `motionDeadline` trigger but element removed.\n return null;\n }\n }\n\n var _useStatus = useStatus(supportMotion, visible, getDomElement, props),\n _useStatus2 = _slicedToArray(_useStatus, 4),\n status = _useStatus2[0],\n statusStep = _useStatus2[1],\n statusStyle = _useStatus2[2],\n mergedVisible = _useStatus2[3]; // ====================== Refs ======================\n\n\n var originRef = useRef(ref);\n originRef.current = ref;\n var setNodeRef = React.useCallback(function (node) {\n nodeRef.current = node;\n fillRef(originRef.current, node);\n }, []); // ===================== Render =====================\n\n var motionChildren;\n\n var mergedProps = _objectSpread(_objectSpread({}, eventProps), {}, {\n visible: visible\n });\n\n if (!children) {\n // No children\n motionChildren = null;\n } else if (status === STATUS_NONE || !isSupportTransition(props)) {\n // Stable children\n if (mergedVisible) {\n motionChildren = children(_objectSpread({}, mergedProps), setNodeRef);\n } else if (!removeOnLeave) {\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n className: leavedClassName\n }), setNodeRef);\n } else if (forceRender) {\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n style: {\n display: 'none'\n }\n }), setNodeRef);\n } else {\n motionChildren = null;\n }\n } else {\n var _classNames; // In motion\n\n\n var statusSuffix;\n\n if (statusStep === STEP_PREPARE) {\n statusSuffix = 'prepare';\n } else if (isActive(statusStep)) {\n statusSuffix = 'active';\n } else if (statusStep === STEP_START) {\n statusSuffix = 'start';\n }\n\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n className: classNames(getTransitionName(motionName, status), (_classNames = {}, _defineProperty(_classNames, getTransitionName(motionName, \"\".concat(status, \"-\").concat(statusSuffix)), statusSuffix), _defineProperty(_classNames, motionName, typeof motionName === 'string'), _classNames)),\n style: statusStyle\n }), setNodeRef);\n }\n\n return /*#__PURE__*/React.createElement(DomWrapper, {\n ref: wrapperNodeRef\n }, motionChildren);\n });\n CSSMotion.displayName = 'CSSMotion';\n return CSSMotion;\n}\nexport default genCSSMotion(supportTransition);","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-motion/es/CSSMotion.js"],"names":["_defineProperty","_objectSpread","_slicedToArray","_typeof","React","useRef","findDOMNode","fillRef","classNames","getTransitionName","supportTransition","STATUS_NONE","STEP_PREPARE","STEP_START","useStatus","DomWrapper","isActive","genCSSMotion","config","transitionSupport","isSupportTransition","props","motionName","CSSMotion","forwardRef","ref","_props$visible","visible","_props$removeOnLeave","removeOnLeave","forceRender","children","leavedClassName","eventProps","supportMotion","nodeRef","wrapperNodeRef","getDomElement","current","e","_useStatus","_useStatus2","status","statusStep","statusStyle","mergedVisible","originRef","setNodeRef","useCallback","node","motionChildren","mergedProps","className","style","display","_classNames","statusSuffix","concat","createElement","displayName"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAOC,OAAP,MAAoB,mCAApB;AAEA;;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,QAAuB,OAAvB;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,iBAAT,EAA4BC,iBAA5B,QAAqD,eAArD;AACA,SAASC,WAAT,EAAsBC,YAAtB,EAAoCC,UAApC,QAAsD,aAAtD;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,SAASC,QAAT,QAAyB,sBAAzB;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,YAAT,CAAsBC,MAAtB,EAA8B;AACnC,MAAIC,iBAAiB,GAAGD,MAAxB;;AAEA,MAAIf,OAAO,CAACe,MAAD,CAAP,KAAoB,QAAxB,EAAkC;AAChCC,IAAAA,iBAAiB,GAAGD,MAAM,CAACC,iBAA3B;AACD;;AAED,WAASC,mBAAT,CAA6BC,KAA7B,EAAoC;AAClC,WAAO,CAAC,EAAEA,KAAK,CAACC,UAAN,IAAoBH,iBAAtB,CAAR;AACD;;AAED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AD6C,KAAhC,EAEjBc,cAFiB,CAApB;AAGD,GAzF4B,CAA7B;AA0FA3B,EAAAA,SAAS,CAACoC,WAAV,GAAwB,WAAxB;AACA,SAAOpC,SAAP;AACD;AACD,eAAeN,YAAY,CAACP,iBAAD,CAA3B","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\n\n/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */\nimport * as React from 'react';\nimport { useRef } from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport { fillRef } from \"rc-util/es/ref\";\nimport classNames from 'classnames';\nimport { getTransitionName, supportTransition } from './util/motion';\nimport { STATUS_NONE, STEP_PREPARE, STEP_START } from './interface';\nimport useStatus from './hooks/useStatus';\nimport DomWrapper from './DomWrapper';\nimport { isActive } from './hooks/useStepQueue';\n/**\n * `transitionSupport` is used for none transition test case.\n * Default we use browser transition event support check.\n */\n\nexport function genCSSMotion(config) {\n var transitionSupport = config;\n\n if (_typeof(config) === 'object') {\n transitionSupport = config.transitionSupport;\n }\n\n function isSupportTransition(props) {\n return !!(props.motionName && transitionSupport);\n }\n\n var CSSMotion = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _props$visible = props.visible,\n visible = _props$visible === void 0 ? true : _props$visible,\n _props$removeOnLeave = props.removeOnLeave,\n removeOnLeave = _props$removeOnLeave === void 0 ? true : _props$removeOnLeave,\n forceRender = props.forceRender,\n children = props.children,\n motionName = props.motionName,\n leavedClassName = props.leavedClassName,\n eventProps = props.eventProps;\n var supportMotion = isSupportTransition(props); // Ref to the react node, it may be a HTMLElement\n\n var nodeRef = useRef(); // Ref to the dom wrapper in case ref can not pass to HTMLElement\n\n var wrapperNodeRef = useRef();\n\n function getDomElement() {\n try {\n return findDOMNode(nodeRef.current || wrapperNodeRef.current);\n } catch (e) {\n // Only happen when `motionDeadline` trigger but element removed.\n return null;\n }\n }\n\n var _useStatus = useStatus(supportMotion, visible, getDomElement, props),\n _useStatus2 = _slicedToArray(_useStatus, 4),\n status = _useStatus2[0],\n statusStep = _useStatus2[1],\n statusStyle = _useStatus2[2],\n mergedVisible = _useStatus2[3]; // ====================== Refs ======================\n\n\n var originRef = useRef(ref);\n originRef.current = ref;\n var setNodeRef = React.useCallback(function (node) {\n nodeRef.current = node;\n fillRef(originRef.current, node);\n }, []); // ===================== Render =====================\n\n var motionChildren;\n\n var mergedProps = _objectSpread(_objectSpread({}, eventProps), {}, {\n visible: visible\n });\n\n if (!children) {\n // No children\n motionChildren = null;\n } else if (status === STATUS_NONE || !isSupportTransition(props)) {\n // Stable children\n if (mergedVisible) {\n motionChildren = children(_objectSpread({}, mergedProps), setNodeRef);\n } else if (!removeOnLeave) {\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n className: leavedClassName\n }), setNodeRef);\n } else if (forceRender) {\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n style: {\n display: 'none'\n }\n }), setNodeRef);\n } else {\n motionChildren = null;\n }\n } else {\n var _classNames;\n\n // In motion\n var statusSuffix;\n\n if (statusStep === STEP_PREPARE) {\n statusSuffix = 'prepare';\n } else if (isActive(statusStep)) {\n statusSuffix = 'active';\n } else if (statusStep === STEP_START) {\n statusSuffix = 'start';\n }\n\n motionChildren = children(_objectSpread(_objectSpread({}, mergedProps), {}, {\n className: classNames(getTransitionName(motionName, status), (_classNames = {}, _defineProperty(_classNames, getTransitionName(motionName, \"\".concat(status, \"-\").concat(statusSuffix)), statusSuffix), _defineProperty(_classNames, motionName, typeof motionName === 'string'), _classNames)),\n style: statusStyle\n }), setNodeRef);\n }\n\n return /*#__PURE__*/React.createElement(DomWrapper, {\n ref: wrapperNodeRef\n }, motionChildren);\n });\n CSSMotion.displayName = 'CSSMotion';\n return CSSMotion;\n}\nexport default genCSSMotion(supportTransition);"]},"metadata":{},"sourceType":"module"}