'use client'; import React, {type ReactNode} from 'react'; import {composeRenderProps} from 'react-aria-components/composeRenderProps'; import { RadioField, RadioButton, RadioGroup as RACRadioGroup, type RadioGroupProps as RACRadioGroupProps, type RadioFieldProps, type ValidationResult } from 'react-aria-components/RadioGroup'; import {tv} from 'tailwind-variants'; import {Description, FieldError, Label} from './Field'; import {composeTailwindRenderProps, focusRing} from './utils'; export interface RadioGroupProps extends Omit { label?: string; children?: ReactNode; description?: string; errorMessage?: string | ((validation: ValidationResult) => string); } export function RadioGroup(props: RadioGroupProps) { return (
{props.children}
{props.description && {props.description}} {props.errorMessage}
); } const styles = tv({ extend: focusRing, base: 'w-4.5 h-4.5 flex-shrink-0 box-border rounded-full border bg-white dark:bg-neutral-900 transition-all', variants: { isSelected: { false: 'border-neutral-400 dark:border-neutral-400 group-pressed:border-neutral-500 dark:group-pressed:border-neutral-300', true: 'border-[calc(var(--spacing)*1.5)] border-neutral-700 dark:border-neutral-300 forced-colors:border-[Highlight]! group-pressed:border-neutral-800 dark:group-pressed:border-neutral-200' }, isInvalid: { true: 'border-red-700 dark:border-red-600 group-pressed:border-red-800 dark:group-pressed:border-red-700 forced-colors:border-[Mark]!' }, isDisabled: { true: 'border-neutral-200 dark:border-neutral-700 forced-colors:border-[GrayText]!' } } }); export interface RadioProps extends RadioFieldProps { description?: string; } export function Radio(props: RadioProps) { return ( {composeRenderProps(props.children, (children, renderProps) => ( <>
{children} ))} {props.description && {props.description}} ); }