license import { MDCComponent } from '@material/base/component' ; import { MDCRipple } from '@material/ripple/component' ; import { MDCFormFieldAdapter } from './adapter' ; import { MDCFormFieldFoundation } from './foundation' ; export interface MDCFormFieldInput { readonly ripple : MDCRipple | undefined ; } export class MDCFormField extends MDCComponent < MDCFormFieldFoundation > { static override attachTo ( root ) { return new MDCFormField ( root ) ; } input ? : MDCFormFieldInput ; private labelEl ( ) { const { LABEL_SELECTOR } = MDCFormFieldFoundation . strings ; return this . root . querySelector ( LABEL_SELECTOR ) ; } override getDefaultFoundation ( ) { const adapter = { activateInputRipple : ( ) => { if ( this . input && this . input . ripple ) { this . input . ripple . activate ( ) ; } } , deactivateInputRipple : ( ) => { if ( this . input && this . input . ripple ) { this . input . ripple . deactivate ( ) ; } } , deregisterInteractionHandler : ( evtType , handler ) => { const labelEl = this . labelEl ( ) ; if ( labelEl ) { ( labelEl as HTMLElement ) . removeEventListener ( evtType , handler ) ; } } , registerInteractionHandler : ( evtType , handler ) => { const labelEl = this . labelEl ( ) ; if ( labelEl ) { ( labelEl as HTMLElement ) . addEventListener ( evtType , handler ) ; } } , } ; return new MDCFormFieldFoundation ( adapter ) ; } }