import React from "react"; /** Multi-line text input — auto-grow, invalid state, optional character counter. * R01: 오류 상태 포커스 링 유지. R04: 소비자 핸들러 합성. */ export function Textarea({ rows = 4, invalid = false, disabled = false, autoGrow = false, maxLength, showCount = false, value, defaultValue, onChange, style, onFocus, onBlur, onMouseEnter, onMouseLeave, "aria-describedby": describedBy, ...rest }) { const [focus, setFocus] = React.useState(false); const [hover, setHover] = React.useState(false); const [internal, setInternal] = React.useState(defaultValue ?? ""); const ref = React.useRef(null); const text = value !== undefined ? value : internal; const countId = React.useId(); React.useEffect(() => { if (!autoGrow || !ref.current) return; ref.current.style.height = "auto"; ref.current.style.height = ref.current.scrollHeight + "px"; }, [text, autoGrow]); const handle = (e) => { if (value === undefined) setInternal(e.target.value); if (onChange) onChange(e); }; const borderColor = invalid ? "hsl(var(--destructive))" : focus ? "hsl(var(--input-active))" : hover ? "hsl(var(--input-hover))" : "hsl(var(--input))"; const ring = focus ? (invalid ? "0 0 0 var(--input-focus-ring-width, var(--focus-ring-width, 3px)) hsl(var(--destructive) / 0.3)" : "0 0 0 var(--input-focus-ring-width, var(--focus-ring-width, 3px)) hsl(var(--ring))") : "none"; return (