@launchmenu/core
Version:
An environment for visual keyboard controlled applets
87 lines • 3.74 kB
TypeScript
import { IMenuItem } from "../items/_types/IMenuItem";
import { IDataHook, Field } from "model-react";
import { IMenuCategoryConfig } from "./_types/IMenuCategoryConfig";
import { TRequired } from "../../_types/TRequired";
import { IMenuCategoryData } from "./_types/IMenuCategoryData";
import { AbstractMenu } from "./AbstractMenu";
import { IIOContext } from "../../context/_types/IIOContext";
import { ICategory } from "../../actions/types/category/_types/ICategory";
/**
* A menu class to control menu items and their state,
* optimized for small item sets.
*/
export declare class Menu extends AbstractMenu {
protected categoryConfig: TRequired<IMenuCategoryConfig>;
protected rawCategories: {
items: IMenuItem[];
category: ICategory | undefined;
}[];
protected categories: Field<IMenuCategoryData[]>;
protected items: Field<IMenuItem[]>;
/**
* Creates a new menu
* @param context The context to be used by menu items
* @param categoryConfig The configuration for category options
*/
constructor(context: IIOContext, categoryConfig?: IMenuCategoryConfig);
/**
* Creates a new menu
* @param context The context to be used by menu items
* @param items The initial items to store
* @param categoryConfig The configuration for category options
*/
constructor(context: IIOContext, items: IMenuItem[], categoryConfig?: IMenuCategoryConfig);
/**
* Adds an item to the menu
* @param item The item to add
* @param index The index to add the item at within its category (defaults to the last index; Infinity)
*/
addItem(item: IMenuItem, index?: number): void;
/**
* Adds all the items from the given array at once (slightly more efficient than adding one by one)
* @param items The generator to get items from
*/
addItems(items: IMenuItem[]): void;
/**
* Adds an item to the menu without updating the item list
* @param item The item to add
* @param destination The list to add the item to
* @param index The index to add the item at within its category (defaults to the last index; Infinity)
* @returns Added whether the item was added
*/
protected addItemWithoutUpdate(item: IMenuItem, destination: IMenuCategoryData[], index?: number): boolean;
/**
* Removes an item from the menu
* @param item The item to remove
* @returns Whether the item was in the menu (and now removed)
*/
removeItem(item: IMenuItem): boolean;
/**
* Removes all the items from the given array at once (slightly more efficient than removing one by one)
* @param item The item to remove
* @param oldCategory The category that item was in (null to use the items' latest category)
* @returns Whether any item was in the menu (and now removed)
*/
removeItems(items: IMenuItem[], oldCategory?: ICategory | null): boolean;
/**
* Synchronizes the item list to be up to date with the categories data
*/
protected updateItemsList(): void;
/**
* Checks whether the cursor item is still present, and deselects it if not
*/
protected deselectRemovedCursor(): void;
/**
* Retrieves the items of the menu
* @param hook The hook to subscribe to changes
* @returns The menu items
*/
getItems(hook?: IDataHook): IMenuItem[];
/**
* Retrieves the item categories of the menu
* @param hook The hook to subscribe to changes
* @returns The categories and their items
*/
getCategories(hook?: IDataHook): IMenuCategoryData[];
}
//# sourceMappingURL=Menu.d.ts.map