Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: a command menu above an agent's message box

This commit is contained in:
iris 2026-11-15 19:18:07 +01:00 • committed by mara
commit fc650f6af3

View file

@ -24,6 +24,8 @@ export function TextField({
placeholder,
hideLabel,
suggestions,
onKeyDown,
combobox,
}: {
id: string;
label: string;
@ -39,6 +41,16 @@ export function TextField({
/** Values to pick from. The field stays free text: a value that is not in
* the list can still be typed. */
suggestions?: TextFieldSuggestion[];
/** Key presses in the field, for a caller that draws its own menu. */
onKeyDown?: (e: KeyboardEvent) => void;
/** Marks the field as the text box of a menu the caller draws itself. */
combobox?: {
expanded: boolean;
/** The id of the menu's list. */
controls: string;
/** The id of the selected row, when there is one. */
activeDescendant?: string;
};
}) {
const listId = `${id}-suggestions`;
return (
@ -56,6 +68,13 @@ export function TextField({
required={required}
placeholder={placeholder}
list={suggestions ? listId : undefined}
autoComplete={combobox ? "off" : undefined}
role={combobox ? "combobox" : undefined}
aria-expanded={combobox ? combobox.expanded : undefined}
aria-controls={combobox ? combobox.controls : undefined}
aria-activedescendant={combobox?.activeDescendant}
aria-autocomplete={combobox ? "list" : undefined}
onKeyDown={onKeyDown}
onInput={(e) => onInput((e.target as HTMLInputElement).value)}
/>
{suggestions ? (