mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Add definitions for ink-select-input
This commit is contained in:
Vendored
+23
@@ -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} />;
|
||||
};
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user