@aircall/ds 0.50.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{data-table-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
  2. package/dist/data-table.d.ts +1 -1
  3. package/dist/globals.css +1 -1
  4. package/dist/index.d.ts +20 -12
  5. package/dist/index.js +14 -10
  6. package/package.json +2 -2
  7. package/skills/aircall-ds/migrate-audio-player/SKILL.md +14 -3
  8. package/skills/aircall-ds/migrate-icons/SKILL.md +45 -16
  9. package/skills/aircall-ds/migrate-tractor/SKILL.md +34 -31
  10. package/skills/aircall-ds/migrate-tractor/accordion/SKILL.md +25 -15
  11. package/skills/aircall-ds/migrate-tractor/alert/SKILL.md +107 -20
  12. package/skills/aircall-ds/migrate-tractor/avatar/SKILL.md +57 -26
  13. package/skills/aircall-ds/migrate-tractor/badge/SKILL.md +71 -25
  14. package/skills/aircall-ds/migrate-tractor/button/SKILL.md +68 -32
  15. package/skills/aircall-ds/migrate-tractor/card/SKILL.md +62 -42
  16. package/skills/aircall-ds/migrate-tractor/combobox/SKILL.md +233 -149
  17. package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +102 -108
  18. package/skills/aircall-ds/migrate-tractor/data-table/references/column-widths-and-pinning.md +50 -0
  19. package/skills/aircall-ds/migrate-tractor/data-table/references/infinite-scroll.md +51 -0
  20. package/skills/aircall-ds/migrate-tractor/data-table/references/row-actions.md +34 -0
  21. package/skills/aircall-ds/migrate-tractor/date-picker/SKILL.md +100 -47
  22. package/skills/aircall-ds/migrate-tractor/dialog/SKILL.md +115 -20
  23. package/skills/aircall-ds/migrate-tractor/dropdown-menu/SKILL.md +135 -57
  24. package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +2 -0
  25. package/skills/aircall-ds/migrate-tractor/form-and-field/SKILL.md +111 -49
  26. package/skills/aircall-ds/migrate-tractor/gauge/SKILL.md +6 -4
  27. package/skills/aircall-ds/migrate-tractor/input/SKILL.md +165 -59
  28. package/skills/aircall-ds/migrate-tractor/item/SKILL.md +85 -63
  29. package/skills/aircall-ds/migrate-tractor/link/SKILL.md +85 -68
  30. package/skills/aircall-ds/migrate-tractor/popover/SKILL.md +115 -74
  31. package/skills/aircall-ds/migrate-tractor/select/SKILL.md +117 -64
  32. package/skills/aircall-ds/migrate-tractor/sheet-vs-drawer/SKILL.md +55 -32
  33. package/skills/aircall-ds/migrate-tractor/skeleton/SKILL.md +40 -11
  34. package/skills/aircall-ds/migrate-tractor/styling/SKILL.md +11 -7
  35. package/skills/aircall-ds/migrate-tractor/tabs/SKILL.md +62 -55
  36. package/skills/aircall-ds/migrate-tractor/toast/SKILL.md +58 -12
  37. package/skills/aircall-ds/migrate-tractor/tooltip/SKILL.md +65 -40
  38. package/skills/aircall-ds/migrate-tractor/tree/SKILL.md +23 -6
  39. package/skills/aircall-ds/setup/SKILL.md +53 -8
@@ -2,9 +2,10 @@
2
2
  name: aircall-ds/migrate-tractor/data-table
3
3
  description: >
4
4
  Migrate Tractor Table and TableColumn to the @aircall/ds DataTable (TanStack
5
- Table-backed). Load when a file imports Table or TableColumn from @aircall/tractor.
6
- Covers column definitions, sorting, row selection, column pinning (`stickTo` ->
7
- `meta.pin`), loading states, and empty states.
5
+ Table-backed). Load when a file imports Table, TableColumn or ActionBar from
6
+ @aircall/tractor. Covers column definitions and widths, sorting, row selection with the
7
+ floating ActionBar, column pinning (`stickTo` -> `columnPinning`), row actions, loading
8
+ states, empty states, infinite scroll and row virtualization.
8
9
  type: sub-skill
9
10
  library: aircall-ds
10
11
  requires:
@@ -12,6 +13,9 @@ requires:
12
13
  - aircall-ds/migrate-tractor
13
14
  sources:
14
15
  - "aircall/hydra:packages/ds/src/components/data-table.tsx"
16
+ - "aircall/hydra:packages/ds/src/components/action-bar.tsx"
17
+ - "aircall/hydra:packages/ds/src/stories/DataTable.stories.tsx"
18
+ - "aircall/hydra:packages/ds/src/stories/DataTableColumnSizing.stories.tsx"
15
19
  ---
16
20
 
