@launchmenu/core
Version:
An environment for visual keyboard controlled applets
81 lines • 3.35 kB
TypeScript
import React from "react";
import { IMenuItem } from "../items/_types/IMenuItem";
import { Field, IDataHook } from "model-react";
import { IPrioritizedMenuItem } from "./_types/IPrioritizedMenuItem";
import { IQuery } from "./_types/IQuery";
import { IIOContext } from "../../context/_types/IIOContext";
import { IPatternMatch } from "../../utils/searchExecuter/_types/IPatternMatch";
import { SearchExecuter } from "../../utils/searchExecuter/SearchExecuter";
import { PrioritizedMenu } from "./PrioritizedMenu";
import { IPrioritizedMenuConfig } from "./_types/IPrioritizedMenuConfig";
import { IMenuSearchable } from "../../actions/types/search/_types/IMenuSearchable";
/**
* A menu that can be used to perform a search on a collection of items
*/
export declare class SearchMenu extends PrioritizedMenu {
protected searchItems: Field<IMenuItem[]>;
protected showAllOnEmptySearch?: boolean;
protected search?: IMenuSearchable["search"];
protected executer: SearchExecuter<IQuery, IPrioritizedMenuItem>;
/**
* Creates a new search menu
* @param context The context to be used by menu items
* @param config The config of the category and other options
*/
constructor(context: IIOContext, config?: IPrioritizedMenuConfig & {
/** Whether to show all items when the set search is empty (defaults to false) */
showAllOnEmptySearch?: boolean;
/** An optional search config to override the items search */
search?: IMenuSearchable["search"];
});
/**
* A default view for a search menu, with instant open and close transitions
*/
view: {
view: JSX.Element;
transitions: {
Open: React.FC<import("../../components/context/stacks/transitions/open/_types/IOpenTransitionProps").IOpenTransitionProps>;
Close: React.FC<import("../../components/context/stacks/transitions/close/_types/ICloseTransitionProps").ICloseTransitionProps>;
};
};
/**
* Sets the search query
* @param search The text to search with
* @returns A promise that resolves once the new search has finished
*/
setSearch(search: string): Promise<void>;
/**
* Sets the items to be searched in
* @param items The items
*/
setSearchItems(items: IMenuItem[]): void;
/**
* Adds an item to be searched in
* @param item The item to add
*/
addSearchItem(item: IMenuItem): void;
/**
* Removes an item and its search results
* @param item The item to remove
*/
removeSearchItem(item: IMenuItem): void;
/**
* Retrieves the search text
* @param hook The hook to subscribe to changes
* @returns The search text
*/
getSearch(hook?: IDataHook): string | null;
/**
* Retrieves the highlight data to use for highlighting within menu items
* @param hook The hook to subscribe to changes
* @returns The highlight data
*/
getHighlight(hook?: IDataHook): IQuery | null;
/**
* Retrieves the pattern matches from searches
* @param hook The hook to subscribe to changes
* @returns The patterns in searches
*/
getPatternMatches(hook?: IDataHook): IPatternMatch[];
}
//# sourceMappingURL=SearchMenu.d.ts.map