|
|
|
@ -11,6 +11,7 @@ interface Props {
|
|
|
|
|
// force disable tooltip |
|
|
|
|
disabled?: boolean |
|
|
|
|
placement?: TooltipPlacement | undefined |
|
|
|
|
showOnTruncateOnly?: boolean |
|
|
|
|
hideOnClick?: boolean |
|
|
|
|
overlayClassName?: string |
|
|
|
|
} |
|
|
|
@ -20,6 +21,7 @@ const props = defineProps<Props>()
|
|
|
|
|
const modifierKey = computed(() => props.modifierKey) |
|
|
|
|
const tooltipStyle = computed(() => props.tooltipStyle) |
|
|
|
|
const disabled = computed(() => props.disabled) |
|
|
|
|
const showOnTruncateOnly = computed(() => props?.showOnTruncateOnly) |
|
|
|
|
const hideOnClick = computed(() => props.hideOnClick) |
|
|
|
|
const placement = computed(() => props.placement ?? 'top') |
|
|
|
|
|
|
|
|
@ -65,9 +67,16 @@ onKeyStroke(
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
watch([isHovering, () => modifierKey.value, () => disabled.value], ([hovering, key, isDisabled]) => { |
|
|
|
|
const targetElement = el?.value |
|
|
|
|
const isElementTruncated = targetElement?.scrollWidth > targetElement?.clientWidth |
|
|
|
|
if (!hovering || isDisabled || !isElementTruncated) { |
|
|
|
|
if (showOnTruncateOnly.value) { |
|
|
|
|
const targetElement = el?.value |
|
|
|
|
const isElementTruncated = targetElement?.scrollWidth > targetElement?.clientWidth |
|
|
|
|
if (!isElementTruncated) { |
|
|
|
|
showTooltip.value = false |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!hovering || isDisabled) { |
|
|
|
|
showTooltip.value = false |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|