@@ -32,16 +32,16 @@ let nextId = 0;
3232/** Change event emitted on selection changes. */
3333export class CdkStepperSelectionEvent {
3434 /** The index of the step that is newly selected during this change event. */
35- newIndex : number ;
35+ selectedIndex : number ;
3636
3737 /** The index of the step that was previously selected. */
38- oldIndex : number ;
38+ previouslySelectedIndex : number ;
3939
4040 /** The new step component that is selected ruing this change event. */
41- newStep : CdkStep ;
41+ selectedStep : CdkStep ;
4242
4343 /** The step component that was previously selected. */
44- oldStep : CdkStep ;
44+ previouslySelectedStep : CdkStep ;
4545}
4646
4747@Component ( {
@@ -70,7 +70,7 @@ export class CdkStep {
7070@Directive ( {
7171 selector : 'cdk-stepper' ,
7272 host : {
73- '(focus)' : '_setStepfocused ()' ,
73+ '(focus)' : '_setStepFocused ()' ,
7474 '(keydown)' : '_onKeydown($event)' ,
7575 } ,
7676} )
@@ -79,14 +79,15 @@ export class CdkStepper {
7979 @ContentChildren ( CdkStep ) _steps : QueryList < CdkStep > ;
8080
8181 /** The list of step headers of the steps in the stepper. */
82- @ ViewChildren ( 'stepHeader' ) _stepHeader : QueryList < ElementRef > ;
82+ _stepHeader : QueryList < ElementRef > ;
8383
8484 /** The index of the selected step. */
8585 get selectedIndex ( ) { return this . _selectedIndex ; }
8686 set selectedIndex ( index : number ) {
87- if ( this . _selectedIndex == index ) { return ; }
88- this . _emitStepperSelectionEvent ( index ) ;
89- this . _setStepFocused ( this . _selectedIndex ) ;
87+ if ( this . _selectedIndex != index ) {
88+ this . _emitStepperSelectionEvent ( index ) ;
89+ this . _setStepFocused ( this . _selectedIndex ) ;
90+ }
9091 }
9192 private _selectedIndex : number = 0 ;
9293
@@ -113,14 +114,12 @@ export class CdkStepper {
113114
114115 /** Selects and focuses the next step in list. */
115116 next ( ) : void {
116- if ( this . _selectedIndex == this . _steps . length - 1 ) { return ; }
117- this . selectedIndex ++ ;
117+ this . selectedIndex = Math . min ( this . _selectedIndex + 1 , this . _steps . length - 1 ) ;
118118 }
119119
120120 /** Selects and focuses the previous step in list. */
121121 previous ( ) : void {
122- if ( this . _selectedIndex == 0 ) { return ; }
123- this . selectedIndex -- ;
122+ this . selectedIndex = Math . max ( this . _selectedIndex - 1 , 0 ) ;
124123 }
125124
126125 /** Returns a unique id for each step label element. */
@@ -134,14 +133,14 @@ export class CdkStepper {
134133 }
135134
136135 private _emitStepperSelectionEvent ( newIndex : number ) : void {
137- const event = new CdkStepperSelectionEvent ( ) ;
138- event . oldIndex = this . _selectedIndex ;
139- event . newIndex = newIndex ;
140- let stepsArray = this . _steps . toArray ( ) ;
141- event . oldStep = stepsArray [ this . _selectedIndex ] ;
142- event . newStep = stepsArray [ newIndex ] ;
136+ const stepsArray = this . _steps . toArray ( ) ;
137+ this . selectionChange . emit ( {
138+ selectedIndex : newIndex ,
139+ previouslySelectedIndex : this . _selectedIndex ,
140+ selectedStep : stepsArray [ newIndex ] ,
141+ previouslySelectedStep : stepsArray [ this . _selectedIndex ] ,
142+ } ) ;
143143 this . _selectedIndex = newIndex ;
144- this . selectionChange . emit ( event ) ;
145144 }
146145
147146 _onKeydown ( event : KeyboardEvent ) {
0 commit comments