"use client"; /** * 添付ファイル中身プレビューモーダル(Pane 4 モード 2 / AttachmentList から開く)。 * * - shadcn Dialog 公式構造(Title / Description / Header / ScrollArea)に揃える * - WAI-ARIA Modal Dialog Pattern: aria-labelledby(Title 自動接続)+ aria-describedby * (Description 自動接続)+ Esc 閉じ + focus 戻し(Base UI Dialog で標準提供) * - txt は本文を whitespace-pre-wrap で表示。font-mono は使わず、日本語長文の * 可読性を優先(ADR-0010 §13 D75 / レビュー反映) * - PDF はそもそも `AttachmentList` 側で `disabled` のためモーダルが開かない。 * この Dialog では PDF 分岐を持たない(YAGNI、PDF プレビューは雛形外) * * ADR 出典: ADR-0010 §13 / design.md D75 */ import { Download } from "lucide-react"; import { type Attachment } from "@/lib/schema"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { ScrollArea } from "@/components/ui/scroll-area"; export function AttachmentPreviewDialog({ item, onOpenChange, }: { item: Attachment | null; onOpenChange: (open: boolean) => void; }) { // モーダルは「txt の Attachment」専用。PDF は親側で disabled されているため // ここに到達しない前提だが、型安全のため item?.kind === "txt" でガードする。 return (
{item?.name ?? ""} {item && ( )}
Esc キーまたは右上 × で閉じます。
{item?.kind === "txt" ? (
{item.previewText}
) : null}
); }