@aircall/ds 0.33.0 → 0.34.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.
@@ -3,7 +3,8 @@ name: aircall-ds/migrate-tractor/data-table
3
3
  description: >
4
4
  Migrate Tractor Table and TableColumn to the @aircall/ds DataTable (TanStack
5
5
  Table-backed). Load when a file imports Table or TableColumn from @aircall/tractor.
6
- Covers column definitions, sorting, row selection, loading states, and empty states.
6
+ Covers column definitions, sorting, row selection, column pinning (`stickTo` ->
7
+ `meta.pin`), loading states, and empty states.
7
8
  type: sub-skill
8
9
  library: aircall-ds
9
10
  requires:
@@ -40,6 +41,7 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
40
41
  | `onOrderChange(columnId)` | `onSortingChange` (receives `SortingState`) + `sorting` |
41
42
  | `order` (`OrderInput`) | `sorting` (`SortingState`) |
42
43
  | `footer` | column-level `ColumnDef.footer` (auto-renders `<tfoot>`) |
44
+ | `stickTo: 'left' \| 'right'` (Tractor column pinning) | `meta: { pin: 'left' \| 'right' }` on the column def |
43
45
  | _(no equivalent)_ | `loadingState="sorting"` / `"filtering"` (overlay spinner) |
44
46
  | _(no equivalent)_ | `loadingState="loadingMore"` (infinite scroll spinner row) |
45
47
  | _(no equivalent)_ | `onFetchMore` + `hasMore` (IntersectionObserver sentinel for infinite scroll) |
@@ -71,8 +73,42 @@ Tractor used a descriptor array (`TableColumn[]`) with a `renderer` function. DS
71
73
  | `label` | `header` (`ReactNode` or render function) |
72
74
  | `renderer(rowData, value, rowIndex)` | `cell: ({ row }) => row.original.<field>` |
73
75
  | `sortable: false` | `enableSorting: false` |
76
+ | `stickTo` / `StickTo.Left` / `StickTo.Right` | `meta: { pin: 'left' \| 'right' }` (implies fixed widths — set `size`) |
74
77
  | _(no equivalent)_ | `footer` (triggers `<tfoot>` rendering) |
75
- | _(no equivalent)_ | `size`, `minSize`, `maxSize` (for `enableColumnResizing`) |
78
+ | _(no equivalent)_ | `size`, `minSize`, `maxSize` (for `enableColumnResizing` / pinned columns) |
79
+
80
+ ### Column pinning (`stickTo` → `meta.pin`)
81
+
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:
83
+
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
+
104
+ Rules:
105
+
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.
110
+
111
+ Source: `packages/ds/src/components/data-table.tsx`
76
112
 
77
113
  ## 6. Before / After
78
114
 
@@ -332,6 +368,30 @@ Tractor `noDataMessage` accepted a `ReactNode` but was declared as a simple prop
332
368
 
333
369
  Source: `packages/ds/src/components/data-table.tsx`
334
370
 
371
+ ### Mistake 5 — `meta.pin` without a resolvable column id
372
+
373
+ ```tsx
374
+ // Wrong — no id / accessorKey / string header; pinning is silently skipped
375
+ {
376
+ header: () => <span>Status</span>,
377
+ cell: ({ row }) => <Badge>{row.original.status}</Badge>,
378
+ meta: { pin: 'left' }
379
+ }
380
+
381
+ // Correct — give TanStack (and DataTable) a stable id
382
+ {
383
+ id: 'status',
384
+ header: () => <span>Status</span>,
385
+ cell: ({ row }) => <Badge>{row.original.status}</Badge>,
386
+ size: 120,
387
+ meta: { pin: 'left' }
388
+ }
389
+ ```
390
+
391
+ `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).
392
+
393
+ Source: `packages/ds/src/components/data-table.tsx`
394
+
335
395
  ## 8. Infinite scroll and row virtualization
336
396
 
337
397
  `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.