import { createMemo, Show } from "solid-js" import type { JSX } from "solid-js" import { useSortable } from "@dnd-kit/solid/sortable" import { IconButton } from "@opencode-ai/ui/icon-button" import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2" import { TooltipV2 } from "@opencode-ai/ui/v2/tooltip-v2" import { Tabs } from "@opencode-ai/ui/tabs" import { useFile } from "@/context/file" import { useLanguage } from "@/context/language" import { useCommand } from "@/context/command" import { FileVisual } from "./session-sortable-tab" export function SortableTabV2(props: { tab: string index: () => number temporary?: boolean onTabClose: (tab: string) => void onTabDoubleClick?: (tab: string) => void }): JSX.Element { const file = useFile() const language = useLanguage() const command = useCommand() const closeTabKeybind = createMemo(() => command.keybindParts("tab.close")) const sortable = useSortable({ get id() { return props.tab }, get index() { return props.index() }, }) const path = createMemo(() => file.pathFromTab(props.tab)) const content = createMemo(() => { const value = path() if (!value) return return }) return (
{language.t("common.closeTab")} 0}> } placement="bottom" gutter={10} > props.onTabClose(props.tab)} aria-label={language.t("common.closeTab")} /> } hideCloseButton onMiddleClick={() => props.onTabClose(props.tab)} onDblClick={() => props.onTabDoubleClick?.(props.tab)} > {(value) => value()}
) }