Do not use default export, align indentation

This commit is contained in:
lukostry
2019-02-18 12:44:53 +01:00
parent 3a137a2977
commit 0dd0e94685
3 changed files with 25 additions and 17 deletions
+5 -3
View File
@@ -6,12 +6,12 @@
import { Component, InkComponent } from 'ink';
export interface ItemOfSelectInput {
interface ItemOfSelectInput {
label: string;
value: any;
}
export interface SelectInputProps<T extends ItemOfSelectInput = ItemOfSelectInput> {
interface SelectInputProps<T extends ItemOfSelectInput = ItemOfSelectInput> {
focus?: boolean;
indicatorComponent?: InkComponent;
itemComponent?: InkComponent;
@@ -20,4 +20,6 @@ export interface SelectInputProps<T extends ItemOfSelectInput = ItemOfSelectInpu
onSelect?: (item: T) => void;
}
export default class SelectInput extends Component<SelectInputProps> { }
declare class SelectInput extends Component<SelectInputProps> { }
export = SelectInput;
@@ -1,27 +1,32 @@
/** @jsx h */
import { h, InkComponent } from 'ink';
import SelectInput from 'ink-select-input';
// NOTE: `import SelectInput = require('ink-select-input');` will work as well.
// If importing using ES6 default import as above,
// `allowSyntheticDefaultImports` flag in compiler options needs to be set to `true`
interface DemoItem {
label: string;
value: string;
label: string;
value: string;
}
const items: ReadonlyArray<DemoItem> = [{
label: 'First',
value: 'first'
}, {
label: 'Second',
value: 'second'
}, {
label: 'Third',
value: 'third'
label: 'First',
value: 'first'
},
{
label: 'Second',
value: 'second'
},
{
label: 'Third',
value: 'third'
}];
const Demo: InkComponent = () => {
const handleSelect = (item: DemoItem) => {
console.log(item);
};
const handleSelect = (item: DemoItem) => {
console.log(item);
};
return <SelectInput items={items} onSelect={handleSelect} />;
return <SelectInput items={items} onSelect={handleSelect} />;
};
+1
View File
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"jsx": "react",
"module": "commonjs",
"lib": [