cb12b8b6b8c6c9d6a848a96873813658.json
20.8 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider';\nimport { cloneElement } from '../_util/reactNode';\n\nfunction getNumberArray(num) {\n return num ? num.toString().split('').reverse().map(function (i) {\n var current = Number(i);\n return isNaN(current) ? i : current;\n }) : [];\n}\n\nfunction renderNumberList(position, className) {\n var childrenToReturn = [];\n\n for (var i = 0; i < 30; i++) {\n childrenToReturn.push( /*#__PURE__*/React.createElement(\"p\", {\n key: i.toString(),\n className: classNames(className, {\n current: position === i\n })\n }, i % 10));\n }\n\n return childrenToReturn;\n}\n\nvar ScrollNumber = function ScrollNumber(_a) {\n var customizePrefixCls = _a.prefixCls,\n customizeCount = _a.count,\n className = _a.className,\n style = _a.style,\n title = _a.title,\n show = _a.show,\n _a$component = _a.component,\n component = _a$component === void 0 ? 'sup' : _a$component,\n children = _a.children,\n _a$onAnimated = _a.onAnimated,\n onAnimated = _a$onAnimated === void 0 ? function () {} : _a$onAnimated,\n restProps = __rest(_a, [\"prefixCls\", \"count\", \"className\", \"style\", \"title\", \"show\", \"component\", \"children\", \"onAnimated\"]);\n\n var _React$useState = React.useState(true),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n animateStarted = _React$useState2[0],\n setAnimateStarted = _React$useState2[1];\n\n var _React$useState3 = React.useState(customizeCount),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n count = _React$useState4[0],\n setCount = _React$useState4[1];\n\n var _React$useState5 = React.useState(customizeCount),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n prevCount = _React$useState6[0],\n setPrevCount = _React$useState6[1];\n\n var _React$useState7 = React.useState(customizeCount),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n lastCount = _React$useState8[0],\n setLastCount = _React$useState8[1];\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var prefixCls = getPrefixCls('scroll-number', customizePrefixCls);\n\n if (prevCount !== customizeCount) {\n setAnimateStarted(true);\n setPrevCount(customizeCount);\n }\n\n React.useEffect(function () {\n setLastCount(count);\n var timeout;\n\n if (animateStarted) {\n // Let browser has time to reset the scroller before actually\n // performing the transition.\n timeout = setTimeout(function () {\n setAnimateStarted(false);\n setCount(customizeCount);\n onAnimated();\n });\n }\n\n return function () {\n if (timeout) {\n clearTimeout(timeout);\n }\n };\n }, [animateStarted, customizeCount, onAnimated]); // =========================== Function ===========================\n\n var getPositionByNum = function getPositionByNum(num, i) {\n var currentCount = Math.abs(Number(count));\n var lstCount = Math.abs(Number(lastCount));\n var currentDigit = Math.abs(getNumberArray(count)[i]);\n var lastDigit = Math.abs(getNumberArray(lstCount)[i]);\n\n if (animateStarted) {\n return 10 + num;\n } // 同方向则在同一侧切换数字\n\n\n if (currentCount > lstCount) {\n if (currentDigit >= lastDigit) {\n return 10 + num;\n }\n\n return 20 + num;\n }\n\n if (currentDigit <= lastDigit) {\n return 10 + num;\n }\n\n return num;\n }; // ============================ Render ============================\n\n\n var newProps = _extends(_extends({}, restProps), {\n 'data-show': show,\n style: style,\n className: classNames(prefixCls, className),\n title: title\n });\n\n var renderCurrentNumber = function renderCurrentNumber(num, i) {\n if (typeof num === 'number') {\n var position = getPositionByNum(num, i);\n var removeTransition = animateStarted || getNumberArray(lastCount)[i] === undefined;\n return /*#__PURE__*/React.createElement('span', {\n className: \"\".concat(prefixCls, \"-only\"),\n style: {\n transition: removeTransition ? 'none' : undefined,\n msTransform: \"translateY(\".concat(-position * 100, \"%)\"),\n WebkitTransform: \"translateY(\".concat(-position * 100, \"%)\"),\n transform: \"translateY(\".concat(-position * 100, \"%)\")\n },\n key: i\n }, renderNumberList(position, \"\".concat(prefixCls, \"-only-unit\")));\n }\n\n return /*#__PURE__*/React.createElement(\"span\", {\n key: \"symbol\",\n className: \"\".concat(prefixCls, \"-symbol\")\n }, num);\n };\n\n var numberNodeRef = React.useRef(null);\n\n if (show) {\n numberNodeRef.current = count && Number(count) % 1 === 0 ? getNumberArray(count).map(function (num, i) {\n return renderCurrentNumber(num, i);\n }).reverse() : count;\n } // allow specify the border\n // mock border-color by box-shadow for compatible with old usage:\n // <Badge count={4} style={{ backgroundColor: '#fff', color: '#999', borderColor: '#d9d9d9' }} />\n\n\n if (style && style.borderColor) {\n newProps.style = _extends(_extends({}, style), {\n boxShadow: \"0 0 0 1px \".concat(style.borderColor, \" inset\")\n });\n }\n\n if (children) {\n return cloneElement(children, function (oriProps) {\n return {\n className: classNames(\"\".concat(prefixCls, \"-custom-component\"), oriProps === null || oriProps === void 0 ? void 0 : oriProps.className)\n };\n });\n }\n\n return /*#__PURE__*/React.createElement(component, newProps, numberNodeRef.current);\n};\n\nexport default ScrollNumber;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/badge/ScrollNumber.js"],"names":["_extends","_slicedToArray","__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","classNames","ConfigContext","cloneElement","getNumberArray","num","toString","split","reverse","map","current","Number","isNaN","renderNumberList","position","className","childrenToReturn","push","createElement","key","ScrollNumber","_a","customizePrefixCls","prefixCls","customizeCount","count","style","title","show","_a$component","component","children","_a$onAnimated","onAnimated","restProps","_React$useState","useState","_React$useState2","animateStarted","setAnimateStarted","_React$useState3","_React$useState4","setCount","_React$useState5","_React$useState6","prevCount","setPrevCount","_React$useState7","_React$useState8","lastCount","setLastCount","_React$useContext","useContext","getPrefixCls","useEffect","timeout","setTimeout","clearTimeout","getPositionByNum","currentCount","Math","abs","lstCount","currentDigit","lastDigit","newProps","renderCurrentNumber","removeTransition","undefined","concat","transition","msTransform","WebkitTransform","transform","numberNodeRef","useRef","borderColor","boxShadow","oriProps"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,cAAP,MAA2B,sCAA3B;;AAEA,IAAIC,MAAM,GAAG,QAAQ,KAAKA,MAAb,IAAuB,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAClD,MAAIC,CAAC,GAAG,EAAR;;AAEA,OAAK,IAAIC,CAAT,IAAcH,CAAd,EAAiB;AACf,QAAII,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCP,CAArC,EAAwCG,CAAxC,KAA8CF,CAAC,CAACO,OAAF,CAAUL,CAAV,IAAe,CAAjE,EAAoED,CAAC,CAACC,CAAD,CAAD,GAAOH,CAAC,CAACG,CAAD,CAAR;AACrE;;AAED,MAAIH,CAAC,IAAI,IAAL,IAAa,OAAOI,MAAM,CAACK,qBAAd,KAAwC,UAAzD,EAAqE,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWP,CAAC,GAAGC,MAAM,CAACK,qBAAP,CAA6BT,CAA7B,CAApB,EAAqDU,CAAC,GAAGP,CAAC,CAACQ,MAA3D,EAAmED,CAAC,EAApE,EAAwE;AAC3I,QAAIT,CAAC,CAACO,OAAF,CAAUL,CAAC,CAACO,CAAD,CAAX,IAAkB,CAAlB,IAAuBN,MAAM,CAACC,SAAP,CAAiBO,oBAAjB,CAAsCL,IAAtC,CAA2CP,CAA3C,EAA8CG,CAAC,CAACO,CAAD,CAA/C,CAA3B,EAAgFR,CAAC,CAACC,CAAC,CAACO,CAAD,CAAF,CAAD,GAAUV,CAAC,CAACG,CAAC,CAACO,CAAD,CAAF,CAAX;AACjF;A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B,GAAmCrB,cAAc,CAACqB,KAAD,CAAd,CAAsBhB,GAAtB,CAA0B,UAAUJ,GAAV,EAAeR,CAAf,EAAkB;AACrG,aAAOqE,mBAAmB,CAAC7D,GAAD,EAAMR,CAAN,CAA1B;AACD,KAF0D,EAExDW,OAFwD,EAAnC,GAETiB,KAFf;AAGD,GA/H0C,CA+HzC;AACF;AACA;;;AAGA,MAAIC,KAAK,IAAIA,KAAK,CAACkD,WAAnB,EAAgC;AAC9BX,IAAAA,QAAQ,CAACvC,KAAT,GAAiB1C,QAAQ,CAACA,QAAQ,CAAC,EAAD,EAAK0C,KAAL,CAAT,EAAsB;AAC7CmD,MAAAA,SAAS,EAAE,aAAaR,MAAb,CAAoB3C,KAAK,CAACkD,WAA1B,EAAuC,QAAvC;AADkC,KAAtB,CAAzB;AAGD;;AAED,MAAI7C,QAAJ,EAAc;AACZ,WAAO5B,YAAY,CAAC4B,QAAD,EAAW,UAAU+C,QAAV,EAAoB;AAChD,aAAO;AACL/D,QAAAA,SAAS,EAAEd,UAAU,CAAC,GAAGoE,MAAH,CAAU9C,SAAV,EAAqB,mBAArB,CAAD,EAA4CuD,QAAQ,KAAK,IAAb,IAAqBA,QAAQ,KAAK,KAAK,CAAvC,GAA2C,KAAK,CAAhD,GAAoDA,QAAQ,CAAC/D,SAAzG;AADhB,OAAP;AAGD,KAJkB,CAAnB;AAKD;;AAED,SAAO,aAAaf,KAAK,CAACkB,aAAN,CAAoBY,SAApB,EAA+BmC,QAA/B,EAAyCS,aAAa,CAAChE,OAAvD,CAApB;AACD,CAnJD;;AAqJA,eAAeU,YAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider';\nimport { cloneElement } from '../_util/reactNode';\n\nfunction getNumberArray(num) {\n return num ? num.toString().split('').reverse().map(function (i) {\n var current = Number(i);\n return isNaN(current) ? i : current;\n }) : [];\n}\n\nfunction renderNumberList(position, className) {\n var childrenToReturn = [];\n\n for (var i = 0; i < 30; i++) {\n childrenToReturn.push( /*#__PURE__*/React.createElement(\"p\", {\n key: i.toString(),\n className: classNames(className, {\n current: position === i\n })\n }, i % 10));\n }\n\n return childrenToReturn;\n}\n\nvar ScrollNumber = function ScrollNumber(_a) {\n var customizePrefixCls = _a.prefixCls,\n customizeCount = _a.count,\n className = _a.className,\n style = _a.style,\n title = _a.title,\n show = _a.show,\n _a$component = _a.component,\n component = _a$component === void 0 ? 'sup' : _a$component,\n children = _a.children,\n _a$onAnimated = _a.onAnimated,\n onAnimated = _a$onAnimated === void 0 ? function () {} : _a$onAnimated,\n restProps = __rest(_a, [\"prefixCls\", \"count\", \"className\", \"style\", \"title\", \"show\", \"component\", \"children\", \"onAnimated\"]);\n\n var _React$useState = React.useState(true),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n animateStarted = _React$useState2[0],\n setAnimateStarted = _React$useState2[1];\n\n var _React$useState3 = React.useState(customizeCount),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n count = _React$useState4[0],\n setCount = _React$useState4[1];\n\n var _React$useState5 = React.useState(customizeCount),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n prevCount = _React$useState6[0],\n setPrevCount = _React$useState6[1];\n\n var _React$useState7 = React.useState(customizeCount),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n lastCount = _React$useState8[0],\n setLastCount = _React$useState8[1];\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var prefixCls = getPrefixCls('scroll-number', customizePrefixCls);\n\n if (prevCount !== customizeCount) {\n setAnimateStarted(true);\n setPrevCount(customizeCount);\n }\n\n React.useEffect(function () {\n setLastCount(count);\n var timeout;\n\n if (animateStarted) {\n // Let browser has time to reset the scroller before actually\n // performing the transition.\n timeout = setTimeout(function () {\n setAnimateStarted(false);\n setCount(customizeCount);\n onAnimated();\n });\n }\n\n return function () {\n if (timeout) {\n clearTimeout(timeout);\n }\n };\n }, [animateStarted, customizeCount, onAnimated]); // =========================== Function ===========================\n\n var getPositionByNum = function getPositionByNum(num, i) {\n var currentCount = Math.abs(Number(count));\n var lstCount = Math.abs(Number(lastCount));\n var currentDigit = Math.abs(getNumberArray(count)[i]);\n var lastDigit = Math.abs(getNumberArray(lstCount)[i]);\n\n if (animateStarted) {\n return 10 + num;\n } // 同方向则在同一侧切换数字\n\n\n if (currentCount > lstCount) {\n if (currentDigit >= lastDigit) {\n return 10 + num;\n }\n\n return 20 + num;\n }\n\n if (currentDigit <= lastDigit) {\n return 10 + num;\n }\n\n return num;\n }; // ============================ Render ============================\n\n\n var newProps = _extends(_extends({}, restProps), {\n 'data-show': show,\n style: style,\n className: classNames(prefixCls, className),\n title: title\n });\n\n var renderCurrentNumber = function renderCurrentNumber(num, i) {\n if (typeof num === 'number') {\n var position = getPositionByNum(num, i);\n var removeTransition = animateStarted || getNumberArray(lastCount)[i] === undefined;\n return /*#__PURE__*/React.createElement('span', {\n className: \"\".concat(prefixCls, \"-only\"),\n style: {\n transition: removeTransition ? 'none' : undefined,\n msTransform: \"translateY(\".concat(-position * 100, \"%)\"),\n WebkitTransform: \"translateY(\".concat(-position * 100, \"%)\"),\n transform: \"translateY(\".concat(-position * 100, \"%)\")\n },\n key: i\n }, renderNumberList(position, \"\".concat(prefixCls, \"-only-unit\")));\n }\n\n return /*#__PURE__*/React.createElement(\"span\", {\n key: \"symbol\",\n className: \"\".concat(prefixCls, \"-symbol\")\n }, num);\n };\n\n var numberNodeRef = React.useRef(null);\n\n if (show) {\n numberNodeRef.current = count && Number(count) % 1 === 0 ? getNumberArray(count).map(function (num, i) {\n return renderCurrentNumber(num, i);\n }).reverse() : count;\n } // allow specify the border\n // mock border-color by box-shadow for compatible with old usage:\n // <Badge count={4} style={{ backgroundColor: '#fff', color: '#999', borderColor: '#d9d9d9' }} />\n\n\n if (style && style.borderColor) {\n newProps.style = _extends(_extends({}, style), {\n boxShadow: \"0 0 0 1px \".concat(style.borderColor, \" inset\")\n });\n }\n\n if (children) {\n return cloneElement(children, function (oriProps) {\n return {\n className: classNames(\"\".concat(prefixCls, \"-custom-component\"), oriProps === null || oriProps === void 0 ? void 0 : oriProps.className)\n };\n });\n }\n\n return /*#__PURE__*/React.createElement(component, newProps, numberNodeRef.current);\n};\n\nexport default ScrollNumber;"]},"metadata":{},"sourceType":"module"}