import { useEffect, useState } from 'react';
export function useFocusControl(_a) {
    var disabled = _a.disabled, onFocus = _a.onFocus, onBlur = _a.onBlur, onBlurWhenDisabled = _a.onBlurWhenDisabled;
    var _b = useState(false), isFocused = _b[0], setFocused = _b[1];
    useEffect(function () {
        if (disabled && isFocused && onBlurWhenDisabled) {
            // force calling custom blur event, try "fix" bug in react https://github.com/facebook/react/issues/9142
            onBlurWhenDisabled();
        }
    }, [disabled, isFocused]);
    var handleFocus = function (e) {
        setFocused(true);
        onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
    };
    var handleBlur = function (e) {
        setFocused(false);
        onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
    };
    return {
        handleFocus: handleFocus,
        handleBlur: handleBlur,
    };
}
//# sourceMappingURL=useFocusControl.js.map