PromoCursed/node_modules/.cache/babel-loader/81b0e829d064ddd80358f3b0b14936493488aa5a9c449724084268bddb11f1c4.json
2024-08-20 23:25:37 +04:00

1 line
9.1 KiB
JSON

{"ast":null,"code":"\"use client\";\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nconst UnitNumber = props => {\n const {\n prefixCls,\n value,\n current,\n offset = 0\n } = props;\n let style;\n if (offset) {\n style = {\n position: 'absolute',\n top: `${offset}00%`,\n left: 0\n };\n }\n return /*#__PURE__*/React.createElement(\"span\", {\n style: style,\n className: classNames(`${prefixCls}-only-unit`, {\n current\n })\n }, value);\n};\nfunction getOffset(start, end, unit) {\n let index = start;\n let offset = 0;\n while ((index + 10) % 10 !== end) {\n index += unit;\n offset += unit;\n }\n return offset;\n}\nconst SingleNumber = props => {\n const {\n prefixCls,\n count: originCount,\n value: originValue\n } = props;\n const value = Number(originValue);\n const count = Math.abs(originCount);\n const [prevValue, setPrevValue] = React.useState(value);\n const [prevCount, setPrevCount] = React.useState(count);\n // ============================= Events =============================\n const onTransitionEnd = () => {\n setPrevValue(value);\n setPrevCount(count);\n };\n // Fallback if transition events are not supported\n React.useEffect(() => {\n const timer = setTimeout(onTransitionEnd, 1000);\n return () => clearTimeout(timer);\n }, [value]);\n // ============================= Render =============================\n // Render unit list\n let unitNodes;\n let offsetStyle;\n if (prevValue === value || Number.isNaN(value) || Number.isNaN(prevValue)) {\n // Nothing to change\n unitNodes = [/*#__PURE__*/React.createElement(UnitNumber, Object.assign({}, props, {\n key: value,\n current: true\n }))];\n offsetStyle = {\n transition: 'none'\n };\n } else {\n unitNodes = [];\n // Fill basic number units\n const end = value + 10;\n const unitNumberList = [];\n for (let index = value; index <= end; index += 1) {\n unitNumberList.push(index);\n }\n // Fill with number unit nodes\n const prevIndex = unitNumberList.findIndex(n => n % 10 === prevValue);\n unitNodes = unitNumberList.map((n, index) => {\n const singleUnit = n % 10;\n return /*#__PURE__*/React.createElement(UnitNumber, Object.assign({}, props, {\n key: n,\n value: singleUnit,\n offset: index - prevIndex,\n current: index === prevIndex\n }));\n });\n // Calculate container offset value\n const unit = prevCount < count ? 1 : -1;\n offsetStyle = {\n transform: `translateY(${-getOffset(prevValue, value, unit)}00%)`\n };\n }\n return /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-only`,\n style: offsetStyle,\n onTransitionEnd: onTransitionEnd\n }, unitNodes);\n};\nexport default SingleNumber;","map":{"version":3,"names":["React","classNames","UnitNumber","props","prefixCls","value","current","offset","style","position","top","left","createElement","className","getOffset","start","end","unit","index","SingleNumber","count","originCount","originValue","Number","Math","abs","prevValue","setPrevValue","useState","prevCount","setPrevCount","onTransitionEnd","useEffect","timer","setTimeout","clearTimeout","unitNodes","offsetStyle","isNaN","Object","assign","key","transition","unitNumberList","push","prevIndex","findIndex","n","map","singleUnit","transform"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/badge/SingleNumber.js"],"sourcesContent":["\"use client\";\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nconst UnitNumber = props => {\n const {\n prefixCls,\n value,\n current,\n offset = 0\n } = props;\n let style;\n if (offset) {\n style = {\n position: 'absolute',\n top: `${offset}00%`,\n left: 0\n };\n }\n return /*#__PURE__*/React.createElement(\"span\", {\n style: style,\n className: classNames(`${prefixCls}-only-unit`, {\n current\n })\n }, value);\n};\nfunction getOffset(start, end, unit) {\n let index = start;\n let offset = 0;\n while ((index + 10) % 10 !== end) {\n index += unit;\n offset += unit;\n }\n return offset;\n}\nconst SingleNumber = props => {\n const {\n prefixCls,\n count: originCount,\n value: originValue\n } = props;\n const value = Number(originValue);\n const count = Math.abs(originCount);\n const [prevValue, setPrevValue] = React.useState(value);\n const [prevCount, setPrevCount] = React.useState(count);\n // ============================= Events =============================\n const onTransitionEnd = () => {\n setPrevValue(value);\n setPrevCount(count);\n };\n // Fallback if transition events are not supported\n React.useEffect(() => {\n const timer = setTimeout(onTransitionEnd, 1000);\n return () => clearTimeout(timer);\n }, [value]);\n // ============================= Render =============================\n // Render unit list\n let unitNodes;\n let offsetStyle;\n if (prevValue === value || Number.isNaN(value) || Number.isNaN(prevValue)) {\n // Nothing to change\n unitNodes = [/*#__PURE__*/React.createElement(UnitNumber, Object.assign({}, props, {\n key: value,\n current: true\n }))];\n offsetStyle = {\n transition: 'none'\n };\n } else {\n unitNodes = [];\n // Fill basic number units\n const end = value + 10;\n const unitNumberList = [];\n for (let index = value; index <= end; index += 1) {\n unitNumberList.push(index);\n }\n // Fill with number unit nodes\n const prevIndex = unitNumberList.findIndex(n => n % 10 === prevValue);\n unitNodes = unitNumberList.map((n, index) => {\n const singleUnit = n % 10;\n return /*#__PURE__*/React.createElement(UnitNumber, Object.assign({}, props, {\n key: n,\n value: singleUnit,\n offset: index - prevIndex,\n current: index === prevIndex\n }));\n });\n // Calculate container offset value\n const unit = prevCount < count ? 1 : -1;\n offsetStyle = {\n transform: `translateY(${-getOffset(prevValue, value, unit)}00%)`\n };\n }\n return /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-only`,\n style: offsetStyle,\n onTransitionEnd: onTransitionEnd\n }, unitNodes);\n};\nexport default SingleNumber;"],"mappings":"AAAA,YAAY;;AAEZ,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,MAAMC,UAAU,GAAGC,KAAK,IAAI;EAC1B,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,OAAO;IACPC,MAAM,GAAG;EACX,CAAC,GAAGJ,KAAK;EACT,IAAIK,KAAK;EACT,IAAID,MAAM,EAAE;IACVC,KAAK,GAAG;MACNC,QAAQ,EAAE,UAAU;MACpBC,GAAG,EAAE,GAAGH,MAAM,KAAK;MACnBI,IAAI,EAAE;IACR,CAAC;EACH;EACA,OAAO,aAAaX,KAAK,CAACY,aAAa,CAAC,MAAM,EAAE;IAC9CJ,KAAK,EAAEA,KAAK;IACZK,SAAS,EAAEZ,UAAU,CAAC,GAAGG,SAAS,YAAY,EAAE;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