<!-- generated by scripts/gen-docs.mjs from docs/system/member-list.md. Edit the source and rerun. -->
# MemberList

## Description
Lists the people who have access to something shared and the invitations still open, each with a role that can be changed and a way to take the access away.

`import { MemberList, memberListLabels, MemberRow, ShareLink, shareLinkLabels, type Member } from "@/components/cobalt/ui/member-list"`, source `registry/cobalt/ui/member-list.tsx`, status `ready-with-gaps`.
Foundation: `hand-rolled`. Traps checked: `trap/button-icon-name`, `trap/overlay-destructive`, `trap/overlay-pending-dismiss`, `trap/overlay-focus-return`, `trap/toast-errors`, `trap/loading-label-swap`, `trap/loading-layout-shift`, `trap/disabled-drops-focus`, `trap/select-value-lost`, `trap/color-only-status`, `trap/illustration-announced`, `trap/motion-layout-property`, `trap/reduced-motion-ignored`, `trap/touch-hover-flash`, `trap/touch-input-zoom`, `trap/list-dead-gap` (n/a: a row is not a press target; only its role and its Remove are), `trap/table-divs` (n/a: the rows are a list, `ul` and `li`).

`ShareLink` is on this page too: the link to what is shared, read only, beside the system's `CopyButton`, with a line under it that says what the link lets someone do. The field shows the address without `https://`, so its room goes to the part that names the place, and below 640px `CopyButton` sits under the field, which then has the whole width (measured at 390: "app.example.com/watchlists/l…" in a 310px field, where "https://app.exam…" showed in 196px before); Copy link copies the whole address. The role type `MemberRole` comes from `InviteField`, so the roles a person is invited with are the roles their row shows.

`trap/button-icon-name` is answered by Remove and Revoke, named for the person, such as "Remove Priya Shah" (ARIA). `trap/overlay-destructive` by the `AlertDialog` that asks before removing, and `trap/overlay-pending-dismiss` by that dialog holding while the request is out: Escape and Cancel do nothing (Keyboard, measured). `trap/overlay-focus-return` by the focus going to the next row's Remove, else the one before, else the list, once a row is removed (Keyboard, measured). `trap/toast-errors` by a removal's failure staying in the dialog's footer, and a role's failure staying under the name until the next change (States). `trap/loading-label-swap` by the dialog's `StateButton`, and by "Saving" taking the line under the name, never the role's place (States). `trap/loading-layout-shift` by that line swapping its words in place, the row holding 58px through a save (measured). `trap/disabled-drops-focus` by the role's Select keeping its look while a change saves and ignoring a second pick. `trap/select-value-lost` by the new role showing at once and the old one coming back when the change is refused (States). `trap/color-only-status` by the words "Invited, expires Oct 24", "You" and the failure sentence, and the mail glyph on an invitation's avatar. `trap/illustration-announced` by the avatar being `aria-hidden`, with the name as text beside it, and no avatar at all with `pictures={false}` (ARIA). `trap/motion-layout-property` by `Presence`, whose rows animate their height on purpose, so the rows below move with a row that comes or goes instead of jumping (Motion). `trap/reduced-motion-ignored` by `Presence` keeping only the fades under reduced motion (Motion). `trap/touch-hover-flash` by the system's `hover` variant, which applies only under `(hover: hover)`. `trap/touch-input-zoom` by `ShareLink`'s link at 16px below 768px, as every field is (measured 16px at 390 and 14px at 1440).

### Foundation
Not applicable: hand-rolled.

| Given by the foundation | Added by the team |
|---|---|
| The system's `Item` parts for the row, `Avatar`, `Select`, `IconButton`, `AlertDialog`, `StateButton`, `CopyButton` and `TextSwap`; `Presence` and `PresenceRow` for rows that come and go; `useAction` and `useSlowWait` for the requests | A `ul` named by `label` whose rows are people and open invitations. A row shows the avatar, the name with "You" for the reader, the address, the role in a Select whose options say what each allows, and Remove; an invitation shows its address, when it expires, the role as text, and Revoke. A role change shows at once, says "Saving" under the name from 250ms, and when refused brings the old role back and says so until the next change; a visually hidden status line in the row reads each of these once. With `pictures={false}` the rows draw no avatars and the grid drops its first column. Removing asks first in an alert dialog that holds while the request is out and says when it failed; once done, focus goes to the next row's Remove, else the one before, else the list, which then shows a 2px ring inside its edge. A row that cannot be changed shows its role as text and the reason under the name, and keeps Remove's slot, so the roles stay in one column. From 640px the role is a 112px column before Remove; below it, the role sits under the name. `ShareLink`: a read-only link that selects whole on a press, the system's `CopyButton` in its text form, and a line on what the link allows |

