UNPKG

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