@charcuterie/ui 4.27.3 → 4.28.1

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 (120) hide show
  1. package/dist/Accordion/AccordionSection.d.ts.map +1 -1
  2. package/dist/Accordion/AccordionSection.js +43 -4
  3. package/dist/Accordion/AccordionSection.js.map +1 -1
  4. package/dist/Combobox/Combobox.d.ts.map +1 -1
  5. package/dist/Combobox/Combobox.js +3 -3
  6. package/dist/Combobox/Combobox.js.map +1 -1
  7. package/dist/DatePicker/DatePicker.d.ts.map +1 -1
  8. package/dist/DatePicker/DatePicker.js +3 -3
  9. package/dist/DatePicker/DatePicker.js.map +1 -1
  10. package/dist/Dialog/Dialog.d.ts +7 -1
  11. package/dist/Dialog/Dialog.d.ts.map +1 -1
  12. package/dist/Dialog/Dialog.js +2 -2
  13. package/dist/Dialog/Dialog.js.map +1 -1
  14. package/dist/GroupedList/GroupedList.d.ts +9 -2
  15. package/dist/GroupedList/GroupedList.d.ts.map +1 -1
  16. package/dist/GroupedList/GroupedList.js +39 -5
  17. package/dist/GroupedList/GroupedList.js.map +1 -1
  18. package/dist/GroupedList/GroupedListRow.d.ts +4 -1
  19. package/dist/GroupedList/GroupedListRow.d.ts.map +1 -1
  20. package/dist/GroupedList/GroupedListRow.js +3 -3
  21. package/dist/GroupedList/GroupedListRow.js.map +1 -1
  22. package/dist/GroupedList/GroupedListRows.d.ts +16 -0
  23. package/dist/GroupedList/GroupedListRows.d.ts.map +1 -0
  24. package/dist/GroupedList/GroupedListRows.js +17 -0
  25. package/dist/GroupedList/GroupedListRows.js.map +1 -0
  26. package/dist/Listbox/Listbox.d.ts.map +1 -1
  27. package/dist/Listbox/Listbox.js +6 -4
  28. package/dist/Listbox/Listbox.js.map +1 -1
  29. package/dist/Menu/Menu.d.ts.map +1 -1
  30. package/dist/Menu/Menu.js +6 -4
  31. package/dist/Menu/Menu.js.map +1 -1
  32. package/dist/Modal/Modal.d.ts +7 -1
  33. package/dist/Modal/Modal.d.ts.map +1 -1
  34. package/dist/Modal/Modal.js +1 -1
  35. package/dist/Modal/Modal.js.map +1 -1
  36. package/dist/Motion/useLastPresentValue.d.ts +21 -0
  37. package/dist/Motion/useLastPresentValue.d.ts.map +1 -0
  38. package/dist/Motion/useLastPresentValue.js +30 -0
  39. package/dist/Motion/useLastPresentValue.js.map +1 -0
  40. package/dist/Motion/useListMotion.d.ts +111 -0
  41. package/dist/Motion/useListMotion.d.ts.map +1 -0
  42. package/dist/Motion/useListMotion.js +358 -0
  43. package/dist/Motion/useListMotion.js.map +1 -0
  44. package/dist/Motion/usePresence.d.ts +81 -0
  45. package/dist/Motion/usePresence.d.ts.map +1 -0
  46. package/dist/Motion/usePresence.js +131 -0
  47. package/dist/Motion/usePresence.js.map +1 -0
  48. package/dist/Motion/useValueChangeMotion.d.ts +52 -0
  49. package/dist/Motion/useValueChangeMotion.d.ts.map +1 -0
  50. package/dist/Motion/useValueChangeMotion.js +87 -0
  51. package/dist/Motion/useValueChangeMotion.js.map +1 -0
  52. package/dist/Overlay/OverlayPanel.d.ts +18 -1
  53. package/dist/Overlay/OverlayPanel.d.ts.map +1 -1
  54. package/dist/Overlay/OverlayPanel.js +83 -11
  55. package/dist/Overlay/OverlayPanel.js.map +1 -1
  56. package/dist/Overlay/SharedBackdrop.d.ts +3 -0
  57. package/dist/Overlay/SharedBackdrop.d.ts.map +1 -1
  58. package/dist/Overlay/SharedBackdrop.js +8 -2
  59. package/dist/Overlay/SharedBackdrop.js.map +1 -1
  60. package/dist/Overlay/focusHistory.d.ts +16 -0
  61. package/dist/Overlay/focusHistory.d.ts.map +1 -0
  62. package/dist/Overlay/focusHistory.js +110 -0
  63. package/dist/Overlay/focusHistory.js.map +1 -0
  64. package/dist/Overlay/useAnchoredOverlay.d.ts +17 -3
  65. package/dist/Overlay/useAnchoredOverlay.d.ts.map +1 -1
  66. package/dist/Overlay/useAnchoredOverlay.js +23 -5
  67. package/dist/Overlay/useAnchoredOverlay.js.map +1 -1
  68. package/dist/Popover/Popover.d.ts.map +1 -1
  69. package/dist/Popover/Popover.js +4 -2
  70. package/dist/Popover/Popover.js.map +1 -1
  71. package/dist/ReorderList/ReorderList.d.ts +6 -0
  72. package/dist/ReorderList/ReorderList.d.ts.map +1 -1
  73. package/dist/ReorderList/ReorderList.js +23 -6
  74. package/dist/ReorderList/ReorderList.js.map +1 -1
  75. package/dist/TableViewport/TableViewport.d.ts.map +1 -1
  76. package/dist/TableViewport/TableViewport.js +9 -1
  77. package/dist/TableViewport/TableViewport.js.map +1 -1
  78. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  79. package/dist/Tooltip/Tooltip.js +16 -13
  80. package/dist/Tooltip/Tooltip.js.map +1 -1
  81. package/dist/index.d.ts +22 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +12 -0
  84. package/dist/index.js.map +1 -1
  85. package/dist/styles.css +191 -1
  86. package/package.json +6 -6
  87. package/src/Accordion/AccordionSection.tsx +63 -4
  88. package/src/Combobox/Combobox.tsx +8 -2
  89. package/src/DatePicker/DatePicker.tsx +7 -1
  90. package/src/Dialog/Dialog.tsx +8 -0
  91. package/src/GroupedList/GroupedList.mdx +3 -2
  92. package/src/GroupedList/GroupedList.test.tsx +283 -0
  93. package/src/GroupedList/GroupedList.tsx +88 -44
  94. package/src/GroupedList/GroupedListRow.tsx +8 -0
  95. package/src/GroupedList/GroupedListRows.tsx +51 -0
  96. package/src/Listbox/Listbox.tsx +9 -1
  97. package/src/Menu/Menu.tsx +9 -1
  98. package/src/Modal/Modal.tsx +8 -0
  99. package/src/Motion/useLastPresentValue.test.tsx +66 -0
  100. package/src/Motion/useLastPresentValue.ts +38 -0
  101. package/src/Motion/useListMotion.test.tsx +527 -0
  102. package/src/Motion/useListMotion.ts +674 -0
  103. package/src/Motion/usePresence.test.tsx +223 -0
  104. package/src/Motion/usePresence.ts +252 -0
  105. package/src/Motion/useValueChangeMotion.test.tsx +131 -0
  106. package/src/Motion/useValueChangeMotion.ts +110 -0
  107. package/src/Overlay/OverlayPanel.server.test.ts +30 -0
  108. package/src/Overlay/OverlayPanel.tsx +146 -14
  109. package/src/Overlay/SharedBackdrop.tsx +17 -2
  110. package/src/Overlay/focusHistory.ts +152 -0
  111. package/src/Overlay/overlayReturnFocus.storyHelpers.tsx +242 -0
  112. package/src/Overlay/overlayReturnFocus.test.tsx +255 -0
  113. package/src/Overlay/useAnchoredOverlay.ts +56 -4
  114. package/src/Popover/Popover.tsx +9 -1
  115. package/src/ReorderList/ReorderList.test.tsx +76 -0
  116. package/src/ReorderList/ReorderList.tsx +86 -48
  117. package/src/TableViewport/TableViewport.tsx +4 -0
  118. package/src/Tooltip/Tooltip.tsx +32 -4
  119. package/src/index.ts +30 -0
  120. package/src/styles.css +191 -1
