Files
element-plus/packages/components/tooltip/src/trigger.ts
Xc b1f3b6602c docs(components): [tooltip, popover] controlled mode warnings (#12088)
* docs(components): [tooltip, popover]
* Add controlled mode api description

* docs: add code lost

* chore: add missing comments

---------

Co-authored-by: Dsaquel <291874700n@gmail.com>
2025-09-29 14:18:39 +08:00

43 lines
1.5 KiB
TypeScript

import { buildProps, definePropType } from '@element-plus/utils'
import { popperTriggerProps } from '@element-plus/components/popper'
import { EVENT_CODE } from '@element-plus/constants'
import type { Arrayable } from '@element-plus/utils'
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'
export type TooltipTriggerType = 'hover' | 'focus' | 'click' | 'contextmenu'
export const useTooltipTriggerProps = buildProps({
...popperTriggerProps,
/**
* @description whether Tooltip is disabled
*/
disabled: Boolean,
/**
* @description How should the tooltip be triggered (to show), not valid in controlled mode
*/
trigger: {
type: definePropType<Arrayable<TooltipTriggerType>>([String, Array]),
default: 'hover',
},
/**
* @description When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of tooltip through the keyboard, not valid in controlled mode
*/
triggerKeys: {
type: definePropType<string[]>(Array),
default: () => [EVENT_CODE.enter, EVENT_CODE.numpadEnter, EVENT_CODE.space],
},
/**
* @description when triggering tooltips through hover, whether to focus the trigger element, which improves accessibility
*/
focusOnTarget: Boolean,
} as const)
export type ElTooltipTriggerProps = ExtractPropTypes<
typeof useTooltipTriggerProps
>
export type ElTooltipTriggerPropsPublic = __ExtractPublicPropTypes<
typeof useTooltipTriggerProps
>