{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slash-menu-demo",
  "title": "Slash Menu Demo",
  "description": "A worked example of Slash Menu: A message field that opens a command menu when a word starts with a slash, then spells out the chosen command's arguments and marks the one you are typing.",
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/slash-menu.json"
  ],
  "files": [
    {
      "path": "components/demos/slash-menu-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  parseSlashCommand,\n  SlashMenu,\n  type SlashCommand,\n} from \"@/registry/default/slash-menu/slash-menu\"\n\nconst commands: SlashCommand[] = [\n  {\n    name: \"translate\",\n    description: \"Translate text into another language\",\n    args: [\"language\", \"text\"],\n  },\n  {\n    name: \"summarize\",\n    description: \"Summarize the conversation so far\",\n    args: [\"length\"],\n  },\n  {\n    name: \"rename\",\n    description: \"Rename a symbol across the project\",\n    args: [\"from\", \"to\"],\n  },\n  {\n    name: \"model\",\n    description: \"Switch the model for this chat\",\n    args: [\"name\"],\n  },\n  { name: \"clear\", description: \"Start a new conversation\" },\n]\n\nexport function SlashMenuDemo() {\n  const [text, setText] = React.useState(\"\")\n  const [result, setResult] = React.useState<string | null>(null)\n\n  const submit = () => {\n    const parsed = parseSlashCommand(text, commands)\n    if (!text.trim()) return\n\n    if (parsed) {\n      const names = parsed.command.args ?? []\n      const filled = names.map(\n        (name, index) => `${name}: ${parsed.args[index] ?? \"(missing)\"}`\n      )\n      setResult(\n        `Ran /${parsed.command.name}${filled.length ? ` with ${filled.join(\", \")}` : \"\"}`\n      )\n    } else {\n      setResult(`Sent: ${text.trim()}`)\n    }\n    setText(\"\")\n  }\n\n  return (\n    <div className=\"grid min-h-[19rem] w-full max-w-xl content-start gap-3\">\n      <SlashMenu\n        commands={commands}\n        placeholder=\"Type / for commands\"\n        rows={2}\n        value={text}\n        onKeyDown={(event) => {\n          if (event.key !== \"Enter\" || event.shiftKey) return\n          if (event.nativeEvent.isComposing) return\n          event.preventDefault()\n          submit()\n        }}\n        onValueChange={setText}\n      />\n\n      <p className=\"text-muted-foreground text-xs\" role=\"status\">\n        {result ?? \"Try /translate Spanish Where is the station?\"}\n      </p>\n\n      <dl className=\"border-border grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5 border-t pt-3 text-xs\">\n        {commands.map((command) => (\n          <React.Fragment key={command.name}>\n            <dt className=\"font-[family-name:var(--font-mono),monospace]\">\n              /{command.name}\n            </dt>\n            <dd className=\"text-muted-foreground\">{command.description}</dd>\n          </React.Fragment>\n        ))}\n      </dl>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}