Skip to content

Commit 92b47ca

Browse files
committed
feat: Changed to custom components intead of inkjs
1 parent 2a30c3f commit 92b47ca

6 files changed

Lines changed: 58 additions & 50 deletions

File tree

package-lock.json

Lines changed: 2 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"@codifycli/ink-form": "0.0.12",
88
"@codifycli/schemas": "1.1.0-beta4",
99
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
10-
"@inkjs/ui": "^2",
1110
"@mischnic/json-sourcemap": "^0.1.1",
1211
"@oclif/core": "^4.0.8",
1312
"@oclif/plugin-autocomplete": "^3.2.24",

src/ui/components/default-component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Form, FormProps } from '@codifycli/ink-form';
2-
import { TextInput } from '@inkjs/ui';
32
import chalk from 'chalk';
43
import { Box, Static, Text } from 'ink';
54
import SelectInput from 'ink-select-input';
@@ -21,6 +20,7 @@ import { PlanComponent } from './plan/plan.js';
2120
import { ProgressDisplay } from './progress/progress-display.js';
2221
import { PromptPressKeyToContinue } from './widgets/PromptPressKeyToContinue.js';
2322
import { SudoPasswordInput } from './widgets/SudoPasswordInput.js';
23+
import { TextInput } from './widgets/TextInput.js';
2424

2525
export function DefaultComponent(props: {
2626
emitter: EventEmitter

src/ui/components/import/import-result.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { OrderedList } from '@inkjs/ui';
21
import { Box, Text } from 'ink';
32
import React from 'react';
43

@@ -15,13 +14,11 @@ export function ImportResultComponent(props: {
1514
{
1615
result.length > 0 && !props.showConfigs && (<Box flexDirection="column">
1716
<Text bold={true} color={'green'}>Successfully imported the following configs:</Text>
18-
<OrderedList>
19-
{
20-
result.map((r, idx) => <OrderedList.Item key={idx}>
21-
<Text color={'green'}>{r.type}</Text>
22-
</OrderedList.Item>)
23-
}
24-
</OrderedList>
17+
<Box flexDirection="column">
18+
{result.map((r, idx) => (
19+
<Text key={idx} color={'green'}>{idx + 1}. {r.type}</Text>
20+
))}
21+
</Box>
2522
</Box>)
2623
}
2724
{
@@ -39,13 +36,11 @@ export function ImportResultComponent(props: {
3936
{
4037
errors.length > 0 && (<Box flexDirection="column">
4138
<Text bold={true} color={'yellow'}>The following configs failed to import:</Text>
42-
<OrderedList>
43-
{
44-
errors.map((e, idx) => <OrderedList.Item key={idx}>
45-
<Text color={'yellow'}>{e}</Text>
46-
</OrderedList.Item>)
47-
}
48-
</OrderedList>
39+
<Box flexDirection="column">
40+
{errors.map((e, idx) => (
41+
<Text key={idx} color={'yellow'}>{idx + 1}. {e}</Text>
42+
))}
43+
</Box>
4944
</Box>)
5045
}
5146

src/ui/components/init/InitBanner.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Select } from '@inkjs/ui';
2-
import { Box, Static, Text } from 'ink';
1+
import { Box, Static, Text, useInput } from 'ink';
32
import BigText from 'ink-big-text';
43
import Gradient from 'ink-gradient';
54
import EventEmitter from 'node:events';
@@ -8,6 +7,12 @@ import React from 'react';
87
import { RenderEvent } from '../../reporters/reporter.js';
98

109
export function InitBanner(props: { emitter: EventEmitter }) {
10+
useInput((_, key) => {
11+
if (key.return) {
12+
props.emitter.emit(RenderEvent.PROMPT_RESULT);
13+
}
14+
});
15+
1116
return <Box flexDirection='column'>
1217
<Static items={[{}]}>{
1318
() => <Box flexDirection='column' key='0'>
@@ -20,6 +25,6 @@ export function InitBanner(props: { emitter: EventEmitter }) {
2025
<Text bold>Codify will scan your system for any supported programs or settings and automatically generate configs for you.</Text>
2126
</Box>
2227
}</Static>
23-
<Select onChange={() => { props.emitter.emit(RenderEvent.PROMPT_RESULT); }} options={[{ label: 'Continue', value: 'Continue' }]}/>
28+
<Text dimColor>Press Enter to continue</Text>
2429
</Box>
2530
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Text, useInput } from 'ink';
2+
import React, { useState } from 'react';
3+
4+
export function TextInput(props: {
5+
onSubmit: (value: string) => void;
6+
placeholder?: string;
7+
}) {
8+
const { onSubmit, placeholder } = props;
9+
const [value, setValue] = useState('');
10+
11+
useInput((input, key) => {
12+
if (key.return) {
13+
onSubmit(value);
14+
return;
15+
}
16+
17+
if (key.backspace || key.delete) {
18+
setValue((prev) => prev.slice(0, -1));
19+
return;
20+
}
21+
22+
if (input && !key.ctrl && !key.meta) {
23+
setValue((prev) => prev + input);
24+
}
25+
});
26+
27+
const showPlaceholder = value.length === 0 && placeholder;
28+
29+
return (
30+
<Text>
31+
{showPlaceholder
32+
? <Text dimColor>{placeholder}<Text inverse> </Text></Text>
33+
: <Text>{value}<Text inverse> </Text></Text>
34+
}
35+
</Text>
36+
);
37+
}

0 commit comments

Comments
 (0)