"use client"; import { useState } from "react"; import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; import { DownloadIcon, ExternalLinkIcon, PaperclipIcon, XIcon, } from "lucide-react"; import type { ResolvedAttachment } from "@/lib/npc-dialogue/dialogue"; /** * Attachment chips for a conversation line. Each chip opens the file in a * dossier-styled modal (images render directly, everything else through an * iframe, which gives PDFs and plain text their native browser viewer) with * download and new-tab escape hatches. Mirrors how DialogueLink presents * linked pages, so attachments and links feel like one system. */ export function DialogueAttachments({ attachments, }: { attachments: ResolvedAttachment[] | undefined; }) { const [active, setActive] = useState(null); if (!attachments || attachments.length === 0) return null; const isImage = (a: ResolvedAttachment) => a.mimeType.startsWith("image/"); return ( <>
{attachments.map((attachment) => ( ))}
!next && setActive(null)}>
Attachment // {active?.label}
{active && ( <> New tab Download )}
{active && isImage(active) ? (
{/* eslint-disable-next-line @next/next/no-img-element */} {active.label}
) : ( active && (