Files
element-plus/packages/components/tooltip/src/utils.ts
三咲智子 6503e55277 refactor(utils): migrate utils (#5949)
* refactor(utils-v2): migrate utils

* refactor(utils-v2): migrate utils

* refactor(utils-v2): migrate utils

* refactor(utils): remove

* refactor(utils): rename

* refactor(utils): move EVENT_CODE to constants

* refactor: remove generic
2022-02-11 11:03:15 +08:00

22 lines
525 B
TypeScript

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