{
  "name": "command-stack-workspace-demo",
  "type": "registry:example",
  "registryDependencies": [
    "command-stack"
  ],
  "files": [
    {
      "path": "examples/command-stack-workspace-demo.tsx",
      "type": "registry:example",
      "content": "\"use client\";\n\nimport {\n  Bell,\n  CreditCard,\n  FolderKanban,\n  Mail,\n  Settings,\n  Trash2,\n  UserCog,\n  Users,\n} from \"lucide-react\";\nimport * as React from \"react\";\n\nimport {\n  CommandStack,\n  CommandStackEmpty,\n  CommandStackGroup,\n  CommandStackInput,\n  CommandStackItem,\n  CommandStackList,\n  CommandStackPage,\n  CommandStackSeparator,\n  CommandStackShortcut,\n  type CommandStackValue,\n} from \"@/registry/bases/radix/ui/command-stack\";\n\nconst roles = [\n  {\n    value: \"owner\",\n    label: \"Owner\",\n    description: \"Full access, including billing\",\n  },\n  {\n    value: \"admin\",\n    label: \"Admin\",\n    description: \"Manage members and settings\",\n  },\n  {\n    value: \"member\",\n    label: \"Member\",\n    description: \"Create and edit projects\",\n  },\n  { value: \"guest\", label: \"Guest\", description: \"View shared projects only\" },\n];\n\nconst plans = [\n  { value: \"hobby\", label: \"Hobby\", description: \"Free for personal projects\" },\n  { value: \"pro\", label: \"Pro\", description: \"$20 per seat each month\" },\n  {\n    value: \"enterprise\",\n    label: \"Enterprise\",\n    description: \"Custom pricing and support\",\n  },\n];\n\nconst members = [\n  { id: \"olivia\", name: \"Olivia Martin\", email: \"olivia@acme.com\" },\n  { id: \"jackson\", name: \"Jackson Lee\", email: \"jackson@acme.com\" },\n  { id: \"isabella\", name: \"Isabella Nguyen\", email: \"isabella@acme.com\" },\n  { id: \"william\", name: \"William Kim\", email: \"will@acme.com\" },\n];\n\nconst initialValue: CommandStackValue = {\n  \"role-olivia\": [\"owner\"],\n  \"role-jackson\": [\"admin\"],\n  \"role-isabella\": [\"member\"],\n  \"role-william\": [\"guest\"],\n  plan: [\"pro\"],\n};\n\nfunction getInitials(name: string) {\n  return name\n    .split(\" \")\n    .map((part) => part[0])\n    .join(\"\");\n}\n\nfunction getLabel(\n  options: { value: string; label: string }[],\n  value: string | undefined,\n) {\n  return options.find((option) => option.value === value)?.label;\n}\n\nexport default function CommandStackWorkspaceDemo() {\n  const [value, setValue] = React.useState<CommandStackValue>(initialValue);\n\n  function onValueChange(nextValue: CommandStackValue) {\n    setValue((prevValue) => {\n      const keptValue = { ...nextValue };\n      for (const [page, selected] of Object.entries(nextValue)) {\n        if (selected.length === 0 && prevValue[page]) {\n          keptValue[page] = prevValue[page];\n        }\n      }\n      return keptValue;\n    });\n  }\n\n  return (\n    <CommandStack\n      value={value}\n      onValueChange={onValueChange}\n      className=\"w-full max-w-md border shadow-md\"\n    >\n      <CommandStackInput placeholder=\"Search workspace...\" />\n      <CommandStackList>\n        <CommandStackEmpty>No results found.</CommandStackEmpty>\n        <CommandStackPage value=\"root\" label=\"Home\">\n          <CommandStackGroup heading=\"Workspace\">\n            <CommandStackItem>\n              <FolderKanban />\n              Projects\n              <CommandStackShortcut>G P</CommandStackShortcut>\n            </CommandStackItem>\n            <CommandStackItem page=\"settings\">\n              <Settings />\n              Settings...\n              <CommandStackShortcut>G S</CommandStackShortcut>\n            </CommandStackItem>\n          </CommandStackGroup>\n          <CommandStackGroup heading=\"Account\">\n            <CommandStackItem>\n              <Bell />\n              Notifications\n            </CommandStackItem>\n          </CommandStackGroup>\n        </CommandStackPage>\n\n        <CommandStackPage\n          value=\"settings\"\n          label=\"Settings\"\n          placeholder=\"Search settings...\"\n        >\n          <CommandStackGroup heading=\"Workspace\">\n            <CommandStackItem page=\"members\">\n              <Users />\n              Members...\n              <span className=\"ml-auto text-xs text-muted-foreground\">\n                {members.length}\n              </span>\n            </CommandStackItem>\n            <CommandStackItem page=\"billing\">\n              <CreditCard />\n              Billing...\n              <span className=\"ml-auto text-xs text-muted-foreground\">\n                {getLabel(plans, value.plan?.[0])}\n              </span>\n            </CommandStackItem>\n          </CommandStackGroup>\n        </CommandStackPage>\n\n        <CommandStackPage\n          value=\"members\"\n          label=\"Members\"\n          placeholder=\"Search members...\"\n        >\n          <CommandStackGroup heading={`${members.length} members`}>\n            {members.map((member) => (\n              <CommandStackItem\n                key={member.id}\n                value={`${member.name} ${member.email}`}\n                page={`member-${member.id}`}\n              >\n                <span className=\"flex size-7 shrink-0 items-center justify-center rounded-full border bg-background text-[10px] font-medium\">\n                  {getInitials(member.name)}\n                </span>\n                <span className=\"flex min-w-0 flex-col\">\n                  <span className=\"truncate\">{member.name}</span>\n                  <span className=\"truncate text-xs text-muted-foreground\">\n                    {member.email}\n                  </span>\n                </span>\n                <span className=\"ml-auto text-xs text-muted-foreground\">\n                  {getLabel(roles, value[`role-${member.id}`]?.[0])}\n                </span>\n              </CommandStackItem>\n            ))}\n          </CommandStackGroup>\n        </CommandStackPage>\n\n        {members.map((member) => (\n          <CommandStackPage\n            key={member.id}\n            value={`member-${member.id}`}\n            label={member.name}\n            placeholder={`Manage ${member.name}...`}\n          >\n            <CommandStackGroup heading={member.email}>\n              <CommandStackItem page={`role-${member.id}`}>\n                <UserCog />\n                Change role...\n                <span className=\"ml-auto text-xs text-muted-foreground\">\n                  {getLabel(roles, value[`role-${member.id}`]?.[0])}\n                </span>\n              </CommandStackItem>\n              <CommandStackItem>\n                <Mail />\n                Send email\n              </CommandStackItem>\n            </CommandStackGroup>\n            <CommandStackSeparator />\n            <CommandStackGroup>\n              <CommandStackItem className=\"text-destructive data-selected:text-destructive *:[svg]:text-destructive! data-selected:*:[svg]:text-destructive!\">\n                <Trash2 />\n                Remove from workspace\n              </CommandStackItem>\n            </CommandStackGroup>\n          </CommandStackPage>\n        ))}\n\n        {members.map((member) => (\n          <CommandStackPage\n            key={member.id}\n            value={`role-${member.id}`}\n            label=\"Role\"\n            placeholder={`Change role for ${member.name}...`}\n            selectionMode=\"single\"\n          >\n            <CommandStackGroup heading=\"Role\">\n              {roles.map((role) => (\n                <CommandStackItem key={role.value} value={role.value}>\n                  <span className=\"flex flex-col\">\n                    <span>{role.label}</span>\n                    <span className=\"text-xs text-muted-foreground\">\n                      {role.description}\n                    </span>\n                  </span>\n                </CommandStackItem>\n              ))}\n            </CommandStackGroup>\n          </CommandStackPage>\n        ))}\n\n        <CommandStackPage\n          value=\"billing\"\n          label=\"Billing\"\n          placeholder=\"Search billing...\"\n        >\n          <CommandStackGroup heading=\"Billing\">\n            <CommandStackItem page=\"plan\">\n              <CreditCard />\n              Change plan...\n              <span className=\"ml-auto text-xs text-muted-foreground\">\n                {getLabel(plans, value.plan?.[0])}\n              </span>\n            </CommandStackItem>\n            <CommandStackItem>\n              <Mail />\n              Billing email\n            </CommandStackItem>\n          </CommandStackGroup>\n        </CommandStackPage>\n\n        <CommandStackPage\n          value=\"plan\"\n          label=\"Plan\"\n          placeholder=\"Change plan...\"\n          selectionMode=\"single\"\n        >\n          <CommandStackGroup heading=\"Plan\">\n            {plans.map((plan) => (\n              <CommandStackItem key={plan.value} value={plan.value}>\n                <span className=\"flex flex-col\">\n                  <span>{plan.label}</span>\n                  <span className=\"text-xs text-muted-foreground\">\n                    {plan.description}\n                  </span>\n                </span>\n              </CommandStackItem>\n            ))}\n          </CommandStackGroup>\n        </CommandStackPage>\n      </CommandStackList>\n    </CommandStack>\n  );\n}\n",
      "target": ""
    }
  ]
}