import { type InputHTMLAttributes, type ReactNode } from "react"; import "@shared/components/Radio.css"; export interface RadioOption { value: V; label: ReactNode; description?: ReactNode; disabled?: boolean; } export interface RadioGroupProps { name: string; value: V; onChange: (value: V) => void; options: RadioOption[]; /** Layout. `vertical` stacks options; `horizontal` lays them inline. */ direction?: "vertical" | "horizontal"; className?: string; } /** Standalone single radio — usually consumed via {@link RadioGroup}. */ export function Radio({ label, description, className, ...rest }: Omit, "type"> & { label?: ReactNode; description?: ReactNode; }) { return ( {(label || description) && ( {label && {label}} {description && ( {description} )} )} ); } export function RadioGroup({ name, value, onChange, options, direction = "vertical", className, }: RadioGroupProps) { return ( {options.map((opt) => ( onChange(opt.value)} disabled={opt.disabled} label={opt.label} description={opt.description} /> ))} ); }