"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormToggleButtonGroup = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const ToggleButtonGroup_1 = require("../../components/ToggleButtonGroup");
const useFormFieldProps_1 = require("../useFormFieldProps");
const FormToggleButtonGroup = (props) => {
    const { isError, onChange, errorText, color: colorToggleButton, isDisabledErrorText, ...restProps } = props;
    const { error, children, helperText, onChange: fieldPropsOnChange, ...fieldProps } = (0, useFormFieldProps_1.useFormFieldProps)({
        ...restProps,
        defaultValue: restProps.defaultValue ||
            null,
    });
    const handleChange = (_, value) => {
        if (value) {
            fieldPropsOnChange(value);
        }
    };
    const { color, inputRef, ...restFieldProps } = fieldProps;
    return ((0, jsx_runtime_1.jsx)(ToggleButtonGroup_1.ToggleButtonGroup, { isError: error, errorText: !isDisabledErrorText && helperText, onChange: handleChange, color: colorToggleButton, exclusive: true, ...restFieldProps, children: children }));
};
exports.FormToggleButtonGroup = FormToggleButtonGroup;
