@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
@@ -2,8 +2,9 @@
2
2
  name: aircall-ds/migrate-tractor/form-and-field
3
3
  description: >
4
4
  Migrate Tractor Form and FormItem to native <form> + @aircall/ds Field compound.
5
- Load when a file imports Form, FormItem, or FormRow from @aircall/tractor. Covers
6
- label/control/error layout, validation state, fieldsets, and help text.
5
+ Load when a file imports Form or FormItem from @aircall/tractor. Covers
6
+ label/control/error layout, validation state, fieldsets, help text, orientation, and
7
+ label add-ons.
7
8
  type: sub-skill
8
9
  library: aircall-ds
9
10
  requires:
@@ -11,26 +12,38 @@ requires:
11
12
  - aircall-ds/migrate-tractor
12
13
  sources:
13
14
  - "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/form-and-field.md"
15
+ - "aircall/hydra:packages/ds/src/components/field.tsx"
16
+ - "aircall/hydra:packages/ds/src/stories/Field.stories.tsx"
17
+ - "aircall/hydra:packages/blocks/src/components/form-field.tsx"
18
+ - "aircall/hydra:packages/tractor/src/components/Form/components/FormItem/FormItem.tsx"
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 form-specific steps below.
17
22
 
18
- > **Principle — for a form that collects + submits data, drive it with `@aircall/blocks` `useForm` + the `Form*Field` wrappers, not local `useState`.** The ds `Field`/`FieldLabel`/`FieldError` primitives below are the field *shell* those wrappers render — reach for them bare only for non-form display. See `@aircall/blocks#aircall-blocks/migrate-dashboard/form-wizard`.
23
+ > **Principle — for a form that collects + submits data, drive it with `@aircall/blocks` `useForm` + the `Form*Field` wrappers, not local `useState`.** The ds `Field`/`FieldLabel`/`FieldError` primitives below are the field *shell* those wrappers render — reach for them bare only for non-form display. See `@aircall/blocks#aircall-blocks/migrate-dashboard/form-wizard` and §3h below for how the wrapper props (`label`, `description`, `necessityIndicator`, `orientation`, `controlPosition`) map onto the primitives.
19
24
 
20
25
  ## 1. Component mapping
21
26
 
22
27
  DS has no `Form` component. Use a native `<form>` element and wrap each field row in `<Field>`.
23
28
 
29
+ Tractor `FormItem` only had `label`, `labelId`, `name`, `helpText`, `validationStatus` (plus Grid layout props). There is no `hint`, `error` or `FormRow`.
30
+
24
31
  | Tractor | @aircall/ds | Notes |
25
32
  | --- | --- | --- |
26
- | `<Form>` | `<form>` | Native HTML element — no DS wrapper |
33
+ | `<Form size>` | `<form>` | Native HTML element — no DS wrapper. The form-level `size` context is gone: `Input`, `Textarea`, `Switch`, `Checkbox` have no size; `SelectTrigger` takes `size="default"\|"sm"` per control |
27
34
  | `<FormItem label="…">` | `<Field>` + `<FieldLabel>` + control | Layout and label are now separate |
28
- | `<FormItem validationStatus="error">` | `aria-invalid` on the control | No Tractor-style prop; use standard ARIA |
29
- | `<FormItem hint="…">` | `<FieldDescription>` | Renders muted below the control |
30
- | `<FormItem error="…">` | `<FieldError>` | Renders in `text-destructive`; conditionally mount it |
31
- | — | `<FieldGroup>` | Stacks multiple `<Field>` rows with consistent spacing |
35
+ | `<FormItem name="x">` | `id="x"` on the control + `htmlFor="x"` on `FieldLabel` | Tractor wired label → control through `name`; DS does not (see Mistake 2) |
36
+ | `<FormItem labelId>` | `id` on `<FieldLabel>` | |
37
+ | `<FormItem validationStatus="error">` | `aria-invalid` on the control **and** `data-invalid` on `<Field>` | No Tractor-style prop; use standard ARIA. `data-invalid` is what hides a contextual `FieldDescription` while the error shows (Mistake 4) |
38
+ | `<FormItem helpText="…">` (neutral) | `<FieldDescription>` | Muted, below the control. Hidden while `Field` has `data-invalid` |
39
+ | `<FormItem helpText="…">` + `validationStatus="error"` (the error message) | `<FieldError>` | Renders in `text-destructive`; renders nothing when empty, so it can stay mounted |
40
+ | `<FormItem gap … />` (Grid props) | Tailwind `className` on `<Field>` | `Field` is `flex w-full gap-2` |
41
+ | — | `<FieldGroup>` | Stacks multiple `<Field>` rows with consistent spacing (`gap-6`) |
32
42
  | — | `<FieldSet>` + `<FieldLegend>` | Wraps a group of related fields in a semantic `<fieldset>` |
