import React, { useState } from "react"; import type { DesktopManifest, DesktopMenu, DesktopMenuItem, DesktopWorkbench } from "./command-registry.js"; import { commandLabel, commandTooltip } from "./command-registry.js"; const STANDARD_MENUS: Array<{ label: string; items: string[] }> = [ { label: "File", items: ["Std_New", "Std_Open", "Std_Save", "Std_Export", "Std_Close"] }, { label: "Edit", items: ["Std_Undo", "Std_Redo"] }, { label: "View", items: ["Std_ViewFitAll", "Std_ViewIsometric", "Std_ViewTop", "Std_ViewFront"] }, { label: "Tools", items: ["Std_DlgPreferences", "Std_DlgCustomize", "Std_UnitsCalculator"] }, { label: "Macro", items: ["Std_MacroStartDebug", "Std_MacroStopDebug"] }, { label: "Windows", items: ["Std_DockViewMenu", "Std_TileWindows"] }, { label: "Help", items: ["Std_About", "Std_OnlineHelp"] }, ]; function MenuItems({ items, manifest, onCommand }: { items: DesktopMenuItem[]; manifest: DesktopManifest; onCommand?: (id: string) => void; }) { return
{items.map((item, index) => { if (item.type === "separator") return
; if (item.type === "submenu") return
{item.label ?? "Submenu"}
; if (!item.id) return null; return ; })}
; } export function DesktopMenuBar({ manifest, workbench, onCommand, initialOpen }: { manifest: DesktopManifest; workbench: DesktopWorkbench; onCommand?: (id: string) => void; initialOpen?: string; }) { const [open, setOpen] = useState(initialOpen ?? ""); const menus: DesktopMenu[] = workbench.menus; return ; }