import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef, useMemo } from 'react';
import { Checkbox } from '../Checkbox';
import { FormControl } from '../FormControl';
import { Tooltip } from '../Tooltip';
import { checkboxFieldClassnames } from './constants';
import { StyledFormControlledLabel, StyledFormHelperText } from './styles';
/**
 * Составной компонент чекбокса. Содержит label, tooltip, helperText и т.д.
 */
export const CheckboxField = forwardRef(({ isSuccess, helperText, hideHelperText = false, label, isError, ...restProps }, ref) => {
    const showTooltip = useMemo(() => Boolean(isError && hideHelperText), [isError, hideHelperText]);
    return (_jsxs(FormControl, { ref: ref, children: [_jsx(Tooltip, { title: showTooltip && helperText, placement: "bottom-start", withoutContainer: false, children: _jsx(StyledFormControlledLabel, { classes: { label: checkboxFieldClassnames.label }, control: _jsx(Checkbox, { isError: isError, ...restProps }), label: label }) }), !hideHelperText && (_jsx(StyledFormHelperText, { error: isError, success: isSuccess, children: helperText }))] }));
});
