diff --git a/types/ink-text-input/index.d.ts b/types/ink-text-input/index.d.ts new file mode 100644 index 0000000000..1d7192e1dc --- /dev/null +++ b/types/ink-text-input/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for ink-text-input 2.0 +// Project: https://github.com/vadimdemedes/ink-text-input#readme +// Definitions by: Ɓukasz Ostrowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Component } from 'ink'; + +export interface TextInputProps { + focus?: boolean; + onChange?: (value: string) => void; + onSubmit?: (value: string) => void; + placeholder?: string; + value?: string; +} + +export default class TextInput extends Component { } diff --git a/types/ink-text-input/ink-text-input-tests.tsx b/types/ink-text-input/ink-text-input-tests.tsx new file mode 100644 index 0000000000..ada8ab3a83 --- /dev/null +++ b/types/ink-text-input/ink-text-input-tests.tsx @@ -0,0 +1,44 @@ +/** @jsx h */ +import { h, Component } from 'ink'; +import TextInput from 'ink-text-input'; + +interface QueryState { + query: string; +} + +class SearchQuery extends Component { + constructor() { + super(); + + this.state = { + query: '' + }; + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + render(props: {}, state: QueryState) { + return ( +
+ Enter your query: + + +
+ ); + } + + private handleChange(value: string) { + this.setState({ + query: value, + }); + } + + private handleSubmit(value: string) { + console.log(value); + } +} diff --git a/types/ink-text-input/tsconfig.json b/types/ink-text-input/tsconfig.json new file mode 100644 index 0000000000..f58efc92ff --- /dev/null +++ b/types/ink-text-input/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "jsx": "react", + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ink-text-input-tests.tsx" + ] +} diff --git a/types/ink-text-input/tslint.json b/types/ink-text-input/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ink-text-input/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }