-
-
{
- const nextQuery = event.target.value;
- setQuery(nextQuery);
- if (!nextQuery.startsWith(">")) setThreadItems([]);
+
Quick palette
+ {activeMode === undefined ? (
+
+ )
+ }
+ inputLabel={PALETTE_PLACEHOLDER}
+ listId={listId}
+ listLabel="Commands"
+ listRef={listRef}
+ onInputChange={(value) => {
+ setQuery(value);
setHighlightedIndex(0);
// `activeIndex` may not change, so the effect above cannot do
// this: send the scrolled container back to the first row.
if (listRef.current !== null) listRef.current.scrollTop = 0;
}}
- onKeyDown={handleKeyDown}
+ onInputKeyDown={handleKeyDown}
+ placeholder={PALETTE_PLACEHOLDER}
+ value={query}
+ >
+ {!isGroupedRoot && visibleEntries.length === 0 ? (
+
+ No matching commands
+
+ ) : isGroupedRoot ? (
+ rootGroups.map((group, groupIndex) => {
+ const labelId = `${optionIdPrefix}-${group.bucket.toLowerCase()}-label`;
+ return (
+
+
+ {group.bucket}
+
+ {group.entries.map((entry, index) => {
+ const visibleIndex = group.startIndex + index;
+ return (
+
setHighlightedIndex(visibleIndex)}
+ onSelect={() => chooseAction(entry.action)}
+ />
+ );
+ })}
+
+ );
+ })
+ ) : (
+ visibleEntries.map((entry, index) => (
+
setHighlightedIndex(index)}
+ onSelect={() => chooseAction(entry.action)}
+ />
+ ))
+ )}
+
+ ) : (
+ {
+ setActiveModeId(null);
+ setQuery("");
+ setHighlightedIndex(0);
+ }}
+ runAfterClose={runAfterClose}
/>
-
-
- {mode === "commands" && rankedCommands.length === 0 ? (
-
- No matching commands
-
- ) : mode === "commands" ? (
- rankedCommands.map((entry, index) => (
-
setHighlightedIndex(index)}
- onSelect={() => chooseAction(entry.action)}
- />
- ))
- ) : (
-
- )}
-
+ )}