import React from 'react' ; import { useFoundation } from '@rmwc/base' ; import { IconProps } from '@rmwc/icon' ; import { EventType , SpecificEventListener } from '@material/base/types' ; import { MDCSelectIconFoundation } from '@material/select' ; import { MDCTextFieldIconFoundation } from '@material/textfield' ; import { SelectIconApi } from './' ; export const useSelectIconFoundation = ( props ) => { const { foundation , ... elements } = useFoundation ( { props , elements : { rootEl : true } , api : ( { foundation } ) : SelectIconApi => { return { getFoundation : ( ) => foundation } ; } , foundation : ( { rootEl , emit } ) => { return new MDCSelectIconFoundation ( { getAttr : ( attr ) => rootEl . getProp ( attr as any ) as string | null , setAttr : ( attr , value ) => rootEl . setProp ( attr as any , value ) , removeAttr : ( attr ) => rootEl . removeProp ( attr as any ) , setContent : ( content ) => { rootEl . ref && ( rootEl . ref . textContent = content ) ; } , registerInteractionHandler : < K extends EventType > ( evtType , handler ) => rootEl . addEventListener ( evtType , handler ) , deregisterInteractionHandler : < K extends EventType > ( evtType , handler ) => rootEl . removeEventListener ( evtType , handler ) , notifyIconAction : ( ) => emit ( 'onClick' , { } , true ) } ) ; } } ) ; return { ... elements } ; } ;