basalt-ui 2.28.0 → 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 (229) hide show
  1. package/CHANGELOG.md +461 -401
  2. package/MIGRATING.md +202 -12
  3. package/agent/skills/basalt-app/SKILL.md +3 -3
  4. package/agent/skills/basalt-charts/SKILL.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +11 -5
  6. package/agent/skills/basalt-design/references/catalogue.md +3 -1
  7. package/agent/skills/basalt-design/references/recipes.md +1 -1
  8. package/agent/skills/basalt-design/references/states.md +1 -1
  9. package/configs/oxlint-plugin.js +2 -1
  10. package/configs/oxlint.json +1 -0
  11. package/dist/charts/ChartCard.d.ts +9 -5
  12. package/dist/charts/ChartCard.d.ts.map +1 -1
  13. package/dist/charts/ChartCard.js +68 -12
  14. package/dist/charts/Sparkline.d.ts +5 -0
  15. package/dist/charts/Sparkline.d.ts.map +1 -1
  16. package/dist/charts/Sparkline.js +53 -5
  17. package/dist/charts/chart-box.module.css +9 -2
  18. package/dist/charts/chart-card.module.css +16 -13
  19. package/dist/charts/chart-card.module.css.d.ts +2 -0
  20. package/dist/charts/compile.d.ts +1 -1
  21. package/dist/charts/compile.d.ts.map +1 -1
  22. package/dist/charts/compile.js +18 -9
  23. package/dist/charts/ref-label.d.ts +6 -0
  24. package/dist/charts/ref-label.d.ts.map +1 -1
  25. package/dist/charts/ref-label.js +19 -5
  26. package/dist/charts/sparkline.module.css +44 -0
  27. package/dist/charts/sparkline.module.css.d.ts +3 -0
  28. package/dist/charts/state.d.ts +1 -1
  29. package/dist/charts/state.d.ts.map +1 -1
  30. package/dist/charts/state.js +3 -3
  31. package/dist/cli/doctor-upgrade.d.ts +11 -0
  32. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  33. package/dist/cli/doctor-upgrade.js +54 -0
  34. package/dist/cli/doctor.d.ts.map +1 -1
  35. package/dist/cli/doctor.js +32 -0
  36. package/dist/cli/help.d.ts.map +1 -1
  37. package/dist/cli/help.js +8 -3
  38. package/dist/cli/index.d.ts +13 -13
  39. package/dist/cli/index.d.ts.map +1 -1
  40. package/dist/cli/index.js +36 -2
  41. package/dist/cli/init.d.ts +6 -0
  42. package/dist/cli/init.d.ts.map +1 -1
  43. package/dist/cli/init.js +118 -27
  44. package/dist/cli/router-wiring.d.ts +3 -0
  45. package/dist/cli/router-wiring.d.ts.map +1 -1
  46. package/dist/cli/router-wiring.js +2 -0
  47. package/dist/cli/shot/capture.d.ts +28 -1
  48. package/dist/cli/shot/capture.d.ts.map +1 -1
  49. package/dist/cli/shot/capture.js +77 -7
  50. package/dist/cli/shot/detect.d.ts +4 -1
  51. package/dist/cli/shot/detect.d.ts.map +1 -1
  52. package/dist/cli/shot/detect.js +38 -16
  53. package/dist/cli/shot/index.d.ts.map +1 -1
  54. package/dist/cli/shot/index.js +9 -2
  55. package/dist/cli/shot/measure.d.ts.map +1 -1
  56. package/dist/cli/shot/measure.js +11 -2
  57. package/dist/cli/shot/types.d.ts +4 -1
  58. package/dist/cli/shot/types.d.ts.map +1 -1
  59. package/dist/cli/sync.d.ts.map +1 -1
  60. package/dist/cli/sync.js +10 -2
  61. package/dist/common/could-not-load.d.ts +13 -0
  62. package/dist/common/could-not-load.d.ts.map +1 -0
  63. package/dist/common/could-not-load.js +14 -0
  64. package/dist/common/index.d.ts +1 -0
  65. package/dist/common/index.d.ts.map +1 -1
  66. package/dist/common/index.js +3 -0
  67. package/dist/common/props.d.ts +20 -0
  68. package/dist/common/props.d.ts.map +1 -1
  69. package/dist/common/props.js +13 -1
  70. package/dist/common/retry-button.module.css +7 -3
  71. package/dist/dashboard/bar-list.d.ts +4 -4
  72. package/dist/dashboard/bar-list.d.ts.map +1 -1
  73. package/dist/dashboard/bar-list.js +10 -7
  74. package/dist/dashboard/bar-list.module.css +21 -3
  75. package/dist/dashboard/board.d.ts +2 -2
  76. package/dist/dashboard/board.d.ts.map +1 -1
  77. package/dist/dashboard/board.js +31 -12
  78. package/dist/dashboard/board.module.css +19 -0
  79. package/dist/dashboard/board.module.css.d.ts +2 -0
  80. package/dist/dashboard/empty-state.d.ts +3 -3
  81. package/dist/dashboard/empty-state.d.ts.map +1 -1
  82. package/dist/dashboard/empty-state.js +4 -2
  83. package/dist/dashboard/event-list-model.d.ts +3 -0
  84. package/dist/dashboard/event-list-model.d.ts.map +1 -1
  85. package/dist/dashboard/event-list-model.js +5 -1
  86. package/dist/dashboard/event-list-rows.d.ts.map +1 -1
  87. package/dist/dashboard/event-list-rows.js +2 -6
  88. package/dist/dashboard/event-list-scroll.d.ts +32 -4
  89. package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
  90. package/dist/dashboard/event-list-scroll.js +117 -4
  91. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
  92. package/dist/dashboard/event-list-skeleton.js +2 -4
  93. package/dist/dashboard/event-list.d.ts +4 -4
  94. package/dist/dashboard/event-list.d.ts.map +1 -1
  95. package/dist/dashboard/event-list.js +53 -23
  96. package/dist/dashboard/event-list.module.css +90 -37
  97. package/dist/dashboard/event-list.module.css.d.ts +1 -0
  98. package/dist/dashboard/meter-model.d.ts +6 -3
  99. package/dist/dashboard/meter-model.d.ts.map +1 -1
  100. package/dist/dashboard/meter-model.js +9 -4
  101. package/dist/dashboard/meter-parts.d.ts +3 -0
  102. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  103. package/dist/dashboard/meter-parts.js +32 -4
  104. package/dist/dashboard/meter.d.ts +3 -3
  105. package/dist/dashboard/meter.d.ts.map +1 -1
  106. package/dist/dashboard/meter.js +10 -2
  107. package/dist/dashboard/meter.module.css +18 -11
  108. package/dist/dashboard/meter.module.css.d.ts +0 -1
  109. package/dist/dashboard/page-summary.d.ts +3 -3
  110. package/dist/dashboard/page-summary.d.ts.map +1 -1
  111. package/dist/dashboard/page-summary.js +7 -2
  112. package/dist/dashboard/page-summary.module.css +5 -2
  113. package/dist/dashboard/query-state.d.ts +9 -8
  114. package/dist/dashboard/query-state.d.ts.map +1 -1
  115. package/dist/dashboard/query-state.js +28 -10
  116. package/dist/dashboard/section.d.ts +11 -3
  117. package/dist/dashboard/section.d.ts.map +1 -1
  118. package/dist/dashboard/section.js +34 -7
  119. package/dist/dashboard/settings-section.d.ts +4 -4
  120. package/dist/dashboard/settings-section.d.ts.map +1 -1
  121. package/dist/dashboard/settings-section.js +11 -7
  122. package/dist/dashboard/settings-section.module.css +6 -0
  123. package/dist/dashboard/settings-section.module.css.d.ts +1 -0
  124. package/dist/dashboard/stat-card.d.ts +3 -3
  125. package/dist/dashboard/stat-card.d.ts.map +1 -1
  126. package/dist/dashboard/stat-card.js +24 -8
  127. package/dist/dashboard/stat-card.module.css +11 -0
  128. package/dist/dashboard/stat-group.d.ts +2 -2
  129. package/dist/dashboard/stat-group.d.ts.map +1 -1
  130. package/dist/dashboard/stat-group.js +10 -3
  131. package/dist/dashboard/stat-strip.d.ts +5 -4
  132. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  133. package/dist/dashboard/stat-strip.js +41 -31
  134. package/dist/dashboard/stat-strip.module.css +4 -5
  135. package/dist/dashboard/visual-slot.d.ts +4 -0
  136. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  137. package/dist/dashboard/visual-slot.js +2 -0
  138. package/dist/dashboard/widget-header.d.ts +6 -6
  139. package/dist/dashboard/widget-header.d.ts.map +1 -1
  140. package/dist/dashboard/widget-header.js +4 -2
  141. package/dist/dashboard/widget-header.module.css +6 -25
  142. package/dist/format/shared.d.ts.map +1 -1
  143. package/dist/format/shared.js +24 -1
  144. package/dist/guard/index.d.ts +1 -1
  145. package/dist/guard/index.d.ts.map +1 -1
  146. package/dist/guard/index.js +2 -1
  147. package/dist/styles.css +23 -0
  148. package/dist/table/cell-kinds.d.ts +10 -7
  149. package/dist/table/cell-kinds.d.ts.map +1 -1
  150. package/dist/table/cell-kinds.js +18 -7
  151. package/dist/table/data-table-fold.d.ts +13 -5
  152. package/dist/table/data-table-fold.d.ts.map +1 -1
  153. package/dist/table/data-table-fold.js +48 -16
  154. package/dist/table/data-table.d.ts +2 -2
  155. package/dist/table/data-table.d.ts.map +1 -1
  156. package/dist/table/data-table.js +16 -9
  157. package/dist/table/data-table.module.css +74 -2
  158. package/dist/table/data-table.module.css.d.ts +4 -0
  159. package/dist/theme/controls.module.css +23 -2
  160. package/llms.txt +263 -2
  161. package/package.json +1 -1
  162. package/src/charts/ChartCard.tsx +98 -16
  163. package/src/charts/Sparkline.tsx +84 -5
  164. package/src/charts/chart-box.module.css +9 -2
  165. package/src/charts/chart-card.module.css +16 -13
  166. package/src/charts/chart-card.module.css.d.ts +2 -0
  167. package/src/charts/compile.ts +37 -15
  168. package/src/charts/ref-label.ts +36 -9
  169. package/src/charts/sparkline.module.css +44 -0
  170. package/src/charts/sparkline.module.css.d.ts +3 -0
  171. package/src/charts/state.tsx +4 -3
  172. package/src/cli/doctor-upgrade.ts +75 -0
  173. package/src/cli/doctor.ts +36 -0
  174. package/src/cli/help.ts +16 -6
  175. package/src/cli/index.ts +73 -67
  176. package/src/cli/init.ts +157 -36
  177. package/src/cli/router-wiring.ts +2 -2
  178. package/src/cli/shot/capture.ts +109 -10
  179. package/src/cli/shot/detect.ts +46 -22
  180. package/src/cli/shot/index.ts +8 -2
  181. package/src/cli/shot/measure.ts +11 -2
  182. package/src/cli/shot/types.ts +4 -1
  183. package/src/cli/sync.ts +12 -2
  184. package/src/common/could-not-load.ts +22 -0
  185. package/src/common/index.ts +1 -0
  186. package/src/common/props.ts +30 -0
  187. package/src/common/retry-button.module.css +7 -3
  188. package/src/dashboard/bar-list.module.css +21 -3
  189. package/src/dashboard/bar-list.tsx +46 -41
  190. package/src/dashboard/board.module.css +19 -0
  191. package/src/dashboard/board.module.css.d.ts +2 -0
  192. package/src/dashboard/board.tsx +69 -48
  193. package/src/dashboard/empty-state.tsx +5 -2
  194. package/src/dashboard/event-list-model.ts +13 -1
  195. package/src/dashboard/event-list-rows.tsx +3 -6
  196. package/src/dashboard/event-list-scroll.ts +154 -8
  197. package/src/dashboard/event-list-skeleton.tsx +5 -1
  198. package/src/dashboard/event-list.module.css +90 -37
  199. package/src/dashboard/event-list.module.css.d.ts +1 -0
  200. package/src/dashboard/event-list.tsx +92 -65
  201. package/src/dashboard/meter-model.ts +16 -7
  202. package/src/dashboard/meter-parts.tsx +45 -13
  203. package/src/dashboard/meter.module.css +18 -11
  204. package/src/dashboard/meter.module.css.d.ts +0 -1
  205. package/src/dashboard/meter.tsx +36 -18
  206. package/src/dashboard/page-summary.module.css +5 -2
  207. package/src/dashboard/page-summary.tsx +13 -6
  208. package/src/dashboard/query-state.tsx +54 -29
  209. package/src/dashboard/section.tsx +83 -41
  210. package/src/dashboard/settings-section.module.css +6 -0
  211. package/src/dashboard/settings-section.module.css.d.ts +1 -0
  212. package/src/dashboard/settings-section.tsx +11 -6
  213. package/src/dashboard/stat-card.module.css +11 -0
  214. package/src/dashboard/stat-card.tsx +31 -8
  215. package/src/dashboard/stat-group.tsx +22 -14
  216. package/src/dashboard/stat-strip.module.css +4 -5
  217. package/src/dashboard/stat-strip.tsx +29 -20
  218. package/src/dashboard/visual-slot.ts +5 -0
  219. package/src/dashboard/widget-header.module.css +6 -25
  220. package/src/dashboard/widget-header.tsx +8 -5
  221. package/src/format/shared.ts +30 -1
  222. package/src/guard/index.ts +5 -1
  223. package/src/styles.css +23 -0
  224. package/src/table/cell-kinds.tsx +42 -13
  225. package/src/table/data-table-fold.tsx +65 -12
  226. package/src/table/data-table.module.css +74 -2
  227. package/src/table/data-table.module.css.d.ts +4 -0
  228. package/src/table/data-table.tsx +34 -13
  229. package/src/theme/controls.module.css +23 -2
