mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Initial typings for react-autosuggest (#9184)
* Initial react-autosuggest typings * Fixed tests
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/// <reference path="react-autosuggest.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
import Autosuggest = require('react-autosuggest');
|
||||
import * as React from 'react';
|
||||
|
||||
let autosuggest = <Autosuggest
|
||||
suggestions={[{name: "C", year: "1972" }, {name: "Elm", year: "2012" }]}
|
||||
getSuggestionValue={(suggestion: any) => suggestion.name}
|
||||
renderSuggestion={(suggestion: any) => (<span>{suggestion.name}</span>)}
|
||||
inputProps={{value: "El", onChange: (event: any, params: {newValue: string, method: string}) => {}}}
|
||||
/>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// Type definitions for react-autosuggest 3.7.1
|
||||
// Project: https://github.com/moroshko/react-autosuggest
|
||||
// Definitions by: Stephen Jelfs <https://github.com/stephenjelfs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "react-autosuggest" {
|
||||
interface Suggestion {
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface Theme {
|
||||
container?: string;
|
||||
containerOpen?: string;
|
||||
input?: string;
|
||||
suggestionsContainer?: string;
|
||||
suggestion?: string;
|
||||
suggestionFocused?: string;
|
||||
sectionContainer?: string;
|
||||
sectionTitle?: string;
|
||||
sectionSuggestionsContainer?: string;
|
||||
}
|
||||
|
||||
interface InputProps {
|
||||
value: string;
|
||||
onChange: (event: any, params: {newValue: string, method: string}) => void;
|
||||
type?: string;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
interface AutosuggestProps extends __React.Props<Autosuggest> {
|
||||
suggestions: any[];
|
||||
onSuggestionsUpdateRequested?: (params: {value: string, reason: string}) => void;
|
||||
getSuggestionValue: (suggestion: any) => string;
|
||||
renderSuggestion: (suggestion: any, params: {value: string, valueBeforeUpDown: string}) => __React.ReactElement<any>;
|
||||
inputProps: InputProps;
|
||||
shouldRenderSuggestions?: (value: string) => boolean;
|
||||
multiSection?: boolean;
|
||||
renderSectionTitle?: (section: any) => __React.ReactElement<any>;
|
||||
getSectionSuggestions?: (section: any) => any[];
|
||||
onSuggestionSelected?: (event: any, params: {suggestion: any, suggestionValue: string, method: string}) => void;
|
||||
focusInputOnSuggestionClick?: boolean;
|
||||
theme?: Theme;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
class Autosuggest extends __React.Component<AutosuggestProps, {}> {}
|
||||
|
||||
export = Autosuggest;
|
||||
}
|
||||
Reference in New Issue
Block a user