@gravity-ui/uikit
Version:
Gravity UI base styling and components
30 lines (29 loc) • 1.64 kB
JavaScript
'use client';
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SegmentedRadioGroup = 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 cn_1 = require("../utils/cn.js");
const SegmentedRadioGroupOption_1 = require("./SegmentedRadioGroupOption.js");
require("./SegmentedRadioGroup.css");
const b = (0, cn_1.block)('segmented-radio-group');
exports.SegmentedRadioGroup = React.forwardRef(function SegmentedRadioGroup(props, ref) {
const { size = 'm', width, style, className, qa, children } = props;
let options = props.options;
if (!options) {
options = React.Children.toArray(children).map(({ props: optionProps }) => ({
value: optionProps.value,
content: optionProps.content || optionProps.children,
disabled: optionProps.disabled,
title: optionProps.title,
}));
}
const { containerProps, optionsProps } = (0, private_1.useRadioGroup)({ ...props, options });
return ((0, jsx_runtime_1.jsx)("div", { ...containerProps, ref: ref, style: style, className: b({ size, width }, className), "data-qa": qa, children: optionsProps.map((optionProps) => ((0, react_1.createElement)(SegmentedRadioGroupOption_1.SegmentedRadioGroupOption, { ...optionProps, key: optionProps.value }))) }));
});
exports.SegmentedRadioGroup.Option = SegmentedRadioGroupOption_1.SegmentedRadioGroupOption;
//# sourceMappingURL=SegmentedRadioGroup.js.map