From e2dfe19ed6933f3ef6c9016b2143dbf1450334f0 Mon Sep 17 00:00:00 2001 From: Michael Macnair Date: Fri, 1 Dec 2017 21:22:17 +0000 Subject: [PATCH] Add react-tagsinput definition --- types/react-tagsinput/index.d.ts | 47 +++++++++++++++++++ .../react-tagsinput/react-tagsinput-tests.tsx | 23 +++++++++ types/react-tagsinput/tsconfig.json | 24 ++++++++++ types/react-tagsinput/tslint.json | 1 + 4 files changed, 95 insertions(+) create mode 100644 types/react-tagsinput/index.d.ts create mode 100644 types/react-tagsinput/react-tagsinput-tests.tsx create mode 100644 types/react-tagsinput/tsconfig.json create mode 100644 types/react-tagsinput/tslint.json diff --git a/types/react-tagsinput/index.d.ts b/types/react-tagsinput/index.d.ts new file mode 100644 index 0000000000..5c569df07d --- /dev/null +++ b/types/react-tagsinput/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for react-tagsinput 3.19 +// Project: https://github.com/olahol/react-tagsinput +// Definitions by: Michael Macnair +// 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 { + accept(): any; + addTag(tag: string): any; + blur(): void; + clearInput(): void; + focus(): void; +} + +declare namespace TagsInput { + interface ReactTagsInputProps extends React.Props { + 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; + } +} diff --git a/types/react-tagsinput/react-tagsinput-tests.tsx b/types/react-tagsinput/react-tagsinput-tests.tsx new file mode 100644 index 0000000000..8a3a113227 --- /dev/null +++ b/types/react-tagsinput/react-tagsinput-tests.tsx @@ -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 ( + + ); + } +} diff --git a/types/react-tagsinput/tsconfig.json b/types/react-tagsinput/tsconfig.json new file mode 100644 index 0000000000..1e9342e032 --- /dev/null +++ b/types/react-tagsinput/tsconfig.json @@ -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" + ] +} diff --git a/types/react-tagsinput/tslint.json b/types/react-tagsinput/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-tagsinput/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }