UNPKG

@difizen/mana-core

Version:

101 lines 3.19 kB
/// <reference types="react" /> import type { CommandHandler } from '../command/command-protocol'; import type { DefaultActionMenuItem, DefaultGeneralMenuItem } from './default-menu-node'; export type ActionMenuItem = DefaultActionMenuItem; export type GeneralMenuItem = DefaultGeneralMenuItem; export type MenuPath = string[]; export declare namespace MenuSymbol { const MenuNodeSymbol: unique symbol; const ActionMenuNodeSymbol: unique symbol; const ParentPathSymbol: unique symbol; } /** * Factory for instantiating menu item. */ export declare const GeneralMenuItemFactory: unique symbol; export interface GeneralMenuItemFactory { (item: MenuNode, menuPath: MenuPath): GeneralMenuItem; } /** * Factory for instantiating menu item. */ export declare const ActionMenuItemFactory: unique symbol; export interface ActionMenuItemFactory { (item: ActionMenuNode, menuPath: MenuPath): ActionMenuItem; } /** * Base interface of the nodes used in the menu tree structure. */ export interface MenuNode { /** * The unique ID of the menu node. */ label?: React.ReactNode | React.FC; /** * technical identifier. */ readonly id: string; /** * The order to display menu node. */ order?: string; /** * Optional icon for the menu item */ icon?: React.ReactNode | React.FC; } export declare namespace MenuNode { function is(arg: any): arg is MenuNode; } export interface CommandMenuNode extends MenuNode { /** * The command to execute. */ command: string; /** * In addition to the mandatory command property, an alternative command can be defined. * It will be shown and invoked when pressing Alt while opening a menu. */ alt?: string; } export declare namespace CommandMenuNode { function is(arg: any): arg is CommandMenuNode; } export interface ExecutableMenuNode extends MenuNode, CommandHandler { command?: string; /** * In addition to the mandatory command property, an alternative command can be defined. * It will be shown and invoked when pressing Alt while opening a menu. */ alt?: string; } export declare namespace ExecutableMenuNode { function is(arg: any): arg is ExecutableMenuNode; } export type ActionMenuNode = CommandMenuNode | ExecutableMenuNode; export declare namespace ActionMenuNode { function is(arg: any): arg is ActionMenuNode; } export type MenuOptions = Omit<MenuNode, 'id'>; export declare namespace MenuItem { function isGeneralMenuItem(arg: any): arg is GeneralMenuItem; function isActionMenuItem(arg: any): arg is ActionMenuItem; } export declare namespace ActionMenuItem { /** * @deprecated use MenuItem.isActionMenuItem instead * @param arg * @returns arg is ActionMenuItem */ function is(arg: any): arg is ActionMenuItem; } export declare namespace GeneralMenuItem { /** * @deprecated use MenuItem.isGeneralMenuItem instead * @param arg * @returns arg is GeneralMenuItem */ function is(arg: any): arg is GeneralMenuItem; } export type MenuItem = ActionMenuItem | GeneralMenuItem; //# sourceMappingURL=menu-protocol.d.ts.map