@@ -27,66 +27,27 @@ export default function MultiStep(props: PropsWithChildren<MultiStepProps>) {
2727 currentStep = arNavigationSteps [ lastActiveStepIndex >= 0 ? lastActiveStepIndex : 0 ] ;
2828 }
2929
30- // const svgCurrent = Utils.getImageSrc("circle-solid", Utils.getSDKStaticConentUrl());
31- // const svgNotCurrent = Utils.getImageSrc("circle-solid", Utils.getSDKStaticConentUrl());
32-
33- function _getVIconClass ( status ) : string {
34- if ( status === 'current' ) {
35- return 'psdk-vertical-step-icon-selected' ;
36- } else if ( status === 'future' ) {
37- return 'psdk-vertical-step-icon-future' ;
38- }
39-
40- return 'psdk-vertical-step-icon' ;
41- }
42-
43- function _getVLabelClass ( status ) : string {
44- if ( status === 'current' ) {
45- return 'psdk-vertical-step-label-selected' ;
46- }
47-
48- return 'psdk-vertical-step-label' ;
49- }
50-
5130 function _getVBodyClass ( index : number ) : string {
52- if ( index < arNavigationSteps . length - 1 ) {
53- return 'psdk-vertical-step-body psdk-vertical-step-line' ;
54- }
31+ const baseClass = 'psdk-vertical-step-body' ;
32+ const isNotLastStep = index < arNavigationSteps . length - 1 ;
5533
56- return 'psdk-vertical-step-body' ;
57- }
58-
59- function _getHLabelClass ( step ) : string {
60- if ( step . ID === currentStep ?. ID ) {
61- return 'psdk-horizontal-step-label-selected' ;
62- }
63-
64- return 'psdk-horizontal-step-label' ;
34+ return isNotLastStep ? `${ baseClass } psdk-vertical-step-line` : baseClass ;
6535 }
6636
6737 function _getAutoFlexClass ( currentStep ) : string {
6838 const currentStepIndex = arNavigationSteps . findIndex ( step => step . ID === currentStep ?. ID ) ;
69- const len = arNavigationSteps . length ;
70-
71- console . log ( 'Current Step Index:' , currentStep , arNavigationSteps . length - 2 ) ;
72-
73- if ( currentStepIndex === arNavigationSteps . length - 2 && arNavigationSteps [ len - 1 ] . visited_status === 'current' ) {
74- return 'flex-auto' ;
75- }
76-
77- if ( currentStep . visited_status === 'current' ) {
78- return 'flex-auto' ;
79- }
39+ const totalSteps = arNavigationSteps . length ;
40+ const lastStep = arNavigationSteps [ totalSteps - 1 ] ;
8041
81- if ( currentStep . visited_status === ' current' ) {
82- return 'flex-auto ';
83- }
42+ // Apply flex-auto class if current step is active OR if current step is second-to-last and the last step is active
43+ const isCurrentStepActive = currentStep . visited_status === 'current ';
44+ const isSecondToLastWithActiveLastStep = currentStepIndex === totalSteps - 2 && lastStep ?. visited_status === 'current' ;
8445
85- return '' ;
46+ return isCurrentStepActive || isSecondToLastWithActiveLastStep ? 'flex-auto' : '' ;
8647 }
8748
88- function _showHLine ( index : number ) : boolean {
89- return index < arNavigationSteps . length - 1 ;
49+ function isLastStep ( index : number ) : boolean {
50+ return index === arNavigationSteps . length - 1 ;
9051 }
9152
9253 function buttonPress ( sAction : string , sButtonType : string ) {
@@ -101,13 +62,13 @@ export default function MultiStep(props: PropsWithChildren<MultiStepProps>) {
10162 return (
10263 < React . Fragment key = { mainStep . actionID } >
10364 < div className = 'psdk-vertical-step' >
104- < div className = ' psdk-vertical-step-header' >
105- < div className = { _getVIconClass ( mainStep . visited_status ) } >
65+ < div className = { ` psdk-vertical-step-header ${ mainStep . visited_status } ` } >
66+ < div className = { `psdk-vertical-step-icon` } >
10667 < div className = 'psdk-vertical-step-icon-content' >
10768 < span > { index + 1 } </ span >
10869 </ div >
10970 </ div >
110- < div className = { _getVLabelClass ( mainStep . visited_status ) } > { mainStep . visited_status === 'current' && mainStep . name } </ div >
71+ < div className = 'psdk-vertical-step-label' > { mainStep . visited_status === 'current' && mainStep . name } </ div >
11172 </ div >
11273 < div className = { _getVBodyClass ( index ) } >
11374 { mainStep ?. steps && (
@@ -161,9 +122,9 @@ export default function MultiStep(props: PropsWithChildren<MultiStepProps>) {
161122 < span > { index + 1 } </ span >
162123 </ div >
163124 </ div >
164- < div className = { _getHLabelClass ( mainStep ) } > { mainStep . visited_status === 'current' && mainStep . name } </ div >
125+ < div className = 'psdk-horizontal-step-label' > { mainStep . visited_status === 'current' && mainStep . name } </ div >
165126 </ div >
166- { _showHLine ( index ) && < div className = { `psdk-horizontal-step-line ${ _getAutoFlexClass ( mainStep ) } ` } /> }
127+ { ! isLastStep ( index ) && < div className = { `psdk-horizontal-step-line ${ _getAutoFlexClass ( mainStep ) } ` } /> }
167128 </ React . Fragment >
168129 ) ;
169130 } ) }
0 commit comments