'use client' import { FieldWrapper, InputLabel } from './shared' export type RadioOption = { label: string value: string | number } type RadioItemProps = Omit, 'name'> & { name: string label?: string error?: string info?: string description?: string className?: string textSize?: 'sm' | 'md' } export type RadioProps = Omit, 'name' | 'onChange' | 'value'> & { name: string label?: string error?: string info?: string description?: string className?: string options: RadioOption[] value?: string | number | null onChange?: (value: string | number) => void textSize?: 'sm' | 'md' } export default function Radio(props: RadioProps) { const { options, onChange, value, label, description, error, info, name, className, textSize = 'sm', ...rest } = props return (
{options.map((option) => ( { if (onChange) onChange(option.value) }} className='mb-0' /> ))}
) } function RadioItem(props: RadioItemProps) { const { name, label, error, ...inputProps } = props const { value } = inputProps const id = `${name}-${value}` return (
{label && ( )}
) }