@aircall/ds 0.18.0 → 0.21.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.
@@ -0,0 +1,438 @@
1
+ ---
2
+ name: aircall-ds/migrate-audio-player
3
+ description: >
4
+ Migrate audio-player code to @aircall/ds Audio primitives. Load when a file
5
+ imports from @aircall/tractor (Audio, QuickAudioPlayer, PlayButton, AudioBar,
6
+ AudioCurrentTime, AudioDuration, AudioManager, useAudio) or contains a custom
7
+ AudioPlayerProvider. Covers the component map, hook rename table, when to use
8
+ AudioPlayerManager, before/after for tractor patterns, and DS recipe examples
9
+ for custom implementations.
10
+ type: sub-skill
11
+ library: aircall-ds
12
+ library_version: "0.16.0"
13
+ requires:
14
+ - aircall-ds/setup
15
+ sources:
16
+ - "aircall/hydra:packages/ds/src/components/audio-player.tsx"
17
+ - "aircall/hydra:specs/audio-player.spec.md"
18
+ ---
19
+
20
+ # Migrating to @aircall/ds AudioPlayer
21
+
22
+ ## 1. Import
23
+
24
+ ```tsx
25
+ import {
26
+ Audio,
27
+ AudioPlayerManager,
28
+ AudioPlayerRow,
29
+ AudioPlayerButton,
30
+ AudioPlayerBar,
31
+ AudioPlayerCurrentTime,
32
+ AudioPlayerTime,
33
+ AudioPlayerDuration,
34
+ AudioPlayerSpeed,
35
+ AudioPlayerSkip,
36
+ useAudioPlayer,
37
+ useAudioPlayerTime,
38
+ } from '@aircall/ds';
39
+ ```
40
+
41
+ Never import sub-paths (`@aircall/ds/components/audio-player`) — use the root barrel.
42
+
43
+ ---
44
+
45
+ ## 2. When to use `AudioPlayerManager`
46
+
47
+ `<AudioPlayerManager>` is **optional**. Only add it when you have multiple independent
48
+ `<Audio>` players on the same page and need them to pause each other automatically when
49
+ a new one starts playing.
50
+
51
+ | Situation | What to use |
52
+ |---|---|
53
+ | Single player on the page | `<Audio src>` alone — no manager needed |
54
+ | Multiple players, each plays independently | `<Audio src>` alone — no manager needed |
55
+ | Multiple players, playing one should pause the others | Wrap all in `<AudioPlayerManager>` |
56
+
57
+ ```tsx
58
+ // Single player — no manager needed
59
+ <Audio src={url}>
60
+ <AudioPlayerRow>
61
+ <AudioPlayerButton />
62
+ <AudioPlayerBar />
63
+ <AudioPlayerTime />
64
+ </AudioPlayerRow>
65
+ </Audio>
66
+
67
+ // Multiple players that coordinate
68
+ <AudioPlayerManager>
69
+ <Audio src={url1}>…</Audio>
70
+ <Audio src={url2}>…</Audio>
71
+ <Audio src={url3}>…</Audio>
72
+ </AudioPlayerManager>
73
+ ```
74
+
75
+ The manager hooks in transparently — no changes to the `<Audio>` children or
76
+ `useAudioPlayer()` calls are required.
77
+
78
+ ---
79
+
80
+ ## 3. Component map
81
+
82
+ | Tractor / custom | DS replacement | Notes |
83
+ |---|---|---|
84
+ | `<QuickAudioPlayer src>` | `<Audio src><AudioPlayerRow>…</AudioPlayerRow></Audio>` | Drop-in; see §4.1 for layout note |
85
+ | `<Audio src>` | `<Audio src>` | Same name; drop `initialDuration` |
86
+ | `<PlayButton>` | `<AudioPlayerButton>` | No props — `src` flows from `<Audio>` |
87
+ | `<PlayButton color="green">` | `<AudioPlayerButton>` (default) | Green filled 32 px button |
88
+ | `<PlayButton color="default" mode="icon">` | `<AudioPlayerButton variant="ghost">` | Secondary transparent 24 px button |
89
+ | `<AudioBar>` | `<AudioPlayerBar>` | Inside `<AudioPlayerRow>`, `flex-1` is automatic |
90
+ | `<AudioCurrentTime>` | `<AudioPlayerCurrentTime>` | Always shows elapsed position |
91
+ | `<AudioDuration>` | `<AudioPlayerDuration>` | Always shows total duration |
92
+ | custom speed button using `setSpeed()` | `<AudioPlayerSpeed>` | Cycling button; `speeds` prop to customise |
93
+ | custom skip using `seek()` | `<AudioPlayerSkip offset={±N}>` | `N` in seconds |
94
+ | `<AudioManager>` | `<AudioPlayerManager>` | See §2 for when it's needed |
95
+ | `useAudio()` | `useAudioPlayer()` | See hook table in §4 |
96
+ | `useAudioManager()` | _(removed)_ | Manager is fully transparent — no consumer hook |
97
+ | `<Flex>` / `<Grid>` layout wrappers | `<AudioPlayerRow>` or plain `<div>` with Tailwind | Drop styled-components layout primitives |
98
+
99
+ ---
100
+
101
+ ## 4. Hook rename table
102
+
103
+ | Tractor `useAudio()` | DS `useAudioPlayer()` | Notes |
104
+ |---|---|---|
105
+ | `isPlaying` | `isPlaying` | identical |
106
+ | `togglePlay()` | `toggle()` | renamed |
107
+ | `pause()` | `pause()` | identical |
108
+ | `rewind()` / `fastForward()` | `<AudioPlayerSkip offset={±N} />` | now a component, not a hook call |
109
+ | `speed` | `playbackRate` | renamed |
110
+ | `setSpeed(n)` | `setPlaybackRate(n)` | renamed |
111
+ | `duration` | `duration` | identical (`null` until metadata loads) |
112
+ | `currentTime` | `useAudioPlayerTime()` | separate hook — RAF-driven, avoids re-rendering every frame |
113
+ | `error` | `error` | identical (`MediaError \| null`) |
114
+ | `seek(s)` | `seek(s)` | identical |
115
+ | `audioRef` | `audioRef` | identical — escape hatch for `setSinkId` etc. |
116
+ | _(not in tractor)_ | `isBuffering` | new in DS |
117
+ | _(not in tractor)_ | `isEnded` | new in DS |
118
+ | _(not in tractor)_ | `isItemActive(src)` | new in DS — for multi-item layouts |
119
+
120
+ ---
121
+
122
+ ## Part 1 — Tractor migrations (before → after)
123
+
124
+ ### 1.1 QuickAudioPlayer
125
+
126
+ `QuickAudioPlayer` is a tractor preset: play button on the left, current time + duration
127
+ above the bar on the right. The DS uses an **inline row** layout (everything in one line)
128
+ which is the Figma-faithful pattern — the stacked layout is not reproduced.
129
+
130
+ **Before (tractor):**
131
+ ```tsx
132
+ import { AudioManager } from '@aircall/tractor';
133
+ import { QuickAudioPlayer } from '@aircall/tractor';
134
+
135
+ <AudioManager>
136
+ <QuickAudioPlayer src={url} />
137
+ </AudioManager>
138
+ ```
139
+
140
+ **After (DS):**
141
+ ```tsx
142
+ import { Audio, AudioPlayerManager, AudioPlayerRow, AudioPlayerButton, AudioPlayerBar, AudioPlayerTime } from '@aircall/ds';
143
+
144
+ <AudioPlayerManager>
145
+ <Audio src={url}>
146
+ <AudioPlayerRow>
147
+ <AudioPlayerButton />
148
+ <AudioPlayerBar />
149
+ <AudioPlayerTime />
150
+ </AudioPlayerRow>
151
+ </Audio>
152
+ </AudioPlayerManager>
153
+ ```
154
+
155
+ > **Layout note:** `QuickAudioPlayer` stacked `AudioCurrentTime / AudioDuration` above
156
+ > `AudioBar`. The DS row puts everything inline. If your design requires the stacked
157
+ > layout, use the recipe in Part 2.
158
+
159
+ ---
160
+
161
+ ### 1.2 Standard row (play + bar + time)
162
+
163
+ **Before (tractor):**
164
+ ```tsx
165
+ import { Audio, AudioManager, Grid, PlayButton, AudioBar, AudioCurrentTime } from '@aircall/tractor';
166
+
167
+ <AudioManager>
168
+ <Audio src={url}>
169
+ <Grid w="100%" gridTemplateColumns="auto 1fr auto" columnGap="8px" alignItems="center">
170
+ <PlayButton color="green" />
171
+ <AudioBar />
172
+ <AudioCurrentTime />
173
+ </Grid>
174
+ </Audio>
175
+ </AudioManager>
176
+ ```
177
+
178
+ **After (DS):**
179
+ ```tsx
180
+ import { Audio, AudioPlayerManager, AudioPlayerRow, AudioPlayerButton, AudioPlayerBar, AudioPlayerTime } from '@aircall/ds';
181
+
182
+ <AudioPlayerManager>
183
+ <Audio src={url}>
184
+ <AudioPlayerRow>
185
+ <AudioPlayerButton />
186
+ <AudioPlayerBar />
187
+ <AudioPlayerTime />
188
+ </AudioPlayerRow>
189
+ </Audio>
190
+ </AudioPlayerManager>
191
+ ```
192
+
193
+ Changes:
194
+ - Drop `initialDuration` — DS loads metadata automatically via `preload="metadata"`.
195
+ - `<Grid gridTemplateColumns="auto 1fr auto">` → `<AudioPlayerRow>` — `flex-1` on the bar is automatic.
196
+ - `<AudioCurrentTime>` → `<AudioPlayerTime>` — smart: shows duration while paused, elapsed while playing.
197
+
198
+ ---
199
+
200
+ ### 1.3 Ghost / compact row (no bar)
201
+
202
+ **Before (tractor):**
203
+ ```tsx
204
+ import { Audio, AudioManager, Flex, PlayButton, AudioCurrentTime } from '@aircall/tractor';
205
+
206
+ <AudioManager>
207
+ <Audio src={url}>
208
+ <Flex alignItems="center" gap="8px">
209
+ <PlayButton color="default" mode="icon" />
210
+ <AudioCurrentTime />
211
+ </Flex>
212
+ </Audio>
213
+ </AudioManager>
214
+ ```
215
+
216
+ **After (DS):**
217
+ ```tsx
218
+ import { Audio, AudioPlayerManager, AudioPlayerRow, AudioPlayerButton, AudioPlayerTime } from '@aircall/ds';
219
+
220
+ <AudioPlayerManager>
221
+ <Audio src={url}>
222
+ <AudioPlayerRow variant="ghost">
223
+ <AudioPlayerButton />
224
+ <AudioPlayerTime />
225
+ </AudioPlayerRow>
226
+ </Audio>
227
+ </AudioPlayerManager>
228
+ ```
229
+
230
+ Changes:
231
+ - `variant="ghost"` on `<AudioPlayerRow>` cascades to `<AudioPlayerButton>` (24 px transparent) — no per-component `color` or `mode` props.
232
+
233
+ ---
234
+
235
+ ### 1.4 Row with elapsed + total duration
236
+
237
+ **Before (tractor):**
238
+ ```tsx
239
+ import { Audio, AudioManager, Flex, Grid, PlayButton, AudioBar, AudioCurrentTime, AudioDuration } from '@aircall/tractor';
240
+
241
+ <AudioManager>
242
+ <Audio src={url}>
243
+ <Flex alignItems="center">
244
+ <PlayButton />
245
+ <Grid gridTemplateColumns="auto 1fr auto" columnGap="24px" alignItems="center" w="100%">
246
+ <AudioCurrentTime />
247
+ <AudioBar />
248
+ <AudioDuration />
249
+ </Grid>
250
+ </Flex>
251
+ </Audio>
252
+ </AudioManager>
253
+ ```
254
+
255
+ **After (DS):**
256
+ ```tsx
257
+ import { Audio, AudioPlayerManager, AudioPlayerRow, AudioPlayerButton, AudioPlayerBar, AudioPlayerTime } from '@aircall/ds';
258
+
259
+ <AudioPlayerManager>
260
+ <Audio src={url}>
261
+ <AudioPlayerRow>
262
+ <AudioPlayerButton />
263
+ <AudioPlayerBar />
264
+ <AudioPlayerTime mode="full" />
265
+ </AudioPlayerRow>
266
+ </Audio>
267
+ </AudioPlayerManager>
268
+ ```
269
+
270
+ Changes:
271
+ - `<AudioPlayerTime mode="full">` renders `current / total` with a separator internally — no manual `<span>/</span>` needed.
272
+
273
+ ---
274
+
275
+ ### 1.5 Multi-player coordination
276
+
277
+ **Before (tractor):**
278
+ ```tsx
279
+ import { AudioManager, useAudioManager } from '@aircall/tractor';
280
+
281
+ function Player({ src }) {
282
+ const audioRef = useRef(new Audio(src));
283
+ const { play, unregister } = useAudioManager();
284
+
285
+ useEffect(() => {
286
+ const audio = audioRef.current;
287
+ audio.addEventListener('pause', () => setIsPlaying(false));
288
+ return () => unregister(audio);
289
+ }, []);
290
+
291
+ return (
292
+ <button onClick={() => play(audioRef.current)}>…</button>
293
+ );
294
+ }
295
+
296
+ <AudioManager>
297
+ <Player src="https://..." />
298
+ <Player src="https://..." />
299
+ </AudioManager>
300
+ ```
301
+
302
+ **After (DS):**
303
+ ```tsx
304
+ import { AudioPlayerManager, Audio, AudioPlayerRow, AudioPlayerButton, AudioPlayerBar, AudioPlayerTime } from '@aircall/ds';
305
+
306
+ <AudioPlayerManager>
307
+ {tracks.map(track => (
308
+ <Audio key={track.src} src={track.src}>
309
+ <AudioPlayerRow>
310
+ <AudioPlayerButton />
311
+ <AudioPlayerBar />
312
+ <AudioPlayerTime />
313
+ </AudioPlayerRow>
314
+ </Audio>
315
+ ))}
316
+ </AudioPlayerManager>
317
+ ```
318
+
319
+ Changes:
320
+ - `useAudioManager()` is gone — `AudioPlayerManager` hooks into each `Audio` internally.
321
+ - No manual `unregister` on unmount — `Audio` handles it.
322
+
323
+ ---
324
+
325
+ ## Part 2 — DS recipes for custom implementations
326
+
327
+ Use these patterns when replacing a hand-rolled audio player (custom hooks, manual
328
+ `<audio>` elements, custom progress bars). Pick the recipe that matches your layout need.
329
+
330
+ ---
331
+
332
+ ### 2.1 Simple player row
333
+
334
+ Button + seek bar + smart time. The standard layout.
335
+
336
+ ```tsx
337
+ <Audio src={url}>
338
+ <AudioPlayerRow>
339
+ <AudioPlayerButton />
340
+ <AudioPlayerBar />
341
+ <AudioPlayerTime />
342
+ </AudioPlayerRow>
343
+ </Audio>
344
+ ```
345
+
346
+ ---
347
+
348
+ ### 2.2 Compact player (no bar)
349
+
350
+ Button + time only. Use `variant="ghost"` for the smaller 24 px button.
351
+
352
+ ```tsx
353
+ <Audio src={url}>
354
+ <AudioPlayerRow variant="ghost">
355
+ <AudioPlayerButton />
356
+ <AudioPlayerTime />
357
+ </AudioPlayerRow>
358
+ </Audio>
359
+ ```
360
+
361
+ ---
362
+
363
+ ### 2.3 Full row with elapsed + total
364
+
365
+ Shows `current / total` at all times (e.g. `1:23 / 3:45`).
366
+
367
+ ```tsx
368
+ <Audio src={url}>
369
+ <AudioPlayerRow>
370
+ <AudioPlayerButton />
371
+ <AudioPlayerBar />
372
+ <AudioPlayerTime mode="full" />
373
+ </AudioPlayerRow>
374
+ </Audio>
375
+ ```
376
+
377
+ ---
378
+
379
+ ### 2.4 Row with skip controls
380
+
381
+ Bar above, controls row below with skip buttons and speed.
382
+
383
+ ```tsx
384
+ <Audio src={url}>
385
+ <AudioPlayerBar />
386
+ <div className="mt-2 flex items-center gap-1.5">
387
+ <AudioPlayerButton />
388
+ <AudioPlayerSkip offset={-10} />
389
+ <AudioPlayerSkip offset={10} />
390
+ <AudioPlayerSpeed />
391
+ <AudioPlayerTime mode="full" className="ml-auto" />
392
+ </div>
393
+ </Audio>
394
+ ```
395
+
396
+ ---
397
+
398
+ ### 2.5 Multiple independent players with auto-pause
399
+
400
+ Each player is self-contained. `AudioPlayerManager` ensures only one plays at a time.
401
+
402
+ ```tsx
403
+ <AudioPlayerManager>
404
+ {tracks.map(track => (
405
+ <Audio key={track.src} src={track.src}>
406
+ <AudioPlayerRow>
407
+ <AudioPlayerButton />
408
+ <AudioPlayerBar />
409
+ <AudioPlayerTime />
410
+ </AudioPlayerRow>
411
+ </Audio>
412
+ ))}
413
+ </AudioPlayerManager>
414
+ ```
415
+
416
+ ---
417
+
418
+ ## 5. Prop drops
419
+
420
+ | Tractor prop | Action |
421
+ |---|---|
422
+ | `initialDuration` on `<Audio>` / `<QuickAudioPlayer>` | Drop — DS loads metadata via `preload="metadata"` |
423
+ | `color` on `<PlayButton>` | Map: `color="green"` → default, `color="default" mode="icon"` → `variant="ghost"`, `color="yellow"` → no direct equivalent (use `className`) |
424
+ | `mode` on `<PlayButton>` | Drop — `<AudioPlayerButton>` is always icon-only |
425
+ | `className="flex-1"` on `<AudioBar>` inside `<AudioPlayerRow>` | Drop — automatic via `[data-slot]` selector |
426
+ | `<Flex>` / `<Grid>` layout props | Replace with `<AudioPlayerRow>` or a plain `<div className="flex …">` |
427
+
428
+ ---
429
+
430
+ ## 6. `AudioPlayerTime` display modes
431
+
432
+ | Situation | Component | Behaviour |
433
+ |---|---|---|
434
+ | Compact row, single value | `<AudioPlayerTime />` | Smart: shows total duration before first play; switches to current position once playback starts (including while paused mid-track) |
435
+ | Always current position | `<AudioPlayerCurrentTime />` | Dumb: always elapsed |
436
+ | Always total duration | `<AudioPlayerDuration />` | Dumb: always total |
437
+ | Both side-by-side (`1:23 / 3:45`) | `<AudioPlayerTime mode="full" />` | Renders `current / total` with separator internally |
438
+ | Explicit primitives with custom layout | `<AudioPlayerCurrentTime /> / <AudioPlayerDuration />` | Use when you need a custom separator style or gap |
@@ -235,7 +235,7 @@ Then load the listed recipe skill (if `available`) for the detailed swap.
235
235
  | --- | --- | --- | --- |
