import { useState } from 'react'
import type { DocSummary, Tag, TagColor } from '../../api/client'
import { TagChip } from './TagChip'
import { TagPicker } from './TagPicker'
interface Props {
doc: DocSummary
active: boolean
roster: Tag[]
onSelect: () => void
onDelete: () => void
onDuplicate: () => void
onToggleTag: (docId: string, tag: Tag) => void
onCreateTag: (docId: string, name: string, color: TagColor) => void
}
// One row in the sidebar: title + word count, its tag chips, a tag affordance and
// a delete affordance on hover, and a rose wash when it's the open document.
export function DocListItem({
doc,
active,
roster,
onSelect,
onDelete,
onDuplicate,
onToggleTag,
onCreateTag,
}: Props) {
const [picking, setPicking] = useState(false)
const assignedIds = new Set(doc.tags.map((t) => t.id))
return (