UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

26 lines (25 loc) 1.35 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { createElement as _createElement } from "react"; import * as React from 'react'; import { useRadioGroup } from "../../hooks/private/index.js"; import { block } from "../utils/cn.js"; import { SegmentedRadioGroupOption as Option } from "./SegmentedRadioGroupOption.js"; import "./SegmentedRadioGroup.css"; const b = block('segmented-radio-group'); export const 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 } = useRadioGroup({ ...props, options }); return (_jsx("div", { ...containerProps, ref: ref, style: style, className: b({ size, width }, className), "data-qa": qa, children: optionsProps.map((optionProps) => (_createElement(Option, { ...optionProps, key: optionProps.value }))) })); }); SegmentedRadioGroup.Option = Option; //# sourceMappingURL=SegmentedRadioGroup.js.map