import { HTMLProps, useState } from 'react'; import { SubstraitVizTheme } from '@substrait-viz/react'; import { CancelButton } from './CancelButton.tsx'; import { Tooltip } from 'react-tooltip'; export interface FileCardProps extends HTMLProps { name: string; help: string; theme: SubstraitVizTheme; setHelp: (value: string) => void; onDelete: () => void; } export function FileCard({ name, help, setHelp, theme, className = '', onDelete, ...props }: FileCardProps) { const [isEditing, setIsEditing] = useState(false); const [tempHelp, setTempHelp] = useState(help); const handleSave = () => { setHelp(tempHelp); setIsEditing(false); }; const handleEditClick = () => { setTempHelp(help); setIsEditing(true); }; return ( onDelete()} /> {name} {isEditing ? ( setTempHelp(e.target.value)} onBlur={handleSave} placeholder="Add help text for this descriptor..." className={`flex-1 w-full text-xs p-2 rounded border resize-none text-left ${ theme.background === '#ffffff' ? 'bg-white border-gray-300 text-gray-800' : 'bg-gray-700 border-gray-600 text-gray-200' }`} style={{ minHeight: '60px' }} autoFocus /> ) : ( {help || ( Click to add help text )} )} {/* Tooltips */} ); }