@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.
- package/dist/{data-table-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
- package/dist/data-table.d.ts +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +20 -12
- package/dist/index.js +14 -10
- package/package.json +2 -2
- package/skills/aircall-ds/migrate-audio-player/SKILL.md +14 -3
- package/skills/aircall-ds/migrate-icons/SKILL.md +45 -16
- package/skills/aircall-ds/migrate-tractor/SKILL.md +34 -31
- package/skills/aircall-ds/migrate-tractor/accordion/SKILL.md +25 -15
- package/skills/aircall-ds/migrate-tractor/alert/SKILL.md +107 -20
- package/skills/aircall-ds/migrate-tractor/avatar/SKILL.md +57 -26
- package/skills/aircall-ds/migrate-tractor/badge/SKILL.md +71 -25
- package/skills/aircall-ds/migrate-tractor/button/SKILL.md +68 -32
- package/skills/aircall-ds/migrate-tractor/card/SKILL.md +62 -42
- package/skills/aircall-ds/migrate-tractor/combobox/SKILL.md +233 -149
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +102 -108
- package/skills/aircall-ds/migrate-tractor/data-table/references/column-widths-and-pinning.md +50 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/infinite-scroll.md +51 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/row-actions.md +34 -0
- package/skills/aircall-ds/migrate-tractor/date-picker/SKILL.md +100 -47
- package/skills/aircall-ds/migrate-tractor/dialog/SKILL.md +115 -20
- package/skills/aircall-ds/migrate-tractor/dropdown-menu/SKILL.md +135 -57
- package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +2 -0
- package/skills/aircall-ds/migrate-tractor/form-and-field/SKILL.md +111 -49
- package/skills/aircall-ds/migrate-tractor/gauge/SKILL.md +6 -4
- package/skills/aircall-ds/migrate-tractor/input/SKILL.md +165 -59
- package/skills/aircall-ds/migrate-tractor/item/SKILL.md +85 -63
- package/skills/aircall-ds/migrate-tractor/link/SKILL.md +85 -68
- package/skills/aircall-ds/migrate-tractor/popover/SKILL.md +115 -74
- package/skills/aircall-ds/migrate-tractor/select/SKILL.md +117 -64
- package/skills/aircall-ds/migrate-tractor/sheet-vs-drawer/SKILL.md +55 -32
- package/skills/aircall-ds/migrate-tractor/skeleton/SKILL.md +40 -11
- package/skills/aircall-ds/migrate-tractor/styling/SKILL.md +11 -7
- package/skills/aircall-ds/migrate-tractor/tabs/SKILL.md +62 -55
- package/skills/aircall-ds/migrate-tractor/toast/SKILL.md +58 -12
- package/skills/aircall-ds/migrate-tractor/tooltip/SKILL.md +65 -40
- package/skills/aircall-ds/migrate-tractor/tree/SKILL.md +23 -6
- package/skills/aircall-ds/setup/SKILL.md +53 -8
|
@@ -11,6 +11,7 @@ requires:
|
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
13
|
- "aircall/hydra:packages/ds/src/components/sonner.tsx"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/stories/Sonner.stories.tsx"
|
|
14
15
|
---
|
|
15
16
|
|
|
16
17
|
This skill builds on aircall-ds/migrate-tractor.
|
|
@@ -21,16 +22,21 @@ Tractor had a context-based system (`ToastManager` provider + `useToast` hook or
|
|
|
21
22
|
|
|
22
23
|
| Tractor part | DS replacement | Notes |
|
|
23
24
|
| --- | --- | --- |
|
|
24
|
-
| `<ToastManager>` in app root | `<Toaster>` in app root |
|
|
25
|
+
| `<ToastManager placement container takeContainerWidth position>` in app root | `<Toaster position>` in app root | No children. `placement` → `position` (`top-left` \| `top-right` \| `bottom-left` \| `bottom-right`, plus `top-center` / `bottom-center`). Default is `bottom-right`; Tractor's was `top-right`. `container`, `takeContainerWidth` and Tractor's `position` have no equivalent: the DS `Toaster` always portals into `document.body` |
|
|
25
26
|
| `useToast()` → `toast.showToast({ … })` | `toast(message, options?)` | Direct import — no hook, no context |
|
|
26
27
|
| `toasts.showToast({ … })` (pubsub) | `toast(message, options?)` | Same replacement; the pubsub layer is gone |
|
|
27
28
|
| `toast.showToast({ variant: 'success' })` | `toast.success(message)` | Convenience method per variant |
|
|
28
29
|
| `toast.showToast({ variant: 'info' })` | `toast.info(message)` | |
|
|
29
30
|
| `toast.showToast({ variant: 'critical' })` | `toast.error(message)` | Tractor `critical` → DS `error` |
|
|
30
31
|
| `toast.showToast({ variant: 'warning' })` | `toast.warning(message)` | |
|
|
31
|
-
| `toast.showToast({ dismissIn: N })` | `toast(msg, { duration: N })` | Same unit (ms) |
|
|
32
|
+
| `toast.showToast({ dismissIn: N })` | `toast(msg, { duration: N })` | Same unit (ms). **Defaults differ:** Tractor `dismissIn` defaulted to `0`, meaning the toast stayed until closed. Sonner auto-closes after 4000 ms by default, so keep a persistent toast with `duration: Infinity` (`toast.loading` never auto-closes either) |
|
|
32
33
|
| `toast.showToast({ message: <ReactNode> })` | `toast(message)` | Pass string or JSX directly |
|
|
33
|
-
|
|
|
34
|
+
| `icon: true` / `icon: <Node />` | _(automatic)_ / `{ icon: <Node /> }` | `toast.success` / `.info` / `.warning` / `.error` / `.loading` show the DS icon for their type. Pass `icon` only to override it |
|
|
35
|
+
| `action: { children, onClick(dismiss) }` | `{ action: { label, onClick } }` | Sonner closes the toast after the action by default. Close button: Tractor showed an "×" unless there was an `action`; Sonner shows none unless `closeButton: true` (per toast or on `Toaster`) |
|
|
36
|
+
| `onClick(dismiss)` (click on the toast body) | _(no equivalent)_ | Put the interaction in an `action`, or render the body with `toast.custom` |
|
|
37
|
+
| `customComponent(dismiss, dismissIn)` | `toast.custom(id => <YourToast onClose={() => toast.dismiss(id)} />)` | You own the markup and styling |
|
|
38
|
+
| cleanup fn returned by `showToast` | `toast.dismiss(id)` | Call with the id returned by `toast()`. `toast.dismiss()` with no id closes every toast |
|
|
39
|
+
| `toasts.removeToast(id)` / `removeToast(id)` | `toast.dismiss(id)` | |
|
|
34
40
|
|
|
35
41
|
## 2. Verified DS exports (`packages/ds/src/index.ts`)
|
|
36
42
|
|
|
@@ -63,7 +69,7 @@ function App() {
|
|
|
63
69
|
}
|
|
64
70
|
```
|
|
65
71
|
|
|
66
|
-
`Toaster` accepts all [sonner `ToasterProps`](https://sonner.emilkowal.ski/getting-started) — e.g. `position`, `
|
|
72
|
+
`Toaster` accepts all [sonner `ToasterProps`](https://sonner.emilkowal.ski/getting-started) — e.g. `position`, `closeButton`, `duration`, `visibleToasts`, `offset`. It already styles the variants, so `richColors` is not needed. `toastOptions` and `icons` are spread **after** the DS values, so passing either replaces the DS `classNames` / icons wholesale; leave them out unless you mean to restyle every toast. `Toaster` portals into `document.body` and reads the theme from `ThemeProvider` (`next-themes`), falling back to `system`; it needs no other provider.
|
|
67
73
|
|
|
68
74
|
## 5. Trigger toasts imperatively
|
|
69
75
|
|
|
@@ -79,19 +85,34 @@ toast.info('Sync in progress');
|
|
|
79
85
|
toast.error('Could not reach the server'); // Tractor: variant="critical"
|
|
80
86
|
toast.warning('Your plan is almost at capacity');
|
|
81
87
|
|
|
82
|
-
// With duration (ms)
|
|
88
|
+
// With duration (ms); the default is 4000
|
|
83
89
|
toast.success('Done', { duration: 3000 });
|
|
84
90
|
|
|
91
|
+
// Stays until dismissed (Tractor's default behaviour)
|
|
92
|
+
toast.info('Sync in progress', { duration: Infinity });
|
|
93
|
+
|
|
85
94
|
// With a description
|
|
86
95
|
toast.success('Recording saved', {
|
|
87
96
|
description: 'The file has been uploaded to your workspace.'
|
|
88
97
|
});
|
|
89
98
|
|
|
90
|
-
// Capture id to dismiss later
|
|
99
|
+
// Capture id to dismiss later (a loading toast never auto-closes)
|
|
91
100
|
const id = toast.loading('Uploading…');
|
|
92
101
|
// … async work …
|
|
93
102
|
toast.dismiss(id);
|
|
94
103
|
toast.success('Upload complete');
|
|
104
|
+
|
|
105
|
+
// Or follow one promise: loading → success / error in the same toast
|
|
106
|
+
toast.promise(upload(file), {
|
|
107
|
+
loading: 'Uploading…',
|
|
108
|
+
success: 'Upload complete',
|
|
109
|
+
error: 'Upload failed'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Action button
|
|
113
|
+
toast('Contact deleted', {
|
|
114
|
+
action: { label: 'Undo', onClick: () => restoreContact() }
|
|
115
|
+
});
|
|
95
116
|
```
|
|
96
117
|
|
|
97
118
|
## 6. Before / After examples
|
|
@@ -104,7 +125,7 @@ import { ToastManager } from '@aircall/tractor';
|
|
|
104
125
|
|
|
105
126
|
function App({ children }: { children: React.ReactNode }) {
|
|
106
127
|
return (
|
|
107
|
-
<ToastManager placement="bottom">
|
|
128
|
+
<ToastManager placement="bottom-right">
|
|
108
129
|
{children}
|
|
109
130
|
</ToastManager>
|
|
110
131
|
);
|
|
@@ -118,7 +139,7 @@ import { Toaster } from '@aircall/ds';
|
|
|
118
139
|
function App({ children }: { children: React.ReactNode }) {
|
|
119
140
|
return (
|
|
120
141
|
<>
|
|
121
|
-
<Toaster position="bottom-
|
|
142
|
+
<Toaster position="bottom-right" />
|
|
122
143
|
{children}
|
|
123
144
|
</>
|
|
124
145
|
);
|
|
@@ -202,6 +223,7 @@ function SyncButton() {
|
|
|
202
223
|
const { showToast } = useToast();
|
|
203
224
|
|
|
204
225
|
const handleSync = async () => {
|
|
226
|
+
// dismissIn: 0 (the default) kept the toast until it was dismissed
|
|
205
227
|
const dismiss = showToast({ variant: 'info', message: 'Syncing…', dismissIn: 0 });
|
|
206
228
|
await syncData();
|
|
207
229
|
dismiss();
|
|
@@ -236,7 +258,7 @@ function SyncButton() {
|
|
|
236
258
|
```tsx
|
|
237
259
|
import { ToastManager } from '@aircall/tractor';
|
|
238
260
|
|
|
239
|
-
<ToastManager placement="bottom">
|
|
261
|
+
<ToastManager placement="bottom-right">
|
|
240
262
|
<App />
|
|
241
263
|
</ToastManager>
|
|
242
264
|
```
|
|
@@ -246,12 +268,12 @@ import { ToastManager } from '@aircall/tractor';
|
|
|
246
268
|
import { Toaster } from '@aircall/ds';
|
|
247
269
|
|
|
248
270
|
<>
|
|
249
|
-
<Toaster position="bottom-
|
|
271
|
+
<Toaster position="bottom-right" />
|
|
250
272
|
<App />
|
|
251
273
|
</>
|
|
252
274
|
```
|
|
253
275
|
|
|
254
|
-
`<Toaster>` is a portal mount point, not a layout wrapper — it renders the toast container into a portal and takes no children
|
|
276
|
+
`<Toaster>` is a portal mount point, not a layout wrapper — it renders the toast container into a portal on `document.body` and takes no children (`ToasterProps` has no `children`, so wrapping the app in it is a type error). Sonner manages the DOM insertion independently.
|
|
255
277
|
|
|
256
278
|
Source: `packages/ds/src/components/sonner.tsx`
|
|
257
279
|
|
|
@@ -316,6 +338,30 @@ toast.success('Done', { dismissIn: 3000 });
|
|
|
316
338
|
toast.success('Done', { duration: 3000 });
|
|
317
339
|
```
|
|
318
340
|
|
|
319
|
-
Tractor's `showToast` accepted a `dismissIn` property (milliseconds). Sonner's option key is `duration`.
|
|
341
|
+
Tractor's `showToast` accepted a `dismissIn` property (milliseconds). Sonner's option key is `duration`. `dismissIn` is not a sonner option (a type error on an object literal), and if it slips through it is ignored — the toast uses the default duration (4 s) regardless of the value passed.
|
|
342
|
+
|
|
343
|
+
The defaults also differ. Tractor's `dismissIn` defaulted to `0`, which meant "never auto-dismiss"; sonner closes after 4000 ms unless told otherwise. Migrate a persistent toast (`dismissIn` omitted or `0`) to `duration: Infinity`, not to a bare `toast(...)`.
|
|
320
344
|
|
|
321
345
|
Source: `packages/ds/src/components/sonner.tsx` — wraps sonner `Toaster`; see [sonner API](https://sonner.emilkowal.ski/toast) for `duration`.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
### Mistake 5 — Expecting the toast body or an "×" to be clickable by default
|
|
350
|
+
|
|
351
|
+
**Wrong:**
|
|
352
|
+
```tsx
|
|
353
|
+
// Tractor: onClick on the toast body, and a close icon shown by default
|
|
354
|
+
toast.success('Export ready', { onClick: openExport });
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Correct:**
|
|
358
|
+
```tsx
|
|
359
|
+
toast.success('Export ready', {
|
|
360
|
+
action: { label: 'Open', onClick: openExport },
|
|
361
|
+
closeButton: true
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Sonner has no click handler on the toast body, and shows no close button unless `closeButton` is set on the toast or on `<Toaster closeButton />`. Move the Tractor `onClick` behaviour into an `action`, and opt in to the close button where the Tractor toast showed its "×".
|
|
366
|
+
|
|
367
|
+
Source: `packages/ds/src/components/sonner.tsx` — wraps sonner's `Toaster`; options per sonner's `ExternalToast` (`action`, `closeButton`, `duration`, `icon`).
|
|
@@ -11,6 +11,8 @@ requires:
|
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
13
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/tooltip.md"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/components/tooltip.tsx"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/stories/Tooltip.stories.tsx"
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the tooltip-specific steps below.
|
|
@@ -19,11 +21,11 @@ This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules f
|
|
|
19
21
|
|
|
20
22
|
| Tractor | @aircall/ds |
|
|
21
23
|
| --- | --- |
|
|
22
|
-
| `Tooltip` (self-contained,
|
|
23
|
-
|
|
|
24
|
-
| `content`
|
|
25
|
-
| — | `TooltipProvider` (once at app root;
|
|
26
|
-
| `
|
|
24
|
+
| `Tooltip` (self-contained, wraps its child) | `Tooltip` (Root state owner) |
|
|
25
|
+
| the wrapped child | `TooltipTrigger` (the element that activates the tooltip; pass your element through `render`) |
|
|
26
|
+
| `content` / `title` props (tooltip text) | `TooltipContent` (children, compound part) |
|
|
27
|
+
| — | `TooltipProvider` (optional, once at app root; shared open delay) |
|
|
28
|
+
| `side` / `align` props | `side` + `align` props on `TooltipContent` (same names and values, moved from the root to the content) |
|
|
27
29
|
|
|
28
30
|
## 2. Imports
|
|
29
31
|
|
|
@@ -37,22 +39,23 @@ For icon-only triggers, import icons from `@aircall/react-icons`:
|
|
|
37
39
|
import { Info } from '@aircall/react-icons';
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
## 3. Provider (
|
|
42
|
+
## 3. Provider (optional, once at the app root)
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
`TooltipProvider` supplies one shared open delay and lets tooltips that are hovered in quick succession open instantly. Tooltips still open without it (the setup skill lists it as optional).
|
|
43
45
|
|
|
44
46
|
```tsx
|
|
45
|
-
// Before — no
|
|
47
|
+
// Before — no provider; each Tractor Tooltip carried its own timing
|
|
48
|
+
// (mouseEnterDelay default 400 ms, mouseLeaveDelay default 100 ms)
|
|
46
49
|
|
|
47
50
|
// After — add once near the root (e.g. in App.tsx or a layout component)
|
|
48
51
|
import { TooltipProvider } from '@aircall/ds';
|
|
49
52
|
|
|
50
|
-
<TooltipProvider delay={
|
|
53
|
+
<TooltipProvider delay={400} closeDelay={100}>
|
|
51
54
|
<App />
|
|
52
55
|
</TooltipProvider>
|
|
53
56
|
```
|
|
54
57
|
|
|
55
|
-
The prop is `delay` (Base UI), not `delayDuration` (Radix).
|
|
58
|
+
`TooltipProvider` props: `delay` (ms before opening, DS default **`0`**), `closeDelay` and `timeout`. The prop is `delay` (Base UI), not `delayDuration` (Radix). Tractor's default open delay was 400 ms, so keep `delay={400}` if you want the old feel; the DS default opens at once. A single tooltip can override it on its trigger: `<TooltipTrigger delay={500} closeDelay={500} … />` (Tractor `mouseEnterDelay` / `mouseLeaveDelay`).
|
|
56
59
|
|
|
57
60
|
## 4. Before / After
|
|
58
61
|
|
|
@@ -62,8 +65,8 @@ The prop is `delay` (Base UI), not `delayDuration` (Radix). Default is `0`.
|
|
|
62
65
|
// Before
|
|
63
66
|
import { Tooltip, Button } from '@aircall/tractor';
|
|
64
67
|
|
|
65
|
-
<Tooltip
|
|
66
|
-
<Button variant="ghost">Help</Button>
|
|
68
|
+
<Tooltip title="Helpful hint">
|
|
69
|
+
<Button variant="secondary" mode="ghost">Help</Button>
|
|
67
70
|
</Tooltip>
|
|
68
71
|
|
|
69
72
|
// After
|
|
@@ -80,10 +83,10 @@ import { Tooltip, TooltipTrigger, TooltipContent, Button } from '@aircall/ds';
|
|
|
80
83
|
```tsx
|
|
81
84
|
// Before
|
|
82
85
|
import { Tooltip, IconButton } from '@aircall/tractor';
|
|
83
|
-
import {
|
|
86
|
+
import { InformationOutlined } from '@aircall/icons';
|
|
84
87
|
|
|
85
|
-
<Tooltip
|
|
86
|
-
<IconButton label="More information"
|
|
88
|
+
<Tooltip title="More information" side="bottom">
|
|
89
|
+
<IconButton component={InformationOutlined} aria-label="More information" />
|
|
87
90
|
</Tooltip>
|
|
88
91
|
|
|
89
92
|
// After
|
|
@@ -92,18 +95,37 @@ import { Info } from '@aircall/react-icons';
|
|
|
92
95
|
|
|
93
96
|
<Tooltip>
|
|
94
97
|
<TooltipTrigger render={<Button variant="ghost" size="icon" aria-label="More information" />}>
|
|
95
|
-
<Info
|
|
98
|
+
<Info />
|
|
96
99
|
</TooltipTrigger>
|
|
97
100
|
<TooltipContent side="bottom">More information</TooltipContent>
|
|
98
101
|
</Tooltip>
|
|
99
102
|
```
|
|
100
103
|
|
|
101
104
|
Key changes:
|
|
102
|
-
- `content`
|
|
103
|
-
- The trigger element is wrapped in `TooltipTrigger` with the DS component passed via `render`
|
|
104
|
-
- `
|
|
105
|
+
- `content` / `title` props are gone — tooltip text moves to children of `TooltipContent`
|
|
106
|
+
- The trigger element is wrapped in `TooltipTrigger` with the DS component passed via `render`; the trigger's own children go in `TooltipTrigger`, not in the `render` element
|
|
107
|
+
- `side` / `align` move from the `Tooltip` root to `TooltipContent` (default `side="top"`, `align="center"`, `sideOffset={4}`)
|
|
105
108
|
- Icon-only triggers must have an explicit `aria-label` — the tooltip text is not exposed as the control's accessible name
|
|
106
|
-
- The arrow and `accent-foreground` styling are built in — do not re-skin them
|
|
109
|
+
- The arrow and `accent-foreground` styling are built in — do not re-skin them. The panel is `max-w-sm` (384px) where Tractor's `maxW` defaulted to 250px; pass `className="max-w-[250px]"` on `TooltipContent` to keep it
|
|
110
|
+
- Tractor's `mode="light"` (dark text on a light tooltip) and `arrowPointsAtCenter` have no DS equivalent
|
|
111
|
+
- Icons size themselves inside `Button`; do not add `size-4` to them
|
|
112
|
+
|
|
113
|
+
Other Tractor props: `visible` / `onVisibilityChange` → `open` / `onOpenChange` on `Tooltip`; `disabled` → `disabled` on `Tooltip`; `maxW` → `className` on `TooltipContent`; `onClick` on the Tooltip → `onClick` on the trigger element.
|
|
114
|
+
|
|
115
|
+
### Triggers that cannot receive hover (disabled controls)
|
|
116
|
+
|
|
117
|
+
A disabled control may not report pointer events. The `@dashboard/library` `ConditionalTooltip` handles this by making the *wrapper* the trigger, so the tooltip anchors to a shrink-wrapped element:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<Tooltip>
|
|
121
|
+
<TooltipTrigger render={<div style={{ width: 'fit-content' }} />}>
|
|
122
|
+
<Button disabled>Disabled action</Button>
|
|
123
|
+
</TooltipTrigger>
|
|
124
|
+
<TooltipContent>You don't have permission to perform this action</TooltipContent>
|
|
125
|
+
</Tooltip>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For a tooltip that only exists under a condition, render the `Tooltip` parts when the condition holds and the bare child otherwise; no wrapper component is needed (see `aircall-blocks/migrate-dashboard`, `ConditionalTooltip` row).
|
|
107
129
|
|
|
108
130
|
### Controlled placement
|
|
109
131
|
|
|
@@ -111,7 +133,7 @@ Key changes:
|
|
|
111
133
|
// Before
|
|
112
134
|
import { Tooltip } from '@aircall/tractor';
|
|
113
135
|
|
|
114
|
-
<Tooltip
|
|
136
|
+
<Tooltip title="Save changes" side="right" align="start">
|
|
115
137
|
<button>Save</button>
|
|
116
138
|
</Tooltip>
|
|
117
139
|
|
|
@@ -120,11 +142,11 @@ import { Tooltip, TooltipTrigger, TooltipContent } from '@aircall/ds';
|
|
|
120
142
|
|
|
121
143
|
<Tooltip>
|
|
122
144
|
<TooltipTrigger>Save</TooltipTrigger>
|
|
123
|
-
<TooltipContent side="right">Save changes</TooltipContent>
|
|
145
|
+
<TooltipContent side="right" align="start">Save changes</TooltipContent>
|
|
124
146
|
</Tooltip>
|
|
125
147
|
```
|
|
126
148
|
|
|
127
|
-
`align` defaults to `"center"`.
|
|
149
|
+
`side` is `'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end'`; `align` is `'start' | 'center' | 'end'` and defaults to `"center"`. `sideOffset` and `alignOffset` fine-tune the distance. A bare `<button>` is fine as a `TooltipTrigger` too (it renders a `<button>` by default).
|
|
128
150
|
|
|
129
151
|
---
|
|
130
152
|
|
|
@@ -133,7 +155,7 @@ import { Tooltip, TooltipTrigger, TooltipContent } from '@aircall/ds';
|
|
|
133
155
|
### Mistake 1 — Passing tooltip text via a `content` prop instead of `TooltipContent` children
|
|
134
156
|
|
|
135
157
|
```tsx
|
|
136
|
-
// ❌ Wrong — content
|
|
158
|
+
// ❌ Wrong — content / title props are a Tractor API; they are type errors on the DS Tooltip
|
|
137
159
|
<Tooltip content="Helpful hint">
|
|
138
160
|
<TooltipTrigger>Help</TooltipTrigger>
|
|
139
161
|
</Tooltip>
|
|
@@ -145,42 +167,45 @@ import { Tooltip, TooltipTrigger, TooltipContent } from '@aircall/ds';
|
|
|
145
167
|
</Tooltip>
|
|
146
168
|
```
|
|
147
169
|
|
|
148
|
-
DS `Tooltip` is a Base UI compound — the tooltip label lives in `TooltipContent`, not on the root.
|
|
170
|
+
DS `Tooltip` is a Base UI compound — the tooltip label lives in `TooltipContent`, not on the root. `content` is not a prop of `Tooltip.Root`, so no tooltip text is shown.
|
|
149
171
|
|
|
150
172
|
Source: `packages/ds/src/components/tooltip.tsx`
|
|
151
173
|
|
|
152
|
-
### Mistake 2 —
|
|
174
|
+
### Mistake 2 — Leaving `side` / `align` on the `Tooltip` root
|
|
153
175
|
|
|
154
176
|
```tsx
|
|
155
|
-
// ❌ Wrong —
|
|
156
|
-
<
|
|
177
|
+
// ❌ Wrong — Tractor took side/align on Tooltip; in DS the root has no positioning props
|
|
178
|
+
<Tooltip side="bottom" align="start">
|
|
179
|
+
<TooltipTrigger>Help</TooltipTrigger>
|
|
180
|
+
<TooltipContent>Helpful hint</TooltipContent>
|
|
181
|
+
</Tooltip>
|
|
157
182
|
|
|
158
|
-
// ✅ Correct —
|
|
159
|
-
<
|
|
183
|
+
// ✅ Correct — side (and optionally align) live on TooltipContent
|
|
184
|
+
<Tooltip>
|
|
185
|
+
<TooltipTrigger>Help</TooltipTrigger>
|
|
186
|
+
<TooltipContent side="bottom" align="start">Helpful hint</TooltipContent>
|
|
187
|
+
</Tooltip>
|
|
160
188
|
```
|
|
161
189
|
|
|
162
|
-
`TooltipContent` exposes `side`, `sideOffset`, `align`, and `alignOffset` (picked from `TooltipPrimitive.Positioner.Props`).
|
|
190
|
+
`TooltipContent` exposes `side`, `sideOffset`, `align`, and `alignOffset` (picked from `TooltipPrimitive.Positioner.Props`). The same props on the root are a type error; if they slip through, the tooltip renders at the default `side="top"` position. (`placement` was never a Tractor Tooltip prop either, so do not introduce it.)
|
|
163
191
|
|
|
164
192
|
Source: `packages/ds/src/components/tooltip.tsx`
|
|
165
193
|
|
|
166
|
-
### Mistake 3 —
|
|
194
|
+
### Mistake 3 — Using `delayDuration` instead of `delay`
|
|
167
195
|
|
|
168
196
|
```tsx
|
|
169
|
-
// ❌ Wrong —
|
|
170
|
-
<App />
|
|
171
|
-
|
|
172
|
-
// ❌ Wrong — delayDuration is the Radix prop; Base UI ignores it
|
|
197
|
+
// ❌ Wrong — delayDuration is the Radix prop; it is not a Base UI prop
|
|
173
198
|
<TooltipProvider delayDuration={300}>
|
|
174
199
|
<App />
|
|
175
200
|
</TooltipProvider>
|
|
176
201
|
|
|
177
202
|
// ✅ Correct — mount once with the Base UI prop name
|
|
178
|
-
<TooltipProvider delay={
|
|
203
|
+
<TooltipProvider delay={300}>
|
|
179
204
|
<App />
|
|
180
205
|
</TooltipProvider>
|
|
181
206
|
```
|
|
182
207
|
|
|
183
|
-
`TooltipProvider` is
|
|
208
|
+
`TooltipProvider` is optional (a tooltip opens without it); it only sets the shared open delay. The prop is `delay` (milliseconds), not `delayDuration`. `delayDuration` is a type error; if it slips through, the provider keeps its default `delay` of `0`.
|
|
184
209
|
|
|
185
210
|
Source: `packages/ds/src/components/tooltip.tsx`
|
|
186
211
|
|
|
@@ -189,12 +214,12 @@ Source: `packages/ds/src/components/tooltip.tsx`
|
|
|
189
214
|
```tsx
|
|
190
215
|
// ❌ Wrong — no accessible name; tooltip text is not the control's name
|
|
191
216
|
<TooltipTrigger render={<Button variant="ghost" size="icon" />}>
|
|
192
|
-
<Info
|
|
217
|
+
<Info />
|
|
193
218
|
</TooltipTrigger>
|
|
194
219
|
|
|
195
220
|
// ✅ Correct — aria-label names the control independently of the tooltip
|
|
196
221
|
<TooltipTrigger render={<Button variant="ghost" size="icon" aria-label="More information" />}>
|
|
197
|
-
<Info
|
|
222
|
+
<Info />
|
|
198
223
|
</TooltipTrigger>
|
|
199
224
|
```
|
|
200
225
|
|
|
@@ -11,6 +11,10 @@ requires:
|
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
13
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/tree.md"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/components/data-tree.tsx"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/components/tree.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/stories/DataTree.stories.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/stories/Tree.stories.tsx"
|
|
14
18
|
---
|
|
15
19
|
|
|
16
20
|
This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the tree-specific steps below.
|
|
@@ -193,10 +197,12 @@ import { Tree } from '@aircall/tractor';
|
|
|
193
197
|
```tsx
|
|
194
198
|
import { Tree, TreeItem, TreeItemLabel } from '@aircall/ds';
|
|
195
199
|
import { useTree } from '@headless-tree/react';
|
|
196
|
-
import {
|
|
200
|
+
import { hotkeysCoreFeature, syncDataLoaderFeature } from '@headless-tree/core';
|
|
197
201
|
|
|
198
202
|
const tree = useTree<Item>({
|
|
199
203
|
rootItemId: 'root',
|
|
204
|
+
getItemName: item => item.getItemData().name,
|
|
205
|
+
isItemFolder: item => (item.getItemData()?.children?.length ?? 0) > 0,
|
|
200
206
|
dataLoader: {
|
|
201
207
|
getItem: id => itemMap[id],
|
|
202
208
|
getChildren: id => childIds[id] ?? []
|
|
@@ -213,6 +219,14 @@ const tree = useTree<Item>({
|
|
|
213
219
|
</Tree>
|
|
214
220
|
```
|
|
215
221
|
|
|
222
|
+
`hotkeysCoreFeature` declares `getItemName` and `isItemFolder` as required config, so a tree built
|
|
223
|
+
without them does not type-check.
|
|
224
|
+
|
|
225
|
+
`@headless-tree/core` and `@headless-tree/react` are dependencies **of `@aircall/ds`**, not
|
|
226
|
+
re-exported from it — a consumer composing the `Tree` primitives must add them to its own
|
|
227
|
+
`package.json`. (`DataTree` needs nothing: it owns the `useTree` instance for you.)
|
|
228
|
+
`TreeDragLine` is exported alongside them for drag-and-drop drop indicators.
|
|
229
|
+
|
|
216
230
|
## 7. TreeSelect
|
|
217
231
|
|
|
218
232
|
Tractor's `TreeSelect` has no turn-key DS equivalent. Compose `DataTree` inside a `Popover`:
|
|
@@ -221,11 +235,10 @@ Tractor's `TreeSelect` has no turn-key DS equivalent. Compose `DataTree` inside
|
|
|
221
235
|
import { DataTree, Popover, PopoverContent, PopoverTrigger, Button } from '@aircall/ds';
|
|
222
236
|
|
|
223
237
|
<Popover>
|
|
224
|
-
<PopoverTrigger
|
|
225
|
-
|
|
226
|
-
</PopoverTrigger>
|
|
227
|
-
<PopoverContent className="w-72 p-2">
|
|
238
|
+
<PopoverTrigger render={<Button variant="outline" />}>Select team…</PopoverTrigger>
|
|
239
|
+
<PopoverContent align="start" className="w-72 p-1.5">
|
|
228
240
|
<DataTree
|
|
241
|
+
aria-label="Select team"
|
|
229
242
|
items={items}
|
|
230
243
|
getKey={n => n.id}
|
|
231
244
|
getLabel={n => n.label}
|
|
@@ -240,6 +253,10 @@ import { DataTree, Popover, PopoverContent, PopoverTrigger, Button } from '@airc
|
|
|
240
253
|
</Popover>
|
|
241
254
|
```
|
|
242
255
|
|
|
256
|
+
The trigger uses Base UI's `render` prop (not Radix `asChild`), the label goes as children of
|
|
257
|
+
`PopoverTrigger`, and `DataTree` needs `aria-label` — it renders a tree widget with no visible
|
|
258
|
+
label of its own.
|
|
259
|
+
|
|
243
260
|
## 8. Common Mistakes
|
|
244
261
|
|
|
245
262
|
### Mistake 1 — Using `onItemSelected` instead of `onSelectionChange`
|
|
@@ -311,7 +328,7 @@ Source: `packages/ds/src/components/data-tree.tsx`
|
|
|
311
328
|
/>
|
|
312
329
|
```
|
|
313
330
|
|
|
314
|
-
Tractor forced callers to reshape their data into `{ id, label, children }`. `DataTree` accepts your data as-is via `items` and resolves identifiers and hierarchy through the `getKey` / `getLabel` / `getChildren` accessor functions.
|
|
331
|
+
Tractor forced callers to reshape their data into `{ id, label, children }`. `DataTree` accepts your data as-is via `items` and resolves identifiers and hierarchy through the `getKey` / `getLabel` / `getChildren` accessor functions. `nodes` is not a prop — TypeScript rejects it (`items` is required) and at runtime the index build throws on the missing array, so the mistake surfaces immediately rather than rendering an empty tree.
|
|
315
332
|
|
|
316
333
|
Source: `packages/ds/src/components/data-tree.tsx`
|
|
317
334
|
|
|
@@ -11,6 +11,8 @@ library: aircall-ds
|
|
|
11
11
|
sources:
|
|
12
12
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/00-setup.md"
|
|
13
13
|
- "aircall/hydra:packages/ds/package.json"
|
|
14
|
+
- "aircall/hydra:packages/ds/AGENTS.consumer.md"
|
|
15
|
+
- "aircall/hydra:packages/ds/README.md"
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
# Setting up @aircall/ds
|
|
@@ -24,10 +26,10 @@ published package exposes.
|
|
|
24
26
|
|
|
25
27
|
## Setup
|
|
26
28
|
|
|
27
|
-
Install the design system and
|
|
29
|
+
Install the design system, icon package and the i18next peer (keep Tractor and icons for now):
|
|
28
30
|
|
|
29
31
|
```bash
|
|
30
|
-
pnpm add @aircall/ds @aircall/react-icons
|
|
32
|
+
pnpm add @aircall/ds @aircall/react-icons i18next
|
|
31
33
|
```
|
|
32
34
|
|
|
33
35
|
> **Version floor — `@aircall/react-icons` must be `>= 0.4.0`** (the version `@aircall/ds`
|
|
@@ -220,13 +222,56 @@ whole document. A duplicate emitted by the remote's injected `<style>` tag wins
|
|
|
220
222
|
|
|
221
223
|
### Peers you provide
|
|
222
224
|
|
|
223
|
-
`@aircall/ds` ships its
|
|
224
|
-
`
|
|
225
|
-
automatically with ds; nothing to add.
|
|
225
|
+
`@aircall/ds` ships most of its libraries (`@tanstack/react-table`, `@tanstack/react-virtual`,
|
|
226
|
+
`embla-carousel-react`, `sonner`, `@base-ui/react`, `@platejs/*`, …) as regular **dependencies** —
|
|
227
|
+
they install automatically with ds; nothing to add. `@tanstack/react-table` is one of those, and
|
|
228
|
+
its `ColumnDef` / `SortingState` / `OnChangeFn` types are re-exported from `@aircall/ds` so you
|
|
229
|
+
never import react-table yourself.
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
The peers declared by `@aircall/ds` (see `packages/ds/package.json`):
|
|
232
|
+
|
|
233
|
+
| Peer | Range | Notes |
|
|
234
|
+
| --- | --- | --- |
|
|
235
|
+
| `react` / `react-dom` | `^18 \|\| ^19` | |
|
|
236
|
+
| `@aircall/react-icons` | `*` (use `>= 0.4.0`) | see the version-floor note above |
|
|
237
|
+
| `@aircall/hooks` | `*` | Aircall registry — powers controlled state across DS components |
|
|
238
|
+
| `@aircall/numbers` | `*` | Aircall registry — `CountryCode` typings (CountryFlag) |
|
|
239
|
+
| `i18next` | `>=20.3.0 <24` | DS renders its own strings through a private i18next instance |
|
|
240
|
+
| `react-day-picker` | `^9` | **optional** — only if you use `Calendar` / `DatePicker` |
|
|
241
|
+
| `date-fns` | `^4` | **optional** — same components |
|
|
242
|
+
|
|
243
|
+
`i18next` is a required peer: the ds barrel imports it, so a missing install is a build error even
|
|
244
|
+
if you never touch `<DsI18nProvider>`. Most apps already have it; keep the version they use.
|
|
245
|
+
`@aircall/hooks` and `@aircall/numbers` live on the Aircall registry; pnpm's
|
|
246
|
+
`auto-install-peers` will usually fetch them, but add them explicitly if your installer does not.
|
|
247
|
+
|
|
248
|
+
`react-day-picker` and `date-fns` are optional — DS's own component module graph keeps them out
|
|
249
|
+
until `Calendar` is imported, so add them only when you use it:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
pnpm add react-day-picker date-fns # only if you use <Calendar> / <DatePicker>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Brand font (Fellix)
|
|
256
|
+
|
|
257
|
+
DS sets `--font-sans: 'Fellix'` but deliberately ships **no** `@font-face` rules — each app
|
|
258
|
+
declares its own. The `.woff2` files are published with the package (`@aircall/ds/fonts/*`, source
|
|
259
|
+
`packages/ds/src/fonts/`). Add the rules once to your entry CSS, using a path that your bundler can
|
|
260
|
+
resolve (a relative path into `node_modules` is the reliable form):
|
|
261
|
+
|
|
262
|
+
```css
|
|
263
|
+
@font-face {
|
|
264
|
+
font-display: swap;
|
|
265
|
+
font-family: 'Fellix';
|
|
266
|
+
font-style: normal;
|
|
267
|
+
font-weight: 400;
|
|
268
|
+
src: url('../node_modules/@aircall/ds/src/fonts/FellixAircall-Regular.woff2') format('woff2');
|
|
269
|
+
}
|
|
270
|
+
/* repeat for -Light (100-300), -Medium (500), -SemiBold (600), -Bold (700-900) */
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Skipping this is not fatal — text falls back to the system sans-serif — but every DS surface then
|
|
274
|
+
renders in the wrong typeface.
|
|
230
275
|
|
|
231
276
|
## Common Mistakes
|
|
232
277
|
|