import { type FC, type RefObject, useCallback, useRef } from "react"; import { cn } from "../../utils/bem"; import { IconSend } from "@humansignal/icons"; import { TextArea } from "../../common/TextArea/TextArea"; import { observer } from "mobx-react"; import { Button } from "@humansignal/ui"; export type CommentFormProps = { value?: string; onChange?: (value: string) => void; onSubmit?: (value: string) => void; onBlur?: (e: FocusEvent) => void; inline?: boolean; rows?: number; maxRows?: number; classifications?: object | null; }; export const CommentFormBase: FC = observer( ({ value = "", inline = true, onChange, onSubmit, onBlur, rows = 1, maxRows = 4, classifications }) => { const formRef = useRef(null); const actionRef = useRef<{ update?: (text?: string) => void; el?: RefObject }>({}); const submitHandler = useCallback( async (e?: any) => { e?.preventDefault?.(); if (!formRef.current) return; const comment = (new FormData(formRef.current).get("comment") as string)?.trim(); if (!comment && !classifications) return; onSubmit?.(comment); }, [onSubmit], ); const onInput = useCallback( (comment: string) => { onChange?.(comment || ""); }, [onChange], ); return (