@trellixio/roaster-coffee
Version:
Beans' product component library
32 lines (29 loc) • 1.23 kB
JavaScript
import * as React from 'react';
import { classNames } from '../../utils/classNames/index.js';
import { useUid } from '../../utils/useUid/index.js';
import '@floating-ui/react';
import { RadioGroup } from './RadioGroup/RadioGroup.js';
import { useRadioGroupContext } from './RadioGroup/RadioGroup.context.js';
const Radio = React.forwardRef((props, ref) => {
const { id, label, name, disabled, value, labelClassName, inputClassName, isRichSelector } = props;
const ctx = useRadioGroupContext();
const uid = useUid(id);
const checked = ctx.value === value;
return /* @__PURE__ */ React.createElement("label", { htmlFor: uid, className: classNames(labelClassName, { selector: isRichSelector, selected: checked }) }, /* @__PURE__ */ React.createElement(
"input",
{
value,
ref,
type: "radio",
name: name ?? ctx.name,
id: uid,
checked,
disabled,
onChange: ctx.onChange
}
), /* @__PURE__ */ React.createElement("span", { className: classNames("input-radio", inputClassName) }), /* @__PURE__ */ React.createElement("div", { className: "content" }, label));
});
Radio.displayName = "Radio";
Radio.Group = RadioGroup;
export { Radio };
//# sourceMappingURL=Radio.js.map