88
99import { FocusableOption , FocusKeyManager } from '@angular/cdk/a11y' ;
1010import { Direction , Directionality } from '@angular/cdk/bidi' ;
11- import {
12- BooleanInput ,
13- coerceBooleanProperty ,
14- coerceNumberProperty ,
15- NumberInput ,
16- } from '@angular/cdk/coercion' ;
1711import { ENTER , hasModifierKey , SPACE } from '@angular/cdk/keycodes' ;
1812import {
1913 AfterViewInit ,
@@ -38,6 +32,8 @@ import {
3832 ViewChild ,
3933 ViewEncapsulation ,
4034 AfterContentInit ,
35+ booleanAttribute ,
36+ numberAttribute ,
4137} from '@angular/core' ;
4238import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform' ;
4339import { Observable , of as observableOf , Subject } from 'rxjs' ;
@@ -149,32 +145,18 @@ export class CdkStep implements OnChanges {
149145 @Input ( ) state : StepState ;
150146
151147 /** Whether the user can return to this step once it has been marked as completed. */
152- @Input ( )
153- get editable ( ) : boolean {
154- return this . _editable ;
155- }
156- set editable ( value : BooleanInput ) {
157- this . _editable = coerceBooleanProperty ( value ) ;
158- }
159- private _editable = true ;
148+ @Input ( { transform : booleanAttribute } ) editable : boolean = true ;
160149
161150 /** Whether the completion of step is optional. */
162- @Input ( )
163- get optional ( ) : boolean {
164- return this . _optional ;
165- }
166- set optional ( value : BooleanInput ) {
167- this . _optional = coerceBooleanProperty ( value ) ;
168- }
169- private _optional = false ;
151+ @Input ( { transform : booleanAttribute } ) optional : boolean = false ;
170152
171153 /** Whether step is marked as completed. */
172- @Input ( )
154+ @Input ( { transform : booleanAttribute } )
173155 get completed ( ) : boolean {
174156 return this . _completedOverride == null ? this . _getDefaultCompleted ( ) : this . _completedOverride ;
175157 }
176- set completed ( value : BooleanInput ) {
177- this . _completedOverride = coerceBooleanProperty ( value ) ;
158+ set completed ( value : boolean ) {
159+ this . _completedOverride = value ;
178160 }
179161 _completedOverride : boolean | null = null ;
180162
@@ -183,12 +165,12 @@ export class CdkStep implements OnChanges {
183165 }
184166
185167 /** Whether step has an error. */
186- @Input ( )
168+ @Input ( { transform : booleanAttribute } )
187169 get hasError ( ) : boolean {
188170 return this . _customError == null ? this . _getDefaultError ( ) : this . _customError ;
189171 }
190- set hasError ( value : BooleanInput ) {
191- this . _customError = coerceBooleanProperty ( value ) ;
172+ set hasError ( value : boolean ) {
173+ this . _customError = value ;
192174 }
193175 private _customError : boolean | null = null ;
194176
@@ -271,40 +253,31 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
271253 private _sortedHeaders = new QueryList < CdkStepHeader > ( ) ;
272254
273255 /** Whether the validity of previous steps should be checked or not. */
274- @Input ( )
275- get linear ( ) : boolean {
276- return this . _linear ;
277- }
278- set linear ( value : BooleanInput ) {
279- this . _linear = coerceBooleanProperty ( value ) ;
280- }
281- private _linear = false ;
256+ @Input ( { transform : booleanAttribute } ) linear : boolean = false ;
282257
283258 /** The index of the selected step. */
284- @Input ( )
259+ @Input ( { transform : numberAttribute } )
285260 get selectedIndex ( ) : number {
286261 return this . _selectedIndex ;
287262 }
288- set selectedIndex ( index : NumberInput ) {
289- const newIndex = coerceNumberProperty ( index ) ;
290-
263+ set selectedIndex ( index : number ) {
291264 if ( this . steps && this . _steps ) {
292265 // Ensure that the index can't be out of bounds.
293- if ( ! this . _isValidIndex ( newIndex ) && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
266+ if ( ! this . _isValidIndex ( index ) && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
294267 throw Error ( 'cdkStepper: Cannot assign out-of-bounds value to `selectedIndex`.' ) ;
295268 }
296269
297270 this . selected ?. _markAsInteracted ( ) ;
298271
299272 if (
300- this . _selectedIndex !== newIndex &&
301- ! this . _anyControlsInvalidOrPending ( newIndex ) &&
302- ( newIndex >= this . _selectedIndex || this . steps . toArray ( ) [ newIndex ] . editable )
273+ this . _selectedIndex !== index &&
274+ ! this . _anyControlsInvalidOrPending ( index ) &&
275+ ( index >= this . _selectedIndex || this . steps . toArray ( ) [ index ] . editable )
303276 ) {
304- this . _updateSelectedItemIndex ( newIndex ) ;
277+ this . _updateSelectedItemIndex ( index ) ;
305278 }
306279 } else {
307- this . _selectedIndex = newIndex ;
280+ this . _selectedIndex = index ;
308281 }
309282 }
310283 private _selectedIndex = 0 ;
@@ -551,7 +524,7 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
551524 }
552525
553526 private _anyControlsInvalidOrPending ( index : number ) : boolean {
554- if ( this . _linear && index >= 0 ) {
527+ if ( this . linear && index >= 0 ) {
555528 return this . steps
556529 . toArray ( )
557530 . slice ( 0 , index )
0 commit comments