import { useId } from "react"; import type { BaseProps, HTMLProps, IOption } from "../../shared/types"; import { cn } from "../../shared/utils/cn"; import { RadioOption } from "./RadioOption"; export type RadioGroupProps = Omit< HTMLProps<"input">, "value" | "onChange" > & { options: IOption[]; value: T; onChange: (option: IOption) => void; labelClassName?: string; } & BaseProps; export const RadioGroup = ({ value, options, onChange, className, labelClassName, disabled, id: propId, testId, ...props }: RadioGroupProps) => { const generatedId = useId(); const id = propId ?? generatedId; return (
{options.map((o) => ( onChange(o)} /> ))}
); };