client/menus: add support for menu headers

This commit is contained in:
Adorian Doran 2025-09-20 00:18:56 +03:00
parent 79718c7e6e
commit 17e87278eb
2 changed files with 10 additions and 4 deletions

View File

@ -18,6 +18,11 @@ interface MenuSeparatorItem {
title: "----";
}
interface MenuHeader {
title: string;
kind: "header";
}
export interface MenuItemBadge {
title: string;
className?: string;
@ -45,7 +50,7 @@ export interface MenuCommandItem<T> {
columns?: number;
}
export type MenuItem<T> = MenuCommandItem<T> | MenuSeparatorItem;
export type MenuItem<T> = MenuCommandItem<T> | MenuSeparatorItem | MenuHeader;
export type MenuHandler<T> = (item: MenuCommandItem<T>, e: JQuery.MouseDownEvent<HTMLElement, undefined, HTMLElement, HTMLElement>) => void;
export type ContextMenuEvent = PointerEvent | MouseEvent | JQuery.ContextMenuEvent;
@ -158,6 +163,8 @@ class ContextMenu {
if (item.title === "----") {
$parent.append($("<div>").addClass("dropdown-divider"));
} else if ("kind" in item && item.kind === "header") {
$parent.append($("<h6>").addClass("dropdown-header").text(item.title));
} else {
const $icon = $("<span>");

View File

@ -157,9 +157,8 @@ async function getBuiltInTemplates(title: string | null, command: TreeCommandNam
const items: MenuItem<TreeCommandNames>[] = [];
if (title) {
items.push({
title: title,
enabled: false,
uiIcon: "bx bx-empty"
title: "title",
kind: "header"
});
} else {
items.push(SEPARATOR);