UNPKG

@grafana/ui

Version:
27 lines (24 loc) 709 B
import { useState, useRef, useCallback } from 'react'; "use strict"; 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