1
- import type { App , ExtractPropTypes , PropType } from 'vue' ;
1
+ import type { App , ExtractPropTypes } from 'vue' ;
2
2
import { computed , defineComponent } from 'vue' ;
3
3
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined' ;
4
4
import CheckOutlined from '@ant-design/icons-vue/CheckOutlined' ;
@@ -13,35 +13,40 @@ import omit from '../_util/omit';
13
13
import { VcStepProps } from '../vc-steps/Step' ;
14
14
import type { ProgressDotRender } from '../vc-steps/Steps' ;
15
15
import type { MouseEventHandler } from '../_util/EventInterface' ;
16
+ import { booleanType , stringType , functionType , someType } from '../_util/type' ;
17
+
18
+ // CSSINJS
19
+ import useStyle from './style' ;
20
+ import { useToken } from '../theme/internal' ;
16
21
17
22
export const stepsProps = ( ) => ( {
18
23
prefixCls : String ,
19
24
iconPrefix : String ,
20
25
current : Number ,
21
26
initial : Number ,
22
27
percent : Number ,
23
- responsive : { type : Boolean , default : undefined } ,
24
- labelPlacement : String as PropType < 'horizontal' | 'vertical' > ,
25
- status : String as PropType < 'wait' | 'process' | 'finish' | 'error' > ,
26
- size : String as PropType < 'default' | 'small' > ,
27
- direction : String as PropType < 'horizontal' | 'vertical' > ,
28
- progressDot : {
29
- type : [ Boolean , Function ] as PropType < boolean | ProgressDotRender > ,
30
- default : undefined as boolean | ProgressDotRender ,
31
- } ,
32
- type : String as PropType < 'default' | 'navigation' > ,
33
- onChange : Function as PropType < ( current : number ) => void > ,
34
- 'onUpdate:current' : Function as PropType < ( current : number ) => void > ,
28
+ responsive : booleanType ( ) ,
29
+ labelPlacement : stringType < 'horizontal' | 'vertical' > ( ) ,
30
+ status : stringType < 'wait' | 'process' | 'finish' | 'error' > ( ) ,
31
+ size : stringType < 'default' | 'small' > ( ) ,
32
+ direction : stringType < 'horizontal' | 'vertical' > ( ) ,
33
+ progressDot : someType < boolean | ProgressDotRender > (
34
+ [ Boolean , Function ] ,
35
+ undefined as boolean | ProgressDotRender ,
36
+ ) ,
37
+ type : stringType < 'default' | 'navigation' > ( ) ,
38
+ onChange : functionType < ( current : number ) => void > ( ) ,
39
+ 'onUpdate:current' : functionType < ( current : number ) => void > ( ) ,
35
40
} ) ;
36
41
37
42
export const stepProps = ( ) => ( {
38
43
description : PropTypes . any ,
39
44
icon : PropTypes . any ,
40
- status : String as PropType < 'wait' | 'process' | 'finish' | 'error' > ,
41
- disabled : { type : Boolean , default : undefined } ,
45
+ status : stringType < 'wait' | 'process' | 'finish' | 'error' > ( ) ,
46
+ disabled : booleanType ( ) ,
42
47
title : PropTypes . any ,
43
48
subTitle : PropTypes . any ,
44
- onClick : Function as PropType < MouseEventHandler > ,
49
+ onClick : functionType < MouseEventHandler > ( ) ,
45
50
} ) ;
46
51
47
52
export type StepsProps = Partial < ExtractPropTypes < ReturnType < typeof stepsProps > > > ;
@@ -61,6 +66,13 @@ const Steps = defineComponent({
61
66
// emits: ['update:current', 'change'],
62
67
setup ( props , { attrs, slots, emit } ) {
63
68
const { prefixCls, direction : rtlDirection , configProvider } = useConfigInject ( 'steps' , props ) ;
69
+
70
+ // 接入换肤
71
+ const [ , token ] = useToken ( ) ;
72
+
73
+ // style
74
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
75
+
64
76
const screens = useBreakpoint ( ) ;
65
77
const direction = computed ( ( ) =>
66
78
props . responsive && screens . value . xs ? 'vertical' : props . direction ,
@@ -84,11 +96,12 @@ const Steps = defineComponent({
84
96
// currently it's hard-coded, since we can't easily read the actually width of icon
85
97
const progressWidth = props . size === 'small' ? 32 : 40 ;
86
98
const iconWithProgress = (
87
- < div class = { `${ prefixCls } -progress-icon` } >
99
+ < div class = { `${ prefixCls . value } -progress-icon` } >
88
100
< Progress
89
101
type = "circle"
90
102
percent = { props . percent }
91
103
width = { progressWidth }
104
+ strokeColor = { token . value . colorPrimary }
92
105
strokeWidth = { 4 }
93
106
format = { ( ) => null }
94
107
/>
@@ -106,22 +119,24 @@ const Steps = defineComponent({
106
119
[ `${ prefixCls . value } -with-progress` ] : props . percent !== undefined ,
107
120
} ,
108
121
attrs . class ,
122
+ hashId . value ,
109
123
) ;
110
124
const icons = {
111
125
finish : < CheckOutlined class = { `${ prefixCls } -finish-icon` } /> ,
112
126
error : < CloseOutlined class = { `${ prefixCls } -error-icon` } /> ,
113
127
} ;
114
- return (
128
+ return wrapSSR (
115
129
< VcSteps
116
130
icons = { icons }
131
+ { ...attrs }
117
132
{ ...omit ( props , [ 'percent' , 'responsive' ] ) }
118
133
direction = { direction . value }
119
134
prefixCls = { prefixCls . value }
120
135
iconPrefix = { iconPrefix . value }
121
136
class = { stepsClassName }
122
137
onChange = { handleChange }
123
138
v-slots = { { ...slots , stepIcon : stepIconRender } }
124
- />
139
+ /> ,
125
140
) ;
126
141
} ;
127
142
} ,
0 commit comments