# Workspace Table

The workspace's Interactions and Documents tables: 36 px headings, sortable ones with ↑↓ at 40 % and the sorted one dark with a single arrow; 40 px rows of 12 px text. Rows show keyboard focus with the hover highlight, never a ring, and their menu on hover or focus.

- Beta: ready to use; its API can still change in a minor release.
- Category: Patterns · Workspace & pipeline

```tsx
import { WorkspaceTable, WorkspaceInteractionRow, WorkspaceDocumentRow } from "@leap-crm/design-system";
```

## Best practices

- Do: Give the table a `label`, like “Interactions” or “Documents”, and set `hideLabel` on a column with no visible heading, like the menu, so screen readers still hear its name.
- Do: Pair each row with the columns its docs list, like Type `w-16` and Date `w-34` for `WorkspaceInteractionRow`, so headings and cells line up.
- Do: Set `upcoming` on an interaction that hasn't happened yet. Its glyphs fade and its title goes muted, so the text keeps AA contrast; never fade the row yourself.
- Do: Leave `timeEntry` or `billed` out when there is none. The cell shows a named empty value, like “Not billed”, instead of a blank.
- Don't: Recolour a document row's `icon`. It is brand file art for PDF, Word, Excel or image files.
- Don't: Use it for a full-page list, like the opportunities list. Use `Table`; `WorkspaceTable` is for the workspace's Interactions and Documents.

## Keyboard

| Keys | What they do |
| --- | --- |
| Tab | Moves through the sortable headers and each row's record. |
| Enter, Space | Sort by the focused column header, or open the focused row's record. |

## Related

- [Table](./table.md)
- [Workspace Overview](./workspace-overview.md)
- [List](./list.md)
- [Pagination](./pagination.md)

## Examples

What the examples import:

```tsx
import { EllipsisVertical, FileText, Sheet } from "lucide-react";
import { useState } from "react";
import { IconButton, WorkspaceDocumentRow, WorkspaceInteractionRow, WorkspaceTable, type SortDirection, type WorkspaceTableColumn } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const interactionColumns: WorkspaceTableColumn[] = [
  { id: "type", label: "Type", className: "w-16" },
  { id: "title", label: "Title" },
  { id: "summary", label: "Summary", className: "w-9", hideLabel: true },
  { id: "participants", label: "Participants", className: "w-28" },
  {
    id: "date",
    label: "Date",
    className: "w-34",
    align: "end",
    sortable: true,
  },
  { id: "time", label: "Time entry", className: "w-26" },
  { id: "billed", label: "Billed", className: "w-32", sortable: true },
  { id: "tags", label: "Tags", className: "w-28" },
  { id: "menu", label: "Actions", className: "w-11", hideLabel: true },
];

const documentColumns: WorkspaceTableColumn[] = [
  { id: "title", label: "Title", sortable: true },
  { id: "date", label: "Date", className: "w-34", sortable: true },
  { id: "uploadedBy", label: "Uploaded by", className: "w-32", sortable: true },
  { id: "type", label: "Type", className: "w-20", sortable: true },
  {
    id: "size",
    label: "Size",
    className: "w-22",
    align: "end",
    sortable: true,
  },
  { id: "menu", label: "Actions", className: "w-11", hideLabel: true },
];

const more = (label: string) => (
  <IconButton size="xs" icon={<EllipsisVertical />} aria-label={label} />
);

const noop = () => undefined;

function useSort(initial: string) {
  const [sort, setSort] = useState<{ id: string; direction: SortDirection }>({
    id: initial,
    direction: "descending",
  });
  const onSortChange = (id: string) =>
    setSort(current => ({
      id,
      direction:
        current.id === id && current.direction === "descending"
          ? "ascending"
          : "descending",
    }));
  return { sort, onSortChange };
}

function Interactions() {
  const { sort, onSortChange } = useSort("date");
  return (
    <WorkspaceTable
      label="Interactions"
      columns={interactionColumns}
      sort={sort}
      onSortChange={onSortChange}
    >
      <WorkspaceInteractionRow
        type="email"
        direction="inbound"
        title="Re: Vendor contract"
        summarised
        participants={[
          { id: "1", name: "Tom Chen", initials: "TC" },
          { id: "2", name: "Sam Evans", initials: "SE" },
        ]}
        date="Yesterday"
        tags={["Lead"]}
        onOpen={noop}
        actions={more("More actions for Re: Vendor contract")}
      />
      <WorkspaceInteractionRow
        type="phone"
        direction="outbound"
        title="Called the vendor's solicitor about the deposit release authority and the cooling-off period"
        participants={[{ id: "2", name: "Sam Evans", initials: "SE" }]}
        date="2 days ago"
        timeEntry="0:30"
        billed="$120.00"
        tags={["Settlement", "Urgent", "Bank"]}
        onOpen={noop}
        actions={more("More actions for the call")}
      />
      <WorkspaceInteractionRow
        type="meeting"
        title="Settlement meeting"
        participants={[
          { id: "1", name: "Tom Chen", initials: "TC" },
          { id: "2", name: "Sam Evans", initials: "SE" },
          { id: "3", name: "Mia Grant", initials: "MG" },
        ]}
        date="Next Tuesday"
        upcoming
        onOpen={noop}
        actions={more("More actions for Settlement meeting")}
      />
    </WorkspaceTable>
  );
}

function Documents() {
  const { sort, onSortChange } = useSort("date");
  return (
    <WorkspaceTable
      label="Documents"
      columns={documentColumns}
      sort={sort}
      onSortChange={onSortChange}
    >
      <WorkspaceDocumentRow
        icon={<FileText className="text-signal-destructive" />}
        name="Contract of sale.pdf"
        date="18 Nov 2026"
        uploadedBy="Sam Evans"
        type="PDF"
        size="1.2 MB"
        onOpen={noop}
        actions={more("More actions for Contract of sale.pdf")}
      />
      <WorkspaceDocumentRow
        icon={<Sheet className="text-status-success-text" />}
        name="Settlement statement.xlsx"
        folder="… / Settlement / Statements"
        date="17 Nov 2026"
        uploadedBy="Mia Grant"
        type="Excel"
        size="84 KB"
        onOpen={noop}
        actions={more("More actions for Settlement statement.xlsx")}
      />
    </WorkspaceTable>
  );
}
```

### Interactions

Type badge, the title (a button that opens it; long ones truncate), sparkles when Firm Pilot summarised it, two faces at most, the date, time entry and billed (an empty value when there is none), the first tag and +N. An upcoming interaction fades its glyphs to 55 % and mutes its title, keeping AA contrast. Press Date or Billed to sort.

```tsx
<Interactions />
```

### Documents

Every column sorts. The doctype art at 20 px (the CRM passes @leapdev/gui-icons; never recolour it), the name, an optional folder path, then date, uploader, type and size.

```tsx
<Documents />
```

## Props

### WorkspaceTable

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` |  | Names the table for screen readers, like "Interactions". |
| `columns` (required) | `unknown` |  | The columns: id, label, and an optional width class and sort. |
| `sort` | `{ id: string; direction: SortDirection }` |  | The column it's sorted by now, and which way. |
| `onSortChange` | `(id: string) => void` |  | Called with a sortable column's id when its heading is pressed. |
| `children` (required) | `ReactNode` |  | The rows: WorkspaceInteractionRow or WorkspaceDocumentRow. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### WorkspaceInteractionRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` (required) | `InteractionTypeBadgeProps["type"]` |  | email, phone or meeting, as InteractionTypeBadge. |
| `direction` | `InteractionTypeBadgeProps["direction"]` |  | inbound or outbound, for the badge's arrow. |
| `title` (required) | `string` |  | The subject, or what the call or meeting was about. |
| `summarised` | `boolean` | `false` | Firm Pilot has summarised it: shows the sparkles. |
| `participants` | `AvatarItem[]` | `[]` | Who took part, two faces at most. |
| `date` (required) | `string` |  | When, already worded, like "Yesterday". |
| `timeEntry` | `string` |  | The time entry, like "0:30", or nothing for an empty value. |
| `billed` | `string` |  | What was billed, like "$120.00", or nothing for an empty value. |
| `tags` | `unknown` | `[]` | Interaction tags, after the title. |
| `upcoming` | `boolean` | `false` | Hasn't happened yet: its glyphs fade to 55 % and its title goes muted, so the text still passes AA. |
| `onOpen` | `() => void` |  | Opens the interaction. Makes the title a button. |
| `actions` | `ReactNode` |  | The row's menu, shown on hover or focus. |

### WorkspaceDocumentRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` (required) | `ReactNode` |  | The 20 px doctype art (PDF, Word, Excel, image). Brand file art: never recolour it. |
| `name` (required) | `string` |  | The document's file name. |
| `folder` | `string` |  | The folder it sits in, like "… / Contracts". |
| `date` (required) | `string` |  | When, already worded, like "18 Nov 2026". |
| `uploadedBy` (required) | `string` |  | Who added the document. |
| `type` (required) | `string` |  | The type's label, like "PDF". |
| `size` (required) | `string` |  | Already worded, like "1.2 MB". |
| `onOpen` | `() => void` |  | Opens the document. Makes the name a button. |
| `actions` | `ReactNode` |  | The row's menu, shown on hover or focus. |
