import { useRef } from 'react'; import { type AriaTextFieldProps, useId, useTextField } from 'react-aria'; import cn from '~/utils/cn'; export interface InputProps extends AriaTextFieldProps { isRequired?: boolean; className?: string; } export default function Input(props: InputProps) { const { label, className } = props; const ref = useRef(null); const id = useId(props.id); const { labelProps, inputProps, descriptionProps, errorMessageProps, isInvalid, validationErrors, } = useTextField(props, ref); return (
{props.description && (
{props.description}
)} {isInvalid && (
{validationErrors.join(' ')}
)}
); }