UNPKG

2.16 kBTypeScriptView Raw
1import React from 'react';
2import { RenderTagProp, TagComponentProp } from './MultiselectTagList';
3import { BaseListboxInputProps, Filterable, PopupWidgetProps, Searchable, WidgetHTMLProps, WidgetProps } from './shared';
4import { DataItem, Value, WidgetHandle } from './types';
5export declare type MultiselectHandle = WidgetHandle;
6export declare type ChangeHandler<TDataItem> = (dataItem: TDataItem[], metadata: {
7 action: 'insert' | 'remove';
8 dataItem: TDataItem;
9 searchTerm?: string;
10 lastValue: Value;
11 originalEvent?: React.SyntheticEvent;
12}) => void;
13export interface MultiselectProps<TDataItem = DataItem> extends WidgetHTMLProps, WidgetProps, PopupWidgetProps, Filterable<TDataItem>, Searchable, Omit<BaseListboxInputProps<TDataItem, unknown[]>, 'onChange'> {
14 onChange?: ChangeHandler<TDataItem>;
15 onCreate?: (searchTerm: string) => void;
16 showPlaceholderWithValues?: boolean;
17 renderTagValue?: RenderTagProp<TDataItem>;
18 clearTagIcon?: React.ReactNode;
19 tagOptionComponent?: TagComponentProp;
20}
21declare interface Multiselect {
22 <TDataItem = DataItem>(props: MultiselectProps<TDataItem> & React.RefAttributes<MultiselectHandle>): React.ReactElement | null;
23 displayName?: string;
24 propTypes?: any;
25}
26/**
27 * ---
28 * shortcuts:
29 * - { key: left arrow, label: move focus to previous tag }
30 * - { key: right arrow, label: move focus to next tag }
31 * - { key: delete, deselect focused tag }
32 * - { key: backspace, deselect next tag }
33 * - { key: alt + up arrow, label: close Multiselect }
34 * - { key: down arrow, label: open Multiselect, and move focus to next item }
35 * - { key: up arrow, label: move focus to previous item }
36 * - { key: home, label: move focus to first item }
37 * - { key: end, label: move focus to last item }
38 * - { key: enter, label: select focused item }
39 * - { key: ctrl + enter, label: create new tag from current searchTerm }
40 * - { key: any key, label: search list for item starting with key }
41 * ---
42 *
43 * A select listbox alternative.
44 *
45 * @public
46 */
47declare const Multiselect: Multiselect;
48export default Multiselect;
49//# sourceMappingURL=Multiselect.d.ts.map
\No newline at end of file