/**
 * v-click-outside
 *
 * ```vue
 * <div v-click-outside="onClickOutside">
 * ```
 */ import { VNodeDirective } from 'vue/types/vnode' ; interface ClickOutsideDirective extends VNodeDirective { value ? : ( e : Event ) => void ; } export default { inserted ( el , binding ) { el . _clickOutside = ( e ) => { if ( ! el . contains ( e . target as HTMLElement ) ) { binding . value ! ( e ) ; } } ; document . body . addEventListener ( 'click' , el . _clickOutside , true ) ; } , unbind ( el ) { if ( ! el . _clickOutside ) { return ; } document . body . removeEventListener ( 'click' , el . _clickOutside , true ) ; delete el . _clickOutside ; } , } ;