| 1 | import * as React from "react"; |
| 2 | import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; |
| 3 | import { Circle } from "lucide-react"; |
| 4 | |
| 5 | import { cn } from "@/lib/utils"; |
| 6 | |
| 7 | const RadioGroup = React.forwardRef< |
| 8 | React.ElementRef<typeof RadioGroupPrimitive.Root>, |
| 9 | React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> |
| 10 | >(({ className, ...props }, ref) => { |
| 11 | return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />; |
| 12 | }); |
| 13 | RadioGroup.displayName = RadioGroupPrimitive.Root.displayName; |
| 14 | |
| 15 | const RadioGroupItem = React.forwardRef< |
| 16 | React.ElementRef<typeof RadioGroupPrimitive.Item>, |
| 17 | React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> |
| 18 | >(({ className, ...props }, ref) => { |
| 19 | return ( |
| 20 | <RadioGroupPrimitive.Item |
| 21 | ref={ref} |
| 22 | className={cn( |
| 23 | "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", |
| 24 | className, |
| 25 | )} |
| 26 | {...props} |
| 27 | > |
| 28 | <RadioGroupPrimitive.Indicator className="flex items-center justify-center"> |
| 29 | <Circle className="h-2.5 w-2.5 fill-current text-current" /> |
| 30 | </RadioGroupPrimitive.Indicator> |
| 31 | </RadioGroupPrimitive.Item> |
| 32 | ); |
| 33 | }); |
| 34 | RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName; |
| 35 | |
| 36 | export { RadioGroup, RadioGroupItem }; |