import { useState, useEffect, useRef } from 'react'; import { X } from 'lucide-react'; import '../styles/PromptDialog.css'; interface PromptDialogProps { title: string; message: string; defaultValue?: string; placeholder?: string; confirmText: string; cancelText: string; onConfirm: (value: string) => void; onCancel: () => void; } export function PromptDialog({ title, message, defaultValue = '', placeholder, confirmText, cancelText, onConfirm, onCancel }: PromptDialogProps) { const [value, setValue] = useState(defaultValue); const inputRef = useRef(null); useEffect(() => { if (inputRef.current) { inputRef.current.focus(); inputRef.current.select(); } }, []); const handleConfirm = () => { if (value.trim()) { onConfirm(value.trim()); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); handleConfirm(); } else if (e.key === 'Escape') { e.preventDefault(); onCancel(); } }; return (
e.stopPropagation()}>

{title}

{message}

setValue(e.target.value)} onKeyDown={handleKeyDown} placeholder={placeholder} />
); }