sintonia_webapp/resources/js/composables/content/models/misc/contextMenu.ts
2025-03-19 10:57:20 +01:00

34 lines
792 B
TypeScript

export interface ContextMenuType {
visible: boolean;
position: {
top: number;
left: number;
};
menu: ContextMenu
}
export interface ContextMenu {
entries: ContextMenuEntry[];
}
interface ContextMenuEntryWithAction {
menuText: string;
actionTrigger: string;
}
interface ContextMenuEntryWithChildren {
expanded: boolean;
menuText: string;
children: ContextMenuEntry[];
}
type ContextMenuEntry = ContextMenuEntryWithAction | ContextMenuEntryWithChildren;
export function menuEntryWithAction(entry: ContextMenuEntry): entry is ContextMenuEntryWithAction {
return 'actionTrigger' in entry;
}
export function menuEntryWithChildren(entry: ContextMenuEntry): entry is ContextMenuEntryWithChildren {
return 'children' in entry;
}