import * as RadioGroupPrimitive from "@rn-primitives/radio-group";

import { cn } from "@turbostarter/ui";

function RadioGroup({
  className,
  ...props
}: RadioGroupPrimitive.RootProps &
  React.RefAttributes<RadioGroupPrimitive.RootRef>) {
  return (
    <RadioGroupPrimitive.Root className={cn("gap-3", className)} {...props} />
  );
}

function RadioGroupItem({
  className,
  ...props
}: RadioGroupPrimitive.ItemProps &
  React.RefAttributes<RadioGroupPrimitive.ItemRef>) {
  return (
    <RadioGroupPrimitive.Item
      className={cn(
        "border-input dark:bg-input/30 aspect-square size-4 shrink-0 items-center justify-center rounded-full border shadow-sm shadow-black/5",
        props.disabled && "opacity-50",
        className,
      )}
      {...props}
    >
      <RadioGroupPrimitive.Indicator className="bg-primary size-2 rounded-full" />
    </RadioGroupPrimitive.Item>
  );
}

export { RadioGroup, RadioGroupItem };
