import type { ChangeEvent, ReactNode } from "react"; /** 后台文本框:与聊天搜索同款壳层,聚焦只画外框一圈 */ export default function AdminField({ id, label, hint, value, onChange, placeholder, maxLength, as = "input", type = "text", autoComplete, disabled, className = "", minHeight, embed, error, describedBy, }: { id: string; label: ReactNode; hint?: ReactNode; value: string; onChange: (v: string) => void; placeholder?: string; maxLength?: number; as?: "input" | "textarea"; type?: string; autoComplete?: string; disabled?: boolean; className?: string; minHeight?: string; /** 标签由外层设置行提供,本组件只保留计数与输入 */ embed?: boolean; error?: string; describedBy?: string; }) { const handle = (e: ChangeEvent) => onChange(e.target.value); const invalid = Boolean(error); const described = [describedBy, error ? `${id}-error` : null].filter(Boolean).join(" ") || undefined; const count = maxLength != null ? ( {value.length}/{maxLength} ) : null; return (
{embed ? null : (
{count}
)} {!embed && hint != null && hint !== "" && (

{hint}

)} {as === "textarea" ? (
{embed ? count : null}