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