236
236
  | `Accordion` (+ `AccordionSection`) | `Accordion` + `AccordionItem` + `AccordionTrigger` + `AccordionContent` | `@aircall/ds#aircall-ds/migrate-tractor/accordion` | available |
237
237
  | `ActionMenu` | `DropdownMenu` (compound) | `@aircall/ds#aircall-ds/migrate-tractor/dropdown-menu` | available |
238
- | `AudioPlayer` | — (no DS equivalent yet) | — | not-yet |
238
+ | `Audio` / `AudioPlayer` / `AudioManager` / `useAudio` | `Audio` + `AudioPlayerRow` + `AudioPlayerButton` + `AudioPlayerBar` + `AudioPlayerTime` + `AudioPlayerSpeed` + `AudioPlayerSkip` + `AudioPlayerManager` | `@aircall/ds#aircall-ds/migrate-audio-player` | available |
239
239
  | `Avatar` (+ `QuickAvatar`) | `Avatar` + `AvatarImage` + `AvatarFallback` | `@aircall/ds#aircall-ds/migrate-tractor/avatar` | available |
240
240
  | `Badge` | `AvatarBadge` (status dot on avatar); `Badge` (label/tag style) | `@aircall/ds#aircall-ds/migrate-tractor/badge` | available |
241
241
  | `Banner` (+ `BannerHeading`/`BannerIcon`/`BannerSuffix`) | `Alert` (rounded card) / `Banner` (inline full-width) | `@aircall/ds#aircall-ds/migrate-tractor/alert` | available |
