{
  "name": "channel-sidebar",
  "type": "registry:block",
  "framework": "react",
  "title": "Channel sidebar",
  "description": "The column a server is navigated from: its name, its channels as a tree and the user panel at the foot.",
  "registryDependencies": [
    "@newtui/tree",
    "@newtui/user-panel",
    "@newtui/status-indicator",
    "@newtui/avatar"
  ],
  "files": [
    {
      "path": "blocks/channel-sidebar/channel-sidebar.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Avatar } from \"@/registry/bases/newt/ui/avatar\"\nimport {\n  StatusDot,\n  StatusIndicator,\n} from \"@/registry/bases/newt/ui/status-indicator\"\nimport type { StatusDotProps } from \"@/registry/bases/newt/ui/status-indicator\"\nimport { Tree, type TreeNode } from \"@/registry/bases/newt/ui/tree\"\nimport {\n  UserPanel,\n  UserPanelActions,\n  UserPanelButton,\n  UserPanelInfo,\n} from \"@/registry/bases/newt/ui/user-panel\"\n\n/*\n * The shape the sidebar reads. A block does not know your data layer; map\n * onto this at the edge of it.\n */\nexport interface SidebarUser {\n  name: string\n  initials: string\n  status: NonNullable<StatusDotProps[\"status\"]>\n  /** The line under the name. */\n  statusText?: string\n}\n\n/*\n * The state of the dot in words, for a screen reader. The dot speaks it only\n * when no status line is written beside it.\n */\nconst STATUS_LABELS = {\n  online: \"Online\",\n  idle: \"Idle\",\n  dnd: \"Do not disturb\",\n  offline: \"Offline\",\n  streaming: \"Streaming\",\n} as const satisfies Record<SidebarUser[\"status\"], string>\n\nexport interface ChannelSidebarProps extends Omit<\n  React.ComponentProps<\"aside\">,\n  \"onChange\"\n> {\n  serverName: string\n  /** Categories and their channels, as the tree takes them. */\n  channels: readonly TreeNode[]\n  /** Ids of the categories that start open. */\n  defaultExpanded?: readonly string[]\n  /** The id of the channel being shown. */\n  channel?: string\n  onChannelChange?: (channel: string) => void\n  user: SidebarUser\n  /** Called when the settings button in the user panel is pressed. */\n  onOpenSettings?: () => void\n}\n\n/*\n * The column a server is navigated from: its name, its channels as a tree and\n * the signed-in user's controls pinned to the foot. Muting and deafening are\n * kept here as local state because the block has no voice connection to tell;\n * lift them when yours does.\n */\nexport function ChannelSidebar({\n  serverName,\n  channels,\n  defaultExpanded,\n  channel,\n  onChannelChange,\n  user,\n  onOpenSettings,\n  className,\n  ...props\n}: ChannelSidebarProps) {\n  const [muted, setMuted] = React.useState(false)\n  const [deafened, setDeafened] = React.useState(false)\n\n  return (\n    <aside\n      aria-label={`${serverName} channels`}\n      className={cn(\n        \"flex h-full min-h-0 flex-col bg-newt-bg-surface\",\n        className\n      )}\n      {...props}\n    >\n      <header className=\"border-b border-newt-border px-4 py-3 text-[15px] font-semibold leading-5 text-newt-text-primary\">\n        <span className=\"block truncate\">{serverName}</span>\n      </header>\n      <div className=\"min-h-0 flex-1 overflow-y-auto p-2\">\n        <Tree\n          label=\"Channels\"\n          items={channels}\n          defaultExpanded={defaultExpanded}\n          value={channel}\n          onValueChange={onChannelChange}\n        />\n      </div>\n      <div className=\"p-2\">\n        <UserPanel>\n          <StatusIndicator>\n            <Avatar size=\"sm\">{user.initials}</Avatar>\n            <StatusDot\n              status={user.status}\n              label={\n                user.statusText === undefined\n                  ? STATUS_LABELS[user.status]\n                  : undefined\n              }\n            />\n          </StatusIndicator>\n          <UserPanelInfo name={user.name} status={user.statusText} />\n          <UserPanelActions>\n            <UserPanelButton\n              icon=\"microphone\"\n              label=\"Mute\"\n              pressed={muted}\n              onPressedChange={setMuted}\n            />\n            <UserPanelButton\n              icon=\"headphones\"\n              label=\"Deafen\"\n              pressed={deafened}\n              onPressedChange={setDeafened}\n            />\n            <UserPanelButton\n              icon=\"settings\"\n              label=\"User settings\"\n              onClick={onOpenSettings}\n            />\n          </UserPanelActions>\n        </UserPanel>\n      </div>\n    </aside>\n  )\n}\n",
      "type": "registry:block"
    }
  ]
}