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