{
  "name": "member-list",
  "type": "registry:ui",
  "framework": "react",
  "title": "Member List",
  "description": "A server member sidebar: role sections, presence, coloured names and APP tags.",
  "registryDependencies": [
    "@newtui/avatar",
    "@newtui/status-indicator",
    "@newtui/role-tag"
  ],
  "files": [
    {
      "path": "ui/member-list.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/*\n * The composition:\n *\n *   MemberListSection          <section>\n *     MemberListHeading        <h3 id>\n *     MemberList               role=\"list\", aria-labelledby the heading\n *       MemberListItem         role=\"listitem\"\n *\n * A heading is never a child of the list, which may own only list items.\n * The section generates one id, the heading takes it and the list points at\n * it, so each list is named by its heading. A list outside a section takes\n * an `aria-label` instead.\n */\nconst MemberListSectionContext = React.createContext<string | undefined>(\n  undefined\n)\n\nconst MemberList = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(\n  (\n    {\n      className,\n      \"aria-label\": ariaLabel,\n      \"aria-labelledby\": ariaLabelledby,\n      ...props\n    },\n    ref\n  ) => {\n    const headingId = React.useContext(MemberListSectionContext)\n    return (\n      <div\n        ref={ref}\n        role=\"list\"\n        aria-label={ariaLabel}\n        aria-labelledby={\n          ariaLabelledby ?? (ariaLabel === undefined ? headingId : undefined)\n        }\n        className={cn(\"flex flex-col\", className)}\n        {...props}\n      />\n    )\n  }\n)\nMemberList.displayName = \"MemberList\"\n\n/*\n * Discord groups members under each hoisted role, then Online, then Offline.\n * `offline` dims the whole group rather than every row on its own.\n */\nexport interface MemberListSectionProps extends React.HTMLAttributes<HTMLElement> {\n  offline?: boolean\n}\n\nconst MemberListSection = React.forwardRef<HTMLElement, MemberListSectionProps>(\n  ({ className, offline = false, ...props }, ref) => {\n    const headingId = React.useId()\n    return (\n      <MemberListSectionContext.Provider value={headingId}>\n        <section\n          ref={ref}\n          data-offline={offline || undefined}\n          className={cn(\n            \"[&:not(:first-child)]:mt-3\",\n            offline &&\n              \"[&_[role=listitem]]:opacity-45 [&_[data-slot=member-name]]:text-newt-text-muted\",\n            className\n          )}\n          {...props}\n        />\n      </MemberListSectionContext.Provider>\n    )\n  }\n)\nMemberListSection.displayName = \"MemberListSection\"\n\nexport interface MemberListHeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n  /** The heading level. Pick the one that fits the outline of the page. */\n  as?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"\n}\n\n/*\n * Inside a section the heading takes the id the section generated, so the\n * list beside it is named by it. If you pass an `id` of your own, pass the\n * same id as `aria-labelledby` on the `MemberList`.\n */\nconst MemberListHeading = React.forwardRef<\n  HTMLHeadingElement,\n  MemberListHeadingProps\n>(({ className, as: Heading = \"h3\", id, ...props }, ref) => {\n  const headingId = React.useContext(MemberListSectionContext)\n  return (\n    <Heading\n      ref={ref}\n      id={id ?? headingId}\n      className={cn(\n        \"m-0 px-2 pb-0.5 text-[12px] font-semibold uppercase leading-4 tracking-[0.02em] text-newt-text-muted\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nMemberListHeading.displayName = \"MemberListHeading\"\n\ninterface MemberListItemOwnProps {\n  /**\n   * An underlay drawn behind the row, such as a profile decoration. The hover\n   * is drawn over it, so it stays visible. An `img` fills the row.\n   */\n  decoration?: React.ReactNode\n}\n\n/*\n * `interactive` picks the element, so it also picks the attributes: a plain\n * row takes the attributes of a `div`, an interactive row those of a\n * `button`, such as `disabled`, `name` and `value`.\n */\nexport type MemberListItemProps =\n  | (MemberListItemOwnProps &\n      React.HTMLAttributes<HTMLDivElement> & {\n        interactive?: false\n      })\n  | (MemberListItemOwnProps &\n      React.ButtonHTMLAttributes<HTMLButtonElement> & {\n        /**\n         * Make the row a button, for a row that opens a profile. It takes\n         * focus, answers Enter and Space, and shows a hover and a focus\n         * ring. Every attribute and listener, and the ref, land on the\n         * button.\n         */\n        interactive: true\n      })\n\nconst MEMBER_ROW =\n  \"relative isolate flex min-w-0 items-center gap-2.5 rounded-[var(--newt-radius-sm)] px-2 py-1.5\"\nconst MEMBER_ROW_INTERACTIVE =\n  \"w-full cursor-pointer border-0 bg-transparent text-start after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:rounded-[inherit] after:transition-colors after:duration-fast after:ease-newt after:content-[''] hover:after:bg-newt-bg-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-newt-text-link\"\n\n/*\n * One member. A plain row has no pointer and no hover, because it does\n * nothing. With `interactive` the row is a button inside the list item.\n */\nconst MemberListItem = React.forwardRef<HTMLElement, MemberListItemProps>(\n  ({ className, interactive = false, decoration, children, ...props }, ref) => {\n    /*\n     * `createElement` types the ref by the element it is given, so one\n     * `HTMLElement` ref serves the `div` and the `button` without an\n     * assertion.\n     */\n    const row = React.createElement(\n      interactive ? \"button\" : \"div\",\n      {\n        ref,\n        type: interactive ? \"button\" : undefined,\n        role: interactive ? undefined : \"listitem\",\n        className: cn(\n          MEMBER_ROW,\n          interactive && MEMBER_ROW_INTERACTIVE,\n          className\n        ),\n        ...props,\n      },\n      decoration === undefined ? null : (\n        <span\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit] [&>img]:h-full [&>img]:w-full [&>img]:object-cover\"\n        >\n          {decoration}\n        </span>\n      ),\n      children\n    )\n    return interactive ? <div role=\"listitem\">{row}</div> : row\n  }\n)\nMemberListItem.displayName = \"MemberListItem\"\n\nconst MemberListNameRow = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex min-w-0 items-center gap-1\", className)}\n    {...props}\n  />\n))\nMemberListNameRow.displayName = \"MemberListNameRow\"\n\nconst MemberListInfo = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex min-w-0 flex-col leading-[1.2]\", className)}\n    {...props}\n  />\n))\nMemberListInfo.displayName = \"MemberListInfo\"\n\nexport interface MemberListNameProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"color\"\n> {\n  /** Render the name in the brand colour (e.g. highlighted role). */\n  colored?: boolean\n  /** Role colour. Any CSS colour; wins over `colored`. */\n  color?: string\n}\n\nconst MemberListName = React.forwardRef<HTMLSpanElement, MemberListNameProps>(\n  ({ className, colored = false, color, style, ...props }, ref) => (\n    <span\n      ref={ref}\n      data-slot=\"member-name\"\n      /*\n       * SAFETY: `CSSProperties` has no index signature for custom properties,\n       * but React forwards unknown `--*` keys to the style attribute verbatim,\n       * so the extra key is written out exactly as spelled here.\n       */\n      style={\n        color\n          ? ({\n              ...style,\n              \"--newt-member-name-color\": color,\n            } as React.CSSProperties)\n          : style\n      }\n      className={cn(\n        \"truncate text-sm font-medium\",\n        color\n          ? \"text-[var(--newt-member-name-color)]\"\n          : colored\n            ? \"text-newt-brand\"\n            : \"text-newt-text-primary\",\n        className\n      )}\n      {...props}\n    />\n  )\n)\nMemberListName.displayName = \"MemberListName\"\n\n/* The APP tag bots carry next to their name; `verified` adds Discord's check. */\nexport interface MemberListAppTagProps extends React.HTMLAttributes<HTMLSpanElement> {\n  verified?: boolean\n  /** Accessible name of the tag. `aria-label` still wins. */\n  label?: string\n  /** Accessible name with `verified`. `aria-label` still wins. */\n  verifiedLabel?: string\n}\n\nconst MemberListAppTag = React.forwardRef<\n  HTMLSpanElement,\n  MemberListAppTagProps\n>(\n  (\n    {\n      className,\n      verified = false,\n      label = \"Application\",\n      verifiedLabel = \"Verified application\",\n      children = \"APP\",\n      ...props\n    },\n    ref\n  ) => (\n    <span\n      ref={ref}\n      role=\"img\"\n      aria-label={verified ? verifiedLabel : label}\n      className={cn(\n        \"inline-flex shrink-0 items-center gap-0.5 rounded-[var(--newt-radius-sm)] bg-newt-brand px-1 py-px text-[9px] font-bold leading-none text-newt-on-accent\",\n        className\n      )}\n      {...props}\n    >\n      {verified ? (\n        <svg\n          viewBox=\"0 0 24 24\"\n          aria-hidden=\"true\"\n          focusable=\"false\"\n          className=\"h-2.5 w-2.5\"\n        >\n          <path\n            fill=\"currentColor\"\n            d=\"M9.55 17.6 4.4 12.45l1.4-1.4 3.75 3.75 8.65-8.65 1.4 1.4z\"\n          />\n        </svg>\n      ) : null}\n      {children}\n    </span>\n  )\n)\nMemberListAppTag.displayName = \"MemberListAppTag\"\n\nconst MemberListRole = React.forwardRef<\n  HTMLSpanElement,\n  React.HTMLAttributes<HTMLSpanElement>\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\"truncate text-xs text-newt-text-muted\", className)}\n    {...props}\n  />\n))\nMemberListRole.displayName = \"MemberListRole\"\n\nexport {\n  MemberList,\n  MemberListSection,\n  MemberListHeading,\n  MemberListItem,\n  MemberListInfo,\n  MemberListNameRow,\n  MemberListName,\n  MemberListAppTag,\n  MemberListRole,\n}\n",
      "type": "registry:ui"
    }
  ]
}