@@ -0,0 +1,527 @@
1
+ import type { ReactNode } from "react"
2
+ import { useState } from "react"
3
+ import type { Root } from "react-dom/client"
4
+ import { createRoot } from "react-dom/client"
5
+ import { expect, userEvent, waitFor } from "storybook/test"
6
+ import { afterEach, beforeEach, test } from "vitest"
7
+
8
+ import { useListMotion } from "./useListMotion.ts"
9
+
10
+ /**
11
+ * As in `usePresence.test.tsx`: these tests are about the motion, so
12
+ * they lift the suite's motion freeze for their own duration.
13
+ */
14
+ const FREEZE_ID = "charcuterie-freeze-motion"
15
+
16
+ let frozenStyle: HTMLElement | null = null
17
+
18
+ beforeEach(() => {
19
+ frozenStyle = document.getElementById(FREEZE_ID)
20
+ })
21
+
22
+ const mounted: { host: HTMLElement; root: Root }[] = []
23
+
24
+ afterEach(() => {
25
+ for (const { host, root } of mounted.splice(0)) {
26
+ root.unmount()
27
+
28
+ host.remove()
29
+ }
30
+
31
+ if (frozenStyle !== null && !frozenStyle.isConnected) {
32
+ document.head.append(frozenStyle)
33
+ }
34
+ })
35
+
36
+ /**
37
+ * Long enough that a loaded test host cannot finish an exit or a
38
+ * slide between two lines of a test. The tokens are inherited, so
39
+ * setting them on the host slows every motion inside it.
40
+ */
41
+ const SLOW_MOTION = "600ms"
42
+
43
+ const MOTION_TIMEOUT = { timeout: 5_000 }
44
+
45
+ const unfreeze = () => {
46
+ frozenStyle?.remove()
47
+ }
48
+
49
+ const List = ({
50
+ initial,
51
+ }: {
52
+ initial: string[]
53
+ }): ReactNode => {
54
+ const [names, setNames] = useState(initial)
55
+
56
+ const [isTall, setIsTall] = useState(false)
57
+
58
+ const { entries } = useListMotion({
59
+ getKey: (name: string) => name,
60
+ // A fresh array every render, as a caller that derives its list
61
+ // during render passes. The hook must compare keys, not identity,
62
+ // or its render-phase update loops forever.
63
+ items: names.map((name) => name),
64
+ })
65
+
66
+ return (
67
+ <div>
68
+ <button
69
+ onClick={() => {
70
+ setNames((previous) => [...previous, "Delta"])
71
+ }}
72
+ type="button"
73
+ >
74
+ Add
75
+ </button>
76
+
77
+ <button
78
+ onClick={() => {
79
+ setNames((previous) =>
80
+ previous.filter((name) => name !== "Alpha"),
81
+ )
82
+ }}
83
+ type="button"
84
+ >
85
+ Remove Alpha
86
+ </button>
87
+
88
+ <button
89
+ onClick={() => {
90
+ setNames((previous) => [...previous].reverse())
91
+ }}
92
+ type="button"
93
+ >
94
+ Reverse
95
+ </button>
96
+
97
+ <button
98
+ onClick={() => {
99
+ setIsTall(true)
100
+ }}
101
+ type="button"
102
+ >
103
+ Grow Alpha
104
+ </button>
105
+
106
+ <button
107
+ onClick={() => {
108
+ setNames((previous) => ["Newest", ...previous])
109
+ }}
110
+ type="button"
111
+ >
112
+ Add to front
113
+ </button>
114
+
115
+ <button
116
+ onClick={() => {
117
+ // A newest-first list capped at its length: one in at the
118
+ // top, the oldest out at the bottom.
119
+ setNames((previous) => [
120
+ "Newest",
121
+ ...previous.slice(0, -1),
122
+ ])
123
+ }}
124
+ type="button"
125
+ >
126
+ Add capped
127
+ </button>
128
+
129
+ <button
130
+ onClick={() => {
131
+ setNames((previous) =>
132
+ previous
133
+ .filter((name) => name !== "Beta")
134
+ .reverse(),
135
+ )
136
+ }}
137
+ type="button"
138
+ >
139
+ Remove Beta and reverse
140
+ </button>
141
+
142
+ {["Beta", "Gamma"].map((name) => (
143
+ <button
144
+ key={name}
145
+ onClick={() => {
146
+ setNames((previous) =>
147
+ previous.filter((one) => one !== name),
148
+ )
149
+ }}
150
+ type="button"
151
+ >
152
+ {`Remove ${name}`}
153
+ </button>
154
+ ))}
155
+
156
+ <ul className="m-0 list-none p-0">
157
+ {entries.map(({ item, key, motionProps }) => (
158
+ <li
159
+ key={key}
160
+ {...motionProps}
161
+ style={{
162
+ blockSize:
163
+ isTall && item === "Alpha"
164
+ ? "100px"
165
+ : "40px",
166
+ }}
167
+ >
168
+ {item}
169
+ </li>
170
+ ))}
171
+ </ul>
172
+ </div>
173
+ )
174
+ }
175
+
176
+ const mount = (node: ReactNode) => {
177
+ const host = document.createElement("div")
178
+
179
+ for (const token of [
180
+ "--duration-fast",
181
+ "--duration-normal",
182
+ "--duration-slow",
183
+ ]) {
184
+ host.style.setProperty(token, SLOW_MOTION)
185
+ }
186
+
187
+ document.body.append(host)
188
+
189
+ const root = createRoot(host)
190
+
191
+ root.render(node)
192
+
193
+ mounted.push({ host, root })
194
+
195
+ return host
196
+ }
197
+
198
+ const getButton = (host: HTMLElement, name: string) =>
199
+ [...host.querySelectorAll("button")].find(
200
+ (button) => button.textContent === name,
201
+ ) as HTMLButtonElement
202
+
203
+ const getItem = (host: HTMLElement, key: string) =>
204
+ host.querySelector<HTMLElement>(
205
+ `[data-motion-key="${key}"]`,
206
+ )
207
+
208
+ test("items on the first render do not animate; an added item enters", async () => {
209
+ unfreeze()
210
+
211
+ const host = mount(
212
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
213
+ )
214
+
215
+ await waitFor(() => {
216
+ expect(getItem(host, "Alpha")).not.toBeNull()
217
+ })
218
+
219
+ expect(getItem(host, "Alpha")?.className).toBe("")
220
+
221
+ await userEvent.click(getButton(host, "Add"))
222
+
223
+ await waitFor(() => {
224
+ expect(getItem(host, "Delta")).toHaveClass(
225
+ "charcuterie-item-enter",
226
+ )
227
+ })
228
+ })
229
+
230
+ test("a removed item stays, inert, at its index until its exit ends", async () => {
231
+ unfreeze()
232
+
233
+ const host = mount(
234
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
235
+ )
236
+
237
+ await waitFor(() => {
238
+ expect(getItem(host, "Alpha")).not.toBeNull()
239
+ })
240
+
241
+ const alpha = getItem(host, "Alpha") as HTMLElement
242
+
243
+ await userEvent.click(getButton(host, "Remove Alpha"))
244
+
245
+ expect(alpha).toHaveClass("charcuterie-item-exit")
246
+ expect(alpha).toHaveAttribute("inert")
247
+ expect(alpha).toHaveAttribute("aria-hidden", "true")
248
+ expect(host.querySelector("li")).toBe(alpha)
249
+
250
+ await waitFor(() => {
251
+ expect(alpha.isConnected).toBe(false)
252
+ }, MOTION_TIMEOUT)
253
+ })
254
+
255
+ test("with motion frozen, a removed item is gone in the same commit", async () => {
256
+ const host = mount(
257
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
258
+ )
259
+
260
+ await waitFor(() => {
261
+ expect(getItem(host, "Alpha")).not.toBeNull()
262
+ })
263
+
264
+ await userEvent.click(getButton(host, "Remove Alpha"))
265
+
266
+ expect(getItem(host, "Alpha")).toBeNull()
267
+ })
268
+
269
+ test("a reorder slides each moved item from where it was", async () => {
270
+ unfreeze()
271
+
272
+ const host = mount(
273
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
274
+ )
275
+
276
+ await waitFor(() => {
277
+ expect(getItem(host, "Alpha")).not.toBeNull()
278
+ })
279
+
280
+ await userEvent.click(getButton(host, "Reverse"))
281
+
282
+ const alpha = getItem(host, "Alpha") as HTMLElement
283
+
284
+ // The slide is a transition back to no offset, so mid-flight the
285
+ // element sits away from its laid-out place.
286
+ expect(alpha.style.transition).toContain("translate")
287
+
288
+ await waitFor(() => {
289
+ expect(alpha.style.transition).toBe("")
290
+ }, MOTION_TIMEOUT)
291
+ })
292
+
293
+ test("an added item loses its enter class when it has entered, so showing the list again does not replay it", async () => {
294
+ unfreeze()
295
+
296
+ const host = mount(
297
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
298
+ )
299
+
300
+ await waitFor(() => {
301
+ expect(getItem(host, "Alpha")).not.toBeNull()
302
+ })
303
+
304
+ await userEvent.click(getButton(host, "Add"))
305
+
306
+ const delta = await waitFor(() => {
307
+ const found = getItem(host, "Delta")
308
+
309
+ expect(found).toHaveClass("charcuterie-item-enter")
310
+
311
+ return found as HTMLElement
312
+ })
313
+
314
+ await waitFor(() => {
315
+ expect(delta).not.toHaveClass("charcuterie-item-enter")
316
+ }, MOTION_TIMEOUT)
317
+
318
+ // Hidden and shown again, with a style flush at each step, which is
319
+ // what restarts a CSS animation still named on the element.
320
+ host.hidden = true
321
+
322
+ delta.getBoundingClientRect()
323
+
324
+ host.hidden = false
325
+
326
+ delta.getBoundingClientRect()
327
+
328
+ expect(delta.getAnimations()).toHaveLength(0)
329
+ })
330
+
331
+ test("a row that changed size without a change of keys does not send the rows after it sliding on the next add", async () => {
332
+ unfreeze()
333
+
334
+ const host = mount(
335
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
336
+ )
337
+
338
+ await waitFor(() => {
339
+ expect(getItem(host, "Alpha")).not.toBeNull()
340
+ })
341
+
342
+ await userEvent.click(getButton(host, "Grow Alpha"))
343
+
344
+ await userEvent.click(getButton(host, "Add"))
345
+
346
+ await waitFor(() => {
347
+ expect(getItem(host, "Delta")).not.toBeNull()
348
+ })
349
+
350
+ // Delta was appended after them, so neither moved.
351
+ expect(getItem(host, "Beta")?.style.translate).toBe("")
352
+ expect(getItem(host, "Beta")?.style.transition).toBe("")
353
+ expect(getItem(host, "Gamma")?.style.transition).toBe("")
354
+ })
355
+
356
+ test("with motion frozen, a reorder leaves no inline transition behind", async () => {
357
+ const host = mount(
358
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
359
+ )
360
+
361
+ await waitFor(() => {
362
+ expect(getItem(host, "Alpha")).not.toBeNull()
363
+ })
364
+
365
+ await userEvent.click(getButton(host, "Reverse"))
366
+
367
+ expect(getItem(host, "Alpha")?.style.transition).toBe("")
368
+ expect(getItem(host, "Alpha")?.style.translate).toBe("")
369
+ })
370
+
371
+ const shownOrder = (host: HTMLElement) =>
372
+ [
373
+ ...host.querySelectorAll<HTMLElement>(
374
+ "[data-motion-key]",
375
+ ),
376
+ ].map((element) => element.dataset.motionKey)
377
+
378
+ test("a capped newest-first list keeps its leaving last item at the bottom", async () => {
379
+ unfreeze()
380
+
381
+ const host = mount(
382
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
383
+ )
384
+
385
+ await waitFor(() => {
386
+ expect(getItem(host, "Alpha")).not.toBeNull()
387
+ })
388
+
389
+ await userEvent.click(getButton(host, "Add capped"))
390
+
391
+ expect(shownOrder(host)).toEqual([
392
+ "Newest",
393
+ "Alpha",
394
+ "Beta",
395
+ "Gamma",
396
+ ])
397
+ expect(getItem(host, "Gamma")).toHaveClass(
398
+ "charcuterie-item-exit",
399
+ )
400
+ })
401
+
402
+ test("an item added in front while another leaves does not move the leaving one", async () => {
403
+ unfreeze()
404
+
405
+ const host = mount(
406
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
407
+ )
408
+
409
+ await waitFor(() => {
410
+ expect(getItem(host, "Alpha")).not.toBeNull()
411
+ })
412
+
413
+ await userEvent.click(getButton(host, "Remove Beta"))
414
+
415
+ await userEvent.click(getButton(host, "Add to front"))
416
+
417
+ expect(shownOrder(host)).toEqual([
418
+ "Newest",
419
+ "Alpha",
420
+ "Beta",
421
+ "Gamma",
422
+ ])
423
+ })
424
+
425
+ test("two items removed one after the other keep their order while they leave", async () => {
426
+ unfreeze()
427
+
428
+ const host = mount(
429
+ <List initial={["Alpha", "Beta", "Gamma", "Delta"]} />,
430
+ )
431
+
432
+ await waitFor(() => {
433
+ expect(getItem(host, "Alpha")).not.toBeNull()
434
+ })
435
+
436
+ await userEvent.click(getButton(host, "Remove Beta"))
437
+
438
+ await userEvent.click(getButton(host, "Remove Gamma"))
439
+
440
+ expect(shownOrder(host)).toEqual([
441
+ "Alpha",
442
+ "Beta",
443
+ "Gamma",
444
+ "Delta",
445
+ ])
446
+
447
+ await waitFor(() => {
448
+ expect(shownOrder(host)).toEqual(["Alpha", "Delta"])
449
+ }, MOTION_TIMEOUT)
450
+ })
451
+
452
+ test("a leaving item that a reorder moves slides from where it was, instead of jumping", async () => {
453
+ unfreeze()
454
+
455
+ const host = mount(
456
+ <List initial={["Alpha", "Beta", "Gamma", "Delta"]} />,
457
+ )
458
+
459
+ await waitFor(() => {
460
+ expect(getItem(host, "Alpha")).not.toBeNull()
461
+ })
462
+
463
+ const beta = getItem(host, "Beta") as HTMLElement
464
+
465
+ const topBefore = beta.getBoundingClientRect().top
466
+
467
+ await userEvent.click(
468
+ getButton(host, "Remove Beta and reverse"),
469
+ )
470
+
471
+ // Drawn after Alpha, its last-shown neighbour, at the end of the
472
+ // reversed list…
473
+ expect(shownOrder(host)).toEqual([
474
+ "Delta",
475
+ "Gamma",
476
+ "Alpha",
477
+ "Beta",
478
+ ])
479
+
480
+ // …and starting from where the user last saw it.
481
+ expect(beta.style.transition).toContain("translate")
482
+ expect(
483
+ Math.abs(beta.getBoundingClientRect().top - topBefore),
484
+ ).toBeLessThan(2)
485
+ })
486
+
487
+ test("an item that moves while it is still entering slides from where it is shown, instead of jumping", async () => {
488
+ unfreeze()
489
+
490
+ const host = mount(
491
+ <List initial={["Alpha", "Beta", "Gamma"]} />,
492
+ )
493
+
494
+ await waitFor(() => {
495
+ expect(getItem(host, "Alpha")).not.toBeNull()
496
+ })
497
+
498
+ await userEvent.click(getButton(host, "Add"))
499
+
500
+ const delta = getItem(host, "Delta") as HTMLElement
501
+
502
+ expect(delta).toHaveClass("charcuterie-item-enter")
503
+
504
+ const topBefore = delta.getBoundingClientRect().top
505
+
506
+ // Still entering (the motion is 600ms here), and moved to the top.
507
+ await userEvent.click(getButton(host, "Reverse"))
508
+
509
+ expect(shownOrder(host)[0]).toBe("Delta")
510
+
511
+ // Still entering when it moved, or this test would prove nothing.
512
+ expect(
513
+ delta
514
+ .getAnimations()
515
+ .some(
516
+ (animation) =>
517
+ animation instanceof CSSAnimation &&
518
+ animation.animationName === "charcuterie-item-in",
519
+ ),
520
+ ).toBe(true)
521
+
522
+ // Sliding, from where it was shown.
523
+ expect(delta.style.transition).toContain("translate")
524
+ expect(
525
+ Math.abs(delta.getBoundingClientRect().top - topBefore),
526
+ ).toBeLessThan(2)
527
+ })