@aircall/ds 0.34.1 → 0.35.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.
- package/AGENTS.consumer.md +3 -2
- package/README.md +1 -5
- package/dist/data-table-C9eD8va8.d.ts +179 -0
- package/dist/data-table-DpKxtE_u.js +1207 -0
- package/dist/data-table.d.ts +2 -0
- package/dist/data-table.js +2 -0
- package/dist/index.d.ts +1 -166
- package/dist/index.js +7 -1203
- package/package.json +7 -7
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +24 -23
- package/skills/aircall-ds/setup/SKILL.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aircall/ds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": [
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"default": "./dist/index.js"
|
|
27
27
|
},
|
|
28
|
+
"./data-table": {
|
|
29
|
+
"types": "./dist/data-table.d.ts",
|
|
30
|
+
"default": "./dist/data-table.js"
|
|
31
|
+
},
|
|
28
32
|
"./globals.css": "./dist/globals.css",
|
|
29
33
|
"./theme.css": "./dist/theme.css",
|
|
30
34
|
"./fonts/*": "./src/fonts/*.woff2"
|
|
@@ -33,7 +37,6 @@
|
|
|
33
37
|
"@aircall/hooks": "*",
|
|
34
38
|
"@aircall/numbers": "*",
|
|
35
39
|
"@aircall/react-icons": "*",
|
|
36
|
-
"@tanstack/react-table": "^8.0.0",
|
|
37
40
|
"date-fns": "^4.0.0",
|
|
38
41
|
"i18next": ">=20.3.0 <24",
|
|
39
42
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -41,9 +44,6 @@
|
|
|
41
44
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
42
45
|
},
|
|
43
46
|
"peerDependenciesMeta": {
|
|
44
|
-
"@tanstack/react-table": {
|
|
45
|
-
"optional": true
|
|
46
|
-
},
|
|
47
47
|
"react-day-picker": {
|
|
48
48
|
"optional": true
|
|
49
49
|
},
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@platejs/markdown": "53.3.3",
|
|
66
66
|
"@platejs/mention": "53.0.0",
|
|
67
67
|
"@platejs/slash-command": "53.0.0",
|
|
68
|
+
"@tanstack/react-table": "8.20.6",
|
|
68
69
|
"@tanstack/react-virtual": "3.13.12",
|
|
69
70
|
"class-variance-authority": "0.7.1",
|
|
70
71
|
"clsx": "2.1.1",
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@aircall/numbers": "*",
|
|
84
85
|
"@aircall/react-icons": "*",
|
|
85
|
-
"@aircall/tsconfig": "1.4.
|
|
86
|
+
"@aircall/tsconfig": "1.4.4",
|
|
86
87
|
"@chromatic-com/storybook": "5.0.2",
|
|
87
88
|
"@faker-js/faker": "10.2.0",
|
|
88
89
|
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
|
@@ -96,7 +97,6 @@
|
|
|
96
97
|
"@tailwindcss/cli": "4.1.18",
|
|
97
98
|
"@tailwindcss/postcss": "4.1.18",
|
|
98
99
|
"@tanstack/intent": "0.1.1",
|
|
99
|
-
"@tanstack/react-table": "8.20.6",
|
|
100
100
|
"@turbo/gen": "2.4.2",
|
|
101
101
|
"@types/node": "24",
|
|
102
102
|
"@types/react": "19",
|
|
@@ -20,7 +20,7 @@ This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules f
|
|
|
20
20
|
|
|
21
21
|
Tractor `Table` was a self-contained component: you passed `data`, `columns` (a `TableColumn[]` descriptor array), and optional callbacks — Tractor handled layout, sorting state, and selection state internally.
|
|
22
22
|
|
|
23
|
-
DS `DataTable` is built on **TanStack Table v8**. Columns are defined as `ColumnDef<TData>[]` (from `@
|
|
23
|
+
DS `DataTable` is built on **TanStack Table v8**. Columns are defined as `ColumnDef<TData>[]` (a bound alias exported from `@aircall/ds`), sorting and selection state are controlled externally by the caller, and loading is expressed as a single `loadingState` string rather than a boolean `loading` flag.
|
|
24
24
|
|
|
25
25
|
There is no sub-component API (no `<TableColumn>`) — everything is declared in `columns`.
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
|
|
|
29
29
|
| Tractor | @aircall/ds |
|
|
30
30
|
| --- | --- |
|
|
31
31
|
| `<Table data columns loading ...>` | `<DataTable data columns loadingState ...>` |
|
|
32
|
-
| `TableColumn<T>` (object descriptor) | `ColumnDef<TData, unknown>` from `@
|
|
32
|
+
| `TableColumn<T>` (object descriptor) | `ColumnDef<TData, unknown>` from `@aircall/ds` |
|
|
33
33
|
| `columns[n].id` | `ColumnDef.id` (or accessor key) |
|
|
34
34
|
| `columns[n].label` | `ColumnDef.header` |
|
|
35
35
|
| `columns[n].renderer` | `ColumnDef.cell` (receives `{ row }`) |
|
|
@@ -37,7 +37,7 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
|
|
|
37
37
|
| `loading={true}` | `loadingState="loading"` |
|
|
38
38
|
| `noDataMessage` | `emptyState` (accepts any `ReactNode`) |
|
|
39
39
|
| `onRowClick(record, event)` | `onRowClick(row)` (no `event` argument) |
|
|
40
|
-
| `bulkActions` + `verticalScrollingParent` | `
|
|
40
|
+
| `bulkActions` + `verticalScrollingParent` | `selectionMode` + `actionBar` |
|
|
41
41
|
| `onOrderChange(columnId)` | `onSortingChange` (receives `SortingState`) + `sorting` |
|
|
42
42
|
| `order` (`OrderInput`) | `sorting` (`SortingState`) |
|
|
43
43
|
| `footer` | column-level `ColumnDef.footer` (auto-renders `<tfoot>`) |
|
|
@@ -51,21 +51,21 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
|
|
|
51
51
|
## 3. Verified DS exports (`packages/ds/src/index.ts`)
|
|
52
52
|
|
|
53
53
|
```
|
|
54
|
-
DataTable, type DataTableLoadingState
|
|
54
|
+
DataTable, type ColumnDef, type DataTableLoadingState, type OnChangeFn, type SortingState
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
`@aircall/ds` **
|
|
57
|
+
`@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.
|
|
58
58
|
|
|
59
59
|
## 4. Imports
|
|
60
60
|
|
|
61
61
|
```tsx
|
|
62
62
|
import { DataTable, type DataTableLoadingState } from '@aircall/ds';
|
|
63
|
-
import type { ColumnDef, SortingState,
|
|
63
|
+
import type { ColumnDef, SortingState, OnChangeFn } from '@aircall/ds';
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## 5. Column definitions
|
|
67
67
|
|
|
68
|
-
Tractor used a descriptor array (`TableColumn[]`) with a `renderer` function. DS uses `ColumnDef<TData>[]
|
|
68
|
+
Tractor used a descriptor array (`TableColumn[]`) with a `renderer` function. DS uses `ColumnDef<TData>[]`, a bound alias of TanStack Table's type exported from `@aircall/ds`. The key changes:
|
|
69
69
|
|
|
70
70
|
| Tractor `TableColumn` field | TanStack `ColumnDef` equivalent |
|
|
71
71
|
| --- | --- |
|
|
@@ -239,17 +239,16 @@ const parentRef = React.useRef<HTMLDivElement | null>(null);
|
|
|
239
239
|
// After
|
|
240
240
|
import { DataTable } from '@aircall/ds';
|
|
241
241
|
import { ActionBar, ActionBarButton } from '@aircall/ds';
|
|
242
|
-
import type { RowSelectionState, OnChangeFn } from '@aircall/ds';
|
|
243
242
|
|
|
244
|
-
const [
|
|
243
|
+
const [selectedKeys, setSelectedKeys] = React.useState<Set<string>>(new Set());
|
|
245
244
|
|
|
246
245
|
<DataTable
|
|
247
246
|
data={people}
|
|
248
247
|
columns={columns}
|
|
249
248
|
getRowId={(row) => row.id}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
selectionMode="multiple"
|
|
250
|
+
selectedKeys={selectedKeys}
|
|
251
|
+
onSelectionChange={setSelectedKeys}
|
|
253
252
|
actionBar={
|
|
254
253
|
<ActionBar>
|
|
255
254
|
<ActionBarButton variant="destructive" onClick={() => deleteSelected()}>
|
|
@@ -263,7 +262,7 @@ const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({});
|
|
|
263
262
|
Key changes:
|
|
264
263
|
- `verticalScrollingParent` is not needed — `DataTable` manages its own ActionBar positioning
|
|
265
264
|
- `bulkActions` array → pass an `<ActionBar>` node to the `actionBar` prop
|
|
266
|
-
- `onSelectionChange(selectedRows, count)` is replaced by controlled `
|
|
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))`
|
|
267
266
|
- `getRowId` is required when selection must survive data refreshes (server pagination)
|
|
268
267
|
|
|
269
268
|
## 7. Common mistakes
|
|
@@ -312,32 +311,34 @@ DS replaced the boolean `loading` flag with a discriminated `loadingState` strin
|
|
|
312
311
|
|
|
313
312
|
Source: `packages/ds/src/components/data-table.tsx`
|
|
314
313
|
|
|
315
|
-
### Mistake 3 —
|
|
314
|
+
### Mistake 3 — Using TanStack's `rowSelection`/`onRowSelectionChange` instead of `selectedKeys`/`onSelectionChange`
|
|
316
315
|
|
|
317
316
|
```tsx
|
|
318
|
-
// Wrong —
|
|
317
|
+
// Wrong — rowSelection/onRowSelectionChange/enableRowSelection are TanStack Table's
|
|
318
|
+
// own row-model API; DataTable does not expose them as props
|
|
319
319
|
<DataTable
|
|
320
320
|
enableRowSelection
|
|
321
|
-
|
|
321
|
+
rowSelection={rowSelection}
|
|
322
|
+
onRowSelectionChange={setRowSelection}
|
|
322
323
|
columns={columns}
|
|
323
324
|
data={people}
|
|
324
325
|
/>
|
|
325
326
|
|
|
326
|
-
// Correct —
|
|
327
|
-
const [
|
|
328
|
-
const selectedPeople = people.filter(p =>
|
|
327
|
+
// Correct — turn on selectionMode; selection is a controlled Set<string> of row ids
|
|
328
|
+
const [selectedKeys, setSelectedKeys] = React.useState<Set<string>>(new Set());
|
|
329
|
+
const selectedPeople = people.filter(p => selectedKeys.has(p.id));
|
|
329
330
|
|
|
330
331
|
<DataTable
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
332
|
+
selectionMode="multiple"
|
|
333
|
+
selectedKeys={selectedKeys}
|
|
334
|
+
onSelectionChange={setSelectedKeys}
|
|
334
335
|
getRowId={(row) => row.id}
|
|
335
336
|
columns={columns}
|
|
336
337
|
data={people}
|
|
337
338
|
/>
|
|
338
339
|
```
|
|
339
340
|
|
|
340
|
-
|
|
341
|
+
DataTable wraps TanStack Table's row selection internally and exposes it React-Spectrum-style: `selectionMode` (`'single' | 'multiple'`) turns it on, and `selectedKeys`/`onSelectionChange` (or uncontrolled `defaultSelectedKeys`) control it as a plain `Set<string>` of row ids — no TanStack selection types involved. Always provide `getRowId` so the ids in the set match your data's primary key.
|
|
341
342
|
|
|
342
343
|
Source: `packages/ds/src/components/data-table.tsx`
|
|
343
344
|
|
|
@@ -406,7 +406,7 @@ Source: aircall/hydra:packages/ds/src/components/switch.tsx
|
|
|
406
406
|
|
|
407
407
|
### MEDIUM — Import `DataTable` column types from `@aircall/ds`, not `@tanstack/react-table`
|
|
408
408
|
|
|
409
|
-
`@aircall/ds` ships the react-table runtime as its own dependency and **
|
|
409
|
+
`@aircall/ds` ships the react-table runtime as its own dependency and **exposes** the types you author (`ColumnDef`, `SortingState`, `OnChangeFn`) as bound aliases. `@tanstack/react-table` is therefore not a direct dependency of your app, so importing from it won't resolve.
|
|
410
410
|
|
|
411
411
|
Wrong:
|
|
412
412
|
|