UNPKG

2.96 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, IPopoverProps, TagInputProps } from "@blueprintjs/core";
3import { IListItemsProps } from "../../common";
4import { QueryList } from "../query-list/queryList";
5export declare type MultiSelectProps<T> = IMultiSelectProps<T>;
6/** @deprecated use MultiSelectProps */
7export interface IMultiSelectProps<T> extends IListItemsProps<T> {
8 /**
9 * Whether the component should take up the full width of its container.
10 * This overrides `popoverProps.fill` and `tagInputProps.fill`.
11 */
12 fill?: boolean;
13 /**
14 * Callback invoked when an item is removed from the selection by
15 * removing its tag in the TagInput. This is generally more useful than
16 * `tagInputProps.onRemove` because it receives the removed value instead of
17 * the value's rendered `ReactNode` tag.
18 *
19 * It is not recommended to supply _both_ this prop and `tagInputProps.onRemove`.
20 */
21 onRemove?: (value: T, index: number) => void;
22 /**
23 * If true, the component waits until a keydown event in the TagInput
24 * before opening its popover.
25 *
26 * If false, the popover opens immediately after a mouse click focuses
27 * the component's TagInput.
28 *
29 * N.B. the behavior of this prop differs slightly from the same one
30 * in the Suggest component; see https://github.com/palantir/blueprint/issues/4152.
31 *
32 * @default false
33 */
34 openOnKeyDown?: boolean;
35 /**
36 * Input placeholder text. Shorthand for `tagInputProps.placeholder`.
37 *
38 * @default "Search..."
39 */
40 placeholder?: string;
41 /** Props to spread to `Popover`. Note that `content` cannot be changed. */
42 popoverProps?: Partial<IPopoverProps> & object;
43 /** Controlled selected values. */
44 selectedItems?: T[];
45 /** Props to spread to `TagInput`. Use `query` and `onQueryChange` to control the input. */
46 tagInputProps?: Partial<TagInputProps> & object;
47 /** Custom renderer to transform an item into tag content. */
48 tagRenderer: (item: T) => React.ReactNode;
49}
50export interface IMultiSelectState {
51 isOpen: boolean;
52}
53export declare class MultiSelect<T> extends AbstractPureComponent2<MultiSelectProps<T>, IMultiSelectState> {
54 static displayName: string;
55 static defaultProps: {
56 fill: boolean;
57 placeholder: string;
58 };
59 static ofType<U>(): new (props: MultiSelectProps<U>) => MultiSelect<U>;
60 state: IMultiSelectState;
61 private TypedQueryList;
62 input: HTMLInputElement | null;
63 queryList: QueryList<T> | null;
64 private refHandlers;
65 componentDidUpdate(prevProps: MultiSelectProps<T>): void;
66 render(): JSX.Element;
67 private renderQueryList;
68 private handleItemSelect;
69 private handleQueryChange;
70 private handlePopoverInteraction;
71 private handlePopoverOpened;
72 private handleTagRemove;
73 private getTagInputKeyDownHandler;
74 private getTagInputKeyUpHandler;
75}