1 | import React, { MutableRefObject } from 'react';
|
2 | import { ListOptionProps } from './ListOption';
|
3 | import { UserProvidedMessages } from './messages';
|
4 | import { DataItem, RenderProp, Value } from './types';
|
5 | import { Accessors } from './Accessors';
|
6 | export declare type GroupBy<TDataItem = unknown> = ((item: TDataItem) => unknown) | string;
|
7 | export interface ListHandle {
|
8 | scrollIntoView(): void;
|
9 | }
|
10 | export declare type RenderItemProp<TDataItem> = RenderProp<{
|
11 | item: TDataItem;
|
12 | searchTerm?: string;
|
13 | index: number;
|
14 | text: string;
|
15 | value: unknown;
|
16 | disabled: boolean;
|
17 | }>;
|
18 | export declare type RenderGroupProp = RenderProp<{
|
19 | group: any;
|
20 | }>;
|
21 | export declare type OptionComponentProp = React.ComponentType<ListOptionProps<any>>;
|
22 | export declare type ChangeHandler<TDataItem> = (dataItem: TDataItem | TDataItem[], metadata: {
|
23 | action?: 'insert' | 'remove';
|
24 | dataItem?: TDataItem;
|
25 | lastValue: Value;
|
26 | originalEvent?: React.SyntheticEvent;
|
27 | }) => void;
|
28 | export 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 | }
|
46 | declare interface List {
|
47 | <TDataItem = DataItem>(props: ListProps<TDataItem> & React.RefAttributes<ListHandle>): React.ReactElement | null;
|
48 | displayName?: string;
|
49 | propTypes?: any;
|
50 | }
|
51 | export declare const useScrollFocusedIntoView: (element: HTMLElement | null, observeChanges?: boolean) => () => void;
|
52 | export declare function useHandleSelect<TDataItem>(multiple: boolean, dataItems: TDataItem[], onChange: ChangeHandler<TDataItem>): (dataItem: TDataItem, event: React.SyntheticEvent) => void;
|
53 | declare const List: List;
|
54 | export default List;
|
55 |
|
\ | No newline at end of file |