UNPKG

@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.

34 lines (29 loc) 1.01 kB
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; import { useRef, useState, useCallback } from "react"; var useErrorTooltip = function useErrorTooltip(_ref) { var onFocus = _ref.onFocus; var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), tooltipShown = _useState2[0], setTooltipShown = _useState2[1]; var _useState3 = useState(false), _useState4 = _slicedToArray(_useState3, 2), tooltipShownHover = _useState4[0], setTooltipShownHover = _useState4[1]; var labelRef = useRef(null); var iconRef = useRef(null); var handleFocus = useCallback(function (ev) { if (onFocus) onFocus(ev); setTooltipShown(true); }, [onFocus]); return { tooltipShown: tooltipShown, tooltipShownHover: tooltipShownHover, setTooltipShown: setTooltipShown, setTooltipShownHover: setTooltipShownHover, labelRef: labelRef, iconRef: iconRef, handleFocus: handleFocus }; }; export default useErrorTooltip;