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