@@ -95,37 +95,182 @@ export function useOpenAtEnd(node: HTMLElement | null, active: boolean, count: n
95
95
  }, [node, active])
96
96
  }
97
97
 
98
- /** Marks the scroll node `data-scrolled` while it is off the top, so CSS can lift the sticky day header. */
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
+ */
99
191
  export function useScrolledEdge(node: HTMLElement | null): void {
100
192
  useEffect(() => {
101
193
  if (node === null) return
102
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
+ }
103
214
  const mark = (): void => {
104
- if (el.scrollTop > 0) el.setAttribute('data-scrolled', '')
105
- else el.removeAttribute('data-scrolled')
215
+ flags()
216
+ counts()
106
217
  }
107
218
  mark()
108
- el.addEventListener('scroll', mark, { passive: true })
109
- return () => el.removeEventListener('scroll', 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
+ }
110
247
  }, [node])
111
248
  }
112
249
 
113
250
  const HELD = '--event-list-held'
251
+ const LAST = '--event-list-last'
114
252
 
115
253
  /**
116
254
  * While rows are plain DOM the content height is kept on the node as `--event-list-held`; the
117
255
  * windowed wrapper takes it as a minimum height, so swapping plain rows for the lazy seam never
118
256
  * collapses the scroller (the browser would clamp `scrollTop` to 0 before the peer resolves). It is
119
- * only for that handoff: it is released as soon as the windowed rows have rendered, and whenever
120
- * there are no rows, so a shorter list never leaves blank space below its last row.
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.
121
261
  */
