/* Copyright 2026 Marimo. All rights reserved. */ import { MenuIcon } from "lucide-react"; import React from "react"; import { useLocale } from "react-aria"; import { Button } from "@/components/editor/inputs/Inputs"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Tooltip } from "@/components/ui/tooltip"; import { getMarimoVersion } from "@/core/meta/globals"; import { MinimalShortcut, renderShortcut, } from "../../shortcuts/renderShortcut"; import type { ActionButton } from "../actions/types"; import { useNotebookActions } from "../actions/useNotebookActions"; interface Props { disabled?: boolean; tooltip?: string; } export const NotebookMenuDropdown: React.FC = ({ disabled = false, tooltip = "Actions", }) => { const actions = useNotebookActions(); const { locale } = useLocale(); // Create tooltip content with keyboard shortcut decoration const tooltipContent = (
{tooltip}
{!disabled && (
Open command palette {renderShortcut("global.commandPalette", false)}
)}
); const button = ( ); const renderLabel = (action: ActionButton) => { return ( <> {action.icon && {action.icon}} {action.labelElement || action.label} {action.hotkey && ( )} {action.rightElement} ); }; const renderLeafAction = (action: ActionButton) => { const item = ( action.handle(evt)} data-testid={`notebook-menu-dropdown-${action.label}`} > {renderLabel(action)} ); if (action.tooltip) { return ( {item} ); } return item; }; const renderAction = (action: ActionButton) => { if (action.hidden || action.redundant) { return null; } if (action.dropdown) { return ( {renderLabel(action)} {action.dropdown.map((childAction) => ( {childAction.divider && } {renderAction(childAction)} ))} ); } return renderLeafAction(action); }; return ( {button} {actions.map((action) => { return ( {action.divider && } {renderAction(action)} ); })}
Locale: {locale} Version: {getMarimoVersion()}
); };