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