{
  "name": "channel-info",
  "type": "registry:ui",
  "framework": "react",
  "title": "Channel Info",
  "description": "The channel detail panel that covers a channel on narrow screens.",
  "dependencies": [
    "radix-ui"
  ],
  "registryDependencies": [
    "@newtui/tabs"
  ],
  "files": [
    {
      "path": "ui/channel-info.tsx",
      "content": "\"use client\"\n\nimport { Dialog as DialogPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst channelInfoClassName =\n  \"flex h-full w-full max-w-sm flex-col overflow-hidden bg-newt-bg-surface text-newt-text-primary\"\n\nexport interface ChannelInfoProps extends React.ComponentProps<\"div\"> {\n  /**\n   * Render a plain panel: no dialog role, and focus stays where it is. Use it\n   * for a side panel that is always on screen.\n   */\n  inline?: boolean\n  /**\n   * Take the page beside the panel out of use: it is hidden from assistive\n   * technology, focus cannot move to it, and a press on it closes the panel.\n   * Use it when the panel covers the channel. Has no effect on an `inline`\n   * panel.\n   */\n  modal?: boolean\n  /**\n   * The accessible name of the panel. Without it, name the panel with\n   * `aria-label` or `aria-labelledby`.\n   */\n  label?: string\n  /**\n   * Called when the user asks to close the dialog: Escape, or a press outside\n   * a `modal` one. Unmount the panel in answer; focus then returns to the\n   * element that held it before the panel opened.\n   */\n  onClose?: () => void\n}\n\n/*\n * Radix owns the behaviour: focus moves into the panel, Tab cycles through\n * its controls, Escape asks to close it, and a `modal` one takes the page\n * behind it out of use. The panel renders in place, with no portal and no\n * overlay, so the application decides where it sits. It is open for as long\n * as it is mounted.\n */\nconst ChannelInfoDialog = React.forwardRef<\n  HTMLDivElement,\n  Omit<ChannelInfoProps, \"inline\">\n>(({ modal = false, label, onClose, className, children, ...props }, ref) => {\n  const opener = React.useRef<Element | null>(null)\n  return (\n    <DialogPrimitive.Root\n      open\n      modal={modal}\n      onOpenChange={(open) => {\n        if (!open) onClose?.()\n      }}\n    >\n      <DialogPrimitive.Content\n        ref={ref}\n        aria-modal={modal ? true : undefined}\n        aria-describedby={undefined}\n        /*\n         * Radix returns focus to a `Dialog.Trigger`, and this dialog has\n         * none: the application opens it by mounting it. So the panel notes\n         * which element holds focus just before it takes it.\n         */\n        onOpenAutoFocus={() => {\n          opener.current = document.activeElement\n        }}\n        onCloseAutoFocus={(event) => {\n          event.preventDefault()\n          const element = opener.current\n          if (element instanceof HTMLElement && element.isConnected)\n            element.focus()\n        }}\n        /*\n         * The page beside a dialog that is not modal stays in use, so a press\n         * or a focus move outside must not close the panel.\n         */\n        onInteractOutside={(event) => {\n          if (!modal) event.preventDefault()\n        }}\n        className={cn(channelInfoClassName, \"outline-none\", className)}\n        {...props}\n      >\n        {/* The name, as a heading no one sees: Radix points the dialog at it. */}\n        {label === undefined ? null : (\n          <DialogPrimitive.Title className=\"sr-only\">\n            {label}\n          </DialogPrimitive.Title>\n        )}\n        {children}\n      </DialogPrimitive.Content>\n    </DialogPrimitive.Root>\n  )\n})\nChannelInfoDialog.displayName = \"ChannelInfoDialog\"\n\n/*\n * The panel that slides in over a channel on narrow screens, holding the\n * member list, pins, threads and the rest of the channel detail tabs. It is a\n * dialog unless it is `inline`.\n */\nconst ChannelInfo = React.forwardRef<HTMLDivElement, ChannelInfoProps>(\n  ({ inline = false, ...props }, ref) => {\n    if (!inline) return <ChannelInfoDialog ref={ref} {...props} />\n    const { modal: _modal, onClose: _onClose, label, role, ...rest } = props\n    return (\n      <div\n        ref={ref}\n        /* A name needs a role to hang on: a `div` alone may not carry one. */\n        role={role ?? (label === undefined ? undefined : \"region\")}\n        aria-label={label}\n        {...rest}\n        className={cn(channelInfoClassName, rest.className)}\n      />\n    )\n  }\n)\nChannelInfo.displayName = \"ChannelInfo\"\n\nconst ChannelInfoToolbar = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"flex h-14 shrink-0 items-center justify-between gap-2 px-2\",\n      className\n    )}\n    {...props}\n  />\n))\nChannelInfoToolbar.displayName = \"ChannelInfoToolbar\"\n\nconst ChannelInfoActions = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex items-center gap-1\", className)}\n    {...props}\n  />\n))\nChannelInfoActions.displayName = \"ChannelInfoActions\"\n\nexport interface ChannelInfoActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n  /**\n   * The element or component to render. Defaults to `button`, or to `a` when\n   * `href` is set; pass a router link component to keep client navigation.\n   * `span` renders the decorative form: hidden from assistive technology, out\n   * of the tab order, with no pointer and no hover.\n   * Its event handlers do not run.\n   */\n  as?: React.ElementType\n  /** Render a link to this URL. */\n  href?: string\n  /**\n   * Turns the control off. A link loses its URL, which takes it out of the\n   * tab order, and says so with `aria-disabled`.\n   */\n  disabled?: boolean\n  /** Link target, with `href`. */\n  target?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"]\n  /** Link relationship, with `href`. */\n  rel?: string\n}\n\n/*\n * The `span` form runs nothing: it drops every event handler, so a click\n * cannot start an action that the keyboard and assistive technology miss.\n */\nfunction withoutHandlers(\n  props: React.HTMLAttributes<HTMLElement>\n): React.HTMLAttributes<HTMLElement> {\n  return Object.fromEntries(\n    Object.entries(props).filter(([name]) => !/^on[A-Z]/.test(name))\n  )\n}\n\nconst ChannelInfoAction = React.forwardRef<HTMLElement, ChannelInfoActionProps>(\n  ({ as, href, disabled, className, type = \"button\", ...props }, ref) => {\n    const Tag: React.ElementType = as ?? (href === undefined ? \"button\" : \"a\")\n    const isButton = Tag === \"button\"\n    const decorative = Tag === \"span\"\n    return (\n      <Tag\n        ref={ref}\n        type={isButton ? type : undefined}\n        href={decorative || disabled ? undefined : href}\n        disabled={isButton ? disabled : undefined}\n        aria-disabled={!isButton && !decorative && disabled ? true : undefined}\n        aria-hidden={decorative ? true : undefined}\n        className={cn(\n          \"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-newt-text-secondary no-underline\",\n          !decorative &&\n            \"cursor-pointer transition-colors duration-fast ease-newt hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-50\",\n          className\n        )}\n        {...(decorative ? withoutHandlers(props) : props)}\n      />\n    )\n  }\n)\nChannelInfoAction.displayName = \"ChannelInfoAction\"\n\nconst ChannelInfoIdentity = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex min-w-0 items-center gap-3 px-4 pb-3\", className)}\n    {...props}\n  />\n))\nChannelInfoIdentity.displayName = \"ChannelInfoIdentity\"\n\nconst ChannelInfoIcon = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, children = \"#\", ...props }, ref) => (\n  <div\n    ref={ref}\n    aria-hidden=\"true\"\n    className={cn(\n      \"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-newt-bg-elevated text-lg font-bold leading-none text-newt-text-muted\",\n      className\n    )}\n    {...props}\n  >\n    {children}\n  </div>\n))\nChannelInfoIcon.displayName = \"ChannelInfoIcon\"\n\nconst ChannelInfoName = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"truncate font-bold text-newt-text-primary\", className)}\n    {...props}\n  />\n))\nChannelInfoName.displayName = \"ChannelInfoName\"\n\nconst ChannelInfoType = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"text-[13px] text-newt-text-muted\", className)}\n    {...props}\n  />\n))\nChannelInfoType.displayName = \"ChannelInfoType\"\n\n/* Scrolling area under the tab strip. */\nconst ChannelInfoPanel = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"min-h-0 flex-1 overflow-y-auto px-2 pb-4\", className)}\n    {...props}\n  />\n))\nChannelInfoPanel.displayName = \"ChannelInfoPanel\"\n\nconst ChannelInfoEmpty = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"flex flex-col items-center gap-2 px-6 py-10 text-center\",\n      className\n    )}\n    {...props}\n  />\n))\nChannelInfoEmpty.displayName = \"ChannelInfoEmpty\"\n\nconst ChannelInfoEmptyIcon = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    aria-hidden=\"true\"\n    className={cn(\n      \"flex h-14 w-14 items-center justify-center rounded-full bg-newt-bg-elevated text-newt-text-muted\",\n      className\n    )}\n    {...props}\n  />\n))\nChannelInfoEmptyIcon.displayName = \"ChannelInfoEmptyIcon\"\n\nconst ChannelInfoEmptyTitle = React.forwardRef<\n  HTMLParagraphElement,\n  React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => (\n  <p\n    ref={ref}\n    className={cn(\"font-semibold text-newt-text-primary\", className)}\n    {...props}\n  />\n))\nChannelInfoEmptyTitle.displayName = \"ChannelInfoEmptyTitle\"\n\nconst ChannelInfoEmptyBody = React.forwardRef<\n  HTMLParagraphElement,\n  React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => (\n  <p\n    ref={ref}\n    className={cn(\"max-w-[36ch] text-sm text-newt-text-muted\", className)}\n    {...props}\n  />\n))\nChannelInfoEmptyBody.displayName = \"ChannelInfoEmptyBody\"\n\nexport {\n  ChannelInfo,\n  ChannelInfoToolbar,\n  ChannelInfoActions,\n  ChannelInfoAction,\n  ChannelInfoIdentity,\n  ChannelInfoIcon,\n  ChannelInfoName,\n  ChannelInfoType,\n  ChannelInfoPanel,\n  ChannelInfoEmpty,\n  ChannelInfoEmptyIcon,\n  ChannelInfoEmptyTitle,\n  ChannelInfoEmptyBody,\n}\n",
      "type": "registry:ui"
    }
  ]
}