diff --git a/types/ink-select-input/index.d.ts b/types/ink-select-input/index.d.ts new file mode 100644 index 0000000000..2dc38d2a86 --- /dev/null +++ b/types/ink-select-input/index.d.ts @@ -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 +// 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 { + focus?: boolean; + indicatorComponent?: InkComponent; + itemComponent?: InkComponent; + items?: ReadonlyArray; + limit?: number; + onSelect?: (item: T) => void; +} + +export default class SelectInput extends Component { } diff --git a/types/ink-select-input/ink-select-input-tests.tsx b/types/ink-select-input/ink-select-input-tests.tsx new file mode 100644 index 0000000000..4120cbf43e --- /dev/null +++ b/types/ink-select-input/ink-select-input-tests.tsx @@ -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 = [{ + label: 'First', + value: 'first' +}, { + label: 'Second', + value: 'second' +}, { + label: 'Third', + value: 'third' +}]; + +const Demo: InkComponent = () => { + const handleSelect = (item: DemoItem) => { + console.log(item); + }; + + return ; +}; diff --git a/types/ink-select-input/tsconfig.json b/types/ink-select-input/tsconfig.json new file mode 100644 index 0000000000..4ae1e800aa --- /dev/null +++ b/types/ink-select-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-select-input-tests.tsx" + ] +} diff --git a/types/ink-select-input/tslint.json b/types/ink-select-input/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ink-select-input/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }