mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 03:02:04 +08:00
Merge pull request #21898 from mykter/master
Add react-tagsinput definition
This commit is contained in:
47
types/react-tagsinput/index.d.ts
vendored
Normal file
47
types/react-tagsinput/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
23
types/react-tagsinput/react-tagsinput-tests.tsx
Normal file
23
types/react-tagsinput/react-tagsinput-tests.tsx
Normal 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} />
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-tagsinput/tsconfig.json
Normal file
24
types/react-tagsinput/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/react-tagsinput/tslint.json
Normal file
1
types/react-tagsinput/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user