"use client"; import { useState } from "react"; import { getFileIcon } from "./FileIcons"; import { useI18n } from "@/hooks/useI18n"; import type { FileViewerDisplayMode, FileViewerState } from "@/lib/file-viewer-state"; export interface Tab { id: string; label: string; filePath: string; sourceSessionId?: string | null; initialDisplayMode?: FileViewerDisplayMode; viewerState?: FileViewerState; viewerRevision?: number; } interface Props { tabs: Tab[]; activeTabId: string; onSelectTab: (id: string) => void; onCloseTab: (id: string) => void; } export function TabBar({ tabs, activeTabId, onSelectTab, onCloseTab }: Props) { const { t } = useI18n(); const [hoveredClose, setHoveredClose] = useState(null); return (
{tabs.map((tab) => { const isActive = tab.id === activeTabId; return (
onSelectTab(tab.id)} onMouseDown={(e) => { if (e.button === 1) e.preventDefault(); }} onAuxClick={(e) => { if (e.button !== 1) return; e.preventDefault(); e.stopPropagation(); onCloseTab(tab.id); }} style={{ display: "flex", alignItems: "center", gap: 6, height: 36, paddingLeft: 12, paddingRight: 6, borderRight: "1px solid var(--border)", background: isActive ? "var(--bg)" : "var(--bg-panel)", cursor: "pointer", fontSize: 12, color: isActive ? "var(--text)" : "var(--text-muted)", whiteSpace: "nowrap", maxWidth: 180, minWidth: 80, flexShrink: 0, userSelect: "none", transition: "background 0.1s, color 0.1s", }} > {getFileIcon(tab.label, 13)} {tab.label}
); })}
); }