UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

19 lines (18 loc) 1.53 kB
import { __assign, __rest } from "tslib"; import clsx from 'clsx'; import React from 'react'; import { getBaseProps } from '../internal/base-component'; import RadioButton from './radio-button'; import styles from './styles.css.js'; import { useFormFieldContext } from '../internal/context/form-field-context'; import { useUniqueId } from '../internal/hooks/use-unique-id'; import { useTelemetry } from '../internal/hooks/use-telemetry'; export default function RadioGroup(_a) { var name = _a.name, value = _a.value, items = _a.items, ariaLabel = _a.ariaLabel, ariaRequired = _a.ariaRequired, onChange = _a.onChange, rest = __rest(_a, ["name", "value", "items", "ariaLabel", "ariaRequired", "onChange"]); useTelemetry('RadioGroup'); var _b = useFormFieldContext(rest), ariaDescribedby = _b.ariaDescribedby, ariaLabelledby = _b.ariaLabelledby; var baseProps = getBaseProps(rest); var generatedName = useUniqueId('awsui-radio-'); return (React.createElement("div", __assign({ role: "radiogroup", "aria-labelledby": ariaLabelledby, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, "aria-required": ariaRequired }, baseProps, { className: clsx(baseProps.className, styles.root) }), items && items.map(function (item) { return (React.createElement(RadioButton, { key: item.value, checked: item.value === value, name: name || generatedName, value: item.value, label: item.label, description: item.description, disabled: item.disabled, onChange: onChange, controlId: item.controlId })); }))); }