|
@ -1,7 +1,7 @@ |
|
|
import classNames from 'classnames'; |
|
|
import classNames from 'classnames'; |
|
|
import * as React from 'react'; |
|
|
import * as React from 'react'; |
|
|
import { ConfigContext } from '../config-provider'; |
|
|
|
|
|
import { cloneElement } from '../_util/reactNode'; |
|
|
import { cloneElement } from '../_util/reactNode'; |
|
|
|
|
|
import { ConfigContext } from '../config-provider'; |
|
|
import SingleNumber from './SingleNumber'; |
|
|
import SingleNumber from './SingleNumber'; |
|
|
|
|
|
|
|
|
export interface ScrollNumberProps { |
|
|
export interface ScrollNumberProps { |
|
@ -21,9 +21,8 @@ export interface ScrollNumberState { |
|
|
count?: string | number | null; |
|
|
count?: string | number | null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const ScrollNumber = React.forwardRef<HTMLElement, ScrollNumberProps>( |
|
|
const ScrollNumber = React.forwardRef<HTMLElement, ScrollNumberProps>((props, ref) => { |
|
|
( |
|
|
const { |
|
|
{ |
|
|
|
|
|
prefixCls: customizePrefixCls, |
|
|
prefixCls: customizePrefixCls, |
|
|
count, |
|
|
count, |
|
|
className, |
|
|
className, |
|
@ -34,9 +33,7 @@ const ScrollNumber = React.forwardRef<HTMLElement, ScrollNumberProps>( |
|
|
component: Component = 'sup', |
|
|
component: Component = 'sup', |
|
|
children, |
|
|
children, |
|
|
...restProps |
|
|
...restProps |
|
|
}, |
|
|
} = props; |
|
|
ref, |
|
|
|
|
|
) => { |
|
|
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext); |
|
|
const { getPrefixCls } = React.useContext(ConfigContext); |
|
|
const prefixCls = getPrefixCls('scroll-number', customizePrefixCls); |
|
|
const prefixCls = getPrefixCls('scroll-number', customizePrefixCls); |
|
|
|
|
|
|
|
@ -76,11 +73,7 @@ const ScrollNumber = React.forwardRef<HTMLElement, ScrollNumberProps>( |
|
|
} |
|
|
} |
|
|
if (children) { |
|
|
if (children) { |
|
|
return cloneElement(children, (oriProps) => ({ |
|
|
return cloneElement(children, (oriProps) => ({ |
|
|
className: classNames( |
|
|
className: classNames(`${prefixCls}-custom-component`, oriProps?.className, motionClassName), |
|
|
`${prefixCls}-custom-component`, |
|
|
|
|
|
oriProps?.className, |
|
|
|
|
|
motionClassName, |
|
|
|
|
|
), |
|
|
|
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -89,7 +82,6 @@ const ScrollNumber = React.forwardRef<HTMLElement, ScrollNumberProps>( |
|
|
{numberNodes} |
|
|
{numberNodes} |
|
|
</Component> |
|
|
</Component> |
|
|
); |
|
|
); |
|
|
}, |
|
|
}); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
export default ScrollNumber; |
|
|
export default ScrollNumber; |
|
|