refactor(cli): remove unused Spinner import

The unnecessary Spinner import from 'ink-spinner' was removed in the SearchBox component. This reduces clutter and enhances code readability.
This commit is contained in:
p-sw 2024-06-08 02:05:21 +09:00
parent 36f465f2cf
commit 803659a06b

View File

@ -2,7 +2,6 @@ import React, {useEffect, useState} from 'react'
import {getSuggestion} from '../helpers/search.js' import {getSuggestion} from '../helpers/search.js'
import Input from 'ink-text-input' import Input from 'ink-text-input'
import {Divider} from './Divider.js' import {Divider} from './Divider.js'
import Spinner from 'ink-spinner'
import {Box, Text, useInput, useApp, type Key} from 'ink' import {Box, Text, useInput, useApp, type Key} from 'ink'
export function SearchBox<T extends {key: string; displayName: string}>({ export function SearchBox<T extends {key: string; displayName: string}>({
@ -68,21 +67,17 @@ export function SearchBox<T extends {key: string; displayName: string}>({
<Input value={query} onChange={(v) => setQuery(v)} showCursor placeholder={'query'} onSubmit={onSubmit} /> <Input value={query} onChange={(v) => setQuery(v)} showCursor placeholder={'query'} onSubmit={onSubmit} />
</Box> </Box>
<Divider title={isLoading ? 'Loading...' : `${suggestions.length} components found.`} /> <Divider title={isLoading ? 'Loading...' : `${suggestions.length} components found.`} />
{isLoading ? ( <Box display={'flex'} flexDirection={'column'}>
<Spinner /> {suggestions.map((name, index) => {
) : ( return (
<Box display={'flex'} flexDirection={'column'}> <Box key={name}>
{suggestions.map((name, index) => { <Text color={selected === index ? undefined : 'gray'}>
return ( {components[components.findIndex(({key}) => key === name)].displayName}
<Box key={name}> </Text>
<Text color={selected === index ? undefined : 'gray'}> </Box>
{components[components.findIndex(({key}) => key === name)].displayName} )
</Text> })}
</Box> </Box>
)
})}
</Box>
)}
</Box> </Box>
) )
} }