@trellixio/roaster-coffee
Version:
Beans' product component library
47 lines (41 loc) • 1.6 kB
JavaScript
;
var React = require('react');
var index$1 = require('../../utils/classNames/index.js');
var index = require('../../utils/useUid/index.js');
require('@floating-ui/react');
var RadioGroup = require('./RadioGroup/RadioGroup.js');
var RadioGroup_context = require('./RadioGroup/RadioGroup.context.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
for (var k in e) {
n[k] = e[k];
}
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const Radio = React__namespace.forwardRef((props, ref) => {
const { id, label, name, disabled, value, labelClassName, inputClassName, isRichSelector } = props;
const ctx = RadioGroup_context.useRadioGroupContext();
const uid = index.useUid(id);
const checked = ctx.value === value;
return /* @__PURE__ */ React__namespace.createElement("label", { htmlFor: uid, className: index$1.classNames(labelClassName, { selector: isRichSelector, selected: checked }) }, /* @__PURE__ */ React__namespace.createElement(
"input",
{
value,
ref,
type: "radio",
name: name ?? ctx.name,
id: uid,
checked,
disabled,
onChange: ctx.onChange
}
), /* @__PURE__ */ React__namespace.createElement("span", { className: index$1.classNames("input-radio", inputClassName) }), /* @__PURE__ */ React__namespace.createElement("div", { className: "content" }, label));
});
Radio.displayName = "Radio";
Radio.Group = RadioGroup.RadioGroup;
exports.Radio = Radio;
//# sourceMappingURL=Radio.js.map