Add definitions for ink-select-input

This commit is contained in:
lukostry
2019-02-13 14:23:38 +01:00
parent d77c47c753
commit 3a137a2977
4 changed files with 75 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for ink-select-input 2.0
// Project: https://github.com/vadimdemedes/ink-select-input#readme
// Definitions by: Łukasz Ostrowski <https://github.com/lukostry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { Component, InkComponent } from 'ink';
export interface ItemOfSelectInput {
label: string;
value: any;
}
export interface SelectInputProps<T extends ItemOfSelectInput = ItemOfSelectInput> {
focus?: boolean;
indicatorComponent?: InkComponent;
itemComponent?: InkComponent;
items?: ReadonlyArray<T>;
limit?: number;
onSelect?: (item: T) => void;
}
export default class SelectInput extends Component<SelectInputProps> { }
@@ -0,0 +1,27 @@
/** @jsx h */
import { h, InkComponent } from 'ink';
import SelectInput from 'ink-select-input';
interface DemoItem {
label: string;
value: string;
}
const items: ReadonlyArray<DemoItem> = [{
label: 'First',
value: 'first'
}, {
label: 'Second',
value: 'second'
}, {
label: 'Third',
value: 'third'
}];
const Demo: InkComponent = () => {
const handleSelect = (item: DemoItem) => {
console.log(item);
};
return <SelectInput items={items} onSelect={handleSelect} />;
};
+24
View 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-select-input-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }