@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43

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 (298) hide show
  1. package/dist/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
  2. package/dist/app-shell.js +1 -1
  3. package/dist/attachment-TZykYNu5.js +300 -0
  4. package/dist/attachment.js +2 -2
  5. package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
  6. package/dist/avatar-group.js +1 -1
  7. package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
  8. package/dist/carousel.js +1 -1
  9. package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
  10. package/dist/command-palette.js +1 -1
  11. package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
  12. package/dist/data-grid.js +1 -1
  13. package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
  14. package/dist/data-list.js +1 -1
  15. package/dist/detail-panel-Cke3ZFU3.js +342 -0
  16. package/dist/detail-panel.js +2 -2
  17. package/dist/docs/action-bar.examples.md +768 -0
  18. package/dist/docs/action-bar.json +74 -50
  19. package/dist/docs/action-bar.md +49 -311
  20. package/dist/docs/app-shell.examples.md +1221 -64
  21. package/dist/docs/app-shell.json +92 -60
  22. package/dist/docs/app-shell.md +92 -57
  23. package/dist/docs/attachment.examples.md +689 -0
  24. package/dist/docs/attachment.json +69 -37
  25. package/dist/docs/attachment.md +44 -203
  26. package/dist/docs/avatar-group.json +111 -23
  27. package/dist/docs/avatar-group.md +487 -28
  28. package/dist/docs/button-group.json +98 -2
  29. package/dist/docs/button-group.md +411 -8
  30. package/dist/docs/calendar.examples.md +512 -0
  31. package/dist/docs/calendar.json +72 -24
  32. package/dist/docs/calendar.md +18 -147
  33. package/dist/docs/carousel.examples.md +868 -0
  34. package/dist/docs/carousel.json +58 -50
  35. package/dist/docs/carousel.md +66 -300
  36. package/dist/docs/cascader.examples.md +1269 -0
  37. package/dist/docs/cascader.json +72 -16
  38. package/dist/docs/cascader.md +78 -154
  39. package/dist/docs/chart.examples.md +734 -24
  40. package/dist/docs/chart.json +93 -13
  41. package/dist/docs/chart.md +28 -7
  42. package/dist/docs/clock.json +71 -15
  43. package/dist/docs/clock.md +326 -21
  44. package/dist/docs/code-block.json +79 -55
  45. package/dist/docs/code-block.md +417 -74
  46. package/dist/docs/color-picker.json +60 -12
  47. package/dist/docs/color-picker.md +245 -22
  48. package/dist/docs/column-manager.examples.md +764 -0
  49. package/dist/docs/column-manager.json +68 -12
  50. package/dist/docs/column-manager.md +44 -203
  51. package/dist/docs/command-palette.examples.md +747 -0
  52. package/dist/docs/command-palette.json +48 -24
  53. package/dist/docs/command-palette.md +60 -339
  54. package/dist/docs/currency-field.examples.md +355 -73
  55. package/dist/docs/currency-field.json +96 -64
  56. package/dist/docs/currency-field.md +57 -50
  57. package/dist/docs/dashboard-grid.examples.md +629 -0
  58. package/dist/docs/dashboard-grid.json +64 -16
  59. package/dist/docs/dashboard-grid.md +34 -152
  60. package/dist/docs/data-list.examples.md +1556 -0
  61. package/dist/docs/data-list.json +58 -18
  62. package/dist/docs/data-list.md +139 -224
  63. package/dist/docs/date-field.examples.md +543 -0
  64. package/dist/docs/date-field.json +64 -24
  65. package/dist/docs/date-field.md +22 -168
  66. package/dist/docs/datetime-field.examples.md +699 -0
  67. package/dist/docs/datetime-field.json +79 -31
  68. package/dist/docs/datetime-field.md +24 -269
  69. package/dist/docs/datetime-range-picker.examples.md +682 -0
  70. package/dist/docs/datetime-range-picker.json +117 -61
  71. package/dist/docs/datetime-range-picker.md +59 -224
  72. package/dist/docs/description-list.examples.md +652 -0
  73. package/dist/docs/description-list.json +49 -25
  74. package/dist/docs/description-list.md +33 -188
  75. package/dist/docs/detail-panel.examples.md +1177 -0
  76. package/dist/docs/detail-panel.json +69 -53
  77. package/dist/docs/detail-panel.md +114 -324
  78. package/dist/docs/entity-picker.examples.md +1037 -0
  79. package/dist/docs/entity-picker.json +66 -18
  80. package/dist/docs/entity-picker.md +56 -246
  81. package/dist/docs/event-calendar.examples.md +749 -49
  82. package/dist/docs/event-calendar.json +46 -22
  83. package/dist/docs/event-calendar.md +81 -11
  84. package/dist/docs/field-group.examples.md +554 -0
  85. package/dist/docs/field-group.json +98 -34
  86. package/dist/docs/field-group.md +55 -133
  87. package/dist/docs/filter-bar.examples.md +772 -0
  88. package/dist/docs/filter-bar.json +41 -25
  89. package/dist/docs/filter-bar.md +42 -246
  90. package/dist/docs/form.examples.md +579 -0
  91. package/dist/docs/form.json +87 -39
  92. package/dist/docs/form.md +53 -177
  93. package/dist/docs/fullscreen.examples.md +558 -0
  94. package/dist/docs/fullscreen.json +58 -18
  95. package/dist/docs/fullscreen.md +50 -169
  96. package/dist/docs/highlight.json +57 -25
  97. package/dist/docs/highlight.md +402 -50
  98. package/dist/docs/icon.json +85 -5
  99. package/dist/docs/icon.md +401 -10
  100. package/dist/docs/image.examples.md +670 -0
  101. package/dist/docs/image.json +44 -28
  102. package/dist/docs/image.md +24 -176
  103. package/dist/docs/import-export-center.examples.md +1280 -0
  104. package/dist/docs/import-export-center.json +67 -27
  105. package/dist/docs/import-export-center.md +121 -226
  106. package/dist/docs/list-item.examples.md +769 -0
  107. package/dist/docs/list-item.json +110 -38
  108. package/dist/docs/list-item.md +84 -201
  109. package/dist/docs/listbox.examples.md +858 -0
  110. package/dist/docs/listbox.json +76 -28
  111. package/dist/docs/listbox.md +41 -263
  112. package/dist/docs/markdown.json +79 -55
  113. package/dist/docs/markdown.md +581 -85
  114. package/dist/docs/media-viewer.examples.md +1038 -0
  115. package/dist/docs/media-viewer.json +70 -15
  116. package/dist/docs/media-viewer.md +84 -135
  117. package/dist/docs/message-scroller.examples.md +1193 -0
  118. package/dist/docs/message-scroller.json +41 -17
  119. package/dist/docs/message-scroller.md +80 -134
  120. package/dist/docs/message.examples.md +944 -0
  121. package/dist/docs/message.json +64 -16
  122. package/dist/docs/message.md +34 -326
  123. package/dist/docs/meter.json +58 -26
  124. package/dist/docs/meter.md +312 -32
  125. package/dist/docs/navigation-menu.examples.md +1107 -0
  126. package/dist/docs/navigation-menu.json +57 -41
  127. package/dist/docs/navigation-menu.md +105 -298
  128. package/dist/docs/notification-center.examples.md +1045 -0
  129. package/dist/docs/notification-center.json +71 -15
  130. package/dist/docs/notification-center.md +76 -266
  131. package/dist/docs/otp-input.examples.md +490 -0
  132. package/dist/docs/otp-input.json +65 -25
  133. package/dist/docs/otp-input.md +20 -191
  134. package/dist/docs/page-header.examples.md +1041 -0
  135. package/dist/docs/page-header.json +75 -43
  136. package/dist/docs/page-header.md +79 -291
  137. package/dist/docs/page.examples.md +633 -0
  138. package/dist/docs/page.json +48 -16
  139. package/dist/docs/page.md +62 -129
  140. package/dist/docs/prompt-composer.examples.md +630 -0
  141. package/dist/docs/prompt-composer.json +66 -18
  142. package/dist/docs/prompt-composer.md +35 -161
  143. package/dist/docs/prose.json +69 -37
  144. package/dist/docs/prose.md +393 -75
  145. package/dist/docs/rating.examples.md +525 -0
  146. package/dist/docs/rating.json +92 -28
  147. package/dist/docs/rating.md +27 -241
  148. package/dist/docs/saved-views.examples.md +1108 -0
  149. package/dist/docs/saved-views.json +53 -21
  150. package/dist/docs/saved-views.md +86 -171
  151. package/dist/docs/scroll-area.examples.md +837 -0
  152. package/dist/docs/scroll-area.json +64 -24
  153. package/dist/docs/scroll-area.md +57 -140
  154. package/dist/docs/section.examples.md +676 -0
  155. package/dist/docs/section.json +68 -20
  156. package/dist/docs/section.md +39 -162
  157. package/dist/docs/segmented-control.examples.md +480 -0
  158. package/dist/docs/segmented-control.json +76 -28
  159. package/dist/docs/segmented-control.md +20 -191
  160. package/dist/docs/side-navigation.examples.md +1468 -0
  161. package/dist/docs/side-navigation.json +53 -53
  162. package/dist/docs/side-navigation.md +79 -354
  163. package/dist/docs/slider.examples.md +505 -0
  164. package/dist/docs/slider.json +91 -51
  165. package/dist/docs/slider.md +47 -212
  166. package/dist/docs/sparkline.json +60 -36
  167. package/dist/docs/sparkline.md +447 -71
  168. package/dist/docs/split-button.examples.md +509 -0
  169. package/dist/docs/split-button.json +73 -41
  170. package/dist/docs/split-button.md +64 -194
  171. package/dist/docs/splitter.examples.md +921 -0
  172. package/dist/docs/splitter.json +94 -46
  173. package/dist/docs/splitter.md +75 -182
  174. package/dist/docs/stat-card.examples.md +725 -0
  175. package/dist/docs/stat-card.json +89 -41
  176. package/dist/docs/stat-card.md +55 -227
  177. package/dist/docs/status-indicator.json +80 -32
  178. package/dist/docs/status-indicator.md +409 -65
  179. package/dist/docs/stepper.json +53 -21
  180. package/dist/docs/stepper.md +369 -48
  181. package/dist/docs/table-of-contents.examples.md +550 -0
  182. package/dist/docs/table-of-contents.json +60 -28
  183. package/dist/docs/table-of-contents.md +70 -205
  184. package/dist/docs/tags-input.examples.md +541 -0
  185. package/dist/docs/tags-input.json +64 -16
  186. package/dist/docs/tags-input.md +15 -262
  187. package/dist/docs/time-field.examples.md +587 -0
  188. package/dist/docs/time-field.json +69 -29
  189. package/dist/docs/time-field.md +21 -223
  190. package/dist/docs/time-picker.json +117 -53
  191. package/dist/docs/time-picker.md +499 -54
  192. package/dist/docs/time-range-picker.examples.md +750 -0
  193. package/dist/docs/time-range-picker.json +139 -75
  194. package/dist/docs/time-range-picker.md +63 -225
  195. package/dist/docs/timeline.examples.md +617 -0
  196. package/dist/docs/timeline.json +44 -28
  197. package/dist/docs/timeline.md +34 -208
  198. package/dist/docs/toolbar.json +56 -16
  199. package/dist/docs/toolbar.md +357 -63
  200. package/dist/docs/top-navigation.examples.md +1206 -140
  201. package/dist/docs/top-navigation.json +49 -33
  202. package/dist/docs/top-navigation.md +87 -36
  203. package/dist/docs/tour.examples.md +960 -0
  204. package/dist/docs/tour.json +57 -25
  205. package/dist/docs/tour.md +60 -244
  206. package/dist/docs/transfer.examples.md +631 -0
  207. package/dist/docs/transfer.json +80 -16
  208. package/dist/docs/transfer.md +41 -170
  209. package/dist/docs/typography.json +96 -0
  210. package/dist/docs/typography.md +352 -4
  211. package/dist/docs/upload.examples.md +555 -53
  212. package/dist/docs/upload.json +62 -30
  213. package/dist/docs/upload.md +46 -11
  214. package/dist/docs/wizard.examples.md +1389 -0
  215. package/dist/docs/wizard.json +89 -49
  216. package/dist/docs/wizard.md +122 -263
  217. package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
  218. package/dist/entity-picker.js +1 -1
  219. package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
  220. package/dist/event-calendar.js +1 -1
  221. package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
  222. package/dist/filter-bar.js +1 -1
  223. package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
  224. package/dist/import-export-center.js +1 -1
  225. package/dist/index.js +58 -58
  226. package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
  227. package/dist/markdown.js +1 -1
  228. package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
  229. package/dist/media-viewer.js +2 -2
  230. package/dist/message-P91bEGyV.js +455 -0
  231. package/dist/message.js +2 -2
  232. package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
  233. package/dist/page-header.js +1 -1
  234. package/dist/section-CVTQdWBl.js +216 -0
  235. package/dist/section.js +2 -2
  236. package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
  237. package/dist/segmented-control.js +1 -1
  238. package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
  239. package/dist/side-navigation.js +1 -1
  240. package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
  241. package/dist/stat-card.js +1 -1
  242. package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
  243. package/dist/stepper.js +2 -2
  244. package/dist/styles/carousel.css +1 -1
  245. package/dist/styles/index.css +1 -1
  246. package/dist/styles.css +1 -1
  247. package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
  248. package/dist/timeline.js +1 -1
  249. package/dist/top-navigation-YSEQzBhD.js +744 -0
  250. package/dist/top-navigation.js +2 -2
  251. package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
  252. package/dist/transfer.js +1 -1
  253. package/dist/types/attachment/attachment-parts.d.ts +24 -11
  254. package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
  255. package/dist/types/attachment/attachment.d.ts +3 -3
  256. package/dist/types/attachment/attachment.d.ts.map +1 -1
  257. package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
  258. package/dist/types/carousel/carousel-parts.d.ts +2 -2
  259. package/dist/types/command-palette/command-palette.d.ts.map +1 -1
  260. package/dist/types/data-list/data-list.d.ts.map +1 -1
  261. package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
  262. package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
  263. package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
  264. package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
  265. package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
  266. package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
  267. package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
  268. package/dist/types/media-viewer/index.d.ts +2 -2
  269. package/dist/types/media-viewer/index.d.ts.map +1 -1
  270. package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
  271. package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
  272. package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
  273. package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
  274. package/dist/types/message/message-parts.d.ts +7 -0
  275. package/dist/types/message/message-parts.d.ts.map +1 -1
  276. package/dist/types/message/message.d.ts.map +1 -1
  277. package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
  278. package/dist/types/section/section-parts.d.ts +16 -8
  279. package/dist/types/section/section-parts.d.ts.map +1 -1
  280. package/dist/types/section/section.d.ts.map +1 -1
  281. package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
  282. package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
  283. package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
  284. package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
  285. package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
  286. package/dist/types/stepper/stepper-parts.d.ts +11 -2
  287. package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
  288. package/dist/types/stepper/stepper.d.ts.map +1 -1
  289. package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
  290. package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
  291. package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
  292. package/dist/wizard.js +1 -1
  293. package/package.json +6 -6
  294. package/dist/attachment-MqczA38F.js +0 -292
  295. package/dist/detail-panel-EImAtksY.js +0 -327
  296. package/dist/message-D1Dd6Y2k.js +0 -452
  297. package/dist/section-D_qOfdxR.js +0 -213
  298. package/dist/top-navigation-D8IHPOmm.js +0 -744
