"use client" import * as React from "react" import * as RadioGroupPrimitive from "@radix-ui/react-radio-group" import { cn } from "../../utils/cn" const RadioGroup = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { return ( ) }) RadioGroup.displayName = RadioGroupPrimitive.Root.displayName const RadioGroupItem = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { return ( ) }) RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName interface RadioGroupBlockOption { value: string label: React.ReactNode description?: React.ReactNode disabled?: boolean /** Optional trailing slot rendered at the end of the row (e.g. a discount tag) */ trailing?: React.ReactNode } interface RadioGroupBlockProps extends Omit, "children"> { options: RadioGroupBlockOption[] /** * - `separated` (default): each option is its own bordered card stacked with gaps. * - `grouped`: options share a single outer border with dividers between rows. */ variant?: "separated" | "grouped" /** Error message displayed below the group (also triggers red borders) */ error?: string itemClassName?: string } const RadioGroupBlock = React.forwardRef< React.ComponentRef, RadioGroupBlockProps >( ( { className, options, variant = "separated", error, itemClassName, disabled, ...props }, ref ) => { const isGrouped = variant === "grouped" return (
{options.map((option, index) => { const itemId = `${props.name ?? "radio-block"}-${option.value}` const isDisabled = disabled || option.disabled const isLast = index === options.length - 1 return ( ) })} {error && (

{error}

)}
) } ) RadioGroupBlock.displayName = "RadioGroupBlock" export { RadioGroup, RadioGroupItem, RadioGroupBlock } export type { RadioGroupBlockProps, RadioGroupBlockOption }