import { inject , customElement , useView , PLATFORM } from 'aurelia-framework' ; import { MDCFloatingLabelFoundation , MDCFloatingLabelAdapter } from '@material/floating-label' ; import { MdcComponent } from '@aurelia-mdc-web/base' ; import { estimateScrollWidth } from '@material/dom/ponyfill' ; @ inject ( Element ) @ customElement ( 'mdc-floating-label' ) @ useView ( PLATFORM . moduleName ( './mdc-floating-label.html' ) ) export class MdcFloatingLabel extends MdcComponent < MDCFloatingLabelFoundation > { 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 ( ) ; } 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 ) ; } }