1
1
import PropTypes from '../_util/vue-types' ;
2
- import { getOptionProps , getComponentFromProp , getListeners } from '../_util/props-util' ;
2
+ import { getOptionProps , getComponent } from '../_util/props-util' ;
3
3
4
4
function isString ( str ) {
5
5
return typeof str === 'string' ;
@@ -28,21 +28,26 @@ export default {
28
28
finish : PropTypes . any ,
29
29
error : PropTypes . any ,
30
30
} ) . loose ,
31
+ onClick : PropTypes . func ,
32
+ onStepClick : PropTypes . func ,
31
33
} ,
32
34
methods : {
33
- onClick ( ...args ) {
34
- this . $emit ( 'click' , ...args ) ;
35
+ onItemClick ( ...args ) {
36
+ const { onClick } = this . $props ;
37
+
38
+ if ( onClick ) {
39
+ this . $emit ( 'click' , ...args ) ;
40
+ }
41
+
35
42
this . $emit ( 'stepClick' , this . stepIndex ) ;
36
43
} ,
37
44
renderIconNode ( ) {
38
- const { prefixCls, stepNumber, status, iconPrefix, icons } = getOptionProps ( this ) ;
39
- let progressDot = this . progressDot ;
40
- if ( progressDot === undefined ) {
41
- progressDot = this . $scopedSlots . progressDot ;
42
- }
43
- const icon = getComponentFromProp ( this , 'icon' ) ;
44
- const title = getComponentFromProp ( this , 'title' ) ;
45
- const description = getComponentFromProp ( this , 'description' ) ;
45
+ const { prefixCls, stepNumber, status, iconPrefix, icons, progressDot } = getOptionProps (
46
+ this ,
47
+ ) ;
48
+ const icon = getComponent ( this , 'icon' ) ;
49
+ const title = getComponent ( this , 'title' ) ;
50
+ const description = getComponent ( this , 'description' ) ;
46
51
let iconNode ;
47
52
const iconClassName = {
48
53
[ `${ prefixCls } -icon` ] : true ,
@@ -86,22 +91,23 @@ export default {
86
91
tailContent,
87
92
adjustMarginRight,
88
93
disabled,
94
+ onClick,
95
+ onStepClick,
89
96
} = getOptionProps ( this ) ;
90
97
91
- const title = getComponentFromProp ( this , 'title' ) ;
92
- const subTitle = getComponentFromProp ( this , 'subTitle' ) ;
93
- const description = getComponentFromProp ( this , 'description' ) ;
98
+ const title = getComponent ( this , 'title' ) ;
99
+ const subTitle = getComponent ( this , 'subTitle' ) ;
100
+ const description = getComponent ( this , 'description' ) ;
94
101
95
102
const classString = {
96
103
[ `${ prefixCls } -item` ] : true ,
97
104
[ `${ prefixCls } -item-${ status } ` ] : true ,
98
- [ `${ prefixCls } -item-custom` ] : getComponentFromProp ( this , 'icon' ) ,
105
+ [ `${ prefixCls } -item-custom` ] : getComponent ( this , 'icon' ) ,
99
106
[ `${ prefixCls } -item-active` ] : active ,
100
107
[ `${ prefixCls } -item-disabled` ] : disabled === true ,
101
108
} ;
102
109
const stepProps = {
103
110
class : classString ,
104
- on : getListeners ( this ) ,
105
111
} ;
106
112
const stepItemStyle = { } ;
107
113
if ( itemWidth ) {
@@ -110,17 +116,15 @@ export default {
110
116
if ( adjustMarginRight ) {
111
117
stepItemStyle . marginRight = adjustMarginRight ;
112
118
}
113
- const listeners = getListeners ( this ) ;
119
+
114
120
const accessibilityProps = {
115
- attrs : { } ,
116
- on : {
117
- click : listeners . click || noop ,
118
- } ,
121
+ onClick : onClick || noop ,
119
122
} ;
120
- if ( listeners . stepClick && ! disabled ) {
121
- accessibilityProps . attrs . role = 'button' ;
122
- accessibilityProps . attrs . tabIndex = 0 ;
123
- accessibilityProps . on . click = this . onClick ;
123
+
124
+ if ( onStepClick && ! disabled ) {
125
+ accessibilityProps . role = 'button' ;
126
+ accessibilityProps . tabIndex = 0 ;
127
+ accessibilityProps . onClick = this . onItemClick ;
124
128
}
125
129
return (
126
130
< div { ...stepProps } style = { stepItemStyle } >
0 commit comments