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