@@ -11,7 +11,6 @@ import Steps from './Steps';
11
11
import { getSuccessPercent , validProgress } from './utils' ;
12
12
import useConfigInject from '../_util/hooks/useConfigInject' ;
13
13
import devWarning from '../vc-util/devWarning' ;
14
- import type { ProgressStatusesType } from './props' ;
15
14
import { progressProps , progressStatuses } from './props' ;
16
15
17
16
export default defineComponent ( {
@@ -26,9 +25,14 @@ export default defineComponent({
26
25
gapDegree : 0 ,
27
26
strokeLinecap : 'round' ,
28
27
} ) ,
28
+ slots : [ 'format' ] ,
29
29
setup ( props , { slots } ) {
30
30
const { prefixCls, direction } = useConfigInject ( 'progress' , props ) ;
31
-
31
+ devWarning (
32
+ props . successPercent == undefined ,
33
+ 'Progress' ,
34
+ '`successPercent` is deprecated. Please use `success.percent` instead.' ,
35
+ ) ;
32
36
const classString = computed ( ( ) => {
33
37
const { type, showInfo, size } = props ;
34
38
const pre = prefixCls . value ;
@@ -41,59 +45,52 @@ export default defineComponent({
41
45
} ;
42
46
} ) ;
43
47
44
- const getPercentNumber = ( ) => {
48
+ const percentNumber = computed ( ( ) => {
45
49
const { percent = 0 } = props ;
46
- const successPercent = getSuccessPercent ( props . success , props . successPercent ) ;
50
+ const successPercent = getSuccessPercent ( props ) ;
47
51
return parseInt (
48
52
successPercent !== undefined ? successPercent . toString ( ) : percent . toString ( ) ,
49
53
10 ,
50
54
) ;
51
- } ;
55
+ } ) ;
52
56
53
- const getProgressStatus = ( ) => {
57
+ const progressStatus = computed ( ( ) => {
54
58
const { status } = props ;
55
- if ( progressStatuses . indexOf ( status ) < 0 && getPercentNumber ( ) >= 100 ) {
59
+ if ( progressStatuses . indexOf ( status ) < 0 && percentNumber . value >= 100 ) {
56
60
return 'success' ;
57
61
}
58
62
return status || 'normal' ;
59
- } ;
63
+ } ) ;
60
64
61
- const renderProcessInfo = ( prefixCls : string , progressStatus : ProgressStatusesType ) => {
65
+ const renderProcessInfo = ( ) => {
62
66
const { showInfo, format, type, percent } = props ;
63
- const successPercent = getSuccessPercent ( props . success , props . successPercent ) ;
67
+ const successPercent = getSuccessPercent ( props ) ;
64
68
if ( ! showInfo ) return null ;
65
69
66
70
let text : VNodeChild ;
67
- const textFormatter = format || slots ?. format || ( percentNumber => `${ percentNumber } %` ) ;
71
+ const textFormatter = format || slots ?. format || ( ( val : number ) => `${ val } %` ) ;
68
72
const isLineType = type === 'line' ;
69
73
if (
70
74
format ||
71
75
slots ?. format ||
72
- ( progressStatus !== 'exception' && progressStatus !== 'success' )
76
+ ( progressStatus . value !== 'exception' && progressStatus . value !== 'success' )
73
77
) {
74
78
text = textFormatter ( validProgress ( percent ) , validProgress ( successPercent ) ) ;
75
- } else if ( progressStatus === 'exception' ) {
79
+ } else if ( progressStatus . value === 'exception' ) {
76
80
text = isLineType ? < CloseCircleFilled /> : < CloseOutlined /> ;
77
- } else if ( progressStatus === 'success' ) {
81
+ } else if ( progressStatus . value === 'success' ) {
78
82
text = isLineType ? < CheckCircleFilled /> : < CheckOutlined /> ;
79
83
}
80
84
return (
81
- < span class = { `${ prefixCls } -text` } title = { typeof text === 'string' ? text : undefined } >
85
+ < span class = { `${ prefixCls . value } -text` } title = { typeof text === 'string' ? text : undefined } >
82
86
{ text }
83
87
</ span >
84
88
) ;
85
89
} ;
86
90
87
91
return ( ) => {
88
92
const { type, steps, strokeColor } = props ;
89
- const progressStatus = getProgressStatus ( ) ;
90
- const progressInfo = renderProcessInfo ( prefixCls . value , progressStatus ) ;
91
-
92
- devWarning (
93
- props . successPercent == undefined ,
94
- 'Progress' ,
95
- '`successPercent` is deprecated. Please use `success.percent` instead.' ,
96
- ) ;
93
+ const progressInfo = renderProcessInfo ( ) ;
97
94
98
95
let progress : VNodeChild ;
99
96
// Render progress shape
@@ -122,7 +119,7 @@ export default defineComponent({
122
119
123
120
const classNames = {
124
121
...classString . value ,
125
- [ `${ prefixCls . value } -status-${ progressStatus } ` ] : true ,
122
+ [ `${ prefixCls . value } -status-${ progressStatus . value } ` ] : true ,
126
123
} ;
127
124
128
125
return < div class = { classNames } > { progress } </ div > ;
0 commit comments