## Examples
The people who can see a shared watchlist and an invitation not yet taken up: a new role shows at once and says Saving while it is on its way, Remove asks first, and the owner's row is locked with the reason.

Real uses, 0 call sites (`rg -n "<MemberList\b" app registry --glob '!registry/cobalt/ui/*'`): no showcase page draws one outside the examples, and the examples folder does not count.

Uses inside the registry: none. The share dialog on this page composes it with `InviteField` and `ShareLink`, `docs/system/examples/member-list/in-dialog.tsx:41`.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/member-list/default.tsx` | default | The people who can see a shared watchlist and one invitation; a new role says Saving under the name while it is on its way, and Remove asks first |
| `docs/system/examples/member-list/default.tsx` | state:locked | The owner's row: the reason in place of the address, the role as text, and no Remove |
| `docs/system/examples/member-list/default.tsx` | state:invited | An invitation not yet taken up: the address, when it expires, the role as text, and Revoke |
| `docs/system/examples/member-list/role-failed.tsx` | state:role-refused | A role change the server refuses, every first try: the new role at once, Saving under the name, then the old role back and the line in red until the next change |
| `docs/system/examples/member-list/share-link.tsx` | composition:CopyButton | The link to what is shared beside the system's copy button, and a line on what it lets someone do; a press on the link selects it whole |
| `docs/system/examples/member-list/in-dialog.tsx` | composition:Dialog | Sharing a watchlist in one dialog: invite by email with a role, everyone with access and their role, and the link; invited addresses join the list as invitations |

Example: The people who can see a shared watchlist and one invitation; a new role says Saving under the name while it is on its way, and Remove asks first (`docs/system/examples/member-list/default.tsx`)

```tsx
import { useState } from "react";

import type { MemberRole } from "@/components/cobalt/ui/invite-field";
import { MemberList, MemberRow, type Member } from "@/components/cobalt/ui/member-list";

const roles: MemberRole[] = [
  { value: "owner", label: "Owner", description: "Can share, rename and delete the watchlist." },
  { value: "editor", label: "Editor", description: "Can add and remove funds and write notes." },
  { value: "viewer", label: "Viewer", description: "Can see the funds and notes." },
];

// Stands in for the requests that change a role and remove someone.
const request = () => new Promise((resolve) => setTimeout(resolve, 800));

export default function Example() {
  const [members, setMembers] = useState<Member[]>([
    { id: "1", name: "Ada Park", email: "ada.park@example.com", picture: "/photos/portrait-1.webp", role: "owner", you: true },
    { id: "2", name: "Tomás Reyes", email: "tomas.reyes@example.com", picture: "/photos/portrait-3.webp", role: "editor" },
    { id: "3", name: "Priya Shah", email: "priya.shah@example.com", role: "viewer" },
    { id: "4", email: "lee.chen@example.com", role: "viewer", invited: { expires: "Oct 24" } },
  ]);
  return (
    <MemberList label="People with access" className="w-full max-w-lg">
      {members.map((member) => (
        <MemberRow
          key={member.id}
          member={member}
          roles={roles}
          thing="Large cap core"
          {...(member.you ? { locked: "The watchlist needs an owner" } : {})}
          onRoleChange={async (role) => {
            await request();
            setMembers((all) => all.map((m) => (m.id === member.id ? { ...m, role } : m)));
          }}
          onRemove={async () => {
            await request();
            setMembers((all) => all.filter((m) => m.id !== member.id));
          }}
        />
      ))}
    </MemberList>
  );
}
```

Example: The link to what is shared beside the system's copy button, and a line on what it lets someone do; a press on the link selects it whole (`docs/system/examples/member-list/share-link.tsx`)

```tsx
import { ShareLink } from "@/components/cobalt/ui/member-list";

