mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
* Support Partial<> on setState now that TS 2.1 is out * Update readme to reflect setState being typed correctly * Switch setState to Pick * Restore cloneELement portion of readme * Use Pick<> | S for setState due to cast issue * state and props should be readonly * Fix nit + document why we * Add typescript compiler header * Update to properly order headers * Update readme to reflect 2.1.5 fixing stPick * Update readme now that 2.1.5 is out * All that depend on react now require 2.1 * Fix definition that fails due to readonly state
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
// Type definitions for react-autosuggest 7.0
|
|
// Project: http://react-autosuggest.js.org/
|
|
// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt>, Philip Ottesen <https://github.com/pjo256>, Robert Essig <https://github.com/robessog>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.1
|
|
|
|
import * as React from 'react';
|
|
|
|
interface SuggestionsFetchRequest {
|
|
value: string;
|
|
reason: string;
|
|
}
|
|
|
|
interface InputValues {
|
|
value: string;
|
|
valueBeforeUpDown?: string;
|
|
}
|
|
|
|
interface ChangeEvent {
|
|
newValue: string;
|
|
method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type';
|
|
}
|
|
|
|
interface BlurEvent {
|
|
focusedSuggestion: any;
|
|
}
|
|
|
|
interface InputProps extends React.HTMLAttributes<any> {
|
|
value: string;
|
|
onChange: (event: React.FormEvent<any>, params?: ChangeEvent) => void;
|
|
onBlur?: (event: React.FormEvent<any>, params?: BlurEvent) => void;
|
|
}
|
|
|
|
export interface SuggestionSelectedEventData<TSuggestion> {
|
|
method: 'click' | 'enter';
|
|
sectionIndex: number | null;
|
|
suggestion: TSuggestion;
|
|
suggestionValue: string;
|
|
}
|
|
|
|
interface Theme {
|
|
container?: string;
|
|
containerOpen?: string;
|
|
input?: string;
|
|
sectionContainer?: string;
|
|
sectionSuggestionsContainer?: string;
|
|
sectionTitle?: string;
|
|
suggestion?: string;
|
|
suggestionFocused?: string;
|
|
suggestionsContainer?: string;
|
|
}
|
|
|
|
interface AutosuggestProps extends React.Props<Autosuggest> {
|
|
suggestions: any[];
|
|
onSuggestionsFetchRequested: (request: SuggestionsFetchRequest) => void;
|
|
onSuggestionsClearRequested?: () => void;
|
|
getSuggestionValue: (suggestion: any) => any;
|
|
renderSuggestion: (suggestion: any, inputValues: InputValues) => JSX.Element;
|
|
inputProps: InputProps;
|
|
onSuggestionSelected?: (event: React.FormEvent<any>, data: SuggestionSelectedEventData<any>) => void;
|
|
shouldRenderSuggestions?: (value: string) => boolean;
|
|
alwaysRenderSuggestions?: boolean;
|
|
focusFirstSuggestion?: boolean;
|
|
focusInputOnSuggestionClick?: boolean;
|
|
multiSection?: boolean;
|
|
renderSectionTitle?: (section: any, inputValues: InputValues) => JSX.Element;
|
|
getSectionSuggestions?: (section: any) => any[];
|
|
renderInputComponent?: () => JSX.Element;
|
|
renderSuggestionsContainer?: (children: any) => JSX.Element;
|
|
theme?: Theme;
|
|
id?: string;
|
|
}
|
|
|
|
export class Autosuggest extends React.Component<any, any> {}
|