import * as React from 'react' import { cn } from '@/lib/utils' /** * Text input — single-line. Использует наши tokens, focus-ring через accent. * * Поддерживает 2 режима: * - "bare" (default) — просто , для inline использования в кастомных * layout'ах (см. SearchInput, FormGrid с FieldLabel separately). * - "field" — когда передан label / hint / error, рендерится FormField * обёртка с label сверху + hint/error снизу. Match'ит @nstart/ui TextInput API. */ export type InputProps = React.InputHTMLAttributes & { /** Если задан — рендерится field-обёртка с label выше. */ label?: React.ReactNode /** Optional helper text under input. */ hint?: React.ReactNode /** Error message — overrides hint визуально, accent в pink. */ error?: React.ReactNode /** Wrapper className когда rendering field-mode. */ containerClassName?: string } export const Input = React.forwardRef( function Input( { className, type = 'text', label, hint, error, required, containerClassName, id, ...props }, ref, ) { const autoId = React.useId() const inputId = id ?? autoId const inputEl = ( ) if (!label && !hint && !error) return inputEl return (
{label && ( )} {inputEl} {error ? ( {error} ) : hint ? ( {hint} ) : null}
) }, )