/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-b46ab85
 * Released under the MIT license.
 */

import { useEffect, useState } from 'react';
import { useFocus as reactAriaUseFocus, useFocusVisible } from 'react-aria';
export function useFocus({ isDisabled }, onlyVisible = false) {
    useEffect(() => {
        setIsFocused(false);
    }, [isDisabled]);
    let [isFocused, setIsFocused] = useState(false);
    let { isFocusVisible } = useFocusVisible({});
    let { focusProps } = reactAriaUseFocus({
        isDisabled,
        // @ts-ignore
        onFocusChange: setIsFocused,
    });
    return {
        focusProps,
        isFocused: isFocused && (onlyVisible ? isFocusVisible : true),
    };
}

        