@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.
33 lines (29 loc) • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
const useErrorTooltip = ({
onFocus
}) => {
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);
setTooltipShown(true);
}, [onFocus]);
return {
tooltipShown,
tooltipShownHover,
setTooltipShown,
setTooltipShownHover,
labelRef,
iconRef,
handleFocus
};
};
var _default = useErrorTooltip;
exports.default = _default;