33
- | — | `<FieldContent>` | Groups the control + description + error in a column (used with `orientation="horizontal"`) |
43
+ | — | `<FieldContent>` | Column wrapper for label/description or control/description/error beside another element (used with `orientation="horizontal"` / `"responsive"`) |
44
+ | — | `<FieldTitle>` | Non-`<label>` title for a field not tied to a single control |
45
+ | — | `<FieldSeparator>` | Divider between fields; optional centered text child |
46
+ | — | `<FieldLabelRow>` + `<FieldLabelInfo>` / `<FieldLabelAside>` | Label add-ons: `(i)` popover and right-aligned help link (§3h) |
34
47
 
35
48
  ## 2. Imports
36
49
 
@@ -42,8 +55,13 @@ import {
42
55
  FieldError,
43
56
  FieldGroup,
44
57
  FieldLabel,
58
+ FieldLabelAside,
59
+ FieldLabelInfo,
60
+ FieldLabelRow,
45
61
  FieldLegend,
62
+ FieldSeparator,
46
63
  FieldSet,
64
+ FieldTitle,
47
65
  Button,
48
66
  Input
49
67
  } from '@aircall/ds';
@@ -55,15 +73,16 @@ import {
55
73
 
56
74
  **Before (Tractor):**
57
75
  ```tsx
58
- import { FormItem, Input } from '@aircall/tractor';
76
+ import { FormItem, TextInput } from '@aircall/tractor';
59
77
 
60
78
  <form onSubmit={onSubmit}>
61
79
  <FormItem
62
80
  label="Email"
81
+ name="email"
63
82
  validationStatus={emailError ? 'error' : undefined}
64
- error={emailError}
83
+ helpText={emailError}
65
84
  >
66
- <Input
85
+ <TextInput
67
86
  type="email"
68
87
  value={email}
69
88
  onChange={e => setEmail(e.target.value)}
@@ -77,7 +96,7 @@ import { FormItem, Input } from '@aircall/tractor';
77
96
  import { Field, FieldLabel, FieldError, Input, Button } from '@aircall/ds';
78
97
 
79
98
  <form onSubmit={onSubmit}>
80
- <Field>
99
+ <Field data-invalid={!!emailError || undefined}>
81
100
  <FieldLabel htmlFor="email">Email</FieldLabel>
82
101
  <Input
83
102
  id="email"
@@ -86,7 +105,7 @@ import { Field, FieldLabel, FieldError, Input, Button } from '@aircall/ds';
86
105
  onChange={e => setEmail(e.target.value)}
87
106
  aria-invalid={!!emailError}
88
107
  />
89
- {emailError && <FieldError>{emailError}</FieldError>}
108
+ <FieldError>{emailError}</FieldError>
90
109
  </Field>
91
110
 
92
111
  <Button type="submit" size="lg">Submit</Button>
@@ -94,19 +113,19 @@ import { Field, FieldLabel, FieldError, Input, Button } from '@aircall/ds';
94
113
  ```
95
114
 
96
115
  Key changes:
97
- - `<FormItem label="…">` → explicit `<FieldLabel htmlFor>` paired with `id` on the control; you own the id/htmlFor pairing.
98
- - `validationStatus="error"` → removed; set `aria-invalid={true}` on the control instead.
99
- - `error={…}` → `<FieldError>` rendered conditionally as a child of `<Field>`.
116
+ - `<FormItem label="…" name="…">` → explicit `<FieldLabel htmlFor>` paired with `id` on the control; you own the id/htmlFor pairing.
117
+ - `validationStatus="error"` → removed; set `aria-invalid` on the control and `data-invalid` on the `Field`.
118
+ - `helpText` carrying the error message → `<FieldError>` as a child of `<Field>`. It renders nothing when its children are empty.
100
119
 
101
120
  ### 3b. Multiple rows with FieldGroup
102
121
 
103
122
  **Before (Tractor):**
104
123
  ```tsx
105
- import { FormItem, Input } from '@aircall/tractor';
124
+ import { FormItem, TextInput } from '@aircall/tractor';
106
125
 
107
126
  <form>
108
- <FormItem label="Name"><Input id="name" /></FormItem>
109
- <FormItem label="Phone"><Input id="phone" type="tel" /></FormItem>
127
+ <FormItem label="Name" name="name"><TextInput /></FormItem>
128
+ <FormItem label="Phone" name="phone"><TextInput type="tel" /></FormItem>
110
129
  </form>
111
130
  ```
112
131
 
@@ -142,7 +161,11 @@ import { Field, FieldLabel, Checkbox } from '@aircall/ds';
142
161
  </Field>
143
162
  ```
144
163
 
145
- Use `orientation="horizontal"` for Checkbox + label and Switch + label pairs. The `Field` component also accepts `orientation="responsive"`, which stacks vertically at narrow widths and switches to horizontal at `@md` breakpoint inside a `FieldGroup`.
164
+ Use `orientation="horizontal"` for Checkbox + label and Switch + label pairs. For a switch with a description, put label and description in a `FieldContent` after the switch (see `aircall-blocks/migrate-dashboard/toggle-row`).
165
+
166
+ For text-like controls, **default to the vertical layout** (what `FormItem` was). Use `horizontal` only on long data-entry surfaces (large settings/config panels) where stacking dozens of fields would be unusably tall, or to deliberately slow completion on sensitive forms.
167
+
168
+ `orientation="responsive"` is vertical on narrow containers and horizontal from the `@md` **container** width (a `@container/field-group` query, not the viewport). It therefore needs a `FieldGroup` ancestor.
146
169
 
147
170
  ### 3d. Grouped fields with fieldset / legend
148
171
 
@@ -165,16 +188,16 @@ import { FieldSet, FieldLegend, FieldGroup, Field, FieldLabel, Input } from '@ai
165
188
  </FieldSet>
166
189
  ```
167
190
 
168
- `FieldLegend` renders a `<legend>` with `variant="legend"` (base text size) by default. Pass `variant="label"` for a smaller label-sized legend.
191
+ `FieldLegend` renders a bold `<legend>`; `variant="legend"` (default) is a section-heading size (`text-xl`), `variant="label"` is label-sized (`text-sm`). Use a nested `<FieldSet>` + `<FieldLegend variant="label">` around a `RadioGroup`/checkbox group.
169
192
 
170
- ### 3e. Field with help text (hint)
193
+ ### 3e. Field with help text (helpText)
171
194
 
172
195
  **Before (Tractor):**
173
196
  ```tsx
174
- import { FormItem, Input } from '@aircall/tractor';
197
+ import { FormItem, TextInput } from '@aircall/tractor';
175
198
 
176
- <FormItem label="Alias" hint="Shown to teammates in your call queue.">
177
- <Input id="alias" />
199
+ <FormItem label="Alias" name="alias" helpText="Shown to teammates in your call queue.">
200
+ <TextInput />
178
201
  </FormItem>
179
202
  ```
180
203
 
@@ -189,61 +212,92 @@ import { Field, FieldLabel, FieldDescription, Input } from '@aircall/ds';
189
212
  </Field>
190
213
  ```
191
214
 
215
+ `FieldDescription` has two kinds via `variant`; never use both on one field:
216
+ - `contextual` (default): consequence / reassurance copy **below** the control; **hidden while the `Field` has `data-invalid`** (the `FieldError` takes its slot).
217
+ - `instructional`: guidance the user needs to fill the field correctly; place it **directly under the label**, above the control; it stays visible next to the error.
218
+
192
219
  ### 3f. Multiple validation errors via FieldError `errors` prop
193
220
 
194
- `FieldError` accepts an `errors` array in addition to `children`. When multiple distinct messages are present it renders a `<ul>` automatically; duplicates are deduplicated.
221
+ `FieldError` accepts an `errors` array in addition to `children` (`children` wins when both are given). When multiple distinct messages are present it renders a `<ul>` automatically; duplicates are removed.
195
222
 
196
223
  **After (DS):**
197
224
  ```tsx
198
225
  import { Field, FieldLabel, FieldError, Input } from '@aircall/ds';
199
226
 
200
- <Field>
227
+ <Field data-invalid={errors.length > 0 || undefined}>
201
228
  <FieldLabel htmlFor="pwd">Password</FieldLabel>
202
229
  <Input id="pwd" type="password" aria-invalid={errors.length > 0} />
203
230
  <FieldError errors={errors} />
204
231
  </Field>
205
232
  ```
206
233
 
207
- Where `errors` is `Array<{ message?: string }>`. When the array is empty `FieldError` renders nothing.
234
+ Where `errors` is `Array<{ message?: string } | undefined>`. When the array is empty `FieldError` renders nothing.
208
235
 
209
236
  ### 3g. Horizontal layout with FieldContent (label beside stacked controls)
210
237
 
211
- When the label sits beside a column of controls (e.g. control + description + error), wrap the right-hand column in `FieldContent`:
238
+ When the label sits beside a column of controls (control + description + error), wrap the right-hand column in `FieldContent`:
212
239
 
213
240
  **After (DS):**
214
241
  ```tsx
215
242
  import { Field, FieldLabel, FieldContent, FieldDescription, FieldError, Input } from '@aircall/ds';
216
243
 
217
- <Field orientation="horizontal">
218
- <FieldLabel htmlFor="alias">Alias</FieldLabel>
244
+ <Field orientation="horizontal" data-invalid={!!aliasError || undefined}>
245
+ <FieldLabel htmlFor="alias" className="w-24">Alias</FieldLabel>
219
246
  <FieldContent>
220
247
  <Input id="alias" aria-invalid={!!aliasError} />
221
248
  <FieldDescription>Shown to teammates in your call queue.</FieldDescription>
222
- {aliasError && <FieldError>{aliasError}</FieldError>}
249
+ <FieldError>{aliasError}</FieldError>
223
250
  </FieldContent>
224
251
  </Field>
225
252
  ```
226
253
 
254
+ For `orientation="responsive"` the structure is different: label **and** description share a `FieldContent`, and the control is a direct sibling after it (see the `Orientations` story).
255
+
256
+ ### 3h. Label add-ons, necessity, and the `Form*Field` equivalents
257
+
258
+ ```tsx
259
+ import {
260
+ Field, FieldLabel, FieldLabelRow, FieldLabelInfo, FieldLabelAside, Input, Anchor
261
+ } from '@aircall/ds';
262
+
263
+ <Field>
264
+ <FieldLabelRow>
265
+ <FieldLabel htmlFor="tax" necessityIndicator="optional">Tax ID Number</FieldLabel>
266
+ <FieldLabelInfo>It appears on your monthly invoices.</FieldLabelInfo>
267
+ <FieldLabelAside>
268
+ <Anchor href="/help/tax-id">Where do I find this?</Anchor>
269
+ </FieldLabelAside>
270
+ </FieldLabelRow>
271
+ <Input id="tax" />
272
+ </Field>
273
+ ```
274
+
275
+ - `necessityIndicator="required" | "optional"` on `FieldLabel` renders `(required)` / `(optional)` text. Mark the **exceptions** (the few optional fields in a mostly-required form, or the reverse); never mix both markers in one form; there is no asterisk. It is presentational: also set the control's own `required`/`aria-required`.
276
+ - `FieldLabelInfo` (an `(i)` popover) and `FieldLabelAside` (right-aligned link/text) belong inside a `FieldLabelRow`, never inside the `<label>`.
277
+ - `data-disabled="true"` on `Field` dims the **label** only; the control still needs its own `disabled`.
278
+
279
+ The `@aircall/blocks` `Form*Field` wrappers render exactly this shell. Their props map as: `label` (string, or `{ content, aside?, info? }`) → `FieldLabel` / `FieldLabelRow`; `description` (a bare string is `instructional`; `{ content, variant }` picks `contextual`) → `FieldDescription`; `necessityIndicator` → `FieldLabel`; `orientation` and `controlPosition` (`'start' | 'end'`; `FormSwitchField` defaults to `'start'`, others `'end'`) → `Field` orientation and which side the control column sits on. They also set `data-invalid`, `aria-invalid` and the `id`/`htmlFor` pairing for you.
280
+
227
281
  ## 4. Common mistakes
228
282
 
229
283
  ### Mistake 1 — Using `validationStatus` instead of `aria-invalid`
230
284
 
231
285
  ```tsx
232
- // Wrong — Field and its children have no validationStatus prop; it is silently ignored
286
+ // Wrong — Field and its children have no validationStatus prop (type error; it would only leak to the DOM)
233
287
  <Field validationStatus="error">
234
288
  <FieldLabel htmlFor="email">Email</FieldLabel>
235
289
  <Input id="email" />
236
290
  </Field>
237
291
 
238
- // Correct — set aria-invalid on the control; FieldError handles the error message
239
- <Field>
292
+ // Correct — set aria-invalid on the control, data-invalid on the Field; FieldError handles the message
293
+ <Field data-invalid={!!emailError || undefined}>
240
294
  <FieldLabel htmlFor="email">Email</FieldLabel>
241
295
  <Input id="email" aria-invalid={!!emailError} />
242
- {emailError && <FieldError>{emailError}</FieldError>}
296
+ <FieldError>{emailError}</FieldError>
243
297
  </Field>
244
298
  ```
245
299
 
246
- DS uses standard ARIA for validation state rather than a custom prop. `aria-invalid` on the control signals the error to assistive technology; `FieldError` renders with `role="alert"` and applies the destructive colour automatically.
300
+ DS uses standard ARIA for validation state rather than a custom prop. `aria-invalid` on the control signals the error to assistive technology and draws the destructive border; `FieldError` renders with `role="alert"` and applies the destructive colour automatically. An invalid field does not turn its label red.
247
301
 
248
302
  Source: `packages/ds/src/components/field.tsx` — `FieldError` sets `role="alert"` and `text-destructive`; `Field` has no `validationStatus` variant.
249
303
 
@@ -265,7 +319,7 @@ Source: `packages/ds/src/components/field.tsx` — `FieldError` sets `role="aler
265
319
  </Field>
266
320
  ```
267
321
 
268
- Tractor's `<FormItem label="…">` wired the label to its child input automatically. DS `FieldLabel` is a styled `<label>` — it does not auto-discover its sibling control. Without `htmlFor` + `id` the label click does not focus the input and screen readers cannot announce the association.
322
+ Tractor's `<FormItem label="…" name="…">` wired the label to its child input automatically. DS `FieldLabel` is a styled `<label>` — it does not auto-discover its sibling control. Without `htmlFor` + `id` the label click does not focus the input (or toggle a Switch/Checkbox) and screen readers cannot announce the association. (The `Form*Field` wrappers generate and pair the id for you.)
269
323
 
270
324
  Source: `packages/ds/src/components/field.tsx` — `FieldLabel` wraps `Label` (a plain `<label>`) with no auto-association logic.
271
325
 
@@ -301,24 +355,32 @@ Source: `packages/ds/src/components/field.tsx` — `FieldLabel` wraps `Label` (a
301
355
  </form>
302
356
  ```
303
357
 
304
- `Field` applies no external margin. `FieldGroup` is the intentional spacing container — it uses `gap-6` between children and adjusts automatically for nested `FieldGroup` elements (`*:data-[slot=field-group]:gap-4`).
358
+ `Field` applies no external margin. `FieldGroup` is the intentional spacing container — it uses `gap-6` between children and adjusts automatically for nested `FieldGroup` elements (`*:data-[slot=field-group]:gap-4`). It is also the `@container` that `orientation="responsive"` reads.
305
359
 
306
360
  Source: `packages/ds/src/components/field.tsx` — `FieldGroup` sets `flex flex-col gap-6`; `Field` sets no external gap.
307
361
 
308
362
  ---
309
363
 
310
- ### Mistake 4 — Conditionally rendering FieldError without checking the message
364
+ ### Mistake 4 — Forgetting `data-invalid` on `Field`, so the contextual description stays next to the error
311
365
 
312
366
  ```tsx
313
- // Wrong — FieldError always mounts, rendering an empty alert div
314
- <FieldError>{emailError}</FieldError>
367
+ // Wrong — the default (contextual) description is still visible beside the error
368
+ <Field>
369
+ <FieldLabel htmlFor="phone">Phone</FieldLabel>
370
+ <Input id="phone" aria-invalid={!!phoneError} />
371
+ <FieldDescription>We'll never share your number.</FieldDescription>
372
+ <FieldError>{phoneError}</FieldError>
373
+ </Field>
315
374
 
316
- // Correct — either guard the mount or pass the errors array prop
317
- {emailError && <FieldError>{emailError}</FieldError>}
318
- // or
319
- <FieldError errors={[{ message: emailError }]} />
375
+ // Correct — data-invalid on the Field hides the contextual description so the error takes its slot
376
+ <Field data-invalid={!!phoneError || undefined}>
377
+ <FieldLabel htmlFor="phone">Phone</FieldLabel>
378
+ <Input id="phone" aria-invalid={!!phoneError} />
379
+ <FieldDescription>We'll never share your number.</FieldDescription>
380
+ <FieldError>{phoneError}</FieldError>
381
+ </Field>
320
382
  ```
321
383
 
322
- When `children` is falsy and `errors` is empty or undefined, `FieldError` returns `null` on its own when you use the `errors` prop. But when using `children`, you must guard the mount yourself — an undefined/empty string child still causes a `<div role="alert">` to be inserted into the DOM, which screen readers may announce unexpectedly.
384
+ The hide is pure CSS (`group-data-[invalid=true]/field:hidden`) and only applies to `variant="contextual"` (the default). `variant="instructional"` descriptions (under the label) stay visible with the error. `@aircall/blocks` `Form*Field` sets `data-invalid` for you; raw ds consumers must set it. `FieldError` itself returns `null` when it has no `children` and no `errors`, so it needs no conditional mount.
323
385
 
324
- Source: `packages/ds/src/components/field.tsx` — `FieldError` only short-circuits to `null` via `useMemo` when `!children && !errors?.length`.
386
+ Source: `packages/ds/src/components/field.tsx` — `FieldDescription` (`variant === 'contextual' && 'group-data-[invalid=true]/field:hidden'`) and `FieldError` (`if (!content) return null`).
@@ -11,6 +11,9 @@ requires:
11
11
  - aircall-ds/migrate-tractor
12
12
  sources:
13
13
  - "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/gauge.md"
14
+ - "aircall/hydra:packages/ds/src/components/gauge.tsx"
15
+ - "aircall/hydra:packages/ds/src/hooks/use-audio-gauge.ts"
16
+ - "aircall/hydra:packages/ds/src/stories/Gauge.stories.tsx"
14
17
  ---
15
18
 
16
19
  This skill builds on aircall-ds/migrate-tractor.
@@ -26,9 +29,8 @@ This skill builds on aircall-ds/migrate-tractor.
26
29
  ## 2. Verified DS exports (`packages/ds/src/index.ts`)
27
30
 
28
31
  ```ts
29
- // line 223
32
+ // packages/ds/src/index.ts
30
33
  export { Gauge } from './components/gauge';
31
- // line 358
32
34
  export * from './hooks/use-audio-gauge'; // exports: useAudioGauge, UseAudioGaugeOptions, UseAudioGaugeResult
33
35
  ```
34
36
 
@@ -64,9 +66,9 @@ Tractor's `value` mapped directly to "this many segments filled" out of a config
64
66
  If your code was computing a raw segment count from a `[0, 1]` level signal, multiply by 8 instead:
65
67
 
66
68
  ```tsx
67
- // Before — mapped to 16 segments with gauges=16
69
+ // Before — mapped a 0–1 level to 16 segments with gauges=16
68
70
  const value = Math.trunc(level * 16);
69
- <Gauge value={value} />
71
+ <Gauge value={value} gauges={16} />
70
72
 
71
73
  // After — DS gauge is always 8 segments; apply ×2 gain to preserve speech sensitivity
72
74
  const value = Math.round(level * 8 * 2);