license import { NgModule , Directive , ElementRef , QueryList , } from '@angular/core' ; import { startWith } from 'rxjs/operators' ; import { MatCommonModule } from '../common-behaviors/common-module' ; /**
 * Shared directive to count lines inside a text area, such as a list item.
 * Line elements can be extracted with a @ContentChildren(MatLine) query, then
 * counted by checking the query list's length.
 */ @ Directive ( { selector : '[mat-line], [matLine]' , host : { 'class' : 'mat-line' } } ) export class MatLine { } docs-private export function setLines ( lines , element ) { lines . changes . pipe ( startWith < QueryList < MatLine > > ( lines ) ) . subscribe ( ( { length } ) => { setClass ( element , 'mat-2-line' , false ) ; setClass ( element , 'mat-3-line' , false ) ; setClass ( element , 'mat-multi-line' , false ) ; if ( length === 2 || length === 3 ) { setClass ( element , `mat-${ length }-line` , true ) ; } else if ( length > 3 ) { setClass ( element , `mat-multi-line` , true ) ; } } ) ; } /** Adds or removes a class from an element. */ function setClass ( element , className , isAdd ) { const classList = element . nativeElement . classList ; isAdd ? classList . add ( className ) : classList . remove ( className ) ; } docs-private deprecated breaking-change export class MatLineSetter { constructor ( lines , element ) { setLines ( lines , element ) ; } } @ NgModule ( { imports : [ MatCommonModule ] , exports : [ MatLine , MatCommonModule ] , declarations : [ MatLine ] , } ) export class MatLineModule { }