basalt-ui 2.27.2 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/CHANGELOG.md +466 -307
  2. package/MIGRATING.md +358 -12
  3. package/agent/rules/basalt-batteries.md +1 -1
  4. package/agent/rules/basalt-mantine.md +1 -1
  5. package/agent/rules/basalt-tokens.md +2 -2
  6. package/agent/skills/basalt-app/SKILL.md +3 -3
  7. package/agent/skills/basalt-charts/SKILL.md +1 -1
  8. package/agent/skills/basalt-design/SKILL.md +12 -6
  9. package/agent/skills/basalt-design/references/catalogue.md +42 -36
  10. package/agent/skills/basalt-design/references/recipes.md +47 -0
  11. package/agent/skills/basalt-design/references/states.md +1 -1
  12. package/configs/oxlint-basalt.json +2 -1
  13. package/configs/oxlint-plugin.js +112 -3
  14. package/configs/oxlint-plugin.test.ts +99 -4
  15. package/configs/oxlint.json +1 -0
  16. package/dist/agent/chat/thread-message.d.ts +1 -160
  17. package/dist/agent/chat/thread-message.d.ts.map +1 -1
  18. package/dist/agent/chat/thread-message.js +7 -162
  19. package/dist/agent/chat/virtualize.d.ts +5 -5
  20. package/dist/charts/ChartCard.d.ts +14 -7
  21. package/dist/charts/ChartCard.d.ts.map +1 -1
  22. package/dist/charts/ChartCard.js +112 -23
  23. package/dist/charts/Lines.d.ts.map +1 -1
  24. package/dist/charts/Lines.js +11 -4
  25. package/dist/charts/Sparkline.d.ts +14 -2
  26. package/dist/charts/Sparkline.d.ts.map +1 -1
  27. package/dist/charts/Sparkline.js +155 -44
  28. package/dist/charts/chart-box.module.css +59 -2
  29. package/dist/charts/chart-box.module.css.d.ts +5 -0
  30. package/dist/charts/chart-card.module.css +28 -17
  31. package/dist/charts/chart-card.module.css.d.ts +3 -0
  32. package/dist/charts/compile.d.ts +1 -1
  33. package/dist/charts/compile.d.ts.map +1 -1
  34. package/dist/charts/compile.js +38 -27
  35. package/dist/charts/labels.d.ts +13 -3
  36. package/dist/charts/labels.d.ts.map +1 -1
  37. package/dist/charts/labels.js +131 -20
  38. package/dist/charts/legend.d.ts.map +1 -1
  39. package/dist/charts/legend.js +1 -1
  40. package/dist/charts/ref-label.d.ts +37 -8
  41. package/dist/charts/ref-label.d.ts.map +1 -1
  42. package/dist/charts/ref-label.js +55 -10
  43. package/dist/charts/sparkline.module.css +50 -0
  44. package/dist/charts/sparkline.module.css.d.ts +3 -0
  45. package/dist/charts/state.d.ts +4 -4
  46. package/dist/charts/state.d.ts.map +1 -1
  47. package/dist/charts/state.js +23 -5
  48. package/dist/cli/doctor-upgrade.d.ts +11 -0
  49. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  50. package/dist/cli/doctor-upgrade.js +54 -0
  51. package/dist/cli/doctor.d.ts.map +1 -1
  52. package/dist/cli/doctor.js +32 -0
  53. package/dist/cli/help.d.ts.map +1 -1
  54. package/dist/cli/help.js +8 -3
  55. package/dist/cli/index.d.ts +13 -13
  56. package/dist/cli/index.d.ts.map +1 -1
  57. package/dist/cli/index.js +36 -2
  58. package/dist/cli/init.d.ts +6 -0
  59. package/dist/cli/init.d.ts.map +1 -1
  60. package/dist/cli/init.js +118 -27
  61. package/dist/cli/router-wiring.d.ts +3 -0
  62. package/dist/cli/router-wiring.d.ts.map +1 -1
  63. package/dist/cli/router-wiring.js +2 -0
  64. package/dist/cli/shot/capture.d.ts +34 -2
  65. package/dist/cli/shot/capture.d.ts.map +1 -1
  66. package/dist/cli/shot/capture.js +95 -12
  67. package/dist/cli/shot/detect.d.ts +4 -1
  68. package/dist/cli/shot/detect.d.ts.map +1 -1
  69. package/dist/cli/shot/detect.js +38 -16
  70. package/dist/cli/shot/index.d.ts.map +1 -1
  71. package/dist/cli/shot/index.js +9 -2
  72. package/dist/cli/shot/measure.d.ts.map +1 -1
  73. package/dist/cli/shot/measure.js +11 -2
  74. package/dist/cli/shot/types.d.ts +4 -1
  75. package/dist/cli/shot/types.d.ts.map +1 -1
  76. package/dist/cli/sync.d.ts.map +1 -1
  77. package/dist/cli/sync.js +10 -2
  78. package/dist/common/could-not-load.d.ts +13 -0
  79. package/dist/common/could-not-load.d.ts.map +1 -0
  80. package/dist/common/could-not-load.js +14 -0
  81. package/dist/common/empty-copy.d.ts +16 -0
  82. package/dist/common/empty-copy.d.ts.map +1 -0
  83. package/dist/common/empty-copy.js +9 -0
  84. package/dist/common/index.d.ts +1 -0
  85. package/dist/common/index.d.ts.map +1 -1
  86. package/dist/common/index.js +3 -0
  87. package/dist/common/props.d.ts +20 -0
  88. package/dist/common/props.d.ts.map +1 -1
  89. package/dist/common/props.js +13 -1
  90. package/dist/common/retry-button.module.css +7 -3
  91. package/dist/common/virtual-rows.d.ts +196 -0
  92. package/dist/common/virtual-rows.d.ts.map +1 -0
  93. package/dist/common/virtual-rows.js +290 -0
  94. package/dist/controls/controls.module.css +33 -1
  95. package/dist/controls/controls.module.css.d.ts +2 -0
  96. package/dist/controls/enum-filter.d.ts.map +1 -1
  97. package/dist/controls/enum-filter.js +8 -2
  98. package/dist/controls/filter-pill.d.ts +27 -3
  99. package/dist/controls/filter-pill.d.ts.map +1 -1
  100. package/dist/controls/filter-pill.js +15 -4
  101. package/dist/controls/form-layout.d.ts +9 -3
  102. package/dist/controls/form-layout.d.ts.map +1 -1
  103. package/dist/controls/form-layout.js +74 -12
  104. package/dist/controls/form-layout.module.css +112 -7
  105. package/dist/controls/form-layout.module.css.d.ts +1 -0
  106. package/dist/controls/multi-select-filter.d.ts +2 -2
  107. package/dist/controls/multi-select-filter.d.ts.map +1 -1
  108. package/dist/controls/multi-select-filter.js +12 -6
  109. package/dist/controls/range-filter.d.ts +1 -1
  110. package/dist/controls/range-filter.d.ts.map +1 -1
  111. package/dist/controls/range-filter.js +8 -2
  112. package/dist/dashboard/bar-list.d.ts +5 -5
  113. package/dist/dashboard/bar-list.d.ts.map +1 -1
  114. package/dist/dashboard/bar-list.js +15 -8
  115. package/dist/dashboard/bar-list.module.css +21 -5
  116. package/dist/dashboard/board-nav.d.ts +22 -0
  117. package/dist/dashboard/board-nav.d.ts.map +1 -0
  118. package/dist/dashboard/board-nav.js +49 -0
  119. package/dist/dashboard/board.d.ts +52 -0
  120. package/dist/dashboard/board.d.ts.map +1 -0
  121. package/dist/dashboard/board.js +247 -0
  122. package/dist/dashboard/board.module.css +179 -0
  123. package/dist/dashboard/board.module.css.d.ts +28 -0
  124. package/dist/dashboard/empty-state.d.ts +6 -6
  125. package/dist/dashboard/empty-state.d.ts.map +1 -1
  126. package/dist/dashboard/empty-state.js +17 -8
  127. package/dist/dashboard/event-list-model.d.ts +54 -0
  128. package/dist/dashboard/event-list-model.d.ts.map +1 -0
  129. package/dist/dashboard/event-list-model.js +76 -0
  130. package/dist/dashboard/event-list-rows.d.ts +23 -0
  131. package/dist/dashboard/event-list-rows.d.ts.map +1 -0
  132. package/dist/dashboard/event-list-rows.js +89 -0
  133. package/dist/dashboard/event-list-scroll.d.ts +55 -0
  134. package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
  135. package/dist/dashboard/event-list-scroll.js +216 -0
  136. package/dist/dashboard/event-list-skeleton.d.ts +10 -0
  137. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
  138. package/dist/dashboard/event-list-skeleton.js +34 -0
  139. package/dist/dashboard/event-list.d.ts +65 -0
  140. package/dist/dashboard/event-list.d.ts.map +1 -0
  141. package/dist/dashboard/event-list.js +208 -0
  142. package/dist/dashboard/event-list.module.css +336 -0
  143. package/dist/dashboard/event-list.module.css.d.ts +34 -0
  144. package/dist/dashboard/index.d.ts +2 -0
  145. package/dist/dashboard/index.d.ts.map +1 -1
  146. package/dist/dashboard/index.js +4 -0
  147. package/dist/dashboard/meter-model.d.ts +6 -3
  148. package/dist/dashboard/meter-model.d.ts.map +1 -1
  149. package/dist/dashboard/meter-model.js +9 -4
  150. package/dist/dashboard/meter-parts.d.ts +3 -0
  151. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  152. package/dist/dashboard/meter-parts.js +36 -6
  153. package/dist/dashboard/meter.d.ts +3 -3
  154. package/dist/dashboard/meter.d.ts.map +1 -1
  155. package/dist/dashboard/meter.js +10 -2
  156. package/dist/dashboard/meter.module.css +20 -12
  157. package/dist/dashboard/meter.module.css.d.ts +0 -1
  158. package/dist/dashboard/page-summary.d.ts +3 -3
  159. package/dist/dashboard/page-summary.d.ts.map +1 -1
  160. package/dist/dashboard/page-summary.js +7 -2
  161. package/dist/dashboard/page-summary.module.css +5 -2
  162. package/dist/dashboard/query-state.d.ts +9 -8
  163. package/dist/dashboard/query-state.d.ts.map +1 -1
  164. package/dist/dashboard/query-state.js +29 -11
  165. package/dist/dashboard/section.d.ts +11 -3
  166. package/dist/dashboard/section.d.ts.map +1 -1
  167. package/dist/dashboard/section.js +34 -7
  168. package/dist/dashboard/settings-section.d.ts +8 -5
  169. package/dist/dashboard/settings-section.d.ts.map +1 -1
  170. package/dist/dashboard/settings-section.js +12 -8
  171. package/dist/dashboard/settings-section.module.css +25 -4
  172. package/dist/dashboard/settings-section.module.css.d.ts +1 -0
  173. package/dist/dashboard/stat-card-parts.d.ts +5 -1
  174. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  175. package/dist/dashboard/stat-card-parts.js +8 -3
  176. package/dist/dashboard/stat-card.d.ts +3 -3
  177. package/dist/dashboard/stat-card.d.ts.map +1 -1
  178. package/dist/dashboard/stat-card.js +47 -12
  179. package/dist/dashboard/stat-card.module.css +42 -7
  180. package/dist/dashboard/stat-card.module.css.d.ts +3 -0
  181. package/dist/dashboard/stat-group.d.ts +2 -2
  182. package/dist/dashboard/stat-group.d.ts.map +1 -1
  183. package/dist/dashboard/stat-group.js +10 -3
  184. package/dist/dashboard/stat-strip.d.ts +5 -4
  185. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  186. package/dist/dashboard/stat-strip.js +41 -31
  187. package/dist/dashboard/stat-strip.module.css +8 -6
  188. package/dist/dashboard/visual-slot.d.ts +4 -0
  189. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  190. package/dist/dashboard/visual-slot.js +2 -0
  191. package/dist/dashboard/widget-header.d.ts +6 -6
  192. package/dist/dashboard/widget-header.d.ts.map +1 -1
  193. package/dist/dashboard/widget-header.js +4 -2
  194. package/dist/dashboard/widget-header.module.css +12 -15
  195. package/dist/format/shared.d.ts.map +1 -1
  196. package/dist/format/shared.js +24 -1
  197. package/dist/guard/index.d.ts +1 -1
  198. package/dist/guard/index.d.ts.map +1 -1
  199. package/dist/guard/index.js +4 -1
  200. package/dist/index.d.ts +1 -1
  201. package/dist/index.d.ts.map +1 -1
  202. package/dist/index.js +4 -0
  203. package/dist/shell/app-main.module.css +18 -0
  204. package/dist/styles.css +69 -0
  205. package/dist/surfaces.d.ts +2 -2
  206. package/dist/surfaces.d.ts.map +1 -1
  207. package/dist/surfaces.js +8 -2
  208. package/dist/table/cell-kinds.d.ts +47 -0
  209. package/dist/table/cell-kinds.d.ts.map +1 -0
  210. package/dist/table/cell-kinds.js +180 -0
  211. package/dist/table/cell-kinds.module.css +55 -0
  212. package/dist/table/cell-kinds.module.css.d.ts +15 -0
  213. package/dist/table/data-table-fold.d.ts +155 -0
  214. package/dist/table/data-table-fold.d.ts.map +1 -0
  215. package/dist/table/data-table-fold.js +320 -0
  216. package/dist/table/data-table-state.d.ts +10 -3
  217. package/dist/table/data-table-state.d.ts.map +1 -1
  218. package/dist/table/data-table-state.js +11 -6
  219. package/dist/table/data-table.d.ts +13 -28
  220. package/dist/table/data-table.d.ts.map +1 -1
  221. package/dist/table/data-table.js +362 -255
  222. package/dist/table/data-table.module.css +282 -3
  223. package/dist/table/data-table.module.css.d.ts +16 -0
  224. package/dist/table/table-features.d.ts +34 -4
  225. package/dist/table/table-features.d.ts.map +1 -1
  226. package/dist/table/table-features.js +10 -0
  227. package/dist/theme/card-inset.module.css +35 -0
  228. package/dist/theme/controls.module.css +55 -2
  229. package/dist/theme/ctl-theme.d.ts.map +1 -1
  230. package/dist/theme/ctl-theme.js +5 -0
  231. package/dist/theme/index.d.ts.map +1 -1
  232. package/dist/theme/index.js +14 -10
  233. package/dist/tokens/core.d.ts +1 -0
  234. package/dist/tokens/core.d.ts.map +1 -1
  235. package/dist/tokens/core.js +1 -0
  236. package/dist/tokens/derive.js +1 -1
  237. package/dist/tokens/palette.d.ts +2 -1
  238. package/dist/tokens/palette.d.ts.map +1 -1
  239. package/llms.txt +295 -5
  240. package/package.json +1 -1
  241. package/src/agent/chat/thread-message.tsx +10 -403
  242. package/src/agent/chat/virtualize.ts +5 -5
  243. package/src/charts/ChartCard.tsx +175 -31
  244. package/src/charts/Lines.tsx +13 -4
  245. package/src/charts/Sparkline.tsx +213 -48
  246. package/src/charts/chart-box.module.css +59 -2
  247. package/src/charts/chart-box.module.css.d.ts +5 -0
  248. package/src/charts/chart-card.module.css +28 -17
  249. package/src/charts/chart-card.module.css.d.ts +3 -0
  250. package/src/charts/compile.ts +59 -33
  251. package/src/charts/labels.ts +175 -24
  252. package/src/charts/legend.tsx +3 -2
  253. package/src/charts/ref-label.ts +114 -18
  254. package/src/charts/sparkline.module.css +50 -0
  255. package/src/charts/sparkline.module.css.d.ts +3 -0
  256. package/src/charts/state.tsx +40 -10
  257. package/src/cli/doctor-upgrade.ts +75 -0
  258. package/src/cli/doctor.ts +36 -0
  259. package/src/cli/help.ts +16 -6
  260. package/src/cli/index.ts +73 -67
  261. package/src/cli/init.ts +157 -36
  262. package/src/cli/router-wiring.ts +2 -2
  263. package/src/cli/shot/capture.ts +138 -16
  264. package/src/cli/shot/detect.ts +46 -22
  265. package/src/cli/shot/index.ts +8 -2
  266. package/src/cli/shot/measure.ts +11 -2
  267. package/src/cli/shot/types.ts +4 -1
  268. package/src/cli/sync.ts +12 -2
  269. package/src/common/could-not-load.ts +22 -0
  270. package/src/common/empty-copy.ts +17 -0
  271. package/src/common/index.ts +1 -0
  272. package/src/common/props.ts +30 -0
  273. package/src/common/retry-button.module.css +7 -3
  274. package/src/common/virtual-rows.tsx +682 -0
  275. package/src/controls/controls.module.css +33 -1
  276. package/src/controls/controls.module.css.d.ts +2 -0
  277. package/src/controls/enum-filter.tsx +8 -2
  278. package/src/controls/filter-pill.tsx +80 -27
  279. package/src/controls/form-layout.module.css +112 -7
  280. package/src/controls/form-layout.module.css.d.ts +1 -0
  281. package/src/controls/form-layout.tsx +115 -22
  282. package/src/controls/multi-select-filter.tsx +22 -11
  283. package/src/controls/range-filter.tsx +9 -3
  284. package/src/dashboard/bar-list.module.css +21 -5
  285. package/src/dashboard/bar-list.tsx +53 -45
  286. package/src/dashboard/board-nav.ts +67 -0
  287. package/src/dashboard/board.module.css +179 -0
  288. package/src/dashboard/board.module.css.d.ts +28 -0
  289. package/src/dashboard/board.tsx +415 -0
  290. package/src/dashboard/empty-state.tsx +21 -11
  291. package/src/dashboard/event-list-model.ts +125 -0
  292. package/src/dashboard/event-list-rows.tsx +117 -0
  293. package/src/dashboard/event-list-scroll.ts +291 -0
  294. package/src/dashboard/event-list-skeleton.tsx +62 -0
  295. package/src/dashboard/event-list.module.css +336 -0
  296. package/src/dashboard/event-list.module.css.d.ts +34 -0
  297. package/src/dashboard/event-list.tsx +336 -0
  298. package/src/dashboard/index.ts +2 -0
  299. package/src/dashboard/meter-model.ts +16 -7
  300. package/src/dashboard/meter-parts.tsx +53 -14
  301. package/src/dashboard/meter.module.css +20 -12
  302. package/src/dashboard/meter.module.css.d.ts +0 -1
  303. package/src/dashboard/meter.tsx +36 -18
  304. package/src/dashboard/page-summary.module.css +5 -2
  305. package/src/dashboard/page-summary.tsx +13 -6
  306. package/src/dashboard/query-state.tsx +55 -30
  307. package/src/dashboard/section.tsx +83 -41
  308. package/src/dashboard/settings-section.module.css +25 -4
  309. package/src/dashboard/settings-section.module.css.d.ts +1 -0
  310. package/src/dashboard/settings-section.tsx +18 -8
  311. package/src/dashboard/stat-card-parts.tsx +20 -3
  312. package/src/dashboard/stat-card.module.css +42 -7
  313. package/src/dashboard/stat-card.module.css.d.ts +3 -0
  314. package/src/dashboard/stat-card.tsx +55 -13
  315. package/src/dashboard/stat-group.tsx +22 -14
  316. package/src/dashboard/stat-strip.module.css +8 -6
  317. package/src/dashboard/stat-strip.tsx +29 -20
  318. package/src/dashboard/visual-slot.ts +5 -0
  319. package/src/dashboard/widget-header.module.css +12 -15
  320. package/src/dashboard/widget-header.tsx +8 -5
  321. package/src/format/shared.ts +30 -1
  322. package/src/guard/index.ts +7 -1
  323. package/src/index.ts +4 -0
  324. package/src/shell/app-main.module.css +18 -0
  325. package/src/styles.css +69 -0
  326. package/src/surfaces.ts +7 -1
  327. package/src/table/cell-kinds.module.css +55 -0
  328. package/src/table/cell-kinds.module.css.d.ts +15 -0
  329. package/src/table/cell-kinds.tsx +263 -0
  330. package/src/table/data-table-fold.tsx +567 -0
  331. package/src/table/data-table-state.ts +24 -13
  332. package/src/table/data-table.module.css +282 -3
  333. package/src/table/data-table.module.css.d.ts +16 -0
  334. package/src/table/data-table.tsx +430 -362
  335. package/src/table/table-features.ts +44 -4
  336. package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
  337. package/src/theme/card-inset.module.css +35 -0
  338. package/src/theme/controls.module.css +55 -2
  339. package/src/theme/ctl-theme.tsx +8 -0
  340. package/src/theme/index.ts +12 -8
  341. package/src/tokens/core.ts +1 -0
  342. package/src/tokens/derive.ts +1 -1
  343. package/src/tokens/palette.ts +4 -1
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Board — status columns of cards (docs/waves/design-parity/SPEC.md § 6.8): a column header (status
3
+ * dot, title, count, right-aligned `total`), then cards stacked 6 px apart, each column scrolling alone
4
+ * inside a `ScrollArea` bounded by `height`. Choose it for work that moves through states (a queue
5
+ * of agent runs, a review pipeline); a table is for comparing rows. No drag and drop: a card changes
6
+ * column when its data does.
7
+ *
8
+ * Cards are typed data: a caption (`actor · type`), a `title`, an optional linked `record`, a `status`
9
+ * line and one optional `meter` slot. `record.href` renders as a link only when it is http(s) or
10
+ * relative; anything else stays text. The theme owns the card's inset, radius and surface.
11
+ *
12
+ * Keyboard: the board is one tab stop (roving tabindex). ArrowUp/Down and Home/End move within a
13
+ * column; ArrowLeft/Right jump to the nearest non-empty column on the same row index (clamped to its
14
+ * last card). Enter and Space call `onOpen`, and so does a click anywhere on the card. A polite live
15
+ * region announces "<column>, card i of n: <title>" on every move.
16
+ *
17
+ * Semantics: each column is a `role="group"` named by its title and count, its cards a `list` of
18
+ * `listitem`s; the focusable element is one `button` per card, named by the card title (its
19
+ * `::after` stretches over the card, so the whole card is the target). No `grid` role.
20
+ *
21
+ * Compact (`useSizeClass() === 'compact'`): one column at a time under a `SegmentedControl` labelled
22
+ * "<title> <count>" (not `ViewTabs`: past three options it becomes a `Select` on a phone, and the
23
+ * board's switcher is always the track). The selected column is a store field when you pass `field` (an enum field whose
24
+ * values are column ids, like `ViewTabs`'s; the URL or storage then remembers it), else internal
25
+ * state. An empty column and an empty board are both `EmptyState` tiles (`empty` on the column
26
+ * or the board); `loading` is column-shaped skeletons. An error is the caller's: put the board in a `Section` with `query`.
27
+ *
28
+ * @example
29
+ * import { Board } from 'basalt-ui'
30
+ *
31
+ * <Board
32
+ * label="Warden board"
33
+ * height={480}
34
+ * onOpen={(id) => openTimeline(id)}
35
+ * columns={[
36
+ * { id: 'needs', title: 'Needs you', tone: VX.status.warn, total: '3 items', cards: [
37
+ * { id: '41', actor: 'warden', type: 'PR review', title: 'Fix the cache key', record: { label: '#482', href: url }, status: 'Waiting 2 h' },
38
+ * ] },
39
+ * { id: 'done', title: 'Done', empty: 'Nothing finished today', cards: [] },
40
+ * ]}
41
+ * />
42
+ */
43
+ import { ScrollArea, SegmentedControl, Skeleton, Card, VisuallyHidden } from '@mantine/core'
44
+ import { Fragment, useEffect, useId, useRef, useState } from 'react'
45
+ import type { KeyboardEvent, ReactNode } from 'react'
46
+ import { cx, pickDataAttributes } from '../common/props'
47
+ import type { BasaltProps, DataAttributes } from '../common/props'
48
+ import { useSizeClass } from '../shell/use-size-class'
49
+ import type { EnumField, FieldHandle } from '../state'
50
+ import { StatusDot } from '../theme/status-dot'
51
+ import { VX } from '../tokens'
52
+ import classes from './board.module.css'
53
+ import { isBoardKey, isSafeHref, moveOnBoard } from './board-nav'
54
+ import type { BoardPos } from './board-nav'
55
+ import { EmptyState } from './empty-state'
56
+ import { useScrolledEdge } from './event-list-scroll'
57
+
58
+ export type BoardProps<T extends string = string> = BasaltProps &
59
+ DataAttributes & {
60
+ /** Accessible name of the board. Default "Board". */
61
+ label?: string
62
+ /** Columns in display order. Column and card `id`s must be unique within their parent. */
63
+ columns: readonly {
64
+ id: T
65
+ title: string
66
+ /** Colour of the header's status dot (a `VX.status.*` token). Default muted. */
67
+ tone?: string
68
+ /** Right-aligned header text, already formatted ("3 items", "$12.40"). */
69
+ total?: string
70
+ /** The title of the `EmptyState` tile an empty column shows. Default "Nothing here"; say why it is empty. */
71
+ empty?: string
72
+ cards: readonly {
73
+ id: string
74
+ actor?: string
75
+ type?: string
76
+ title: string
77
+ /** A linked record; `href` is a link only when http(s) or relative. */
78
+ record?: { label: string; href?: string }
79
+ /** One muted status line ("Deferred · waiting on CI"). */
80
+ status?: string
81
+ /** An optional meter or preview; the one ReactNode slot. */
82
+ meter?: ReactNode
83
+ }[]
84
+ }[]
85
+ /** Called with the card and column ids on Enter, Space or a click. */
86
+ onOpen?: (cardId: string, columnId: string) => void
87
+ /** Each column scrolls alone inside a box of this height. Omitted: content-sized. */
88
+ height?: number | string
89
+ /** Renders column-shaped skeletons. */
90
+ loading?: boolean
91
+ /** The tile shown when no column has a card. Default "Nothing on the board". */
92
+ empty?: { title: string; description?: string; action?: ReactNode }
93
+ /**
94
+ * Compact: the store field holding the selected column id (an enum field of the column ids, the
95
+ * type `ViewTabs` takes). Omitted: internal state, first column.
96
+ */
97
+ field?: FieldHandle<EnumField<T>>
98
+ }
99
+
100
+ const DEFAULT_EMPTY = { title: 'Nothing on the board' } as const
101
+ const SKELETON_COLUMNS = 3
102
+ const SKELETON_CARDS = 3
103
+
104
+ const cardKey = (col: string, card: string): string => `${col}\u0000${card}`
105
+
106
+ /** The compact board's column switcher: the loading and the loaded branch share one box and one selection. */
107
+ function ColumnSwitcher({
108
+ label,
109
+ items,
110
+ value,
111
+ onChange,
112
+ disabled = false,
113
+ }: {
114
+ label: string
115
+ items: readonly { id: string; text: string }[]
116
+ value: string
117
+ onChange?: (id: string) => void
118
+ disabled?: boolean
119
+ }) {
120
+ return (
121
+ // theme-allow raw-selection-control — the board's own column switcher, its selection is the board's own (a `field` when given, else internal), not a page filter.
122
+ <SegmentedControl
123
+ aria-label={`${label} column`}
124
+ disabled={disabled}
125
+ fullWidth
126
+ size="ctl"
127
+ value={value}
128
+ {...(onChange !== undefined && { onChange })}
129
+ data={items.map((i) => ({ value: i.id, label: i.text }))}
130
+ />
131
+ )
132
+ }
133
+
134
+ function SkeletonColumn({ title }: { title?: string }) {
135
+ return (
136
+ <div className={classes.column} aria-hidden>
137
+ <div className={classes.head}>
138
+ {title === undefined ? (
139
+ <Skeleton className={classes.skeletonTitle} />
140
+ ) : (
141
+ <span className={classes.title}>{title}</span>
142
+ )}
143
+ </div>
144
+ <div className={classes.list}>
145
+ {Array.from({ length: SKELETON_CARDS }, (_, i) => (
146
+ <Card key={i} className={classes.card}>
147
+ <Skeleton className={classes.skeletonCaption} />
148
+ <Skeleton className={classes.skeletonLine} />
149
+ <Skeleton className={classes.skeletonStatus} />
150
+ </Card>
151
+ ))}
152
+ </div>
153
+ </div>
154
+ )
155
+ }
156
+
157
+ type BoardViewProps<T extends string> = Omit<BoardProps<T>, 'field'> & {
158
+ /** The selected column id and its setter, from the field or from internal state. */
159
+ picked: T | undefined
160
+ onPick: (columnId: T) => void
161
+ }
162
+
163
+ /** The field's `use()` is a hook, so the field and internal-state forms are two components over one view. */
164
+ function FieldBoard<T extends string>({
165
+ field,
166
+ ...props
167
+ }: Omit<BoardProps<T>, 'field'> & { field: FieldHandle<EnumField<T>> }) {
168
+ const [picked, setPicked] = field.use()
169
+ return <BoardView {...props} picked={picked} onPick={setPicked} />
170
+ }
171
+
172
+ function InternalBoard<T extends string>(props: Omit<BoardProps<T>, 'field'>) {
173
+ const [picked, setPicked] = useState<T | undefined>(undefined)
174
+ return <BoardView {...props} picked={picked} onPick={setPicked} />
175
+ }
176
+
177
+ export function Board<T extends string = string>({ field, ...props }: BoardProps<T>) {
178
+ return field === undefined ? (
179
+ <InternalBoard {...props} />
180
+ ) : (
181
+ <FieldBoard field={field} {...props} />
182
+ )
183
+ }
184
+
185
+ /** One column's scroll box. It marks its viewport `data-more` while cards remain below the fold, and
186
+ * CSS masks the column's bottom edge there, so a clipped last card is never silent. */
187
+ function ColumnScroll({ height, children }: { height?: number | string; children: ReactNode }) {
188
+ const [viewport, setViewport] = useState<HTMLDivElement | null>(null)
189
+ useScrolledEdge(viewport)
190
+ return (
191
+ <ScrollArea.Autosize
192
+ {...(height !== undefined && { mah: height })}
193
+ type="auto"
194
+ offsetScrollbars="y"
195
+ viewportRef={setViewport}
196
+ scrollbarSize={6}
197
+ classNames={{ viewport: classes.viewport, thumb: classes.thumb }}
198
+ >
199
+ {children}
200
+ </ScrollArea.Autosize>
201
+ )
202
+ }
203
+
204
+ function BoardView<T extends string>({
205
+ label = 'Board',
206
+ columns,
207
+ onOpen,
208
+ height,
209
+ loading = false,
210
+ empty = DEFAULT_EMPTY,
211
+ picked,
212
+ onPick,
213
+ className,
214
+ style,
215
+ ...rest
216
+ }: BoardViewProps<T>) {
217
+ const compact = useSizeClass() === 'compact'
218
+ const labelId = useId()
219
+ const [active, setActive] = useState<{ col: string; card: string } | null>(null)
220
+ const [announcement, setAnnouncement] = useState('')
221
+ const buttons = useRef(new Map<string, HTMLButtonElement>())
222
+ const pending = useRef<string | null>(null)
223
+
224
+ const sizes = columns.map((c) => c.cards.length)
225
+ const total = sizes.reduce((a, b) => a + b, 0)
226
+ const selected = columns.find((c) => c.id === picked) ?? columns[0]
227
+ const selectColumn = onPick
228
+
229
+ // The roving stop sits in what is rendered: the focused card if it still exists there (compact
230
+ // renders only the selected column), else the first card of the first rendered non-empty column.
231
+ const selectedIndex = selected === undefined ? -1 : columns.indexOf(selected)
232
+ const rendered = (colIndex: number): boolean => !compact || colIndex === selectedIndex
233
+ const firstCol = columns.findIndex((c, i) => rendered(i) && c.cards.length > 0)
234
+ const activeCol = columns.findIndex((c) => c.id === active?.col)
235
+ const activeRow = columns[activeCol]?.cards.findIndex((c) => c.id === active?.card) ?? -1
236
+ const stop: BoardPos | null =
237
+ activeCol >= 0 && activeRow >= 0 && rendered(activeCol)
238
+ ? { col: activeCol, row: activeRow }
239
+ : firstCol >= 0
240
+ ? { col: firstCol, row: 0 }
241
+ : null
242
+
243
+ // A move in compact may first have to mount the target column; focus lands after that render.
244
+ useEffect(() => {
245
+ const key = pending.current
246
+ if (key === null) return
247
+ // One shot: a target that did not mount is dropped, never retried on a later render.
248
+ pending.current = null
249
+ buttons.current.get(key)?.focus()
250
+ })
251
+
252
+ const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, from: BoardPos): void => {
253
+ if (!isBoardKey(event.key)) return
254
+ event.preventDefault()
255
+ const to = moveOnBoard(sizes, from, event.key)
256
+ const col = to && columns[to.col]
257
+ const card = col && col.cards[to.row]
258
+ if (!to || !col || !card) return
259
+ pending.current = cardKey(col.id, card.id)
260
+ setActive({ col: col.id, card: card.id })
261
+ setAnnouncement(`${col.title}, card ${to.row + 1} of ${col.cards.length}: ${card.title}`)
262
+ if (compact && col.id !== selected?.id) selectColumn(col.id)
263
+ }
264
+
265
+ const renderColumn = (col: (typeof columns)[number], colIndex: number): ReactNode => {
266
+ const headId = `${labelId}-${col.id}`
267
+ const list =
268
+ col.cards.length === 0 ? (
269
+ <EmptyState tier="section" title={col.empty ?? 'Nothing here'} />
270
+ ) : (
271
+ // The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
272
+ // oxlint-disable-next-line jsx-a11y/no-redundant-roles
273
+ <ul className={classes.list} role="list" aria-labelledby={headId}>
274
+ {col.cards.map((card, row) => {
275
+ const here = stop?.col === colIndex && stop.row === row
276
+ const caption = [card.actor, card.type].filter(Boolean).join(' · ')
277
+ return (
278
+ <li key={card.id}>
279
+ <Card className={classes.card}>
280
+ {caption !== '' && <p className={classes.caption}>{caption}</p>}
281
+ <button
282
+ type="button"
283
+ className={classes.open}
284
+ tabIndex={here ? 0 : -1}
285
+ ref={(el) => {
286
+ const key = cardKey(col.id, card.id)
287
+ if (el) buttons.current.set(key, el)
288
+ else buttons.current.delete(key)
289
+ }}
290
+ onFocus={() => setActive({ col: col.id, card: card.id })}
291
+ onKeyDown={(e) => onKeyDown(e, { col: colIndex, row })}
292
+ onClick={() => onOpen?.(card.id, col.id)}
293
+ >
294
+ {card.title}
295
+ </button>
296
+ {card.record !== undefined &&
297
+ (card.record.href !== undefined && isSafeHref(card.record.href) ? (
298
+ <a
299
+ className={classes.record}
300
+ href={card.record.href}
301
+ {...(/^https?:/i.test(card.record.href) && {
302
+ target: '_blank',
303
+ rel: 'noreferrer',
304
+ })}
305
+ >
306
+ {card.record.label}
307
+ </a>
308
+ ) : (
309
+ <span className={classes.record}>{card.record.label}</span>
310
+ ))}
311
+ {card.status !== undefined && <p className={classes.status}>{card.status}</p>}
312
+ {card.meter !== undefined && <div className={classes.meter}>{card.meter}</div>}
313
+ </Card>
314
+ </li>
315
+ )
316
+ })}
317
+ </ul>
318
+ )
319
+ return (
320
+ // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a named group of cards, not a fieldset
321
+ <div key={col.id} className={classes.column} role="group" aria-labelledby={headId}>
322
+ {/* Compact: the switcher already names the column and its count, so only the total stays visible. */}
323
+ <div className={classes.head}>
324
+ {!compact && <StatusDot color={col.tone ?? VX.muted} />}
325
+ <h3 id={headId} className={classes.title}>
326
+ {compact ? <VisuallyHidden>{col.title}</VisuallyHidden> : col.title}
327
+ <VisuallyHidden>{`, ${col.cards.length} ${col.cards.length === 1 ? 'card' : 'cards'}`}</VisuallyHidden>
328
+ </h3>
329
+ {!compact && (
330
+ <span className={classes.count} aria-hidden>
331
+ {col.cards.length}
332
+ </span>
333
+ )}
334
+ {col.total !== undefined && <span className={classes.total}>{col.total}</span>}
335
+ </div>
336
+ <ColumnScroll {...(height !== undefined && { height })}>{list}</ColumnScroll>
337
+ </div>
338
+ )
339
+ }
340
+
341
+ let content: ReactNode
342
+ if (loading) {
343
+ content = (
344
+ <div aria-busy="true">
345
+ <VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
346
+ {compact && columns.length > 0 && (
347
+ // The loaded switcher's footprint with the titles it will carry, inert until the cards land.
348
+ <ColumnSwitcher
349
+ label={label}
350
+ disabled
351
+ value={selected?.id ?? ''}
352
+ items={columns.map((c) => ({ id: c.id, text: c.title }))}
353
+ />
354
+ )}
355
+ <div className={classes.columns}>
356
+ {compact ? (
357
+ <SkeletonColumn />
358
+ ) : columns.length > 0 ? (
359
+ columns.map((c) => <SkeletonColumn key={c.id} title={c.title} />)
360
+ ) : (
361
+ Array.from({ length: SKELETON_COLUMNS }, (_, i) => <SkeletonColumn key={i} />)
362
+ )}
363
+ </div>
364
+ </div>
365
+ )
366
+ } else if (total === 0) {
367
+ content = (
368
+ // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a polite live region whose name is the visually hidden label inside
369
+ <div className={classes.empty} role="status">
370
+ <VisuallyHidden>{label}</VisuallyHidden>
371
+ <EmptyState
372
+ tier="section"
373
+ title={empty.title}
374
+ {...(empty.description !== undefined && { description: empty.description })}
375
+ {...(empty.action !== undefined && { action: empty.action })}
376
+ />
377
+ </div>
378
+ )
379
+ } else {
380
+ content = (
381
+ <Fragment>
382
+ {compact && (
383
+ <ColumnSwitcher
384
+ label={label}
385
+ value={selected?.id ?? ''}
386
+ onChange={(id) => {
387
+ const col = columns.find((c) => c.id === id)
388
+ if (col) selectColumn(col.id)
389
+ }}
390
+ items={columns.map((c) => ({ id: c.id, text: `${c.title} ${c.cards.length}` }))}
391
+ />
392
+ )}
393
+ <div className={classes.columns}>
394
+ {compact
395
+ ? selected && renderColumn(selected, columns.indexOf(selected))
396
+ : columns.map(renderColumn)}
397
+ </div>
398
+ <VisuallyHidden component="output" aria-live="polite">
399
+ {announcement}
400
+ </VisuallyHidden>
401
+ </Fragment>
402
+ )
403
+ }
404
+
405
+ return (
406
+ <div
407
+ {...pickDataAttributes(rest)}
408
+ className={cx(classes.root, className)}
409
+ style={style}
410
+ data-board=""
411
+ >
412
+ {content}
413
+ </div>
414
+ )
415
+ }
@@ -19,21 +19,22 @@
19
19
  */
