a5079d71a5d4726fb0fdda45c638e5f7.json
14.1 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport CSSMotion from 'rc-motion';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport VerticalAlignTopOutlined from '@ant-design/icons/VerticalAlignTopOutlined';\nimport { throttleByAnimationFrame } from '../_util/throttleByAnimationFrame';\nimport { ConfigContext } from '../config-provider';\nimport getScroll from '../_util/getScroll';\nimport scrollTo from '../_util/scrollTo';\nimport { cloneElement } from '../_util/reactNode';\n\nvar BackTop = function BackTop(props) {\n var _useMergedState = useMergedState(false, {\n value: props.visible\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n visible = _useMergedState2[0],\n setVisible = _useMergedState2[1];\n\n var ref = /*#__PURE__*/React.createRef();\n var scrollEvent = React.useRef();\n\n var getDefaultTarget = function getDefaultTarget() {\n return ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window;\n };\n\n var handleScroll = throttleByAnimationFrame(function (e) {\n var visibilityHeight = props.visibilityHeight;\n var scrollTop = getScroll(e.target, true);\n setVisible(scrollTop > visibilityHeight);\n });\n\n var bindScrollEvent = function bindScrollEvent() {\n var target = props.target;\n var getTarget = target || getDefaultTarget;\n var container = getTarget();\n scrollEvent.current = addEventListener(container, 'scroll', function (e) {\n handleScroll(e);\n });\n handleScroll({\n target: container\n });\n };\n\n React.useEffect(function () {\n bindScrollEvent();\n return function () {\n if (scrollEvent.current) {\n scrollEvent.current.remove();\n }\n\n handleScroll.cancel();\n };\n }, [props.target]);\n\n var scrollToTop = function scrollToTop(e) {\n var onClick = props.onClick,\n target = props.target,\n _props$duration = props.duration,\n duration = _props$duration === void 0 ? 450 : _props$duration;\n scrollTo(0, {\n getContainer: target || getDefaultTarget,\n duration: duration\n });\n\n if (typeof onClick === 'function') {\n onClick(e);\n }\n };\n\n var renderChildren = function renderChildren(_ref) {\n var prefixCls = _ref.prefixCls;\n var children = props.children;\n var defaultElement = /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-content\")\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-icon\")\n }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)));\n return /*#__PURE__*/React.createElement(CSSMotion, {\n visible: visible,\n motionName: \"fade\",\n removeOnLeave: true\n }, function (_ref2) {\n var motionClassName = _ref2.className;\n var childNode = children || defaultElement;\n return /*#__PURE__*/React.createElement(\"div\", null, cloneElement(childNode, function (_ref3) {\n var className = _ref3.className;\n return {\n className: classNames(motionClassName, className)\n };\n }));\n });\n };\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction;\n\n var customizePrefixCls = props.prefixCls,\n _props$className = props.className,\n className = _props$className === void 0 ? '' : _props$className;\n var prefixCls = getPrefixCls('back-top', customizePrefixCls);\n var classString = classNames(prefixCls, _defineProperty({}, \"\".concat(prefixCls, \"-rtl\"), direction === 'rtl'), className); // fix https://fb.me/react-unknown-prop\n\n var divProps = omit(props, ['prefixCls', 'className', 'children', 'visibilityHeight', 'target', 'visible']);\n return /*#__PURE__*/React.createElement(\"div\", _extends({}, divProps, {\n className: classString,\n onClick: scrollToTop,\n ref: ref\n }), renderChildren({\n prefixCls: prefixCls\n }));\n};\n\nBackTop.defaultProps = {\n visibilityHeight: 400\n};\nexport default /*#__PURE__*/React.memo(BackTop);","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/back-top/index.js"],"names":["_extends","_defineProperty","_slicedToArray","React","CSSMotion","addEventListener","useMergedState","classNames","omit","VerticalAlignTopOutlined","throttleByAnimationFrame","ConfigContext","getScroll","scrollTo","cloneElement","BackTop","props","_useMergedState","value","visible","_useMergedState2","setVisible","ref","createRef","scrollEvent","useRef","getDefaultTarget","current","ownerDocument","window","handleScroll","e","visibilityHeight","scrollTop","target","bindScrollEvent","getTarget","container","useEffect","remove","cancel","scrollToTop","onClick","_props$duration","duration","getContainer","renderChildren","_ref","prefixCls","children","defaultElement","createElement","className","concat","motionName","removeOnLeave","_ref2","motionClassName","childNode","_ref3","_React$useContext","useContext","getPrefixCls","direction","customizePrefixCls","_props$className","classString","divProps","defaultProps","memo"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,SAAP,MAAsB,WAAtB;AACA,OAAOC,gBAAP,MAA6B,iCAA7B;AACA,OAAOC,cAAP,MAA2B,iCAA3B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,OAAOC,wBAAP,MAAqC,4CAArC;AACA,SAASC,wBAAT,QAAyC,mCAAzC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,OAAOC,QAAP,MAAqB,mBAArB;AACA,SAASC,YAAT,QAA6B,oBAA7B;;AAEA,IAAIC,OAAO,GAAG,SAASA,OAAT,CAAiBC,KAAjB,EAAwB;AACpC,MAAIC,eAAe,GAAGX,cAAc,CAAC,KAAD,EAAQ;AAC1CY,IAAAA,KAAK,EAAEF,KAAK,CAACG;AAD6B,GAAR,CAApC;AAAA,MAGIC,gBAAgB,GAAGlB,cAAc,CAACe,eAAD,EAAkB,CAAlB,CAHrC;AAAA,MAIIE,OAAO,GAAGC,gBAAgB,CAAC,CAAD,CAJ9B;AAAA,MAKIC,UAAU,GAAGD,gBAAgB,CAAC,CAAD,CALjC;;AAOA,MAAIE,GAAG,GAAG,aAAanB,KA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D,aAAN,CAAoB,KAApB,EAA2BnD,QAAQ,CAAC,EAAD,EAAKmE,QAAL,EAAe;AACpEf,IAAAA,SAAS,EAAEc,WADyD;AAEpExB,IAAAA,OAAO,EAAED,WAF2D;AAGpEnB,IAAAA,GAAG,EAAEA;AAH+D,GAAf,CAAnC,EAIhBwB,cAAc,CAAC;AACjBE,IAAAA,SAAS,EAAEA;AADM,GAAD,CAJE,CAApB;AAOD,CArGD;;AAuGAjC,OAAO,CAACqD,YAAR,GAAuB;AACrBpC,EAAAA,gBAAgB,EAAE;AADG,CAAvB;AAGA,eAAe,aAAa7B,KAAK,CAACkE,IAAN,CAAWtD,OAAX,CAA5B","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport CSSMotion from 'rc-motion';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport VerticalAlignTopOutlined from '@ant-design/icons/VerticalAlignTopOutlined';\nimport { throttleByAnimationFrame } from '../_util/throttleByAnimationFrame';\nimport { ConfigContext } from '../config-provider';\nimport getScroll from '../_util/getScroll';\nimport scrollTo from '../_util/scrollTo';\nimport { cloneElement } from '../_util/reactNode';\n\nvar BackTop = function BackTop(props) {\n var _useMergedState = useMergedState(false, {\n value: props.visible\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n visible = _useMergedState2[0],\n setVisible = _useMergedState2[1];\n\n var ref = /*#__PURE__*/React.createRef();\n var scrollEvent = React.useRef();\n\n var getDefaultTarget = function getDefaultTarget() {\n return ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window;\n };\n\n var handleScroll = throttleByAnimationFrame(function (e) {\n var visibilityHeight = props.visibilityHeight;\n var scrollTop = getScroll(e.target, true);\n setVisible(scrollTop > visibilityHeight);\n });\n\n var bindScrollEvent = function bindScrollEvent() {\n var target = props.target;\n var getTarget = target || getDefaultTarget;\n var container = getTarget();\n scrollEvent.current = addEventListener(container, 'scroll', function (e) {\n handleScroll(e);\n });\n handleScroll({\n target: container\n });\n };\n\n React.useEffect(function () {\n bindScrollEvent();\n return function () {\n if (scrollEvent.current) {\n scrollEvent.current.remove();\n }\n\n handleScroll.cancel();\n };\n }, [props.target]);\n\n var scrollToTop = function scrollToTop(e) {\n var onClick = props.onClick,\n target = props.target,\n _props$duration = props.duration,\n duration = _props$duration === void 0 ? 450 : _props$duration;\n scrollTo(0, {\n getContainer: target || getDefaultTarget,\n duration: duration\n });\n\n if (typeof onClick === 'function') {\n onClick(e);\n }\n };\n\n var renderChildren = function renderChildren(_ref) {\n var prefixCls = _ref.prefixCls;\n var children = props.children;\n var defaultElement = /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-content\")\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-icon\")\n }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)));\n return /*#__PURE__*/React.createElement(CSSMotion, {\n visible: visible,\n motionName: \"fade\",\n removeOnLeave: true\n }, function (_ref2) {\n var motionClassName = _ref2.className;\n var childNode = children || defaultElement;\n return /*#__PURE__*/React.createElement(\"div\", null, cloneElement(childNode, function (_ref3) {\n var className = _ref3.className;\n return {\n className: classNames(motionClassName, className)\n };\n }));\n });\n };\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction;\n\n var customizePrefixCls = props.prefixCls,\n _props$className = props.className,\n className = _props$className === void 0 ? '' : _props$className;\n var prefixCls = getPrefixCls('back-top', customizePrefixCls);\n var classString = classNames(prefixCls, _defineProperty({}, \"\".concat(prefixCls, \"-rtl\"), direction === 'rtl'), className); // fix https://fb.me/react-unknown-prop\n\n var divProps = omit(props, ['prefixCls', 'className', 'children', 'visibilityHeight', 'target', 'visible']);\n return /*#__PURE__*/React.createElement(\"div\", _extends({}, divProps, {\n className: classString,\n onClick: scrollToTop,\n ref: ref\n }), renderChildren({\n prefixCls: prefixCls\n }));\n};\n\nBackTop.defaultProps = {\n visibilityHeight: 400\n};\nexport default /*#__PURE__*/React.memo(BackTop);"]},"metadata":{},"sourceType":"module"}