17
21
  This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the data-table-specific steps below.
@@ -24,6 +28,8 @@ DS `DataTable` is built on **TanStack Table v8**. Columns are defined as `Column
24
28
 
25
29
  There is no sub-component API (no `<TableColumn>`) — everything is declared in `columns`.
26
30
 
31
+ `DataTable` **never sorts or paginates rows itself**: it renders `data` as given. Turning sorting on (`onSortingChange`) only makes the headers clickable and reports the new `SortingState`; you sort `data` (client side) or re-query (server side) in response. For a static table with no state use the `Table` primitives (`Table`, `TableHeader`, `TableBody`, `TableRow`, `TableHead`, `TableCell`) instead.
32
+
27
33
  ## 2. Component mapping
28
34
 
29
35
  | Tractor | @aircall/ds |
@@ -34,24 +40,36 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
34
40
  | `columns[n].label` | `ColumnDef.header` |
35
41
  | `columns[n].renderer` | `ColumnDef.cell` (receives `{ row }`) |
36
42
  | `columns[n].sortable` | `ColumnDef.enableSorting` |
37
- | `loading={true}` | `loadingState="loading"` |
43
+ | `loading={true}` | `loadingState="loading"` (skeleton rows) |
44
+ | `pageSize` (number of skeleton rows while loading) | `skeletonCount` (default 5) |
38
45
  | `noDataMessage` | `emptyState` (accepts any `ReactNode`) |
39
- | `onRowClick(record, event)` | `onRowClick(row)` (no `event` argument) |
46
+ | `onRowClick(record, event)` | `onRowClick(row)` — receives the data record (`TData`), no `event` argument. Once a row is selected, a row click toggles selection instead |
40
47
  | `bulkActions` + `verticalScrollingParent` | `selectionMode` + `actionBar` |
48
+ | `hideActionBar` | omit `actionBar` |
49
+ | `onSelectionChange(rows, count)` | `onSelectionChange(keys: Set<string>)` |
50
+ | `recordAttributeIdentifier` (default `'id'`) | `getRowId` (default: the row index) |
51
+ | `disableRow` / `unselectableRowCondition` | `disabledKeys: Set<string>` + `disabledBehavior` (`'all'` default: dimmed and inert; `'selection'`: only unselectable, still clickable) |
52
+ | `rowActions` + `rowActionsType` | a trailing `ColumnDef` whose `cell` renders a `DropdownMenu` (see §6d) |
41
53
  | `onOrderChange(columnId)` | `onSortingChange` (receives `SortingState`) + `sorting` |
42
54
  | `order` (`OrderInput`) | `sorting` (`SortingState`) |
43
- | `footer` | column-level `ColumnDef.footer` (auto-renders `<tfoot>`) |
44
- | `stickTo: 'left' \| 'right'` (Tractor column pinning) | `meta: { pin: 'left' \| 'right' }` on the column def |
45
- | _(no equivalent)_ | `loadingState="sorting"` / `"filtering"` (overlay spinner) |
55
+ | `footer` (any node under the table) | column-level `ColumnDef.footer` (column-aligned summary cells, auto-renders `<tfoot>`); render other footer content (e.g. a count) outside `DataTable` |
56
+ | `stickTo: 'left' \| 'right'` (Tractor column pinning) | `columnPinning={{ left: [ids], right: [ids] }}` prop on `DataTable` |
57
+ | `w` / `h` / sizing props | `className`; `fillHeight` inside a bounded flex parent |
58
+ | _(no equivalent)_ | `loadingState="sorting"` / `"filtering"` (overlay spinner over the current rows) |
46
59
  | _(no equivalent)_ | `loadingState="loadingMore"` (infinite scroll spinner row) |
47
60
  | _(no equivalent)_ | `onFetchMore` + `hasMore` (IntersectionObserver sentinel for infinite scroll) |
48
61
  | _(no equivalent)_ | `fillHeight` (sticky header, internal scroll) |
49
62
  | _(no equivalent)_ | `virtualizeRows` (explicit row virtualization — requires `fillHeight`) |
63
+ | _(no equivalent)_ | `enableColumnResizing`, `columnVisibility` (controlled `VisibilityState`) |
50
64
 
51
65
  ## 3. Verified DS exports (`packages/ds/src/index.ts`)
52
66
 
53
67
  ```
54
- DataTable, type ColumnDef, type DataTableLoadingState, type OnChangeFn, type SortingState
68
+ DataTable, type ColumnDef, type ColumnPinningState, type DataTableLoadingState,
69
+ type OnChangeFn, type SortingState, type VisibilityState
70
+ Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell // static primitives
71
+ ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight
72
+ Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent
55
73
  ```
56
74
 
57
75
  `@aircall/ds` **exposes** the TanStack Table types you author — `ColumnDef`, `SortingState`, `OnChangeFn` — as bound aliases, so **import them from `@aircall/ds`**, not `@tanstack/react-table`. The react-table runtime ships as a regular `@aircall/ds` dependency (auto-installed; `DataTable` owns the table instance internally), so there is nothing to install and no version to keep in sync.
@@ -60,7 +78,7 @@ DataTable, type ColumnDef, type DataTableLoadingState, type OnChangeFn, type Sor
60
78
 
61
79
  ```tsx
