2022-04-22 09:49:26 -04:00
|
|
|
import {
|
|
|
|
OverlayTrigger,
|
|
|
|
OverlayTriggerProps,
|
|
|
|
Tooltip as BSTooltip,
|
|
|
|
} from 'react-bootstrap'
|
|
|
|
|
2022-05-18 09:46:10 -04:00
|
|
|
type OverlayTriggerCustomProps = {
|
|
|
|
shouldUpdatePosition?: boolean // Not officially documented https://stackoverflow.com/a/43138470
|
|
|
|
} & OverlayTriggerProps
|
|
|
|
|
2022-04-22 09:49:26 -04:00
|
|
|
type TooltipProps = {
|
|
|
|
children: React.ReactNode
|
2022-05-18 09:46:10 -04:00
|
|
|
description: React.ReactNode
|
2022-04-22 09:49:26 -04:00
|
|
|
id: string
|
2022-05-18 09:46:10 -04:00
|
|
|
overlayProps?: Omit<OverlayTriggerCustomProps, 'overlay'>
|
2022-04-22 09:49:26 -04:00
|
|
|
tooltipProps?: BSTooltip.TooltipProps
|
|
|
|
}
|
|
|
|
|
|
|
|
function Tooltip({
|
|
|
|
id,
|
|
|
|
description,
|
|
|
|
children,
|
|
|
|
tooltipProps,
|
|
|
|
overlayProps,
|
|
|
|
}: TooltipProps) {
|
|
|
|
return (
|
|
|
|
<OverlayTrigger
|
|
|
|
overlay={
|
|
|
|
<BSTooltip id={`${id}-tooltip`} {...tooltipProps}>
|
|
|
|
{description}
|
|
|
|
</BSTooltip>
|
|
|
|
}
|
|
|
|
{...overlayProps}
|
|
|
|
placement={overlayProps?.placement || 'top'}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</OverlayTrigger>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Tooltip
|