import * as React from 'react'; const RadioGroupContext = React.createContext<{ value: string | undefined; onValueChange: (v: string) => void; disabled?: boolean; } | null>(null); interface RadioGroupProps extends React.HTMLAttributes { value?: string; onValueChange?: (value: string) => void; disabled?: boolean; } const RadioGroup = React.forwardRef( ({ className, value, onValueChange, disabled, ...props }, ref) => { const ctx = React.useMemo(() => ({ value, onValueChange: onValueChange ?? (() => {}), disabled }), [value, onValueChange, disabled]); return (
); }, ); RadioGroup.displayName = 'RadioGroup'; interface RadioGroupItemProps extends React.InputHTMLAttributes { value: string; } const RadioGroupItem = React.forwardRef( ({ className, value, ...props }, ref) => { const ctx = React.useContext(RadioGroupContext); if (!ctx) return ; const checked = ctx.value === value; return ( ctx.onValueChange(value)} className={className} {...props} /> ); }, ); RadioGroupItem.displayName = 'RadioGroupItem'; export { RadioGroup, RadioGroupItem };