import { useObjectRef } from './useObjectRef' ; interface IOptions < T > { onClick ? : ( ) => void ; onDoubleClick ? : ( event : React . MouseEvent < T > ) => void ; } interface IHandlers < T > { onClick : ( event : React . MouseEvent < T > ) => void ; onDoubleClick : ( event : React . MouseEvent < T > ) => void ; } export function useClickEvents < T > ( options ) { return useObjectRef ( ( ) => ( { delayed : false , onClick ( event ) { if ( this . delayed ) { return ; } this . delayed = true ; setTimeout ( ( ) => { if ( this . delayed ) { this . options . onClick ?. ( ) ; this . delayed = false ; } } , 300 ) ; } , onDoubleClick ( event ) { this . delayed = false ; options . onDoubleClick ?. ( event ) ; } , } ) , { options } ) ; }