@@ -43,8 +43,9 @@ There is no sub-component API (no `<TableColumn>`) — everything is declared in
43
43
  | `footer` | column-level `ColumnDef.footer` (auto-renders `<tfoot>`) |
44
44
  | _(no equivalent)_ | `loadingState="sorting"` / `"filtering"` (overlay spinner) |
45
45
  | _(no equivalent)_ | `loadingState="loadingMore"` (infinite scroll spinner row) |
46
- | _(no equivalent)_ | `onFetchMore` + `hasMore` (IntersectionObserver sentinel) |
46
+ | _(no equivalent)_ | `onFetchMore` + `hasMore` (IntersectionObserver sentinel for infinite scroll) |
47
47
  | _(no equivalent)_ | `fillHeight` (sticky header, internal scroll) |
48
+ | _(no equivalent)_ | `virtualizeRows` (explicit row virtualization — requires `fillHeight`) |
48
49
 
49
50
  ## 3. Verified DS exports (`packages/ds/src/index.ts`)
50
51
 
@@ -331,3 +332,48 @@ import { Empty, EmptyContent, EmptyTitle, EmptyDescription } from '@aircall/ds';
331
332
  Tractor `noDataMessage` accepted a `ReactNode` but was declared as a simple prop. DS requires an `emptyState` prop; `noDataMessage` is silently ignored. For plain text, wrap it in a `<p>` with `text-sm text-muted-foreground`. For a full empty state with an icon and a call-to-action, use the `Empty` compound from `@aircall/ds`.
