UNPKG

2.2 kBTypeScriptView Raw
1import * as React 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 *
18 * Make sure to forward the provided `ref` to the rendered element (usually via the `elementRef` prop on `MenuItem`/`MenuItem2`)
19 * to ensure that scrolling to active items works correctly.
20 *
21 * @template T type of the DOM element rendered for this item to which we can attach a ref (defaults to MenuItem's HTMLLIElement)
22 */
23export interface ItemRendererProps<T extends HTMLElement = HTMLLIElement> {
24 /**
25 * A ref attached the native HTML element rendered by this item.
26 *
27 * N.B. this is optional to preserve backwards-compatibilty with @blueprintjs/select version < 4.9.0
28 */
29 ref?: React.Ref<T>;
30 /** Click event handler to select this item. */
31 handleClick: React.MouseEventHandler<HTMLElement>;
32 /**
33 * Focus event handler to set this as the "active" item.
34 *
35 * N.B. this is optional to preserve backwards-compatibility with @blueprintjs/select version < 4.2.0
36 */
37 handleFocus?: () => void;
38 index?: number;
39 /** Modifiers that describe how to render this item, such as `active` or `disabled`. */
40 modifiers: ItemModifiers;
41 /** The current query string used to filter the items. */
42 query: string;
43}
44/**
45 * Type alias for a function that receives an item and props and renders a JSX element (or `null`).
46 *
47 * @template T list item data type
48 */
49export declare type ItemRenderer<T> = (item: T, itemProps: ItemRendererProps) => JSX.Element | null;