import { useCallback, useState } from "react";
const useNativeValidity = (error) => {
    const [nativeInvalid, setNativeInvalid] = useState(false);
    const onBlur = useCallback((e) => {
        setNativeInvalid(!e.currentTarget.checkValidity());
    }, []);
    const onChange = useCallback((e) => {
        if (e.currentTarget.checkValidity()) {
            setNativeInvalid(false);
        }
    }, []);
    const onInvalid = useCallback(() => {
        setNativeInvalid(true);
    }, []);
    const revalidate = useCallback((input) => {
        if (input === null || input === void 0 ? void 0 : input.checkValidity()) {
            setNativeInvalid(false);
        }
    }, []);
    return {
        finalError: Boolean(error) || nativeInvalid,
        onBlur,
        onChange,
        onInvalid,
        revalidate,
    };
};
export { useNativeValidity };
//# sourceMappingURL=useNativeValidity.js.map