import { unref } from 'vue' import { isArray } from '@element-plus/utils' import type { Arrayable } from '@element-plus/utils' import type { Ref } from 'vue' import type { TooltipTriggerType } from './trigger' export const isTriggerType = ( trigger: Arrayable, type: TooltipTriggerType ) => { if (isArray(trigger)) { return trigger.includes(type) } return trigger === type } export const whenTrigger = ( trigger: Ref>, type: TooltipTriggerType, handler: (e: Event) => void ) => { return (e: Event) => { isTriggerType(unref(trigger), type) && handler(e) } }