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 {
93
93
private _optional = false ;
94
94
95
95
/** Return whether step is completed or not. */
96
+ @Input ( )
96
97
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 ( ) {
97
106
return this . _stepControl ? this . _stepControl . valid && this . interacted : this . interacted ;
98
107
}
99
108
@@ -193,6 +202,15 @@ export class CdkStepper {
193
202
}
194
203
}
195
204
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
+
196
214
private _emitStepperSelectionEvent ( newIndex : number ) : void {
197
215
const stepsArray = this . _steps . toArray ( ) ;
198
216
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>
19
19
</ div >
20
20
</ md-step >
21
21
22
- < md-step formGroupName ="1 " [stepControl] ="formArray.get([1]) " [ optional] =" true " >
22
+ < md-step formGroupName ="1 " [stepControl] ="formArray.get([1]) " optional >
23
23
< ng-template mdStepLabel >
24
24
< div > Fill out your phone number</ div >
25
25
</ ng-template >
@@ -62,7 +62,7 @@ <h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
62
62
</ form >
63
63
</ md-step >
64
64
65
- < md-step [stepControl] ="phoneFormGroup ">
65
+ < md-step [stepControl] ="phoneFormGroup " optional >
66
66
< form [formGroup] ="phoneFormGroup ">
67
67
< ng-template mdStepLabel > Fill out your phone number</ ng-template >
68
68
< md-form-field >
Original file line number Diff line number Diff line change 23
23
color : mat-color ($foreground , disabled-text );
24
24
}
25
25
26
- .mat-stepper-index-interacted ,
27
- .mat-stepper-index-new {
26
+ .mat-step-indicator {
28
27
background-color : mat-color ($primary );
29
28
color : mat-color ($primary , default-contrast );
30
29
}
34
33
color : mat-color ($foreground , disabled-text );
35
34
}
36
35
37
- .mat-stepper-index-new {
36
+ .mat-step-indicator-not-touched {
38
37
background-color : mat-color ($foreground , disabled-text );
39
38
}
40
39
}
Original file line number Diff line number Diff line change 8
8
[tabIndex] ="_focusIndex == i ? 0 : -1 "
9
9
(click) ="step.select() "
10
10
(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 >
17
17
</ div >
18
18
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 ">
23
21
<!-- If there is a label template, use it. -->
24
22
< ng-container *ngIf ="step.stepLabel " [ngTemplateOutlet] ="step.stepLabel.template ">
25
23
</ ng-container >
Original file line number Diff line number Diff line change 6
6
[tabIndex] ="_focusIndex == i ? 0 : -1 "
7
7
(click) ="step.select() "
8
8
(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 >
15
15
</ div >
16
16
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 ">
21
19
<!-- If there is a label template, use it. -->
22
20
< ng-container *ngIf ="step.stepLabel "[ngTemplateOutlet] ="step.stepLabel.template ">
23
21
</ ng-container >
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ $mat-step-optional-font-size: 12px;
24
24
vertical-align : middle ;
25
25
}
26
26
27
- .mat-stepper-index-new ,
28
- .mat-stepper-index-interacted {
27
+ .mat-step-indicator {
29
28
border-radius : 50% ;
30
29
height : $mat-stepper-label-header-height ;
31
30
width : $mat-stepper-label-header-height ;
@@ -48,8 +47,7 @@ $mat-step-optional-font-size: 12px;
48
47
outline : none ;
49
48
padding : 0 $mat-stepper-side-gap ;
50
49
51
- .mat-stepper-index-new ,
52
- .mat-stepper-index-interacted {
50
+ .mat-step-indicator {
53
51
margin-right : $mat-stepper-line-gap ;
54
52
flex : none ;
55
53
}
@@ -62,8 +60,7 @@ $mat-step-optional-font-size: 12px;
62
60
outline : none ;
63
61
max-height : $mat-stepper-label-header-height ;
64
62
65
- .mat-stepper-index-new ,
66
- .mat-stepper-index-interacted {
63
+ .mat-step-indicator {
67
64
margin-right : $mat-vertical-stepper-content-margin - $mat-stepper-side-gap ;
68
65
}
69
66
}
You can’t perform that action at this time.
0 commit comments