UNPKG

@launchmenu/core

Version:

An environment for visual keyboard controlled applets

49 lines 1.82 kB
import { DataCacher, IDataHook, IDataRetriever } from "model-react"; import { ICategory } from "../../actions/types/category/_types/ICategory"; import { IMenuItem } from "../items/_types/IMenuItem"; import { ICategorizerConfig } from "./_types/ICategorizerConfig"; import { IMenuCategoryData } from "./_types/IMenuCategoryData"; /** * A class that can be used to categorize a list of menu items */ export declare class MenuItemCategorizer<T> { protected itemsGetter: IDataRetriever<T[]>; protected config: Required<ICategorizerConfig<T>>; /** * Creates a new categorizer * @param items The items getter * @param config The config to customize the categories */ constructor(items: IDataRetriever<T[]>, config: ICategorizerConfig<T>); /** * The items together with a function to retrieve their category, caching the category for future use */ protected itemsWithCategories: DataCacher<{ items: { item: T; categoryGetter: DataCacher<ICategory | undefined>; }[]; categories: Map<T, DataCacher<ICategory | undefined>>; }>; /** * The categories data */ protected categories: DataCacher<IMenuCategoryData[]>; /** * The menu items */ protected items: DataCacher<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[]; /** * Retrieves the items including categories * @param hook The hook to subscribe to changes * @returns The menu items */ getItems(hook?: IDataHook): IMenuItem[]; } //# sourceMappingURL=MenuItemCategorizer.d.ts.map