import { EventSource } from 'apprt-core/Types'; /** * This bundle provides following APIs. * * The {@link SearchUiService} can be used to reset the search input field and pre-fill it with a search term, * it is registered as `search-ui.SearchUiService` and can be injected. * * The {@link SearchUiEnterKeyAction} is a _friend_ interface for the product smart.finder. * * @module */ /** * Interface describing the events of the SearchUiService. */ interface SearchUiServiceEvents { /** * The 'reset' event. Currently any further information. */ reset: void; } /** * Provides methods to control the search-ui. * The service can be referenced via `search-ui.SearchUiService`. * * @example Reset the search * ```ts * const service = this.searchUiService; // injected * service.reset(); * // or * service.reset({searchText: "My text"}); * ... * ``` * * @example Listen for reset event of the search ui * ```ts * const service = this.searchUiService; // injected * service.on("reset", ()=>{ * // react to the reset of the search ui * }); * ... * ``` */ interface SearchUiService extends EventSource { /** * Resets the UI. * Optionally accepts a text to be displayed in the search field. */ reset(options?: { searchText?: string; }): void; } /** * Interface to react on the 'Enter' key pressed event of the search-ui input field. It will provide the * current text from the input field to another component. * * Only one action is allowed. It must be registered as a service which provides `search-ui.EnterKeyAction`. */ interface SearchUiEnterKeyAction { /** * A description of the action. * Used as tooltip for the lens icon button and its aria-label. */ description?: string; /** * Triggers the action. * @param searchText the current searchText shown in the input field. */ trigger(searchText: string): void; /** * Informs the action that the search-ui was reset. */ reset?(): void; } export type { SearchUiEnterKeyAction, SearchUiService, SearchUiServiceEvents };