import type { Filter, FilterGroup, FilterGroupDefinition, SearchFunc } from "./Search"; type Message = { name: "queryChanged"; query: string; } | { name: "toggleFilter"; filter: Filter; } | { name: "refreshSearch"; }; /** * Model for a screen to search and filter items. */ interface Model { /** * The query string. */ query: string; items: TData[]; /** * Contains all visible items. */ visibleItems: TData[]; /** * Optional list of filters. */ filterGroups?: FilterGroup[]; } interface Options { /** * The function to filter one item of the list by the given query string. */ filterByQuery: SearchFunc; /** * Optional list of filter definitions. */ filterGroups?: FilterGroupDefinition[]; /** * If set to true, all items are shown if the query is empty and no filters are set. */ showAllItemsByDefault?: boolean; } type CompositeModel = Model & TModel; interface Msg { /** * Updates the query string. */ queryChanged: (query: string) => Message; /** * Toggles the given filter. */ toggleFilter: (filter: Filter) => Message; /** * Refreshes the search result. * Dispatch this message when the items changed. */ refreshSearch: () => Message; } /** * Creates the `Msg` object with the search message creators. * @returns The `Msg` object. */ declare function createMsg(): Msg; /** * Creates the initial search screen model. * @param options The search screen options. * @returns The `init` function. */ declare function createInit(options: Options): () => Model; export type { CompositeModel, Message, Model, Msg, Options }; export { createInit, createMsg };