1 | import { MouseEventHandler } from "react";
|
2 | export interface IItemModifiers {
|
3 | /** Whether this is the "active" (focused) item, meaning keyboard interactions will act upon it. */
|
4 | active: boolean;
|
5 | /** Whether this item is disabled and should ignore interactions. */
|
6 | disabled: boolean;
|
7 | /** Whether this item matches the predicate. A typical renderer could hide `false` values. */
|
8 | matchesPredicate: boolean;
|
9 | }
|
10 | /**
|
11 | * An object describing how to render a particular item.
|
12 | * An `itemRenderer` receives the item as its first argument, and this object as its second argument.
|
13 | */
|
14 | export interface IItemRendererProps {
|
15 | /** Click event handler to select this item. */
|
16 | handleClick: MouseEventHandler<HTMLElement>;
|
17 | /**
|
18 | * Focus event handler to set this as the "active" item.
|
19 | *
|
20 | * N.B. this is optional to preserve back-compat; it will become required in the next major version.
|
21 | */
|
22 | handleFocus?: () => void;
|
23 | index?: number;
|
24 | /** Modifiers that describe how to render this item, such as `active` or `disabled`. */
|
25 | modifiers: IItemModifiers;
|
26 | /** The current query string used to filter the items. */
|
27 | query: string;
|
28 | }
|
29 | /** Type alias for a function that receives an item and props and renders a JSX element (or `null`). */
|
30 | export declare type ItemRenderer<T> = (item: T, itemProps: IItemRendererProps) => JSX.Element | null;
|