import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { useEffect, useRef } from "react";
import { accessibilityConfigToAttributes } from "../../typings/utilities.js";
import { bem } from "../@utils/bem.js";
const { b, e } = bem("gd-ui-kit-checkbox");
/**
 * @internal
 */
export function UiCheckbox({ checked, onChange = () => { }, preventDefault = false, indeterminate = false, disabled = false, accessibilityConfig, tabIndex, label, }) {
    const inputRef = useRef(null);
    useEffect(() => {
        if (inputRef.current) {
            inputRef.current.indeterminate = indeterminate;
        }
    }, [indeterminate]);
    return (_jsxs("label", { className: b(), children: [
            _jsx("input", { ref: inputRef, type: "checkbox", className: e("input"), checked: checked, onChange: onChange, disabled: disabled, onClick: (e) => preventDefault && e.stopPropagation(), tabIndex: tabIndex, ...accessibilityConfigToAttributes(accessibilityConfig) }), _jsx("span", { className: e("box", { checked, indeterminate, disabled }) }), label ? _jsx("span", { className: e("label") + " gd-label", children: label }) : null] }));
}
//# sourceMappingURL=UiCheckbox.js.map