license import { MDCComponent } from '@material/base/component' ; import { MDCTabIndicatorAdapter } from './adapter' ; import { MDCFadingTabIndicatorFoundation } from './fading-foundation' ; import { MDCTabIndicatorFoundation } from './foundation' ; import { MDCSlidingTabIndicatorFoundation } from './sliding-foundation' ; export type MDCTabIndicatorFactory = ( el : Element , foundation ? : MDCTabIndicatorFoundation ) => MDCTabIndicator ; export class MDCTabIndicator extends MDCComponent < MDCTabIndicatorFoundation > { static override attachTo ( root ) { return new MDCTabIndicator ( root ) ; } private content ! : HTMLElement ; override initialize ( ) { this . content = this . root . querySelector < HTMLElement > ( MDCTabIndicatorFoundation . strings . CONTENT_SELECTOR ) ! ; } computeContentClientRect ( ) { return this . foundation . computeContentClientRect ( ) ; } override getDefaultFoundation ( ) { const adapter = { addClass : ( className ) => this . root . classList . add ( className ) , removeClass : ( className ) => this . root . classList . remove ( className ) , computeContentClientRect : ( ) => this . content . getBoundingClientRect ( ) , setContentStyleProperty : ( prop , value ) => { this . content . style . setProperty ( prop , value ) ; } , } ; if ( this . root . classList . contains ( MDCTabIndicatorFoundation . cssClasses . FADE ) ) { return new MDCFadingTabIndicatorFoundation ( adapter ) ; } return new MDCSlidingTabIndicatorFoundation ( adapter ) ; } activate ( previousIndicatorClientRect ? ) { this . foundation . activate ( previousIndicatorClientRect ) ; } deactivate ( ) { this . foundation . deactivate ( ) ; } }