mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add definitions for ink-text-input
This commit is contained in:
17
types/ink-text-input/index.d.ts
vendored
Normal file
17
types/ink-text-input/index.d.ts
vendored
Normal file
@@ -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 <https://github.com/lukostry>
|
||||
// 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<TextInputProps> { }
|
||||
44
types/ink-text-input/ink-text-input-tests.tsx
Normal file
44
types/ink-text-input/ink-text-input-tests.tsx
Normal file
@@ -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 (
|
||||
<div>
|
||||
Enter your query:
|
||||
|
||||
<TextInput
|
||||
value={state.query}
|
||||
onChange={this.handleChange}
|
||||
onSubmit={this.handleSubmit}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
private handleChange(value: string) {
|
||||
this.setState({
|
||||
query: value,
|
||||
});
|
||||
}
|
||||
|
||||
private handleSubmit(value: string) {
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
24
types/ink-text-input/tsconfig.json
Normal file
24
types/ink-text-input/tsconfig.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
1
types/ink-text-input/tslint.json
Normal file
1
types/ink-text-input/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user