import classNames from 'classnames'; import * as React from 'react'; import type { ConfigConsumerProps } from '../config-provider'; import { withConfigConsumer } from '../config-provider/context'; import Skeleton from '../skeleton'; import type Countdown from './Countdown'; import StatisticNumber from './Number'; import type { FormatConfig, valueType } from './utils'; import useStyle from './style'; interface StatisticComponent { Countdown: typeof Countdown; } export interface StatisticProps extends FormatConfig { prefixCls?: string; className?: string; style?: React.CSSProperties; value?: valueType; valueStyle?: React.CSSProperties; valueRender?: (node: React.ReactNode) => React.ReactNode; title?: React.ReactNode; prefix?: React.ReactNode; suffix?: React.ReactNode; loading?: boolean; onMouseEnter?: React.MouseEventHandler; onMouseLeave?: React.MouseEventHandler; } const Statistic: React.FC = (props) => { const { prefixCls, className, style, valueStyle, value = 0, title, valueRender, prefix, suffix, loading = false, direction, onMouseEnter, onMouseLeave, decimalSeparator = '.', groupSeparator = ',', } = props; const valueNode = ( ); // Style const [wrapSSR, hashId] = useStyle(String(prefixCls)); const cls = classNames( prefixCls, { [`${prefixCls}-rtl`]: direction === 'rtl', }, className, hashId, ); return wrapSSR(
{title &&
{title}
}
{prefix && {prefix}} {valueRender ? valueRender(valueNode) : valueNode} {suffix && {suffix}}
, ); }; const WrapperStatistic = withConfigConsumer({ prefixCls: 'statistic', })(Statistic); export default WrapperStatistic;