@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
29 lines (28 loc) • 771 B
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
var _react = require("react");
const useErrorTooltip = ({
onFocus,
hasTooltip = true
}) => {
const [tooltipShown, setTooltipShown] = (0, _react.useState)(false);
const [tooltipShownHover, setTooltipShownHover] = (0, _react.useState)(false);
const labelRef = (0, _react.useRef)(null);
const iconRef = (0, _react.useRef)(null);
const handleFocus = (0, _react.useCallback)(ev => {
if (onFocus) onFocus(ev);
if (hasTooltip) setTooltipShown(true);
}, [onFocus, hasTooltip]);
return {
tooltipShown,
tooltipShownHover,
setTooltipShown,
setTooltipShownHover,
labelRef,
iconRef,
handleFocus
};
};
var _default = useErrorTooltip;
exports.default = _default;