import React, { type ChangeEventHandler, type ReactNode } from 'react'; import { classNames } from '../../utils'; import { RadioInput } from '../RadioInput'; import { useRadioCheckState } from '../RadioGroup/useRadioCheckState'; import styles from './RadioField.module.css'; export type RadioFieldProps = Readonly<{ /** * className for the element */ className?: string; /** * The name of the RadioField. * Optional within a RadioGroup */ name?: string; /** * Whether the RadioField should be disabled. * @default false */ isDisabled?: boolean; /** * The id of the RadioField */ id?: string; /** * Whether the RadioField should be checked. * Ignored within a RadioGroup. * @default false */ isChecked?: boolean; /** * The current value */ value: string; /** * The content to display as the label. */ label: string | ReactNode; /** * Handler that is called when the value changes. * Ignored within a RadioGroup */ onChange?: ChangeEventHandler; }>; export const RadioField = ({ className, name, isDisabled, id, isChecked = false, value, label, onChange, ...rest }: RadioFieldProps) => { const isRadioChecked = useRadioCheckState(value, isChecked); return ( ); };