@@ -20,22 +20,27 @@ import {
20
20
OnChanges ,
21
21
OnDestroy ,
22
22
ChangeDetectorRef ,
23
+ Input ,
23
24
} from '@angular/core' ;
24
25
import {
26
+ CanDisable ,
27
+ CanDisableCtor ,
25
28
CanDisableRipple ,
26
29
CanDisableRippleCtor ,
27
30
MatLine ,
28
31
setLines ,
29
32
mixinDisableRipple ,
33
+ mixinDisabled ,
30
34
} from '@angular/material/core' ;
35
+ import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
31
36
import { Subject } from 'rxjs' ;
32
37
import { takeUntil } from 'rxjs/operators' ;
33
38
34
39
// Boilerplate for applying mixins to MatList.
35
40
/** @docs -private */
36
41
class MatListBase { }
37
- const _MatListMixinBase : CanDisableRippleCtor & typeof MatListBase =
38
- mixinDisableRipple ( MatListBase ) ;
42
+ const _MatListMixinBase : CanDisableRippleCtor & CanDisableCtor & typeof MatListBase =
43
+ mixinDisabled ( mixinDisableRipple ( MatListBase ) ) ;
39
44
40
45
// Boilerplate for applying mixins to MatListItem.
41
46
/** @docs -private */
@@ -52,12 +57,12 @@ const _MatListItemMixinBase: CanDisableRippleCtor & typeof MatListItemBase =
52
57
} ,
53
58
templateUrl : 'list.html' ,
54
59
styleUrls : [ 'list.css' ] ,
55
- inputs : [ 'disableRipple' ] ,
60
+ inputs : [ 'disableRipple' , 'disabled' ] ,
56
61
encapsulation : ViewEncapsulation . None ,
57
62
changeDetection : ChangeDetectionStrategy . OnPush ,
58
63
} )
59
- export class MatNavList extends _MatListMixinBase implements CanDisableRipple , OnChanges ,
60
- OnDestroy {
64
+ export class MatNavList extends _MatListMixinBase implements CanDisable , CanDisableRipple ,
65
+ OnChanges , OnDestroy {
61
66
/** Emits when the state of the list changes. */
62
67
_stateChanges = new Subject < void > ( ) ;
63
68
@@ -70,6 +75,7 @@ export class MatNavList extends _MatListMixinBase implements CanDisableRipple, O
70
75
}
71
76
72
77
static ngAcceptInputType_disableRipple : boolean | string | null | undefined ;
78
+ static ngAcceptInputType_disabled : boolean | string | null | undefined ;
73
79
}
74
80
75
81
@Component ( {
@@ -80,11 +86,12 @@ export class MatNavList extends _MatListMixinBase implements CanDisableRipple, O
80
86
'class' : 'mat-list mat-list-base'
81
87
} ,
82
88
styleUrls : [ 'list.css' ] ,
83
- inputs : [ 'disableRipple' ] ,
89
+ inputs : [ 'disableRipple' , 'disabled' ] ,
84
90
encapsulation : ViewEncapsulation . None ,
85
91
changeDetection : ChangeDetectionStrategy . OnPush ,
86
92
} )
87
- export class MatList extends _MatListMixinBase implements CanDisableRipple , OnChanges , OnDestroy {
93
+ export class MatList extends _MatListMixinBase implements CanDisable , CanDisableRipple , OnChanges ,
94
+ OnDestroy {
88
95
/** Emits when the state of the list changes. */
89
96
_stateChanges = new Subject < void > ( ) ;
90
97
@@ -119,6 +126,7 @@ export class MatList extends _MatListMixinBase implements CanDisableRipple, OnCh
119
126
}
120
127
121
128
static ngAcceptInputType_disableRipple : boolean | string | null | undefined ;
129
+ static ngAcceptInputType_disabled : boolean | string | null | undefined ;
122
130
}
123
131
124
132
/**
@@ -157,6 +165,7 @@ export class MatListSubheaderCssMatStyler {}
157
165
exportAs : 'matListItem' ,
158
166
host : {
159
167
'class' : 'mat-list-item' ,
168
+ '[class.mat-list-item-disabled]' : 'disabled' ,
160
169
// @breaking -change 8.0.0 Remove `mat-list-item-avatar` in favor of `mat-list-item-with-avatar`.
161
170
'[class.mat-list-item-avatar]' : '_avatar || _icon' ,
162
171
'[class.mat-list-item-with-avatar]' : '_avatar || _icon' ,
@@ -201,6 +210,14 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn
201
210
}
202
211
}
203
212
213
+ /** Whether the option is disabled. */
214
+ @Input ( )
215
+ get disabled ( ) { return this . _disabled || ! ! ( this . _list && this . _list . disabled ) ; }
216
+ set disabled ( value : boolean ) {
217
+ this . _disabled = coerceBooleanProperty ( value ) ;
218
+ }
219
+ private _disabled = false ;
220
+
204
221
ngAfterContentInit ( ) {
205
222
setLines ( this . _lines , this . _element ) ;
206
223
}
@@ -222,4 +239,5 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn
222
239
}
223
240
224
241
static ngAcceptInputType_disableRipple : boolean | string | null | undefined ;
242
+ static ngAcceptInputType_disabled : boolean | string | null | undefined ;
225
243
}
0 commit comments