import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { FormControl } from '../FormControl';
import { Tooltip } from '../Tooltip';
import { RadioGroupContext } from './RadioGroupContext';
import { Fieldset, StyledFormLabel } from './styles';
import { useLogic } from './useLogic';
/**
 * Компонент RadioGroup - fieldset для Radio компонентов
 */
export const RadioGroup = forwardRef((props, ref) => {
    const { errorText, formControlProps, groupLabel, labelId, isError, required, contextValue, className, row, children, disabled, style, inputRef, } = useLogic(props);
    return (_jsx(Tooltip, { arrow: false, title: isError && errorText, placement: "bottom-start", followCursor: true, children: _jsxs(FormControl, { ...formControlProps, ref: ref, children: [groupLabel && (_jsx(StyledFormLabel, { id: labelId, htmlFor: labelId, required: required, disabled: disabled, children: groupLabel })), _jsx(RadioGroupContext.Provider, { value: contextValue, children: _jsx(Fieldset, { id: labelId, "aria-labelledby": labelId, className: className, role: "radiogroup", "$row": row, style: style, ref: inputRef, tabIndex: -1, children: children }) })] }) }));
});
