2021-08-13 21:12:19 +00:00
|
|
|
import { useFormikContext } from 'formik'
|
2023-07-24 18:35:05 +00:00
|
|
|
import OverlayTrigger from 'react-bootstrap/OverlayTrigger'
|
|
|
|
import Tooltip from 'react-bootstrap/Tooltip'
|
2021-07-08 18:43:03 +00:00
|
|
|
|
2022-07-30 13:25:46 +00:00
|
|
|
export default function ActionTooltip ({ children, notForm, disable, overlayText, placement }) {
|
2021-08-13 21:12:19 +00:00
|
|
|
// if we're in a form, we want to hide tooltip on submit
|
|
|
|
let formik
|
|
|
|
if (!notForm) {
|
|
|
|
formik = useFormikContext()
|
|
|
|
}
|
2024-04-17 19:22:17 +00:00
|
|
|
if (disable || !overlayText) {
|
2021-09-12 16:55:38 +00:00
|
|
|
return children
|
|
|
|
}
|
2021-07-08 18:43:03 +00:00
|
|
|
return (
|
|
|
|
<OverlayTrigger
|
2022-07-30 13:25:46 +00:00
|
|
|
placement={placement || 'bottom'}
|
2021-07-08 18:43:03 +00:00
|
|
|
overlay={
|
|
|
|
<Tooltip>
|
2024-04-17 19:22:17 +00:00
|
|
|
{overlayText}
|
2021-07-08 18:43:03 +00:00
|
|
|
</Tooltip>
|
|
|
|
}
|
2021-07-15 16:27:29 +00:00
|
|
|
trigger={['hover', 'focus']}
|
2021-08-13 21:12:19 +00:00
|
|
|
show={formik?.isSubmitting ? false : undefined}
|
2021-07-08 18:43:03 +00:00
|
|
|
>
|
2023-07-24 18:35:05 +00:00
|
|
|
<span>
|
|
|
|
{children}
|
|
|
|
</span>
|
2021-07-08 18:43:03 +00:00
|
|
|
</OverlayTrigger>
|
|
|
|
)
|
|
|
|
}
|