UNPKG

2.3 kBTypeScriptView Raw
1import React from 'react';
2import { MultiselectTagListProps, 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 tagListComponent?: React.ComponentType<MultiselectTagListProps<DataItem>>;
21 showSelectedItemsInList?: boolean;
22}
23declare interface Multiselect {
24 <TDataItem = DataItem>(props: MultiselectProps<TDataItem> & React.RefAttributes<MultiselectHandle>): React.ReactElement | null;
25 displayName?: string;
26 propTypes?: any;
27}
28/**
29 * ---
30 * shortcuts:
31 * - { key: left arrow, label: move focus to previous tag }
32 * - { key: right arrow, label: move focus to next tag }
33 * - { key: delete, deselect focused tag }
34 * - { key: backspace, deselect next tag }
35 * - { key: alt + up arrow, label: close Multiselect }
36 * - { key: down arrow, label: open Multiselect, and move focus to next item }
37 * - { key: up arrow, label: move focus to previous item }
38 * - { key: home, label: move focus to first item }
39 * - { key: end, label: move focus to last item }
40 * - { key: enter, label: select focused item }
41 * - { key: ctrl + enter, label: create new tag from current searchTerm }
42 * - { key: any key, label: search list for item starting with key }
43 * ---
44 *
45 * A select listbox alternative.
46 *
47 * @public
48 */
49declare const Multiselect: Multiselect;
50export default Multiselect;
51//# sourceMappingURL=Multiselect.d.ts.map
\No newline at end of file