diff --git a/types/react-tagsinput/index.d.ts b/types/react-tagsinput/index.d.ts index 5c569df07d..6b4d92b3b7 100644 --- a/types/react-tagsinput/index.d.ts +++ b/types/react-tagsinput/index.d.ts @@ -9,18 +9,42 @@ import * as React from "react"; export as namespace ReactTagsInput; export = TagsInput; +type Tag = any; + declare class TagsInput extends React.Component { accept(): any; - addTag(tag: string): any; + addTag(tag: Tag): any; blur(): void; clearInput(): void; focus(): void; } declare namespace TagsInput { + interface InputProps { + readonly [prop: string]: any; + } + + interface RenderInputProps extends InputProps { + readonly addTag: (tag: Tag) => void; + readonly onChange: (e: React.ChangeEvent<{ readonly value: string }>) => void; + readonly ref: (r: any) => void; // parameter is either a DOM element or a mounted React component + readonly value: Tag; + } + + interface TagProps { + readonly [prop: string]: any; + } + + interface RenderTagProps extends TagProps { + readonly disabled: boolean; + readonly getTagDisplayValue: (tag: Tag) => string; + readonly onRemove: (tagIndex: number) => void; + readonly tag: Tag; + } + interface ReactTagsInputProps extends React.Props { - value: string[]; - onChange: (tags: string[], changed: string[], changedIndexes: number[]) => void; + value: Tag[]; + onChange: (tags: Tag[], changed: Tag[], changedIndexes: number[]) => void; onChangeInput?: (value: string) => void; addKeys?: number[]; currentValue?: string; @@ -36,12 +60,12 @@ declare namespace TagsInput { removeKeys?: number[]; className?: string; focusedClassName?: string; - tagProps?: any; - inputProps?: any; + tagProps?: TagProps; + inputProps?: InputProps; tagDisplayProp?: string | null; - renderTag?: (props: any) => React.Component; - renderInput?: (props: any) => React.Component; - renderLayout?: (tagComponents: React.Component[], inputComponent: React.Component) => any; + renderTag?: (props: RenderTagProps) => React.ReactNode; + renderInput?: (props: RenderInputProps) => React.ReactNode; + renderLayout?: (tagComponents: React.Component[], inputComponent: React.Component) => React.ReactChild; preventSubmit?: boolean; } }