Merge pull request #21898 from mykter/master

Add react-tagsinput definition
This commit is contained in:
Armando Aguirre
2017-12-01 18:03:07 -08:00
committed by GitHub
4 changed files with 95 additions and 0 deletions

47
types/react-tagsinput/index.d.ts vendored Normal file
View File

@@ -0,0 +1,47 @@
// Type definitions for react-tagsinput 3.19
// Project: https://github.com/olahol/react-tagsinput
// Definitions by: Michael Macnair <https://github.com/mykter>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from "react";
export as namespace ReactTagsInput;
export = TagsInput;
declare class TagsInput extends React.Component<TagsInput.ReactTagsInputProps> {
accept(): any;
addTag(tag: string): any;
blur(): void;
clearInput(): void;
focus(): void;
}
declare namespace TagsInput {
interface ReactTagsInputProps extends React.Props<TagsInput> {
value: string[];
onChange: (tags: string[], changed: string[], changedIndexes: number[]) => void;
onChangeInput?: (value: string) => void;
addKeys?: number[];
currentValue?: string;
inputValue?: string;
onlyUnique?: boolean;
validationRegex?: RegExp;
onValidationReject?: (tags: string[]) => void;
disabled?: boolean;
maxTags?: number;
addOnBlur?: boolean;
addOnPaste?: boolean;
pasteSplit?: (data: string) => string[];
removeKeys?: number[];
className?: string;
focusedClassName?: string;
tagProps?: any;
inputProps?: any;
tagDisplayProp?: string | null;
renderTag?: (props: any) => React.Component;
renderInput?: (props: any) => React.Component;
renderLayout?: (tagComponents: React.Component[], inputComponent: React.Component) => any;
preventSubmit?: boolean;
}
}

View File

@@ -0,0 +1,23 @@
import * as React from 'react';
import * as TagsInput from 'react-tagsinput';
interface StateI {
tags: string[];
}
class Example extends React.Component<{}, StateI> {
constructor(props: {}) {
super(props);
this.state = {tags: []};
}
handleChange(tags: string[]) {
this.setState({tags});
}
render() {
return (
<TagsInput value={this.state.tags} onChange={this.handleChange} />
);
}
}

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-tagsinput-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }