diff --git a/react-autosuggest/index.d.ts b/react-autosuggest/index.d.ts index cfec62d047..739509bdef 100644 --- a/react-autosuggest/index.d.ts +++ b/react-autosuggest/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-autosuggest v3.7.3 // Project: http://react-autosuggest.js.org/ -// Definitions by: Nicolas Schmitt +// Definitions by: Nicolas Schmitt , Philip Ottesen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -16,14 +16,24 @@ declare namespace ReactAutosuggest { valueBeforeUpDown?: string; } + interface ChangeEvent { + newValue: string; + method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type'; + } + + interface BlurEvent { + focusedSuggestion: any; + } + interface InputProps extends React.HTMLAttributes { value: string; - onChange: (event: React.FormEvent, params?: {newValue: string, method: string}) => void; + onChange: (event: React.FormEvent, params?: ChangeEvent) => void; + onBlur?: (event: React.FormEvent, params?: BlurEvent) => void; } interface ExplicitSuggestionSelectedEventData { - method: string; - sectionIndex: number; + method: 'click' | 'enter'; + sectionIndex: number | null; suggestion: TSuggestion; suggestionValue: string; } @@ -32,15 +42,15 @@ declare namespace ReactAutosuggest { } interface Theme { - container: string; - containerOpen: string; - input: string; - sectionContainer: string; - sectionSuggestionsContainer: string; - sectionTitle: string; - suggestion: string; - suggestionFocused: string; - suggestionsContainer: string; + container?: string; + containerOpen?: string; + input?: string; + sectionContainer?: string; + sectionSuggestionsContainer?: string; + sectionTitle?: string; + suggestion?: string; + suggestionFocused?: string; + suggestionsContainer?: string; } interface AutosuggestProps extends React.Props { @@ -49,6 +59,7 @@ declare namespace ReactAutosuggest { getSuggestionValue: (suggestion: any) => string; renderSuggestion: (suggestion: any, inputValues: InputValues) => JSX.Element; inputProps: InputProps; + alwaysRenderSuggestions?: boolean; shouldRenderSuggestions?: (value: string) => boolean; multiSection?: boolean; renderSectionTitle?: (section: any, inputValues: InputValues) => JSX.Element; diff --git a/react-autosuggest/react-autosuggest-tests.tsx b/react-autosuggest/react-autosuggest-tests.tsx index 5a107fe525..d3d4278829 100644 --- a/react-autosuggest/react-autosuggest-tests.tsx +++ b/react-autosuggest/react-autosuggest-tests.tsx @@ -55,12 +55,21 @@ export class ReactAutosuggestBasicTest extends React.Component { onChange: this.onChange.bind(this) }; + const theme = { + input: 'themed-input-class', + container: 'themed-container-class', + suggestionFocused: 'active' + } + return ; + alwaysRenderSuggestions={true} + inputProps={inputProps} + theme={theme} + />; } protected onSuggestionsSelected(event: React.FormEvent, data: ReactAutosuggest.ExplicitSuggestionSelectedEventData): void { @@ -306,7 +315,7 @@ export class ReactAutosuggestCustomTest extends React.Component { { parts.map((part, index) => { - const className = part.highlight ? 'highlight' : null; + const className = part.highlight ? 'highlight' : undefined; return {part.text}; }) diff --git a/react-autosuggest/tsconfig.json b/react-autosuggest/tsconfig.json index 6c2ea102f6..07f6b45bf7 100644 --- a/react-autosuggest/tsconfig.json +++ b/react-autosuggest/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../"