import { jsx as _jsx } from "react/jsx-runtime";
import { ToggleButtonGroup, } from '../../components/ToggleButtonGroup';
import { useFormFieldProps } from '../useFormFieldProps';
export const FormToggleButtonGroup = (props) => {
    const { isError, onChange, errorText, color: colorToggleButton, isDisabledErrorText, ...restProps } = props;
    const { error, children, helperText, onChange: fieldPropsOnChange, ...fieldProps } = useFormFieldProps({
        ...restProps,
        defaultValue: restProps.defaultValue ||
            null,
    });
    const handleChange = (_, value) => {
        if (value) {
            fieldPropsOnChange(value);
        }
    };
    const { color, inputRef, ...restFieldProps } = fieldProps;
    return (_jsx(ToggleButtonGroup, { isError: error, errorText: !isDisabledErrorText && helperText, onChange: handleChange, color: colorToggleButton, exclusive: true, ...restFieldProps, children: children }));
};
