@@ -2,7 +2,7 @@ import React, { useState, useEffect, ReactElement, FC } from 'react';
22import styles from './styles' ;
33import { IStep , IStepperProps } from './types' ;
44import Bubble from '../bubble' ;
5- import { LABEL_POSITION } from '../bubble/ constants' ;
5+ import { LABEL_POSITION } from '../constants' ;
66
77const Stepper : FC < IStepperProps > = ( props ) => {
88 const {
@@ -27,10 +27,10 @@ const Stepper: FC<IStepperProps> = (props) => {
2727 getInActiveBubbleStyles
2828 } = stylesOverride ;
2929
30- const [ currentActiveStepIndexVal , setCurrentActiveStepIndexVal ] = useState < number > ( ) ;
30+ const [ currentActiveStepIndexVal , setCurrentActiveStepIndexVal ] = useState < number > ( 0 ) ;
3131
3232 useEffect ( ( ) => {
33- setCurrentActiveStepIndexVal ( currentActiveStepIndex ?? 0 ) ;
33+ setCurrentActiveStepIndexVal ( ( currentActiveStepIndex ?? 0 ) as number ) ;
3434 } , [ currentActiveStepIndex ] ) ;
3535
3636 const handleStepClick = ( stepIndex : number ) : void => {
@@ -65,6 +65,7 @@ const Stepper: FC<IStepperProps> = (props) => {
6565 { step ?. label && (
6666 < span
6767 style = { { ...styles . labelTitle ,
68+ ...( ( enableStepClick && styles . cursorPointer ) || { } ) ,
6869 ...( ( getLabelTitleStyles && getLabelTitleStyles ( step , index ) ) || { } ) ,
6970 ...( ( index === currentActiveStepIndexVal && styles . activeLabelTitle ) || { } ) ,
7071 ...( ( index === currentActiveStepIndexVal && getActiveLabelTitleStyles && getActiveLabelTitleStyles ( step , index ) ) || { } )
@@ -77,19 +78,23 @@ const Stepper: FC<IStepperProps> = (props) => {
7778 ) }
7879 { step ?. description && (
7980 < span style = { { ...styles . labelDescription ,
81+ ...( ( enableStepClick && styles . cursorPointer ) || { } ) ,
8082 ...( ( getLabelDescriptionStyles && getLabelDescriptionStyles ( step , index ) ) || { } ) ,
8183 ...( ( index === currentActiveStepIndexVal ) && styles . activeLabelDescription || { } ) ,
8284 ...( ( index === currentActiveStepIndexVal && getActiveLabelDescriptionStyles && getActiveLabelDescriptionStyles ( step , index ) ) || { } )
83- } } >
85+ } }
86+ onClick = { ( ) : void => handleStepClick ( index ) }
87+ role = "presentation"
88+ >
8489 { step . description }
8590 </ span >
8691 ) }
8792 </ div >
8893 { index < steps ?. length - 1 && (
8994 < div style = { { ...styles . lineSeparator ,
9095 ...( ( getLineSeparatorStyles && getLineSeparatorStyles ( step , index ) ) || { } ) ,
91- ...( ( currentActiveStepIndexVal && index > currentActiveStepIndexVal - 1 ) && styles . inactiveStepLineSeparator || { } ) ,
92- ...( ( currentActiveStepIndexVal && index > currentActiveStepIndexVal - 1
96+ ...( ( index > currentActiveStepIndexVal - 1 ) && styles . inactiveStepLineSeparator || { } ) ,
97+ ...( ( index > currentActiveStepIndexVal - 1
9398 && getInactiveLineSeparatorStyles && getInactiveLineSeparatorStyles ( step , index ) ) || { } )
9499 } } />
95100 ) }
0 commit comments