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,117 @@
1
+ /** `EventList`'s row, day header and the flat rows of its windowed path. */
2
+ import type { VirtualRow } from '../common/virtual-rows'
3
+ import classes from './event-list.module.css'
4
+ import type { EventListProps } from './event-list'
5
+ import {
6
+ formatEventTime,
7
+ isValidEventDate,
8
+ present,
9
+ rowAttributes,
10
+ toEventDate,
11
+ } from './event-list-model'
12
+ import type { EventGroup, RowContext } from './event-list-model'
13
+
14
+ export type EventItem = EventListProps['items'][number]
15
+
16
+ export function EventRow({
17
+ item,
18
+ ctx,
19
+ first,
20
+ last,
21
+ tag: Tag,
22
+ }: {
23
+ item: EventItem
24
+ ctx: RowContext
25
+ first: boolean
26
+ last: boolean
27
+ tag: 'li' | 'div'
28
+ }) {
29
+ const at = toEventDate(item.at)
30
+ const valid = isValidEventDate(at)
31
+ const stamp = formatEventTime(at, ctx.timeMode, ctx.now)
32
+ return (
33
+ <Tag
34
+ className={classes.row}
35
+ // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a windowed row is a div under the seam's wrappers, never a li
36
+ role={Tag === 'div' ? 'listitem' : undefined}
37
+ data-event-id={item.id}
38
+ data-untimed={stamp === '' ? '' : undefined}
39
+ {...rowAttributes(ctx, first, last)}
40
+ >
41
+ {ctx.lead && <span className={classes.leading}>{item.leading}</span>}
42
+ <span className={classes.line}>
43
+ {present(item.actor) && <span className={classes.actor}>{item.actor} </span>}
44
+ {item.title}
45
+ </span>
46
+ {stamp !== '' && (
47
+ <time className={classes.time} {...(valid && { dateTime: at.toISOString() })}>
48
+ {stamp}
49
+ </time>
50
+ )}
51
+ {present(item.body) && (
52
+ <div className={classes.meta}>
53
+ <span className={classes.body}>{item.body}</span>
54
+ </div>
55
+ )}
56
+ {present(item.chips) && <div className={classes.chips}>{item.chips}</div>}
57
+ </Tag>
58
+ )
59
+ }
60
+
61
+ const countLabel = (n: number): string => `· ${n} ${n === 1 ? 'event' : 'events'}`
62
+
63
+ /** The flat rows of the windowed path: a sticky header row per day, then its items. */
64
+ export function buildRows(
65
+ groups: readonly EventGroup<EventItem>[],
66
+ showHeaders: boolean,
67
+ ctx: RowContext,
68
+ headerText: (day: Date) => string,
69
+ ): VirtualRow[] {
70
+ return groups.flatMap((g) => {
71
+ const itemRows = g.items.map((item, i) => ({
72
+ key: `item:${item.id}`,
73
+ node: (
74
+ <EventRow item={item} ctx={ctx} first={i === 0} last={i === g.items.length - 1} tag="div" />
75
+ ),
76
+ }))
77
+ if (!showHeaders) return itemRows
78
+ return [
79
+ {
80
+ key: `day:${g.id}`,
81
+ sticky: true,
82
+ node: <DayHeader text={headerText(g.day)} count={g.items.length} windowed />,
83
+ },
84
+ ...itemRows,
85
+ ]
86
+ })
87
+ }
88
+
89
+ export function DayHeader({
90
+ text,
91
+ count,
92
+ id,
93
+ as: Tag = 'div',
94
+ windowed = false,
95
+ }: {
96
+ text: string
97
+ count: number
98
+ id?: string
99
+ as?: 'h3' | 'div'
100
+ /** A windowed header is its own list item, its inner element a level-3 heading like the plain `<h3>`. */
101
+ windowed?: boolean
102
+ }) {
103
+ const header = (
104
+ <Tag
105
+ id={id}
106
+ data-day-header=""
107
+ {...(windowed && { role: 'heading', 'aria-level': 3 })}
108
+ className={classes.header}
109
+ >
110
+ {text}
111
+ <span className={classes.count}>{countLabel(count)}</span>
112
+ </Tag>
113
+ )
114
+ if (!windowed) return header
115
+ // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- see EventRow: a windowed header is a div
116
+ return <div role="listitem">{header}</div>
117
+ }
@@ -0,0 +1,291 @@
1
+ /**
2
+ * `EventList`'s scroll behaviour: keep the visible row across a prepend, open an oldest-first box on
3
+ * its newest end while the layout settles, and mark a scrolled box so its sticky day header can lift. Every hook takes the scroll node
4
+ * as state (null until mounted) and is inert without one.
5
+ */
6
+ import { useEffect, useRef } from 'react'
7
+ import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
8
+
9
+ type AnchorMemory = { firstId: string; count: number; scrollHeight: number }
10
+
11
+ /**
12
+ * The list's own scroll node keeps the visible row across a prepend: the count grew and the old
13
+ * first id is still in the list, so the height delta goes onto `scrollTop`. Memory resets whenever
14
+ * there is nothing to anchor (disabled, no rows, node absent), so a reload is never read as a
15
+ * prepend. The node sets `overflow-anchor: none` so the browser cannot add the same delta twice.
16
+ */
17
+ export function usePrependAnchor(
18
+ node: HTMLElement | null,
19
+ enabled: boolean,
20
+ items: readonly { readonly id: string }[],
21
+ ): void {
22
+ const prev = useRef<AnchorMemory | null>(null)
23
+ const firstId = items[0]?.id
24
+ const count = items.length
25
+ // oxlint-disable-next-line react-hooks/exhaustive-deps -- every commit, by design
26
+ useIsomorphicLayoutEffect(() => {
27
+ const root = enabled ? node : null
28
+ if (root === null || firstId === undefined) {
29
+ prev.current = null
30
+ return
31
+ }
32
+ const before = prev.current
33
+ if (
34
+ before !== null &&
35
+ before.firstId !== firstId &&
36
+ count > before.count &&
37
+ items.some((item) => item.id === before.firstId)
38
+ ) {
39
+ root.scrollTop += root.scrollHeight - before.scrollHeight
40
+ }
41
+ prev.current = { firstId, count, scrollHeight: root.scrollHeight }
42
+ })
43
+ }
44
+
45
+ /** The inputs that mean the user has taken over the scroll position. */
46
+ const USER_INPUT = ['wheel', 'touchstart', 'pointerdown', 'keydown'] as const
47
+
48
+ /** How long a list that has not been touched keeps re-applying "open on the newest end". */
49
+ const OPEN_AT_END_MS = 3000
50
+
51
+ /**
52
+ * An oldest-first list with its own scroll node opens on the newest end — and keeps opening there
53
+ * while the layout is still settling (fonts, the narrow time move, wrapping grow `scrollHeight`
54
+ * after the first jump), until the user touches it, the item count changes (an `earlier` load), or
55
+ * a few seconds pass. Plain path only: the windowed seam opens itself with `initialScroll`.
56
+ */
57
+ export function useOpenAtEnd(node: HTMLElement | null, active: boolean, count: number): void {
58
+ const latest = useRef(count)
59
+ // The first jump happens before paint: no frame at the top, then a jump.
60
+ useIsomorphicLayoutEffect(() => {
61
+ if (node === null || !active) return
62
+ const el: HTMLElement = node
63
+ el.scrollTo({ top: el.scrollHeight, behavior: 'instant' })
64
+ }, [node, active])
65
+ useIsomorphicLayoutEffect(() => {
66
+ latest.current = count
67
+ })
68
+ useEffect(() => {
69
+ if (node === null || !active) return
70
+ const opened = latest.current
71
+ const el: HTMLElement = node
72
+ let stopped = false
73
+ const toEnd = (): void => {
74
+ el.scrollTo({ top: el.scrollHeight, behavior: 'instant' })
75
+ }
76
+ const reapply = (): void => {
77
+ if (stopped) return
78
+ if (latest.current === opened) toEnd()
79
+ else stop()
80
+ }
81
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(reapply)
82
+ const timer = setTimeout(() => stop(), OPEN_AT_END_MS)
83
+ function stop(): void {
84
+ stopped = true
85
+ observer?.disconnect()
86
+ clearTimeout(timer)
87
+ for (const type of USER_INPUT) el.removeEventListener(type, stop)
88
+ }
89
+ for (const type of USER_INPUT) el.addEventListener(type, stop, { passive: true })
90
+ observer?.observe(el)
91
+ if (el.firstElementChild !== null) observer?.observe(el.firstElementChild)
92
+ toEnd()
93
+ void document.fonts?.ready?.then(reapply)
94
+ return stop
95
+ }, [node, active])
96
+ }
97
+
98
+ const TRIM = '--event-list-trim'
99
+
100
+ /**
101
+ * How far the box must be shorter for its newest end to open on a row boundary: with a sticky day
102
+ * header stuck at the top, the row beneath its lower edge is cut across its first line. Trimming the
103
+ * box by that row's remainder hides it entirely, so the first row in view is whole and the last row
104
+ * still ends on the box's floor. Pure of the current trim (it adds it back), so it settles in one
105
+ * step. 0 when no header is stuck or nothing is cut.
106
+ */
107
+ export function rowBoundaryTrim(el: HTMLElement, content: Element, current: number): number {
108
+ const header = content.querySelector<HTMLElement>('[data-day-header]')
109
+ if (header === null) return 0
110
+ const origin = content.getBoundingClientRect().top
111
+ const rel = (e: Element, edge: 'top' | 'bottom'): number =>
112
+ e.getBoundingClientRect()[edge] - origin
113
+ // The end position of the untrimmed box, and the line the stuck header's lower edge sits on there.
114
+ const end = el.scrollHeight - (el.clientHeight + current)
115
+ const stuck = Array.from(content.querySelectorAll('[data-day-header]')).some(
116
+ (h) => h.parentElement !== null && rel(h.parentElement, 'top') < end - 0.5,
117
+ )
118
+ if (!stuck) return 0
119
+ const cut = end + header.offsetHeight
120
+ for (const row of content.querySelectorAll('[data-event-id]')) {
121
+ const [top, bottom] = [rel(row, 'top'), rel(row, 'bottom')]
122
+ if (top >= cut - 0.5 || bottom <= cut + 0.5) continue
123
+ // A cut through the row's own top padding hides nothing of it.
124
+ if (cut - top <= Number.parseFloat(getComputedStyle(row).paddingTop)) return 0
125
+ return bottom - cut
126
+ }
127
+ return 0
128
+ }
129
+
130
+ /**
131
+ * Keeps `--event-list-trim` on the scroll node at `rowBoundaryTrim` (the box subtracts it from its
132
+ * height) while an oldest-first box opens on its newest end; cleared otherwise.
133
+ */
134
+ export function useRowBoundary(node: HTMLElement | null, active: boolean): void {
135
+ // Before paint, like `useOpenAtEnd`: no frame with a row cut across the header.
136
+ useIsomorphicLayoutEffect(() => {
137
+ const content = node?.firstElementChild
138
+ if (node === null || content === null || content === undefined || !active) return
139
+ const el: HTMLElement = node
140
+ let disposed = false
141
+ const run = (): void => {
142
+ if (disposed) return
143
+ const current = Number.parseFloat(el.style.getPropertyValue(TRIM)) || 0
144
+ const untrimmed = el.clientHeight + current
145
+ const next = Math.min(rowBoundaryTrim(el, content, current), untrimmed / 2)
146
+ if (Math.abs(next - current) < 1.5) return
147
+ el.style.setProperty(TRIM, `${next}px`)
148
+ }
149
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(run)
150
+ observer?.observe(content)
151
+ observer?.observe(el)
152
+ run()
153
+ void document.fonts?.ready?.then(run)
154
+ return () => {
155
+ disposed = true
156
+ observer?.disconnect()
157
+ el.style.removeProperty(TRIM)
158
+ }
159
+ }, [node, active])
160
+ }
161
+
162
+ /**
163
+ * How many plain rows sit above and below what the box shows (a row not wholly in view counts), measured
164
+ * under the stuck day header. Windowed rows (the seam) are a slice of the list, so they have no count.
165
+ */
166
+ export function rowsOutOfView(el: HTMLElement): { above: number; below: number } {
167
+ const rows = el.querySelectorAll('[data-event-id]')
168
+ if (rows.length === 0 || el.querySelector('[data-index]') !== null) return { above: 0, below: 0 }
169
+ const box = el.getBoundingClientRect()
170
+ // The stuck header is the last one at or above the top edge (an earlier day's is scrolled away).
171
+ const stuck = Array.from(el.querySelectorAll('[data-day-header]')).findLast(
172
+ (h) => h.getBoundingClientRect().top <= box.top + 1,
173
+ )
174
+ const top = box.top + (stuck?.getBoundingClientRect().height ?? 0)
175
+ let above = 0
176
+ let below = 0
177
+ for (const row of rows) {
178
+ const rect = row.getBoundingClientRect()
179
+ if (rect.top < top - 1) above += 1
180
+ else if (rect.bottom > box.bottom + 1) below += 1
181
+ }
182
+ return { above, below }
183
+ }
184
+
185
+ /**
186
+ * Marks the scroll node `data-scrolled` while it is off the top (CSS lifts the sticky day header) and
187
+ * `data-more` while content remains below the fold (CSS paints a bottom fade), so a clipped last row
188
+ * is never silent. `data-above` / `data-below` carry how many rows are out of view each way: CSS names
189
+ * them ("1 above" at the top edge, "2 below" at the bottom; "earlier" stays the load control's word) so a cut row has a cue, not only a fade.
190
+ */
191
+ export function useScrolledEdge(node: HTMLElement | null): void {
192
+ useEffect(() => {
193
+ if (node === null) return
194
+ const el: HTMLElement = node
195
+ const flag = (name: string, on: boolean): void => {
196
+ if (on === el.hasAttribute(name)) return
197
+ if (on) el.setAttribute(name, '')
198
+ else el.removeAttribute(name)
199
+ }
200
+ const flags = (): void => {
201
+ flag('data-scrolled', el.scrollTop > 0)
202
+ flag('data-more', el.scrollHeight - el.scrollTop - el.clientHeight > 1)
203
+ }
204
+ const counts = (): void => {
205
+ const { above, below } = rowsOutOfView(el)
206
+ for (const [name, count] of [
207
+ ['data-above', above],
208
+ ['data-below', below],
209
+ ] as const) {
210
+ if (count === 0) el.removeAttribute(name)
211
+ else if (el.getAttribute(name) !== String(count)) el.setAttribute(name, String(count))
212
+ }
213
+ }
214
+ const mark = (): void => {
215
+ flags()
216
+ counts()
217
+ }
218
+ mark()
219
+ // The counts measure every row: on a scroll they are read once a frame, the flags at once.
220
+ let frame = 0
221
+ const onScroll = (): void => {
222
+ flags()
223
+ if (frame !== 0) return
224
+ frame = requestAnimationFrame(() => {
225
+ frame = 0
226
+ counts()
227
+ })
228
+ }
229
+ el.addEventListener('scroll', onScroll, { passive: true })
230
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(mark)
231
+ observer?.observe(el)
232
+ const content = el.firstElementChild
233
+ if (content !== null) observer?.observe(content)
234
+ // The content wrapper stays, its children swap (skeleton, plain rows, the windowed seam): re-read then.
235
+ const swaps = typeof MutationObserver === 'undefined' ? null : new MutationObserver(mark)
236
+ if (content !== null) swaps?.observe(content, { childList: true })
237
+ return () => {
238
+ cancelAnimationFrame(frame)
239
+ el.removeEventListener('scroll', onScroll)
240
+ observer?.disconnect()
241
+ swaps?.disconnect()
242
+ el.removeAttribute('data-scrolled')
243
+ el.removeAttribute('data-more')
244
+ el.removeAttribute('data-above')
245
+ el.removeAttribute('data-below')
246
+ }
247
+ }, [node])
248
+ }
249
+
250
+ const HELD = '--event-list-held'
251
+ const LAST = '--event-list-last'
252
+
253
+ /**
254
+ * While rows are plain DOM the content height is kept on the node as `--event-list-held`; the
255
+ * windowed wrapper takes it as a minimum height, so swapping plain rows for the lazy seam never
256
+ * collapses the scroller (the browser would clamp `scrollTop` to 0 before the peer resolves). It is
257
+ * only for that handoff: it is released as soon as the windowed rows have rendered (their height is
258
+ * measured into `--event-list-last` first), and whenever there are no rows, so a shorter list never
259
+ * leaves blank space below its last row. `loading` leaves both untouched: the skeleton takes
260
+ * `--event-list-held`, else `--event-list-last`, as its minimum height, so a refetch keeps the box.
261
+ */
262
+ export function useHeldHeight(
263
+ node: HTMLElement | null,
264
+ mode: 'plain' | 'windowed' | 'loading' | 'none',
265
+ ): void {
266
+ useEffect(() => {
267
+ const content = node?.firstElementChild
268
+ if (node === null || content === null || content === undefined) return
269
+ const el: HTMLElement = node
270
+ if (mode === 'loading') return
271
+ if (mode === 'none') {
272
+ el.style.removeProperty(HELD)
273
+ el.style.removeProperty(LAST)
274
+ return
275
+ }
276
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => run())
277
+ function run(): void {
278
+ if (mode === 'plain') {
279
+ el.style.setProperty(HELD, `${content?.getBoundingClientRect().height ?? 0}px`)
280
+ } else if (observer === null || content?.querySelector('[data-index]') !== null) {
281
+ // The seam has committed rows (or there is nothing to observe): the hold is spent.
282
+ el.style.setProperty(LAST, `${content?.getBoundingClientRect().height ?? 0}px`)
283
+ el.style.removeProperty(HELD)
284
+ observer?.disconnect()
285
+ }
286
+ }
287
+ observer?.observe(content)
288
+ run()
289
+ return () => observer?.disconnect()
290
+ }, [node, mode])
291
+ }
@@ -0,0 +1,62 @@
1
+ /** Skeleton rows in the loaded shape of an `EventList`, enough to fill a bounded height. */
2
+ import { Skeleton } from '@mantine/core'
3
+ import classes from './event-list.module.css'
4
+ import { rowAttributes } from './event-list-model'
5
+ import type { RowContext } from './event-list-model'
6
+
7
+ /** Rows per skeleton day header. */
8
+ const SKELETON_GROUP = 3
9
+ /** Skeleton rows per px of a bounded height (feed ≈ 48 px a row, timeline ≈ 76). */
10
+ const SKELETON_ROW_PX = { feed: 48, timeline: 76 } as const
11
+
12
+ /** Skeleton rows in the loaded shape (header bars when grouped, glyph, sentence, time, meta and, on
13
+ * a timeline, chips), enough to fill a bounded height. */
14
+ export function SkeletonRows({
15
+ count,
16
+ ctx,
17
+ grouped,
18
+ height,
19
+ }: {
20
+ count: number
21
+ ctx: RowContext
22
+ grouped: boolean
23
+ height: number | string | undefined
24
+ }) {
25
+ const total =
26
+ typeof height === 'number'
27
+ ? Math.max(count, Math.ceil(height / SKELETON_ROW_PX[ctx.density]) + 1)
28
+ : count
29
+ return Array.from({ length: total }, (_, i) => (
30
+ <div key={i} className={classes.skeletonGroup} aria-hidden>
31
+ {grouped && i % SKELETON_GROUP === 0 && (
32
+ <div className={classes.header}>
33
+ <Skeleton className={classes.skeletonHeader} />
34
+ </div>
35
+ )}
36
+ <div
37
+ className={classes.row}
38
+ {...rowAttributes(ctx, i % SKELETON_GROUP === 0, i === total - 1)}
39
+ >
40
+ {ctx.lead && (
41
+ <span className={classes.leading}>
42
+ <Skeleton className={classes.skeletonGlyph} circle />
43
+ </span>
44
+ )}
45
+ <span className={classes.line}>
46
+ <Skeleton className={classes.skeletonLine} />
47
+ </span>
48
+ <span className={classes.time}>
49
+ <Skeleton className={classes.skeletonTime} />
50
+ </span>
51
+ <div className={classes.meta}>
52
+ <Skeleton className={classes.skeletonMeta} />
53
+ </div>
54
+ {ctx.density === 'timeline' && (
55
+ <div className={classes.chips}>
56
+ <Skeleton className={classes.skeletonChip} />
57
+ </div>
58
+ )}
59
+ </div>
60
+ </div>
61
+ ))
62
+ }