11import PropTypes from '../_util/vue-types' ;
2- import { getOptionProps , getComponentFromProp , getListeners } from '../_util/props-util' ;
2+ import { getOptionProps , getComponent } from '../_util/props-util' ;
33
44function isString ( str ) {
55 return typeof str === 'string' ;
@@ -28,21 +28,26 @@ export default {
2828 finish : PropTypes . any ,
2929 error : PropTypes . any ,
3030 } ) . loose ,
31+ onClick : PropTypes . func ,
32+ onStepClick : PropTypes . func ,
3133 } ,
3234 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+
3542 this . $emit ( 'stepClick' , this . stepIndex ) ;
3643 } ,
3744 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' ) ;
4651 let iconNode ;
4752 const iconClassName = {
4853 [ `${ prefixCls } -icon` ] : true ,
@@ -86,22 +91,23 @@ export default {
8691 tailContent,
8792 adjustMarginRight,
8893 disabled,
94+ onClick,
95+ onStepClick,
8996 } = getOptionProps ( this ) ;
9097
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' ) ;
94101
95102 const classString = {
96103 [ `${ prefixCls } -item` ] : true ,
97104 [ `${ prefixCls } -item-${ status } ` ] : true ,
98- [ `${ prefixCls } -item-custom` ] : getComponentFromProp ( this , 'icon' ) ,
105+ [ `${ prefixCls } -item-custom` ] : getComponent ( this , 'icon' ) ,
99106 [ `${ prefixCls } -item-active` ] : active ,
100107 [ `${ prefixCls } -item-disabled` ] : disabled === true ,
101108 } ;
102109 const stepProps = {
103110 class : classString ,
104- on : getListeners ( this ) ,
105111 } ;
106112 const stepItemStyle = { } ;
107113 if ( itemWidth ) {
@@ -110,17 +116,15 @@ export default {
110116 if ( adjustMarginRight ) {
111117 stepItemStyle . marginRight = adjustMarginRight ;
112118 }
113- const listeners = getListeners ( this ) ;
119+
114120 const accessibilityProps = {
115- attrs : { } ,
116- on : {
117- click : listeners . click || noop ,
118- } ,
121+ onClick : onClick || noop ,
119122 } ;
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 ;
124128 }
125129 return (
126130 < div { ...stepProps } style = { stepItemStyle } >
0 commit comments