import { CellContext } from '@tanstack/react-table'; import { Check, File as FileIcon, Folder, X } from 'lucide-react'; import { Form, Formik } from 'formik'; import { Icon } from '@@/Icon'; import { Button } from '@@/buttons'; import { Input } from '@@/form-components/Input'; import { FileData, isFilesTableMeta } from '../types'; export function NameCell({ getValue, row: { original: item }, table, }: CellContext) { const name = getValue(); const { meta } = table.options; if (!isFilesTableMeta(meta)) { throw new Error('Invalid table meta'); } const isEdit = meta.isEdit(name); if (item.custom) { return item.custom; } if (isEdit) { return ( meta.setIsEdit(name, false)} /> ); } return ( <> {item.Dir ? ( ) : ( {name} )} ); function handleRename(name: string) { if (!isFilesTableMeta(meta)) { throw new Error('Invalid table meta'); } meta.onRename(item.Name, name); meta.setIsEdit(name, false); } } function EditForm({ originalName, onSave, onClose, }: { originalName: string; onSave: (name: string) => void; onClose: () => void; }) { return ( onSave(name)} onReset={onClose} > {({ values, setFieldValue }) => (
setFieldValue('name', e.target.value)} className="input-sm w-auto" />