import React, { useState, useRef, useCallback, useEffect } from 'react'; import { ExcelRow } from '../types'; import { useColumns } from '../contexts/ColumnsContext'; import { X, Sparkles, Save, Loader2, Languages, Package, CheckCircle2, Mic, MicOff } from 'lucide-react'; import { generateGemini } from '../services/gemini'; import { cn } from '../lib/utils'; import { useSpeechRecognition } from '../lib/useSpeechRecognition'; import { ConfirmModal } from './ConfirmModal'; interface EditPanelProps { row: ExcelRow; rowIndex: number; onSave: (rowIndex: number, updatedRow: ExcelRow) => void; onClose: () => void; onCaptureState: (message: string) => void; } interface DimensionInputProps { label: string; field: string; value: string; isModified: boolean; onChange: (val: string) => void; placeholder?: string; } const DimensionInput = ({ label, value, isModified, onChange, placeholder }: DimensionInputProps) => (
onChange(e.target.value)} placeholder={placeholder} className={cn( "w-full bg-slate-900 border rounded p-2 text-sm text-white focus:outline-none focus:ring-1 transition-colors", isModified ? "border-blue-500 focus:ring-blue-500" : "border-slate-700 focus:border-slate-500" )} />
); const AutoResizeTextarea = ({ id, value, onChange, onKeyDown, className, placeholder }: { id?: string; value: string; onChange: (e: React.ChangeEvent) => void; onKeyDown?: (e: React.KeyboardEvent) => void; className?: string; placeholder?: string; }) => { const textareaRef = useRef(null); const adjustHeight = useCallback(() => { const textarea = textareaRef.current; if (textarea) { textarea.style.height = 'auto'; textarea.style.height = `${textarea.scrollHeight}px`; } }, []); useEffect(() => { adjustHeight(); }, [value, adjustHeight]); return (