@@ -2,40 +2,22 @@ import React, {
22 useState ,
33 useRef ,
44 useEffect ,
5- ReactNode ,
65 ForwardRefRenderFunction ,
76 useImperativeHandle ,
87} from 'react'
8+ import classNames from 'classnames'
99import { View } from '@tarojs/components'
10- import { BasicComponent , ComponentDefaults } from '@/utils/typings'
10+ import { ComponentDefaults } from '@/utils/typings'
1111import { padZero } from '@/utils/pad-zero'
1212import { web } from '@/utils/platform-taro'
1313
14- export interface CountDownTimeProps {
14+ interface CountDownTimeProps {
1515 d : number
1616 h : number
1717 m : number
1818 s : number
1919 ms : number
2020}
21- export type CountDownType = 'default' | 'primary'
22- export interface CountDownProps extends BasicComponent {
23- type : CountDownType
24- paused : boolean
25- startTime : number
26- endTime : number
27- remainingTime : number
28- millisecond : boolean
29- format : string
30- autoStart : boolean
31- time : number
32- destroy : boolean
33- onEnd : ( ) => void
34- onPaused : ( restTime : number ) => void
35- onRestart : ( restTime : number ) => void
36- onUpdate : ( restTime : any ) => void
37- children : ReactNode
38- }
3921
4022const defaultProps = {
4123 ...ComponentDefaults ,
@@ -198,7 +180,7 @@ const InternalCountDown: ForwardRefRenderFunction<
198180 } else if ( formatCache . includes ( 'SS' ) ) {
199181 formatCache = formatCache . replace ( 'SS' , msC . slice ( 0 , 2 ) )
200182 } else if ( formatCache . includes ( 'S' ) ) {
201- formatCache = formatCache . replace ( 'SS ' , msC . slice ( 0 , 1 ) )
183+ formatCache = formatCache . replace ( 'S ' , msC . slice ( 0 , 1 ) )
202184 }
203185 }
204186
@@ -301,7 +283,11 @@ const InternalCountDown: ForwardRefRenderFunction<
301283 { format . includes ( formatUnit ) ? (
302284 < >
303285 < View
304- className = { `${ classPrefix } -number${ type === 'primary' ? '-primary' : '' } ` }
286+ className = { classNames ( {
287+ [ `${ classPrefix } -number` ] : type === 'default' ,
288+ [ `${ classPrefix } -number-primary` ] : type === 'primary' ,
289+ [ `${ classPrefix } -number-text` ] : type === 'text' ,
290+ } ) }
305291 >
306292 { padZero ( time ) }
307293 </ View >
0 commit comments