UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

19 lines (18 loc) 1.17 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { createElement as _createElement } from "react"; import * as React from 'react'; import { RadioGroupContext, 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; const options = props.options; const { containerProps, optionsProps, contextProps } = useRadioGroup({ ...props, options }); return (_jsx(RadioGroupContext.Provider, { value: contextProps, children: _jsx("div", { ...containerProps, ref: ref, style: style, className: b({ size, width }, className), "data-qa": qa, children: children || optionsProps?.map((optionProps) => (_createElement(Option, { ...optionProps, key: optionProps.value }))) }) })); }); SegmentedRadioGroup.Option = Option; //# sourceMappingURL=SegmentedRadioGroup.js.map