import * as React from 'react'; import classNames from 'classnames'; import { withConfigConsumer, ConfigConsumerProps } from '../config-provider'; import StatisticNumber from './Number'; import Countdown from './Countdown'; import { valueType, FormatConfig } from './utils'; 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; } const Statistic: React.SFC = props => { const { prefixCls, className, style, valueStyle, value = 0, title, valueRender, prefix, suffix, } = props; let valueNode: React.ReactNode = ; if (valueRender) { valueNode = valueRender(valueNode); } return (
{title &&
{title}
}
{prefix && {prefix}} {valueNode} {suffix && {suffix}}
); }; Statistic.defaultProps = { decimalSeparator: '.', groupSeparator: ',', }; const WrapperStatistic = withConfigConsumer({ prefixCls: 'statistic', })(Statistic); export default WrapperStatistic;