// Mixins import Delayable from '../delayable' import Toggleable from '../toggleable' // Utilities import mixins from '../../util/mixins' import { getSlot, getSlotType } from '../../util/helpers' import { consoleError } from '../../util/console' // Types import { VNode, PropType } from 'vue' type Listeners = Dictionary<(e: MouseEvent & KeyboardEvent & FocusEvent) => void> const baseMixins = mixins( Delayable, Toggleable ) /* @vue/component */ export default baseMixins.extend({ name: 'activatable', props: { activator: { default: null as unknown as PropType, validator: (val: string | object) => { return ['string', 'object'].includes(typeof val) }, }, disabled: Boolean, internalActivator: Boolean, openOnHover: Boolean, openOnFocus: Boolean, }, data: () => ({ // Do not use this directly, call getActivator() instead activatorElement: null as HTMLElement | null, activatorNode: [] as VNode[], events: ['click', 'mouseenter', 'mouseleave', 'focus'], listeners: {} as Listeners, }), watch: { activator: 'resetActivator', openOnFocus: 'resetActivator', openOnHover: 'resetActivator', }, mounted () { const slotType = getSlotType(this, 'activator', true) if (slotType && ['v-slot', 'normal'].includes(slotType)) { consoleError(`The activator slot must be bound, try '