UNPKG

2.16 kBTypeScriptView Raw
1import React, { MutableRefObject } from 'react';
2import { ListOptionProps } from './ListOption';
3import { UserProvidedMessages } from './messages';
4import { DataItem, RenderProp, Value } from './types';
5import { Accessors } from './Accessors';
6export declare type GroupBy<TDataItem = unknown> = ((item: TDataItem) => unknown) | string;
7export interface ListHandle {
8 scrollIntoView(): void;
9}
10export declare type RenderItemProp<TDataItem> = RenderProp<{
11 item: TDataItem;
12 searchTerm?: string;
13 index: number;
14 text: string;
15 value: unknown;
16 disabled: boolean;
17}>;
18export declare type RenderGroupProp = RenderProp<{
19 group: any;
20}>;
21export declare type OptionComponentProp = React.ComponentType<ListOptionProps<any>>;
22export declare type ChangeHandler<TDataItem> = (dataItem: TDataItem | TDataItem[], metadata: {
23 action?: 'insert' | 'remove';
24 dataItem?: TDataItem;
25 lastValue: Value;
26 originalEvent?: React.SyntheticEvent;
27}) => void;
28export interface ListProps<TDataItem> {
29 data: readonly TDataItem[];
30 value?: readonly TDataItem[] | TDataItem;
31 accessors: Accessors;
32 focusedItem?: TDataItem;
33 className?: string;
34 multiple?: boolean;
35 disabled?: boolean | readonly TDataItem[];
36 messages?: UserProvidedMessages;
37 renderItem?: RenderItemProp<TDataItem>;
38 renderGroup?: RenderGroupProp;
39 searchTerm?: string;
40 groupBy?: GroupBy<TDataItem>;
41 optionComponent?: React.ElementType;
42 onChange: ChangeHandler<TDataItem>;
43 elementRef?: MutableRefObject<HTMLDivElement | null>;
44 [key: string]: any;
45}
46declare interface List {
47 <TDataItem = DataItem>(props: ListProps<TDataItem> & React.RefAttributes<ListHandle>): React.ReactElement | null;
48 displayName?: string;
49 propTypes?: any;
50}
51export declare const useScrollFocusedIntoView: (element: HTMLElement | null, observeChanges?: boolean) => () => void;
52export declare function useHandleSelect<TDataItem>(multiple: boolean, dataItems: TDataItem[], onChange: ChangeHandler<TDataItem>): (dataItem: TDataItem, event: React.SyntheticEvent) => void;
53declare const List: List;
54export default List;
55//# sourceMappingURL=List.d.ts.map
\No newline at end of file