@grafana/ui
Version:
Grafana Components Library
27 lines (24 loc) • 709 B
JavaScript
import { useState, useRef, useCallback } from 'react';
;
const PopoverController = ({ placement = "auto", content, children, hideAfter }) => {
const [show, setShow] = useState(false);
const hideTimeoutRef = useRef(null);
const showPopper = useCallback(() => {
if (hideTimeoutRef.current) {
clearTimeout(hideTimeoutRef.current);
}
setShow(true);
}, []);
const hidePopper = useCallback(() => {
hideTimeoutRef.current = setTimeout(() => {
setShow(false);
}, hideAfter);
}, [hideAfter]);
return children(showPopper, hidePopper, {
show,
placement,
content
});
};
export { PopoverController };
//# sourceMappingURL=PopoverController.mjs.map