From 3e0d29fd56097733143e63f3062e57a39a5a014a Mon Sep 17 00:00:00 2001 From: p-sw Date: Fri, 7 Jun 2024 21:37:42 +0900 Subject: [PATCH] feat(cli): add initialQuery prop to SearchBox The SearchBox component in the Command Line Interface (CLI) now accepts an optional initialQuery prop. This prop is used to set the initial state of the search box query, which enables prepopulating the search box with a specific string if desired. --- packages/cli/src/components/SearchBox.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/components/SearchBox.tsx b/packages/cli/src/components/SearchBox.tsx index 049d009..e40ee21 100644 --- a/packages/cli/src/components/SearchBox.tsx +++ b/packages/cli/src/components/SearchBox.tsx @@ -5,8 +5,16 @@ import {Divider} from './Divider.js' import Spinner from 'ink-spinner' import {Box, Text} from 'ink' -export function SearchBox({components, helper}: {components: string[]; helper: string}) { - const [query, setQuery] = useState('') +export function SearchBox({ + components, + helper, + initialQuery, +}: { + components: string[] + helper: string + initialQuery?: string +}) { + const [query, setQuery] = useState(initialQuery ?? '') const [isLoading, setLoading] = useState(false) const [suggestions, setSuggestions] = useState([])