'use client'; import { useState, useRef, useEffect } from 'react'; import { Button } from '@kandev/ui/button'; import { Textarea } from '@kandev/ui/textarea'; import { IconSend, IconX } from '@tabler/icons-react'; interface CommentFormProps { /** Initial content for editing */ initialContent?: string; /** Callback when comment is submitted */ onSubmit: (content: string) => void; /** Callback when form is cancelled */ onCancel: () => void; /** Whether the form is in editing mode */ isEditing?: boolean; /** Auto focus the textarea */ autoFocus?: boolean; } export function CommentForm({ initialContent = '', onSubmit, onCancel, isEditing = false, autoFocus = true, }: CommentFormProps) { const [content, setContent] = useState(initialContent); const textareaRef = useRef(null); useEffect(() => { if (autoFocus && textareaRef.current) { textareaRef.current.focus(); } }, [autoFocus]); const handleSubmit = () => { const trimmed = content.trim(); if (trimmed) { onSubmit(trimmed); setContent(''); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); handleSubmit(); } else if (e.key === 'Escape') { e.preventDefault(); onCancel(); } }; return (