import { useContext } from '@lynx-js/react';
import { useEffect } from 'react';
import { formContext } from './Form.jsx';
export const Field = ({ children, name, bindinput, bindblur, ...props }) => {
    const { handleBlur, handleInput, values, setValue } = useContext(formContext);
    useEffect(() => {
        if (!values[name])
            setValue(name, '');
    }, []);
    return (<input 
    //@ts-ignore
    bindinput={(event) => {
            handleInput(name)(event);
            bindinput?.(event);
        }} bindblur={(event) => {
            handleBlur(name)();
            bindblur?.(event);
        }} {...props}/>);
};
