import type { GridApi } from '../api/gridApi'; import type { GetFindTextFunc } from '../entities/colDef'; import type { Column } from './iColumn'; import type { IRowNode } from './iRowNode'; export interface FindMatch { node: IRowNode; /** Will be `null` if the match is within a full width row or detail row. */ column: Column | null; /** The number of the match within the cell (starting from `1`). */ numInMatch: number; /** The number of the match within all the matches in the grid (starting from `1`). */ numOverall: number; } export interface IFindService { totalMatches: number; activeMatch: FindMatch | undefined; isMatch(node: IRowNode, column: Column | null): boolean; getParts(params: FindCellValueParams): FindPart[]; next(): void; previous(): void; goTo(match: number, force?: boolean): void; clearActive(): void; getNumMatches(node: IRowNode, column: Column | null): number; registerDetailGrid(node: IRowNode, api: GridApi): void; refresh(maintainActive: boolean): void; } export interface FindOptions { /** Match values in the current page only (when pagination enabled). */ currentPageOnly?: boolean; /** Match case of values. */ caseSensitive?: boolean; /** Perform searches across Detail Grids or Custom Detail Cells when using Master/Detail. */ searchDetail?: boolean; } export interface FindCellParams { node: IRowNode; /** `null` if the cell is a full width row or detail row. */ column: Column | null; } export interface FindCellValueParams extends FindCellParams { /** Display value to search within. */ value: string; /** * Useful when trying to convert multiple values within a cell separately. * The value supplied here will be treated as the number of matches that appear before `value` in the cell, * and the active match will then be offset correctly. */ precedingNumMatches?: number; } export interface FindPart { /** Partial display value. */ value: string; /** `true` if a match. */ match?: boolean; /** `true` if the active match. */ activeMatch?: boolean; } export type GetFindMatches = (params: GetFindMatchesParams) => number; export interface GetFindMatchesParams { node: IRowNode; data: TData; /** Current search value. */ findSearchValue: string; /** Should be called if the number of matches has updated. */ updateMatches: () => void; /** Helper function to get the number of matches within the provided string value. */ getMatchesForValue: (value: string) => number; } export interface FindDetailCellRendererParams { /** * If using Find across Master / Detail, this will be called to work out * the number of matches that would be within the custom detail cell. */ getFindMatches?: GetFindMatches; } export interface FindDetailGridCellRendererParams { /** * If using Find across Master / Detail and the Detail Grid is not open, * this will be called to work out the number of matches that would be * within the Detail Grid. */ getFindMatches?: GetFindMatches; } export interface FindFullWidthCellRendererParams { /** * If using Find with full width rows, this will be called to work out * the number of matches that would be within the full width row. */ getFindMatches?: GetFindMatches; } export interface FindGroupRowRendererParams { /** * When using Find with a custom group row renderer, this allows providing a custom value to search within. * E.g. if the group row renderer is displaying text that is different from the formatted value. * Returning `null` means Find will not search within the group row. */ getFindText?: GetFindTextFunc; }