62
80
  import { DataTable, type DataTableLoadingState } from '@aircall/ds';
63
- import type { ColumnDef, SortingState, OnChangeFn } from '@aircall/ds';
81
+ import type { ColumnDef, ColumnPinningState, SortingState, OnChangeFn, VisibilityState } from '@aircall/ds';
64
82
  ```
65
83
 
66
84
  ## 5. Column definitions
@@ -72,41 +90,21 @@ Tractor used a descriptor array (`TableColumn[]`) with a `renderer` function. DS
72
90
  | `id` | `accessorKey` (auto-creates accessor) or `id` + `accessorFn` |
73
91
  | `label` | `header` (`ReactNode` or render function) |
74
92
  | `renderer(rowData, value, rowIndex)` | `cell: ({ row }) => row.original.<field>` |
75
- | `sortable: false` | `enableSorting: false` |
76
- | `stickTo` / `StickTo.Left` / `StickTo.Right` | `meta: { pin: 'left' \| 'right' }` (implies fixed widths — set `size`) |
93
+ | `sortable: false` | `enableSorting: false` (a column with an accessor is sortable once `onSortingChange` is passed; display columns are not) |
94
+ | `textAlign` | Tailwind on the cell content, e.g. `cell: … => <div className="text-right">…</div>` |
95
+ | `stickTo` / `StickTo.Left` / `StickTo.Right` | the table-level `columnPinning` prop (ids of the pinned columns) — not a field on the column def |
77
96
  | _(no equivalent)_ | `footer` (triggers `<tfoot>` rendering) |
78
- | _(no equivalent)_ | `size`, `minSize`, `maxSize` (for `enableColumnResizing` / pinned columns) |
97
+ | _(no equivalent)_ | `size`, `minSize`, `maxSize`, `flex` — see "Column widths" below |
79
98
 
80
- ### Column pinning (`stickTo` → `meta.pin`)
99
+ ### Column widths
81
100
 
82
- Tractor pinned columns with `stickTo: StickTo.Left | StickTo.Right` (selection stuck left, row actions stuck right). DS uses TanStack column pinning behind a declarative column-def field:
101
+ A numeric `size` is static (exact px); a column without one is flexible and shares the leftover space equally (`flex` weights the share, `minSize` is the floor, default 75, `maxSize` caps). Keep at least one column flexible. `fixedLayout` is a deprecated no-op: delete it.
83
102
 
84
- ```tsx
85
- const columns: ColumnDef<Person>[] = [
86
- {
87
- accessorKey: 'name',
88
- header: 'Name',
89
- size: 220,
90
- meta: { pin: 'left' }
91
- },
92
- { accessorKey: 'email', header: 'Email', size: 280 },
93
- {
94
- id: 'actions',
95
- header: '',
96
- size: 40,
97
- enableResizing: false,
98
- meta: { pin: 'right' },
99
- cell: ({ row }) => <RowActionsMenu person={row.original} />
100
- }
101
- ];
102
- ```
103
+ ### Column pinning (`stickTo` → `columnPinning`)
103
104
 
104
- Rules:
105
+ Pin with the controlled table-level `columnPinning={{ left: [ids], right: [ids] }}` prop, never a per-column field. Ids resolve as `id` → string `accessorKey` → string `header`; display columns need an explicit `id`. With `selectionMode` on, the checkbox column auto-pins left when anything is pinned. There is no `onColumnPinningChange`.
105
106
 
106
- - **Set an explicit `size`** on every pinned column (and prefer sizes on siblings). Pinning implies `table-layout: fixed`; missing `size` falls back to TanStack's 150px default.
107
- - **Resolvable id required.** Pinning derives TanStack `columnPinning` from column ids. Resolution matches TanStack: `id` → string `accessorKey` → string `header`. Display-only columns (`cell` + non-string `header`, no `id`/`accessorKey`) need an explicit `id` or pinning is skipped (dev warning).
108
- - **Selection auto-pin is gated.** When `selectionMode` is on *and* at least one consumer column has `meta.pin`, the built-in checkbox column is also auto-pinned left. Selection-only tables without `meta.pin` stay on fluid layout.
109
- - Tractor's left-pinned select + right-pinned actions map to: pin your identity/name column(s) left, pin the actions column right, enable `selectionMode` — the checkbox column joins the left pin group automatically.
107
+ See `references/column-widths-and-pinning.md` for the full width model, pinning rules and a worked example.
110
108
 
111
109
  Source: `packages/ds/src/components/data-table.tsx`
112
110
 
@@ -191,7 +189,7 @@ const columns: TableColumn<Person>[] = [
191
189
  ```tsx
