6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { AfterContentInit , Directive , ElementRef , NgZone , OnDestroy , QueryList } from '@angular/core' ;
10
- import { setLines } from '@angular/material/core' ;
9
+ import { Platform } from '@angular/cdk/platform' ;
10
+ import {
11
+ AfterContentInit ,
12
+ Directive ,
13
+ ElementRef ,
14
+ HostBinding ,
15
+ NgZone ,
16
+ OnDestroy ,
17
+ QueryList
18
+ } from '@angular/core' ;
19
+ import { RippleConfig , RippleRenderer , RippleTarget , setLines } from '@angular/material/core' ;
11
20
import { Subscription } from 'rxjs' ;
12
21
import { startWith } from 'rxjs/operators' ;
13
22
14
- export class MatListBase { }
23
+ @Directive ( )
24
+ export class MatListBase {
25
+ // @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
26
+ // metadata is not inherited by child classes, instead the host binding data is defined in a way
27
+ // that can be inherited.
28
+ // tslint:disable-next-line:no-host-decorator-in-concrete
29
+ @HostBinding ( 'class.mdc-list--non-interactive' )
30
+ _isNonInteractive : boolean ;
31
+ }
15
32
16
33
@Directive ( )
17
- export abstract class MatListItemBase implements AfterContentInit , OnDestroy {
34
+ export abstract class MatListItemBase implements AfterContentInit , OnDestroy , RippleTarget {
18
35
lines : QueryList < ElementRef < Element > > ;
19
36
37
+ rippleConfig : RippleConfig = { } ;
38
+
39
+ rippleDisabled : boolean ;
40
+
20
41
private _subscriptions = new Subscription ( ) ;
21
42
22
- constructor ( protected _element : ElementRef , protected _ngZone : NgZone ) { }
43
+ private _rippleRenderer : RippleRenderer ;
44
+
45
+ constructor ( protected _element : ElementRef , protected _ngZone : NgZone , listBase : MatListBase ,
46
+ platform : Platform ) {
47
+ const el = this . _element . nativeElement ;
48
+ this . rippleDisabled = listBase . _isNonInteractive ;
49
+ if ( ! listBase . _isNonInteractive ) {
50
+ el . classList . add ( 'mat-mdc-list-item-interactive' ) ;
51
+ }
52
+ this . _rippleRenderer =
53
+ new RippleRenderer ( this , this . _ngZone , el , platform ) ;
54
+ this . _rippleRenderer . setupTriggerEvents ( el ) ;
55
+ }
23
56
24
57
ngAfterContentInit ( ) {
25
58
this . _monitorLines ( ) ;
@@ -44,5 +77,6 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy {
44
77
45
78
ngOnDestroy ( ) {
46
79
this . _subscriptions . unsubscribe ( ) ;
80
+ this . _rippleRenderer . _removeTriggerEvents ( ) ;
47
81
}
48
82
}
0 commit comments