Skip to content

Instantly share code, notes, and snippets.

@bertrandk
Last active March 3, 2016 04:36
Show Gist options
  • Save bertrandk/81fc6f066aedcc402417 to your computer and use it in GitHub Desktop.
Save bertrandk/81fc6f066aedcc402417 to your computer and use it in GitHub Desktop.
Typescript React Select
/// <reference path="../react/react.d.ts" />
declare namespace ReactSelect {
import React = __React;
interface Option {
label: string;
value: string;
}
interface ReactSelectProps extends React.Props<ReactSelectClass>{
addLabelText?: string;
allowCreate?: boolean;
autoload?: boolean;
backspaceRemoves?: boolean;
cacheAsyncResults?: boolean;
className?: string;
clearable?: boolean;
clearAllText?: string;
clearValueText?: string;
delimiter?: string;
disabled?: boolean;
filterOption?: (option: Option, filterString: string) => Option;
filterOptions?: (options: Array<Option>, filterString: string, values: Array<Object>) => Array<Option>;
ignoreCase?: boolean;
inputProps?: Object;
isLoading?: boolean;
labelKey?: string;
matchPos?: string;
matchProp?: string;
multi?: boolean;
name?: string;
newOptionCreator?: () => Option;
noResultsText?: string;
onBlur?: (event: Event) => void;
onChange?: (newValue: string) => void;
onFocus?: (event: Event) => void;
onInputChange?: (inputValue: string) => void;
onOptionLabelClick?: (value: string, event: Event) => void;
optionRenderer?: () => void;
options?: Array<Option>;
placeholder?: string;
searchable?: boolean;
searchingText?: string;
searchPromptText?: string;
value?: any;
valueKey?: string;
valueRenderer?: () => void;
}
interface ReactAsyncSelectProps extends React.Props<ReactSelectClass> {
cache?: any;
loadOptions?: () => void;
ignoreAccents?: boolean;
isLoading?: boolean;
loadingPlaceholder?: string;
}
interface ReactSelect extends React.ReactElement<ReactSelectProps> {}
interface ReactSelectClass extends React.ComponentClass<ReactSelectProps> {}
interface SelectWithAsync extends ReactSelectClass {
Async? : ReactAsyncSelectProps;
}
var ReactSelecStatict: SelectWithAsync;
}
declare module "react-select" {
export = ReactSelect.ReactSelecStatict;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment