"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckboxField = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const Checkbox_1 = require("../Checkbox");
const FormControl_1 = require("../FormControl");
const Tooltip_1 = require("../Tooltip");
const constants_1 = require("./constants");
const styles_1 = require("./styles");
/**
 * Составной компонент чекбокса. Содержит label, tooltip, helperText и т.д.
 */
exports.CheckboxField = (0, react_1.forwardRef)(({ isSuccess, helperText, hideHelperText = false, label, isError, ...restProps }, ref) => {
    const showTooltip = (0, react_1.useMemo)(() => Boolean(isError && hideHelperText), [isError, hideHelperText]);
    return ((0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { ref: ref, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: showTooltip && helperText, placement: "bottom-start", withoutContainer: false, children: (0, jsx_runtime_1.jsx)(styles_1.StyledFormControlledLabel, { classes: { label: constants_1.checkboxFieldClassnames.label }, control: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { isError: isError, ...restProps }), label: label }) }), !hideHelperText && ((0, jsx_runtime_1.jsx)(styles_1.StyledFormHelperText, { error: isError, success: isSuccess, children: helperText }))] }));
});