332
333
 
333
334
  Source: `packages/ds/src/components/data-table.tsx`
335
+
336
+ ## 8. Infinite scroll and row virtualization
337
+
338
+ `DataTable` supports infinite scroll via `onFetchMore` + `hasMore` (IntersectionObserver sentinel). Row virtualization is a **separate, explicit opt-in** via the `virtualizeRows` prop — the consumer decides when to enable it.
339
+
340
+ `virtualizeRows` **requires `fillHeight={true}`** — the container must scroll internally so the virtualizer can track `scrollTop`. Without `fillHeight` the page scrolls instead, `scrollTop` stays 0, and the virtual window never updates.
341
+
342
+ Use `virtualizeRows` on any table with 1 000+ rows: infinite-scroll tables that accumulate pages, or static datasets loaded all at once.
343
+
344
+ ```tsx
345
+ // Infinite scroll with virtualization
346
+ function CallsTable() {
347
+ const [items, setItems] = React.useState<Call[]>(() => fetchPage(0));
348
+ const [isFetchingMore, setIsFetchingMore] = React.useState(false);
349
+ const hasMore = items.length < totalCount;
350
+
351
+ const onFetchMore = React.useCallback(() => {
352
+ if (isFetchingMore || !hasMore) return;
353
+ setIsFetchingMore(true);
354
+ fetchPage(items.length).then(page => {
355
+ setItems(prev => [...prev, ...page]);
356
+ setIsFetchingMore(false);
357
+ });
358
+ }, [isFetchingMore, hasMore, items.length]);
359
+
360
+ return (
361
+ <div className="flex h-dvh flex-col p-4">
362
+ <DataTable
363
+ columns={columns} // each column must have a size when virtualizing
364
+ data={items}
365
+ getRowId={row => row.id}
366
+ fillHeight
367
+ virtualizeRows
368
+ onFetchMore={onFetchMore}
369
+ hasMore={hasMore}
370
+ loadingState={isFetchingMore ? 'loadingMore' : 'idle'}
371
+ />
372
+ </div>
373
+ );
374
+ }
375
+ ```
376
+
377
+ **Pagination does not need virtualization.** With pagination you replace `data` on each page change — the row count stays constant. Do not pass `onFetchMore`; use an external `<Pagination>` component instead.
378
+
379
+ Source: `packages/ds/src/components/data-table.tsx`
@@ -336,3 +336,36 @@ Source: `packages/ds/src/components/dropzone.tsx`
336
336
  `<DropzoneContent error>` only toggles the destructive border — it does not render an error message. The accessible error text belongs in `<FieldError>` outside the dropzone, associated via `<Field data-invalid>`.
