88
99import {
1010 AfterContentInit ,
11+ booleanAttribute ,
1112 ChangeDetectorRef ,
1213 ContentChildren ,
1314 Directive ,
@@ -33,7 +34,7 @@ import {
3334 SPACE ,
3435 UP_ARROW ,
3536} from '@angular/cdk/keycodes' ;
36- import { BooleanInput , coerceArray , coerceBooleanProperty } from '@angular/cdk/coercion' ;
37+ import { coerceArray } from '@angular/cdk/coercion' ;
3738import { SelectionModel } from '@angular/cdk/collections' ;
3839import { defer , fromEvent , merge , Observable , Subject } from 'rxjs' ;
3940import { filter , map , startWith , switchMap , takeUntil } from 'rxjs/operators' ;
@@ -115,12 +116,12 @@ export class CdkOption<T = unknown> implements ListKeyManagerOption, Highlightab
115116 @Input ( 'cdkOptionTypeaheadLabel' ) typeaheadLabel : string ;
116117
117118 /** Whether this option is disabled. */
118- @Input ( 'cdkOptionDisabled' )
119+ @Input ( { alias : 'cdkOptionDisabled' , transform : booleanAttribute } )
119120 get disabled ( ) : boolean {
120121 return this . listbox . disabled || this . _disabled ;
121122 }
122- set disabled ( value : BooleanInput ) {
123- this . _disabled = coerceBooleanProperty ( value ) ;
123+ set disabled ( value : boolean ) {
124+ this . _disabled = value ;
124125 }
125126 private _disabled : boolean = false ;
126127
@@ -281,37 +282,25 @@ export class CdkListbox<T = unknown> implements AfterContentInit, OnDestroy, Con
281282 * Whether the listbox allows multiple options to be selected. If the value switches from `true`
282283 * to `false`, and more than one option is selected, all options are deselected.
283284 */
284- @Input ( 'cdkListboxMultiple' )
285+ @Input ( { alias : 'cdkListboxMultiple' , transform : booleanAttribute } )
285286 get multiple ( ) : boolean {
286287 return this . selectionModel . multiple ;
287288 }
288- set multiple ( value : BooleanInput ) {
289- this . selectionModel . multiple = coerceBooleanProperty ( value ) ;
289+ set multiple ( value : boolean ) {
290+ this . selectionModel . multiple = value ;
290291
291292 if ( this . options ) {
292293 this . _updateInternalValue ( ) ;
293294 }
294295 }
295296
296297 /** Whether the listbox is disabled. */
297- @Input ( 'cdkListboxDisabled' )
298- get disabled ( ) : boolean {
299- return this . _disabled ;
300- }
301- set disabled ( value : BooleanInput ) {
302- this . _disabled = coerceBooleanProperty ( value ) ;
303- }
304- private _disabled : boolean = false ;
298+ @Input ( { alias : 'cdkListboxDisabled' , transform : booleanAttribute } )
299+ disabled : boolean = false ;
305300
306301 /** Whether the listbox will use active descendant or will move focus onto the options. */
307- @Input ( 'cdkListboxUseActiveDescendant' )
308- get useActiveDescendant ( ) : boolean {
309- return this . _useActiveDescendant ;
310- }
311- set useActiveDescendant ( shouldUseActiveDescendant : BooleanInput ) {
312- this . _useActiveDescendant = coerceBooleanProperty ( shouldUseActiveDescendant ) ;
313- }
314- private _useActiveDescendant : boolean = false ;
302+ @Input ( { alias : 'cdkListboxUseActiveDescendant' , transform : booleanAttribute } )
303+ useActiveDescendant : boolean = false ;
315304
316305 /** The orientation of the listbox. Only affects keyboard interaction, not visual layout. */
317306 @Input ( 'cdkListboxOrientation' )
@@ -341,23 +330,23 @@ export class CdkListbox<T = unknown> implements AfterContentInit, OnDestroy, Con
341330 * Whether the keyboard navigation should wrap when the user presses arrow down on the last item
342331 * or arrow up on the first item.
343332 */
344- @Input ( 'cdkListboxNavigationWrapDisabled' )
333+ @Input ( { alias : 'cdkListboxNavigationWrapDisabled' , transform : booleanAttribute } )
345334 get navigationWrapDisabled ( ) {
346335 return this . _navigationWrapDisabled ;
347336 }
348- set navigationWrapDisabled ( wrap : BooleanInput ) {
349- this . _navigationWrapDisabled = coerceBooleanProperty ( wrap ) ;
337+ set navigationWrapDisabled ( wrap : boolean ) {
338+ this . _navigationWrapDisabled = wrap ;
350339 this . listKeyManager ?. withWrap ( ! this . _navigationWrapDisabled ) ;
351340 }
352341 private _navigationWrapDisabled = false ;
353342
354343 /** Whether keyboard navigation should skip over disabled items. */
355- @Input ( 'cdkListboxNavigatesDisabledOptions' )
344+ @Input ( { alias : 'cdkListboxNavigatesDisabledOptions' , transform : booleanAttribute } )
356345 get navigateDisabledOptions ( ) {
357346 return this . _navigateDisabledOptions ;
358347 }
359- set navigateDisabledOptions ( skip : BooleanInput ) {
360- this . _navigateDisabledOptions = coerceBooleanProperty ( skip ) ;
348+ set navigateDisabledOptions ( skip : boolean ) {
349+ this . _navigateDisabledOptions = skip ;
361350 this . listKeyManager ?. skipPredicate (
362351 this . _navigateDisabledOptions ? this . _skipNonePredicate : this . _skipDisabledPredicate ,
363352 ) ;
@@ -683,7 +672,7 @@ export class CdkListbox<T = unknown> implements AfterContentInit, OnDestroy, Con
683672
684673 /** Called when the user presses keydown on the listbox. */
685674 protected _handleKeydown ( event : KeyboardEvent ) {
686- if ( this . _disabled ) {
675+ if ( this . disabled ) {
687676 return ;
688677 }
689678
@@ -809,7 +798,7 @@ export class CdkListbox<T = unknown> implements AfterContentInit, OnDestroy, Con
809798
810799 /** Get the id of the active option if active descendant is being used. */
811800 protected _getAriaActiveDescendant ( ) : string | null | undefined {
812- return this . _useActiveDescendant ? this . listKeyManager ?. activeItem ?. id : null ;
801+ return this . useActiveDescendant ? this . listKeyManager ?. activeItem ?. id : null ;
813802 }
814803
815804 /** Get the tabindex for the listbox. */
0 commit comments