|
1 | | -// Type definitions for react-autosuggest 8.0 |
| 1 | +// Type definitions for react-autosuggest 9.3 |
2 | 2 | // Project: http://react-autosuggest.js.org/ |
3 | | -// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt>, Philip Ottesen <https://github.com/pjo256>, Robert Essig <https://github.com/robessog>, Terry Bayne <https://github.com/tbayne> |
| 3 | +// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt> |
| 4 | +// Philip Ottesen <https://github.com/pjo256> |
| 5 | +// Robert Essig <https://github.com/robessog> |
| 6 | +// Terry Bayne <https://github.com/tbayne> |
| 7 | +// Christopher Deutsch <https://github.com/cdeutsch> |
4 | 8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
5 | 9 | // TypeScript Version: 2.3 |
6 | 10 |
|
7 | 11 | import * as React from 'react'; |
8 | | -declare class Autosuggest extends React.Component<any> {} |
| 12 | +declare class Autosuggest extends React.Component<Autosuggest.AutosuggestProps> {} |
9 | 13 |
|
10 | 14 | export = Autosuggest; |
11 | 15 |
|
12 | 16 | declare namespace Autosuggest { |
13 | 17 | interface SuggestionsFetchRequest { |
14 | 18 | value: string; |
15 | | - reason: string; |
| 19 | + reason: 'input-changed' | 'input-focused' | 'escape-pressed' | 'suggestions-revealed' | 'suggestion-selected'; |
16 | 20 | } |
17 | 21 |
|
18 | 22 | interface InputValues { |
19 | 23 | value: string; |
20 | 24 | valueBeforeUpDown?: string; |
21 | 25 | } |
22 | 26 |
|
| 27 | + interface RenderSuggestionParams { |
| 28 | + query: string; |
| 29 | + isHighlighted: boolean; |
| 30 | + } |
| 31 | + |
| 32 | + interface SuggestionHighlightedParams { |
| 33 | + suggestion: any; |
| 34 | + } |
| 35 | + |
23 | 36 | interface ChangeEvent { |
24 | 37 | newValue: string; |
25 | 38 | method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type'; |
26 | 39 | } |
27 | 40 |
|
28 | 41 | interface BlurEvent { |
29 | | - focusedSuggestion: any; |
| 42 | + highlightedSuggestion: any; |
30 | 43 | } |
31 | 44 |
|
32 | | - interface InputProps extends React.HTMLAttributes<any> { |
| 45 | + interface InputProps extends React.InputHTMLAttributes<any> { |
33 | 46 | value: string; |
34 | 47 | onChange(event: React.FormEvent<any>, params?: ChangeEvent): void; |
35 | 48 | onBlur?(event: React.FormEvent<any>, params?: BlurEvent): void; |
| 49 | + [key: string]: any; |
36 | 50 | } |
37 | 51 |
|
38 | 52 | interface SuggestionSelectedEventData<TSuggestion> { |
39 | | - method: 'click' | 'enter'; |
40 | | - sectionIndex: number | null; |
41 | 53 | suggestion: TSuggestion; |
42 | 54 | suggestionValue: string; |
| 55 | + suggestionIndex: number; |
| 56 | + sectionIndex: number | null; |
| 57 | + method: 'click' | 'enter'; |
43 | 58 | } |
44 | 59 |
|
45 | 60 | interface Theme { |
46 | 61 | container?: string; |
47 | 62 | containerOpen?: string; |
48 | 63 | input?: string; |
| 64 | + inputOpen?: string; |
| 65 | + inputFocused?: string; |
| 66 | + suggestionsContainer?: string; |
| 67 | + suggestionsContainerOpen?: string; |
| 68 | + suggestionsList?: string; |
| 69 | + suggestion?: string; |
| 70 | + suggestionFirst?: string; |
| 71 | + suggestionHighlighted?: string; |
49 | 72 | sectionContainer?: string; |
50 | | - sectionSuggestionsContainer?: string; |
| 73 | + sectionContainerFirst?: string; |
51 | 74 | sectionTitle?: string; |
52 | | - suggestion?: string; |
53 | | - suggestionFocused?: string; |
54 | | - suggestionsContainer?: string; |
55 | 75 | } |
56 | 76 |
|
57 | 77 | interface AutosuggestProps extends React.Props<Autosuggest> { |
58 | 78 | suggestions: any[]; |
59 | 79 | onSuggestionsFetchRequested(request: SuggestionsFetchRequest): void; |
60 | 80 | onSuggestionsClearRequested?(): void; |
61 | 81 | getSuggestionValue(suggestion: any): any; |
62 | | - renderSuggestion(suggestion: any, inputValues: InputValues): JSX.Element; |
| 82 | + renderSuggestion(suggestion: any, params: RenderSuggestionParams): JSX.Element; |
63 | 83 | inputProps: InputProps; |
64 | 84 | onSuggestionSelected?(event: React.FormEvent<any>, data: SuggestionSelectedEventData<any>): void; |
| 85 | + onSuggestionHighlighted?(params: SuggestionHighlightedParams): void; |
65 | 86 | shouldRenderSuggestions?(value: string): boolean; |
66 | 87 | alwaysRenderSuggestions?: boolean; |
67 | | - focusFirstSuggestion?: boolean; |
| 88 | + highlightFirstSuggestion?: boolean; |
68 | 89 | focusInputOnSuggestionClick?: boolean; |
69 | 90 | multiSection?: boolean; |
70 | | - renderSectionTitle?(section: any, inputValues: InputValues): JSX.Element; |
| 91 | + renderSectionTitle?(section: any): JSX.Element; |
71 | 92 | getSectionSuggestions?(section: any): any[]; |
72 | | - renderInputComponent?(): JSX.Element; |
73 | | - renderSuggestionsContainer?(children: any): JSX.Element; |
| 93 | + renderInputComponent?(inputProps: InputProps): JSX.Element; |
| 94 | + renderSuggestionsContainer?(containerProps: any, children: any, query: string): JSX.Element; |
74 | 95 | theme?: Theme; |
75 | 96 | id?: string; |
76 | 97 | } |
|
0 commit comments