337
337
 
338
338
  Source: `packages/ds/src/components/dropzone.tsx`
339
+
340
+ ## 6. Testing (jsdom)
341
+
342
+ `<Dropzone>` renders a **real `<input type="file">`** and reacts to that input's
343
+ `change` event — so tests drive the input, not a synthetic `drop` on a wrapper.
344
+ This is the part most migrations get wrong: legacy wrappers were tested with
345
+ `fireEvent.drop(...)` reading `dataTransfer`/`event.target.files`, which the DS
346
+ Dropzone ignores. Migrate those assertions:
347
+
348
+ | Legacy test | DS test |
349
+ | --- | --- |
350
+ | `fireEvent.drop(el)` with a stubbed `files` | `userEvent.upload(input, file)` (an accepted file) |
351
+ | dropping an invalid file to hit the reject path | set `input.files` + `fireEvent.change(input)` to **bypass the `accept` filter** |
352
+ | `getByTestId('…-input')` on a wrapper's input | `document.querySelector('input[type="file"]')` (the DS input has no test id) |
353
+
354
+ ```tsx
355
+ const input = document.querySelector('input[type="file"]') as HTMLInputElement;
356
+
357
+ // accepted → onFiles
358
+ await userEvent.upload(input, new File(['phone\n+3361'], 'leads.csv', { type: 'text/csv' }));
359
+
360
+ // rejected → onError (userEvent.upload enforces `accept`, so bypass it)
361
+ Object.defineProperty(input, 'files', { configurable: true, value: [badFile] });
362
+ fireEvent.change(input);
363
+ ```
364
+
365
+ On change the component runs `validateFiles`, then fires `onFiles(accepted)` and/or
366
+ `onError(rejections)` (a mixed batch fires **both**). Assert on those callbacks —
367
+ not on internal DOM. There is no "no test-hookable input" limitation; a wrapper
368
+ that keeps `@dashboard/library` "because tests need `fireEvent.drop`" can be fully
369
+ migrated by moving its tests to the input.
370
+
371
+ Source: `packages/ds/src/components/dropzone.tsx`