export default function Example() {
  return (
    <ShareLink href="https://app.example.com/watchlists/large-cap-core?share=k7Qm2" className="w-full max-w-md">
      Anyone at Harbour Capital with the link can view the watchlist.
    </ShareLink>
  );
}
```

Example: Sharing a watchlist in one dialog: invite by email with a role, everyone with access and their role, and the link; invited addresses join the list as invitations (`docs/system/examples/member-list/in-dialog.tsx`)

```tsx
import { useState } from "react";

import { Button } from "@/components/cobalt/ui/button";
import { Dialog, DialogBody, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/cobalt/ui/dialog";
import { InviteField, type MemberRole } from "@/components/cobalt/ui/invite-field";
import { MemberList, MemberRow, ShareLink, type Member } from "@/components/cobalt/ui/member-list";

const roles: MemberRole[] = [
  { value: "editor", label: "Editor", description: "Can add and remove funds and write notes." },
  { value: "viewer", label: "Viewer", description: "Can see the funds and notes." },
];

const request = () => new Promise((resolve) => setTimeout(resolve, 800));

export default function Example() {
  const [members, setMembers] = useState<Member[]>([
    { id: "1", name: "Ada Park", email: "ada.park@example.com", picture: "/photos/portrait-1.webp", role: "editor", you: true },
    { id: "2", name: "Tomás Reyes", email: "tomas.reyes@example.com", picture: "/photos/portrait-3.webp", role: "viewer" },
  ]);
  return (
    <Dialog>
      <DialogTrigger render={<Button variant="secondary" />}>Share</DialogTrigger>
      <DialogContent className="sm:max-w-xl">
        <DialogHeader>
          <DialogTitle>Share Large cap core</DialogTitle>
          <DialogDescription>People you invite get an email with a link to the watchlist.</DialogDescription>
        </DialogHeader>
        <DialogBody className="flex flex-col gap-6">
          <InviteField
            roles={roles}
            existing={members.map((m) => m.email)}
            onInvite={async (addresses, role) => {
              await request();
              setMembers((all) => [
                ...all,
                ...addresses.map((email) => ({ id: email, email, role, invited: { expires: "Oct 24" } })),
              ]);
            }}
          />
          <MemberList label="People with access" className="-mx-2.5">
            {members.map((member) => (
              <MemberRow
                key={member.id}
                member={member}
                roles={roles}
                thing="Large cap core"
                onRoleChange={async (role) => {
                  await request();
                  setMembers((all) => all.map((m) => (m.id === member.id ? { ...m, role } : m)));
                }}
                onRemove={async () => {
                  await request();
                  setMembers((all) => all.filter((m) => m.id !== member.id));
                }}
              />
            ))}
          </MemberList>
          <ShareLink href="https://app.example.com/watchlists/large-cap-core?share=k7Qm2">
            Anyone at Harbour Capital with the link can view the watchlist.
          </ShareLink>
        </DialogBody>
      </DialogContent>
    </Dialog>
  );
}
```

## Variants
Not applicable: MemberList and MemberRow have no variant axis. A row's look follows its data: `invited`, `you` and `locked`, and whether `onRoleChange` and `onRemove` are passed; `pictures` on the list is a boolean that drops the avatars.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| idle | a row with `onRoleChange` and `onRemove` | change the role, remove the person | the name, the address, the role in a Select named for the person, and Remove | test |
| you | `member.you` | as idle | "You" after the name | test |
| invited | `member.invited` | revoke the invitation | the address in the name's place, "Invited, expires Oct 24" under it, a mail glyph in the avatar, the role as text, and Revoke | test |
| locked | `locked`, a reason | read why | the reason in place of the address, the role as text, and an empty slot where Remove would be | test |
| saving | a new role picked | wait; a second pick is ignored until the first answers | the new role at once, and from 250ms "Saving" under the name, held at least 400ms and read once by the row's status line; the row stays 58px (measured) | by hand |
| role refused | `onRoleChange` rejected | pick again | the old role back, and "Role not changed. Try again." in `--destructive` under the name until the next change, read once by the row's status line; nothing in the row moves (measured on role-failed.tsx at 1440 light and 390 dark, frame by frame: the list and the role's trigger 0px), and the sentence fits the 202px line at 390, where the earlier "Role not changed. Try again." needed 235px and was cut | by hand |
| confirming | Remove or Revoke pressed | press Cancel, or confirm | the alert dialog with the question, such as "Remove Priya Shah?", and what removing does; focus on Cancel | by hand |
| removing | the dialog's action pressed | wait | the action keeps its label and width, with a spinner and "Removing" from 250ms, `aria-busy`; Escape and Cancel do nothing | by hand |
| remove failed | `onRemove` rejected | press the action again, or Cancel | "Not removed" in the action, and "Nothing was changed. Check your connection and try again." in the dialog's footer | by hand |
| leaving | `onRemove` resolved and the host dropped the person | nothing; the row is `inert` | the row fades while its height closes, and the rows under it move up with it (measured 58px, then 13px, then gone) | by hand |
| arriving | the host added a person or an invitation | read it | the row's height opens and its content fades in | by hand |
| hover | the pointer over the role or Remove, under `(hover: hover)` | press it | pointer only, colour change: the grey fill | by hand |
| focus-visible | Tab onto the role or Remove | press it | the system's focus look on that control | by hand |
| link selected | a press on, or Tab into, the `ShareLink` link | copy it by hand | the whole link selected (measured 61 of 61 characters) | by hand |

Example: The owner's row: the reason in place of the address, the role as text, and no Remove (`docs/system/examples/member-list/default.tsx`)

```tsx
import { useState } from "react";

import type { MemberRole } from "@/components/cobalt/ui/invite-field";
import { MemberList, MemberRow, type Member } from "@/components/cobalt/ui/member-list";

const roles: MemberRole[] = [
  { value: "owner", label: "Owner", description: "Can share, rename and delete the watchlist." },
  { value: "editor", label: "Editor", description: "Can add and remove funds and write notes." },
  { value: "viewer", label: "Viewer", description: "Can see the funds and notes." },
];

// Stands in for the requests that change a role and remove someone.
const request = () => new Promise((resolve) => setTimeout(resolve, 800));

export default function Example() {
  const [members, setMembers] = useState<Member[]>([
    { id: "1", name: "Ada Park", email: "ada.park@example.com", picture: "/photos/portrait-1.webp", role: "owner", you: true },
    { id: "2", name: "Tomás Reyes", email: "tomas.reyes@example.com", picture: "/photos/portrait-3.webp", role: "editor" },
    { id: "3", name: "Priya Shah", email: "priya.shah@example.com", role: "viewer" },
    { id: "4", email: "lee.chen@example.com", role: "viewer", invited: { expires: "Oct 24" } },
  ]);
  return (
    <MemberList label="People with access" className="w-full max-w-lg">
      {members.map((member) => (
        <MemberRow
          key={member.id}
          member={member}
          roles={roles}
          thing="Large cap core"
          {...(member.you ? { locked: "The watchlist needs an owner" } : {})}
          onRoleChange={async (role) => {
            await request();
            setMembers((all) => all.map((m) => (m.id === member.id ? { ...m, role } : m)));
          }}
          onRemove={async () => {
            await request();
            setMembers((all) => all.filter((m) => m.id !== member.id));
          }}
        />
      ))}
    </MemberList>
  );
}
```

Example: An invitation not yet taken up: the address, when it expires, the role as text, and Revoke (`docs/system/examples/member-list/default.tsx`)

```tsx
import { useState } from "react";

import type { MemberRole } from "@/components/cobalt/ui/invite-field";
import { MemberList, MemberRow, type Member } from "@/components/cobalt/ui/member-list";

const roles: MemberRole[] = [
  { value: "owner", label: "Owner", description: "Can share, rename and delete the watchlist." },
  { value: "editor", label: "Editor", description: "Can add and remove funds and write notes." },
  { value: "viewer", label: "Viewer", description: "Can see the funds and notes." },
];

// Stands in for the requests that change a role and remove someone.
const request = () => new Promise((resolve) => setTimeout(resolve, 800));

export default function Example() {
  const [members, setMembers] = useState<Member[]>([
    { id: "1", name: "Ada Park", email: "ada.park@example.com", picture: "/photos/portrait-1.webp", role: "owner", you: true },
    { id: "2", name: "Tomás Reyes", email: "tomas.reyes@example.com", picture: "/photos/portrait-3.webp", role: "editor" },
    { id: "3", name: "Priya Shah", email: "priya.shah@example.com", role: "viewer" },
    { id: "4", email: "lee.chen@example.com", role: "viewer", invited: { expires: "Oct 24" } },
  ]);
  return (
    <MemberList label="People with access" className="w-full max-w-lg">
      {members.map((member) => (
        <MemberRow
          key={member.id}
          member={member}
          roles={roles}
          thing="Large cap core"
          {...(member.you ? { locked: "The watchlist needs an owner" } : {})}
          onRoleChange={async (role) => {
            await request();
            setMembers((all) => all.map((m) => (m.id === member.id ? { ...m, role } : m)));
          }}
          onRemove={async () => {
            await request();
            setMembers((all) => all.filter((m) => m.id !== member.id));
          }}
        />
      ))}
    </MemberList>
  );
}
```

Example: A role change the server refuses, every first try: the new role at once, Saving under the name, then the old role back and the line in red until the next change (`docs/system/examples/member-list/role-failed.tsx`)

```tsx
import { useRef, useState } from "react";

import type { MemberRole } from "@/components/cobalt/ui/invite-field";
import { MemberList, MemberRow, type Member } from "@/components/cobalt/ui/member-list";
import { Failure } from "@/lib/cobalt/failure";

const roles: MemberRole[] = [
  { value: "owner", label: "Owner", description: "Can share, rename and delete the watchlist." },
  { value: "editor", label: "Editor", description: "Can add and remove funds and write notes." },
  { value: "viewer", label: "Viewer", description: "Can see the funds and notes." },
];

export default function Example() {
  const [members, setMembers] = useState<Member[]>([
    { id: "1", name: "Ada Park", email: "ada.park@example.com", picture: "/photos/portrait-1.webp", role: "owner", you: true },
    { id: "2", name: "Tomás Reyes", email: "tomas.reyes@example.com", picture: "/photos/portrait-3.webp", role: "editor" },
    { id: "3", name: "Priya Shah", email: "priya.shah@example.com", role: "viewer" },
  ]);
  const tries = useRef(0);
  // Stands in for the request that changes a role: it answers after 900ms, and refuses every first try.
  const save = () =>
    new Promise((resolve, reject) =>
      setTimeout(() => ((tries.current += 1) % 2 === 1 ? reject(new Failure("offline")) : resolve(undefined)), 900),
    );
  return (
    <MemberList label="People with access" className="w-full max-w-lg">
      {members.map((member) => (
        <MemberRow
          key={member.id}
          member={member}
          roles={roles}
          thing="Large cap core"
          {...(member.you ? { locked: "The watchlist needs an owner" } : {})}
          onRoleChange={async (role) => {
            await save();
            setMembers((all) => all.map((m) => (m.id === member.id ? { ...m, role } : m)));
          }}
        />
      ))}
    </MemberList>
  );
}
```

### State precedence
- Saving and role refused: saving wins. A new pick replaces the failure line with "Saving".
- Locked and invited: locked wins on the line under the name; the mail glyph and the role as text stay.
- Locked and saving, or locked and removing: Not applicable: a locked row has no Select and no Remove.
- You and locked: both show. "You" after the name, the reason under it.
- Removing and an Escape or Cancel press: removing wins. The dialog stays until the request answers.
- Leaving and focus-visible: Not applicable: a leaving row is `inert`, and focus has moved to a neighbour's Remove or the list.
- Hover and focus-visible: both show.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| a row is removed | announce | `PresenceRow`: opacity on `--t-leave` with the out curve, and the height closing on the settle spring | opacity, height | the fade, then the rows below close up at once |
| a row is added | announce | `PresenceRow`: the height opening on the layout spring, the content fading with it | height, opacity | the row at its height at once, fading in on `--t-fade` |
| the line under the name turns to Saving or the failure and back | announce | `TextSwap`: the old words leave on 70 percent of `--t-pop`, the new arrive on `--t-icon` | opacity | the same fade |
| the remove dialog opens or closes | announce | the AlertDialog's fade on `--t-arrive`, leaving on 70 percent of it | opacity | the same fade |
| the role list opens or closes | announce | the Select's `popup-motion`, `--t-pop` on `--curve` | opacity | the same fade |
| the dialog's action turns to Removing or Not removed | announce | `StateButton`'s handover: the old copy leaves on 70 percent of `--t-pop`, the new arrives on the settle spring | opacity, transform | the fades stay and the movement drops |

## Props

<!-- Props generated from registry/cobalt/ui/member-list.tsx with TypeScript by scripts/props-table.mjs -->
### MemberList

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  |  |
| `label` | `string` |  |  |
| `className?` | `string` |  |  |
| `pictures?` | `boolean` | `true` | Whether each row starts with the person's picture. |

### MemberRow

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `member` | `Member` |  |  |
| `roles` | `MemberRole[]` |  | The roles a role can be changed to, each with a line on what it allows. |
| `thing` | `string` |  | What access is to, for the question before removing: "Large cap core". |
| `labels?` | `Partial<{ you: string; invited: (expires: string) => string; role: (who: string) => string; saving: string; roleFailed: string; remove: (who: string) => string; revoke: (who: string) => string; removeTitle: (who: string) => string; removeBody: (who: string, thing: string) => string; removeAction: string; revokeTitle: (who: string) => string; revokeBody: (who: string) => string; revokeAction: string; removing: string; removeFailed: string; removeError: string; keep: string; }>` |  |  |
| `locked?` | `string` |  | Why this row cannot be changed, shown in place of the email: "The workspace needs an owner". |
| `onRemove?` | `() => Promise<unknown>` |  | Takes away access, or revokes the invitation. |
| `onRoleChange?` | `(role: string) => Promise<unknown>` |  | Changes the role. |

### ShareLink

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `href` | `string` |  | The address to copy. |
| `children?` | `ReactNode` |  | What the link allows, under it: "Anyone in Harbour Capital with the link can view." |
| `className?` | `string` |  |  |
| `labels?` | `Partial<{ copy: string; link: string; }>` |  |  |

`MemberList` takes `label`, the list's name, `pictures`, true by default, which turns every row's avatar off when false, and `MemberRow` children. `MemberRow` takes `member`: `id`, `email`, and optionally `name`, `picture`, `role`, `you` and `invited` with an `expires` date already written, such as "Oct 24". `roles` are the roles a role can change to, as `InviteField` takes them. `onRoleChange` must resolve once the role is saved and reject when it is not; `onRemove` must resolve once access is gone, after which the host drops the person. Without `onRoleChange` the role shows as text, and without `onRemove` the row keeps an empty slot. `locked` is the reason a row cannot be changed. `thing` names what access is to, for the removal question. `labels` replaces any string in `memberListLabels`. `ShareLink` takes `href`, `children` for the line under it, and `labels` from `shareLinkLabels`.

## Usage

### When to use
- The people and open invitations of something shared, such as a watchlist or a workspace, each with a role that can change.
- A share dialog, under an `InviteField` and above the `ShareLink`.

### When not to use
- People shown without access to manage, such as a fund's team. Use Item instead, inside an ItemGroup.
- Hundreds of members to sort, filter and act on in bulk. Use DataTable instead.
- A few faces that say who is in something. Use Avatar instead, at most 5 in an `AvatarGroup` with an `AvatarGroupCount` for the rest, such as "+6", as `rule/avatar-group-max` says.

### Rules
- Follows `rule/avatar-no-silhouettes-in-lists`.
- `rule/member-list-key-by-id`: When mapping people to `MemberRow`s, key each row by `member.id` instead of its index, because `Presence` follows the keys: with index keys, removing the second person closes the last row's height and moves every row's content up a place. Evidence: principle platform: React keys say which element is which; app 3/3 MemberRow maps in docs/system key by id. Check: review of every `MemberRow` key.
  - Don't: `{members.map((m, i) => <MemberRow key={i} member={m} roles={roles} thing="Large cap core" />)}`
  - Do: `{members.map((m) => <MemberRow key={m.id} member={m} roles={roles} thing="Large cap core" />)}`
- `rule/member-list-lock-with-a-reason`: When a row cannot be changed, such as the only owner, pass `locked` with the reason, such as "The watchlist needs an owner", instead of leaving out `onRoleChange` and `onRemove` with no word, because the row then says why in place of the address and keeps Remove's slot, so the roles stay in one column. Evidence: principle heuristic: visibility of system status, a control that is missing says why; single use `docs/system/examples/member-list/default.tsx:31`. Check: review of every `MemberRow` without `onRemove`.
  - Don't: `<MemberRow member={owner} roles={roles} thing="Large cap core" />`
  - Do: `<MemberRow member={owner} roles={roles} thing="Large cap core" locked="The watchlist needs an owner" onRoleChange={changeRole} onRemove={remove} />`
- `rule/member-list-save-then-set`: When the role changes, await the request inside `onRoleChange` and set `member.role` once it is saved, throwing when it is refused, instead of setting the role first and sending the request without waiting, because the row shows the new role at once by itself, and only a rejection brings the old role back with "Role not changed. Try again.". Evidence: person D39. Check: review of every `onRoleChange`.
  - Don't: `onRoleChange={async (role) => { setRole(member.id, role); void api.setRole(member.id, role); }}`
  - Do: `onRoleChange={async (role) => { await api.setRole(member.id, role); setRole(member.id, role); }}`

### Content
- Follows `rule/writing-confirm-verb-chain`.
- `rule/member-list-thing-is-its-name`: When passing `thing`, write the shared thing's own name, such as "Large cap core", instead of its kind, such as "this watchlist", because the removal question reads "Priya Shah loses access to Large cap core at once." and the name says which access goes. Evidence: principle heuristic: help users recognize, diagnose and recover from errors, the consequence names its object; app 3/3 `thing` values in docs/system pass the watchlist's name. Check: review of every `thing`.
  - Don't: `<MemberRow member={m} roles={roles} thing="this watchlist" onRemove={remove} />`
  - Do: `<MemberRow member={m} roles={roles} thing="Large cap core" onRemove={remove} />`
- `rule/member-list-link-says-who-and-what`: When giving `ShareLink` its line, say who can open the link and what they can do, such as "Anyone at Harbour Capital with the link can view the watchlist.", instead of "Share this link", because the line is the one place that says how far the link reaches. Evidence: app 3/3 ShareLink lines in docs/system name who and what; principle heuristic: visibility of system status. Check: review of every `ShareLink`.
  - Don't: `<ShareLink href={url}>Share this link</ShareLink>`
  - Do: `<ShareLink href={url}>Anyone at Harbour Capital with the link can view the watchlist.</ShareLink>`

### Anti-slop
- `rule/member-list-not-a-table-with-a-menu`: When showing who has access and their roles, use `MemberList` with a `MemberRow` per person instead of a `Table` with a role column and a row menu, because `MemberRow` carries the role's saving and failure lines, the question before removing, and the focus once a row has gone. Evidence: principle heuristic: error prevention, removing access asks first; single use `docs/system/examples/member-list/in-dialog.tsx:41-43`. Check: review of every screen that lists people with roles.
  - Don't: `<Table><TableBody>{members.map((m) => <TableRow key={m.id}><TableCell>{m.name}</TableCell><TableCell>{m.role}</TableCell></TableRow>)}</TableBody></Table>`
  - Do: `<MemberList label="People with access">{members.map((m) => <MemberRow key={m.id} member={m} roles={roles} thing="Large cap core" onRoleChange={change} onRemove={remove} />)}</MemberList>`

### Limits
- `rule/member-list-role-label-length`: When a role's `label` runs past 9 characters, shorten it, such as "Auditor" for "Externe Prüferin mit Lesezugriff", because every row's role sits in a 112px column, so the roles start at one edge, and the Select cuts its label from the 10th character. Evidence: measured at 1440 and 390 on /components/member-list with Playwright, in Manrope, the trigger cuts "Contributor" after "Contribut", and the stress page cuts "Externe Prüferin mit Lesezugriff" to "Externe". Check: review of every `roles` array given to a `MemberRow`.
  - Don't: `{ value: "auditor", label: "External auditor", description: "Can read the funds and notes." }`
  - Do: `{ value: "auditor", label: "Auditor", description: "Can read the funds and notes." }`

## Accessibility
Rests on a `ul` named by `label` with an `li` per row, the system `Select` for the role, `IconButton` for Remove, `AlertDialog` and `StateButton` for the removal, `CopyButton`, and a native read-only `input` for the link. Screen reader pass with VoiceOver: NEEDS REVIEW.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the list | moves through each row's role, then its Remove; a locked row offers nothing, an invitation only Revoke | the next control (measured in that order) | by hand |
| Enter, Space | a role | opens the roles; the arrows move and Enter picks; a pick while saving is ignored | the role | by hand |
| Enter, Space | Remove or Revoke | opens the alert dialog | Cancel (measured) | by hand |
| Enter | the dialog's action | removes; the dialog holds while the request is out | the next row's Remove, else the one before, else the list with its inset ring (measured) | by hand |
| Escape | the open dialog | closes it and keeps the person; while removing, does nothing (measured) | the Remove that opened it (measured) | by hand |
| Tab | before the `ShareLink` | focuses the link and selects all of it | the link (measured) | by hand |
| Enter, Space | Copy link | copies the link and answers in place | stays on the button | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| list | list | `label`, through `aria-label` | `tabindex="-1"`, so focus can land on it once the last removable row has gone, with a 2px ring inside its edge when the keys brought it there (measured) | "People with access, list" and the count | test |
| row | listitem | its content | `inert` while leaving | the name, the line under it, the role and the button | by hand |
| avatar | none, `aria-hidden` | none | none | nothing; the name is text beside it | by hand |
| role | combobox, the Select's trigger | "Role for" and the name, from `labels.role` | `aria-expanded`, `aria-haspopup="listbox"` | the name and the role picked | test |
| line under the name | none | none | not live | the address, the reason a row is locked, "Saving" or the failure, when read | by hand |
| row's status line | status, visually hidden | none | none | "Saving", then "Role not changed. Try again." when refused, once each; a saved role says nothing, since the Select reads the new one (measured "Saving") | by hand |
| Remove, Revoke | button | "Remove" and the name, or "Revoke the invitation to" and the address | none | the name and "button" | test |
| remove dialog | alertdialog | its title, such as "Remove Priya Shah?" | `aria-describedby` the body, `aria-busy` while removing | the title and the body as it opens | by hand |
| link | textbox, read only | "Share link" from `shareLinkLabels.link` | `readonly` | the name and the link | by hand |
| Copy link | button | its text, "Copy link", which never changes | none | the name; "Copied" once, from the CopyButton's status line | test |

## Tokens
| Part | State | Token |
|---|---|---|
| list | focused by the keys | `--ring` |
| row | all | the Item's tokens, `--foreground` for the name, `--muted-foreground` for the line and "You" |
| line under the name | role refused | `--destructive` |
| role | all | the Select's: `--control-sm`, `--r-control`, `--input` |
| role as text | all | `--control-sm`, `--muted-foreground` |
| Remove | all | the IconButton's: `--control-sm`, `--muted` on hover |
| remove dialog action | all | `--destructive` on its 10 percent wash |
| rows coming and going | leaving, arriving | `--t-leave`, `--t-fade` |
| link | all | `--control`, `--r-control`, `--input`, `--primary` for the edge after Tab |
| line under the link | all | `--muted-foreground` |

## Related
- InviteField: invites people by email with the role they get.
- CopyButton: the copy button beside the link.
- AlertDialog: the question before a removal.
- Item: a row about one person or thing with no access to manage.
- DataTable: many members to sort, filter and act on together.
