mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Improve react-tagsinput definitions (#22069)
* Improve react-tagsinput definitions Based on https://github.com/samwise-tech/components (MIT licence) * Fix react-tagsinput 'ref' param
This commit is contained in:
committed by
Mohamed Hegazy
parent
5ca3612206
commit
f7f7d4df0a
Vendored
+32
-8
@@ -9,18 +9,42 @@ import * as React from "react";
|
||||
export as namespace ReactTagsInput;
|
||||
export = TagsInput;
|
||||
|
||||
type Tag = any;
|
||||
|
||||
declare class TagsInput extends React.Component<TagsInput.ReactTagsInputProps> {
|
||||
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<TagsInput> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user