import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2019-2026 GoodData Corporation
import { Fragment, memo, useCallback, useMemo } from "react";
import cx from "classnames";
/**
 * @internal
 */
export const Checkbox = memo(function Checkbox({ disabled = false, name = "", text = "", title = "", value = false, labelSize = "small", onChange = () => { }, id, }) {
    const handleChange = useCallback((e) => {
        onChange(e.target.checked);
    }, [onChange]);
    const labelClasses = useMemo(() => cx("input-label-text", {
        "gd-label-small gd-checkbox-label-small": labelSize === "small",
        "gd-label gd-checkbox-label": labelSize === "normal",
    }), [labelSize]);
    return (_jsxs(Fragment, { children: [title ? _jsx("h6", { children: title }) : null, _jsxs("label", { className: "input-checkbox-label", children: [
                    _jsx("input", { id: id, type: "checkbox", className: "input-checkbox", name: name, checked: value, disabled: disabled, onChange: handleChange }), _jsx("span", { className: labelClasses, children: text })
                ] })
        ] }));
});
