@mcp-b/react-components 0.46.0 → 0.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1026,6 +1026,7 @@ function composerLinksToReferences(text) {
1026
1026
  */
1027
1027
  function PromptInputCommandComposer({ commands, mentionCommands, value, onValueChange, onCommandSelect, emptyMessage = "No commands found.", mentionEmptyMessage = "No MCP servers found.", onKeyDown, ref, placeholder, disabled, className, minHeight, maxHeight, "aria-label": ariaLabel }) {
1028
1028
  const inputRef = React.useRef(null);
1029
+ const highlightedCommandRef = React.useRef(void 0);
1029
1030
  const [dismissedValue, setDismissedValue] = React.useState(null);
1030
1031
  React.useImperativeHandle(ref, () => inputRef.current, []);
1031
1032
  const match = composerTriggerMatch(value);
@@ -1041,7 +1042,7 @@ function PromptInputCommandComposer({ commands, mentionCommands, value, onValueC
1041
1042
  ...command.keywords ?? []
1042
1043
  ].filter((term) => Boolean(term)).some((term) => term.toLocaleLowerCase().includes(normalizedQuery));
1043
1044
  });
1044
- const hasTriggeredCatalog = trigger === "/" ? commands.length > 0 : trigger === "@" && mentionCommands !== void 0;
1045
+ const hasTriggeredCatalog = trigger === "/" ? commands.length > 0 && (match?.triggerIndex === 0 || filtered.length > 0) : trigger === "@" && mentionCommands !== void 0;
1045
1046
  const open = Boolean(match && hasTriggeredCatalog) && dismissedValue !== value;
1046
1047
  const groups = Array.from(new Set(filtered.map((command) => command.group ?? ""))).map((label) => ({
1047
1048
  label,
@@ -1061,6 +1062,9 @@ function PromptInputCommandComposer({ commands, mentionCommands, value, onValueC
1061
1062
  open,
1062
1063
  autoHighlight: true,
1063
1064
  itemToStringValue: (command) => command.value,
1065
+ onItemHighlighted: (command) => {
1066
+ highlightedCommandRef.current = command;
1067
+ },
1064
1068
  onValueChange: (next, { reason }) => {
1065
1069
  if (reason !== "input-change") return;
1066
1070
  setDismissedValue(null);
@@ -1076,7 +1080,16 @@ function PromptInputCommandComposer({ commands, mentionCommands, value, onValueC
1076
1080
  setDismissedValue(null);
1077
1081
  onValueChange(next);
1078
1082
  },
1079
- onKeyDown,
1083
+ onKeyDown: (event) => {
1084
+ onKeyDown?.(event);
1085
+ if (event.defaultPrevented || event.key !== "Enter" || !open) return;
1086
+ const highlightedCommand = highlightedCommandRef.current;
1087
+ if (highlightedCommand && !highlightedCommand.disabled && filtered.includes(highlightedCommand)) return;
1088
+ const command = filtered.find((candidate) => !candidate.disabled);
1089
+ if (!command) return;
1090
+ event.preventDefault();
1091
+ selectCommand(command);
1092
+ },
1080
1093
  placeholder,
1081
1094
  disabled,
1082
1095
  className,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-b/react-components",
3
- "version": "0.46.0",
3
+ "version": "0.46.2",
4
4
  "description": "MCP-B React components built on Base UI and shared design tokens, including Cloudflare Think chat primitives.",
5
5
  "homepage": "https://design-system.sigvelo.com",
6
6
  "bugs": {
@@ -53,7 +53,7 @@
53
53
  "streamdown": "^2.5.0",
54
54
  "unist-util-visit": "^5.1.0",
55
55
  "yet-another-react-lightbox": "^3.32.2",
56
- "@mcp-b/design-tokens": "0.46.0"
56
+ "@mcp-b/design-tokens": "0.46.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@ai-sdk/react": "^3.0.249",