'use client' import * as RadioGroupPrimitive from '@radix-ui/react-radio-group' import * as React from 'react' import { cn } from '../../utils/cn' import { ErrorMessage } from '../ErrorMessage' import { typographyVariants } from '../Typography' import { RadioGroupIndicator } from './RadioGroupIndicator' type RadioGroupProps = React.ComponentPropsWithoutRef< typeof RadioGroupPrimitive.Root > & { error?: string ref?: React.Ref> } const RadioGroup = ({ className, error, children, ref, ...props }: RadioGroupProps) => (
{children} {error && {error}}
) RadioGroup.displayName = RadioGroupPrimitive.Root.displayName type RadioGroupItemProps = React.ComponentPropsWithoutRef< typeof RadioGroupPrimitive.Item > & { error?: boolean | string ref?: React.Ref> } const RadioGroupItem = ({ className, error = false, children, id, ref, ...props }: RadioGroupItemProps) => { // Generate a unique ID if not provided const generatedId = React.useId() const radioId = id || generatedId return (
{children && ( )}
{typeof error === 'string' && {error}}
) } RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName export { RadioGroup, RadioGroupItem }