@gravity-ui/uikit
Version:
Gravity UI base styling and components
30 lines (29 loc) • 1.51 kB
JavaScript
'use client';
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RadioGroup = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const React = tslib_1.__importStar(require("react"));
const private_1 = require("../../hooks/private/index.js");
const Radio_1 = require("../Radio/index.js");
const cn_1 = require("../utils/cn.js");
require("./RadioGroup.css");
const b = (0, cn_1.block)('radio-group');
exports.RadioGroup = React.forwardRef(function RadioGroup(props, ref) {
const { size = 'm', direction = 'horizontal', style, className, optionClassName, qa, children, } = props;
let options = props.options;
if (!options) {
options = React.Children.toArray(children).map(({ props }) => ({
value: props.value,
content: props.content || props.children,
disabled: props.disabled,
qa: props.qa,
}));
}
const { containerProps, optionsProps } = (0, private_1.useRadioGroup)({ ...props, options });
return ((0, jsx_runtime_1.jsx)("div", { ...containerProps, ref: ref, style: style, className: b({ size, direction }, className), "data-qa": qa, children: optionsProps.map((optionProps) => ((0, react_1.createElement)(Radio_1.Radio, { ...optionProps, key: optionProps.value, className: b('option', optionClassName), size: size }))) }));
});
exports.RadioGroup.Option = Radio_1.Radio;
//# sourceMappingURL=RadioGroup.js.map