import * as React from 'react' import { Input } from './input' import { FieldLabel, FieldHint, FieldError } from './field' import { cn } from '@/lib/utils' /** * TextInput — composite field: label + input + hint/error. * * Замена @nstart/ui TextInput (тот же API): label, hint, error, required. * Внутри использует наш shadcn Input primitive. */ export type TextInputProps = Omit, 'size'> & { label?: React.ReactNode hint?: React.ReactNode error?: React.ReactNode required?: boolean /** Wrapper className (label + input + hint stack). */ rootClassName?: string } export const TextInput = React.forwardRef( function TextInput( { label, hint, error, required, rootClassName, className, id, ...props }, ref, ) { const autoId = React.useId() const inputId = id ?? autoId const hintId = hint ? `${inputId}-hint` : undefined const errorId = error ? `${inputId}-error` : undefined return (
{label && ( {label} )} {hint && !error && {hint}} {error && {error}}
) }, )