|
| 1 | +import * as React from "react"; |
| 2 | +import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; |
| 3 | +import { cn } from "../../utilities"; |
| 4 | + |
| 5 | +const RadioGroup = React.forwardRef< |
| 6 | + React.ElementRef<typeof RadioGroupPrimitive.Root>, |
| 7 | + React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> |
| 8 | +>(({ className, ...props }, ref) => { |
| 9 | + return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />; |
| 10 | +}); |
| 11 | +RadioGroup.displayName = RadioGroupPrimitive.Root.displayName; |
| 12 | + |
| 13 | +const RadioGroupItem = React.forwardRef< |
| 14 | + React.ElementRef<typeof RadioGroupPrimitive.Item>, |
| 15 | + React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> |
| 16 | +>(({ className, ...props }, ref) => { |
| 17 | + return ( |
| 18 | + <RadioGroupPrimitive.Item |
| 19 | + ref={ref} |
| 20 | + className={cn( |
| 21 | + "aspect-square h-3 w-3 bg-theme-surface-primary rounded-rounded border border-theme-border-bold 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:data-[state=unchecked]:opacity-30 disabled:data-[state=checked]:bg-neutral-300", |
| 22 | + className |
| 23 | + )} |
| 24 | + {...props} |
| 25 | + > |
| 26 | + <RadioGroupPrimitive.Indicator className="flex text-theme-surface-strong items-center justify-center data-[state=checked]:data-[disabled]:text-theme-surface-primary"> |
| 27 | + <svg |
| 28 | + className="h-[10px] w-[10px] fill-current text-current" |
| 29 | + viewBox="0 0 100 100" |
| 30 | + xmlns="http://www.w3.org/2000/svg" |
| 31 | + > |
| 32 | + <circle cx="50" cy="50" r="50" /> |
| 33 | + </svg> |
| 34 | + </RadioGroupPrimitive.Indicator> |
| 35 | + </RadioGroupPrimitive.Item> |
| 36 | + ); |
| 37 | +}); |
| 38 | +RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName; |
| 39 | + |
| 40 | +export { RadioGroup, RadioGroupItem }; |
0 commit comments