license import { MDCFoundation } from '@material/base/foundation' ; import { SpecificEventListener } from '@material/base/types' ; import { MDCFloatingLabelAdapter } from './adapter' ; import { cssClasses } from './constants' ; export class MDCFloatingLabelFoundation extends MDCFoundation < MDCFloatingLabelAdapter > { static override get cssClasses ( ) { return cssClasses ; } /**
     * See  MDCFloatingLabelAdapter for typing information on parameters and return types.
      static override get defaultAdapter ( ) : MDCFloatingLabelAdapter { return { addClass : ( ) => undefined , removeClass : ( ) => undefined , getWidth : ( ) => 0 , registerInteractionHandler : ( ) => undefined , deregisterInteractionHandler : ( ) => undefined , } ; } private readonly shakeAnimationEndHandler : SpecificEventListener < 'animationend' > ; constructor ( adapter ? ) { super ( { ... MDCFloatingLabelFoundation . defaultAdapter , ... adapter } ) ; this . shakeAnimationEndHandler = ( ) => { this . handleShakeAnimationEnd ( ) ; } ; } override init ( ) { this . adapter . registerInteractionHandler ( 'animationend' , this . shakeAnimationEndHandler ) ; } override destroy ( ) { this . adapter . deregisterInteractionHandler ( 'animationend' , this . shakeAnimationEndHandler ) ; } /**
     * Returns the width of the label element.
     */ getWidth ( ) { return this . adapter . getWidth ( ) ; } param shouldShake shake ( shouldShake ) { const { LABEL_SHAKE } = MDCFloatingLabelFoundation . cssClasses ; if ( shouldShake ) { this . adapter . addClass ( LABEL_SHAKE ) ; } else { this . adapter . removeClass ( LABEL_SHAKE ) ; } } param shouldFloat float ( shouldFloat ) { const { LABEL_FLOAT_ABOVE , LABEL_SHAKE } = MDCFloatingLabelFoundation . cssClasses ; if ( shouldFloat ) { this . adapter . addClass ( LABEL_FLOAT_ABOVE ) ; } else { this . adapter . removeClass ( LABEL_FLOAT_ABOVE ) ; this . adapter . removeClass ( LABEL_SHAKE ) ; } } param isRequired setRequired ( isRequired ) { const { LABEL_REQUIRED } = MDCFloatingLabelFoundation . cssClasses ; if ( isRequired ) { this . adapter . addClass ( LABEL_REQUIRED ) ; } else { this . adapter . removeClass ( LABEL_REQUIRED ) ; } } private handleShakeAnimationEnd ( ) { const { LABEL_SHAKE } = MDCFloatingLabelFoundation . cssClasses ; this . adapter . removeClass ( LABEL_SHAKE ) ; } } export default MDCFloatingLabelFoundation ;