license import { MDCComponent } from '@material/base/component' ; import { estimateScrollWidth } from '@material/dom/ponyfill' ; import { MDCFloatingLabelAdapter } from './adapter' ; import { MDCFloatingLabelFoundation } from './foundation' ; export type MDCFloatingLabelFactory = ( el : Element , foundation ? : MDCFloatingLabelFoundation ) => MDCFloatingLabel ; export class MDCFloatingLabel extends MDCComponent < MDCFloatingLabelFoundation > { static override attachTo ( root ) { return new MDCFloatingLabel ( root ) ; } param shouldShake shake ( shouldShake ) { this . foundation . shake ( shouldShake ) ; } param shouldFloat float ( shouldFloat ) { this . foundation . float ( shouldFloat ) ; } param isRequired setRequired ( isRequired ) { this . foundation . setRequired ( isRequired ) ; } getWidth ( ) { return this . foundation . getWidth ( ) ; } override getDefaultFoundation ( ) { const adapter = { addClass : ( className ) => this . root . classList . add ( className ) , removeClass : ( className ) => this . root . classList . remove ( className ) , getWidth : ( ) => estimateScrollWidth ( this . root ) , registerInteractionHandler : ( evtType , handler ) => this . listen ( evtType , handler ) , deregisterInteractionHandler : ( evtType , handler ) => this . unlisten ( evtType , handler ) , } ; return new MDCFloatingLabelFoundation ( adapter ) ; } }