@aircall/ds 0.49.0 → 0.50.2

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 (41) hide show
  1. package/dist/{data-table-B3ahtFLP.js → data-table-AX0Mgu6K.js} +5 -0
  2. package/dist/{data-table-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
  3. package/dist/data-table.d.ts +1 -1
  4. package/dist/data-table.js +1 -1
  5. package/dist/globals.css +1 -1
  6. package/dist/index.d.ts +53 -16
  7. package/dist/index.js +113 -20
  8. package/package.json +2 -2
  9. package/skills/aircall-ds/migrate-audio-player/SKILL.md +14 -3
  10. package/skills/aircall-ds/migrate-icons/SKILL.md +45 -16
  11. package/skills/aircall-ds/migrate-tractor/SKILL.md +34 -31
  12. package/skills/aircall-ds/migrate-tractor/accordion/SKILL.md +25 -15
  13. package/skills/aircall-ds/migrate-tractor/alert/SKILL.md +107 -20
  14. package/skills/aircall-ds/migrate-tractor/avatar/SKILL.md +57 -26
  15. package/skills/aircall-ds/migrate-tractor/badge/SKILL.md +71 -25
  16. package/skills/aircall-ds/migrate-tractor/button/SKILL.md +68 -32
  17. package/skills/aircall-ds/migrate-tractor/card/SKILL.md +62 -42
  18. package/skills/aircall-ds/migrate-tractor/combobox/SKILL.md +233 -149
  19. package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +102 -108
  20. package/skills/aircall-ds/migrate-tractor/data-table/references/column-widths-and-pinning.md +50 -0
  21. package/skills/aircall-ds/migrate-tractor/data-table/references/infinite-scroll.md +51 -0
  22. package/skills/aircall-ds/migrate-tractor/data-table/references/row-actions.md +34 -0
  23. package/skills/aircall-ds/migrate-tractor/date-picker/SKILL.md +100 -47
  24. package/skills/aircall-ds/migrate-tractor/dialog/SKILL.md +115 -20
  25. package/skills/aircall-ds/migrate-tractor/dropdown-menu/SKILL.md +135 -57
  26. package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +2 -0
  27. package/skills/aircall-ds/migrate-tractor/form-and-field/SKILL.md +111 -49
  28. package/skills/aircall-ds/migrate-tractor/gauge/SKILL.md +6 -4
  29. package/skills/aircall-ds/migrate-tractor/input/SKILL.md +165 -59
  30. package/skills/aircall-ds/migrate-tractor/item/SKILL.md +85 -63
  31. package/skills/aircall-ds/migrate-tractor/link/SKILL.md +85 -68
  32. package/skills/aircall-ds/migrate-tractor/popover/SKILL.md +115 -74
  33. package/skills/aircall-ds/migrate-tractor/select/SKILL.md +117 -64
  34. package/skills/aircall-ds/migrate-tractor/sheet-vs-drawer/SKILL.md +55 -32
  35. package/skills/aircall-ds/migrate-tractor/skeleton/SKILL.md +40 -11
  36. package/skills/aircall-ds/migrate-tractor/styling/SKILL.md +11 -7
  37. package/skills/aircall-ds/migrate-tractor/tabs/SKILL.md +62 -55
  38. package/skills/aircall-ds/migrate-tractor/toast/SKILL.md +58 -12
  39. package/skills/aircall-ds/migrate-tractor/tooltip/SKILL.md +65 -40
  40. package/skills/aircall-ds/migrate-tractor/tree/SKILL.md +23 -6
  41. package/skills/aircall-ds/setup/SKILL.md +53 -8
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  name: aircall-ds/migrate-tractor/popover
3
3
  description: >
4
- Migrate Tractor Popover (single-component, content + placement props) to the
5
- @aircall/ds Popover compound (Popover, PopoverTrigger, PopoverContent, PopoverHeader,
6
- PopoverTitle, PopoverDescription). Load when a file imports Popover from @aircall/tractor.
4
+ Migrate Tractor Popover (Popover.Root / Popover.Trigger / Popover.Content / Popover.Arrow,
5
+ and a Dropdown that holds arbitrary content) to the @aircall/ds Popover compound (Popover,
6
+ PopoverTrigger, PopoverContent, PopoverHeader, PopoverTitle, PopoverDescription,
7
+ PopoverClose). Load when a file imports Popover from @aircall/tractor, or a Dropdown
8
+ whose children are not a menu.
7
9
  type: sub-skill
8
10
  library: aircall-ds
9
11
  requires:
@@ -11,28 +13,38 @@ requires:
11
13
  - aircall-ds/migrate-tractor
12
14
  sources:
13
15
  - "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/popover.md"
16
+ - "aircall/hydra:packages/ds/src/components/popover.tsx"
17
+ - "aircall/hydra:packages/ds/src/stories/Popover.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 popover-specific steps below.
17
21
 
18
22
  ## 1. Component mapping
19
23
 
20
- Tractor `Popover` was a single component: you passed a `content` prop (the panel) and a `placement` prop (positioning) alongside the trigger child. DS uses a Base UI compound where each concern is a named part.
24
+ Tractor `Popover` is already a compound of four parts, rendered by hand: `Popover.Root` (state), `Popover.Trigger` (clones its single child and injects a ref and `onClick`), `Popover.Content` (the panel, mounted only while open; you style its surface with Flex/Box props) and `Popover.Arrow`. Positioning is `side` / `align` / `sideOffset` / `alignOffset` on `Popover.Content`, and there is no `content` or `placement` prop. DS keeps the compound but moves the surface into the component and the trigger behaviour into the Base UI `render` prop.
21
25
 
22
26
  | Tractor | @aircall/ds | Role |
23
27
  | --- | --- | --- |
24
- | `<Popover>` | `<Popover>` | State owner (open, onOpenChange) |
25
- | _(trigger child of `<Popover>`)_ | `<PopoverTrigger>` | The anchor element that opens the panel |
26
- | `content={…}` prop | `<PopoverContent>` | The floating panel; children replace the prop |
27
- | `placement="bottom-start"` | `side="bottom" align="start"` on `<PopoverContent>` | Split into two props |
28
- | _(no equivalent)_ | `<PopoverHeader>` | Optional structured header wrapper |
29
- | _(no equivalent)_ | `<PopoverTitle>` | Accessible title inside the panel |
30
- | _(no equivalent)_ | `<PopoverDescription>` | Accessible description inside the panel |
28
+ | `<Popover.Root open defaultOpen onOpenChange>` | `<Popover open defaultOpen onOpenChange>` | State owner |
29
+ | `<Popover.Trigger><Button/></Popover.Trigger>` | `<PopoverTrigger render={<Button />}>label</PopoverTrigger>` | The anchor. The label moves from the trigger's child to `PopoverTrigger`'s children |
30
+ | `{open && <Popover.Content …>}` | `<PopoverContent>` | The floating panel. Always render it; the open state is handled for you (no `{open && …}` guard) |
31
+ | `side`, `align`, `sideOffset`, `alignOffset` on `Popover.Content` | the same four props on `<PopoverContent>` | Same names, same values (`top`/`right`/`bottom`/`left`, `start`/`center`/`end`). **Defaults differ**, see §5 |
32
+ | `Popover.Arrow` | _(no equivalent)_ | DS popovers have no arrow: delete it |
33
+ | `bg`, `boxShadow`, `borderRadius`, `p`, `w`, `maxW` Flex/Box props on the content | built in / `className` | Surface is provided (§6); size and padding via Tailwind `className` |
34
+ | `takeTriggerWidth` | `className="w-(--anchor-width)"` on `PopoverContent` | Positioner CSS variable |
35
+ | `closeOnOutsideClick` (default `true`) | built in | Outside press and Escape always close it |
36
+ | `closeOnInsideClick` | `<PopoverClose>` around the control that should close it, or controlled `open` | Default is the same as Tractor's (clicks inside do not close) |
37
+ | `closeOnScroll` (default `true`) | _(no equivalent)_ | No scroll-close prop; control `open` yourself if a flow needs it |
38
+ | `portalled`, `zIndex`, `portalContainerRef` | _(drop them)_ | `PopoverContent` always portals and uses the `z-popup` layer |
39
+ | `avoidCollisions`, `collisionTolerance` | _(drop them)_ | Collision handling is on by default |
40
+ | `<Dropdown trigger={…}>` holding non-menu content | `Popover` | A `Dropdown` whose children are a `Menu` is a `DropdownMenu` instead (`aircall-ds/migrate-tractor/dropdown-menu`) |
41
+ | _(no equivalent)_ | `<PopoverHeader>` / `<PopoverTitle>` / `<PopoverDescription>` | Optional structured header; the title also names the popup for assistive tech |
42
+ | _(no equivalent)_ | `<PopoverClose>` | A button that closes the popover (required in `modal="trap-focus"`) |
31
43
 
32
44
  ## 2. Verified DS exports (`packages/ds/src/index.ts`)
33
45
 
34
46
  ```
35
- Popover, PopoverContent, PopoverDescription,
47
+ Popover, PopoverClose, PopoverContent, PopoverDescription,
36
48
  PopoverHeader, PopoverTitle, PopoverTrigger
37
49
  ```
38
50
 
@@ -56,27 +68,29 @@ import {
56
68
 
57
69
  ```tsx
58
70
  // Before
59
- import { Popover, Button } from '@aircall/tractor';
60
-
61
- <Popover
62
- placement="bottom-start"
63
- content={
64
- <div>
65
- <strong>Title</strong>
66
- <p>A short description.</p>
67
- <p>Body content.</p>
68
- </div>
69
- }
70
- >
71
- <Button variant="secondary" mode="outline">Open</Button>
72
- </Popover>
71
+ import { Popover, Button, Typography } from '@aircall/tractor';
72
+
73
+ <Popover.Root>
74
+ <Popover.Trigger>
75
+ <Button variant="secondary" mode="outline">Open</Button>
76
+ </Popover.Trigger>
77
+ <Popover.Content side="bottom" align="start" sideOffset={8} bg="white" boxShadow={1} borderRadius="sm" p="m">
78
+ <Typography variant="headingBoldS">Title</Typography>
79
+ <Typography>A short description.</Typography>
80
+ <Typography>Body content.</Typography>
81
+ </Popover.Content>
82
+ </Popover.Root>
83
+ ```
84
+
85
+ Note that `Popover.Content` only mounts while the popover is open. Tractor's own pattern of controlling it with `{isOpen && <Popover.Content>…}` is not needed in DS.
73
86
 
87
+ ```tsx
74
88
  // After
75
89
  import { Popover, PopoverContent, PopoverHeader, PopoverTitle, PopoverDescription, PopoverTrigger, Button } from '@aircall/ds';
76
90
 
77
91
  <Popover>
78
92
  <PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>
79
- <PopoverContent side="bottom" align="start">
93
+ <PopoverContent side="bottom" align="start" sideOffset={8}>
80
94
  <PopoverHeader>
81
95
  <PopoverTitle>Title</PopoverTitle>
82
96
  <PopoverDescription>A short description.</PopoverDescription>
@@ -86,20 +100,24 @@ import { Popover, PopoverContent, PopoverHeader, PopoverTitle, PopoverDescriptio
86
100
  </Popover>
87
101
  ```
88
102
 
89
- ### Controlled (replaces `isOpen` / `onClose`)
103
+ ### Controlled
90
104
 
91
105
  ```tsx
92
106
  // Before
93
- import { Popover, Button } from '@aircall/tractor';
94
-
95
- <Popover
96
- isOpen={isOpen}
97
- onClose={() => setIsOpen(false)}
98
- placement="top"
99
- content={<p>Settings panel</p>}
100
- >
101
- <Button variant="primary">Settings</Button>
102
- </Popover>
107
+ import { Popover, Button, Typography } from '@aircall/tractor';
108
+
109
+ const [isOpen, setIsOpen] = React.useState(false);
110
+
111
+ <Popover.Root open={isOpen} onOpenChange={setIsOpen}>
112
+ <Popover.Trigger onClick={() => setIsOpen(o => !o)}>
113
+ <Button variant="primary">Settings</Button>
114
+ </Popover.Trigger>
115
+ {isOpen && (
116
+ <Popover.Content side="top" bg="white" boxShadow={1} borderRadius="sm" p="m">
117
+ <Typography>Settings panel</Typography>
118
+ </Popover.Content>
119
+ )}
120
+ </Popover.Root>
103
121
 
104
122
  // After
105
123
  import { Popover, PopoverContent, PopoverTrigger, Button } from '@aircall/ds';
@@ -113,46 +131,48 @@ import { Popover, PopoverContent, PopoverTrigger, Button } from '@aircall/ds';
113
131
  ```
114
132
 
115
133
  Key changes:
116
- - `isOpen` → `open`; `onClose` → `onOpenChange` (receives the new boolean)
117
- - `content={…}` prop is removed — panel content is children of `PopoverContent`
118
- - Tractor's trigger child becomes `<PopoverTrigger render={<Button />}>` — label goes on `PopoverTrigger`, not inside the `render` element
119
- - `placement="bottom-start"` splits into `side="bottom" align="start"` on `PopoverContent`
134
+ - `open` / `defaultOpen` / `onOpenChange` keep their names; `onOpenChange` receives `(open, eventDetails)` (use `eventDetails.reason` to tell an outside press from Escape).
135
+ - The manual `onClick` toggle on the trigger and the `{isOpen && …}` guard are both gone: `PopoverTrigger` toggles the popover and the root mounts the panel.
136
+ - Tractor's trigger child becomes `<PopoverTrigger render={<Button />}>` — the label goes on `PopoverTrigger`, not inside the `render` element. Any element works as `render` (a `Button`, an `Avatar` wrapper, an `Input`), and it no longer needs to forward a ref (Tractor's contract); Base UI wires it.
137
+ - `Popover.Content` Flex/Box styling props (`bg`, `p`, `boxShadow`, `borderRadius`) are deleted; the panel provides them.
120
138
 
121
139
  ## 5. Positioning
122
140
 
123
- Tractor's single `placement` string maps to two props on `PopoverContent`:
141
+ `side` and `align` are the same props with the same values as Tractor's `Popover.Content`, so a Tractor call site carries them over. Only the defaults change:
124
142
 
125
- | Tractor `placement` | DS `side` | DS `align` |
143
+ | Prop | Tractor `Popover.Content` default | DS `PopoverContent` default |
126
144
  | --- | --- | --- |
127
- | `"bottom"` | `"bottom"` | `"center"` (default) |
128
- | `"bottom-start"` | `"bottom"` | `"start"` |
129
- | `"bottom-end"` | `"bottom"` | `"end"` |
130
- | `"top"` | `"top"` | `"center"` (default) |
131
- | `"top-start"` | `"top"` | `"start"` |
132
- | `"top-end"` | `"top"` | `"end"` |
133
- | `"left"` | `"left"` | `"center"` (default) |
134
- | `"right"` | `"right"` | `"center"` (default) |
145
+ | `side` | `"bottom"` | `"bottom"` |
146
+ | `align` | `"center"` | `"center"` |
147
+ | `sideOffset` | `0` (Dropdown: `8`) | `4` |
148
+ | `alignOffset` | _unset_ | `0` |
149
+
150
+ Pass `sideOffset={8}` where the old content used the Dropdown's `8` gap. Tractor accepted `side` of `top | right | bottom | left` and `align` of `start | center | end`; DS takes the same.
135
151
 
136
- Defaults when omitted: `side="bottom"`, `align="center"`, `sideOffset={4}`. Fine-tune gap with `sideOffset` / `alignOffset`.
152
+ To anchor to an element other than the trigger, pass `anchor` (a ref, element or virtual element) to `PopoverContent`.
137
153
 
138
154
  ## 6. Panel surface
139
155
 
140
- `PopoverContent` ships its own surface styles — `rounded-md`, `ring-1`, `bg-popover`, `p-4`, `shadow-md`. Do not re-add a wrapper `<div>` with manual padding, background, or border inside `PopoverContent`; it will double the spacing and styling.
156
+ `PopoverContent` ships its own surface and layout: `w-72` (288px), `p-4`, `flex flex-col gap-4`, `rounded-md`, `bg-popover`, `ring-1`, `shadow-md`, `text-sm`. Do not re-add a wrapper `<div>` with manual padding, background or border inside it; it will double the spacing and styling. Change the width with `className` (`w-48`, `w-80`, `w-(--anchor-width)`). Because the panel is a column with a `gap-4`, stack sections as direct children and let the gap space them, or group a title and description in `PopoverHeader`.
157
+
158
+ The panel is non-modal by default (the page behind stays interactive). `modal` on `Popover` takes `false | true | 'trap-focus'`; `'trap-focus'` needs a `PopoverClose` inside the content.
141
159
 
142
160
  ---
143
161
 
144
162
  ## 7. Common mistakes
145
163
 
146
- ### Mistake 1 — Keeping `content` as a prop instead of children
164
+ ### Mistake 1 — Keeping the `{isOpen && …}` guard or the `content` prop
147
165
 
148
166
  ```tsx
149
- // Wrong — content prop does not exist on DS Popover
150
- <Popover content={<p>Body content.</p>}>
167
+ // Wrong — there is no `content` prop, and the manual guard defeats the open/close animation
168
+ <Popover open={isOpen} content={<p>Body content.</p>}>
151
169
  <PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>
152
170
  </Popover>
171
+ // also wrong
172
+ {isOpen && <PopoverContent>…</PopoverContent>}
153
173
 
154
- // Correct — panel content is children of PopoverContent
155
- <Popover>
174
+ // Correct — panel content is children of PopoverContent, always rendered inside Popover
175
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
156
176
  <PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>
157
177
  <PopoverContent>
158
178
  <p>Body content.</p>
@@ -160,7 +180,7 @@ Defaults when omitted: `side="bottom"`, `align="center"`, `sideOffset={4}`. Fine
160
180
  </Popover>
161
181
  ```
162
182
 
163
- The DS compound has no `content` prop on `Popover`. Passing it silently does nothing — the popover renders with an empty panel. Move the JSX into children of `PopoverContent`.
183
+ The DS `Popover` has no `content` prop; `PopoverContent` is a child of `Popover` and Base UI mounts and unmounts it with the open state (including the exit animation). Move any JSX that Tractor passed as popover content into `PopoverContent`.
164
184
 
165
185
  Source: `packages/ds/src/components/popover.tsx`
166
186
 
@@ -169,45 +189,66 @@ Source: `packages/ds/src/components/popover.tsx`
169
189
  ### Mistake 2 — Putting the label inside the `render` Button instead of `PopoverTrigger`
170
190
 
171
191
  ```tsx
172
- // Wrong — label ends up inside Button's children prop, not managed by PopoverTrigger
192
+ // Wrong — the label is in the render element's children, which Base UI replaces
173
193
  <PopoverTrigger render={<Button variant="outline">Open</Button>} />
174
194
 
175
195
  // Correct — label is a child of PopoverTrigger; it is merged into the rendered Button
176
196
  <PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>
177
197
  ```
178
198
 
179
- `PopoverTrigger` uses the Base UI `render` prop pattern: it clones the element passed as `render` and merges its own open/close handler. The visible label must be the child of `PopoverTrigger`, not of the inner Button — otherwise it is ignored and the button renders empty.
199
+ `PopoverTrigger` uses the Base UI `render` prop pattern: it builds its own button from its props and children and merges them over the element passed as `render`. The visible label must be the child of `PopoverTrigger`; children of the element inside `render` are dropped, so the button renders empty.
180
200
 
181
201
  Source: `packages/ds/src/components/popover.tsx`
182
202
 
183
203
  ---
184
204
 
185
- ### Mistake 3 — Passing a single `placement` string instead of `side` + `align`
205
+ ### Mistake 3 — Styling the panel with Tractor Flex props, or wrapping the content in a styled div
186
206
 
187
207
  ```tsx
188
- // Wrong — placement is a Tractor prop; DS PopoverContent does not accept it
189
- <PopoverContent placement="bottom-start">…</PopoverContent>
208
+ // Wrong — Flex/Box props mean nothing to PopoverContent, and the extra wrapper doubles padding
209
+ <PopoverContent bg="white" boxShadow={1} borderRadius="sm" p="m">
210
+ <div className="rounded-md border bg-white p-4 shadow">…</div>
211
+ </PopoverContent>
190
212
 
191
- // Correct — split into side and align
192
- <PopoverContent side="bottom" align="start">…</PopoverContent>
213
+ // Correct — the panel already has the surface; size it with className
214
+ <PopoverContent className="w-80">…</PopoverContent>
193
215
  ```
194
216
 
195
- The DS `PopoverContent` accepts `side` and `align` as separate props (sourced from `PopoverPrimitive.Positioner`). A `placement` string is silently ignored, and the panel falls back to the default `side="bottom" align="center"` — which may look correct until the layout shifts.
217
+ `bg`, `boxShadow`, `borderRadius`, `p` and the other Tractor style props are `@xstyled` props, not DOM attributes and not `PopoverContent` props: they type-error and have no styling effect. Delete them, and delete any wrapper that repeats the surface.
196
218
 
197
219
  Source: `packages/ds/src/components/popover.tsx`
198
220
 
199
221
  ---
200
222
 
201
- ### Mistake 4 — Using `isOpen` / `onClose` instead of `open` / `onOpenChange`
223
+ ### Mistake 4 — Carrying over `closeOnScroll`, `portalled`, `takeTriggerWidth` and other Tractor-only props
202
224
 
203
225
  ```tsx
204
- // Wrong — isOpen and onClose are Tractor props; DS Popover ignores them
205
- <Popover isOpen={isOpen} onClose={() => setIsOpen(false)}>…</Popover>
226
+ // Wrong — none of these exist on PopoverContent
227
+ <PopoverContent closeOnScroll portalled takeTriggerWidth avoidCollisions zIndex={10}>…</PopoverContent>
228
+
229
+ // Correct — width follows the trigger via the positioner variable; the rest is built in
230
+ <PopoverContent className="w-(--anchor-width)">…</PopoverContent>
231
+ ```
232
+
233
+ `PopoverContent` accepts the Base UI popup props plus `side`, `align`, `sideOffset`, `alignOffset` and `anchor`. It always portals and handles collisions itself. If a flow depended on `closeOnInsideClick`, control it with `open`/`onOpenChange` or put a `PopoverClose` on the control that should close it.
234
+
235
+ Source: `packages/ds/src/components/popover.tsx`
236
+
237
+ ---
206
238
 
207
- // Correct — controlled via open and onOpenChange
208
- <Popover open={isOpen} onOpenChange={setIsOpen}>…</Popover>
239
+ ### Mistake 5 — Using `Popover` for a list of actions
240
+
241
+ ```tsx
242
+ // Wrong — a list of actions in a popover has no menu semantics or arrow-key navigation
243
+ <PopoverContent>
244
+ <Button variant="ghost" onClick={edit}>Edit</Button>
245
+ <Button variant="ghost" onClick={remove}>Delete</Button>
246
+ </PopoverContent>
247
+
248
+ // Correct
249
+ <DropdownMenu>…<DropdownMenuItem>Edit</DropdownMenuItem>…</DropdownMenu>
209
250
  ```
210
251
 
211
- DS `Popover` follows the Base UI controlled pattern: `open` (boolean) and `onOpenChange` (callback receiving the new boolean). `onClose` is not called — the popover stays open permanently when `onClose` is the only handler provided.
252
+ Use `Popover` for arbitrary content (forms, filters, a calendar, a `DataTree`) and `DropdownMenu` for a list of actions. A searchable list of options is a `Combobox`.
212
253
 
213
254
  Source: `packages/ds/src/components/popover.tsx`
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: aircall-ds/migrate-tractor/select
3
3
  description: >
4
- Migrate Tractor Select to the @aircall/ds Select compound. Load when a file
5
- imports Select from @aircall/tractor. Covers the compound parts, the nullable
6
- onValueChange, and the Group-wraps-Label rule.
4
+ Migrate Tractor Select (options-array API) and the @dashboard/library Select/SelectField to
5
+ the @aircall/ds Select compound. Load when a file imports Select from @aircall/tractor or
6
+ @dashboard/library. Covers the compound parts, the `items` prop that makes SelectValue show
7
+ labels, the nullable onValueChange, and the Group-wraps-Label rule.
7
8
  type: sub-skill
8
9
  library: aircall-ds
9
10
  requires:
@@ -11,23 +12,32 @@ requires:
11
12
  - aircall-ds/migrate-tractor
12
13
  sources:
13
14
  - "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/select.md"
15
+ - "aircall/hydra:packages/ds/src/components/select.tsx"
16
+ - "aircall/hydra:packages/ds/src/stories/Select.stories.tsx"
17
+ - "aircall/hydra:packages/blocks/src/components/form-select-field.tsx"
18
+ - "aircall/hydra:packages/tractor/src/components/Select/Select.decl.ts"
14
19
  ---
15
20
 
16
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 select-specific steps below.
17
22
 
23
+ For a form that collects and submits data, use `@aircall/blocks` `FormSelectField` and spread its `selectProps` onto `Select` and `selectTriggerProps` (`id`, `onBlur`, `aria-invalid`) onto `SelectTrigger`; it handles the `null` value and the label/`id` pairing. See `@aircall/blocks#aircall-blocks/migrate-dashboard/form-wizard`. The snippets below are the bare primitives.
24
+
18
25
  ## 1. Component mapping
19
26
 
20
- Tractor `Select` was a flat component with `SelectOption` children. DS uses a compound structure where each visual slot is a named part:
27
+ Tractor `Select` is a **single component driven by an `options` array** (there is no `SelectOption` child component in current Tractor; `@dashboard/library`'s `Select` wraps it and `SelectField` adds a `FormItem` + react-final-form). DS uses a compound structure where each visual slot is a named part and the options are `SelectItem` children:
21
28
 
22
29
  | Tractor | DS compound part | Role |
23
30
  | --- | --- | --- |
24
- | `<Select>` | `<Select>` | State owner (value, open, disabled) |
25
- | _(no equivalent)_ | `<SelectTrigger>` | Visible field / button |
26
- | _(no equivalent)_ | `<SelectValue>` | Renders current label or placeholder |
27
- | _(no equivalent)_ | `<SelectContent>` | Dropdown container |
28
- | `<SelectOption>` | `<SelectItem>` | Individual option |
29
- | _(no equivalent)_ | `<SelectGroup>` | Required wrapper around a labelled section |
30
- | _(no equivalent)_ | `<SelectLabel>` | Section heading inside a `SelectGroup` |
31
+ | `<Select options selectedKeys …>` | `<Select items value onValueChange>` | State owner (value, open, disabled). `items` is the label lookup (§4) |
32
+ | built-in trigger / `trigger` prop | `<SelectTrigger>` | Visible field / button (`w-fit` by default; add `className="w-full"` for Tractor's `w="100%"`) |
33
+ | `placeholder` | `<SelectValue placeholder>` | Renders current label or placeholder |
34
+ | built-in dropdown | `<SelectContent>` | Dropdown container |
35
+ | `options[]` entry `{ label, value }` | `<SelectItem value>label</SelectItem>` | Individual option |
36
+ | `OptionGroup` `{ label, options }` | `<SelectGroup>` + `<SelectLabel>` + `SelectItem`s | Labelled section; `SelectLabel` MUST be inside a `SelectGroup` |
37
+ | group `divider` | `<SelectSeparator>` | Rule between groups |
38
+ | `renderOption`, option `prefix`/`suffix` | children of `SelectItem` | Icons / extra nodes inside the item |
39
+ | `searchable`, `searchOptions` | use `Combobox` / `DataCombobox` instead | See §7 |
40
+ | `selectionMode="multiple"` | use `Combobox` with `multiple` instead | See §7 |
31
41
 
32
42
  ## 2. Verified DS exports (`packages/ds/src/index.ts`)
33
43
 
@@ -49,6 +59,7 @@ import {
49
59
  SelectGroup,
50
60
  SelectItem,
51
61
  SelectLabel,
62
+ SelectSeparator,
52
63
  SelectTrigger,
53
64
  SelectValue,
54
65
  } from '@aircall/ds';
@@ -58,26 +69,35 @@ import {
58
69
 
59
70
  | Tractor prop | DS prop | Notes |
60
71
  | --- | --- | --- |
61
- | `onChange` | `onValueChange` | Signature change — see Mistake 1 below |
72
+ | `options` | `items` on `<Select>` **and** `<SelectItem>` children | `items` (`{ value, label }[]`, a `Record<value, label>`, or grouped `{ items }[]`) lets `SelectValue` show the **label**. Without it the trigger shows the raw `value` (§9 Mistake 5) |
73
+ | `selectedKeys={[v]}` / `defaultSelectedKeys` | `value={v}` / `defaultValue` | A single value, not an array. Use `null` (not `undefined`) for "nothing selected" on a controlled select |
74
+ | `onSelectionChange(keys[])` / `onItemSelected` | `onValueChange(value, eventDetails)` | Signature change — see Mistake 1 |
62
75
  | `placeholder` on `<Select>` | `placeholder` on `<SelectValue>` | Moved to the value part |
63
- | `selectedOption` / `value` | `value` | Unchanged name, same position |
76
+ | `size="small"\|"regular"\|"large"` | `size="default"\|"sm"` on `<SelectTrigger>` | §6 |
77
+ | `validationStatus="error"` | `aria-invalid` on `<SelectTrigger>` | Same ARIA convention as `Input` |
78
+ | `disabled` | `disabled` on `<Select>` | |
79
+ | `getOptionLabel` / `getOptionValue` | _(removed)_ | No accessor props on the DS `Select`; map your array into `SelectItem`s (and into `items`) yourself. Item values are strings (object values need `itemToStringLabel` / `isItemEqualToValue` on the root) |
80
+ | `side`, `align` | `side`, `align` on `<SelectContent>` | Default `side="bottom"`, `align="start"` |
81
+ | `open`, `defaultOpen` | `open`, `defaultOpen`, `onOpenChange` on `<Select>` | |
82
+ | `data-test` | `data-test` on `SelectTrigger` / `SelectContent` | |
64
83
 
65
84
  ## 5. Before / After
66
85
 
67
86
  ### Before (Tractor)
68
87
 
69
88
  ```tsx
70
- import { Select, SelectOption } from '@aircall/tractor';
89
+ import { Select } from '@aircall/tractor';
71
90
 
72
91
  <Select
73
- value={channelType}
74
- onChange={(value) => setChannelType(value)}
92
+ selectedKeys={channelType ? [channelType] : []}
93
+ onSelectionChange={keys => setChannelType(keys[0] ?? '')}
75
94
  placeholder="Pick a channel"
76
- >
77
- <SelectOption value="phone">Phone</SelectOption>
78
- <SelectOption value="email">Email</SelectOption>
79
- <SelectOption value="sms">SMS</SelectOption>
80
- </Select>
95
+ options={[
96
+ { value: 'phone', label: 'Phone' },
97
+ { value: 'email', label: 'Email' },
98
+ { value: 'sms', label: 'SMS' },
99
+ ]}
100
+ />
81
101
  ```
82
102
 
83
103
  ### After (DS)
@@ -91,40 +111,56 @@ import {
91
111
  SelectValue,
92
112
  } from '@aircall/ds';
93
113
 
114
+ const CHANNELS = [
115
+ { value: 'phone', label: 'Phone' },
116
+ { value: 'email', label: 'Email' },
117
+ { value: 'sms', label: 'SMS' },
118
+ ];
119
+
94
120
  <Select
121
+ items={CHANNELS}
95
122
  value={channelType}
96
123
  onValueChange={(value: string | null) => {
97
124
  if (value !== null) setChannelType(value);
98
125
  }}
99
126
  >
100
- <SelectTrigger>
127
+ <SelectTrigger id="channel" className="w-full">
101
128
  <SelectValue placeholder="Pick a channel" />
102
129
  </SelectTrigger>
103
130
  <SelectContent>
104
- <SelectItem value="phone">Phone</SelectItem>
105
- <SelectItem value="email">Email</SelectItem>
106
- <SelectItem value="sms">SMS</SelectItem>
131
+ {CHANNELS.map(item => (
132
+ <SelectItem key={item.value} value={item.value}>
133
+ {item.label}
134
+ </SelectItem>
135
+ ))}
107
136
  </SelectContent>
108
137
  </Select>
109
138
  ```
110
139
 
111
- ## 6. With sections (Labels)
140
+ With a label and an error, wrap it in `Field` (see `aircall-ds/migrate-tractor/form-and-field`): `FieldLabel htmlFor="channel"`, `aria-invalid` on the `SelectTrigger`, `data-invalid` on the `Field`, then `<FieldError>`.
112
141
 
113
- When grouping options under a label, `SelectLabel` **must** be inside a `SelectGroup` along with its items. Direct children of `SelectContent` are not accessibility-correct in Base UI.
142
+ `items` also lets a `{ label: 'Select a timezone', value: null }` entry act as the placeholder label; a `null`-valued item's label wins over `SelectValue`'s `placeholder`.
114
143
 
115
- ```tsx
116
- import {
117
- Select,
118
- SelectContent,
119
- SelectGroup,
120
- SelectItem,
121
- SelectLabel,
122
- SelectTrigger,
123
- SelectValue,
124
- } from '@aircall/ds';
144
+ ## 6. Size
125
145
 
126
- <Select value={value} onValueChange={setValue}>
127
- <SelectTrigger>
146
+ `SelectTrigger` accepts a `size` prop:
147
+
148
+ | Value | Height | Use for |
149
+ | --- | --- | --- |
150
+ | `"default"` | 40px | Any Tractor size (`small` was 40px, `regular` 48px, `large` 56px) |
151
+ | `"sm"` | 32px | Compact layouts (no Tractor equivalent) |
152
+
153
+ ## 7. When to use Combobox instead
154
+
155
+ If users need to **search or filter** the options list, or select **several** options, use `Combobox` / `DataCombobox` (`aircall-ds/migrate-tractor/combobox`) rather than `Select`. Plain `Select` is for short, fixed-enum, single-choice lists. Tractor `Select` with `searchable` or `selectionMode="multiple"` is a Combobox migration.
156
+
157
+ ## 8. With sections (Labels)
158
+
159
+ When grouping options under a label, `SelectLabel` **must** be inside a `SelectGroup` along with its items (Base UI throws "SelectGroupContext is missing" otherwise). Use `SelectSeparator` between groups:
160
+
161
+ ```tsx
162
+ <Select items={groupedItems} value={value} onValueChange={setValue}>
163
+ <SelectTrigger className="w-full">
128
164
  <SelectValue placeholder="Pick a channel" />
129
165
  </SelectTrigger>
130
166
  <SelectContent>
@@ -133,6 +169,7 @@ import {
133
169
  <SelectItem value="phone">Phone</SelectItem>
134
170
  <SelectItem value="sms">SMS</SelectItem>
135
171
  </SelectGroup>
172
+ <SelectSeparator />
136
173
  <SelectGroup>
137
174
  <SelectLabel>Written</SelectLabel>
138
175
  <SelectItem value="email">Email</SelectItem>
@@ -141,18 +178,7 @@ import {
141
178
  </Select>
142
179
  ```
143
180
 
144
- ## 7. Size
145
-
146
- `SelectTrigger` accepts a `size` prop:
147
-
148
- | Value | Height | Use for |
149
- | --- | --- | --- |
150
- | `"default"` | 40px | Any Tractor `regular` or `small` size |
151
- | `"sm"` | 32px | Compact layouts |
152
-
153
- ## 8. When to use Combobox instead
154
-
155
- If users need to **search or filter** the options list, use `Combobox` rather than `Select`. Plain `Select` is for short, fixed-enum lists where no search is needed.
181
+ `groupedItems` can be the flat `{ value, label }[]` of all options (the grouping lives in the JSX).
156
182
 
157
183
  ## 9. Common Mistakes
158
184
 
@@ -174,8 +200,8 @@ If users need to **search or filter** the options list, use `Combobox` rather th
174
200
  </Select>
175
201
  ```
176
202
 
177
- The DS `onValueChange` callback receives `string | null` — `null` is emitted when the selection is cleared. Typing the parameter as `string` causes a TypeScript error; omitting the null guard causes a runtime `null` to propagate into state that expects a string.
178
- Source: `packages/ds/src/components/select.tsx`
203
+ The DS `onValueChange` callback receives `string | null` (plus an event-details argument). Typing the parameter as `string` is a TypeScript error under `strictFunctionTypes`; omitting the null guard lets a runtime `null` propagate into state that expects a string.
204
+ Source: `packages/ds/src/components/select.tsx` (`Select = SelectPrimitive.Root`); Base UI `onValueChange?: (value: Value | null, eventDetails) => void`
179
205
 
180
206
  ---
181
207
 
@@ -197,8 +223,8 @@ Source: `packages/ds/src/components/select.tsx`
197
223
  </SelectContent>
198
224
  ```
199
225
 
200
- In Base UI, `SelectLabel` must be a sibling of its items inside a `SelectGroup`. A bare `SelectLabel` in `SelectContent` is not accessibility-correct — the group association that screen readers rely on is missing, and the label may render incorrectly.
201
- Source: `packages/ds/src/components/select.tsx`
226
+ `SelectLabel` wraps Base UI's `Select.GroupLabel`, which reads its parent `Select.Group` context. Outside a `SelectGroup` it throws ("SelectGroupContext is missing") instead of rendering.
227
+ Source: `packages/ds/src/components/select.tsx` (`SelectLabel` → `SelectPrimitive.GroupLabel`)
202
228
 
203
229
  ---
204
230
 
@@ -222,23 +248,50 @@ Source: `packages/ds/src/components/select.tsx`
222
248
  </Select>
223
249
  ```
224
250
 
225
- Tractor accepted `placeholder` on the root `<Select>`. In the DS compound, the `placeholder` prop lives on `<SelectValue>` — it is silently ignored when placed on `<Select>`, so no placeholder text appears in the trigger.
251
+ Tractor accepted `placeholder` on the root `<Select>`. In the DS compound, the `placeholder` prop lives on `<SelectValue>`; the root has no such prop (type error), so no placeholder text appears in the trigger.
226
252
  Source: `packages/ds/src/components/select.tsx`
227
253
 
228
254
  ---
229
255
 
230
- ### Mistake 4 — Using `SelectOption` instead of `SelectItem`
256
+ ### Mistake 4 — Passing Tractor's `options` / `selectedKeys` / `onSelectionChange` to the DS `Select`
231
257
 
232
258
  ```tsx
233
- // Wrong
234
- import { Select, SelectOption } from '@aircall/tractor';
235
- // SelectOption does not exist in @aircall/ds
259
+ // Wrong — these props do not exist on the DS Select
260
+ <Select options={options} selectedKeys={[value]} onSelectionChange={keys => setValue(keys[0])} />
236
261
 
237
262
  // Correct
238
- import { Select, SelectItem } from '@aircall/ds';
263
+ <Select items={options} value={value} onValueChange={v => v !== null && setValue(v)}>
264
+ <SelectTrigger><SelectValue /></SelectTrigger>
265
+ <SelectContent>
266
+ {options.map(o => <SelectItem key={o.value} value={o.value}>{o.label}</SelectItem>)}
267
+ </SelectContent>
268
+ </Select>
269
+ ```
270
+
271
+ The DS `Select` renders no options on its own; every option is a `SelectItem` child. There is no `SelectOption` in either library, so do not import one.
272
+ Source: `packages/ds/src/components/select.tsx`; `packages/tractor/src/components/Select/Select.decl.ts` (`options`, `selectedKeys`, `onSelectionChange`)
239
273
 
240
- <SelectItem value="phone">Phone</SelectItem>
274
+ ---
275
+
276
+ ### Mistake 5 — Omitting `items`, so the trigger shows the raw value
277
+
278
+ ```tsx
279
+ // Wrong — after picking "Phone" the trigger reads "phone" (the value), not "Phone"
280
+ <Select value={channel} onValueChange={setChannel}>
281
+ <SelectTrigger><SelectValue placeholder="Pick a channel" /></SelectTrigger>
282
+ <SelectContent>
283
+ <SelectItem value="phone">Phone</SelectItem>
284
+ </SelectContent>
285
+ </Select>
286
+
287
+ // Correct — give the root the value→label lookup
288
+ <Select items={[{ value: 'phone', label: 'Phone' }]} value={channel} onValueChange={setChannel}>
289
+ <SelectTrigger><SelectValue placeholder="Pick a channel" /></SelectTrigger>
290
+ <SelectContent>
291
+ <SelectItem value="phone">Phone</SelectItem>
292
+ </SelectContent>
293
+ </Select>
241
294
  ```
242
295
 
243
- Tractor used `SelectOption` for each choice. The DS compound uses `SelectItem`. `SelectOption` is not exported from `@aircall/ds` — importing it will cause a build error.
244
- Source: `packages/ds/src/components/select.tsx`
296
+ `SelectValue` does not read the text of the matching `SelectItem` (the popup may be unmounted). It resolves the label from the root `items` prop, and falls back to the raw value when `items` is absent. Alternatively give `SelectValue` a function child: `<SelectValue>{(v: string | null) => (v ? labelByValue[v] : null)}</SelectValue>` — note a function child bypasses the `placeholder` prop, so render the placeholder yourself when `v` is empty.
297
+ Source: Base UI `SelectValue` / `resolveSelectedLabel`; every story in `packages/ds/src/stories/Select.stories.tsx` passes `items`