File tree Expand file tree Collapse file tree 7 files changed +101
-74
lines changed Expand file tree Collapse file tree 7 files changed +101
-74
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,16 @@ export class CdkStep {
9393 private _optional = false ;
9494
9595 /** Return whether step is completed or not. */
96+ @Input ( )
9697 get completed ( ) {
98+ return this . _customCompleted == null ? this . _defaultCompleted : this . _customCompleted ;
99+ }
100+ set completed ( value : any ) {
101+ this . _customCompleted = coerceBooleanProperty ( value ) ;
102+ }
103+ private _customCompleted : boolean | null = null ;
104+
105+ private get _defaultCompleted ( ) {
97106 return this . _stepControl ? this . _stepControl . valid && this . interacted : this . interacted ;
98107 }
99108
@@ -193,6 +202,15 @@ export class CdkStepper {
193202 }
194203 }
195204
205+ _getIndicatorType ( index : number ) : 'number' | 'edit' | 'done' {
206+ const step = this . _steps . toArray ( ) [ index ] ;
207+ if ( ! step . completed || this . _selectedIndex == index ) {
208+ return 'number' ;
209+ } else {
210+ return step . editable ? 'edit' : 'done' ;
211+ }
212+ }
213+
196214 private _emitStepperSelectionEvent ( newIndex : number ) : void {
197215 const stepsArray = this . _steps . toArray ( ) ;
198216 this . selectionChange . emit ( {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ <h3>Linear Vertical Stepper Demo using a single form</h3>
1919 </ div >
2020 </ md-step >
2121
22- < md-step formGroupName ="1 " [stepControl] ="formArray.get([1]) " [ optional] =" true " >
22+ < md-step formGroupName ="1 " [stepControl] ="formArray.get([1]) " optional >
2323 < ng-template mdStepLabel >
2424 < div > Fill out your phone number</ div >
2525 </ ng-template >
@@ -62,7 +62,7 @@ <h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
6262 </ form >
6363 </ md-step >
6464
65- < md-step [stepControl] ="phoneFormGroup ">
65+ < md-step [stepControl] ="phoneFormGroup " optional >
6666 < form [formGroup] ="phoneFormGroup ">
6767 < ng-template mdStepLabel > Fill out your phone number</ ng-template >
6868 < md-form-field >
Original file line number Diff line number Diff line change 2323 color : mat-color ($foreground , disabled-text );
2424 }
2525
26- .mat-stepper-index-interacted ,
27- .mat-stepper-index-new {
26+ .mat-step-indicator {
2827 background-color : mat-color ($primary );
2928 color : mat-color ($primary , default-contrast );
3029 }
3433 color : mat-color ($foreground , disabled-text );
3534 }
3635
37- .mat-stepper-index-new {
36+ .mat-step-indicator-not-touched {
3837 background-color : mat-color ($foreground , disabled-text );
3938 }
4039 }
Original file line number Diff line number Diff line change 88 [tabIndex] ="_focusIndex == i ? 0 : -1 "
99 (click) ="step.select() "
1010 (keydown) ="_onKeydown($event) ">
11- < div class ="mat-stepper-index-new " *ngIf =" !step.completed || selectedIndex == i " >
12- {{i + 1}}
13- </ div >
14- < div class =" mat-stepper-index-interacted " *ngIf =" step.completed && selectedIndex != i " >
15- < md-icon *ngIf =" !step.editable " > done </ md-icon >
16- < md-icon *ngIf =" step.editable " > create </ md-icon >
11+ < div class ="mat-step-indicator "
12+ [ngSwitch] =" _getIndicatorType(i) "
13+ [class.mat-step-indicator-not-touched] =" _getIndicatorType(i) == 'number' " >
14+ < span *ngSwitchCase =" 'number' " > {{i + 1}} </ span >
15+ < md-icon *ngSwitchCase =" 'edit' " > create </ md-icon >
16+ < md-icon *ngSwitchCase =" 'done' " > done </ md-icon >
1717 </ div >
1818
19- < div [ngClass] ="{
20- 'mat-stepper-label-active': step.completed || selectedIndex == i,
21- 'mat-stepper-label-inactive': !step.completed && selectedIndex != i
22- } ">
19+ < div [class.mat-stepper-label-active] ="step.completed || selectedIndex == i "
20+ [class.mat-stepper-label-inactive] ="!step.completed && selectedIndex != i ">
2321 <!-- If there is a label template, use it. -->
2422 < ng-container *ngIf ="step.stepLabel " [ngTemplateOutlet] ="step.stepLabel.template ">
2523 </ ng-container >
Original file line number Diff line number Diff line change 66 [tabIndex] ="_focusIndex == i ? 0 : -1 "
77 (click) ="step.select() "
88 (keydown) ="_onKeydown($event) ">
9- < div class ="mat-stepper-index-new " *ngIf =" !step.completed || selectedIndex == i " >
10- {{i + 1}}
11- </ div >
12- < div class =" mat-stepper-index-interacted " *ngIf =" step.completed && selectedIndex != i " >
13- < md-icon *ngIf =" !step.editable " > done </ md-icon >
14- < md-icon *ngIf =" step.editable " > create </ md-icon >
9+ < div class ="mat-step-indicator "
10+ [ngSwitch] =" _getIndicatorType(i) "
11+ [class.mat-step-indicator-not-touched] =" _getIndicatorType(i) == 'number' " >
12+ < span *ngSwitchCase =" 'number' " > {{i + 1}} </ span >
13+ < md-icon *ngSwitchCase =" 'edit' " > create </ md-icon >
14+ < md-icon *ngSwitchCase =" 'done' " > done </ md-icon >
1515 </ div >
1616
17- < div [ngClass] ="{
18- 'mat-stepper-label-active': step.completed || selectedIndex == i,
19- 'mat-stepper-label-inactive': !step.completed && selectedIndex != i
20- } ">
17+ < div [class.mat-stepper-label-active] ="step.completed || selectedIndex == i "
18+ [class.mat-stepper-label-inactive] ="!step.completed && selectedIndex != i ">
2119 <!-- If there is a label template, use it. -->
2220 < ng-container *ngIf ="step.stepLabel "[ngTemplateOutlet] ="step.stepLabel.template ">
2321 </ ng-container >
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ $mat-step-optional-font-size: 12px;
2424 vertical-align : middle ;
2525}
2626
27- .mat-stepper-index-new ,
28- .mat-stepper-index-interacted {
27+ .mat-step-indicator {
2928 border-radius : 50% ;
3029 height : $mat-stepper-label-header-height ;
3130 width : $mat-stepper-label-header-height ;
@@ -48,8 +47,7 @@ $mat-step-optional-font-size: 12px;
4847 outline : none ;
4948 padding : 0 $mat-stepper-side-gap ;
5049
51- .mat-stepper-index-new ,
52- .mat-stepper-index-interacted {
50+ .mat-step-indicator {
5351 margin-right : $mat-stepper-line-gap ;
5452 flex : none ;
5553 }
@@ -62,8 +60,7 @@ $mat-step-optional-font-size: 12px;
6260 outline : none ;
6361 max-height : $mat-stepper-label-header-height ;
6462
65- .mat-stepper-index-new ,
66- .mat-stepper-index-interacted {
63+ .mat-step-indicator {
6764 margin-right : $mat-vertical-stepper-content-margin - $mat-stepper-side-gap ;
6865 }
6966}
You can’t perform that action at this time.
0 commit comments