122
- export function useHeldHeight(node: HTMLElement | null, mode: 'plain' | 'windowed' | 'none'): void {
262
+ export function useHeldHeight(
263
+ node: HTMLElement | null,
264
+ mode: 'plain' | 'windowed' | 'loading' | 'none',
265
+ ): void {
123
266
  useEffect(() => {
124
267
  const content = node?.firstElementChild
125
268
  if (node === null || content === null || content === undefined) return
126
269
  const el: HTMLElement = node
270
+ if (mode === 'loading') return
127
271
  if (mode === 'none') {
128
272
  el.style.removeProperty(HELD)
273
+ el.style.removeProperty(LAST)
129
274
  return
130
275
  }
131
276
  const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => run())
@@ -134,6 +279,7 @@ export function useHeldHeight(node: HTMLElement | null, mode: 'plain' | 'windowe
134
279
  el.style.setProperty(HELD, `${content?.getBoundingClientRect().height ?? 0}px`)
135
280
  } else if (observer === null || content?.querySelector('[data-index]') !== null) {
136
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`)
137
283
  el.style.removeProperty(HELD)
138
284
  observer?.disconnect()
139
285
  }
@@ -50,8 +50,12 @@ export function SkeletonRows({
50
50
  </span>
51
51
  <div className={classes.meta}>
52
52
  <Skeleton className={classes.skeletonMeta} />
53
- {ctx.density === 'timeline' && <Skeleton className={classes.skeletonChip} />}
54
53
  </div>
54
+ {ctx.density === 'timeline' && (
55
+ <div className={classes.chips}>
56
+ <Skeleton className={classes.skeletonChip} />
57
+ </div>
58
+ )}
55
59
  </div>
56
60
  </div>
57
61
  ))
@@ -1,9 +1,11 @@
1
1
  /*
2
2
  * EventList (docs/waves/design-parity/SPEC.md § 6.7). One row shape for the plain and the virtualised
3
3
  * path: nothing here keys on a parent selector, so the seam's wrapper divs change no geometry.
4
- * Two sizes only: the row size (actor, sentence, body) and the micro size (day header, time, chips).
5
- * Two lines at every width: line one is the glyph and the sentence at full width; line two leads
6
- * with the mono time, then the body (it wraps, never truncates), then the chips.
4
+ * Two type rungs: the row size (actor, sentence, body, leading glyph) and the micro size (day header,
5
+ * time, chips; a chip Badge is pinned to it whatever `size` it asks for).
6
+ * Line one is the glyph and the sentence at full width; line two leads with the mono time, then the
7
+ * body (it wraps, never truncates); the chips, when a row has any, sit on a line of their own under the
8
+ * time, so their place never depends on the body.
7
9
  */
8
10
  .frame {
9
11
  inline-size: 100%;
@@ -27,6 +29,65 @@
27
29
  overflow-anchor: none;
28
30
  }
29
31
 
32
+ /* A bottom fade while more rows sit below the fold (`data-more`); it overlays the last rows and adds no height. */
33
+ .scroll[data-more]::after {
34
+ content: '';
35
+ display: block;
36
+ position: sticky;
37
+ inset-block-end: 0;
38
+ block-size: var(--vx-space-stack-lg, 1.5rem);
39
+ margin-block-start: calc(var(--vx-space-stack-lg, 1.5rem) * -1);
40
+ background: linear-gradient(transparent, var(--event-list-bg));
41
+ pointer-events: none;
42
+ }
43
+
44
+ /* The count of rows out of view each way (`data-above` / `data-below`, set by `useScrolledEdge`): small mono
45
+ text at the end of the edge, over the sticky header (top) and the fade (bottom). Zero height: no shift. */
46
+ .scroll[data-above]::before {
47
+ content: '↑ ' attr(data-above) ' above';
48
+ display: block;
49
+ position: sticky;
50
+ inset-block-start: 0;
51
+ z-index: 2;
52
+ block-size: 0;
53
+ /* Moved, not padded: padding would add height to the content. */
54
+ translate: 0 var(--vx-space-stack-xs);
55
+ text-align: end;
56
+ /* Inside the box: flush text lost its last glyph edge to the clip at 390. */
57
+ padding-inline-end: var(--vx-space-stack-xs);
58
+ font-family: var(--basalt-font-mono);
59
+ font-size: var(--vx-text-micro);
60
+ line-height: 1.4;
61
+ white-space: nowrap;
62
+ color: var(--vx-muted);
63
+ pointer-events: none;
64
+ }
65
+
66
+ .scroll[data-below]::after {
67
+ content: '↓ ' attr(data-below) ' below';
68
+ display: flex;
69
+ align-items: flex-end;
70
+ justify-content: flex-end;
71
+ box-sizing: border-box;
72
+ padding-inline-end: var(--vx-space-stack-xs);
73
+ /* Self-contained, like the fade it shares the pseudo with: sticky and cancelled, so it adds no height. */
74
+ position: sticky;
75
+ inset-block-end: 0;
76
+ block-size: var(--vx-space-stack-lg, 1.5rem);
77
+ margin-block-start: calc(var(--vx-space-stack-lg, 1.5rem) * -1);
78
+ pointer-events: none;
79
+ font-family: var(--basalt-font-mono);
80
+ font-size: var(--vx-text-micro);
81
+ line-height: 1.4;
82
+ white-space: nowrap;
83
+ color: var(--vx-muted);
84
+ }
85
+
86
+ /* Loading after rows: the skeleton keeps their last height, so the box does not collapse. */
87
+ .skeleton {
88
+ min-block-size: var(--event-list-held, var(--event-list-last, 0px));
89
+ }
90
+
30
91
  .virtual {
31
92
  min-width: 0;
32
93
  /* The plain rows' last height (see useHeldHeight): no collapse while the seam loads. */
@@ -83,7 +144,8 @@
83
144
  grid-template-columns: auto minmax(0, 1fr);
84
145
  grid-template-areas:
85
146
  'line line'
86
- 'time meta';
147
+ 'time meta'
148
+ 'chips chips';
87
149
  column-gap: var(--vx-space-stack-md);
88
150
  padding-block: var(--vx-space-stack-xs);
89
151
  font-size: var(--vx-text-sm);
@@ -91,6 +153,13 @@
91
153
  color: var(--vx-ink);
92
154
  }
93
155
 
156
+ /* A consistent gap between the rows of a feed (a rail row has its rail; a hairline would be a divider the
157
+ divider law does not list): nine rows of one day read as nine. Padding, not margin: the windowed seam
158
+ measures a row's own box, and the same on every row, so a prepend moves nothing. */
159
+ .row:not([data-rail]) {
160
+ padding-block: calc(var(--vx-space-stack-xs) * 1.5);
161
+ }
162
+
94
163
  .row[data-density='timeline'] {
95
164
  padding-block: var(--vx-space-stack-sm);
96
165
  }
@@ -99,34 +168,23 @@
99
168
  grid-template-columns: var(--event-list-lead) auto minmax(0, 1fr);
100
169
  grid-template-areas:
101
170
  'lead line line'
102
- '. time meta';
171
+ '. time meta'
172
+ '. chips chips';
103
173
  }
104
174
 
105
175
  /* An untimed row has no time to lead the meta line: the meta takes the whole line. */
106
176
  .row[data-untimed] {
107
177
  grid-template-areas:
108
178
  'line line'
109
- 'meta meta';
179
+ 'meta meta'
180
+ 'chips chips';
110
181
  }
111
182
 
112
183
  .row[data-lead][data-untimed] {
113
184
  grid-template-areas:
114
185
  'lead line line'
115
- '. meta meta';
116
- }
117
-
118
- /* The chips follow the sentence's last word, not the row's far edge: the sentence's track grows to
119
- its content (and shrinks, wrapping, when the chips need the room), the chips' track hugs them. */
120
- .row[data-chips-only] {
121
- grid-template-columns: minmax(0, max-content) auto;
122
- grid-template-areas: 'line meta';
123
- justify-content: start;
124
- align-items: start;
125
- }
126
-
127
- .row[data-lead][data-chips-only] {
128
- grid-template-columns: var(--event-list-lead) minmax(0, max-content) auto;
129
- grid-template-areas: 'lead line meta';
186
+ '. meta meta'
187
+ '. chips chips';
130
188
  }
131
189
 
132
190
  .leading {
@@ -135,6 +193,8 @@
135
193
  align-items: center;
136
194
  justify-content: center;
137
195
  min-height: 1.4em;
196
+ /* A glyph or avatar initial rides the row size, never a size of its own. */
197
+ font-size: var(--vx-text-sm);
138
198
  color: var(--vx-muted);
139
199
  }
140
200
 
@@ -193,37 +253,35 @@
193
253
  block-size: calc(var(--vx-text-sm) * 1.4);
194
254
  }
195
255
 
196
- /* The meta line: the body, then the chips. The body wraps inside its own box and the chips stay beside
197
- it on the first line, never on a line of their own; body text is never truncated. */
256
+ /* The meta line: the body wraps (never truncated) beside the time. */
198
257
  .meta {
199
258
  grid-area: meta;
200
- display: flex;
201
- flex-wrap: nowrap;
202
- align-items: flex-start;
203
- gap: var(--vx-space-stack-xs) var(--vx-space-control-gap);
204
259
  min-width: 0;
205
260
  color: var(--vx-muted);
206
261
  }
207
262
 
208
263
  .body {
209
- flex: 0 1 auto;
210
264
  min-width: 0;
211
- max-inline-size: 100%;
212
265
  overflow-wrap: anywhere;
213
266
  }
214
267
 
268
+ /* The chips: one fixed line under the time (the row's third), whatever the body holds. */
215
269
  .chips {
216
- display: inline-flex;
217
- flex: none;
270
+ grid-area: chips;
271
+ display: flex;
272
+ flex-wrap: wrap;
218
273
  align-items: center;
219
- align-self: flex-start;
220
274
  gap: var(--vx-space-control-gap);
275
+ padding-block-start: var(--vx-space-stack-xs);
221
276
  font-size: var(--vx-text-micro);
222
277
  }
223
278
 
224
279
  /* A neutral chip needs a visible surface in light as well: the theme's subtle fill is the page. */
225
280
  .chips :global(.mantine-Badge-root) {
226
281
  background: var(--event-list-tint);
282
+ /* A chip is always the micro rung: Mantine writes `--badge-fz` inline from `size`, so the pin is the
283
+ property itself, which the class beats and the inline custom property does not reach. */
284
+ font-size: var(--vx-text-micro);
227
285
  }
228
286
 
229
287
  .earlier {
@@ -232,11 +290,6 @@
232
290
  padding-block: var(--vx-space-stack-xs);
233
291
  }
234
292
 
235
- .earlierButton {
236
- /* The label starts on the rows' edge: cancel the button's own inline padding. */
237
- margin-inline-start: calc(var(--button-padding-x, 0px) * -1);
238
- }
239
-
240
293
  .earlierButton:hover:not(:disabled, [data-disabled]) {
241
294
  background: var(--event-list-hover);
242
295
  }
@@ -7,6 +7,7 @@ declare const classes: {
7
7
  readonly root: string
8
8
  readonly scroll: string
9
9
  readonly virtual: string
10
+ readonly skeleton: string
10
11
  readonly group: string
11
12
  readonly list: string
12
13
  readonly header: string
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * The row is two lines at every width: line one is the glyph and `actor + sentence` (clamped to one line in
12
12
  * `feed`, wrapping in `timeline`); line two leads with the time, then the body (it wraps, never
13
- * truncates), then the chips (they wrap to the next line only if they must). A row with no body or
13
+ * truncates), then the chips (they follow its last word in the same flow, each chip unbroken). A row with no body or
14
14
  * chips still has line two, the time alone; an untimed row's line two is body and chips only.
15
15
  *
16
16
  * Above 200 rows the rows window through the package's one lazy virtual-list seam
@@ -38,8 +38,8 @@
38
38
  import { Button, VisuallyHidden } from '@mantine/core'
39
39
  import { useId, useRef, useState, useSyncExternalStore } from 'react'
40
40
  import type { CSSProperties, ReactNode } from 'react'
41
- import { cx } from '../common/props'
42
- import type { BasaltProps } from '../common/props'
41
+ import { cx, pickDataAttributes } from '../common/props'
42
+ import type { BasaltProps, DataAttributes } from '../common/props'
43
43
  import { VirtualRows } from '../common/virtual-rows'
44
44
  import classes from './event-list.module.css'
45
45
  import { EmptyState } from './empty-state'
@@ -49,68 +49,76 @@ import {
49
49
  groupByDay,
50
50
  isValidEventDate,
51
51
  present,
52
+ skeletonRowCount,
52
53
  toEventDate,
53
54
  } from './event-list-model'
54
55
  import type { RowContext } from './event-list-model'
55
- import { useHeldHeight, useOpenAtEnd, usePrependAnchor, useScrolledEdge } from './event-list-scroll'
56
+ import {
57
+ useHeldHeight,
58
+ useOpenAtEnd,
59
+ usePrependAnchor,
60
+ useRowBoundary,
61
+ useScrolledEdge,
62
+ } from './event-list-scroll'
56
63
  import { SkeletonRows } from './event-list-skeleton'
57
64
 
58
65
  /** Rows above this window through the virtual-list seam; at or below it the list is plain DOM. */
59
66
  const VIRTUALIZE_THRESHOLD = 200
60
67
 
61
- export type EventListProps = BasaltProps & {
62
- /** Accessible name of the list. Default "Events". */
63
- label?: string
64
- /** Events in display order — kept as given, never re-sorted. `id`s must be unique within the list. */
65
- items: readonly {
66
- id: string
67
- at: Date | number
68
- actor?: ReactNode
69
- title: ReactNode
70
- body?: ReactNode
71
- /** A glyph or avatar in the leading column. */
72
- leading?: ReactNode
73
- chips?: ReactNode
74
- }[]
75
- /** `feed`: one clamped line, about 52 px a two-line row. `timeline`: a rail, full sentences, body and chips in full. */
76
- density?: 'feed' | 'timeline'
77
- /** The 1 px line through the leading column joining rows within a day group. Default: `density === 'timeline'`. */
78
- rail?: boolean
79
- /** Day headers (`micro` mono, muted, with the row count) or one flat list. Default `day`. */
80
- group?: 'day' | 'none'
81
- /**
82
- * The instant "Today" and relative times are measured from. Default: the client clock, read once
83
- * after mount; until then (the server render, the hydrating paint) days read as dates and a
84
- * `relative` time as a date-time, so server and client markup match.
85
- */
86
- now?: number | Date
87
- /** Overrides the `Today` / `Yesterday` / short-date header text. Without a clock yet, `now` is the day itself. */
88
- dayLabel?: (day: Date, now: Date) => string
89
- /**
90
- * The time column. Default `clock` when grouped by day, `date-time` when not. A function formats it
91
- * yourself; one returning an empty string renders no time for that row (an untimed entry).
92
- */
93
- time?: 'clock' | 'relative' | 'date-time' | ((at: Date) => string)
94
- /** Which end of `items` is earlier. Does not sort. Default `newest-first`. */
95
- order?: 'newest-first' | 'oldest-first'
96
- /**
97
- * A quiet "Show earlier (N)" control at the earlier end (bottom for newest-first, top for
98
- * oldest-first). With `height`, prepending (oldest-first) keeps the visible row where it is and a
99
- * list opens on its newest end; a content-sized list leaves scrolling to the page.
100
- */
101
- earlier?: { onLoad: () => void; loading?: boolean; remaining?: number }
102
- /** The list owns a scroll node of this height (modal, aside, card). Omitted: content-sized. */
103
- height?: number | string
104
- /** Renders row-shaped skeletons. */
105
- loading?: boolean
106
- /** Skeleton rows while loading. Default 5. */
107
- loadingRows?: number
108
- /**
109
- * The empty state, an `EmptyState` in a ring-edged tile that sizes to its content (no void in a
110
- * bounded `height`). Default: "Nothing has happened yet" with a one-line why.
111
- */
112
- empty?: { title: string; description?: string; action?: ReactNode }
113
- }
68
+ export type EventListProps = BasaltProps &
69
+ DataAttributes & {
70
+ /** Accessible name of the list. Default "Events". */
71
+ label?: string
72
+ /** Events in display order — kept as given, never re-sorted. `id`s must be unique within the list. */
73
+ items: readonly {
74
+ id: string
75
+ at: Date | number
76
+ actor?: ReactNode
77
+ title: ReactNode
78
+ body?: ReactNode
79
+ /** A glyph or avatar in the leading column. */
80
+ leading?: ReactNode
81
+ chips?: ReactNode
82
+ }[]
83
+ /** `feed`: one clamped line, about 52 px a two-line row. `timeline`: a rail, full sentences, body and chips in full. */
84
+ density?: 'feed' | 'timeline'
85
+ /** The 1 px line through the leading column joining rows within a day group. Default: `density === 'timeline'`. */
86
+ rail?: boolean
87
+ /** Day headers (`micro` mono, muted, with the row count) or one flat list. Default `day`. */
88
+ group?: 'day' | 'none'
89
+ /**
90
+ * The instant "Today" and relative times are measured from. Default: the client clock, read once
91
+ * after mount; until then (the server render, the hydrating paint) days read as dates and a
92
+ * `relative` time as a date-time, so server and client markup match.
93
+ */
94
+ now?: number | Date
95
+ /** Overrides the `Today` / `Yesterday` / short-date header text. Without a clock yet, `now` is the day itself. */
96
+ dayLabel?: (day: Date, now: Date) => string
97
+ /**
98
+ * The time column. Default `clock` when grouped by day, `date-time` when not. A function formats it
99
+ * yourself; one returning an empty string renders no time for that row (an untimed entry).
100
+ */
101
+ time?: 'clock' | 'relative' | 'date-time' | ((at: Date) => string)
102
+ /** Which end of `items` is earlier. Does not sort. Default `newest-first`. */
103
+ order?: 'newest-first' | 'oldest-first'
104
+ /**
105
+ * A quiet "Show earlier (N)" control at the earlier end (bottom for newest-first, top for
106
+ * oldest-first). With `height`, prepending (oldest-first) keeps the visible row where it is and a
107
+ * list opens on its newest end; a content-sized list leaves scrolling to the page.
108
+ */
109
+ earlier?: { onLoad: () => void; loading?: boolean; remaining?: number }
110
+ /** The list owns a scroll node of this height (modal, aside, card). Omitted: content-sized. */
111
+ height?: number | string
112
+ /** Renders row-shaped skeletons. */
113
+ loading?: boolean
114
+ /** Skeleton rows while loading. Default: the rows `items` holds now (a refetch, capped at 30), else 5. */
115
+ loadingRows?: number
116
+ /**
117
+ * The empty state, an `EmptyState` in a ring-edged tile that sizes to its content (no void in a
118
+ * bounded `height`). Default: "Nothing has happened yet" with a one-line why.
119
+ */
120
+ empty?: { title: string; description?: string; action?: ReactNode }
121
+ }
114
122
 
115
123
  const subscribeNever = (): (() => void) => () => {}
116
124
 
@@ -154,10 +162,11 @@ export function EventList({
154
162
  earlier,
155
163
  height,
156
164
  loading = false,
157
- loadingRows = 5,
165
+ loadingRows,
158
166
  empty = DEFAULT_EMPTY,
159
167
  className,
160
168
  style,
169
+ ...rest
161
170
  }: EventListProps) {
162
171
  const clock = useClientClock()
163
172
  // The scroll node as state, so a windowed list can wait for it (see `VirtualRows` `scrollRoot`).
@@ -181,15 +190,18 @@ export function EventList({
181
190
  const plainBefore = usePlainBefore(hasRows, virtualised)
182
191
  usePrependAnchor(scrollEl, opensAtEnd && hasRows && !virtualised, items)
183
192
  useOpenAtEnd(scrollEl, opensAtEnd && hasRows && !virtualised, items.length)
193
+ useRowBoundary(scrollEl, opensAtEnd && hasRows && !virtualised)
184
194
  useScrolledEdge(ownScroll ? scrollEl : null)
185
- useHeldHeight(scrollEl, !hasRows ? 'none' : virtualised ? 'windowed' : 'plain')
195
+ useHeldHeight(
196
+ scrollEl,
197
+ loading ? 'loading' : !hasRows ? 'none' : virtualised ? 'windowed' : 'plain',
198
+ )
186
199
 
187
200
  const control =
188
201
  earlier === undefined || !hasRows ? null : (
189
202
  <div className={classes.earlier} data-end={oldestFirst ? 'top' : 'bottom'}>
190
203
  <Button
191
- variant="subtle"
192
- color="gray"
204
+ variant="default"
193
205
  size="compact-sm"
194
206
  className={classes.earlierButton}
195
207
  loading={earlier.loading === true}
@@ -203,9 +215,14 @@ export function EventList({
203
215
  let content: ReactNode
204
216
  if (loading) {
205
217
  content = (
206
- <div aria-busy="true">
218
+ <div aria-busy="true" className={classes.skeleton}>
207
219
  <VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
208
- <SkeletonRows count={loadingRows} ctx={ctx} grouped={grouped} height={height} />
220
+ <SkeletonRows
221
+ count={skeletonRowCount(loadingRows, items.length)}
222
+ ctx={ctx}
223
+ grouped={grouped}
224
+ height={height}
225
+ />
209
226
  </div>
210
227
  )
211
228
  } else if (items.length === 0) {
@@ -290,9 +307,19 @@ export function EventList({
290
307
 
291
308
  // The box keeps its height for rows and skeletons; an empty state sizes to its content.
292
309
  const boxed = ownScroll && (loading || items.length > 0)
293
- const scrollStyle: CSSProperties | undefined = boxed ? { height } : undefined
310
+ // `--event-list-trim` is set by `useRowBoundary`: the box gives up the remainder of a row it would cut.
311
+ const scrollStyle: CSSProperties | undefined = boxed
312
+ ? {
313
+ height: `calc(${typeof height === 'number' ? `${height}px` : String(height)} - var(--event-list-trim, 0px))`,
314
+ }
315
+ : undefined
294
316
  return (
295
- <div className={cx(classes.frame, className)} style={style} data-density={density}>
317
+ <div
318
+ {...pickDataAttributes(rest)}
319
+ className={cx(classes.frame, className)}
320
+ style={style}
321
+ data-density={density}
322
+ >
296
323
  {oldestFirst && control}
297
324
  {/* theme-allow raw-scroll-container — the list owns its scroll node when given a height, like the virtual seam. */}
298
325
  <div