PromoCursed/node_modules/.cache/babel-loader/48a73376ec67a4e4930ee2c947a176d86ce95ad33e0cb29c6fc5fbd57973eb50.json

1 line
8.1 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\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};\nimport * as React from 'react';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { cloneElement } from '../_util/reactNode';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nconst REFRESH_INTERVAL = 1000 / 30;\nfunction getTime(value) {\n return new Date(value).getTime();\n}\nconst Countdown = props => {\n const {\n value,\n format = 'HH:mm:ss',\n onChange,\n onFinish\n } = props,\n rest = __rest(props, [\"value\", \"format\", \"onChange\", \"onFinish\"]);\n const forceUpdate = useForceUpdate();\n const countdown = React.useRef(null);\n const stopTimer = () => {\n onFinish === null || onFinish === void 0 ? void 0 : onFinish();\n if (countdown.current) {\n clearInterval(countdown.current);\n countdown.current = null;\n }\n };\n const syncTimer = () => {\n const timestamp = getTime(value);\n if (timestamp >= Date.now()) {\n countdown.current = setInterval(() => {\n forceUpdate();\n onChange === null || onChange === void 0 ? void 0 : onChange(timestamp - Date.now());\n if (timestamp < Date.now()) {\n stopTimer();\n }\n }, REFRESH_INTERVAL);\n }\n };\n React.useEffect(() => {\n syncTimer();\n return () => {\n if (countdown.current) {\n clearInterval(countdown.current);\n countdown.current = null;\n }\n };\n }, [value]);\n const formatter = (formatValue, config) => formatCountdown(formatValue, Object.assign(Object.assign({}, config), {\n format\n }));\n const valueRender = node => cloneElement(node, {\n title: undefined\n });\n return /*#__PURE__*/React.createElement(Statistic, Object.assign({}, rest, {\n value: value,\n valueRender: valueRender,\n formatter: formatter\n }));\n};\nexport default /*#__PURE__*/React.memo(Countdown);","map":{"version":3,"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","useForceUpdate","cloneElement","Statistic","formatCountdown","REFRESH_INTERVAL","getTime","value","Date","Countdown","props","format","onChange","onFinish","rest","forceUpdate","countdown","useRef","stopTimer","current","clearInterval","syncTimer","timestamp","now","setInterval","useEffect","formatter","formatValue","config","assign","valueRender","node","title","undefined","createElement","memo"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/statistic/Countdown.js"],"sourcesContent":["\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\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};\nimport * as React from 'react';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { cloneElement } from '../_util/reactNode';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nconst REFRESH_INTERVAL = 1000 / 30;\nfunction getTime(value) {\n return new Date(value).getTime();\n}\nconst Countdown = props => {\n const {\n value,\n format = 'HH:mm:ss',\n onChange,\n onFinish\n } = props,\n rest = __rest(props, [\"value\", \"format\", \"onChange\", \"onFinish\"]);\n const forceUpdate = useForceUpdat