import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useRef } from 'react';
import { RadioCheckedIcon } from '../../../lib/icons/RadioChecked.js';
import { RadioUncheckedIcon } from '../../../lib/icons/RadioUnchecked.js';
import { useRadioField } from '../../../lib/ui/RadioField/RadioField.js';
export function Radio({ value, label, }) {
    const { value: fieldValue, onChange, name } = useRadioField();
    const checked = fieldValue === value;
    const inputRef = useRef();
    const checkRadio = () => {
        if (inputRef.current != null) {
            inputRef.current.click();
        }
    };
    return (_jsxs("label", { className: 'seam-radio', onClick: checkRadio, children: [_jsx("span", { className: 'seam-radio-icon', children: checked ? _jsx(RadioCheckedIcon, {}) : _jsx(RadioUncheckedIcon, {}) }), _jsx("input", { type: 'radio', name: name, value: value, checked: checked, onChange: (event) => {
                    onChange(event.target.value);
                } }), _jsx("span", { className: 'seam-radio-label', children: label })] }));
}
//# sourceMappingURL=Radio.js.map