@@ -0,0 +1,1193 @@
1
+ <!-- index: ./index.md -->
2
+ # message-scroller
3
+
4
+ `data-ui="message-scroller"` · Scrolling log of messages that follows new ones.
5
+
6
+ ## Examples
7
+
8
+ ### Playground
9
+
10
+ A conversation in a frame 22 rem tall with follow, the opening position and the peek on the controls. Scroll up and the jump control arrives; press it and it leaves.
11
+
12
+ Excerpt — not a complete module
13
+
14
+ ```tsx
15
+ <MessageScroller follow>
16
+ <MessageScrollerViewport>
17
+ <MessageScrollerContent>
18
+ {messages.map((message) => (
19
+ <MessageScrollerItem key={message.id} messageId={message.id} anchor={message.own}>
20
+ <Message align={message.own ? 'end' : 'start'}>…</Message>
21
+ </MessageScrollerItem>
22
+ ))}
23
+ </MessageScrollerContent>
24
+ </MessageScrollerViewport>
25
+ <MessageScrollerJump />
26
+ </MessageScroller>;
27
+ ```
28
+
29
+ ### Where a saved conversation opens
30
+
31
+ last-anchor opens at the reader’s last question with the answer under it; end at the last line; start at the first. None of them shows the oldest rows first and then jumps.
32
+
33
+ Excerpt — not a complete module
34
+
35
+ ```tsx
36
+ <MessageScroller defaultPosition="last-anchor">…</MessageScroller>;
37
+ ```
38
+
39
+ ### Following a reply, and letting go
40
+
41
+ With follow the view keeps the streaming reply in sight while the reader is at the end. Scroll up, select a word or press an arrow and it stops pulling; the jump control resumes it.
42
+
43
+ Example
44
+
45
+ ```tsx
46
+ import { useEffect, useState } from 'react';
47
+
48
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
49
+ import { Button } from '@slotted/react/button';
50
+ import {
51
+ MessageScroller,
52
+ MessageScrollerContent,
53
+ MessageScrollerItem,
54
+ MessageScrollerJump,
55
+ MessageScrollerViewport,
56
+ } from '@slotted/react/message-scroller';
57
+ import { Stack } from '@slotted/react/stack';
58
+ import { Text } from '@slotted/react/typography';
59
+
60
+ const REPLY =
61
+ 'Pallet P-7731 reached the Rotterdam hub at 19:48. The temperature log stayed between -19 and -18 degrees C for the whole trip, so no quality hold is needed. The receiving team can release the pallet to the cold room.';
62
+
63
+ const ROWS = [
64
+ {
65
+ id: 'q1',
66
+ own: true,
67
+ author: 'Dana Reyes',
68
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
69
+ },
70
+ {
71
+ id: 'a1',
72
+ own: false,
73
+ author: 'Dispatch assistant',
74
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
75
+ },
76
+ {
77
+ id: 'q2',
78
+ own: true,
79
+ author: 'Dana Reyes',
80
+ text: 'Is the cold-chain pallet part of that group?',
81
+ },
82
+ {
83
+ id: 'a2',
84
+ own: false,
85
+ author: 'Dispatch assistant',
86
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
87
+ },
88
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
89
+ {
90
+ id: 'a3',
91
+ own: false,
92
+ author: 'Dispatch assistant',
93
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
94
+ },
95
+ {
96
+ id: 'q4',
97
+ own: true,
98
+ author: 'Dana Reyes',
99
+ text: 'Tell the customer the delivery moves to tomorrow.',
100
+ },
101
+ {
102
+ id: 'a4',
103
+ own: false,
104
+ author: 'Dispatch assistant',
105
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
106
+ },
107
+ ];
108
+
109
+ export default function MessageScrollerFollowExample() {
110
+ const [length, setLength] = useState<number | null>(null);
111
+ const streaming = length !== null && length < REPLY.length;
112
+
113
+ useEffect(() => {
114
+ if (!streaming) return undefined;
115
+ const timer = window.setTimeout(() => setLength((value) => (value ?? 0) + 8), 60);
116
+ return () => window.clearTimeout(timer);
117
+ }, [streaming, length]);
118
+
119
+ function handleStream() {
120
+ setLength(8);
121
+ }
122
+
123
+ return (
124
+ <Stack gap={3}>
125
+ <Button size="sm" disabled={streaming} onClick={handleStream}>
126
+ Stream a reply
127
+ </Button>
128
+
129
+ <AspectRatio ratio="square">
130
+ <MessageScroller follow defaultPosition="end">
131
+ <MessageScrollerViewport>
132
+ <MessageScrollerContent>
133
+ {ROWS.map((row) => (
134
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
135
+ <Text size="sm" weight="semibold">
136
+ {row.author}
137
+ </Text>
138
+ <Text size="sm">{row.text}</Text>
139
+ </MessageScrollerItem>
140
+ ))}
141
+ {length === null ? null : (
142
+ <MessageScrollerItem messageId="live">
143
+ <Text size="sm" weight="semibold">
144
+ Dispatch assistant
145
+ </Text>
146
+ <Text size="sm">{REPLY.slice(0, length)}</Text>
147
+ </MessageScrollerItem>
148
+ )}
149
+ </MessageScrollerContent>
150
+ </MessageScrollerViewport>
151
+ <MessageScrollerJump />
152
+ </MessageScroller>
153
+ </AspectRatio>
154
+ </Stack>
155
+ );
156
+ }
157
+ ```
158
+
159
+ ### A question lifted to the top
160
+
161
+ An item with anchor that arrives is brought to the top with a peek of the row above it, and room is kept below so it can stand there while the answer is still short.
162
+
163
+ Example
164
+
165
+ ```tsx
166
+ import { useState } from 'react';
167
+
168
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
169
+ import { Button } from '@slotted/react/button';
170
+ import {
171
+ MessageScroller,
172
+ MessageScrollerContent,
173
+ MessageScrollerItem,
174
+ MessageScrollerJump,
175
+ MessageScrollerViewport,
176
+ } from '@slotted/react/message-scroller';
177
+ import { Stack } from '@slotted/react/stack';
178
+ import { Text } from '@slotted/react/typography';
179
+
180
+ const FOLLOW_UPS = [
181
+ {
182
+ id: 'q5',
183
+ own: true,
184
+ author: 'Dana Reyes',
185
+ text: 'Which warehouse holds the replacement stock?',
186
+ },
187
+ {
188
+ id: 'a5',
189
+ own: false,
190
+ author: 'Dispatch assistant',
191
+ text: 'Rotterdam holds 40 units. Antwerp holds 12 and can ship by 06:00.',
192
+ },
193
+ {
194
+ id: 'q6',
195
+ own: true,
196
+ author: 'Dana Reyes',
197
+ text: 'Reserve the 40 units for order NW-20418.',
198
+ },
199
+ {
200
+ id: 'a6',
201
+ own: false,
202
+ author: 'Dispatch assistant',
203
+ text: 'Reserved. The pick list prints at 05:30.',
204
+ },
205
+ ];
206
+
207
+ const ROWS = [
208
+ {
209
+ id: 'q1',
210
+ own: true,
211
+ author: 'Dana Reyes',
212
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
213
+ },
214
+ {
215
+ id: 'a1',
216
+ own: false,
217
+ author: 'Dispatch assistant',
218
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
219
+ },
220
+ {
221
+ id: 'q2',
222
+ own: true,
223
+ author: 'Dana Reyes',
224
+ text: 'Is the cold-chain pallet part of that group?',
225
+ },
226
+ {
227
+ id: 'a2',
228
+ own: false,
229
+ author: 'Dispatch assistant',
230
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
231
+ },
232
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
233
+ {
234
+ id: 'a3',
235
+ own: false,
236
+ author: 'Dispatch assistant',
237
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
238
+ },
239
+ {
240
+ id: 'q4',
241
+ own: true,
242
+ author: 'Dana Reyes',
243
+ text: 'Tell the customer the delivery moves to tomorrow.',
244
+ },
245
+ {
246
+ id: 'a4',
247
+ own: false,
248
+ author: 'Dispatch assistant',
249
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
250
+ },
251
+ ];
252
+
253
+ export default function MessageScrollerAnchorExample() {
254
+ const [sent, setSent] = useState(0);
255
+ const rows = [...ROWS, ...FOLLOW_UPS.slice(0, sent * 2)];
256
+
257
+ function handleSend() {
258
+ setSent((value) => value + 1);
259
+ }
260
+
261
+ return (
262
+ <Stack gap={3}>
263
+ <Button size="sm" disabled={sent === 2} onClick={handleSend}>
264
+ Send the next question
265
+ </Button>
266
+
267
+ <AspectRatio ratio="square">
268
+ <MessageScroller peek={48} scrollMargin={8}>
269
+ <MessageScrollerViewport>
270
+ <MessageScrollerContent>
271
+ {rows.map((row) => (
272
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
273
+ <Text size="sm" weight="semibold">
274
+ {row.author}
275
+ </Text>
276
+ <Text size="sm">{row.text}</Text>
277
+ </MessageScrollerItem>
278
+ ))}
279
+ </MessageScrollerContent>
280
+ </MessageScrollerViewport>
281
+ <MessageScrollerJump />
282
+ </MessageScroller>
283
+ </AspectRatio>
284
+ </Stack>
285
+ );
286
+ }
287
+ ```
288
+
289
+ ### Older messages without a jump
290
+
291
+ Reach the top and onReachStart asks for more; the rows arrive above and the one the reader was on stays exactly where it was. The loader holds the head while they travel.
292
+
293
+ Example
294
+
295
+ ```tsx
296
+ import { useEffect, useState } from 'react';
297
+
298
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
299
+ import {
300
+ MessageScroller,
301
+ MessageScrollerContent,
302
+ MessageScrollerItem,
303
+ MessageScrollerJump,
304
+ MessageScrollerLoader,
305
+ MessageScrollerViewport,
306
+ } from '@slotted/react/message-scroller';
307
+ import { Stack } from '@slotted/react/stack';
308
+ import { Text } from '@slotted/react/typography';
309
+
310
+ const OLDER = [
311
+ [
312
+ {
313
+ id: 'o1',
314
+ own: true,
315
+ author: 'Dana Reyes',
316
+ text: 'Ticket 4821: exports come back empty for one customer.',
317
+ },
318
+ {
319
+ id: 'o2',
320
+ own: false,
321
+ author: 'Dispatch assistant',
322
+ text: 'Each job finished with zero rows. Only workspace ws-3311 shows the pattern.',
323
+ },
324
+ ],
325
+ [
326
+ {
327
+ id: 'p1',
328
+ own: true,
329
+ author: 'Dana Reyes',
330
+ text: 'Did the carrier change its pickup window this month?',
331
+ },
332
+ {
333
+ id: 'p2',
334
+ own: false,
335
+ author: 'Dispatch assistant',
336
+ text: 'Yes. Harbor Freight moved the Rotterdam pickup from 18:00 to 17:30 on the 3rd.',
337
+ },
338
+ ],
339
+ ];
340
+
341
+ const ROWS = [
342
+ {
343
+ id: 'q1',
344
+ own: true,
345
+ author: 'Dana Reyes',
346
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
347
+ },
348
+ {
349
+ id: 'a1',
350
+ own: false,
351
+ author: 'Dispatch assistant',
352
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
353
+ },
354
+ {
355
+ id: 'q2',
356
+ own: true,
357
+ author: 'Dana Reyes',
358
+ text: 'Is the cold-chain pallet part of that group?',
359
+ },
360
+ {
361
+ id: 'a2',
362
+ own: false,
363
+ author: 'Dispatch assistant',
364
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
365
+ },
366
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
367
+ {
368
+ id: 'a3',
369
+ own: false,
370
+ author: 'Dispatch assistant',
371
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
372
+ },
373
+ {
374
+ id: 'q4',
375
+ own: true,
376
+ author: 'Dana Reyes',
377
+ text: 'Tell the customer the delivery moves to tomorrow.',
378
+ },
379
+ {
380
+ id: 'a4',
381
+ own: false,
382
+ author: 'Dispatch assistant',
383
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
384
+ },
385
+ ];
386
+
387
+ export default function MessageScrollerHistoryExample() {
388
+ const [loaded, setLoaded] = useState(0);
389
+ const [loading, setLoading] = useState(false);
390
+ const rows = [...OLDER.slice(0, loaded).reverse().flat(), ...ROWS];
391
+
392
+ useEffect(() => {
393
+ if (!loading) return undefined;
394
+ const timer = window.setTimeout(() => {
395
+ setLoaded((value) => value + 1);
396
+ setLoading(false);
397
+ }, 1200);
398
+ return () => window.clearTimeout(timer);
399
+ }, [loading]);
400
+
401
+ function handleReachStart() {
402
+ if (!loading && loaded < OLDER.length) setLoading(true);
403
+ }
404
+
405
+ return (
406
+ <Stack gap={3}>
407
+ <Text size="sm" tone="muted">
408
+ Earlier messages loaded: {loaded} of {OLDER.length}
409
+ </Text>
410
+
411
+ <AspectRatio ratio="square">
412
+ <MessageScroller defaultPosition="end" onReachStart={handleReachStart}>
413
+ <MessageScrollerViewport>
414
+ <MessageScrollerContent>
415
+ {loading ? <MessageScrollerLoader /> : null}
416
+ {rows.map((row) => (
417
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
418
+ <Text size="sm" weight="semibold">
419
+ {row.author}
420
+ </Text>
421
+ <Text size="sm">{row.text}</Text>
422
+ </MessageScrollerItem>
423
+ ))}
424
+ </MessageScrollerContent>
425
+ </MessageScrollerViewport>
426
+ <MessageScrollerJump />
427
+ </MessageScroller>
428
+ </AspectRatio>
429
+ </Stack>
430
+ );
431
+ }
432
+ ```
433
+
434
+ ### Back to the latest, with a count
435
+
436
+ Scroll up and send two messages from the other side: the control widens to say how many arrived out of view. It arrives on the enter curve and leaves faster than it came.
437
+
438
+ Example
439
+
440
+ ```tsx
441
+ import { useState } from 'react';
442
+
443
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
444
+ import { Button } from '@slotted/react/button';
445
+ import {
446
+ MessageScroller,
447
+ MessageScrollerContent,
448
+ MessageScrollerItem,
449
+ MessageScrollerJump,
450
+ MessageScrollerViewport,
451
+ } from '@slotted/react/message-scroller';
452
+ import { Stack } from '@slotted/react/stack';
453
+ import { Text } from '@slotted/react/typography';
454
+
455
+ const INCOMING = [
456
+ {
457
+ id: 'a5',
458
+ own: false,
459
+ author: 'Dispatch assistant',
460
+ text: 'Harbor Freight confirmed the 19:00 pickup.',
461
+ },
462
+ {
463
+ id: 'a6',
464
+ own: false,
465
+ author: 'Dispatch assistant',
466
+ text: 'The Rotterdam dock released door 4 at 18:40.',
467
+ },
468
+ {
469
+ id: 'a7',
470
+ own: false,
471
+ author: 'Dispatch assistant',
472
+ text: 'Pallet P-7731 was loaded at 18:55.',
473
+ },
474
+ ];
475
+
476
+ const ROWS = [
477
+ {
478
+ id: 'q1',
479
+ own: true,
480
+ author: 'Dana Reyes',
481
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
482
+ },
483
+ {
484
+ id: 'a1',
485
+ own: false,
486
+ author: 'Dispatch assistant',
487
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
488
+ },
489
+ {
490
+ id: 'q2',
491
+ own: true,
492
+ author: 'Dana Reyes',
493
+ text: 'Is the cold-chain pallet part of that group?',
494
+ },
495
+ {
496
+ id: 'a2',
497
+ own: false,
498
+ author: 'Dispatch assistant',
499
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
500
+ },
501
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
502
+ {
503
+ id: 'a3',
504
+ own: false,
505
+ author: 'Dispatch assistant',
506
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
507
+ },
508
+ {
509
+ id: 'q4',
510
+ own: true,
511
+ author: 'Dana Reyes',
512
+ text: 'Tell the customer the delivery moves to tomorrow.',
513
+ },
514
+ {
515
+ id: 'a4',
516
+ own: false,
517
+ author: 'Dispatch assistant',
518
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
519
+ },
520
+ ];
521
+
522
+ export default function MessageScrollerJumpExample() {
523
+ const [received, setReceived] = useState(0);
524
+ const rows = [...ROWS, ...INCOMING.slice(0, received)];
525
+
526
+ function handleReceive() {
527
+ setReceived((value) => value + 1);
528
+ }
529
+
530
+ return (
531
+ <Stack gap={3}>
532
+ <Button size="sm" disabled={received === INCOMING.length} onClick={handleReceive}>
533
+ Receive a message
534
+ </Button>
535
+
536
+ <AspectRatio ratio="square">
537
+ <MessageScroller defaultPosition="end">
538
+ <MessageScrollerViewport>
539
+ <MessageScrollerContent>
540
+ {rows.map((row) => (
541
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
542
+ <Text size="sm" weight="semibold">
543
+ {row.author}
544
+ </Text>
545
+ <Text size="sm">{row.text}</Text>
546
+ </MessageScrollerItem>
547
+ ))}
548
+ </MessageScrollerContent>
549
+ </MessageScrollerViewport>
550
+ <MessageScrollerJump direction="start" behavior="instant" />
551
+ <MessageScrollerJump />
552
+ </MessageScroller>
553
+ </AspectRatio>
554
+ </Stack>
555
+ );
556
+ }
557
+ ```
558
+
559
+ ### Jumping to a turn from outside
560
+
561
+ A footer outside the frame reads onAnchorChange and drives ref.current.scrollToMessage with highlight: the landed row glows in the accent’s tint and loses it slowly.
562
+
563
+ Example
564
+
565
+ ```tsx
566
+ import { useRef, useState } from 'react';
567
+
568
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
569
+ import { Button } from '@slotted/react/button';
570
+ import { Inline } from '@slotted/react/inline';
571
+ import {
572
+ MessageScroller,
573
+ MessageScrollerContent,
574
+ MessageScrollerItem,
575
+ MessageScrollerJump,
576
+ MessageScrollerViewport,
577
+ } from '@slotted/react/message-scroller';
578
+ import type { MessageScrollerHandle } from '@slotted/react/message-scroller';
579
+ import { Stack } from '@slotted/react/stack';
580
+ import { Text } from '@slotted/react/typography';
581
+
582
+ const TURNS = [
583
+ { id: 'q1', label: 'Pickup' },
584
+ { id: 'q2', label: 'Cold chain' },
585
+ { id: 'q3', label: 'Rebooking' },
586
+ { id: 'q4', label: 'Customer' },
587
+ ];
588
+
589
+ const ROWS = [
590
+ {
591
+ id: 'q1',
592
+ own: true,
593
+ author: 'Dana Reyes',
594
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
595
+ },
596
+ {
597
+ id: 'a1',
598
+ own: false,
599
+ author: 'Dispatch assistant',
600
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
601
+ },
602
+ {
603
+ id: 'q2',
604
+ own: true,
605
+ author: 'Dana Reyes',
606
+ text: 'Is the cold-chain pallet part of that group?',
607
+ },
608
+ {
609
+ id: 'a2',
610
+ own: false,
611
+ author: 'Dispatch assistant',
612
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
613
+ },
614
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
615
+ {
616
+ id: 'a3',
617
+ own: false,
618
+ author: 'Dispatch assistant',
619
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
620
+ },
621
+ {
622
+ id: 'q4',
623
+ own: true,
624
+ author: 'Dana Reyes',
625
+ text: 'Tell the customer the delivery moves to tomorrow.',
626
+ },
627
+ {
628
+ id: 'a4',
629
+ own: false,
630
+ author: 'Dispatch assistant',
631
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
632
+ },
633
+ ];
634
+
635
+ export default function MessageScrollerNavigatorExample() {
636
+ const scroller = useRef<MessageScrollerHandle>(null);
637
+ const [current, setCurrent] = useState<string | null>(null);
638
+
639
+ function handleGo(id: string) {
640
+ scroller.current?.scrollToMessage(id, { highlight: true });
641
+ }
642
+
643
+ return (
644
+ <Stack gap={3}>
645
+ <Inline gap={2}>
646
+ {TURNS.map((turn) => (
647
+ <Button
648
+ key={turn.id}
649
+ size="sm"
650
+ variant={turn.id === current ? 'solid' : 'outline'}
651
+ onClick={() => handleGo(turn.id)}
652
+ >
653
+ {turn.label}
654
+ </Button>
655
+ ))}
656
+ </Inline>
657
+
658
+ <AspectRatio ratio="square">
659
+ <MessageScroller
660
+ ref={scroller}
661
+ defaultPosition="start"
662
+ onAnchorChange={(id) => setCurrent(id)}
663
+ >
664
+ <MessageScrollerViewport>
665
+ <MessageScrollerContent>
666
+ {ROWS.map((row) => (
667
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
668
+ <Text size="sm" weight="semibold">
669
+ {row.author}
670
+ </Text>
671
+ <Text size="sm">{row.text}</Text>
672
+ </MessageScrollerItem>
673
+ ))}
674
+ </MessageScrollerContent>
675
+ </MessageScrollerViewport>
676
+ <MessageScrollerJump />
677
+ </MessageScroller>
678
+ </AspectRatio>
679
+ </Stack>
680
+ );
681
+ }
682
+ ```
683
+
684
+ ### Days that stay at the top
685
+
686
+ A sticky separator is a pill that stays at the top while its day is in view and gives way to the next day as it arrives; a separator that is not sticky keeps its rules.
687
+
688
+ Example
689
+
690
+ ```tsx
691
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
692
+ import {
693
+ MessageScroller,
694
+ MessageScrollerContent,
695
+ MessageScrollerItem,
696
+ MessageScrollerJump,
697
+ MessageScrollerSeparator,
698
+ MessageScrollerViewport,
699
+ } from '@slotted/react/message-scroller';
700
+ import { Text } from '@slotted/react/typography';
701
+
702
+ const ITEMS = [
703
+ { id: 's1', kind: 'day', text: 'Yesterday' },
704
+ {
705
+ id: 'm1',
706
+ kind: 'message',
707
+ author: 'Dana Reyes',
708
+ text: 'Count the returns bay before the shift ends.',
709
+ },
710
+ {
711
+ id: 'm2',
712
+ kind: 'message',
713
+ author: 'Dispatch assistant',
714
+ text: 'The count finished at 21:10. Two cartons carry no label.',
715
+ },
716
+ { id: 'm3', kind: 'message', author: 'Dana Reyes', text: 'Hold both cartons for inspection.' },
717
+ {
718
+ id: 'm4',
719
+ kind: 'message',
720
+ author: 'Dispatch assistant',
721
+ text: 'Both cartons moved to the quarantine rack in aisle 9.',
722
+ },
723
+ { id: 's2', kind: 'note', text: 'Night shift took over at 22:00' },
724
+ {
725
+ id: 'm5',
726
+ kind: 'message',
727
+ author: 'Dispatch assistant',
728
+ text: 'Night shift confirmed the quarantine rack is sealed.',
729
+ },
730
+ { id: 's3', kind: 'day', text: 'Today' },
731
+ {
732
+ id: 'm6',
733
+ kind: 'message',
734
+ author: 'Dana Reyes',
735
+ text: 'Open the inspection for the two cartons.',
736
+ },
737
+ {
738
+ id: 'm7',
739
+ kind: 'message',
740
+ author: 'Dispatch assistant',
741
+ text: 'Inspection INS-3302 opened at 07:45.',
742
+ },
743
+ { id: 'm8', kind: 'message', author: 'Dana Reyes', text: 'Assign it to the quality team.' },
744
+ {
745
+ id: 'm9',
746
+ kind: 'message',
747
+ author: 'Dispatch assistant',
748
+ text: 'Assigned to the quality team, due at 12:00.',
749
+ },
750
+ ];
751
+
752
+ export default function MessageScrollerSeparatorsExample() {
753
+ return (
754
+ <AspectRatio ratio="square">
755
+ <MessageScroller defaultPosition="start">
756
+ <MessageScrollerViewport>
757
+ <MessageScrollerContent>
758
+ {ITEMS.map((item) => (
759
+ <MessageScrollerItem key={item.id}>
760
+ {item.kind === 'message' ? (
761
+ <>
762
+ <Text size="sm" weight="semibold">
763
+ {item.author}
764
+ </Text>
765
+ <Text size="sm">{item.text}</Text>
766
+ </>
767
+ ) : (
768
+ <MessageScrollerSeparator sticky={item.kind === 'day'}>
769
+ {item.text}
770
+ </MessageScrollerSeparator>
771
+ )}
772
+ </MessageScrollerItem>
773
+ ))}
774
+ </MessageScrollerContent>
775
+ </MessageScrollerViewport>
776
+ <MessageScrollerJump />
777
+ </MessageScroller>
778
+ </AspectRatio>
779
+ );
780
+ }
781
+ ```
782
+
783
+ ### Where the reader stopped reading
784
+
785
+ The unread line is a row like any other, in the accent, above the first message the reader has not seen; it is text in the flow, so it is read in order.
786
+
787
+ Example
788
+
789
+ ```tsx
790
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
791
+ import {
792
+ MessageScroller,
793
+ MessageScrollerContent,
794
+ MessageScrollerItem,
795
+ MessageScrollerJump,
796
+ MessageScrollerUnread,
797
+ MessageScrollerViewport,
798
+ } from '@slotted/react/message-scroller';
799
+ import { Text } from '@slotted/react/typography';
800
+
801
+ const READ = [
802
+ { id: 'r1', author: 'Dana Reyes', text: 'Is the Antwerp transfer on track?' },
803
+ { id: 'r2', author: 'Dispatch assistant', text: 'Yes. The truck left at 14:10.' },
804
+ { id: 'r3', author: 'Dana Reyes', text: 'Tell me when it docks.' },
805
+ ];
806
+
807
+ const UNREAD = [
808
+ { id: 'u1', author: 'Dispatch assistant', text: 'The truck docked at door 2 at 16:25.' },
809
+ { id: 'u2', author: 'Dispatch assistant', text: 'Receiving counted 18 of 18 pallets.' },
810
+ ];
811
+
812
+ export default function MessageScrollerUnreadExample() {
813
+ return (
814
+ <AspectRatio ratio="landscape">
815
+ <MessageScroller defaultPosition="start">
816
+ <MessageScrollerViewport>
817
+ <MessageScrollerContent>
818
+ {READ.map((row) => (
819
+ <MessageScrollerItem key={row.id} messageId={row.id}>
820
+ <Text size="sm" weight="semibold">
821
+ {row.author}
822
+ </Text>
823
+ <Text size="sm">{row.text}</Text>
824
+ </MessageScrollerItem>
825
+ ))}
826
+
827
+ <MessageScrollerItem>
828
+ <MessageScrollerUnread>2 new since 15:00</MessageScrollerUnread>
829
+ </MessageScrollerItem>
830
+
831
+ {UNREAD.map((row) => (
832
+ <MessageScrollerItem key={row.id} messageId={row.id}>
833
+ <Text size="sm" weight="semibold">
834
+ {row.author}
835
+ </Text>
836
+ <Text size="sm">{row.text}</Text>
837
+ </MessageScrollerItem>
838
+ ))}
839
+ </MessageScrollerContent>
840
+ </MessageScrollerViewport>
841
+ <MessageScrollerJump />
842
+ </MessageScroller>
843
+ </AspectRatio>
844
+ );
845
+ }
846
+ ```
847
+
848
+ ### Announcing a reply once
849
+
850
+ While busy the log holds its announcements back; the change is said once each way — Responding, then Response complete — never word by word.
851
+
852
+ Example
853
+
854
+ ```tsx
855
+ import { useEffect, useState } from 'react';
856
+
857
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
858
+ import { Button } from '@slotted/react/button';
859
+ import {
860
+ MessageScroller,
861
+ MessageScrollerContent,
862
+ MessageScrollerItem,
863
+ MessageScrollerJump,
864
+ MessageScrollerViewport,
865
+ } from '@slotted/react/message-scroller';
866
+ import { Stack } from '@slotted/react/stack';
867
+ import { Text } from '@slotted/react/typography';
868
+
869
+ const REPLY =
870
+ 'Pallet P-7731 reached the Rotterdam hub at 19:48. The temperature log stayed between -19 and -18 degrees C for the whole trip, so no quality hold is needed.';
871
+
872
+ const ROWS = [
873
+ {
874
+ id: 'q1',
875
+ own: true,
876
+ author: 'Dana Reyes',
877
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
878
+ },
879
+ {
880
+ id: 'a1',
881
+ own: false,
882
+ author: 'Dispatch assistant',
883
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
884
+ },
885
+ {
886
+ id: 'q2',
887
+ own: true,
888
+ author: 'Dana Reyes',
889
+ text: 'Is the cold-chain pallet part of that group?',
890
+ },
891
+ {
892
+ id: 'a2',
893
+ own: false,
894
+ author: 'Dispatch assistant',
895
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
896
+ },
897
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
898
+ {
899
+ id: 'a3',
900
+ own: false,
901
+ author: 'Dispatch assistant',
902
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
903
+ },
904
+ {
905
+ id: 'q4',
906
+ own: true,
907
+ author: 'Dana Reyes',
908
+ text: 'Tell the customer the delivery moves to tomorrow.',
909
+ },
910
+ {
911
+ id: 'a4',
912
+ own: false,
913
+ author: 'Dispatch assistant',
914
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
915
+ },
916
+ ];
917
+
918
+ export default function MessageScrollerBusyExample() {
919
+ const [length, setLength] = useState<number | null>(null);
920
+ const streaming = length !== null && length < REPLY.length;
921
+
922
+ useEffect(() => {
923
+ if (!streaming) return undefined;
924
+ const timer = window.setTimeout(() => setLength((value) => (value ?? 0) + 8), 80);
925
+ return () => window.clearTimeout(timer);
926
+ }, [streaming, length]);
927
+
928
+ function handleStream() {
929
+ setLength(8);
930
+ }
931
+
932
+ return (
933
+ <Stack gap={3}>
934
+ <Button size="sm" disabled={streaming} onClick={handleStream}>
935
+ Stream a reply
936
+ </Button>
937
+
938
+ <Text size="sm" tone="muted">
939
+ aria-busy on the log: {String(streaming)}
940
+ </Text>
941
+
942
+ <AspectRatio ratio="square">
943
+ <MessageScroller
944
+ follow
945
+ defaultPosition="end"
946
+ busy={streaming}
947
+ messages={{
948
+ busy: 'The dispatch assistant is replying',
949
+ idle: 'The dispatch assistant finished replying',
950
+ label: 'Dispatch conversation',
951
+ }}
952
+ >
953
+ <MessageScrollerViewport>
954
+ <MessageScrollerContent>
955
+ {ROWS.map((row) => (
956
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
957
+ <Text size="sm" weight="semibold">
958
+ {row.author}
959
+ </Text>
960
+ <Text size="sm">{row.text}</Text>
961
+ </MessageScrollerItem>
962
+ ))}
963
+ {length === null ? null : (
964
+ <MessageScrollerItem messageId="live">
965
+ <Text size="sm" weight="semibold">
966
+ Dispatch assistant
967
+ </Text>
968
+ <Text size="sm">{REPLY.slice(0, length)}</Text>
969
+ </MessageScrollerItem>
970
+ )}
971
+ </MessageScrollerContent>
972
+ </MessageScrollerViewport>
973
+ <MessageScrollerJump />
974
+ </MessageScroller>
975
+ </AspectRatio>
976
+ </Stack>
977
+ );
978
+ }
979
+ ```
980
+
981
+ ### defaults.tsx
982
+
983
+ Example
984
+
985
+ ```tsx
986
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
987
+ import {
988
+ MessageScroller,
989
+ MessageScrollerContent,
990
+ MessageScrollerDefaultsProvider,
991
+ MessageScrollerItem,
992
+ MessageScrollerViewport,
993
+ } from '@slotted/react/message-scroller';
994
+ import { Stack } from '@slotted/react/stack';
995
+ import { Text } from '@slotted/react/typography';
996
+
997
+ const ROWS = [
998
+ {
999
+ id: 'q1',
1000
+ own: true,
1001
+ author: 'Dana Reyes',
1002
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
1003
+ },
1004
+ {
1005
+ id: 'a1',
1006
+ own: false,
1007
+ author: 'Dispatch assistant',
1008
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
1009
+ },
1010
+ {
1011
+ id: 'q2',
1012
+ own: true,
1013
+ author: 'Dana Reyes',
1014
+ text: 'Is the cold-chain pallet part of that group?',
1015
+ },
1016
+ {
1017
+ id: 'a2',
1018
+ own: false,
1019
+ author: 'Dispatch assistant',
1020
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
1021
+ },
1022
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
1023
+ {
1024
+ id: 'a3',
1025
+ own: false,
1026
+ author: 'Dispatch assistant',
1027
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
1028
+ },
1029
+ {
1030
+ id: 'q4',
1031
+ own: true,
1032
+ author: 'Dana Reyes',
1033
+ text: 'Tell the customer the delivery moves to tomorrow.',
1034
+ },
1035
+ {
1036
+ id: 'a4',
1037
+ own: false,
1038
+ author: 'Dispatch assistant',
1039
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
1040
+ },
1041
+ ];
1042
+
1043
+ export default function MessageScrollerDefaultsExample() {
1044
+ return (
1045
+ <MessageScrollerDefaultsProvider defaultPosition="end">
1046
+ <Stack gap={3}>
1047
+ <AspectRatio ratio="landscape">
1048
+ <MessageScroller>
1049
+ <MessageScrollerViewport aria-label="Opens at the end">
1050
+ <MessageScrollerContent>
1051
+ {ROWS.map((row) => (
1052
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
1053
+ <Text size="sm" weight="semibold">
1054
+ {row.author}
1055
+ </Text>
1056
+ <Text size="sm">{row.text}</Text>
1057
+ </MessageScrollerItem>
1058
+ ))}
1059
+ </MessageScrollerContent>
1060
+ </MessageScrollerViewport>
1061
+ </MessageScroller>
1062
+ </AspectRatio>
1063
+
1064
+ <AspectRatio ratio="landscape">
1065
+ <MessageScroller defaultPosition="start">
1066
+ <MessageScrollerViewport aria-label="Opens at the start">
1067
+ <MessageScrollerContent>
1068
+ {ROWS.map((row) => (
1069
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
1070
+ <Text size="sm" weight="semibold">
1071
+ {row.author}
1072
+ </Text>
1073
+ <Text size="sm">{row.text}</Text>
1074
+ </MessageScrollerItem>
1075
+ ))}
1076
+ </MessageScrollerContent>
1077
+ </MessageScrollerViewport>
1078
+ </MessageScroller>
1079
+ </AspectRatio>
1080
+ </Stack>
1081
+ </MessageScrollerDefaultsProvider>
1082
+ );
1083
+ }
1084
+ ```
1085
+
1086
+ ### position.tsx
1087
+
1088
+ Example
1089
+
1090
+ ```tsx
1091
+ import { useState } from 'react';
1092
+
1093
+ import { AspectRatio } from '@slotted/react/aspect-ratio';
1094
+ import { Button } from '@slotted/react/button';
1095
+ import { Inline } from '@slotted/react/inline';
1096
+ import {
1097
+ MessageScroller,
1098
+ MessageScrollerContent,
1099
+ MessageScrollerItem,
1100
+ MessageScrollerJump,
1101
+ MessageScrollerViewport,
1102
+ } from '@slotted/react/message-scroller';
1103
+ import type { MessageScrollerPosition } from '@slotted/react/message-scroller';
1104
+ import { Stack } from '@slotted/react/stack';
1105
+ import { Text } from '@slotted/react/typography';
1106
+
1107
+ const POSITIONS: MessageScrollerPosition[] = ['start', 'end', 'last-anchor'];
1108
+
1109
+ const ROWS = [
1110
+ {
1111
+ id: 'q1',
1112
+ own: true,
1113
+ author: 'Dana Reyes',
1114
+ text: 'Which carrier missed the 17:30 pickup at the Rotterdam dock?',
1115
+ },
1116
+ {
1117
+ id: 'a1',
1118
+ own: false,
1119
+ author: 'Dispatch assistant',
1120
+ text: 'Harbor Freight. Three pallets for order NW-20418 were still on the dock at 17:42.',
1121
+ },
1122
+ {
1123
+ id: 'q2',
1124
+ own: true,
1125
+ author: 'Dana Reyes',
1126
+ text: 'Is the cold-chain pallet part of that group?',
1127
+ },
1128
+ {
1129
+ id: 'a2',
1130
+ own: false,
1131
+ author: 'Dispatch assistant',
1132
+ text: 'Yes. Pallet P-7731 holds frozen goods and left the cold room at 16:55, so it has 90 minutes of margin.',
1133
+ },
1134
+ { id: 'q3', own: true, author: 'Dana Reyes', text: 'Rebook it on the 19:00 truck.' },
1135
+ {
1136
+ id: 'a3',
1137
+ own: false,
1138
+ author: 'Dispatch assistant',
1139
+ text: 'Booked on the 19:00 truck under reference BK-5509. The carrier confirmed by email at 18:12.',
1140
+ },
1141
+ {
1142
+ id: 'q4',
1143
+ own: true,
1144
+ author: 'Dana Reyes',
1145
+ text: 'Tell the customer the delivery moves to tomorrow.',
1146
+ },
1147
+ {
1148
+ id: 'a4',
1149
+ own: false,
1150
+ author: 'Dispatch assistant',
1151
+ text: 'Alder Market was notified at 18:15. The new delivery window is 09:00 to 11:00.',
1152
+ },
1153
+ ];
1154
+
1155
+ export default function MessageScrollerPositionExample() {
1156
+ const [position, setPosition] = useState<MessageScrollerPosition>('last-anchor');
1157
+
1158
+ return (
1159
+ <Stack gap={3}>
1160
+ <Inline gap={2}>
1161
+ {POSITIONS.map((value) => (
1162
+ <Button
1163
+ key={value}
1164
+ size="sm"
1165
+ variant={value === position ? 'solid' : 'outline'}
1166
+ onClick={() => setPosition(value)}
1167
+ >
1168
+ {value}
1169
+ </Button>
1170
+ ))}
1171
+ </Inline>
1172
+
1173
+ <AspectRatio ratio="square">
1174
+ <MessageScroller key={position} defaultPosition={position}>
1175
+ <MessageScrollerViewport>
1176
+ <MessageScrollerContent>
1177
+ {ROWS.map((row) => (
1178
+ <MessageScrollerItem key={row.id} messageId={row.id} anchor={row.own}>
1179
+ <Text size="sm" weight="semibold">
1180
+ {row.author}
1181
+ </Text>
1182
+ <Text size="sm">{row.text}</Text>
1183
+ </MessageScrollerItem>
1184
+ ))}
1185
+ </MessageScrollerContent>
1186
+ </MessageScrollerViewport>
1187
+ <MessageScrollerJump />
1188
+ </MessageScroller>
1189
+ </AspectRatio>
1190
+ </Stack>
1191
+ );
1192
+ }
1193
+ ```