import { RefObject } from "react" ; const ApiMethods = [ "blur" , "focus" , "click" , "select" , "setRangeText" , "setSelectionRange" , "checkValidity" , "reportValidity" , "setCustomValidity" ] ; export function useForwardInputApi ( inputRef ) { return ( targetRef ) => { const element = targetRef . current ; ApiMethods . forEach ( ( x ) => { ( element as Record < string , any > ) [ x ] = ( ( ... args ) => { inputRef . current [ x ] ( ... args ) ; } ) ; } ) ; return element ; } ; }