import './index.css' import { memo, forwardRef, useContext } from 'react' import * as React from 'react' import warning from 'warning' import { useClassNames } from '../../_lib/useClassNames' import { RadioGroupContext } from './RadioGroupContext' import RadioInput from './RadioInput' export type RadioProps = React.PropsWithChildren<{ value: string disabled?: boolean className?: string }> const Radio = forwardRef(function RadioInner( { value, disabled = false, children, ...props }, ref, ) { const { name, selected, disabled: isParentDisabled, readonly, invalid, onChange, } = useContext(RadioGroupContext) const classNames = useClassNames('charcoal-radio__label', props.className) warning( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition name !== undefined, `"name" is not Provided for . Perhaps you forgot to wrap with ?`, ) const isSelected = value === selected const isDisabled = disabled || isParentDisabled const isReadonly = readonly && !isSelected return ( ) }) export default memo(Radio)