UNPKG

3.22 kBTypeScriptView Raw
1/// <reference types="react" />
2import { AbstractPureComponent2, InputGroupProps2, IPopoverProps } from "@blueprintjs/core";
3import { IListItemsProps } from "../../common";
4export declare type SuggestProps<T> = ISuggestProps<T>;
5/** @deprecated use SuggestProps */
6export interface ISuggestProps<T> extends IListItemsProps<T> {
7 /**
8 * Whether the popover should close after selecting an item.
9 *
10 * @default true
11 */
12 closeOnSelect?: boolean;
13 /** Whether the input field should be disabled. */
14 disabled?: boolean;
15 /**
16 * Whether the component should take up the full width of its container.
17 * This overrides `popoverProps.fill` and `inputProps.fill`.
18 */
19 fill?: boolean;
20 /**
21 * Props to spread to the query `InputGroup`. To control this input, use
22 * `query` and `onQueryChange` instead of `inputProps.value` and
23 * `inputProps.onChange`.
24 */
25 inputProps?: InputGroupProps2;
26 /** Custom renderer to transform an item into a string for the input value. */
27 inputValueRenderer: (item: T) => string;
28 /**
29 * The uncontrolled default selected item.
30 * This prop is ignored if `selectedItem` is used to control the state.
31 */
32 defaultSelectedItem?: T;
33 /**
34 * The currently selected item, or `null` to indicate that no item is selected.
35 * If omitted or `undefined`, this prop will be uncontrolled (managed by the component's state).
36 * Use `onItemSelect` to listen for updates.
37 */
38 selectedItem?: T | null;
39 /**
40 * If true, the component waits until a keydown event in the TagInput
41 * before opening its popover.
42 *
43 * If false, the popover opens immediately after a mouse click or TAB key
44 * interaction focuses the component's TagInput.
45 *
46 * @default false
47 */
48 openOnKeyDown?: boolean;
49 /** Props to spread to `Popover`. Note that `content` cannot be changed. */
50 popoverProps?: Partial<IPopoverProps> & object;
51 /**
52 * Whether the active item should be reset to the first matching item _when
53 * the popover closes_. The query will also be reset to the empty string.
54 *
55 * @default false
56 */
57 resetOnClose?: boolean;
58}
59export interface ISuggestState<T> {
60 isOpen: boolean;
61 selectedItem: T | null;
62}
63export declare class Suggest<T> extends AbstractPureComponent2<SuggestProps<T>, ISuggestState<T>> {
64 static displayName: string;
65 static defaultProps: Partial<SuggestProps<any>>;
66 static ofType<U>(): new (props: SuggestProps<U>) => Suggest<U>;
67 state: ISuggestState<T>;
68 private TypedQueryList;
69 inputElement: HTMLInputElement | null;
70 private queryList;
71 private handleInputRef;
72 private handleQueryListRef;
73 render(): JSX.Element;
74 componentDidUpdate(prevProps: SuggestProps<T>, prevState: ISuggestState<T>): void;
75 private renderQueryList;
76 private selectText;
77 private handleInputFocus;
78 private handleItemSelect;
79 private getInitialSelectedItem;
80 private handlePopoverInteraction;
81 private handlePopoverOpening;
82 private handlePopoverOpened;
83 private getTargetKeyDownHandler;
84 private getTargetKeyUpHandler;
85 private maybeResetActiveItemToSelectedItem;
86}