import React, { useEffect, useRef } from 'react'; import { Check, X } from 'lucide-react'; import type { KeyboardEvent } from 'react'; interface RenameFormProps { titleInput: string; setTitleInput: (value: string) => void; onSubmit: (title: string) => void; onCancel: () => void; localize: (key: any, options?: any) => string; } const RenameForm: React.FC = ({ titleInput, setTitleInput, onSubmit, onCancel, localize, }) => { const inputRef = useRef(null); useEffect(() => { if (inputRef.current) { inputRef.current.focus(); inputRef.current.select(); } }, []); const handleKeyDown = (e: KeyboardEvent) => { switch (e.key) { case 'Escape': onCancel(); break; case 'Enter': onSubmit(titleInput); break; } }; return (
setTitleInput(e.target.value)} onKeyDown={handleKeyDown} onBlur={() => onSubmit(titleInput)} maxLength={100} aria-label={localize('com_ui_new_conversation_title')} />
); }; export default RenameForm;