@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,1556 @@
1
+ <!-- index: ./index.md -->
2
+ # data-list
3
+
4
+ `data-ui="data-list"` · Records as stacked label and value items.
5
+
6
+ ## Examples
7
+
8
+ ### Playground
9
+
10
+ An account list at a phone’s width: select two records, sort by balance from the menu, open the fields of a record. The line under the list shows the query and the selection the list asked for.
11
+
12
+ Excerpt — not a complete module
13
+
14
+ ```tsx
15
+ <DataList
16
+ columns={columns}
17
+ label="Accounts"
18
+ rowKey="id"
19
+ rows={accounts}
20
+ selectionMode="multiple"
21
+ subtitle="email"
22
+ trailing="balance"
23
+ />;
24
+ ```
25
+
26
+ ### Anatomy
27
+
28
+ Every part on one record: the checkbox and the avatar at the start, the title as a link, the subtitle, the balance at the end, four fields, the disclosure for two more, and the row’s actions.
29
+
30
+ Excerpt — not a complete module
31
+
32
+ ```tsx
33
+ const columns: GridColumn<Account>[] = [
34
+ { id: 'name', label: 'Account', rowHeader: true },
35
+ { id: 'email', label: 'Email' },
36
+ { id: 'balance', label: 'Balance', kind: 'number' },
37
+ { id: 'status', label: 'Status', priority: 1 },
38
+ { id: 'owner', label: 'Owner', priority: 2 },
39
+ { id: 'actions', label: 'Actions', kind: 'actions' },
40
+ ];
41
+ ```
42
+
43
+ ### Fields by priority, at three widths
44
+
45
+ The same record at 375, 640 and 1024 pixels. Priority orders the pairs; a phone gives one pair a line with the label beside the value, a tablet two and three columns of label over value.
46
+
47
+ Example
48
+
49
+ ```tsx
50
+ import { useState } from 'react';
51
+
52
+ import type { GridColumn } from '@slotted/core/grid';
53
+ import { DataList } from '@slotted/react/data-list';
54
+ import { Stack } from '@slotted/react/stack';
55
+ import { Text } from '@slotted/react/typography';
56
+
57
+ interface Account {
58
+ id: string;
59
+ name: string;
60
+ email: string;
61
+ balance: number;
62
+ status: string;
63
+ owner: string | null;
64
+ region: string;
65
+ }
66
+
67
+ const ACCOUNTS: Account[] = [
68
+ {
69
+ id: 'acme',
70
+ name: 'Acme Logistics',
71
+ email: 'ops@acme.example',
72
+ balance: 12480,
73
+ status: 'Active',
74
+ owner: 'Marta Silva',
75
+ region: 'Lisbon',
76
+ },
77
+ {
78
+ id: 'borealis',
79
+ name: 'Borealis Foods',
80
+ email: 'buying@borealis.example',
81
+ balance: 3902.15,
82
+ status: 'On hold',
83
+ owner: null,
84
+ region: 'Porto',
85
+ },
86
+ {
87
+ id: 'cobalt',
88
+ name: 'Cobalt Studio',
89
+ email: 'hello@cobalt.example',
90
+ balance: 48120.4,
91
+ status: 'Active',
92
+ owner: 'John Reed',
93
+ region: 'Madrid',
94
+ },
95
+ {
96
+ id: 'dunmore',
97
+ name: 'Dunmore Freight',
98
+ email: 'accounts@dunmore.example',
99
+ balance: 0,
100
+ status: 'Closed',
101
+ owner: 'Rui Neves',
102
+ region: 'Seville',
103
+ },
104
+ {
105
+ id: 'star',
106
+ name: 'Star Pharma',
107
+ email: 'purchasing@star.example',
108
+ balance: 27650.9,
109
+ status: 'Active',
110
+ owner: 'Ana Costa',
111
+ region: 'Lisbon',
112
+ },
113
+ {
114
+ id: 'tailspin',
115
+ name: 'Tailspin Market',
116
+ email: 'orders@tailspin.example',
117
+ balance: 860.5,
118
+ status: 'On hold',
119
+ owner: 'Marta Silva',
120
+ region: 'Porto',
121
+ },
122
+ ];
123
+
124
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
125
+
126
+ const COLUMNS: GridColumn<Account>[] = [
127
+ { id: 'name', label: 'Account', rowHeader: true },
128
+ { id: 'email', label: 'Email' },
129
+ {
130
+ id: 'balance',
131
+ label: 'Balance',
132
+ kind: 'number',
133
+ format: (value) => USD.format(value as number),
134
+ },
135
+ { id: 'status', label: 'Status', priority: 1 },
136
+ { id: 'owner', label: 'Owner', priority: 2 },
137
+ { id: 'region', label: 'Region', priority: 3 },
138
+ ];
139
+
140
+ export default function DataListFieldsExample() {
141
+ const [open, setOpen] = useState<readonly string[]>(['borealis']);
142
+
143
+ return (
144
+ <Stack gap={3}>
145
+ <DataList
146
+ columns={COLUMNS}
147
+ expanded={open}
148
+ fields={1}
149
+ label="Accounts"
150
+ onExpandedChange={setOpen}
151
+ rowKey="id"
152
+ rows={ACCOUNTS.slice(0, 4)}
153
+ subtitle="email"
154
+ trailing="balance"
155
+ />
156
+
157
+ <Text size="sm" tone="muted">
158
+ Records showing every field: {open.length}
159
+ </Text>
160
+ </Stack>
161
+ );
162
+ }
163
+ ```
164
+
165
+ ### A link, a command, or text
166
+
167
+ With href the title is a link and the whole record is its target; with activatable it is a button that emits onActivate; with neither the record is only read. The current record, open beside the list, carries the neutral ground.
168
+
169
+ Example
170
+
171
+ ```tsx
172
+ import { useState } from 'react';
173
+
174
+ import type { GridColumn } from '@slotted/core/grid';
175
+ import { DataList } from '@slotted/react/data-list';
176
+ import { Stack } from '@slotted/react/stack';
177
+ import { Text } from '@slotted/react/typography';
178
+
179
+ interface Account {
180
+ id: string;
181
+ name: string;
182
+ email: string;
183
+ balance: number;
184
+ status: string;
185
+ owner: string | null;
186
+ region: string;
187
+ }
188
+
189
+ const ACCOUNTS: Account[] = [
190
+ {
191
+ id: 'acme',
192
+ name: 'Acme Logistics',
193
+ email: 'ops@acme.example',
194
+ balance: 12480,
195
+ status: 'Active',
196
+ owner: 'Marta Silva',
197
+ region: 'Lisbon',
198
+ },
199
+ {
200
+ id: 'borealis',
201
+ name: 'Borealis Foods',
202
+ email: 'buying@borealis.example',
203
+ balance: 3902.15,
204
+ status: 'On hold',
205
+ owner: null,
206
+ region: 'Porto',
207
+ },
208
+ {
209
+ id: 'cobalt',
210
+ name: 'Cobalt Studio',
211
+ email: 'hello@cobalt.example',
212
+ balance: 48120.4,
213
+ status: 'Active',
214
+ owner: 'John Reed',
215
+ region: 'Madrid',
216
+ },
217
+ {
218
+ id: 'dunmore',
219
+ name: 'Dunmore Freight',
220
+ email: 'accounts@dunmore.example',
221
+ balance: 0,
222
+ status: 'Closed',
223
+ owner: 'Rui Neves',
224
+ region: 'Seville',
225
+ },
226
+ {
227
+ id: 'star',
228
+ name: 'Star Pharma',
229
+ email: 'purchasing@star.example',
230
+ balance: 27650.9,
231
+ status: 'Active',
232
+ owner: 'Ana Costa',
233
+ region: 'Lisbon',
234
+ },
235
+ {
236
+ id: 'tailspin',
237
+ name: 'Tailspin Market',
238
+ email: 'orders@tailspin.example',
239
+ balance: 860.5,
240
+ status: 'On hold',
241
+ owner: 'Marta Silva',
242
+ region: 'Porto',
243
+ },
244
+ ];
245
+
246
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
247
+
248
+ const COLUMNS: GridColumn<Account>[] = [
249
+ { id: 'name', label: 'Account', rowHeader: true },
250
+ { id: 'email', label: 'Email' },
251
+ {
252
+ id: 'balance',
253
+ label: 'Balance',
254
+ kind: 'number',
255
+ format: (value) => USD.format(value as number),
256
+ },
257
+ { id: 'status', label: 'Status', priority: 1 },
258
+ { id: 'owner', label: 'Owner', priority: 2 },
259
+ { id: 'region', label: 'Region', priority: 3 },
260
+ ];
261
+
262
+ export default function DataListActivationExample() {
263
+ const [openId, setOpenId] = useState<string | null>('acme');
264
+
265
+ return (
266
+ <Stack gap={4}>
267
+ <Text size="sm" tone="muted">
268
+ The title is a link
269
+ </Text>
270
+ <DataList
271
+ columns={COLUMNS.slice(0, 3)}
272
+ href={(account) => `#${account.id}`}
273
+ label="Accounts with links"
274
+ rowKey="id"
275
+ rows={ACCOUNTS.slice(0, 3)}
276
+ subtitle="email"
277
+ trailing="balance"
278
+ />
279
+
280
+ <Text size="sm" tone="muted">
281
+ The title is a button
282
+ </Text>
283
+ <DataList
284
+ activatable
285
+ columns={COLUMNS.slice(0, 3)}
286
+ current={openId}
287
+ label="Accounts with a command"
288
+ onActivate={({ key }) => setOpenId(key)}
289
+ rowKey="id"
290
+ rows={ACCOUNTS.slice(0, 3)}
291
+ subtitle="email"
292
+ trailing="balance"
293
+ />
294
+
295
+ <Text size="sm" tone="muted">
296
+ Open record: {openId}
297
+ </Text>
298
+ </Stack>
299
+ );
300
+ }
301
+ ```
302
+
303
+ ### Selection
304
+
305
+ Multiple: the checkbox in each record, Shift to extend from the anchor, select-all over every record the query left and the count saying how many are chosen. Single holds one key, as table does.
306
+
307
+ Example
308
+
309
+ ```tsx
310
+ import { useState } from 'react';
311
+
312
+ import type { GridColumn } from '@slotted/core/grid';
313
+ import { Button } from '@slotted/react/button';
314
+ import { DataList } from '@slotted/react/data-list';
315
+ import type { DataListSelection } from '@slotted/react/data-list';
316
+ import { Inline } from '@slotted/react/inline';
317
+ import { Stack } from '@slotted/react/stack';
318
+ import { Text } from '@slotted/react/typography';
319
+
320
+ interface Account {
321
+ id: string;
322
+ name: string;
323
+ email: string;
324
+ balance: number;
325
+ status: string;
326
+ owner: string | null;
327
+ region: string;
328
+ }
329
+
330
+ const ACCOUNTS: Account[] = [
331
+ {
332
+ id: 'acme',
333
+ name: 'Acme Logistics',
334
+ email: 'ops@acme.example',
335
+ balance: 12480,
336
+ status: 'Active',
337
+ owner: 'Marta Silva',
338
+ region: 'Lisbon',
339
+ },
340
+ {
341
+ id: 'borealis',
342
+ name: 'Borealis Foods',
343
+ email: 'buying@borealis.example',
344
+ balance: 3902.15,
345
+ status: 'On hold',
346
+ owner: null,
347
+ region: 'Porto',
348
+ },
349
+ {
350
+ id: 'cobalt',
351
+ name: 'Cobalt Studio',
352
+ email: 'hello@cobalt.example',
353
+ balance: 48120.4,
354
+ status: 'Active',
355
+ owner: 'John Reed',
356
+ region: 'Madrid',
357
+ },
358
+ {
359
+ id: 'dunmore',
360
+ name: 'Dunmore Freight',
361
+ email: 'accounts@dunmore.example',
362
+ balance: 0,
363
+ status: 'Closed',
364
+ owner: 'Rui Neves',
365
+ region: 'Seville',
366
+ },
367
+ {
368
+ id: 'star',
369
+ name: 'Star Pharma',
370
+ email: 'purchasing@star.example',
371
+ balance: 27650.9,
372
+ status: 'Active',
373
+ owner: 'Ana Costa',
374
+ region: 'Lisbon',
375
+ },
376
+ {
377
+ id: 'tailspin',
378
+ name: 'Tailspin Market',
379
+ email: 'orders@tailspin.example',
380
+ balance: 860.5,
381
+ status: 'On hold',
382
+ owner: 'Marta Silva',
383
+ region: 'Porto',
384
+ },
385
+ ];
386
+
387
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
388
+
389
+ const COLUMNS: GridColumn<Account>[] = [
390
+ { id: 'name', label: 'Account', rowHeader: true },
391
+ { id: 'email', label: 'Email' },
392
+ {
393
+ id: 'balance',
394
+ label: 'Balance',
395
+ kind: 'number',
396
+ format: (value) => USD.format(value as number),
397
+ },
398
+ { id: 'status', label: 'Status', priority: 1 },
399
+ { id: 'owner', label: 'Owner', priority: 2 },
400
+ { id: 'region', label: 'Region', priority: 3 },
401
+ ];
402
+
403
+ export default function DataListSelectionExample() {
404
+ const [chosen, setChosen] = useState<DataListSelection>(['acme', 'star']);
405
+
406
+ return (
407
+ <Stack gap={4}>
408
+ <Text size="sm" tone="muted">
409
+ Multiple, controlled
410
+ </Text>
411
+ <DataList
412
+ columns={COLUMNS.slice(0, 3)}
413
+ label="Accounts to invoice"
414
+ onValueChange={setChosen}
415
+ rowKey="id"
416
+ rows={ACCOUNTS.slice(0, 4)}
417
+ selectionMode="multiple"
418
+ subtitle="email"
419
+ trailing="balance"
420
+ value={chosen}
421
+ />
422
+ <Inline>
423
+ <Button size="sm" tone="secondary" variant="outline" onClick={() => setChosen([])}>
424
+ Clear selection
425
+ </Button>
426
+ </Inline>
427
+
428
+ <Text size="sm" tone="muted">
429
+ Single
430
+ </Text>
431
+ <DataList
432
+ columns={COLUMNS.slice(0, 3)}
433
+ label="Primary account"
434
+ rowKey="id"
435
+ rows={ACCOUNTS.slice(0, 3)}
436
+ selectionMode="single"
437
+ subtitle="email"
438
+ trailing="balance"
439
+ />
440
+ </Stack>
441
+ );
442
+ }
443
+ ```
444
+
445
+ ### Sorting without a header
446
+
447
+ The sort control is a menu of the sortable columns and a direction. The trigger names the first key; a query sorted by several keys in data-grid shows +1 and the announcement reads the whole order.
448
+
449
+ Excerpt — not a complete module
450
+
451
+ ```tsx
452
+ const [query, setQuery] = useState<GridQuery>(emptyQuery());
453
+
454
+ <DataList query={query} onQueryChange={(next) => setQuery(next)} {...list} />;
455
+ ```
456
+
457
+ ### Filtering with filter-bar and a search field
458
+
459
+ The list applies query.filter and query.search; the controls that write them are FilterBar and a TextField bound to the same query. Type “lis” to keep the Lisbon accounts.
460
+
461
+ Excerpt — not a complete module
462
+
463
+ ```tsx
464
+ <TextField
465
+ label="Search accounts"
466
+ value={query.search}
467
+ onValueChange={(search) => setQuery({ ...query, search })}
468
+ />;
469
+ <DataList query={query} onQueryChange={setQuery} {...list} />;
470
+ ```
471
+
472
+ ### Groups
473
+
474
+ query.group becomes list sections, each named by the column, the value and the count. The groups stay open: a list has no collapsible group row.
475
+
476
+ Example
477
+
478
+ ```tsx
479
+ import type { GridColumn, GridQuery } from '@slotted/core/grid';
480
+ import { DataList } from '@slotted/react/data-list';
481
+
482
+ interface Account {
483
+ id: string;
484
+ name: string;
485
+ email: string;
486
+ balance: number;
487
+ status: string;
488
+ owner: string | null;
489
+ region: string;
490
+ }
491
+
492
+ const ACCOUNTS: Account[] = [
493
+ {
494
+ id: 'acme',
495
+ name: 'Acme Logistics',
496
+ email: 'ops@acme.example',
497
+ balance: 12480,
498
+ status: 'Active',
499
+ owner: 'Marta Silva',
500
+ region: 'Lisbon',
501
+ },
502
+ {
503
+ id: 'borealis',
504
+ name: 'Borealis Foods',
505
+ email: 'buying@borealis.example',
506
+ balance: 3902.15,
507
+ status: 'On hold',
508
+ owner: null,
509
+ region: 'Porto',
510
+ },
511
+ {
512
+ id: 'cobalt',
513
+ name: 'Cobalt Studio',
514
+ email: 'hello@cobalt.example',
515
+ balance: 48120.4,
516
+ status: 'Active',
517
+ owner: 'John Reed',
518
+ region: 'Madrid',
519
+ },
520
+ {
521
+ id: 'dunmore',
522
+ name: 'Dunmore Freight',
523
+ email: 'accounts@dunmore.example',
524
+ balance: 0,
525
+ status: 'Closed',
526
+ owner: 'Rui Neves',
527
+ region: 'Seville',
528
+ },
529
+ {
530
+ id: 'star',
531
+ name: 'Star Pharma',
532
+ email: 'purchasing@star.example',
533
+ balance: 27650.9,
534
+ status: 'Active',
535
+ owner: 'Ana Costa',
536
+ region: 'Lisbon',
537
+ },
538
+ {
539
+ id: 'tailspin',
540
+ name: 'Tailspin Market',
541
+ email: 'orders@tailspin.example',
542
+ balance: 860.5,
543
+ status: 'On hold',
544
+ owner: 'Marta Silva',
545
+ region: 'Porto',
546
+ },
547
+ ];
548
+
549
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
550
+
551
+ const COLUMNS: GridColumn<Account>[] = [
552
+ { id: 'name', label: 'Account', rowHeader: true },
553
+ { id: 'email', label: 'Email' },
554
+ {
555
+ id: 'balance',
556
+ label: 'Balance',
557
+ kind: 'number',
558
+ format: (value) => USD.format(value as number),
559
+ },
560
+ { id: 'status', label: 'Status', priority: 1 },
561
+ { id: 'owner', label: 'Owner', priority: 2 },
562
+ { id: 'region', label: 'Region', priority: 3 },
563
+ ];
564
+
565
+ const BY_REGION: GridQuery = { sort: [], filter: null, search: '', page: null, group: ['region'] };
566
+
567
+ export default function DataListGroupingExample() {
568
+ return (
569
+ <DataList
570
+ columns={COLUMNS}
571
+ defaultQuery={BY_REGION}
572
+ fields={1}
573
+ label="Accounts by region"
574
+ rowKey="id"
575
+ rows={ACCOUNTS}
576
+ subtitle="email"
577
+ trailing="balance"
578
+ />
579
+ );
580
+ }
581
+ ```
582
+
583
+ ### The fields past the first few
584
+
585
+ fields sets how many a closed record shows. Show 3 more opens the rest in the same grid, and the expansion is a controlled set of keys like data-grid’s detail.
586
+
587
+ Excerpt — not a complete module
588
+
589
+ ```tsx
590
+ <DataList expanded={open} fields={2} onExpandedChange={(keys) => setOpen(keys)} {...list} />;
591
+ ```
592
+
593
+ ### Record states
594
+
595
+ Selected, current, disabled and loading on four records: selected is the accent ground with its edge, current the neutral one, disabled and loading recede and refuse the activation while keeping their width.
596
+
597
+ Example
598
+
599
+ ```tsx
600
+ import type { GridColumn } from '@slotted/core/grid';
601
+ import { DataList } from '@slotted/react/data-list';
602
+
603
+ interface Account {
604
+ id: string;
605
+ name: string;
606
+ email: string;
607
+ balance: number;
608
+ status: string;
609
+ owner: string | null;
610
+ region: string;
611
+ }
612
+
613
+ const ACCOUNTS: Account[] = [
614
+ {
615
+ id: 'acme',
616
+ name: 'Acme Logistics',
617
+ email: 'ops@acme.example',
618
+ balance: 12480,
619
+ status: 'Active',
620
+ owner: 'Marta Silva',
621
+ region: 'Lisbon',
622
+ },
623
+ {
624
+ id: 'borealis',
625
+ name: 'Borealis Foods',
626
+ email: 'buying@borealis.example',
627
+ balance: 3902.15,
628
+ status: 'On hold',
629
+ owner: null,
630
+ region: 'Porto',
631
+ },
632
+ {
633
+ id: 'cobalt',
634
+ name: 'Cobalt Studio',
635
+ email: 'hello@cobalt.example',
636
+ balance: 48120.4,
637
+ status: 'Active',
638
+ owner: 'John Reed',
639
+ region: 'Madrid',
640
+ },
641
+ {
642
+ id: 'dunmore',
643
+ name: 'Dunmore Freight',
644
+ email: 'accounts@dunmore.example',
645
+ balance: 0,
646
+ status: 'Closed',
647
+ owner: 'Rui Neves',
648
+ region: 'Seville',
649
+ },
650
+ {
651
+ id: 'star',
652
+ name: 'Star Pharma',
653
+ email: 'purchasing@star.example',
654
+ balance: 27650.9,
655
+ status: 'Active',
656
+ owner: 'Ana Costa',
657
+ region: 'Lisbon',
658
+ },
659
+ {
660
+ id: 'tailspin',
661
+ name: 'Tailspin Market',
662
+ email: 'orders@tailspin.example',
663
+ balance: 860.5,
664
+ status: 'On hold',
665
+ owner: 'Marta Silva',
666
+ region: 'Porto',
667
+ },
668
+ ];
669
+
670
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
671
+
672
+ const COLUMNS: GridColumn<Account>[] = [
673
+ { id: 'name', label: 'Account', rowHeader: true },
674
+ { id: 'email', label: 'Email' },
675
+ {
676
+ id: 'balance',
677
+ label: 'Balance',
678
+ kind: 'number',
679
+ format: (value) => USD.format(value as number),
680
+ },
681
+ { id: 'status', label: 'Status', priority: 1 },
682
+ { id: 'owner', label: 'Owner', priority: 2 },
683
+ { id: 'region', label: 'Region', priority: 3 },
684
+ ];
685
+
686
+ export default function DataListStatesExample() {
687
+ return (
688
+ <DataList
689
+ activatable
690
+ columns={COLUMNS.slice(0, 3)}
691
+ current="cobalt"
692
+ defaultValue={['acme']}
693
+ disabledKeys={['dunmore']}
694
+ label="Accounts"
695
+ loadingKeys={['borealis']}
696
+ rowKey="id"
697
+ rows={ACCOUNTS.slice(0, 4)}
698
+ selectionMode="multiple"
699
+ subtitle="email"
700
+ trailing="balance"
701
+ />
702
+ );
703
+ }
704
+ ```
705
+
706
+ ### The first load, and a refresh
707
+
708
+ With no rows the loader draws the record’s anatomy: title, subtitle, balance and four fields with their real labels. Over rows already shown a refresh keeps them and dims them; nothing moves.
709
+
710
+ Example
711
+
712
+ ```tsx
713
+ import { useState } from 'react';
714
+
715
+ import type { GridColumn } from '@slotted/core/grid';
716
+ import { Button } from '@slotted/react/button';
717
+ import { DataList } from '@slotted/react/data-list';
718
+ import { Inline } from '@slotted/react/inline';
719
+ import { Stack } from '@slotted/react/stack';
720
+ import { Text } from '@slotted/react/typography';
721
+
722
+ interface Account {
723
+ id: string;
724
+ name: string;
725
+ email: string;
726
+ balance: number;
727
+ status: string;
728
+ owner: string | null;
729
+ region: string;
730
+ }
731
+
732
+ const ACCOUNTS: Account[] = [
733
+ {
734
+ id: 'acme',
735
+ name: 'Acme Logistics',
736
+ email: 'ops@acme.example',
737
+ balance: 12480,
738
+ status: 'Active',
739
+ owner: 'Marta Silva',
740
+ region: 'Lisbon',
741
+ },
742
+ {
743
+ id: 'borealis',
744
+ name: 'Borealis Foods',
745
+ email: 'buying@borealis.example',
746
+ balance: 3902.15,
747
+ status: 'On hold',
748
+ owner: null,
749
+ region: 'Porto',
750
+ },
751
+ {
752
+ id: 'cobalt',
753
+ name: 'Cobalt Studio',
754
+ email: 'hello@cobalt.example',
755
+ balance: 48120.4,
756
+ status: 'Active',
757
+ owner: 'John Reed',
758
+ region: 'Madrid',
759
+ },
760
+ {
761
+ id: 'dunmore',
762
+ name: 'Dunmore Freight',
763
+ email: 'accounts@dunmore.example',
764
+ balance: 0,
765
+ status: 'Closed',
766
+ owner: 'Rui Neves',
767
+ region: 'Seville',
768
+ },
769
+ {
770
+ id: 'star',
771
+ name: 'Star Pharma',
772
+ email: 'purchasing@star.example',
773
+ balance: 27650.9,
774
+ status: 'Active',
775
+ owner: 'Ana Costa',
776
+ region: 'Lisbon',
777
+ },
778
+ {
779
+ id: 'tailspin',
780
+ name: 'Tailspin Market',
781
+ email: 'orders@tailspin.example',
782
+ balance: 860.5,
783
+ status: 'On hold',
784
+ owner: 'Marta Silva',
785
+ region: 'Porto',
786
+ },
787
+ ];
788
+
789
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
790
+
791
+ const COLUMNS: GridColumn<Account>[] = [
792
+ { id: 'name', label: 'Account', rowHeader: true },
793
+ { id: 'email', label: 'Email' },
794
+ {
795
+ id: 'balance',
796
+ label: 'Balance',
797
+ kind: 'number',
798
+ format: (value) => USD.format(value as number),
799
+ },
800
+ { id: 'status', label: 'Status', priority: 1 },
801
+ { id: 'owner', label: 'Owner', priority: 2 },
802
+ { id: 'region', label: 'Region', priority: 3 },
803
+ ];
804
+
805
+ export default function DataListLoadingExample() {
806
+ const [refreshing, setRefreshing] = useState(false);
807
+
808
+ function handleRefresh() {
809
+ setRefreshing(true);
810
+ setTimeout(() => setRefreshing(false), 2500);
811
+ }
812
+
813
+ return (
814
+ <Stack gap={4}>
815
+ <Text size="sm" tone="muted">
816
+ First load, no rows yet
817
+ </Text>
818
+ <DataList
819
+ columns={COLUMNS}
820
+ label="Accounts, first load"
821
+ loading
822
+ rowKey="id"
823
+ rows={[]}
824
+ skeletonRows={3}
825
+ subtitle="email"
826
+ trailing="balance"
827
+ />
828
+
829
+ <Text size="sm" tone="muted">
830
+ Refresh over the rows shown
831
+ </Text>
832
+ <DataList
833
+ columns={COLUMNS.slice(0, 3)}
834
+ label="Accounts, refresh"
835
+ loading={refreshing}
836
+ rowKey="id"
837
+ rows={ACCOUNTS.slice(0, 3)}
838
+ subtitle="email"
839
+ trailing="balance"
840
+ />
841
+ <Inline>
842
+ <Button
843
+ disabled={refreshing}
844
+ size="sm"
845
+ tone="secondary"
846
+ variant="outline"
847
+ onClick={handleRefresh}
848
+ >
849
+ Refresh
850
+ </Button>
851
+ </Inline>
852
+ </Stack>
853
+ );
854
+ }
855
+ ```
856
+
857
+ ### Empty, no results, error
858
+
859
+ Three states, each with its own next step: nothing yet, a query that left nothing and offers Clear filters, and a failure that offers Try again.
860
+
861
+ Excerpt — not a complete module
862
+
863
+ ```tsx
864
+ <DataList error={failed} onRetry={refetch} rows={rows} {...list} />;
865
+ ```
866
+
867
+ ### Load more
868
+
869
+ With hasMore the footer asks for the next page through onLoadMore; the button carries the wait and the list stays readable. The count says how many exist when the server gives totalCount.
870
+
871
+ Example
872
+
873
+ ```tsx
874
+ import { useState } from 'react';
875
+
876
+ import type { GridColumn } from '@slotted/core/grid';
877
+ import { DataList } from '@slotted/react/data-list';
878
+
879
+ interface Account {
880
+ id: string;
881
+ name: string;
882
+ email: string;
883
+ balance: number;
884
+ status: string;
885
+ owner: string | null;
886
+ region: string;
887
+ }
888
+
889
+ const ACCOUNTS: Account[] = [
890
+ {
891
+ id: 'acme',
892
+ name: 'Acme Logistics',
893
+ email: 'ops@acme.example',
894
+ balance: 12480,
895
+ status: 'Active',
896
+ owner: 'Marta Silva',
897
+ region: 'Lisbon',
898
+ },
899
+ {
900
+ id: 'borealis',
901
+ name: 'Borealis Foods',
902
+ email: 'buying@borealis.example',
903
+ balance: 3902.15,
904
+ status: 'On hold',
905
+ owner: null,
906
+ region: 'Porto',
907
+ },
908
+ {
909
+ id: 'cobalt',
910
+ name: 'Cobalt Studio',
911
+ email: 'hello@cobalt.example',
912
+ balance: 48120.4,
913
+ status: 'Active',
914
+ owner: 'John Reed',
915
+ region: 'Madrid',
916
+ },
917
+ {
918
+ id: 'dunmore',
919
+ name: 'Dunmore Freight',
920
+ email: 'accounts@dunmore.example',
921
+ balance: 0,
922
+ status: 'Closed',
923
+ owner: 'Rui Neves',
924
+ region: 'Seville',
925
+ },
926
+ {
927
+ id: 'star',
928
+ name: 'Star Pharma',
929
+ email: 'purchasing@star.example',
930
+ balance: 27650.9,
931
+ status: 'Active',
932
+ owner: 'Ana Costa',
933
+ region: 'Lisbon',
934
+ },
935
+ {
936
+ id: 'tailspin',
937
+ name: 'Tailspin Market',
938
+ email: 'orders@tailspin.example',
939
+ balance: 860.5,
940
+ status: 'On hold',
941
+ owner: 'Marta Silva',
942
+ region: 'Porto',
943
+ },
944
+ ];
945
+
946
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
947
+
948
+ const COLUMNS: GridColumn<Account>[] = [
949
+ { id: 'name', label: 'Account', rowHeader: true },
950
+ { id: 'email', label: 'Email' },
951
+ {
952
+ id: 'balance',
953
+ label: 'Balance',
954
+ kind: 'number',
955
+ format: (value) => USD.format(value as number),
956
+ },
957
+ { id: 'status', label: 'Status', priority: 1 },
958
+ { id: 'owner', label: 'Owner', priority: 2 },
959
+ { id: 'region', label: 'Region', priority: 3 },
960
+ ];
961
+
962
+ const PAGE = 3;
963
+
964
+ export default function DataListLoadMoreExample() {
965
+ const [shown, setShown] = useState(PAGE);
966
+ const [fetching, setFetching] = useState(false);
967
+
968
+ function handleLoadMore() {
969
+ setFetching(true);
970
+ setTimeout(() => {
971
+ setShown((count) => count + PAGE);
972
+ setFetching(false);
973
+ }, 1200);
974
+ }
975
+
976
+ return (
977
+ <DataList
978
+ columns={COLUMNS.slice(0, 3)}
979
+ hasMore={shown < ACCOUNTS.length}
980
+ label="Accounts"
981
+ loading={fetching}
982
+ onLoadMore={handleLoadMore}
983
+ rowKey="id"
984
+ rows={ACCOUNTS.slice(0, shown)}
985
+ subtitle="email"
986
+ totalCount={ACCOUNTS.length}
987
+ trailing="balance"
988
+ />
989
+ );
990
+ }
991
+ ```
992
+
993
+ ### Beside table, on one state
994
+
995
+ createWidthGate at COMPACT_BELOW swaps table and data-list over the same sort and selection. Resize the room: under 600 pixels the list takes over and the chosen accounts stay chosen.
996
+
997
+ Excerpt — not a complete module
998
+
999
+ ```tsx
1000
+ useEffect(() => {
1001
+ const gate = createWidthGate(frame.current!, { at: COMPACT_BELOW, onChange: setCompact });
1002
+ return gate.destroy;
1003
+ }, []);
1004
+
1005
+ return (
1006
+ <div ref={frame}>
1007
+ {compact ? (
1008
+ <DataList query={{ ...query, sort: sort ? [sort] : [] }} value={chosen} {...list} />
1009
+ ) : (
1010
+ <Table selectionMode="multiple" sort={sort} value={chosen}>
1011
+ {rows}
1012
+ </Table>
1013
+ )}
1014
+ </div>
1015
+ );
1016
+ ```
1017
+
1018
+ ### Content the columns did not plan for
1019
+
1020
+ A title in two lines, an address with no break in it, labels a translation made long and a value in another script: the pairs wrap, nothing is cut, and the Arabic value takes its own direction.
1021
+
1022
+ Excerpt — not a complete module
1023
+
1024
+ ```tsx
1025
+ <SlottedProvider catalogs={{ 'pt-BR': PT_BR }} locale="pt-BR">
1026
+ <DataList {...list} messages={{ count: '{count, plural, one {# conta} other {# contas}}' }} />
1027
+ </SlottedProvider>;
1028
+ ```
1029
+
1030
+ ### Keyboard
1031
+
1032
+ Tab moves through select-all, the sort trigger, then each record’s checkbox, title, disclosure and actions. Space toggles a checkbox, Shift+Space extends from the anchor, Enter follows the title. No arrow key is bound.
1033
+
1034
+ Excerpt — not a complete module
1035
+
1036
+ ```tsx
1037
+ const list = useRef<DataListHandle>(null);
1038
+
1039
+ list.current?.focusKey('cobalt');
1040
+ ```
1041
+
1042
+ ### What a reader hears
1043
+
1044
+ The list is named Accounts; each record is a list item whose title is its link; the checkbox is named Select and the title; the count and the sort order are announced politely.
1045
+
1046
+ Excerpt — not a complete module
1047
+
1048
+ ```tsx
1049
+ <h2 id="accounts-heading">Accounts</h2>;
1050
+ <DataList labelledBy="accounts-heading" {...list} />;
1051
+ ```
1052
+
1053
+ ### empty.tsx
1054
+
1055
+ Example
1056
+
1057
+ ```tsx
1058
+ import { useState } from 'react';
1059
+
1060
+ import type { GridColumn, GridQuery } from '@slotted/core/grid';
1061
+ import { DataList } from '@slotted/react/data-list';
1062
+ import { Stack } from '@slotted/react/stack';
1063
+ import { Text } from '@slotted/react/typography';
1064
+
1065
+ interface Account {
1066
+ id: string;
1067
+ name: string;
1068
+ email: string;
1069
+ balance: number;
1070
+ status: string;
1071
+ owner: string | null;
1072
+ region: string;
1073
+ }
1074
+
1075
+ const ACCOUNTS: Account[] = [
1076
+ {
1077
+ id: 'acme',
1078
+ name: 'Acme Logistics',
1079
+ email: 'ops@acme.example',
1080
+ balance: 12480,
1081
+ status: 'Active',
1082
+ owner: 'Marta Silva',
1083
+ region: 'Lisbon',
1084
+ },
1085
+ {
1086
+ id: 'borealis',
1087
+ name: 'Borealis Foods',
1088
+ email: 'buying@borealis.example',
1089
+ balance: 3902.15,
1090
+ status: 'On hold',
1091
+ owner: null,
1092
+ region: 'Porto',
1093
+ },
1094
+ {
1095
+ id: 'cobalt',
1096
+ name: 'Cobalt Studio',
1097
+ email: 'hello@cobalt.example',
1098
+ balance: 48120.4,
1099
+ status: 'Active',
1100
+ owner: 'John Reed',
1101
+ region: 'Madrid',
1102
+ },
1103
+ {
1104
+ id: 'dunmore',
1105
+ name: 'Dunmore Freight',
1106
+ email: 'accounts@dunmore.example',
1107
+ balance: 0,
1108
+ status: 'Closed',
1109
+ owner: 'Rui Neves',
1110
+ region: 'Seville',
1111
+ },
1112
+ {
1113
+ id: 'star',
1114
+ name: 'Star Pharma',
1115
+ email: 'purchasing@star.example',
1116
+ balance: 27650.9,
1117
+ status: 'Active',
1118
+ owner: 'Ana Costa',
1119
+ region: 'Lisbon',
1120
+ },
1121
+ {
1122
+ id: 'tailspin',
1123
+ name: 'Tailspin Market',
1124
+ email: 'orders@tailspin.example',
1125
+ balance: 860.5,
1126
+ status: 'On hold',
1127
+ owner: 'Marta Silva',
1128
+ region: 'Porto',
1129
+ },
1130
+ ];
1131
+
1132
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
1133
+
1134
+ const COLUMNS: GridColumn<Account>[] = [
1135
+ { id: 'name', label: 'Account', rowHeader: true },
1136
+ { id: 'email', label: 'Email' },
1137
+ {
1138
+ id: 'balance',
1139
+ label: 'Balance',
1140
+ kind: 'number',
1141
+ format: (value) => USD.format(value as number),
1142
+ },
1143
+ { id: 'status', label: 'Status', priority: 1 },
1144
+ { id: 'owner', label: 'Owner', priority: 2 },
1145
+ { id: 'region', label: 'Region', priority: 3 },
1146
+ ];
1147
+
1148
+ const NO_MATCH: GridQuery = { sort: [], filter: null, search: 'zzz', page: null, group: [] };
1149
+
1150
+ export default function DataListEmptyExample() {
1151
+ const [failed, setFailed] = useState(true);
1152
+
1153
+ return (
1154
+ <Stack gap={4}>
1155
+ <Text size="sm" tone="muted">
1156
+ No records yet
1157
+ </Text>
1158
+ <DataList columns={COLUMNS} label="New accounts" rowKey="id" rows={[]} />
1159
+
1160
+ <Text size="sm" tone="muted">
1161
+ A search that matches nothing
1162
+ </Text>
1163
+ <DataList
1164
+ columns={COLUMNS}
1165
+ defaultQuery={NO_MATCH}
1166
+ label="Searched accounts"
1167
+ rowKey="id"
1168
+ rows={ACCOUNTS}
1169
+ />
1170
+
1171
+ <Text size="sm" tone="muted">
1172
+ The request failed
1173
+ </Text>
1174
+ <DataList
1175
+ columns={COLUMNS}
1176
+ error={failed}
1177
+ label="Fetched accounts"
1178
+ onRetry={() => setFailed(false)}
1179
+ rowKey="id"
1180
+ rows={failed ? [] : ACCOUNTS.slice(0, 3)}
1181
+ subtitle="email"
1182
+ trailing="balance"
1183
+ />
1184
+ </Stack>
1185
+ );
1186
+ }
1187
+ ```
1188
+
1189
+ ### query.tsx
1190
+
1191
+ Example
1192
+
1193
+ ```tsx
1194
+ import { useState } from 'react';
1195
+
1196
+ import type { GridColumn, GridQuery } from '@slotted/core/grid';
1197
+ import { DataList } from '@slotted/react/data-list';
1198
+ import { Field, FieldLabel } from '@slotted/react/field';
1199
+ import { Stack } from '@slotted/react/stack';
1200
+ import { TextField } from '@slotted/react/text-field';
1201
+ import { Text } from '@slotted/react/typography';
1202
+
1203
+ interface Account {
1204
+ id: string;
1205
+ name: string;
1206
+ email: string;
1207
+ balance: number;
1208
+ status: string;
1209
+ owner: string | null;
1210
+ region: string;
1211
+ }
1212
+
1213
+ const ACCOUNTS: Account[] = [
1214
+ {
1215
+ id: 'acme',
1216
+ name: 'Acme Logistics',
1217
+ email: 'ops@acme.example',
1218
+ balance: 12480,
1219
+ status: 'Active',
1220
+ owner: 'Marta Silva',
1221
+ region: 'Lisbon',
1222
+ },
1223
+ {
1224
+ id: 'borealis',
1225
+ name: 'Borealis Foods',
1226
+ email: 'buying@borealis.example',
1227
+ balance: 3902.15,
1228
+ status: 'On hold',
1229
+ owner: null,
1230
+ region: 'Porto',
1231
+ },
1232
+ {
1233
+ id: 'cobalt',
1234
+ name: 'Cobalt Studio',
1235
+ email: 'hello@cobalt.example',
1236
+ balance: 48120.4,
1237
+ status: 'Active',
1238
+ owner: 'John Reed',
1239
+ region: 'Madrid',
1240
+ },
1241
+ {
1242
+ id: 'dunmore',
1243
+ name: 'Dunmore Freight',
1244
+ email: 'accounts@dunmore.example',
1245
+ balance: 0,
1246
+ status: 'Closed',
1247
+ owner: 'Rui Neves',
1248
+ region: 'Seville',
1249
+ },
1250
+ {
1251
+ id: 'star',
1252
+ name: 'Star Pharma',
1253
+ email: 'purchasing@star.example',
1254
+ balance: 27650.9,
1255
+ status: 'Active',
1256
+ owner: 'Ana Costa',
1257
+ region: 'Lisbon',
1258
+ },
1259
+ {
1260
+ id: 'tailspin',
1261
+ name: 'Tailspin Market',
1262
+ email: 'orders@tailspin.example',
1263
+ balance: 860.5,
1264
+ status: 'On hold',
1265
+ owner: 'Marta Silva',
1266
+ region: 'Porto',
1267
+ },
1268
+ ];
1269
+
1270
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
1271
+
1272
+ const COLUMNS: GridColumn<Account>[] = [
1273
+ { id: 'name', label: 'Account', rowHeader: true },
1274
+ { id: 'email', label: 'Email' },
1275
+ {
1276
+ id: 'balance',
1277
+ label: 'Balance',
1278
+ kind: 'number',
1279
+ format: (value) => USD.format(value as number),
1280
+ },
1281
+ { id: 'status', label: 'Status', priority: 1 },
1282
+ { id: 'owner', label: 'Owner', priority: 2 },
1283
+ { id: 'region', label: 'Region', priority: 3 },
1284
+ ];
1285
+
1286
+ const EMPTY_QUERY: GridQuery = { sort: [], filter: null, search: '', page: null, group: [] };
1287
+
1288
+ export default function DataListQueryExample() {
1289
+ const [query, setQuery] = useState<GridQuery>(EMPTY_QUERY);
1290
+ const [first] = query.sort;
1291
+
1292
+ return (
1293
+ <Stack gap={3}>
1294
+ <Field>
1295
+ <FieldLabel>Search accounts</FieldLabel>
1296
+ <TextField
1297
+ onValueChange={(search) => setQuery({ ...query, search })}
1298
+ value={query.search}
1299
+ />
1300
+ </Field>
1301
+ <DataList
1302
+ columns={COLUMNS}
1303
+ label="Accounts"
1304
+ onQueryChange={setQuery}
1305
+ query={query}
1306
+ rowKey="id"
1307
+ rows={ACCOUNTS}
1308
+ subtitle="email"
1309
+ trailing="balance"
1310
+ />
1311
+
1312
+ <Text size="sm" tone="muted">
1313
+ Sort: {first ? `${first.column}, ${first.direction}` : 'none'}
1314
+ </Text>
1315
+ </Stack>
1316
+ );
1317
+ }
1318
+ ```
1319
+
1320
+ ### sizes.tsx
1321
+
1322
+ Example
1323
+
1324
+ ```tsx
1325
+ import type { GridColumn } from '@slotted/core/grid';
1326
+ import { DataList } from '@slotted/react/data-list';
1327
+ import { Stack } from '@slotted/react/stack';
1328
+ import { Text } from '@slotted/react/typography';
1329
+
1330
+ interface Account {
1331
+ id: string;
1332
+ name: string;
1333
+ email: string;
1334
+ balance: number;
1335
+ status: string;
1336
+ owner: string | null;
1337
+ region: string;
1338
+ }
1339
+
1340
+ const ACCOUNTS: Account[] = [
1341
+ {
1342
+ id: 'acme',
1343
+ name: 'Acme Logistics',
1344
+ email: 'ops@acme.example',
1345
+ balance: 12480,
1346
+ status: 'Active',
1347
+ owner: 'Marta Silva',
1348
+ region: 'Lisbon',
1349
+ },
1350
+ {
1351
+ id: 'borealis',
1352
+ name: 'Borealis Foods',
1353
+ email: 'buying@borealis.example',
1354
+ balance: 3902.15,
1355
+ status: 'On hold',
1356
+ owner: null,
1357
+ region: 'Porto',
1358
+ },
1359
+ {
1360
+ id: 'cobalt',
1361
+ name: 'Cobalt Studio',
1362
+ email: 'hello@cobalt.example',
1363
+ balance: 48120.4,
1364
+ status: 'Active',
1365
+ owner: 'John Reed',
1366
+ region: 'Madrid',
1367
+ },
1368
+ {
1369
+ id: 'dunmore',
1370
+ name: 'Dunmore Freight',
1371
+ email: 'accounts@dunmore.example',
1372
+ balance: 0,
1373
+ status: 'Closed',
1374
+ owner: 'Rui Neves',
1375
+ region: 'Seville',
1376
+ },
1377
+ {
1378
+ id: 'star',
1379
+ name: 'Star Pharma',
1380
+ email: 'purchasing@star.example',
1381
+ balance: 27650.9,
1382
+ status: 'Active',
1383
+ owner: 'Ana Costa',
1384
+ region: 'Lisbon',
1385
+ },
1386
+ {
1387
+ id: 'tailspin',
1388
+ name: 'Tailspin Market',
1389
+ email: 'orders@tailspin.example',
1390
+ balance: 860.5,
1391
+ status: 'On hold',
1392
+ owner: 'Marta Silva',
1393
+ region: 'Porto',
1394
+ },
1395
+ ];
1396
+
1397
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
1398
+
1399
+ const COLUMNS: GridColumn<Account>[] = [
1400
+ { id: 'name', label: 'Account', rowHeader: true },
1401
+ { id: 'email', label: 'Email' },
1402
+ {
1403
+ id: 'balance',
1404
+ label: 'Balance',
1405
+ kind: 'number',
1406
+ format: (value) => USD.format(value as number),
1407
+ },
1408
+ { id: 'status', label: 'Status', priority: 1 },
1409
+ { id: 'owner', label: 'Owner', priority: 2 },
1410
+ { id: 'region', label: 'Region', priority: 3 },
1411
+ ];
1412
+
1413
+ const SIZES = ['sm', 'md', 'lg'] as const;
1414
+
1415
+ export default function DataListSizesExample() {
1416
+ return (
1417
+ <Stack gap={4}>
1418
+ {SIZES.map((size) => (
1419
+ <Stack gap={2} key={size}>
1420
+ <Text size="sm" tone="muted">
1421
+ {size}
1422
+ </Text>
1423
+ <DataList
1424
+ columns={COLUMNS.slice(0, 3)}
1425
+ label={`Accounts, ${size}`}
1426
+ rowKey="id"
1427
+ rows={ACCOUNTS.slice(0, 2)}
1428
+ size={size}
1429
+ subtitle="email"
1430
+ trailing="balance"
1431
+ />
1432
+ </Stack>
1433
+ ))}
1434
+ </Stack>
1435
+ );
1436
+ }
1437
+ ```
1438
+
1439
+ ### variants.tsx
1440
+
1441
+ Example
1442
+
1443
+ ```tsx
1444
+ import type { GridColumn } from '@slotted/core/grid';
1445
+ import { DataList } from '@slotted/react/data-list';
1446
+ import { Stack } from '@slotted/react/stack';
1447
+ import { Text } from '@slotted/react/typography';
1448
+
1449
+ interface Account {
1450
+ id: string;
1451
+ name: string;
1452
+ email: string;
1453
+ balance: number;
1454
+ status: string;
1455
+ owner: string | null;
1456
+ region: string;
1457
+ }
1458
+
1459
+ const ACCOUNTS: Account[] = [
1460
+ {
1461
+ id: 'acme',
1462
+ name: 'Acme Logistics',
1463
+ email: 'ops@acme.example',
1464
+ balance: 12480,
1465
+ status: 'Active',
1466
+ owner: 'Marta Silva',
1467
+ region: 'Lisbon',
1468
+ },
1469
+ {
1470
+ id: 'borealis',
1471
+ name: 'Borealis Foods',
1472
+ email: 'buying@borealis.example',
1473
+ balance: 3902.15,
1474
+ status: 'On hold',
1475
+ owner: null,
1476
+ region: 'Porto',
1477
+ },
1478
+ {
1479
+ id: 'cobalt',
1480
+ name: 'Cobalt Studio',
1481
+ email: 'hello@cobalt.example',
1482
+ balance: 48120.4,
1483
+ status: 'Active',
1484
+ owner: 'John Reed',
1485
+ region: 'Madrid',
1486
+ },
1487
+ {
1488
+ id: 'dunmore',
1489
+ name: 'Dunmore Freight',
1490
+ email: 'accounts@dunmore.example',
1491
+ balance: 0,
1492
+ status: 'Closed',
1493
+ owner: 'Rui Neves',
1494
+ region: 'Seville',
1495
+ },
1496
+ {
1497
+ id: 'star',
1498
+ name: 'Star Pharma',
1499
+ email: 'purchasing@star.example',
1500
+ balance: 27650.9,
1501
+ status: 'Active',
1502
+ owner: 'Ana Costa',
1503
+ region: 'Lisbon',
1504
+ },
1505
+ {
1506
+ id: 'tailspin',
1507
+ name: 'Tailspin Market',
1508
+ email: 'orders@tailspin.example',
1509
+ balance: 860.5,
1510
+ status: 'On hold',
1511
+ owner: 'Marta Silva',
1512
+ region: 'Porto',
1513
+ },
1514
+ ];
1515
+
1516
+ const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
1517
+
1518
+ const COLUMNS: GridColumn<Account>[] = [
1519
+ { id: 'name', label: 'Account', rowHeader: true },
1520
+ { id: 'email', label: 'Email' },
1521
+ {
1522
+ id: 'balance',
1523
+ label: 'Balance',
1524
+ kind: 'number',
1525
+ format: (value) => USD.format(value as number),
1526
+ },
1527
+ { id: 'status', label: 'Status', priority: 1 },
1528
+ { id: 'owner', label: 'Owner', priority: 2 },
1529
+ { id: 'region', label: 'Region', priority: 3 },
1530
+ ];
1531
+
1532
+ const VARIANTS = ['plain', 'ruled', 'framed'] as const;
1533
+
1534
+ export default function DataListVariantsExample() {
1535
+ return (
1536
+ <Stack gap={4}>
1537
+ {VARIANTS.map((variant) => (
1538
+ <Stack gap={2} key={variant}>
1539
+ <Text size="sm" tone="muted">
1540
+ {variant}
1541
+ </Text>
1542
+ <DataList
1543
+ columns={COLUMNS.slice(0, 3)}
1544
+ label={`Accounts, ${variant}`}
1545
+ rowKey="id"
1546
+ rows={ACCOUNTS.slice(0, 2)}
1547
+ subtitle="email"
1548
+ trailing="balance"
1549
+ variant={variant}
1550
+ />
1551
+ </Stack>
1552
+ ))}
1553
+ </Stack>
1554
+ );
1555
+ }
1556
+ ```