import { _EventListener , eventType , Handler } from '../types/event' ; import { State } from '../types/store' ; import { isDisabledDate } from './date' ; import { isObject } from './typeOf' ; export function getEventListener ( el , eventName = 'click' ) { let eventHandler ; function _on ( handler , state ? ) { eventHandler = on ( el , handler , eventName , state ) ; } function _off ( ) { el . removeEventListener ( eventName , eventHandler ) ; } return [ _on , _off ] ; } export function on ( el , handler , eventName = 'click' , state ? , arg ? ) { function listener ( e ) { if ( isObject ( arg ) && arg . date && state && isDisabledDate ( state , ( arg as any ) . date ) ) return ; return handler . call ( state , e ) ; } el . addEventListener ( eventName , listener ) ; return listener ; }