20
20
  import { Center, Stack } from '@mantine/core'
21
21
  import type { ReactNode } from 'react'
22
- import { VX } from '../tokens'
23
- import { cx } from '../common/props'
24
- import type { BasaltProps, SlotStylesProps } from '../common/props'
22
+ import { VX, alpha } from '../tokens'
23
+ import { cx, pickDataAttributes } from '../common/props'
24
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
25
25
 
26
26
  /** The five boxes `EmptyState` paints, and the whole styling seam it offers (`common/props.ts`). */
27
27
  export type EmptyStateSlot = 'root' | 'icon' | 'title' | 'description' | 'action'
28
28
 
29
29
  export type EmptyStateProps = BasaltProps &
30
+ DataAttributes &
30
31
  SlotStylesProps<EmptyStateSlot> & {
31
32
  /** Optional glyph slot, rendered faint at ~28-32px. No shipped illustration assets. */
32
33
  icon?: ReactNode
33
- /** Head-font title (18px, weight 550, ink). */
34
+ /** Weight 500, ink: `sm` in a section tile (never louder than its host's title), `md` on a page (SPEC § 6.11). */
34
35
  title: string
35
36
  /**
36
- * Muted 15px description, capped at ~360px so it reads as a short explanation. Optional: a
37
+ * Muted `sm` description, capped at ~360px so it reads as a short explanation. Optional: a
37
38
  * compact panel ("No data yet") should not have to invent a second sentence, and five argo
38
39
  * features wrapped this component solely to avoid doing so.
39
40
  */
@@ -41,7 +42,7 @@ export type EmptyStateProps = BasaltProps &
41
42
  /** Optional call-to-action rendered below the description. */
42
43
  action?: ReactNode
43
44
  /** How loud this state is: `'page'` (default) = generous padding for a full-page state;
44
- * `'section'` = compact. */
45
+ * `'section'` = a compact, ring-edged tile (one ring, card radius) inside the surface it replaces. */
45
46
  tier?: 'page' | 'section'
46
47
  }
47
48
 
@@ -65,10 +66,12 @@ export function EmptyState({
65
66
  className,
66
67
  style,
67
68
  classNames,
69
+ ...rest
68
70
  }: EmptyStateProps) {
69
71
  const resolved = tier ?? 'page'
70
72
  return (
71
73
  <Stack
74
+ {...pickDataAttributes(rest)}
72
75
  align="center"
73
76
  gap="xs"
74
77
  className={cx(classNames?.root, className)}
@@ -78,6 +81,14 @@ export function EmptyState({
78
81
  ? `${PAGE_PADDING_Y} ${PAGE_PADDING_X}`
79
82
  : `${SECTION_PADDING_Y} ${SECTION_PADDING_X}`,
80
83
  textAlign: 'center',
84
+ // The section tile: one ring (a shadow, never a border), card radius. The ring is a neutral
85
+ // tint, not the card hairline: the tile sits on the page or a panel, and the hairline (a card
86
+ // edge on a white card) vanishes on the grey page in light.
87
+ ...(resolved === 'section' && {
88
+ // theme-allow surface-shadow-override — an inset ring on a tile inside a surface, not a card's depth
89
+ boxShadow: `inset 0 0 0 1px ${alpha(VX.neutral, 0.25)}`,
90
+ borderRadius: 'var(--vx-radius-card)',
91
+ }),
81
92
  ...style,
82
93
  }}
83
94
  >
@@ -94,10 +105,9 @@ export function EmptyState({
94
105
  <span
95
106
  className={classNames?.title}
96
107
  style={{
97
- fontFamily: 'var(--basalt-font-head)',
98
- fontStretch: '88%',
99
- fontSize: VX.text.xl,
100
- fontWeight: 550,
108
+ // A section tile never out-sizes its host's own title (`sm`); the page tier has none and keeps `md`.
109
+ fontSize: resolved === 'section' ? VX.text.sm : VX.text.md,
110
+ fontWeight: 500,
101
111
  color: VX.ink,
102
112
  }}
103
113
  >
@@ -107,7 +117,7 @@ export function EmptyState({
107
117
  // 360px (22.5rem) is a reading-width cap, not a density inset — kept structural.
108
118
  <span
109
119
  className={classNames?.description}
110
- style={{ fontSize: VX.text.md, color: VX.muted, maxWidth: '22.5rem' }}
120
+ style={{ fontSize: VX.text.sm, color: VX.muted, maxWidth: '22.5rem' }}
111
121
  >
112
122
  {description}
113
123
  </span>
@@ -0,0 +1,125 @@
1
+ /**
2
+ * `EventList`'s pure half: day grouping and the labels. Local-time day boundaries, the caller's
3
+ * order kept (a group is a run of adjacent items on one local day, never a re-sort).
4
+ */
5
+ import type { ReactNode } from 'react'
6
+ import { date, dateTime, relativeTime, time, weekday } from '../format'
7
+
8
+ export type EventTimeMode = 'clock' | 'relative' | 'date-time' | ((at: Date) => string)
9
+
10
+ export const toEventDate = (at: Date | number): Date => (at instanceof Date ? at : new Date(at))
11
+
12
+ export const isValidEventDate = (at: Date): boolean => Number.isFinite(at.getTime())
13
+
14
+ /** Shown in the time column of a row whose `at` is not a real instant. */
15
+ const NO_TIME = '—'
16
+
17
+ /** Local calendar day, `YYYY-MM-DD`. */
18
+ export function dayKey(at: Date): string {
19
+ const month = String(at.getMonth() + 1).padStart(2, '0')
20
+ const day = String(at.getDate()).padStart(2, '0')
21
+ return `${at.getFullYear()}-${month}-${day}`
22
+ }
23
+
24
+ export type EventGroup<T extends { readonly at: Date | number }> = {
25
+ readonly day: Date
26
+ /** The local day, `YYYY-MM-DD`, or `invalid` for a list with no real instant. */
27
+ readonly key: string
28
+ /** `key` plus the run's occurrence, so a same-day prepend keeps every group's identity. */
29
+ readonly id: string
30
+ readonly items: readonly T[]
31
+ }
32
+
33
+ /**
34
+ * Runs of adjacent items on one local day, in the order given. An item whose `at` is invalid has no
35
+ * day of its own: it joins the run before it, or (leading) the first real run that follows. A list
36
+ * with no real instant at all is one group on an invalid day, which renders without a header.
37
+ */
38
+ export function groupByDay<T extends { readonly at: Date | number }>(
39
+ items: readonly T[],
40
+ ): EventGroup<T>[] {
41
+ const runs: { day: Date; key: string; items: T[] }[] = []
42
+ const leading: T[] = []
43
+ for (const item of items) {
44
+ const at = toEventDate(item.at)
45
+ const last = runs[runs.length - 1]
46
+ if (!isValidEventDate(at)) {
47
+ if (last === undefined) leading.push(item)
48
+ else last.items.push(item)
49
+ continue
50
+ }
51
+ const key = dayKey(at)
52
+ if (last !== undefined && last.key === key) last.items.push(item)
53
+ else runs.push({ day: at, key, items: runs.length === 0 ? [...leading, item] : [item] })
54
+ }
55
+ if (runs.length === 0) {
56
+ return leading.length === 0
57
+ ? []
58
+ : [{ day: new Date(Number.NaN), key: 'invalid', id: 'invalid#0', items: leading }]
59
+ }
60
+ const seen = new Map<string, number>()
61
+ return runs.map((run) => {
62
+ const n = seen.get(run.key) ?? 0
63
+ seen.set(run.key, n + 1)
64
+ return { ...run, id: `${run.key}#${n}` }
65
+ })
66
+ }
67
+
68
+ /** `Today`, `Yesterday`, else `Wed, Sep 2, 2026`. With no clock yet (the server render) always the date. */
69
+ export function defaultDayLabel(day: Date, now: Date | null): string {
70
+ if (!isValidEventDate(day)) return NO_TIME
71
+ if (now === null) return `${weekday(day)}, ${date(day)}`
72
+ const key = dayKey(day)
73
+ if (key === dayKey(now)) return 'Today'
74
+ const before = new Date(now)
75
+ before.setDate(before.getDate() - 1)
76
+ if (key === dayKey(before)) return 'Yesterday'
77
+ return `${weekday(day)}, ${date(day)}`
78
+ }
79
+
80
+ export function formatEventTime(at: Date, mode: EventTimeMode, now: Date | null): string {
81
+ if (!isValidEventDate(at)) return NO_TIME
82
+ if (typeof mode === 'function') return mode(at)
83
+ // Relative needs a clock; before there is one (the server render) the absolute stamp stands in.
84
+ if (mode === 'relative' && now !== null) return relativeTime(at, { now: now.getTime() })
85
+ if (mode === 'relative') return dateTime(at, { format: 'short' })
86
+ if (mode === 'date-time') return dateTime(at, { format: 'short' })
87
+ return time(at, { format: 'short' })
88
+ }
89
+
90
+ /** What every row (real or skeleton) shares: the list's density, rail, lead column, time mode and "now". */
91
+ export type RowContext = {
92
+ readonly density: 'feed' | 'timeline'
93
+ readonly rail: boolean
94
+ readonly lead: boolean
95
+ readonly timeMode: EventTimeMode
96
+ /** `null` until the client clock is read (the server render and the hydrating paint). */
97
+ readonly now: Date | null
98
+ }
99
+
100
+ /** `null`, `undefined`, booleans and the empty string render nothing, so they are not content. */
101
+ export const present = (node: ReactNode): boolean =>
102
+ node !== undefined &&
103
+ node !== null &&
104
+ typeof node !== 'boolean' &&
105
+ node !== '' &&
106
+ !(Array.isArray(node) && !node.some(present))
107
+
108
+ const SKELETON_DEFAULT_ROWS = 5
109
+ const SKELETON_MAX_ROWS = 30
110
+
111
+ /** Skeleton rows while loading, shared by `EventList` and `BarList`: an explicit `loadingRows`, else the
112
+ * rows held now (a refetch), capped at 30, else 5 (a cold load has no count to keep). */
113
+ export const skeletonRowCount = (loadingRows: number | undefined, held: number): number =>
114
+ loadingRows ?? (held > 0 ? Math.min(held, SKELETON_MAX_ROWS) : SKELETON_DEFAULT_ROWS)
115
+
116
+ /** The data attributes a row (real or skeleton) carries; the CSS keys on them. */
117
+ export function rowAttributes(ctx: RowContext, first: boolean, last: boolean) {
118
+ return {
119
+ 'data-density': ctx.density,
120
+ 'data-lead': ctx.lead ? '' : undefined,
121
+ 'data-rail': ctx.rail ? '' : undefined,
122
+ 'data-first': first ? '' : undefined,
123
+ 'data-last': last ? '' : undefined,
124
+ }
125
+ }