Merge branch 'main' into add-dropdowns-for-enums
This commit is contained in:
commit
097e2dd722
2 changed files with 25 additions and 4 deletions
|
|
@ -63,9 +63,7 @@ const PromptsTab = ({
|
||||||
clearCompletions();
|
clearCompletions();
|
||||||
}, [clearCompletions, selectedPrompt]);
|
}, [clearCompletions, selectedPrompt]);
|
||||||
|
|
||||||
const handleInputChange = async (argName: string, value: string) => {
|
const triggerCompletions = (argName: string, value: string) => {
|
||||||
setPromptArgs((prev) => ({ ...prev, [argName]: value }));
|
|
||||||
|
|
||||||
if (selectedPrompt) {
|
if (selectedPrompt) {
|
||||||
requestCompletions(
|
requestCompletions(
|
||||||
{
|
{
|
||||||
|
|
@ -79,6 +77,16 @@ const PromptsTab = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleInputChange = async (argName: string, value: string) => {
|
||||||
|
setPromptArgs((prev) => ({ ...prev, [argName]: value }));
|
||||||
|
triggerCompletions(argName, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFocus = async (argName: string) => {
|
||||||
|
const currentValue = promptArgs[argName] || "";
|
||||||
|
triggerCompletions(argName, currentValue);
|
||||||
|
};
|
||||||
|
|
||||||
const handleGetPrompt = () => {
|
const handleGetPrompt = () => {
|
||||||
if (selectedPrompt) {
|
if (selectedPrompt) {
|
||||||
getPrompt(selectedPrompt.name, promptArgs);
|
getPrompt(selectedPrompt.name, promptArgs);
|
||||||
|
|
@ -143,6 +151,7 @@ const PromptsTab = ({
|
||||||
onInputChange={(value) =>
|
onInputChange={(value) =>
|
||||||
handleInputChange(arg.name, value)
|
handleInputChange(arg.name, value)
|
||||||
}
|
}
|
||||||
|
onFocus={() => handleFocus(arg.name)}
|
||||||
options={completions[arg.name] || []}
|
options={completions[arg.name] || []}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ interface ComboboxProps {
|
||||||
value: string;
|
value: string;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
onInputChange: (value: string) => void;
|
onInputChange: (value: string) => void;
|
||||||
|
onFocus?: () => void;
|
||||||
options: string[];
|
options: string[];
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
emptyMessage?: string;
|
emptyMessage?: string;
|
||||||
|
|
@ -29,6 +30,7 @@ export function Combobox({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
onInputChange,
|
onInputChange,
|
||||||
|
onFocus,
|
||||||
options = [],
|
options = [],
|
||||||
placeholder = "Select...",
|
placeholder = "Select...",
|
||||||
emptyMessage = "No results found.",
|
emptyMessage = "No results found.",
|
||||||
|
|
@ -36,6 +38,16 @@ export function Combobox({
|
||||||
}: ComboboxProps) {
|
}: ComboboxProps) {
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
|
const handleOpenChange = React.useCallback(
|
||||||
|
(newOpen: boolean) => {
|
||||||
|
setOpen(newOpen);
|
||||||
|
if (newOpen && onFocus) {
|
||||||
|
onFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[onFocus],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSelect = React.useCallback(
|
const handleSelect = React.useCallback(
|
||||||
(option: string) => {
|
(option: string) => {
|
||||||
onChange(option);
|
onChange(option);
|
||||||
|
|
@ -52,7 +64,7 @@ export function Combobox({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover open={open} onOpenChange={setOpen}>
|
<Popover open={open} onOpenChange={handleOpenChange}>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue