66 * found in the LICENSE file at https://angular.io/license
77 */
88
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' ;
1120import { Subscription } from 'rxjs' ;
1221import { startWith } from 'rxjs/operators' ;
1322
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+ }
1532
1633@Directive ( )
17- export abstract class MatListItemBase implements AfterContentInit , OnDestroy {
34+ export abstract class MatListItemBase implements AfterContentInit , OnDestroy , RippleTarget {
1835 lines : QueryList < ElementRef < Element > > ;
1936
37+ rippleConfig : RippleConfig = { } ;
38+
39+ rippleDisabled : boolean ;
40+
2041 private _subscriptions = new Subscription ( ) ;
2142
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+ }
2356
2457 ngAfterContentInit ( ) {
2558 this . _monitorLines ( ) ;
@@ -44,5 +77,6 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy {
4477
4578 ngOnDestroy ( ) {
4679 this . _subscriptions . unsubscribe ( ) ;
80+ this . _rippleRenderer . _removeTriggerEvents ( ) ;
4781 }
4882}
0 commit comments