UNPKG

3.09 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, IPopoverProps, TagInputProps } from "@blueprintjs/core";
3import { ListItemsProps } from "../../common";
4import { QueryList } from "../query-list/queryList";
5export declare type MultiSelectProps<T> = IMultiSelectProps<T>;
6/** @deprecated use MultiSelectProps */
7export interface IMultiSelectProps<T> extends ListItemsProps<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}
53/**
54 * Multi select component.
55 *
56 * @see https://blueprintjs.com/docs/#select/multi-select
57 * @deprecated use { MultiSelect2 } from "@blueprintjs/select"
58 */
59export declare class MultiSelect<T> extends AbstractPureComponent2<MultiSelectProps<T>, IMultiSelectState> {
60 static displayName: string;
61 static defaultProps: {
62 fill: boolean;
63 placeholder: string;
64 };
65 static ofType<U>(): new (props: MultiSelectProps<U>) => MultiSelect<U>;
66 state: IMultiSelectState;
67 input: HTMLInputElement | null;
68 queryList: QueryList<T> | null;
69 private refHandlers;
70 componentDidUpdate(prevProps: MultiSelectProps<T>): void;
71 render(): JSX.Element;
72 private renderQueryList;
73 private handleItemSelect;
74 private handleQueryChange;
75 private handlePopoverInteraction;
76 private handlePopoverOpened;
77 private handleTagRemove;
78 private getTagInputKeyDownHandler;
79 private getTagInputKeyUpHandler;
80}