1 | import PropTypes from 'prop-types';
|
2 | import React, { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, SyntheticEvent } from 'react';
|
3 | import { noop } from '../utils';
|
4 | import type { Option, RefElement, SelectEvent, TypeaheadProps, TypeaheadState } from '../types';
|
5 | declare type Props = TypeaheadProps;
|
6 | export declare function getInitialState(props: Props): TypeaheadState;
|
7 | export declare function clearTypeahead(state: TypeaheadState, props: Props): {
|
8 | isFocused: boolean;
|
9 | selected: never[];
|
10 | text: string;
|
11 | activeIndex: number;
|
12 | activeItem?: Option | undefined;
|
13 | initialItem?: Option | undefined;
|
14 | showMenu: boolean;
|
15 | shownResults: number;
|
16 | };
|
17 | export declare function clickOrFocusInput(state: TypeaheadState): {
|
18 | isFocused: boolean;
|
19 | showMenu: boolean;
|
20 | activeIndex: number;
|
21 | activeItem?: Option | undefined;
|
22 | initialItem?: Option | undefined;
|
23 | selected: Option[];
|
24 | shownResults: number;
|
25 | text: string;
|
26 | };
|
27 | export declare function hideMenu(state: TypeaheadState, props: Props): {
|
28 | activeIndex: number;
|
29 | activeItem: Option | undefined;
|
30 | initialItem: Option | undefined;
|
31 | showMenu: boolean;
|
32 | shownResults: number;
|
33 | isFocused: boolean;
|
34 | selected: Option[];
|
35 | text: string;
|
36 | };
|
37 | export declare function toggleMenu(state: TypeaheadState, props: Props): {
|
38 | showMenu: boolean;
|
39 | activeIndex: number;
|
40 | activeItem?: Option | undefined;
|
41 | initialItem?: Option | undefined;
|
42 | isFocused: boolean;
|
43 | selected: Option[];
|
44 | shownResults: number;
|
45 | text: string;
|
46 | };
|
47 | declare class Typeahead extends React.Component<Props, TypeaheadState> {
|
48 | static propTypes: {
|
49 | allowNew: PropTypes.Requireable<boolean | ((...args: any[]) => any)>;
|
50 | autoFocus: PropTypes.Requireable<boolean>;
|
51 | caseSensitive: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
52 | defaultInputValue: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
53 | defaultOpen: PropTypes.Requireable<boolean>;
|
54 | defaultSelected: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
55 | filterBy: PropTypes.Requireable<string[] | ((...args: any[]) => any)>;
|
56 | highlightOnlyResult: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
57 | id: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
58 | ignoreDiacritics: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
59 | labelKey: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
60 | maxResults: PropTypes.Requireable<number>;
|
61 | minLength: PropTypes.Requireable<number>;
|
62 | multiple: PropTypes.Requireable<boolean>;
|
63 | onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
64 | onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
65 | onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
66 | onInputChange: PropTypes.Requireable<(...args: any[]) => any>;
|
67 | onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
68 | onMenuToggle: PropTypes.Requireable<(...args: any[]) => any>;
|
69 | onPaginate: PropTypes.Requireable<(...args: any[]) => any>;
|
70 | open: PropTypes.Requireable<boolean>;
|
71 | options: PropTypes.Validator<(string | object | null | undefined)[]>;
|
72 | paginate: PropTypes.Requireable<boolean>;
|
73 | selected: (props: TypeaheadProps, propName: keyof TypeaheadProps, componentName: string) => void;
|
74 | };
|
75 | static defaultProps: {
|
76 | allowNew: boolean;
|
77 | autoFocus: boolean;
|
78 | caseSensitive: boolean;
|
79 | defaultInputValue: string;
|
80 | defaultOpen: boolean;
|
81 | defaultSelected: never[];
|
82 | filterBy: never[];
|
83 | highlightOnlyResult: boolean;
|
84 | ignoreDiacritics: boolean;
|
85 | labelKey: string;
|
86 | maxResults: number;
|
87 | minLength: number;
|
88 | multiple: boolean;
|
89 | onBlur: typeof noop;
|
90 | onFocus: typeof noop;
|
91 | onInputChange: typeof noop;
|
92 | onKeyDown: typeof noop;
|
93 | onMenuToggle: typeof noop;
|
94 | onPaginate: typeof noop;
|
95 | paginate: boolean;
|
96 | };
|
97 | state: TypeaheadState;
|
98 | inputNode: RefElement<HTMLInputElement>;
|
99 | isMenuShown: boolean;
|
100 | items: Option[];
|
101 | componentDidMount(): void;
|
102 | componentDidUpdate(prevProps: Props, prevState: TypeaheadState): void;
|
103 | render(): JSX.Element;
|
104 | blur: () => void;
|
105 | clear: () => void;
|
106 | focus: () => void;
|
107 | getInput: () => RefElement<HTMLInputElement>;
|
108 | inputRef: (inputNode: RefElement<HTMLInputElement>) => void;
|
109 | setItem: (item: Option, position: number) => void;
|
110 | hideMenu: () => void;
|
111 | toggleMenu: () => void;
|
112 | _handleActiveIndexChange: (activeIndex: number) => void;
|
113 | _handleActiveItemChange: (activeItem: Option) => void;
|
114 | _handleBlur: (e: FocusEvent<HTMLInputElement>) => void;
|
115 | _handleChange: (selected: Option[]) => void;
|
116 | _handleClear: () => void;
|
117 | _handleClick: (e: MouseEvent<HTMLInputElement>) => void;
|
118 | _handleFocus: (e: SyntheticEvent<HTMLInputElement>) => void;
|
119 | _handleInitialItemChange: (initialItem?: Option | undefined) => void;
|
120 | _handleInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
121 | _handleKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
|
122 | _handleMenuItemSelect: (option: Option, e: SelectEvent<HTMLElement>) => void;
|
123 | _handlePaginate: (e: SelectEvent<HTMLElement>) => void;
|
124 | _handleSelectionAdd: (option: Option) => void;
|
125 | _handleSelectionRemove: (selection: Option) => void;
|
126 | }
|
127 | export default Typeahead;
|