192
190
  // After
193
191
  import { DataTable } from '@aircall/ds';
194
- import type { ColumnDef, SortingState, OnChangeFn } from '@aircall/ds';
192
+ import type { ColumnDef, SortingState } from '@aircall/ds';
195
193
 
196
194
  const [sorting, setSorting] = React.useState<SortingState>([{ id: 'firstName', desc: false }]);
197
195
 
@@ -212,7 +210,8 @@ const columns: ColumnDef<Person>[] = [
212
210
 
213
211
  Key changes:
214
212
  - `order: OrderInput` → `sorting: SortingState` (array of `{ id, desc }` objects)
215
- - `onOrderChange(columnId)` → `onSortingChange: OnChangeFn<SortingState>` (receives the new full state)
213
+ - `onOrderChange(columnId)` → `onSortingChange: OnChangeFn<SortingState>` (receives the new full state, so there is no direction toggling to write)
214
+ - `DataTable` does not reorder `data`: refetch with the new `sorting` (server side), or sort the array yourself (client side, see the `Full` story)
216
215
  - A `loadingState="sorting"` dims the existing rows with an overlay spinner while the server re-queries — no skeleton flash
217
216
 
218
217
  ### 6c. Selectable table with bulk action bar
@@ -240,6 +239,8 @@ const parentRef = React.useRef<HTMLDivElement | null>(null);
240
239
  import { DataTable } from '@aircall/ds';
241
240
  import { ActionBar, ActionBarButton } from '@aircall/ds';
242
241
 
242
+ import { Trash } from '@aircall/react-icons';
243
+
243
244
  const [selectedKeys, setSelectedKeys] = React.useState<Set<string>>(new Set());
244
245
 
245
246
  <DataTable
@@ -249,10 +250,11 @@ const [selectedKeys, setSelectedKeys] = React.useState<Set<string>>(new Set());
249
250
  selectionMode="multiple"
250
251
  selectedKeys={selectedKeys}
251
252
  onSelectionChange={setSelectedKeys}
253
+ // Inside a DataTable, ActionBar reads `count` and the Clear handler from context: no props needed.
252
254
  actionBar={
253
255
  <ActionBar>
254
- <ActionBarButton variant="destructive" onClick={() => deleteSelected()}>
255
- Delete
256
+ <ActionBarButton onClick={deleteSelected}>
257
+ <Trash /> Delete
256
258
  </ActionBarButton>
257
259
  </ActionBar>
258
260
  }
@@ -260,10 +262,19 @@ const [selectedKeys, setSelectedKeys] = React.useState<Set<string>>(new Set());
260
262
  ```
261
263
 
262
264
  Key changes:
263
- - `verticalScrollingParent` is not needed — `DataTable` manages its own ActionBar positioning
264
- - `bulkActions` array → pass an `<ActionBar>` node to the `actionBar` prop
265
- - `onSelectionChange(selectedRows, count)` is replaced by controlled `selectedKeys` — a React-Spectrum-style `Set<string>` of row ids — derive selected records from `people.filter(p => selectedKeys.has(p.id))`
266
- - `getRowId` is required when selection must survive data refreshes (server pagination)
265
+ - `verticalScrollingParent` is not needed — the bar floats at the bottom of the table and the scroll area reserves space for it
266
+ - `bulkActions` array → pass an `<ActionBar>` node to the `actionBar` prop. The bar shows only while at least one selected row is **in the current `data`**, with an "N items selected." label and a clear (X) button. Its count comes from the loaded rows (`getSelectedRowModel()`), not from `selectedKeys`
267
+ - `ActionBarButton` is always `ghost`; it only takes `size="default" | "icon"`. There is no `variant` prop, so a destructive action is not styled red: say so in the label/icon. Put the icon inside as a child
268
+ - `ActionBar` outside a `DataTable` needs its own `count` and `onClear` props (or an `ActionBarContext` provider)
269
+ - `onSelectionChange(selectedRows, count)` is replaced by controlled `selectedKeys` — a React-Spectrum-style `Set<string>` of row ids. For the current page, derive selected records from `data.filter(p => selectedKeys.has(p.id))`
270
+ - `selectionMode="single"` shows a checkbox column with no select-all header; picking a row replaces the selection
271
+ - `getRowId` is required when selection must survive data refreshes (server pagination); without it the keys are row indexes
272
+ - **Selection across pages:** with server pagination, keys survive a page change but the built-in bar only counts rows on the loaded page, so it hides when the user moves to a page with none selected, and `data.filter` can't see off-page records. For cross-page bulk actions, keep the selected records yourself (a `Map` updated in `onSelectionChange`), render your own `ActionBar` outside the table with `count` / `onClear` from that state, and leave the `actionBar` prop unset
273
+ - Once anything is selected, clicking a row toggles it instead of calling `onRowClick`. Interactive cells (menus, links) must stop propagation themselves; the built-in checkbox already does
274
+
275
+ ### 6d. Row actions column
276
+
277
+ Tractor's `rowActions` / `rowActionsType` become an ordinary trailing column (`id: 'actions'`, `header: ''`, static `size: 40`, `enableResizing: false`) whose `cell` renders a `DropdownMenu`; wrap it in a div that stops click propagation so it does not fire `onRowClick`. See `references/row-actions.md` for the full example.
267
278
 
268
279
  ## 7. Common mistakes
269
280
 
@@ -289,7 +300,7 @@ const columns: ColumnDef<Person>[] = [
289
300
  ];
290
301
  ```
291
302
 
292
- `ColumnDef` has no `renderer` field — passing it adds an unrecognised property that TypeScript will not catch (the field just becomes dead code). The cell always renders the raw accessor value. Use `cell: ({ row }) => …` and access typed row data via `row.original`.
303
+ `ColumnDef` has no `renderer` field — it is dead code and is never called, so the cell renders the raw accessor value. Use `cell: ({ row }) => …` and access typed row data via `row.original`.
293
304
 
294
305
  Source: `packages/ds/src/components/data-table.tsx`
295
306
 
@@ -349,93 +360,76 @@ Source: `packages/ds/src/components/data-table.tsx`
349
360
  <DataTable data={[]} columns={columns} noDataMessage="No records found." />
350
361
 
351
362
  // Correct — emptyState accepts any ReactNode; render an Empty component for rich states
352
- import { Empty, EmptyContent, EmptyTitle, EmptyDescription } from '@aircall/ds';
363
+ import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@aircall/ds';
364
+ import { Search } from '@aircall/react-icons';
353
365
 
354
366
  <DataTable
355
367
  data={[]}
356
368
  columns={columns}
357
369
  emptyState={
358
370
  <Empty>
359
- <EmptyContent>
371
+ <EmptyHeader>
372
+ <EmptyMedia variant="icon">
373
+ <Search />
374
+ </EmptyMedia>
360
375
  <EmptyTitle>No records found</EmptyTitle>
361
376
  <EmptyDescription>Try adjusting your filters.</EmptyDescription>
362
- </EmptyContent>
377
+ </EmptyHeader>
363
378
  </Empty>
364
379
  }
365
380
  />
366
381
  ```
367
382
 
368
- Tractor `noDataMessage` accepted a `ReactNode` but was declared as a simple prop. DS requires an `emptyState` prop; `noDataMessage` is silently ignored. For plain text, wrap it in a `<p>` with `text-sm text-muted-foreground`. For a full empty state with an icon and a call-to-action, use the `Empty` compound from `@aircall/ds`.
383
+ Tractor `noDataMessage` accepted a `ReactNode` but was declared as a simple prop. DS requires an `emptyState` prop; `noDataMessage` is silently ignored. For plain text, wrap it in a `<p>` with `text-sm text-muted-foreground`. For a full empty state use the `Empty` compound from `@aircall/ds`: `EmptyHeader` holds the media, title and description, and `EmptyContent` is the region below for actions (buttons). In an `@aircall/blocks` app prefer `NoDataEmptyState` (search/filter with no results) or the other `*EmptyState` presets. `emptyState` shows only when there are no rows and `loadingState` is not `'loading'`; nothing renders if you omit it.
369
384
 
370
385
  Source: `packages/ds/src/components/data-table.tsx`
371
386
 
372
- ### Mistake 5 — `meta.pin` without a resolvable column id
387
+ ### Mistake 5 — Pinning with `stickTo` or `meta.pin` instead of the `columnPinning` prop
373
388
 
374
389
  ```tsx
375
- // Wrong — no id / accessorKey / string header; pinning is silently skipped
376
- {
377
- header: () => <span>Status</span>,
378
- cell: ({ row }) => <Badge>{row.original.status}</Badge>,
379
- meta: { pin: 'left' }
380
- }
381
-
382
- // Correct — give TanStack (and DataTable) a stable id
383
- {
384
- id: 'status',
385
- header: () => <span>Status</span>,
386
- cell: ({ row }) => <Badge>{row.original.status}</Badge>,
387
- size: 120,
388
- meta: { pin: 'left' }
389
- }
390
+ // Wrong — stickTo is Tractor's; meta.pin was removed from DataTable and is ignored
391
+ const columns: ColumnDef<Person>[] = [
392
+ { accessorKey: 'name', header: 'Name', size: 220, stickTo: 'left' },
393
+ { id: 'actions', header: '', size: 40, meta: { pin: 'right' } }
394
+ ];
395
+ <DataTable columns={columns} data={people} />
396
+
397
+ // Correct — pin by column id on the table
398
+ <DataTable
399
+ columns={columns}
400
+ data={people}
401
+ columnPinning={{ left: ['name'], right: ['actions'] }}
402
+ />
390
403
  ```
391
404
 
392
- `meta.pin` is applied by deriving `columnPinning` from column ids before render. If the id cannot be resolved, the column does not pin (dev-only console warning). Prefer `id` or a string `accessorKey`; a string `header` also works as a last resort (same as TanStack).
405
+ Pinning is a controlled table-level prop (`ColumnPinningState`, arrays of column ids), like `sorting` and `columnVisibility`. The ids are the ones TanStack resolves: `id`, else the `accessorKey` (dots become `_`), else a string `header`. A column with none of those, such as a display column with a render-function `header`, needs an explicit `id` or the id in `columnPinning` matches nothing.
393
406
 
394
407
  Source: `packages/ds/src/components/data-table.tsx`
395
408
 
396
- ## 8. Infinite scroll and row virtualization
409
+ ### Mistake 6 — Declaring a `size` on every column
397
410
 
398
- `DataTable` supports infinite scroll via `onFetchMore` + `hasMore` (IntersectionObserver sentinel). Row virtualization is a **separate, explicit opt-in** via the `virtualizeRows` prop — the consumer decides when to enable it.
411
+ ```tsx
412
+ // Wrong — every column is static, so nothing absorbs the container width and the table ends short
413
+ const columns: ColumnDef<Person>[] = [
414
+ { accessorKey: 'name', header: 'Name', size: 260 },
415
+ { accessorKey: 'email', header: 'Email', size: 280 },
416
+ { id: 'actions', header: '', size: 40 }
417
+ ];
399
418
 
400
- `virtualizeRows` **requires `fillHeight={true}`** — the container must scroll internally so the virtualizer can track `scrollTop`. Without `fillHeight` the page scrolls instead, `scrollTop` stays 0, and the virtual window never updates.
419
+ // Correct — static for columns with a known width, flexible (with a floor) for the rest
420
+ const columns: ColumnDef<Person>[] = [
421
+ { accessorKey: 'name', header: 'Name', minSize: 260 },
422
+ { accessorKey: 'email', header: 'Email', minSize: 200 },
423
+ { id: 'actions', header: '', size: 40 }
424
+ ];
425
+ ```
401
426
 
402
- Use `virtualizeRows` on any table with 1 000+ rows: infinite-scroll tables that accumulate pages, or static datasets loaded all at once.
427
+ A numeric `size` is exact and never grows; a column without one takes an equal share of the free space. The selection checkbox column is always 40px static, so with `selectionMode` on, at least one more column must stay flexible.
403
428
 
404
- `virtualizeRows` **implies `fixedLayout`** (`table-layout: fixed`) — the virtualizer needs stable column widths, so every column takes its `size` instead of sizing to content. **Columns without a `size` fall back to TanStack's 150px default.** This is a visible tradeoff: a table that relied on content-based auto widths (e.g. a narrow icon column) will snap to 150px columns the moment you enable virtualization. Give each column def an explicit `size` (`minSize`/`maxSize` optional) that matches the intended width. Verify column widths in the browser — `tsc`/tests won't catch this.
429
+ Source: `packages/ds/src/components/data-table.tsx`
405
430
 
406
- ```tsx
407
- // Infinite scroll with virtualization
408
- function CallsTable() {
409
- const [items, setItems] = React.useState<Call[]>(() => fetchPage(0));
410
- const [isFetchingMore, setIsFetchingMore] = React.useState(false);
411
- const hasMore = items.length < totalCount;
412
-
413
- const onFetchMore = React.useCallback(() => {
414
- if (isFetchingMore || !hasMore) return;
415
- setIsFetchingMore(true);
416
- fetchPage(items.length).then(page => {
417
- setItems(prev => [...prev, ...page]);
418
- setIsFetchingMore(false);
419
- });
420
- }, [isFetchingMore, hasMore, items.length]);
421
-
422
- return (
423
- <div className="flex h-dvh flex-col p-4">
424
- <DataTable
425
- columns={columns} // each column must have a size when virtualizing
426
- data={items}
427
- getRowId={row => row.id}
428
- fillHeight
429
- virtualizeRows
430
- onFetchMore={onFetchMore}
431
- hasMore={hasMore}
432
- loadingState={isFetchingMore ? 'loadingMore' : 'idle'}
433
- />
434
- </div>
435
- );
436
- }
437
- ```
431
+ ## 8. Infinite scroll and row virtualization
438
432
 
439
- **Pagination does not need virtualization.** With pagination you replace `data` on each page change — the row count stays constant. Do not pass `onFetchMore`; use an external `<Pagination>` component instead.
433
+ `onFetchMore` + `hasMore` give infinite scroll; `virtualizeRows` is a separate opt-in that **requires `fillHeight`** inside a bounded-height parent. Pagination needs neither. See `references/infinite-scroll.md` for the rules and a full example.
440
434
 
441
- Source: `packages/ds/src/components/data-table.tsx`
435
+ Source: `packages/ds/src/components/data-table.tsx`, `packages/ds/src/stories/DataTable.stories.tsx` (`VirtualizedInfiniteScroll`, `InfiniteScroll`)
@@ -0,0 +1,50 @@
1
+ ## Column widths
2
+
3
+ Tractor sized columns from content. DS resolves every column width from the defs, in every mode (this is what React Spectrum's `TableView` does too):
4
+
5
+ - **`size: 40`** — static: exactly 40px at every container width. Use it for columns with a known width (checkbox, icon, row actions, status badge).
6
+ - **no `size`** — flexible: an equal share of whatever the static columns leave. This is the default, so leave identity columns (name, email) without a `size`.
7
+ - **`flex: 2`** — flexible with twice the share. **`minSize`** is the floor (defaults to **75** on a flexible column; when floors exceed the container the table scrolls horizontally instead of crushing columns). **`maxSize`** caps it.
8
+ - If **every** column declares a `size`, nothing absorbs the container width and the table ends short of its right edge. Keep at least one column flexible (give it a `minSize` rather than a `size`).
9
+ - Cells clip at the column edge. Wrap long text in a `truncate` div for an ellipsis.
10
+ - `fixedLayout` is deprecated and does nothing (still accepted); delete it.
11
+
12
+ ## Column pinning (`stickTo` → `columnPinning`)
13
+
14
+ Tractor pinned columns with `stickTo: StickTo.Left | StickTo.Right` (selection stuck left, row actions stuck right). DS has a controlled `columnPinning` prop (TanStack `ColumnPinningState`) that lists column ids; there is no per-column field and no `meta.pin`:
15
+
16
+ ```tsx
17
+ const columns: ColumnDef<Person>[] = [
18
+ { accessorKey: 'name', header: 'Name', size: 220 },
19
+ { accessorKey: 'email', header: 'Email', minSize: 280 }, // flexible: absorbs the spare width
20
+ { accessorKey: 'phone', header: 'Phone', size: 200 },
21
+ {
22
+ id: 'actions',
23
+ header: '',
24
+ size: 40,
25
+ enableResizing: false,
26
+ cell: ({ row }) => <RowActionsMenu person={row.original} />
27
+ }
28
+ ];
29
+
30
+ <DataTable
31
+ columns={columns}
32
+ data={people}
33
+ getRowId={row => row.id}
34
+ columnPinning={{ left: ['name'], right: ['actions'] }}
35
+ selectionMode="multiple"
36
+ selectedKeys={selectedKeys}
37
+ onSelectionChange={setSelectedKeys}
38
+ fillHeight
39
+ />
40
+ ```
41
+
42
+ Rules:
43
+
44
+ - **Use ids that the table resolves.** The ids in `columnPinning` are the column ids: `id` → string `accessorKey` (dots replaced by `_`) → string `header`. A display-only column (`cell` with a non-string `header`, no `id`/`accessorKey`) needs an explicit `id` to be pinnable.
45
+ - Pin offsets come from the resolved widths, so pinned columns need no special sizing. Give pinned columns a `size` when their width is known (a name column, the actions column) and keep at least one unpinned column flexible.
46
+ - **Selection auto-pin.** When `columnPinning` pins anything and `selectionMode` is on, the built-in checkbox column is auto-pinned left so it cannot scroll away from its rows. A selection-only table with no `columnPinning` stays unpinned.
47
+ - `columnPinning` is a controlled prop with no `onColumnPinningChange` callback: the user can't re-pin columns from the UI. You can still change pinning at runtime by passing a new value from your own state (a toggle, a screen-size hook), and the table re-resolves it.
48
+ - Tractor's left-pinned select + right-pinned actions map to: list your identity column(s) in `columnPinning.left`, the actions column in `columnPinning.right`, and enable `selectionMode`.
49
+
50
+ Source: `packages/ds/src/components/data-table.tsx`
@@ -0,0 +1,51 @@
1
+ ## Infinite scroll and row virtualization
2
+
3
+ `DataTable` supports infinite scroll via `onFetchMore` + `hasMore` (IntersectionObserver sentinel row at the bottom, with a 200px look-ahead). Row virtualization is a **separate, explicit opt-in** via the `virtualizeRows` prop. Unlike `DataCombobox`, `DataTable` has no `'auto'` mode: `virtualizeRows` is a plain boolean and is off unless you pass it.
4
+
5
+ `fillHeight` makes the table fill its parent and scroll its body inside, with a sticky header. The parent must supply a bounded height (a `flex flex-col` parent with `min-h-0`/fixed height). Without a bounded parent it has no effect. `onFetchMore` works with or without `fillHeight`, but inside a page that scrolls the sentinel is measured against the viewport, so for a list page use `fillHeight`.
6
+
7
+ `virtualizeRows` **requires `fillHeight`** — the container must scroll internally so the virtualizer can track `scrollTop`. Without `fillHeight` it is ignored (the page scrolls instead and the virtual window never updates).
8
+
9
+ Use `virtualizeRows` on any table with 1 000+ rows: infinite-scroll tables that accumulate pages, or static datasets loaded all at once.
10
+
11
+ **Virtualization needs no sizing setup.** Column widths are resolved from the column defs in every mode, so turning it on does not change the widths (the old "implies `fixedLayout`, columns fall back to 150px" behaviour is gone, and `fixedLayout` is a deprecated no-op). Follow the usual width rule instead: `size` for columns with a known width, none (or `minSize`/`flex`) for the rest.
12
+
13
+ ```tsx
14
+ // Infinite scroll with virtualization
15
+ function CallsTable() {
16
+ const [items, setItems] = React.useState<Call[]>(() => fetchPage(0));
17
+ const [isFetchingMore, setIsFetchingMore] = React.useState(false);
18
+ const hasMore = items.length < totalCount;
19
+
20
+ const onFetchMore = React.useCallback(() => {
21
+ if (isFetchingMore || !hasMore) return;
22
+ setIsFetchingMore(true);
23
+ fetchPage(items.length).then(page => {
24
+ setItems(prev => [...prev, ...page]);
25
+ setIsFetchingMore(false);
26
+ });
27
+ }, [isFetchingMore, hasMore, items.length]);
28
+
29
+ return (
30
+ <div className="flex h-dvh flex-col p-4">
31
+ <DataTable
32
+ columns={columns}
33
+ data={items}
34
+ getRowId={row => row.id}
35
+ fillHeight
36
+ virtualizeRows
37
+ onFetchMore={onFetchMore}
38
+ hasMore={hasMore}
39
+ loadingState={isFetchingMore ? 'loadingMore' : 'idle'}
40
+ />
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ - `onFetchMore` fires once per intersection and re-arms when `data` changes length. Guard against double fetches with your own `isFetchingMore` flag, as above; while `loadingState` is `'loadingMore'` the sentinel is replaced by a spinner row.
47
+ - Selection keys persist across pages as long as `getRowId` returns stable ids.
48
+
49
+ **Pagination does not need virtualization.** With pagination you replace `data` on each page change — the row count stays constant. Do not pass `onFetchMore`; use an external `<Pagination>` component instead.
50
+
51
+ Source: `packages/ds/src/components/data-table.tsx`, `packages/ds/src/stories/DataTable.stories.tsx` (`VirtualizedInfiniteScroll`, `InfiniteScroll`)
@@ -0,0 +1,34 @@
1
+ ## Row actions column
2
+
3
+ Tractor's `rowActions` / `rowActionsType` become an ordinary trailing column. Use a static `size` and keep it unresizable:
4
+
5
+ ```tsx
6
+ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@aircall/ds';
7
+ import { EllipsisVertical } from '@aircall/react-icons';
8
+
9
+ const actionsColumn: ColumnDef<Person> = {
10
+ id: 'actions',
11
+ header: '',
12
+ size: 40,
13
+ enableResizing: false,
14
+ cell: ({ row }) => (
15
+ // DataTable only guards its own checkbox: stop the click so opening the menu does not fire onRowClick
16
+ <div onClick={e => e.stopPropagation()}>
17
+ <DropdownMenu>
18
+ <DropdownMenuTrigger
19
+ render={<Button variant="ghost" size="icon-sm" aria-label={`Actions for ${row.original.firstName}`} />}
20
+ >
21
+ <EllipsisVertical />
22
+ </DropdownMenuTrigger>
23
+ <DropdownMenuContent align="end">
24
+ <DropdownMenuItem>Edit</DropdownMenuItem>
25
+ <DropdownMenuSeparator />
26
+ <DropdownMenuItem variant="destructive">Delete</DropdownMenuItem>
27
+ </DropdownMenuContent>
28
+ </DropdownMenu>
29
+ </div>
30
+ )
31
+ };
32
+ ```
33
+
34
+ Every body row has a named hover group (`group/row`), so a cell that reveals itself on hover or focus can use `group-hover/row:` and `group-focus-within/row:`. See `aircall-ds/migrate-tractor/dropdown-menu` for the menu parts.