import { useRef, useState } from 'react' import type { StoredSequence } from '../storage/seqStore.ts' function fmtBytes(n: number): string { if (n < 1024) return `${n} B` if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB` return `${(n / (1024 * 1024)).toFixed(1)} MB` } export function SequencePanel({ sequences, selectedId, onSelect, onUpload, onRename, onDelete, }: { sequences: StoredSequence[] selectedId: string | null onSelect: (id: string) => void onUpload: (files: FileList) => void onRename: (id: string, name: string) => void onDelete: (id: string) => void }) { const fileRef = useRef(null) const [dragging, setDragging] = useState(false) const [editingId, setEditingId] = useState(null) const [draft, setDraft] = useState('') const startEdit = (seq: StoredSequence) => { setEditingId(seq.id) setDraft(seq.name) } const commitEdit = () => { if (editingId && draft.trim()) onRename(editingId, draft.trim()) setEditingId(null) } return (

Sequences

{ if (e.target.files?.length) onUpload(e.target.files) e.target.value = '' }} />
{ e.preventDefault() setDragging(true) }} onDragLeave={() => setDragging(false)} onDrop={(e) => { e.preventDefault() setDragging(false) if (e.dataTransfer.files?.length) onUpload(e.dataTransfer.files) }} > Drop .seq files here
{sequences.length === 0 ? (

No sequences yet. Upload a .seq file — for example one exported from{' '} seqlab .

) : (
    {sequences.map((seq) => (
  • onSelect(seq.id)} >
    onSelect(seq.id)} onClick={(e) => e.stopPropagation()} /> {editingId === seq.id ? ( setDraft(e.target.value)} onBlur={commitEdit} onKeyDown={(e) => { if (e.key === 'Enter') commitEdit() if (e.key === 'Escape') setEditingId(null) }} onClick={(e) => e.stopPropagation()} /> ) : ( {seq.name} )}
    e.stopPropagation()}>
    {fmtBytes(seq.size)}
  • ))}
)}
) }