import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback } from 'react';
import { AddressAutocomplete, } from '../../components/AddressAutocomplete';
import { useFormFieldProps } from '../useFormFieldProps';
export const FormAddressAutocomplete = (props) => {
    const { freeSolo = true, defaultValue, ...restProps } = props;
    const fieldProps = useFormFieldProps({
        freeSolo,
        ...restProps,
    });
    const { onChange, onInputChange, ...restFieldProps } = fieldProps;
    const handleOnInputChange = useCallback((_event, value, reason) => {
        //Устанавливаем значение в форму если триггером изменения инпута был пользовательский ввод
        if (freeSolo && reason === 'input') {
            onChange({ addressString: value });
        }
    }, [freeSolo, onInputChange]);
    return (_jsx(AddressAutocomplete, { ...restFieldProps, onChange: onChange, onInputChange: handleOnInputChange, defaultValue: defaultValue }));
};
