import React, { useState, useEffect, useRef } from 'react'; import { X, Check } from 'lucide-react'; interface InputDrawerProps { isOpen: boolean; onClose: () => void; title: string; onSubmit: (value: string) => void; placeholder?: string; defaultValue?: string; submitLabel?: string; } export const InputDrawer: React.FC = ({ isOpen, onClose, title, onSubmit, placeholder = '', defaultValue = '', submitLabel = '确定' }) => { const [value, setValue] = useState(defaultValue); const inputRef = useRef(null); useEffect(() => { if (isOpen) { setValue(defaultValue); setTimeout(() => { inputRef.current?.focus(); }, 50); } }, [isOpen, defaultValue]); const handleSubmit = (e?: React.FormEvent) => { e?.preventDefault(); if (value.trim()) { onSubmit(value.trim()); onClose(); } }; if (!isOpen) return null; return (
{/* pointer-events-none on wrapper, auto on content to allow closing by clicking left side */}

{title}

setValue(e.target.value)} placeholder={placeholder} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all" />
); };